@diplodoc/transform 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.diplodoc.md +38 -0
- package/CHANGELOG.md +404 -0
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/README.ru.md +36 -0
- package/dist/css/yfm.css +736 -0
- package/dist/css/yfm.css.map +7 -0
- package/dist/css/yfm.min.css +2 -0
- package/dist/css/yfm.min.css.map +7 -0
- package/dist/js/code.d.ts +1 -0
- package/dist/js/cut.d.ts +1 -0
- package/dist/js/index.d.ts +5 -0
- package/dist/js/polyfill.d.ts +1 -0
- package/dist/js/tabs.d.ts +1 -0
- package/dist/js/term/index.d.ts +1 -0
- package/dist/js/term/utils.d.ts +10 -0
- package/dist/js/utils.d.ts +2 -0
- package/dist/js/yfm.js +432 -0
- package/dist/js/yfm.js.map +7 -0
- package/dist/js/yfm.min.js +2 -0
- package/dist/js/yfm.min.js.map +7 -0
- package/lib/getObject.d.ts +2 -0
- package/lib/getObject.js +11 -0
- package/lib/getObject.js.map +1 -0
- package/lib/headings.d.ts +4 -0
- package/lib/headings.js +73 -0
- package/lib/headings.js.map +1 -0
- package/lib/highlight.d.ts +3 -0
- package/lib/highlight.js +29 -0
- package/lib/highlight.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +35 -0
- package/lib/index.js.map +1 -0
- package/lib/liquid/conditions.d.ts +4 -0
- package/lib/liquid/conditions.js +181 -0
- package/lib/liquid/conditions.js.map +1 -0
- package/lib/liquid/cycles.d.ts +4 -0
- package/lib/liquid/cycles.js +160 -0
- package/lib/liquid/cycles.js.map +1 -0
- package/lib/liquid/errors.d.ts +3 -0
- package/lib/liquid/errors.js +13 -0
- package/lib/liquid/errors.js.map +1 -0
- package/lib/liquid/evaluation.d.ts +3 -0
- package/lib/liquid/evaluation.js +138 -0
- package/lib/liquid/evaluation.js.map +1 -0
- package/lib/liquid/filters.d.ts +9 -0
- package/lib/liquid/filters.js +22 -0
- package/lib/liquid/filters.js.map +1 -0
- package/lib/liquid/index.d.ts +9 -0
- package/lib/liquid/index.js +87 -0
- package/lib/liquid/index.js.map +1 -0
- package/lib/liquid/lexical.d.ts +14 -0
- package/lib/liquid/lexical.js +79 -0
- package/lib/liquid/lexical.js.map +1 -0
- package/lib/liquid/services/argv.d.ts +15 -0
- package/lib/liquid/services/argv.js +17 -0
- package/lib/liquid/services/argv.js.map +1 -0
- package/lib/liquid/sourceMap.d.ts +24 -0
- package/lib/liquid/sourceMap.js +56 -0
- package/lib/liquid/sourceMap.js.map +1 -0
- package/lib/liquid/substitutions.d.ts +2 -0
- package/lib/liquid/substitutions.js +36 -0
- package/lib/liquid/substitutions.js.map +1 -0
- package/lib/liquid/utils.d.ts +8 -0
- package/lib/liquid/utils.js +24 -0
- package/lib/liquid/utils.js.map +1 -0
- package/lib/log.d.ts +18 -0
- package/lib/log.js +54 -0
- package/lib/log.js.map +1 -0
- package/lib/md.d.ts +14 -0
- package/lib/md.js +96 -0
- package/lib/md.js.map +1 -0
- package/lib/plugins/anchors/collect.d.ts +5 -0
- package/lib/plugins/anchors/collect.js +81 -0
- package/lib/plugins/anchors/collect.js.map +1 -0
- package/lib/plugins/anchors/constants.d.ts +2 -0
- package/lib/plugins/anchors/constants.js +6 -0
- package/lib/plugins/anchors/constants.js.map +1 -0
- package/lib/plugins/anchors/index.d.ts +7 -0
- package/lib/plugins/anchors/index.js +134 -0
- package/lib/plugins/anchors/index.js.map +1 -0
- package/lib/plugins/changelog/collect.d.ts +8 -0
- package/lib/plugins/changelog/collect.js +50 -0
- package/lib/plugins/changelog/collect.js.map +1 -0
- package/lib/plugins/changelog/index.d.ts +6 -0
- package/lib/plugins/changelog/index.js +131 -0
- package/lib/plugins/changelog/index.js.map +1 -0
- package/lib/plugins/changelog/types.d.ts +10 -0
- package/lib/plugins/changelog/types.js +3 -0
- package/lib/plugins/changelog/types.js.map +1 -0
- package/lib/plugins/checkbox/checkbox.d.ts +7 -0
- package/lib/plugins/checkbox/checkbox.js +91 -0
- package/lib/plugins/checkbox/checkbox.js.map +1 -0
- package/lib/plugins/checkbox/index.d.ts +8 -0
- package/lib/plugins/checkbox/index.js +12 -0
- package/lib/plugins/checkbox/index.js.map +1 -0
- package/lib/plugins/code.d.ts +3 -0
- package/lib/plugins/code.js +61 -0
- package/lib/plugins/code.js.map +1 -0
- package/lib/plugins/cut.d.ts +3 -0
- package/lib/plugins/cut.js +70 -0
- package/lib/plugins/cut.js.map +1 -0
- package/lib/plugins/deflist.d.ts +3 -0
- package/lib/plugins/deflist.js +8 -0
- package/lib/plugins/deflist.js.map +1 -0
- package/lib/plugins/file/const.d.ts +27 -0
- package/lib/plugins/file/const.js +47 -0
- package/lib/plugins/file/const.js.map +1 -0
- package/lib/plugins/file/file.d.ts +8 -0
- package/lib/plugins/file/file.js +63 -0
- package/lib/plugins/file/file.js.map +1 -0
- package/lib/plugins/file/index.d.ts +4 -0
- package/lib/plugins/file/index.js +9 -0
- package/lib/plugins/file/index.js.map +1 -0
- package/lib/plugins/images/collect.d.ts +8 -0
- package/lib/plugins/images/collect.js +43 -0
- package/lib/plugins/images/collect.js.map +1 -0
- package/lib/plugins/images/index.d.ts +10 -0
- package/lib/plugins/images/index.js +81 -0
- package/lib/plugins/images/index.js.map +1 -0
- package/lib/plugins/imsize/const.d.ts +7 -0
- package/lib/plugins/imsize/const.js +12 -0
- package/lib/plugins/imsize/const.js.map +1 -0
- package/lib/plugins/imsize/helpers.d.ts +6 -0
- package/lib/plugins/imsize/helpers.js +64 -0
- package/lib/plugins/imsize/helpers.js.map +1 -0
- package/lib/plugins/imsize/index.d.ts +8 -0
- package/lib/plugins/imsize/index.js +12 -0
- package/lib/plugins/imsize/index.js.map +1 -0
- package/lib/plugins/imsize/plugin.d.ts +3 -0
- package/lib/plugins/imsize/plugin.js +188 -0
- package/lib/plugins/imsize/plugin.js.map +1 -0
- package/lib/plugins/includes/collect.d.ts +8 -0
- package/lib/plugins/includes/collect.js +49 -0
- package/lib/plugins/includes/collect.js.map +1 -0
- package/lib/plugins/includes/index.d.ts +8 -0
- package/lib/plugins/includes/index.js +98 -0
- package/lib/plugins/includes/index.js.map +1 -0
- package/lib/plugins/links/collect.d.ts +7 -0
- package/lib/plugins/links/collect.js +74 -0
- package/lib/plugins/links/collect.js.map +1 -0
- package/lib/plugins/links/constants.d.ts +1 -0
- package/lib/plugins/links/constants.js +5 -0
- package/lib/plugins/links/constants.js.map +1 -0
- package/lib/plugins/links/index.d.ts +24 -0
- package/lib/plugins/links/index.js +178 -0
- package/lib/plugins/links/index.js.map +1 -0
- package/lib/plugins/meta.d.ts +3 -0
- package/lib/plugins/meta.js +8 -0
- package/lib/plugins/meta.js.map +1 -0
- package/lib/plugins/monospace.d.ts +3 -0
- package/lib/plugins/monospace.js +109 -0
- package/lib/plugins/monospace.js.map +1 -0
- package/lib/plugins/notes.d.ts +3 -0
- package/lib/plugins/notes.js +103 -0
- package/lib/plugins/notes.js.map +1 -0
- package/lib/plugins/sup.d.ts +3 -0
- package/lib/plugins/sup.js +8 -0
- package/lib/plugins/sup.js.map +1 -0
- package/lib/plugins/table/index.d.ts +3 -0
- package/lib/plugins/table/index.js +215 -0
- package/lib/plugins/table/index.js.map +1 -0
- package/lib/plugins/tabs.d.ts +4 -0
- package/lib/plugins/tabs.js +4 -0
- package/lib/plugins/tabs.js.map +1 -0
- package/lib/plugins/term/constants.d.ts +1 -0
- package/lib/plugins/term/constants.js +5 -0
- package/lib/plugins/term/constants.js.map +1 -0
- package/lib/plugins/term/index.d.ts +3 -0
- package/lib/plugins/term/index.js +108 -0
- package/lib/plugins/term/index.js.map +1 -0
- package/lib/plugins/term/termDefinitions.d.ts +4 -0
- package/lib/plugins/term/termDefinitions.js +125 -0
- package/lib/plugins/term/termDefinitions.js.map +1 -0
- package/lib/plugins/typings.d.ts +12 -0
- package/lib/plugins/typings.js +3 -0
- package/lib/plugins/typings.js.map +1 -0
- package/lib/plugins/utils.d.ts +6 -0
- package/lib/plugins/utils.js +30 -0
- package/lib/plugins/utils.js.map +1 -0
- package/lib/plugins/video/const.d.ts +10 -0
- package/lib/plugins/video/const.js +22 -0
- package/lib/plugins/video/const.js.map +1 -0
- package/lib/plugins/video/index.d.ts +8 -0
- package/lib/plugins/video/index.js +104 -0
- package/lib/plugins/video/index.js.map +1 -0
- package/lib/plugins/video/parsers.d.ts +6 -0
- package/lib/plugins/video/parsers.js +64 -0
- package/lib/plugins/video/parsers.js.map +1 -0
- package/lib/plugins/video/types.d.ts +34 -0
- package/lib/plugins/video/types.js +3 -0
- package/lib/plugins/video/types.js.map +1 -0
- package/lib/plugins/video/utils.d.ts +2 -0
- package/lib/plugins/video/utils.js +25 -0
- package/lib/plugins/video/utils.js.map +1 -0
- package/lib/plugins.d.ts +3 -0
- package/lib/plugins.js +36 -0
- package/lib/plugins.js.map +1 -0
- package/lib/sanitize.d.ts +12 -0
- package/lib/sanitize.js +572 -0
- package/lib/sanitize.js.map +1 -0
- package/lib/title.d.ts +7 -0
- package/lib/title.js +18 -0
- package/lib/title.js.map +1 -0
- package/lib/typings.d.ts +57 -0
- package/lib/typings.js +3 -0
- package/lib/typings.js.map +1 -0
- package/lib/utils.d.ts +13 -0
- package/lib/utils.js +79 -0
- package/lib/utils.js.map +1 -0
- package/lib/utilsFS.d.ts +27 -0
- package/lib/utilsFS.js +89 -0
- package/lib/utilsFS.js.map +1 -0
- package/lib/yfmlint/index.d.ts +26 -0
- package/lib/yfmlint/index.js +72 -0
- package/lib/yfmlint/index.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/index.d.ts +9 -0
- package/lib/yfmlint/markdownlint-custom-rule/index.js +22 -0
- package/lib/yfmlint/markdownlint-custom-rule/index.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.js +33 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.js +33 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.js +29 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.js +28 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.js.map +1 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.d.ts +2 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.js +47 -0
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.js.map +1 -0
- package/lib/yfmlint/typings.d.ts +12 -0
- package/lib/yfmlint/typings.js +3 -0
- package/lib/yfmlint/typings.js.map +1 -0
- package/lib/yfmlint/utils.d.ts +9 -0
- package/lib/yfmlint/utils.js +22 -0
- package/lib/yfmlint/utils.js.map +1 -0
- package/lib/yfmlint/yfmlint.d.ts +3 -0
- package/lib/yfmlint/yfmlint.js +69 -0
- package/lib/yfmlint/yfmlint.js.map +1 -0
- package/package.json +106 -0
- package/src/.eslintrc +10 -0
- package/src/js/code.ts +65 -0
- package/src/js/cut.ts +57 -0
- package/src/js/index.ts +6 -0
- package/src/js/polyfill.js +27 -0
- package/src/js/term/index.ts +79 -0
- package/src/js/term/utils.ts +151 -0
- package/src/js/utils.ts +9 -0
- package/src/scss/_anchor.scss +33 -0
- package/src/scss/_code.scss +23 -0
- package/src/scss/_common.scss +407 -0
- package/src/scss/_cut.scss +42 -0
- package/src/scss/_file.scss +35 -0
- package/src/scss/_highlight.scss +96 -0
- package/src/scss/_note.scss +73 -0
- package/src/scss/_print.scss +20 -0
- package/src/scss/_term.scss +79 -0
- package/src/scss/_variables.scss +16 -0
- package/src/scss/yfm.scss +11 -0
- package/src/transform/getObject.ts +10 -0
- package/src/transform/headings.ts +88 -0
- package/src/transform/highlight.ts +33 -0
- package/src/transform/index.ts +50 -0
- package/src/transform/liquid/conditions.ts +259 -0
- package/src/transform/liquid/cycles.ts +244 -0
- package/src/transform/liquid/errors.ts +10 -0
- package/src/transform/liquid/evaluation.ts +145 -0
- package/src/transform/liquid/filters.ts +19 -0
- package/src/transform/liquid/index.ts +141 -0
- package/src/transform/liquid/lexical.ts +86 -0
- package/src/transform/liquid/services/argv.ts +23 -0
- package/src/transform/liquid/sourceMap.ts +72 -0
- package/src/transform/liquid/substitutions.ts +40 -0
- package/src/transform/liquid/utils.ts +30 -0
- package/src/transform/log.ts +60 -0
- package/src/transform/md.ts +123 -0
- package/src/transform/plugins/anchors/collect.ts +101 -0
- package/src/transform/plugins/anchors/constants.ts +2 -0
- package/src/transform/plugins/anchors/index.ts +166 -0
- package/src/transform/plugins/changelog/collect.ts +66 -0
- package/src/transform/plugins/changelog/index.ts +164 -0
- package/src/transform/plugins/changelog/types.ts +10 -0
- package/src/transform/plugins/checkbox/checkbox.ts +107 -0
- package/src/transform/plugins/checkbox/index.ts +15 -0
- package/src/transform/plugins/code.ts +79 -0
- package/src/transform/plugins/cut.ts +98 -0
- package/src/transform/plugins/deflist.ts +5 -0
- package/src/transform/plugins/file/README.md +34 -0
- package/src/transform/plugins/file/const.ts +46 -0
- package/src/transform/plugins/file/file.ts +82 -0
- package/src/transform/plugins/file/index.ts +10 -0
- package/src/transform/plugins/images/collect.ts +60 -0
- package/src/transform/plugins/images/index.ts +119 -0
- package/src/transform/plugins/imsize/const.ts +7 -0
- package/src/transform/plugins/imsize/helpers.ts +75 -0
- package/src/transform/plugins/imsize/index.ts +14 -0
- package/src/transform/plugins/imsize/plugin.ts +214 -0
- package/src/transform/plugins/includes/collect.ts +73 -0
- package/src/transform/plugins/includes/index.ts +127 -0
- package/src/transform/plugins/links/collect.ts +92 -0
- package/src/transform/plugins/links/constants.ts +1 -0
- package/src/transform/plugins/links/index.ts +218 -0
- package/src/transform/plugins/meta.ts +5 -0
- package/src/transform/plugins/monospace.ts +141 -0
- package/src/transform/plugins/notes.ts +134 -0
- package/src/transform/plugins/sup.ts +5 -0
- package/src/transform/plugins/table/index.ts +290 -0
- package/src/transform/plugins/tabs.ts +3 -0
- package/src/transform/plugins/term/constants.ts +1 -0
- package/src/transform/plugins/term/index.ts +139 -0
- package/src/transform/plugins/term/termDefinitions.ts +177 -0
- package/src/transform/plugins/typings.ts +14 -0
- package/src/transform/plugins/utils.ts +38 -0
- package/src/transform/plugins/video/const.ts +20 -0
- package/src/transform/plugins/video/index.ts +134 -0
- package/src/transform/plugins/video/parsers.ts +65 -0
- package/src/transform/plugins/video/types.ts +27 -0
- package/src/transform/plugins/video/utils.ts +24 -0
- package/src/transform/plugins.ts +35 -0
- package/src/transform/sanitize.ts +596 -0
- package/src/transform/title.ts +22 -0
- package/src/transform/typings.ts +64 -0
- package/src/transform/utils.ts +91 -0
- package/src/transform/utilsFS.ts +128 -0
- package/src/transform/yfmlint/README.md +48 -0
- package/src/transform/yfmlint/index.ts +124 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/index.ts +9 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +36 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts +33 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts +33 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts +27 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts +27 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts +26 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +28 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm008.ts +26 -0
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm009.ts +54 -0
- package/src/transform/yfmlint/typings.ts +13 -0
- package/src/transform/yfmlint/utils.ts +31 -0
- package/src/transform/yfmlint/yfmlint.ts +73 -0
package/lib/sanitize.js
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.defaultOptions = exports.defaultParseOptions = void 0;
|
|
30
|
+
const sanitize_html_1 = __importDefault(require("sanitize-html"));
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
const cssfilter_1 = __importDefault(require("cssfilter"));
|
|
33
|
+
const cheerio = __importStar(require("cheerio"));
|
|
34
|
+
const css_1 = __importDefault(require("css"));
|
|
35
|
+
const htmlTags = [
|
|
36
|
+
'a',
|
|
37
|
+
'abbr',
|
|
38
|
+
'acronym',
|
|
39
|
+
'address',
|
|
40
|
+
'area',
|
|
41
|
+
'article',
|
|
42
|
+
'aside',
|
|
43
|
+
'audio',
|
|
44
|
+
'b',
|
|
45
|
+
'bdi',
|
|
46
|
+
'bdo',
|
|
47
|
+
'big',
|
|
48
|
+
'blink',
|
|
49
|
+
'blockquote',
|
|
50
|
+
'body',
|
|
51
|
+
'br',
|
|
52
|
+
'button',
|
|
53
|
+
'canvas',
|
|
54
|
+
'caption',
|
|
55
|
+
'center',
|
|
56
|
+
'cite',
|
|
57
|
+
'code',
|
|
58
|
+
'col',
|
|
59
|
+
'colgroup',
|
|
60
|
+
'content',
|
|
61
|
+
'data',
|
|
62
|
+
'datalist',
|
|
63
|
+
'dd',
|
|
64
|
+
'decorator',
|
|
65
|
+
'del',
|
|
66
|
+
'details',
|
|
67
|
+
'dfn',
|
|
68
|
+
'dialog',
|
|
69
|
+
'dir',
|
|
70
|
+
'div',
|
|
71
|
+
'dl',
|
|
72
|
+
'dt',
|
|
73
|
+
'element',
|
|
74
|
+
'em',
|
|
75
|
+
'fieldset',
|
|
76
|
+
'figcaption',
|
|
77
|
+
'figure',
|
|
78
|
+
'font',
|
|
79
|
+
'footer',
|
|
80
|
+
'h1',
|
|
81
|
+
'h2',
|
|
82
|
+
'h3',
|
|
83
|
+
'h4',
|
|
84
|
+
'h5',
|
|
85
|
+
'h6',
|
|
86
|
+
'head',
|
|
87
|
+
'header',
|
|
88
|
+
'hgroup',
|
|
89
|
+
'hr',
|
|
90
|
+
'html',
|
|
91
|
+
'i',
|
|
92
|
+
'img',
|
|
93
|
+
'input',
|
|
94
|
+
'ins',
|
|
95
|
+
'kbd',
|
|
96
|
+
'label',
|
|
97
|
+
'legend',
|
|
98
|
+
'li',
|
|
99
|
+
'main',
|
|
100
|
+
'map',
|
|
101
|
+
'mark',
|
|
102
|
+
'marquee',
|
|
103
|
+
'menu',
|
|
104
|
+
'menuitem',
|
|
105
|
+
'meter',
|
|
106
|
+
'nav',
|
|
107
|
+
'nobr',
|
|
108
|
+
'ol',
|
|
109
|
+
'optgroup',
|
|
110
|
+
'option',
|
|
111
|
+
'output',
|
|
112
|
+
'p',
|
|
113
|
+
'picture',
|
|
114
|
+
'pre',
|
|
115
|
+
'progress',
|
|
116
|
+
'q',
|
|
117
|
+
'rp',
|
|
118
|
+
'rt',
|
|
119
|
+
'ruby',
|
|
120
|
+
's',
|
|
121
|
+
'samp',
|
|
122
|
+
'section',
|
|
123
|
+
'select',
|
|
124
|
+
'shadow',
|
|
125
|
+
'small',
|
|
126
|
+
'source',
|
|
127
|
+
'spacer',
|
|
128
|
+
'span',
|
|
129
|
+
'strike',
|
|
130
|
+
'strong',
|
|
131
|
+
'sub',
|
|
132
|
+
'summary',
|
|
133
|
+
'sup',
|
|
134
|
+
'table',
|
|
135
|
+
'tbody',
|
|
136
|
+
'td',
|
|
137
|
+
'template',
|
|
138
|
+
'textarea',
|
|
139
|
+
'tfoot',
|
|
140
|
+
'th',
|
|
141
|
+
'thead',
|
|
142
|
+
'time',
|
|
143
|
+
'tr',
|
|
144
|
+
'track',
|
|
145
|
+
'tt',
|
|
146
|
+
'u',
|
|
147
|
+
'ul',
|
|
148
|
+
'var',
|
|
149
|
+
'video',
|
|
150
|
+
'wbr',
|
|
151
|
+
'iframe',
|
|
152
|
+
'style',
|
|
153
|
+
];
|
|
154
|
+
const svgTags = [
|
|
155
|
+
'svg',
|
|
156
|
+
'altglyph',
|
|
157
|
+
'altglyphdef',
|
|
158
|
+
'altglyphitem',
|
|
159
|
+
'animatecolor',
|
|
160
|
+
'animatemotion',
|
|
161
|
+
'animatetransform',
|
|
162
|
+
'circle',
|
|
163
|
+
'clippath',
|
|
164
|
+
'defs',
|
|
165
|
+
'desc',
|
|
166
|
+
'ellipse',
|
|
167
|
+
'filter',
|
|
168
|
+
'font',
|
|
169
|
+
'g',
|
|
170
|
+
'glyph',
|
|
171
|
+
'glyphref',
|
|
172
|
+
'hkern',
|
|
173
|
+
'image',
|
|
174
|
+
'line',
|
|
175
|
+
'lineargradient',
|
|
176
|
+
'marker',
|
|
177
|
+
'mask',
|
|
178
|
+
'metadata',
|
|
179
|
+
'mpath',
|
|
180
|
+
'path',
|
|
181
|
+
'pattern',
|
|
182
|
+
'polygon',
|
|
183
|
+
'polyline',
|
|
184
|
+
'radialgradient',
|
|
185
|
+
'rect',
|
|
186
|
+
'stop',
|
|
187
|
+
'switch',
|
|
188
|
+
'symbol',
|
|
189
|
+
'text',
|
|
190
|
+
'textpath',
|
|
191
|
+
'title',
|
|
192
|
+
'tref',
|
|
193
|
+
'tspan',
|
|
194
|
+
'view',
|
|
195
|
+
'vkern',
|
|
196
|
+
'animate',
|
|
197
|
+
];
|
|
198
|
+
const htmlAttrs = [
|
|
199
|
+
'accept',
|
|
200
|
+
'action',
|
|
201
|
+
'align',
|
|
202
|
+
'alt',
|
|
203
|
+
'autocapitalize',
|
|
204
|
+
'autocomplete',
|
|
205
|
+
'autopictureinpicture',
|
|
206
|
+
'autoplay',
|
|
207
|
+
'background',
|
|
208
|
+
'bgcolor',
|
|
209
|
+
'border',
|
|
210
|
+
'capture',
|
|
211
|
+
'cellpadding',
|
|
212
|
+
'cellspacing',
|
|
213
|
+
'checked',
|
|
214
|
+
'cite',
|
|
215
|
+
'class',
|
|
216
|
+
'clear',
|
|
217
|
+
'color',
|
|
218
|
+
'cols',
|
|
219
|
+
'colspan',
|
|
220
|
+
'controls',
|
|
221
|
+
'controlslist',
|
|
222
|
+
'coords',
|
|
223
|
+
'crossorigin',
|
|
224
|
+
'datetime',
|
|
225
|
+
'decoding',
|
|
226
|
+
'default',
|
|
227
|
+
'dir',
|
|
228
|
+
'disabled',
|
|
229
|
+
'disablepictureinpicture',
|
|
230
|
+
'disableremoteplayback',
|
|
231
|
+
'download',
|
|
232
|
+
'draggable',
|
|
233
|
+
'enctype',
|
|
234
|
+
'enterkeyhint',
|
|
235
|
+
'face',
|
|
236
|
+
'for',
|
|
237
|
+
'headers',
|
|
238
|
+
'height',
|
|
239
|
+
'hidden',
|
|
240
|
+
'high',
|
|
241
|
+
'href',
|
|
242
|
+
'hreflang',
|
|
243
|
+
'id',
|
|
244
|
+
'inputmode',
|
|
245
|
+
'integrity',
|
|
246
|
+
'ismap',
|
|
247
|
+
'kind',
|
|
248
|
+
'label',
|
|
249
|
+
'lang',
|
|
250
|
+
'list',
|
|
251
|
+
'loading',
|
|
252
|
+
'loop',
|
|
253
|
+
'low',
|
|
254
|
+
'max',
|
|
255
|
+
'maxlength',
|
|
256
|
+
'media',
|
|
257
|
+
'method',
|
|
258
|
+
'min',
|
|
259
|
+
'minlength',
|
|
260
|
+
'multiple',
|
|
261
|
+
'muted',
|
|
262
|
+
'name',
|
|
263
|
+
'nonce',
|
|
264
|
+
'noshade',
|
|
265
|
+
'novalidate',
|
|
266
|
+
'nowrap',
|
|
267
|
+
'open',
|
|
268
|
+
'optimum',
|
|
269
|
+
'pattern',
|
|
270
|
+
'placeholder',
|
|
271
|
+
'playsinline',
|
|
272
|
+
'poster',
|
|
273
|
+
'preload',
|
|
274
|
+
'pubdate',
|
|
275
|
+
'radiogroup',
|
|
276
|
+
'readonly',
|
|
277
|
+
'rel',
|
|
278
|
+
'required',
|
|
279
|
+
'rev',
|
|
280
|
+
'reversed',
|
|
281
|
+
'role',
|
|
282
|
+
'rows',
|
|
283
|
+
'rowspan',
|
|
284
|
+
'spellcheck',
|
|
285
|
+
'scope',
|
|
286
|
+
'selected',
|
|
287
|
+
'shape',
|
|
288
|
+
'size',
|
|
289
|
+
'sizes',
|
|
290
|
+
'span',
|
|
291
|
+
'srclang',
|
|
292
|
+
'start',
|
|
293
|
+
'src',
|
|
294
|
+
'srcset',
|
|
295
|
+
'step',
|
|
296
|
+
'style',
|
|
297
|
+
'summary',
|
|
298
|
+
'tabindex',
|
|
299
|
+
'title',
|
|
300
|
+
'translate',
|
|
301
|
+
'type',
|
|
302
|
+
'usemap',
|
|
303
|
+
'valign',
|
|
304
|
+
'value',
|
|
305
|
+
'width',
|
|
306
|
+
'xmlns',
|
|
307
|
+
'slot',
|
|
308
|
+
'frameborder',
|
|
309
|
+
'scrolling',
|
|
310
|
+
'allow',
|
|
311
|
+
'target',
|
|
312
|
+
'attributeName',
|
|
313
|
+
'aria-hidden',
|
|
314
|
+
'referrerpolicy',
|
|
315
|
+
'aria-describedby',
|
|
316
|
+
'data-*',
|
|
317
|
+
];
|
|
318
|
+
const svgAttrs = [
|
|
319
|
+
'viewBox',
|
|
320
|
+
'accent-height',
|
|
321
|
+
'accumulate',
|
|
322
|
+
'additive',
|
|
323
|
+
'alignment-baseline',
|
|
324
|
+
'ascent',
|
|
325
|
+
'attributename',
|
|
326
|
+
'attributetype',
|
|
327
|
+
'azimuth',
|
|
328
|
+
'basefrequency',
|
|
329
|
+
'baseline-shift',
|
|
330
|
+
'begin',
|
|
331
|
+
'bias',
|
|
332
|
+
'by',
|
|
333
|
+
'class',
|
|
334
|
+
'clip',
|
|
335
|
+
'clippathunits',
|
|
336
|
+
'clip-path',
|
|
337
|
+
'clip-rule',
|
|
338
|
+
'color',
|
|
339
|
+
'color-interpolation',
|
|
340
|
+
'color-interpolation-filters',
|
|
341
|
+
'color-profile',
|
|
342
|
+
'color-rendering',
|
|
343
|
+
'cx',
|
|
344
|
+
'cy',
|
|
345
|
+
'd',
|
|
346
|
+
'dx',
|
|
347
|
+
'dy',
|
|
348
|
+
'diffuseconstant',
|
|
349
|
+
'direction',
|
|
350
|
+
'display',
|
|
351
|
+
'divisor',
|
|
352
|
+
'dur',
|
|
353
|
+
'edgemode',
|
|
354
|
+
'elevation',
|
|
355
|
+
'end',
|
|
356
|
+
'fill',
|
|
357
|
+
'fill-opacity',
|
|
358
|
+
'fill-rule',
|
|
359
|
+
'filter',
|
|
360
|
+
'filterunits',
|
|
361
|
+
'flood-color',
|
|
362
|
+
'flood-opacity',
|
|
363
|
+
'font-family',
|
|
364
|
+
'font-size',
|
|
365
|
+
'font-size-adjust',
|
|
366
|
+
'font-stretch',
|
|
367
|
+
'font-style',
|
|
368
|
+
'font-variant',
|
|
369
|
+
'font-weight',
|
|
370
|
+
'fx',
|
|
371
|
+
'fy',
|
|
372
|
+
'g1',
|
|
373
|
+
'g2',
|
|
374
|
+
'glyph-name',
|
|
375
|
+
'glyphref',
|
|
376
|
+
'gradientunits',
|
|
377
|
+
'gradienttransform',
|
|
378
|
+
'height',
|
|
379
|
+
'href',
|
|
380
|
+
'id',
|
|
381
|
+
'image-rendering',
|
|
382
|
+
'in',
|
|
383
|
+
'in2',
|
|
384
|
+
'k',
|
|
385
|
+
'k1',
|
|
386
|
+
'k2',
|
|
387
|
+
'k3',
|
|
388
|
+
'k4',
|
|
389
|
+
'kerning',
|
|
390
|
+
'keypoints',
|
|
391
|
+
'keysplines',
|
|
392
|
+
'keytimes',
|
|
393
|
+
'lang',
|
|
394
|
+
'lengthadjust',
|
|
395
|
+
'letter-spacing',
|
|
396
|
+
'kernelmatrix',
|
|
397
|
+
'kernelunitlength',
|
|
398
|
+
'lighting-color',
|
|
399
|
+
'local',
|
|
400
|
+
'marker-end',
|
|
401
|
+
'marker-mid',
|
|
402
|
+
'marker-start',
|
|
403
|
+
'markerheight',
|
|
404
|
+
'markerunits',
|
|
405
|
+
'markerwidth',
|
|
406
|
+
'maskcontentunits',
|
|
407
|
+
'maskunits',
|
|
408
|
+
'max',
|
|
409
|
+
'mask',
|
|
410
|
+
'media',
|
|
411
|
+
'method',
|
|
412
|
+
'mode',
|
|
413
|
+
'min',
|
|
414
|
+
'name',
|
|
415
|
+
'numoctaves',
|
|
416
|
+
'offset',
|
|
417
|
+
'operator',
|
|
418
|
+
'opacity',
|
|
419
|
+
'order',
|
|
420
|
+
'orient',
|
|
421
|
+
'orientation',
|
|
422
|
+
'origin',
|
|
423
|
+
'overflow',
|
|
424
|
+
'paint-order',
|
|
425
|
+
'path',
|
|
426
|
+
'pathlength',
|
|
427
|
+
'patterncontentunits',
|
|
428
|
+
'patterntransform',
|
|
429
|
+
'patternunits',
|
|
430
|
+
'points',
|
|
431
|
+
'preservealpha',
|
|
432
|
+
'preserveaspectratio',
|
|
433
|
+
'primitiveunits',
|
|
434
|
+
'r',
|
|
435
|
+
'rx',
|
|
436
|
+
'ry',
|
|
437
|
+
'radius',
|
|
438
|
+
'refx',
|
|
439
|
+
'refy',
|
|
440
|
+
'repeatcount',
|
|
441
|
+
'repeatdur',
|
|
442
|
+
'restart',
|
|
443
|
+
'result',
|
|
444
|
+
'rotate',
|
|
445
|
+
'scale',
|
|
446
|
+
'seed',
|
|
447
|
+
'shape-rendering',
|
|
448
|
+
'specularconstant',
|
|
449
|
+
'specularexponent',
|
|
450
|
+
'spreadmethod',
|
|
451
|
+
'startoffset',
|
|
452
|
+
'stddeviation',
|
|
453
|
+
'stitchtiles',
|
|
454
|
+
'stop-color',
|
|
455
|
+
'stop-opacity',
|
|
456
|
+
'stroke-dasharray',
|
|
457
|
+
'stroke-dashoffset',
|
|
458
|
+
'stroke-linecap',
|
|
459
|
+
'stroke-linejoin',
|
|
460
|
+
'stroke-miterlimit',
|
|
461
|
+
'stroke-opacity',
|
|
462
|
+
'stroke',
|
|
463
|
+
'stroke-width',
|
|
464
|
+
'style',
|
|
465
|
+
'surfacescale',
|
|
466
|
+
'systemlanguage',
|
|
467
|
+
'tabindex',
|
|
468
|
+
'targetx',
|
|
469
|
+
'targety',
|
|
470
|
+
'transform',
|
|
471
|
+
'text-anchor',
|
|
472
|
+
'text-decoration',
|
|
473
|
+
'text-rendering',
|
|
474
|
+
'textlength',
|
|
475
|
+
'type',
|
|
476
|
+
'u1',
|
|
477
|
+
'u2',
|
|
478
|
+
'unicode',
|
|
479
|
+
'values',
|
|
480
|
+
'viewbox',
|
|
481
|
+
'visibility',
|
|
482
|
+
'version',
|
|
483
|
+
'vert-adv-y',
|
|
484
|
+
'vert-origin-x',
|
|
485
|
+
'vert-origin-y',
|
|
486
|
+
'width',
|
|
487
|
+
'word-spacing',
|
|
488
|
+
'wrap',
|
|
489
|
+
'writing-mode',
|
|
490
|
+
'xchannelselector',
|
|
491
|
+
'ychannelselector',
|
|
492
|
+
'x',
|
|
493
|
+
'x1',
|
|
494
|
+
'x2',
|
|
495
|
+
'xmlns',
|
|
496
|
+
'y',
|
|
497
|
+
'y1',
|
|
498
|
+
'y2',
|
|
499
|
+
'z',
|
|
500
|
+
'zoomandpan',
|
|
501
|
+
'from',
|
|
502
|
+
'to',
|
|
503
|
+
];
|
|
504
|
+
const yfmHtmlAttrs = ['note-type', 'yfm2xliff-explicit', 'term-key'];
|
|
505
|
+
const allowedTags = Array.from(new Set([...htmlTags, ...svgTags, ...sanitize_html_1.default.defaults.allowedTags]));
|
|
506
|
+
const allowedAttributes = Array.from(new Set([...htmlAttrs, ...svgAttrs, ...yfmHtmlAttrs]));
|
|
507
|
+
exports.defaultParseOptions = {
|
|
508
|
+
lowerCaseAttributeNames: false,
|
|
509
|
+
};
|
|
510
|
+
exports.defaultOptions = Object.assign(Object.assign({}, sanitize_html_1.default.defaults), { allowedTags, allowedAttributes: Object.assign(Object.assign({}, sanitize_html_1.default.defaults.allowedAttributes), { '*': allowedAttributes }), allowVulnerableTags: true, parser: exports.defaultParseOptions, cssWhiteList: cssfilter_1.default.whiteList });
|
|
511
|
+
function sanitizeStyleTags(dom, cssWhiteList) {
|
|
512
|
+
const styleTags = dom('style');
|
|
513
|
+
styleTags.each((_index, element) => {
|
|
514
|
+
const styleText = dom(element).text();
|
|
515
|
+
try {
|
|
516
|
+
const parsedCSS = css_1.default.parse(styleText);
|
|
517
|
+
if (!parsedCSS.stylesheet) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
parsedCSS.stylesheet.rules = parsedCSS.stylesheet.rules.filter((rule) => rule.type === 'rule');
|
|
521
|
+
parsedCSS.stylesheet.rules.forEach((rule) => {
|
|
522
|
+
if (!rule.declarations) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
rule.declarations = rule.declarations.filter((declaration) => {
|
|
526
|
+
if (!declaration.property || !declaration.value) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
const isWhiteListed = cssWhiteList[declaration.property];
|
|
530
|
+
if (isWhiteListed) {
|
|
531
|
+
declaration.value = cssfilter_1.default.safeAttrValue(declaration.property, declaration.value);
|
|
532
|
+
}
|
|
533
|
+
if (!declaration.value) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
return isWhiteListed;
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
dom(element).text(css_1.default.stringify(parsedCSS));
|
|
540
|
+
}
|
|
541
|
+
catch (_a) { }
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
function sanitizeStyleAttrs(dom, cssWhiteList) {
|
|
545
|
+
const options = {
|
|
546
|
+
whiteList: cssWhiteList,
|
|
547
|
+
};
|
|
548
|
+
const cssSanitizer = new cssfilter_1.default.FilterCSS(options);
|
|
549
|
+
dom('*').each((_index, element) => {
|
|
550
|
+
const styleAttrValue = dom(element).attr('style');
|
|
551
|
+
if (!styleAttrValue) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
dom(element).attr('style', cssSanitizer.process(styleAttrValue));
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
function sanitizeStyles(html, options) {
|
|
558
|
+
const cssWhiteList = options.cssWhiteList || {};
|
|
559
|
+
const $ = cheerio.load(html);
|
|
560
|
+
sanitizeStyleTags($, cssWhiteList);
|
|
561
|
+
sanitizeStyleAttrs($, cssWhiteList);
|
|
562
|
+
const styles = $('head').html() || '';
|
|
563
|
+
const content = $('body').html() || '';
|
|
564
|
+
return styles + content;
|
|
565
|
+
}
|
|
566
|
+
function sanitize(html, options) {
|
|
567
|
+
const sanitizeOptions = options || exports.defaultOptions;
|
|
568
|
+
const modifiedHtml = sanitizeStyles(html, sanitizeOptions);
|
|
569
|
+
return (0, sanitize_html_1.default)(modifiedHtml, sanitizeOptions);
|
|
570
|
+
}
|
|
571
|
+
exports.default = sanitize;
|
|
572
|
+
//# sourceMappingURL=sanitize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/transform/sanitize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAyC;AACzC,aAAa;AACb,0DAAkC;AAClC,iDAAmC;AACnC,8CAAsB;AAEtB,MAAM,QAAQ,GAAG;IACb,GAAG;IACH,MAAM;IACN,SAAS;IACT,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACP,GAAG;IACH,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,YAAY;IACZ,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,MAAM;IACN,KAAK;IACL,UAAU;IACV,SAAS;IACT,MAAM;IACN,UAAU;IACV,IAAI;IACJ,WAAW;IACX,KAAK;IACL,SAAS;IACT,KAAK;IAC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O,EAAE,EAAE;QAC9B,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAElD,IAAI,CAAC,cAAc,EAAE;YACjB,OAAO;SACV;QAED,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,OAAwB;IAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;IAEhD,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7B,iBAAiB,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAEnC,kBAAkB,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAEpC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IAEvC,OAAO,MAAM,GAAG,OAAO,CAAC;AAC5B,CAAC;AAED,SAAwB,QAAQ,CAAC,IAAY,EAAE,OAAyB;IACpE,MAAM,eAAe,GAAG,OAAO,IAAI,sBAAc,CAAC;IAElD,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAE3D,OAAO,IAAA,uBAAY,EAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AAND,2BAMC"}
|
package/lib/title.d.ts
ADDED
package/lib/title.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function extractTitle(tokens) {
|
|
3
|
+
let title = '', contentTokens = tokens, titleTokens = [];
|
|
4
|
+
if (Array.isArray(tokens) && tokens.length > 0) {
|
|
5
|
+
if (tokens[0].type === 'heading_open' && tokens[0].tag === 'h1') {
|
|
6
|
+
titleTokens = tokens[1].children || [];
|
|
7
|
+
title = tokens[1].content;
|
|
8
|
+
// cut out "heading_open", "inline" and "heading_close" tokens
|
|
9
|
+
contentTokens = tokens.slice(3);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
titleTokens,
|
|
14
|
+
title,
|
|
15
|
+
tokens: contentTokens,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=title.js.map
|
package/lib/title.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.js","sourceRoot":"","sources":["../src/transform/title.ts"],"names":[],"mappings":";AAEA,iBAAS,SAAS,YAAY,CAAC,MAAe;IAC1C,IAAI,KAAK,GAAG,EAAE,EACV,aAAa,GAAG,MAAM,EACtB,WAAW,GAAY,EAAE,CAAC;IAE9B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5C,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,EAAE;YAC7D,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;YACvC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC1B,8DAA8D;YAC9D,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACnC;KACJ;IAED,OAAO;QACH,WAAW;QACX,KAAK;QACL,MAAM,EAAE,aAAa;KACxB,CAAC;AACN,CAAC,CAAC"}
|
package/lib/typings.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { LanguageFn } from 'highlight.js';
|
|
2
|
+
import DefaultMarkdownIt from 'markdown-it';
|
|
3
|
+
import DefaultStateCore from 'markdown-it/lib/rules_core/state_core';
|
|
4
|
+
import { SanitizeOptions } from './sanitize';
|
|
5
|
+
import { MarkdownItPluginCb } from './plugins/typings';
|
|
6
|
+
import { LogLevels } from './log';
|
|
7
|
+
import { ChangelogItem } from './plugins/changelog/types';
|
|
8
|
+
export interface MarkdownIt extends DefaultMarkdownIt {
|
|
9
|
+
assets?: string[];
|
|
10
|
+
meta?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface StateCore extends DefaultStateCore {
|
|
13
|
+
md: MarkdownIt;
|
|
14
|
+
}
|
|
15
|
+
export declare type HighlightLangMap = Record<string, LanguageFn>;
|
|
16
|
+
export declare type Heading = {
|
|
17
|
+
title: string;
|
|
18
|
+
href: string;
|
|
19
|
+
level: number;
|
|
20
|
+
items?: Heading[];
|
|
21
|
+
};
|
|
22
|
+
export interface OptionsType {
|
|
23
|
+
vars?: Record<string, string>;
|
|
24
|
+
path?: string;
|
|
25
|
+
extractTitle?: boolean;
|
|
26
|
+
needTitle?: boolean;
|
|
27
|
+
allowHTML?: boolean;
|
|
28
|
+
linkify?: boolean;
|
|
29
|
+
linkifyTlds?: string | string[];
|
|
30
|
+
breaks?: boolean;
|
|
31
|
+
conditionsInCode?: boolean;
|
|
32
|
+
disableLiquid?: boolean;
|
|
33
|
+
leftDelimiter?: string;
|
|
34
|
+
rightDelimiter?: string;
|
|
35
|
+
isLiquided?: boolean;
|
|
36
|
+
needToSanitizeHtml?: boolean;
|
|
37
|
+
sanitizeOptions?: SanitizeOptions;
|
|
38
|
+
needFlatListHeadings?: boolean;
|
|
39
|
+
plugins?: MarkdownItPluginCb<any>[];
|
|
40
|
+
highlightLangs?: HighlightLangMap;
|
|
41
|
+
root?: string;
|
|
42
|
+
extractChangelogs?: boolean;
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface OutputType {
|
|
46
|
+
result: {
|
|
47
|
+
html: string;
|
|
48
|
+
} & EnvType;
|
|
49
|
+
logs: Record<LogLevels, string[]>;
|
|
50
|
+
}
|
|
51
|
+
export declare type EnvType<Extras extends {} = {}> = {
|
|
52
|
+
title?: string;
|
|
53
|
+
headings: Heading[];
|
|
54
|
+
assets?: unknown[];
|
|
55
|
+
meta?: object;
|
|
56
|
+
changelogs?: ChangelogItem[];
|
|
57
|
+
} & Extras;
|
package/lib/typings.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typings.js","sourceRoot":"","sources":["../src/transform/typings.ts"],"names":[],"mappings":""}
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Token from 'markdown-it/lib/token';
|
|
2
|
+
export declare function isLocalUrl(url: string): boolean;
|
|
3
|
+
export declare function findBlockTokens(tokens: Token[], id: string): Token[];
|
|
4
|
+
export declare function headingInfo(tokens: Token[], idx: number): {
|
|
5
|
+
level: number;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function isExternalHref(href: string): boolean;
|
|
9
|
+
export declare function transformLinkToOriginalArticle(opts: {
|
|
10
|
+
root: string;
|
|
11
|
+
currentPath: string;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function getHrefTokenAttr(token: Token): string;
|