fix(plugins): html2text format

This commit is contained in:
Artemy 2024-05-14 15:21:39 +03:00
parent 41dab54df3
commit 1d47c66f7d
5 changed files with 18 additions and 13 deletions

View File

@ -19,10 +19,12 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@mozilla/readability": "^0.5.0", "@mozilla/readability": "^0.5.0",
"linkedom": "^0.18.0", "@txtdot/sdk": "workspace:*",
"@txtdot/sdk": "workspace:*" "html-to-text": "^9.0.5",
"linkedom": "^0.18.0"
}, },
"devDependencies": { "devDependencies": {
"@types/html-to-text": "^9.0.4",
"typescript": "^5.4.5" "typescript": "^5.4.5"
} }
} }

View File

@ -7,3 +7,9 @@ export const engineList = [
engines.SearX, engines.SearX,
engines.Readability, engines.Readability,
]; ];
import { compile } from 'html-to-text';
export const html2text = compile({
selectors: [{ selector: 'img', format: 'skip' }],
});

View File

@ -30,7 +30,6 @@
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"ejs": "^3.1.10", "ejs": "^3.1.10",
"fastify": "^4.26.2", "fastify": "^4.26.2",
"html-to-text": "^9.0.5",
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"ip-range-check": "^0.2.0", "ip-range-check": "^0.2.0",
"json-schema-to-ts": "^3.0.1", "json-schema-to-ts": "^3.0.1",
@ -41,7 +40,6 @@
"devDependencies": { "devDependencies": {
"@types/dompurify": "^3.0.5", "@types/dompurify": "^3.0.5",
"@types/ejs": "^3.1.5", "@types/ejs": "^3.1.5",
"@types/html-to-text": "^9.0.4",
"@types/jsdom": "^21.1.6", "@types/jsdom": "^21.1.6",
"@types/micromatch": "^4.0.7", "@types/micromatch": "^4.0.7",
"clean-css-cli": "^5.6.3", "clean-css-cli": "^5.6.3",

View File

@ -1,6 +1,5 @@
import { IAppConfig } from '../types/pluginConfig'; import { IAppConfig } from '../types/pluginConfig';
import { engineList } from '@txtdot/plugins'; import { engineList, html2text } from '@txtdot/plugins';
import { compile } from 'html-to-text';
/** /**
* Configuration of plugins * Configuration of plugins
@ -8,7 +7,7 @@ import { compile } from 'html-to-text';
*/ */
const plugin_config: IAppConfig = { const plugin_config: IAppConfig = {
engines: [...engineList], engines: [...engineList],
html2text: compile(), html2text,
}; };
export default plugin_config; export default plugin_config;

View File

@ -41,10 +41,16 @@ importers:
'@txtdot/sdk': '@txtdot/sdk':
specifier: workspace:* specifier: workspace:*
version: link:../sdk version: link:../sdk
html-to-text:
specifier: ^9.0.5
version: 9.0.5
linkedom: linkedom:
specifier: ^0.18.0 specifier: ^0.18.0
version: 0.18.0 version: 0.18.0
devDependencies: devDependencies:
'@types/html-to-text':
specifier: ^9.0.4
version: 9.0.4
typescript: typescript:
specifier: ^5.4.5 specifier: ^5.4.5
version: 5.4.5 version: 5.4.5
@ -103,9 +109,6 @@ importers:
fastify: fastify:
specifier: ^4.26.2 specifier: ^4.26.2
version: 4.27.0 version: 4.27.0
html-to-text:
specifier: ^9.0.5
version: 9.0.5
iconv-lite: iconv-lite:
specifier: ^0.6.3 specifier: ^0.6.3
version: 0.6.3 version: 0.6.3
@ -131,9 +134,6 @@ importers:
'@types/ejs': '@types/ejs':
specifier: ^3.1.5 specifier: ^3.1.5
version: 3.1.5 version: 3.1.5
'@types/html-to-text':
specifier: ^9.0.4
version: 9.0.4
'@types/jsdom': '@types/jsdom':
specifier: ^21.1.6 specifier: ^21.1.6
version: 21.1.6 version: 21.1.6