1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-25 06:56:40 +07:00

#5 updated suggest template

This commit is contained in:
Fedor Katurov 2021-05-12 12:49:41 +07:00
parent 174dcac9e6
commit 1fe3d35540
3 changed files with 22 additions and 4 deletions

View file

@ -1,6 +1,7 @@
import extract from "remark-extract-frontmatter";
import frontmatter from "remark-frontmatter";
import stringify from "retext-stringify";
import stringify from "remark-stringify";
import textStringify from "retext-stringify";
import parser from "remark-parse";
import unified from "unified";
import { parse } from "yaml";
@ -58,6 +59,17 @@ export class Template<
return arg1 == arg2 ? options.fn(this) : options.inverse(this);
});
}
public static cleanText(text: string) {
const processor = unified()
.use(textStringify)
.use(frontmatter)
.use(extract, { yaml: parse })
.use(removeFrontmatter)
.use(parser);
return processor.processSync(text).contents.toString();
}
}
Template.registerHelpers();