@rshirohara/rekurke-repixe
Version:
rekurke plugin that turns kakuyomu novel format into pixiv novel format to support repixe.
32 lines (31 loc) • 973 B
JavaScript
import { toPxast } from "./lib/index.js";
/**
* Turn Kakuyomu novel format into Pixiv novel format.
*
* ##### Notes
*
* ###### Sigunature
*
* - if a processor is given, runs the (rekurke) plugins used on it with a
* kkast tree, then discards the result. (*bridge mode*)
* - otherwise, returns a kkast tree, the plugins used after `repixeRekurke`
* are rekurke plugins. (*mutate mode*)
*
* @overload
* @param {Processor} processor
* @param {Readonly<Options> | null | undefined} options
* @returns {TransformBridge}
*
* @overload
* @param {Readonly<Options> | null | undefined} options
* @returns {TransformMutate}
*/
export function rekurkeRepixe(destination, options) {
if (destination && "run" in destination) {
return async (tree, file) => {
const pxastTree = toPxast(tree, options);
await destination.run(pxastTree, file);
};
}
return (tree, _file) => toPxast(tree, destination ?? options);
}