mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-25 23:16:41 +07:00
#6 made better content stripping
This commit is contained in:
parent
31c6f100fc
commit
2c5f111c56
3 changed files with 11 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue