@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/utils.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHrefTokenAttr = exports.transformLinkToOriginalArticle = exports.isExternalHref = exports.headingInfo = exports.findBlockTokens = exports.isLocalUrl = void 0;
|
|
4
|
+
function isLocalUrl(url) {
|
|
5
|
+
return !/^(?:[a-z]+:)?\/\//i.test(url);
|
|
6
|
+
}
|
|
7
|
+
exports.isLocalUrl = isLocalUrl;
|
|
8
|
+
function findBlockTokens(tokens, id) {
|
|
9
|
+
let blockTokens = [];
|
|
10
|
+
let i = 0, startToken, start, end;
|
|
11
|
+
while (i < tokens.length) {
|
|
12
|
+
const token = tokens[i];
|
|
13
|
+
if (typeof start === 'number' && startToken) {
|
|
14
|
+
if (startToken.type === 'paragraph_open' && token.type === 'paragraph_close') {
|
|
15
|
+
end = i + 1;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
else if (startToken.type === 'heading_open') {
|
|
19
|
+
if (token.type === 'heading_open' && token.tag === startToken.tag) {
|
|
20
|
+
end = i;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
else if (i === tokens.length - 1) {
|
|
24
|
+
end = tokens.length;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if ((token.type === 'paragraph_open' || token.type === 'heading_open') &&
|
|
29
|
+
token.attrGet('id') === id &&
|
|
30
|
+
typeof start === 'undefined') {
|
|
31
|
+
startToken = token;
|
|
32
|
+
start = i;
|
|
33
|
+
}
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
if (typeof start === 'number' && typeof end === 'number') {
|
|
37
|
+
blockTokens = tokens.slice(start, end);
|
|
38
|
+
}
|
|
39
|
+
return blockTokens;
|
|
40
|
+
}
|
|
41
|
+
exports.findBlockTokens = findBlockTokens;
|
|
42
|
+
function headingInfo(tokens, idx) {
|
|
43
|
+
const openToken = tokens[idx];
|
|
44
|
+
const inlineToken = tokens[idx + 1];
|
|
45
|
+
let lastTextToken, i = 0;
|
|
46
|
+
while (inlineToken.children && i < inlineToken.children.length) {
|
|
47
|
+
const token = inlineToken.children[i];
|
|
48
|
+
if (token.type === 'text') {
|
|
49
|
+
lastTextToken = token;
|
|
50
|
+
}
|
|
51
|
+
i++;
|
|
52
|
+
}
|
|
53
|
+
const level = Number.parseInt(openToken.tag.slice(1), 10);
|
|
54
|
+
const title = (lastTextToken && lastTextToken.content) || inlineToken.content;
|
|
55
|
+
return {
|
|
56
|
+
level,
|
|
57
|
+
title,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.headingInfo = headingInfo;
|
|
61
|
+
function isExternalHref(href) {
|
|
62
|
+
return href.startsWith('http') || href.startsWith('//');
|
|
63
|
+
}
|
|
64
|
+
exports.isExternalHref = isExternalHref;
|
|
65
|
+
function transformLinkToOriginalArticle(opts) {
|
|
66
|
+
const { root, currentPath } = opts;
|
|
67
|
+
return currentPath.replace(root, '').replace(/\.(md|ya?ml|html)$/i, '');
|
|
68
|
+
}
|
|
69
|
+
exports.transformLinkToOriginalArticle = transformLinkToOriginalArticle;
|
|
70
|
+
function getHrefTokenAttr(token) {
|
|
71
|
+
let href = token.attrGet('href') || '';
|
|
72
|
+
try {
|
|
73
|
+
href = decodeURI(href);
|
|
74
|
+
}
|
|
75
|
+
catch (e) { }
|
|
76
|
+
return href;
|
|
77
|
+
}
|
|
78
|
+
exports.getHrefTokenAttr = getHrefTokenAttr;
|
|
79
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/transform/utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,GAAW;IAClC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC;AAFD,gCAEC;AAED,SAAgB,eAAe,CAAC,MAAe,EAAE,EAAU;IACvD,IAAI,WAAW,GAAY,EAAE,CAAC;IAC9B,IAAI,CAAC,GAAG,CAAC,EACL,UAAU,EACV,KAAK,EACL,GAAG,CAAC;IACR,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,EAAE;YACzC,IAAI,UAAU,CAAC,IAAI,KAAK,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;gBAC1E,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;gBACZ,MAAM;aACT;iBAAM,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,EAAE;gBAC3C,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,KAAK,CAAC,GAAG,KAAK,UAAU,CAAC,GAAG,EAAE;oBAC/D,GAAG,GAAG,CAAC,CAAC;oBACR,MAAM;iBACT;qBAAM,IAAI,CAAC,K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AC,OAAO,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC;IAE9E,OAAO;QACH,KAAK;QACL,KAAK;KACR,CAAC;AACN,CAAC;AAvBD,kCAuBC;AAED,SAAgB,cAAc,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC;AAFD,wCAEC;AAED,SAAgB,8BAA8B,CAAC,IAAyC;IACpF,MAAM,EAAC,IAAI,EAAE,WAAW,EAAC,GAAG,IAAI,CAAC;IAEjC,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC;AAJD,wEAIC;AAED,SAAgB,gBAAgB,CAAC,KAAY;IACzC,IAAI,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI;QACA,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;KAC1B;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,OAAO,IAAI,CAAC;AAChB,CAAC;AAPD,4CAOC"}
|
package/lib/utilsFS.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dictionary } from 'lodash';
|
|
2
|
+
import { StateCore } from './typings';
|
|
3
|
+
export declare function isFileExists(file: string): boolean;
|
|
4
|
+
export declare function resolveRelativePath(fromPath: string, relativePath: string): string;
|
|
5
|
+
export declare type GetFileTokensOpts = {
|
|
6
|
+
getVarsPerFile?: (path: string) => Record<string, string>;
|
|
7
|
+
vars?: Record<string, unknown>;
|
|
8
|
+
disableLiquid?: boolean;
|
|
9
|
+
disableLint?: boolean;
|
|
10
|
+
lintMarkdown?: (opts: {
|
|
11
|
+
input: string;
|
|
12
|
+
path: string;
|
|
13
|
+
sourceMap?: Dictionary<string>;
|
|
14
|
+
}) => void;
|
|
15
|
+
disableTitleRefSubstitution?: boolean;
|
|
16
|
+
disableCircularError?: boolean;
|
|
17
|
+
inheritVars?: boolean;
|
|
18
|
+
conditionsInCode?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function getFileTokens(path: string, state: StateCore, options: GetFileTokensOpts): import("markdown-it/lib/token")[];
|
|
21
|
+
export declare const getFullIncludePath: (includePath: string, root: string, path: string) => string;
|
|
22
|
+
export declare function getSinglePageAnchorId(args: {
|
|
23
|
+
root: string;
|
|
24
|
+
currentPath: string;
|
|
25
|
+
pathname?: string;
|
|
26
|
+
hash?: string | null;
|
|
27
|
+
}): string;
|
package/lib/utilsFS.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSinglePageAnchorId = exports.getFullIncludePath = exports.getFileTokens = exports.resolveRelativePath = exports.isFileExists = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const liquid_1 = __importDefault(require("./liquid"));
|
|
11
|
+
const filesCache = {};
|
|
12
|
+
function isFileExists(file) {
|
|
13
|
+
try {
|
|
14
|
+
const stats = (0, fs_1.statSync)(file);
|
|
15
|
+
return stats.isFile();
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.isFileExists = isFileExists;
|
|
22
|
+
function resolveRelativePath(fromPath, relativePath) {
|
|
23
|
+
const { dir: fromDir } = (0, path_1.parse)(fromPath);
|
|
24
|
+
return (0, path_1.resolve)(fromDir, relativePath);
|
|
25
|
+
}
|
|
26
|
+
exports.resolveRelativePath = resolveRelativePath;
|
|
27
|
+
function getFileTokens(path, state, options) {
|
|
28
|
+
const { getVarsPerFile, vars, disableLiquid, disableLint, lintMarkdown, disableTitleRefSubstitution, disableCircularError, inheritVars = true, conditionsInCode, } = options;
|
|
29
|
+
let content;
|
|
30
|
+
const builtVars = (getVarsPerFile && !inheritVars ? getVarsPerFile(path) : vars) || {};
|
|
31
|
+
if (filesCache[path]) {
|
|
32
|
+
content = filesCache[path];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
content = (0, fs_1.readFileSync)(path, 'utf8');
|
|
36
|
+
filesCache[path] = content;
|
|
37
|
+
}
|
|
38
|
+
let sourceMap;
|
|
39
|
+
if (!disableLiquid) {
|
|
40
|
+
const liquidResult = (0, liquid_1.default)(content, builtVars, path, {
|
|
41
|
+
withSourceMap: true,
|
|
42
|
+
conditionsInCode,
|
|
43
|
+
});
|
|
44
|
+
content = liquidResult.output;
|
|
45
|
+
sourceMap = liquidResult.sourceMap;
|
|
46
|
+
}
|
|
47
|
+
if (!disableLint && lintMarkdown) {
|
|
48
|
+
lintMarkdown({
|
|
49
|
+
input: content,
|
|
50
|
+
path,
|
|
51
|
+
sourceMap,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const meta = state.md.meta;
|
|
55
|
+
const tokens = state.md.parse(content, Object.assign(Object.assign({}, state.env), { path,
|
|
56
|
+
disableTitleRefSubstitution,
|
|
57
|
+
disableCircularError }));
|
|
58
|
+
state.md.meta = meta;
|
|
59
|
+
return tokens;
|
|
60
|
+
}
|
|
61
|
+
exports.getFileTokens = getFileTokens;
|
|
62
|
+
const getFullIncludePath = (includePath, root, path) => {
|
|
63
|
+
let fullIncludePath;
|
|
64
|
+
if (includePath.startsWith(path_1.sep)) {
|
|
65
|
+
fullIncludePath = (0, path_1.join)(root, includePath);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
fullIncludePath = resolveRelativePath(path, includePath);
|
|
69
|
+
}
|
|
70
|
+
return fullIncludePath;
|
|
71
|
+
};
|
|
72
|
+
exports.getFullIncludePath = getFullIncludePath;
|
|
73
|
+
function getSinglePageAnchorId(args) {
|
|
74
|
+
const { root, currentPath, pathname, hash } = args;
|
|
75
|
+
let resultAnchor = currentPath;
|
|
76
|
+
if (pathname) {
|
|
77
|
+
resultAnchor = resolveRelativePath(currentPath, pathname);
|
|
78
|
+
}
|
|
79
|
+
resultAnchor = resultAnchor
|
|
80
|
+
.replace(root, '')
|
|
81
|
+
.replace(/\.(md|ya?ml|html)$/i, '')
|
|
82
|
+
.replace(new RegExp(lodash_1.default.escapeRegExp(path_1.sep), 'gi'), '_');
|
|
83
|
+
if (hash) {
|
|
84
|
+
resultAnchor = resultAnchor + '_' + hash.slice(1);
|
|
85
|
+
}
|
|
86
|
+
return `#${resultAnchor}`;
|
|
87
|
+
}
|
|
88
|
+
exports.getSinglePageAnchorId = getSinglePageAnchorId;
|
|
89
|
+
//# sourceMappingURL=utilsFS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilsFS.js","sourceRoot":"","sources":["../src/transform/utilsFS.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAqC;AACrC,2BAA0C;AAE1C,+BAA+C;AAE/C,sDAA8B;AAG9B,MAAM,UAAU,GAA2B,EAAE,CAAC;AAE9C,SAAgB,YAAY,CAAC,IAAY;IACrC,IAAI;QACA,MAAM,KAAK,GAAG,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC;QAE7B,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;KACzB;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AARD,oCAQC;AAED,SAAgB,mBAAmB,CAAC,QAAgB,EAAE,YAAoB;IACtE,MAAM,EAAC,GAAG,EAAE,OAAO,EAAC,GAAG,IAAA,YAAK,EAAC,QAAQ,CAAC,CAAC;IAEvC,OAAO,IAAA,cAAO,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAC1C,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
|
|
3
|
+
import { Dictionary } from 'lodash';
|
|
4
|
+
import { Logger, LogLevels } from '../log';
|
|
5
|
+
declare function yfmlint(opts: Options): void;
|
|
6
|
+
export = yfmlint;
|
|
7
|
+
declare namespace yfmlint {
|
|
8
|
+
interface LintMarkdownFunctionOptions {
|
|
9
|
+
input: string;
|
|
10
|
+
path: string;
|
|
11
|
+
sourceMap?: Dictionary<string>;
|
|
12
|
+
}
|
|
13
|
+
interface PluginOptions {
|
|
14
|
+
log: Logger;
|
|
15
|
+
path?: string;
|
|
16
|
+
disableLint?: boolean;
|
|
17
|
+
lintMarkdown?: (opts: LintMarkdownFunctionOptions) => void;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
interface LintConfig {
|
|
21
|
+
default?: boolean;
|
|
22
|
+
'log-levels': Record<string, LogLevels>;
|
|
23
|
+
[x: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
type LintRule = Rule;
|
|
26
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const markdownlint_1 = require("markdownlint");
|
|
6
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
7
|
+
const union_1 = __importDefault(require("lodash/union"));
|
|
8
|
+
const markdown_it_attrs_1 = __importDefault(require("markdown-it-attrs"));
|
|
9
|
+
const yfmlint_1 = __importDefault(require("./yfmlint"));
|
|
10
|
+
const markdownlint_custom_rule_1 = require("./markdownlint-custom-rule");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const yfm009_1 = require("./markdownlint-custom-rule/yfm009");
|
|
13
|
+
const defaultLintRules = [markdownlint_custom_rule_1.yfm001, markdownlint_custom_rule_1.yfm002, markdownlint_custom_rule_1.yfm003, markdownlint_custom_rule_1.yfm004, markdownlint_custom_rule_1.yfm005, markdownlint_custom_rule_1.yfm006, markdownlint_custom_rule_1.yfm007, markdownlint_custom_rule_1.yfm008, yfm009_1.yfm009];
|
|
14
|
+
const lintCache = new Set();
|
|
15
|
+
function yfmlint(opts) {
|
|
16
|
+
const { input, plugins: customPlugins, pluginOptions, customLintRules, sourceMap } = opts;
|
|
17
|
+
const { path = 'input', log } = pluginOptions;
|
|
18
|
+
pluginOptions.isLintRun = true;
|
|
19
|
+
const { LogLevels: { ERROR, WARN, DISABLED }, } = log;
|
|
20
|
+
if (lintCache.has(path)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
lintCache.add(path);
|
|
24
|
+
const defaultLintConfig = opts.defaultLintConfig || yfmlint_1.default;
|
|
25
|
+
let lintConfig = defaultLintConfig;
|
|
26
|
+
if (opts.lintConfig) {
|
|
27
|
+
lintConfig = (0, merge_1.default)({}, defaultLintConfig, opts.lintConfig);
|
|
28
|
+
}
|
|
29
|
+
let lintRules = defaultLintRules;
|
|
30
|
+
if (customLintRules) {
|
|
31
|
+
lintRules = (0, union_1.default)(lintRules, customLintRules);
|
|
32
|
+
}
|
|
33
|
+
const plugins = customPlugins && [markdown_it_attrs_1.default, ...customPlugins];
|
|
34
|
+
const preparedPlugins = plugins && plugins.map((plugin) => [plugin, pluginOptions]);
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
result = (0, markdownlint_1.sync)({
|
|
38
|
+
strings: { [path]: input },
|
|
39
|
+
markdownItPlugins: preparedPlugins,
|
|
40
|
+
handleRuleFailures: true,
|
|
41
|
+
config: lintConfig,
|
|
42
|
+
customRules: lintRules,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (_a) { }
|
|
46
|
+
const errors = result && result[path];
|
|
47
|
+
if (!errors) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const logLevelsConfig = lintConfig['log-levels'];
|
|
51
|
+
for (const error of errors) {
|
|
52
|
+
const message = (0, utils_1.errorToString)(path, error, sourceMap);
|
|
53
|
+
const logLevel = (0, utils_1.getLogLevel)({
|
|
54
|
+
logLevelsConfig,
|
|
55
|
+
ruleNames: error.ruleNames,
|
|
56
|
+
defaultLevel: WARN,
|
|
57
|
+
});
|
|
58
|
+
switch (logLevel) {
|
|
59
|
+
case ERROR:
|
|
60
|
+
log.error(message);
|
|
61
|
+
break;
|
|
62
|
+
case WARN:
|
|
63
|
+
log.warn(message);
|
|
64
|
+
break;
|
|
65
|
+
case DISABLED:
|
|
66
|
+
default:
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
module.exports = yfmlint;
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/yfmlint/index.ts"],"names":[],"mappings":";;;;AAAA,+CAAwC;AACxC,yDAAiC;AACjC,yDAAiC;AACjC,0EAAsC;AACtC,wDAA8C;AAE9C,yEASoC;AAEpC,mCAAmD;AAInD,8DAAyD;AAEzD,MAAM,gBAAgB,GAAG,CAAC,iCAAM,EAAE,iCAAM,EAAE,iCAAM,EAAE,iCAAM,EAAE,iCAAM,EAAE,iCAAM,EAAE,iCAAM,EAAE,iCAAM,EAAE,eAAM,CAAC,CAAC;AAElG,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;AAE5B,SAAS,OAAO,CAAC,IAAa;IAC1B,MAAM,EAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,SAAS,EAAC,GAAG,IAAI,CAAC;IACxF,MAAM,EAAC,IAAI,GAAG,OAAO,EAAE,GAAG,EAAC,GAAG,aAAa,CAAC;IAE5C,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC;IAE/B,MAAM,EACF,SAAS,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAC,GACrC,GAAG,GAAG,CAAC;IAER,IAAI,SAAS,CA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AE,SAAS,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC;YACzB,eAAe;YACf,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;QAEH,QAAQ,QAAQ,EAAE;YACd,KAAK,KAAK;gBACN,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACnB,MAAM;YACV,KAAK,IAAI;gBACL,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAClB,MAAM;YACV,KAAK,QAAQ,CAAC;YACd;gBACI,MAAM;SACb;KACJ;AACL,CAAC;AAED,iBAAS,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { yfm001 } from './yfm001';
|
|
2
|
+
export { yfm002 } from './yfm002';
|
|
3
|
+
export { yfm003 } from './yfm003';
|
|
4
|
+
export { yfm004 } from './yfm004';
|
|
5
|
+
export { yfm005 } from './yfm005';
|
|
6
|
+
export { yfm006 } from './yfm006';
|
|
7
|
+
export { yfm007 } from './yfm007';
|
|
8
|
+
export { yfm008 } from './yfm008';
|
|
9
|
+
export { yfm009 } from './yfm009';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm009 = exports.yfm008 = exports.yfm007 = exports.yfm006 = exports.yfm005 = exports.yfm004 = exports.yfm003 = exports.yfm002 = exports.yfm001 = void 0;
|
|
4
|
+
var yfm001_1 = require("./yfm001");
|
|
5
|
+
Object.defineProperty(exports, "yfm001", { enumerable: true, get: function () { return yfm001_1.yfm001; } });
|
|
6
|
+
var yfm002_1 = require("./yfm002");
|
|
7
|
+
Object.defineProperty(exports, "yfm002", { enumerable: true, get: function () { return yfm002_1.yfm002; } });
|
|
8
|
+
var yfm003_1 = require("./yfm003");
|
|
9
|
+
Object.defineProperty(exports, "yfm003", { enumerable: true, get: function () { return yfm003_1.yfm003; } });
|
|
10
|
+
var yfm004_1 = require("./yfm004");
|
|
11
|
+
Object.defineProperty(exports, "yfm004", { enumerable: true, get: function () { return yfm004_1.yfm004; } });
|
|
12
|
+
var yfm005_1 = require("./yfm005");
|
|
13
|
+
Object.defineProperty(exports, "yfm005", { enumerable: true, get: function () { return yfm005_1.yfm005; } });
|
|
14
|
+
var yfm006_1 = require("./yfm006");
|
|
15
|
+
Object.defineProperty(exports, "yfm006", { enumerable: true, get: function () { return yfm006_1.yfm006; } });
|
|
16
|
+
var yfm007_1 = require("./yfm007");
|
|
17
|
+
Object.defineProperty(exports, "yfm007", { enumerable: true, get: function () { return yfm007_1.yfm007; } });
|
|
18
|
+
var yfm008_1 = require("./yfm008");
|
|
19
|
+
Object.defineProperty(exports, "yfm008", { enumerable: true, get: function () { return yfm008_1.yfm008; } });
|
|
20
|
+
var yfm009_1 = require("./yfm009");
|
|
21
|
+
Object.defineProperty(exports, "yfm009", { enumerable: true, get: function () { return yfm009_1.yfm009; } });
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,mCAAgC;AAAxB,gGAAA,MAAM,OAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm001 = void 0;
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
const markdownlint_rule_helpers_1 = require("markdownlint-rule-helpers");
|
|
6
|
+
exports.yfm001 = {
|
|
7
|
+
names: ['YFM001', 'inline-code-length'],
|
|
8
|
+
description: 'Inline code length',
|
|
9
|
+
tags: ['line_length'],
|
|
10
|
+
function: function YFM001(params, onError) {
|
|
11
|
+
const { config } = params;
|
|
12
|
+
const maxLength = Number(config.maximum || 100);
|
|
13
|
+
(0, markdownlint_rule_helpers_1.filterTokens)(params, 'inline', (token) => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (!((_a = token.children) === null || _a === void 0 ? void 0 : _a.some((child) => child.type === 'code_inline')) || !token.map) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const tokenLines = params.lines.slice(token.map[0], token.map[1]);
|
|
19
|
+
(0, markdownlint_rule_helpers_1.forEachInlineCodeSpan)(tokenLines.join('\n'), (code, currentLine) => {
|
|
20
|
+
if (code.length <= maxLength) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
(0, markdownlint_rule_helpers_1.addErrorDetailIf)(onError, token.lineNumber + currentLine, maxLength, code.length, null, code);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=yfm001.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm001.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,yEAAgG;AAInF,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACvC,WAAW,EAAE,oBAAoB;IACjC,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;QAEhD,IAAA,wCAAY,EAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAsB,EAAE,EAAE;;YACtD,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,CAAA,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC9E,OAAO;aACV;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,IAAA,iDAAqB,EAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAY,EAAE,WAAmB,EAAE,EAAE;gBAC/E,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE;oBAC1B,OAAO;iBACV;gBAED,IAAA,4CAAgB,EACZ,OAAO,EACP,KAAK,CAAC,UAAU,GAAG,WAAW,EAC9B,SAAS,EACT,IAAI,CAAC,MAAM,EACX,IAAI,EACJ,IAAI,CACP,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm002 = void 0;
|
|
4
|
+
exports.yfm002 = {
|
|
5
|
+
names: ['YFM002', 'no-header-found-for-link'],
|
|
6
|
+
description: 'No header found in the file for the link text',
|
|
7
|
+
tags: ['links'],
|
|
8
|
+
function: function YFM002(params, onError) {
|
|
9
|
+
const { config } = params;
|
|
10
|
+
if (!config) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.tokens
|
|
14
|
+
.filter((token) => {
|
|
15
|
+
return token.type === 'inline';
|
|
16
|
+
})
|
|
17
|
+
.forEach((inline) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = inline.children) === null || _a === void 0 ? void 0 : _a.filter((child) => {
|
|
20
|
+
return child.type === 'link_open';
|
|
21
|
+
}).forEach((link) => {
|
|
22
|
+
// @ts-expect-error bad markdownlint typings
|
|
23
|
+
if (link.attrGet('YFM002')) {
|
|
24
|
+
onError({
|
|
25
|
+
lineNumber: link.lineNumber,
|
|
26
|
+
context: link.line,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=yfm002.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm002.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAC7C,WAAW,EAAE,+CAA+C;IAC5D,IAAI,EAAE,CAAC,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QAED,MAAM,CAAC,MAAM;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;QACnC,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;;YAChB,MAAA,MAAM,CAAC,QAAQ,0CACT,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;YACtC,CAAC,EACA,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACd,4CAA4C;gBAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBACxB,OAAO,CAAC;wBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,OAAO,EAAE,IAAI,CAAC,IAAI;qBACrB,CAAC,CAAC;iBACN;YACL,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm003 = void 0;
|
|
4
|
+
exports.yfm003 = {
|
|
5
|
+
names: ['YFM003', 'unreachable-link'],
|
|
6
|
+
description: 'Link is unreachable',
|
|
7
|
+
tags: ['links'],
|
|
8
|
+
function: function YFM003(params, onError) {
|
|
9
|
+
const { config } = params;
|
|
10
|
+
if (!config) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.tokens
|
|
14
|
+
.filter((token) => {
|
|
15
|
+
return token.type === 'inline';
|
|
16
|
+
})
|
|
17
|
+
.forEach((inline) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = inline.children) === null || _a === void 0 ? void 0 : _a.filter((child) => {
|
|
20
|
+
return child.type === 'link_open';
|
|
21
|
+
}).forEach((link) => {
|
|
22
|
+
// @ts-expect-error bad markdownlint typings
|
|
23
|
+
if (link.attrGet('YFM003')) {
|
|
24
|
+
onError({
|
|
25
|
+
lineNumber: link.lineNumber,
|
|
26
|
+
context: link.line,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=yfm003.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm003.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACrC,WAAW,EAAE,qBAAqB;IAClC,IAAI,EAAE,CAAC,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QAED,MAAM,CAAC,MAAM;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;QACnC,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;;YAChB,MAAA,MAAM,CAAC,QAAQ,0CACT,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;YACtC,CAAC,EACA,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACd,4CAA4C;gBAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBACxB,OAAO,CAAC;wBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,OAAO,EAAE,IAAI,CAAC,IAAI;qBACrB,CAAC,CAAC;iBACN;YACL,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm004 = void 0;
|
|
4
|
+
exports.yfm004 = {
|
|
5
|
+
names: ['YFM004', 'table-not-closed'],
|
|
6
|
+
description: 'Table not closed',
|
|
7
|
+
tags: ['table'],
|
|
8
|
+
function: function YFM004(params, onError) {
|
|
9
|
+
const { config } = params;
|
|
10
|
+
if (!config) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.tokens
|
|
14
|
+
.filter((token) => {
|
|
15
|
+
return token.type === '__yfm_lint';
|
|
16
|
+
})
|
|
17
|
+
.forEach((table) => {
|
|
18
|
+
// @ts-expect-error bad markdownlint typings
|
|
19
|
+
if (table.attrGet('YFM004')) {
|
|
20
|
+
onError({
|
|
21
|
+
lineNumber: table.lineNumber,
|
|
22
|
+
context: table.line,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=yfm004.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm004.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACrC,WAAW,EAAE,kBAAkB;IAC/B,IAAI,EAAE,CAAC,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QAED,MAAM,CAAC,MAAM;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;QACvC,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,4CAA4C;YAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACzB,OAAO,CAAC;oBACJ,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,OAAO,EAAE,KAAK,CAAC,IAAI;iBACtB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm005 = void 0;
|
|
4
|
+
exports.yfm005 = {
|
|
5
|
+
names: ['YFM005', 'tab-list-not-closed'],
|
|
6
|
+
description: 'Tab list not closed',
|
|
7
|
+
tags: ['tab'],
|
|
8
|
+
function: function YFM005(params, onError) {
|
|
9
|
+
const { config } = params;
|
|
10
|
+
if (!config) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.tokens
|
|
14
|
+
.filter((token) => {
|
|
15
|
+
return token.type === 'paragraph_open';
|
|
16
|
+
})
|
|
17
|
+
.forEach((table) => {
|
|
18
|
+
// @ts-expect-error bad markdownlint typings
|
|
19
|
+
if (table.attrGet('YFM005')) {
|
|
20
|
+
onError({
|
|
21
|
+
lineNumber: table.lineNumber,
|
|
22
|
+
context: table.line,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=yfm005.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm005.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACxC,WAAW,EAAE,qBAAqB;IAClC,IAAI,EAAE,CAAC,KAAK,CAAC;IACb,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QAED,MAAM,CAAC,MAAM;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC;QAC3C,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,4CAA4C;YAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACzB,OAAO,CAAC;oBACJ,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,OAAO,EAAE,KAAK,CAAC,IAAI;iBACtB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm006 = void 0;
|
|
4
|
+
exports.yfm006 = {
|
|
5
|
+
names: ['YFM006', 'term-definition-duplicated'],
|
|
6
|
+
description: 'Term definition duplicated',
|
|
7
|
+
tags: ['term'],
|
|
8
|
+
function: function YFM006(params, onError) {
|
|
9
|
+
const { config } = params;
|
|
10
|
+
if (!config) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.tokens
|
|
14
|
+
.filter((token) => {
|
|
15
|
+
return token.type === '__yfm_lint';
|
|
16
|
+
})
|
|
17
|
+
.forEach((term) => {
|
|
18
|
+
// @ts-expect-error bad markdownlint typings
|
|
19
|
+
if (term.attrGet('YFM006')) {
|
|
20
|
+
onError({
|
|
21
|
+
lineNumber: term.lineNumber,
|
|
22
|
+
context: term.line,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=yfm006.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm006.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,4BAA4B,CAAC;IAC/C,WAAW,EAAE,4BAA4B;IACzC,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QACD,MAAM,CAAC,MAAM;aACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;QACvC,CAAC,CAAC;aACD,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,4CAA4C;YAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACxB,OAAO,CAAC;oBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,OAAO,EAAE,IAAI,CAAC,IAAI;iBACrB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yfm007 = void 0;
|
|
4
|
+
exports.yfm007 = {
|
|
5
|
+
names: ['YFM007', 'term-used-without-definition'],
|
|
6
|
+
description: 'Term used without definition',
|
|
7
|
+
tags: ['term'],
|
|
8
|
+
function: function YFM007(params, onError) {
|
|
9
|
+
const { config } = params;
|
|
10
|
+
if (!config) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
params.tokens.forEach((el) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = el.children) === null || _a === void 0 ? void 0 : _a.filter((token) => {
|
|
16
|
+
return token.type === '__yfm_lint';
|
|
17
|
+
}).forEach((term) => {
|
|
18
|
+
// @ts-expect-error bad markdownlint typings
|
|
19
|
+
if (term.attrGet('YFM007')) {
|
|
20
|
+
onError({
|
|
21
|
+
lineNumber: term.lineNumber,
|
|
22
|
+
context: term.line,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=yfm007.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yfm007.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAS;IACxB,KAAK,EAAE,CAAC,QAAQ,EAAE,8BAA8B,CAAC;IACjD,WAAW,EAAE,8BAA8B;IAC3C,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO;SACV;QACD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;;YACzB,OAAA,MAAA,EAAE,CAAC,QAAQ,0CACL,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,OAAO,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;YACvC,CAAC,EACA,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACd,4CAA4C;gBAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBACxB,OAAO,CAAC;wBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,OAAO,EAAE,IAAI,CAAC,IAAI;qBACrB,CAAC,CAAC;iBACN;YACL,CAAC,CAAC,CAAA;SAAA,CACT,CAAC;IACN,CAAC;CACJ,CAAC"}
|