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

#6 made better content stripping

This commit is contained in:
Fedor Katurov 2021-05-13 14:07:56 +07:00
parent 31c6f100fc
commit 2c5f111c56
3 changed files with 11 additions and 4 deletions

View file

@ -1,13 +1,13 @@
import extract from "remark-extract-frontmatter";
import frontmatter from "remark-frontmatter";
import stringify from "remark-stringify";
import textStringify from "retext-stringify";
import parser from "remark-parse";
import unified from "unified";
import { parse } from "yaml";
import toVFile from "to-vfile";
import path from "path";
import hb from "handlebars";
import strip from "strip-markdown";
const removeFrontmatter = () => (tree) => {
tree.children = tree.children.filter((item) => item.type !== "yaml");
@ -62,11 +62,12 @@ export class Template<
public static cleanText(text: string) {
const processor = unified()
.use(textStringify)
.use(stringify)
.use(frontmatter)
.use(extract, { yaml: parse })
.use(removeFrontmatter)
.use(parser);
.use(parser)
.use(strip);
return processor.processSync(text).contents.toString();
}