mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46: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
|
@ -26,6 +26,7 @@
|
|||
"remark-parse-frontmatter": "^1.0.3",
|
||||
"retext": "^7.0.1",
|
||||
"socks-proxy-agent": "^5.0.0",
|
||||
"strip-markdown": "^4.0.0",
|
||||
"telegraf": "^4.3.0",
|
||||
"to-vfile": "^6.1.0",
|
||||
"typeorm": "^0.2.32",
|
||||
|
@ -39,9 +40,9 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/axios": "^0.14.0",
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/express": "^4.17.11",
|
||||
"@types/handlebars": "^4.1.0",
|
||||
"@types/node": "^14.14.37",
|
||||
"@types/ramda": "^0.27.39",
|
||||
"@types/winston": "^2.4.4",
|
||||
"@types/yargs": "^16.0.1",
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -1686,6 +1686,11 @@ strip-ansi@^6.0.0:
|
|||
dependencies:
|
||||
ansi-regex "^5.0.0"
|
||||
|
||||
strip-markdown@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/strip-markdown/-/strip-markdown-4.0.0.tgz#1f48aeb5ce81b646487d9f8fbdc18f8bf1416ba2"
|
||||
integrity sha512-jwoS5zwHNFjergQjg4RFzmdS4n5WOd5DXDIwRY0jye9ALYMscLWfwZVBMt4P/va5aRmm7Dlj6O4NjMuaD7609Q==
|
||||
|
||||
supports-color@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue