@diplodoc/transform 4.29.0 → 4.30.2
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/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css +0 -1
- package/dist/css/yfm.css.map +2 -2
- package/dist/css/yfm.min.css +1 -1
- package/dist/css/yfm.min.css.map +2 -2
- package/dist/js/yfm.js.map +2 -2
- package/dist/js/yfm.min.js.map +2 -2
- package/lib/headings.js.map +1 -1
- package/lib/highlight.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/liquid/conditions.js +1 -1
- package/lib/liquid/conditions.js.map +1 -1
- package/lib/liquid/cycles.js +1 -1
- package/lib/liquid/cycles.js.map +1 -1
- package/lib/liquid/evaluation.js +1 -1
- package/lib/liquid/evaluation.js.map +1 -1
- package/lib/liquid/index.d.ts +1 -1
- package/lib/liquid/index.js.map +1 -1
- package/lib/liquid/substitutions.js +2 -2
- package/lib/liquid/substitutions.js.map +1 -1
- package/lib/md.js +30 -9
- package/lib/md.js.map +1 -1
- package/lib/plugins/anchors/collect.js +1 -1
- package/lib/plugins/anchors/collect.js.map +1 -1
- package/lib/plugins/anchors/index.js +4 -4
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/plugins/block-anchor/index.js.map +1 -1
- package/lib/plugins/changelog/collect.d.ts +1 -1
- package/lib/plugins/changelog/collect.js +1 -1
- package/lib/plugins/changelog/collect.js.map +1 -1
- package/lib/plugins/changelog/index.js.map +1 -1
- package/lib/plugins/checkbox/index.js.map +1 -1
- package/lib/plugins/deflist.js.map +1 -1
- package/lib/plugins/file/index.js.map +1 -1
- package/lib/plugins/images/index.js +1 -1
- package/lib/plugins/images/index.js.map +1 -1
- package/lib/plugins/imsize/index.js.map +1 -1
- package/lib/plugins/imsize/plugin.js.map +1 -1
- package/lib/plugins/includes/collect.d.ts +4 -2
- package/lib/plugins/includes/collect.js +20 -3
- package/lib/plugins/includes/collect.js.map +1 -1
- package/lib/plugins/includes/index.js +8 -5
- package/lib/plugins/includes/index.js.map +1 -1
- package/lib/plugins/includes/types.d.ts +6 -0
- package/lib/plugins/includes/types.js +3 -0
- package/lib/plugins/includes/types.js.map +1 -0
- package/lib/plugins/links/collect.js.map +1 -1
- package/lib/plugins/links/index.js +1 -1
- package/lib/plugins/links/index.js.map +1 -1
- package/lib/plugins/meta.js.map +1 -1
- package/lib/plugins/monospace.js +0 -1
- package/lib/plugins/monospace.js.map +1 -1
- package/lib/plugins/notes/index.js +0 -2
- package/lib/plugins/notes/index.js.map +1 -1
- package/lib/plugins/sup.js.map +1 -1
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/term/index.js.map +1 -1
- package/lib/plugins/term/termDefinitions.js.map +1 -1
- package/lib/plugins/typings.d.ts +1 -14
- package/lib/plugins/typings.js +15 -0
- package/lib/plugins/typings.js.map +1 -1
- package/lib/plugins/utils.d.ts +1 -1
- package/lib/plugins/utils.js.map +1 -1
- package/lib/plugins/video/const.d.ts +3 -1
- package/lib/plugins/video/const.js +4 -0
- package/lib/plugins/video/const.js.map +1 -1
- package/lib/plugins/video/index.js +7 -9
- package/lib/plugins/video/index.js.map +1 -1
- package/lib/plugins/video/parsers.d.ts +2 -0
- package/lib/plugins/video/parsers.js +19 -1
- package/lib/plugins/video/parsers.js.map +1 -1
- package/lib/plugins/video/types.d.ts +8 -0
- package/lib/plugins/video/utils.js +9 -6
- package/lib/plugins/video/utils.js.map +1 -1
- package/lib/preprocessors/included/index.d.ts +5 -0
- package/lib/preprocessors/included/index.js +71 -0
- package/lib/preprocessors/included/index.js.map +1 -0
- package/lib/preprocessors.d.ts +3 -0
- package/lib/preprocessors.js +8 -0
- package/lib/preprocessors.js.map +1 -0
- package/lib/sanitize.js +1 -1
- package/lib/sanitize.js.map +1 -1
- package/lib/typings.d.ts +22 -2
- package/lib/utilsFS.d.ts +2 -0
- package/lib/utilsFS.js +18 -8
- package/lib/utilsFS.js.map +1 -1
- package/lib/yfmlint/index.d.ts +2 -2
- package/lib/yfmlint/index.js +6 -1
- package/lib/yfmlint/index.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -1
- package/lib/yfmlint/typings.d.ts +2 -0
- package/lib/yfmlint/utils.d.ts +2 -2
- package/lib/yfmlint/utils.js.map +1 -1
- package/lib/yfmlint/yfmlint.js.map +1 -1
- package/package.json +13 -11
- package/src/.eslintrc.js +1 -23
- package/src/js/index.ts +0 -1
- package/src/js/term/index.ts +1 -0
- package/src/transform/headings.ts +1 -0
- package/src/transform/highlight.ts +1 -0
- package/src/transform/index.ts +2 -0
- package/src/transform/liquid/conditions.ts +3 -1
- package/src/transform/liquid/cycles.ts +3 -1
- package/src/transform/liquid/evaluation.ts +2 -1
- package/src/transform/liquid/index.ts +2 -3
- package/src/transform/liquid/substitutions.ts +3 -2
- package/src/transform/md.ts +55 -14
- package/src/transform/plugins/anchors/collect.ts +2 -1
- package/src/transform/plugins/anchors/index.ts +4 -3
- package/src/transform/plugins/block-anchor/index.ts +1 -0
- package/src/transform/plugins/changelog/collect.ts +5 -2
- package/src/transform/plugins/changelog/index.ts +2 -1
- package/src/transform/plugins/checkbox/index.ts +1 -0
- package/src/transform/plugins/deflist.ts +1 -0
- package/src/transform/plugins/file/index.ts +1 -0
- package/src/transform/plugins/images/index.ts +2 -2
- package/src/transform/plugins/imsize/index.ts +1 -0
- package/src/transform/plugins/imsize/plugin.ts +1 -0
- package/src/transform/plugins/includes/collect.ts +45 -5
- package/src/transform/plugins/includes/index.ts +23 -7
- package/src/transform/plugins/includes/types.ts +7 -0
- package/src/transform/plugins/links/collect.ts +2 -0
- package/src/transform/plugins/links/index.ts +5 -3
- package/src/transform/plugins/meta.ts +1 -0
- package/src/transform/plugins/monospace.ts +1 -1
- package/src/transform/plugins/notes/index.ts +2 -2
- package/src/transform/plugins/sup.ts +1 -0
- package/src/transform/plugins/table/index.ts +3 -1
- package/src/transform/plugins/term/index.ts +1 -0
- package/src/transform/plugins/term/termDefinitions.ts +2 -0
- package/src/transform/plugins/typings.ts +1 -16
- package/src/transform/plugins/utils.ts +2 -1
- package/src/transform/plugins/video/const.ts +5 -0
- package/src/transform/plugins/video/index.ts +8 -10
- package/src/transform/plugins/video/parsers.ts +18 -0
- package/src/transform/plugins/video/types.ts +2 -0
- package/src/transform/plugins/video/utils.ts +9 -6
- package/src/transform/preprocessors/included/index.ts +101 -0
- package/src/transform/preprocessors.ts +7 -0
- package/src/transform/sanitize.ts +2 -2
- package/src/transform/typings.ts +27 -2
- package/src/transform/utilsFS.ts +19 -7
- package/src/transform/yfmlint/index.ts +18 -5
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +0 -1
- package/src/transform/yfmlint/typings.ts +5 -0
- package/src/transform/yfmlint/utils.ts +4 -2
- package/src/transform/yfmlint/yfmlint.ts +2 -1
package/lib/utilsFS.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPublicPath = exports.getSinglePageAnchorId = exports.getFullIncludePath = exports.getFileTokens = exports.resolveRelativePath = exports.isFileExists = void 0;
|
|
6
|
+
exports.getRelativePath = exports.getPublicPath = exports.getSinglePageAnchorId = exports.getFullIncludePath = exports.getFileTokens = exports.resolveRelativePath = exports.isFileExists = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
|
|
9
9
|
const path_1 = require("path");
|
|
@@ -27,14 +27,17 @@ function resolveRelativePath(fromPath, relativePath) {
|
|
|
27
27
|
exports.resolveRelativePath = resolveRelativePath;
|
|
28
28
|
function getFileTokens(path, state, options) {
|
|
29
29
|
const { getVarsPerFile, vars, disableLiquid, disableLint, lintMarkdown, disableTitleRefSubstitution, disableCircularError, inheritVars = true, conditionsInCode, } = options;
|
|
30
|
-
let content;
|
|
30
|
+
let { content } = options;
|
|
31
31
|
const builtVars = (getVarsPerFile && !inheritVars ? getVarsPerFile(path) : vars) || {};
|
|
32
|
-
if
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
// Read the content only if we dont have one in the args
|
|
33
|
+
if (!content) {
|
|
34
|
+
if (filesCache[path]) {
|
|
35
|
+
content = filesCache[path];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
content = (0, fs_1.readFileSync)(path, 'utf8');
|
|
39
|
+
filesCache[path] = content;
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
42
|
let sourceMap;
|
|
40
43
|
if (!disableLiquid) {
|
|
@@ -95,4 +98,11 @@ function getPublicPath({ path, root, rootPublicPath, transformLink, }, input) {
|
|
|
95
98
|
return href;
|
|
96
99
|
}
|
|
97
100
|
exports.getPublicPath = getPublicPath;
|
|
101
|
+
function getRelativePath(path, toPath) {
|
|
102
|
+
const pathDirs = path.split(path_1.sep);
|
|
103
|
+
pathDirs.pop();
|
|
104
|
+
const parentPath = pathDirs.join(path_1.sep);
|
|
105
|
+
return (0, path_1.relative)(parentPath, toPath);
|
|
106
|
+
}
|
|
107
|
+
exports.getRelativePath = getRelativePath;
|
|
98
108
|
//# sourceMappingURL=utilsFS.js.map
|
package/lib/utilsFS.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsFS.js","sourceRoot":"","sources":["../src/transform/utilsFS.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"utilsFS.js","sourceRoot":"","sources":["../src/transform/utilsFS.ts"],"names":[],"mappings":";;;;;;AAEA,2BAA0C;AAC1C,uEAA+C;AAC/C,+BAAyD;AAEzD,sDAA8B;AAE9B,mCAA6C;AAE7C,MAAM,UAAU,GAA2B,EAAE,CAAC;AAE9C,SAAgB,YAAY,CAAC,IAAY;IACrC,IAAI;QAC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|
import type { Dictionary } from 'lodash';
|
|
2
|
+
import { Rule } from 'markdownlint';
|
|
4
3
|
import { LogLevels, Logger } from '../log';
|
|
4
|
+
import { Options } from './typings';
|
|
5
5
|
declare function yfmlint(opts: Options): void;
|
|
6
6
|
export = yfmlint;
|
|
7
7
|
declare namespace yfmlint {
|
package/lib/yfmlint/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const markdownlint_1 = require("markdownlint");
|
|
|
6
6
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
7
7
|
const union_1 = __importDefault(require("lodash/union"));
|
|
8
8
|
const markdown_it_attrs_1 = __importDefault(require("markdown-it-attrs"));
|
|
9
|
+
const preprocessors_1 = __importDefault(require("../preprocessors"));
|
|
9
10
|
const yfmlint_1 = __importDefault(require("./yfmlint"));
|
|
10
11
|
const markdownlint_custom_rule_1 = require("./markdownlint-custom-rule");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
@@ -13,7 +14,8 @@ const yfm009_1 = require("./markdownlint-custom-rule/yfm009");
|
|
|
13
14
|
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
15
|
const lintCache = new Set();
|
|
15
16
|
function yfmlint(opts) {
|
|
16
|
-
|
|
17
|
+
let { input } = opts;
|
|
18
|
+
const { plugins: customPlugins, preprocessors = preprocessors_1.default, pluginOptions, customLintRules, sourceMap, } = opts;
|
|
17
19
|
const { path = 'input', log } = pluginOptions;
|
|
18
20
|
pluginOptions.isLintRun = true;
|
|
19
21
|
const { LogLevels: { ERROR, WARN, DISABLED }, } = log;
|
|
@@ -32,6 +34,9 @@ function yfmlint(opts) {
|
|
|
32
34
|
}
|
|
33
35
|
const plugins = customPlugins && [markdown_it_attrs_1.default, ...customPlugins];
|
|
34
36
|
const preparedPlugins = plugins && plugins.map((plugin) => [plugin, pluginOptions]);
|
|
37
|
+
for (const preprocessor of preprocessors) {
|
|
38
|
+
input = preprocessor(input, pluginOptions);
|
|
39
|
+
}
|
|
35
40
|
let result;
|
|
36
41
|
try {
|
|
37
42
|
result = (0, markdownlint_1.sync)({
|
package/lib/yfmlint/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/yfmlint/index.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/yfmlint/index.ts"],"names":[],"mappings":";;;;AAEA,+CAAwC;AACxC,yDAAiC;AACjC,yDAAiC;AACjC,0EAAsC;AAGtC,qEAAoD;AAEpD,wDAA8C;AAC9C,yEASoC;AACpC,mCAAmD;AAEnD,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,IAAI,EAAC,KAAK,EAAC,GAAG,IAAI,CAAC;IACnB,MAAM,EACF,OAAO,EAAE,aAAa,EACtB,aAAa,GAAG,uBAAoB,EACpC,aAAa,EACb,eAAe,EACf,SAAS,GACZ,GAAG,IAAI,CAAC;IACT,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,CAAC,GAAG,CAAC,IAAI,CAAC,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AAI,MAAM,EAAE;QACxB,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAC,IAAI,EAAE,KAAK,EAAE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yfm001.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,yEAAgG;
|
|
1
|
+
{"version":3,"file":"yfm001.js","sourceRoot":"","sources":["../../../src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,yEAAgG;AAGnF,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"}
|
package/lib/yfmlint/typings.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Dictionary } from 'lodash';
|
|
2
2
|
import { Plugin, Rule } from 'markdownlint';
|
|
3
|
+
import { MarkdownItPreprocessorCb } from '../typings';
|
|
3
4
|
import { LintConfig, PluginOptions } from '.';
|
|
4
5
|
export interface Options {
|
|
5
6
|
input: string;
|
|
6
7
|
plugins?: Function[] | Plugin;
|
|
8
|
+
preprocessors?: MarkdownItPreprocessorCb[];
|
|
7
9
|
pluginOptions: PluginOptions;
|
|
8
10
|
defaultLintConfig?: LintConfig;
|
|
9
11
|
lintConfig?: LintConfig;
|
package/lib/yfmlint/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LogLevels } from '../log';
|
|
2
|
-
import { LintError } from 'markdownlint';
|
|
3
1
|
import type { Dictionary } from 'lodash';
|
|
2
|
+
import { LintError } from 'markdownlint';
|
|
3
|
+
import { LogLevels } from '../log';
|
|
4
4
|
export declare function errorToString(path: string, error: LintError, sourceMap?: Dictionary<string>): string;
|
|
5
5
|
export declare function getLogLevel(opts: {
|
|
6
6
|
ruleNames: string[];
|
package/lib/yfmlint/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transform/yfmlint/utils.ts"],"names":[],"mappings":";;;AAGA,+BAAyB;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/transform/yfmlint/utils.ts"],"names":[],"mappings":";;;AAGA,+BAAyB;AAIzB,SAAgB,aAAa,CAAC,IAAY,EAAE,KAAgB,EAAE,SAA8B;IACxF,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS;QAC/B,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,UAAG,CAAC;QAC3B,CAAC,CAAC,4CAA4C;YAC5C,KAAK,CAAC,QAAQ,GAAG,UAAG,GAAG,KAAK,CAAC,SAAS,CAAC;IAC7C,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAE9E,OAAO,CACH,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,eAAe,EAAE;QACzF,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,eAAe,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CACpE,CAAC;AACN,CAAC;AAZD,sCAYC;AAED,SAAgB,WAAW,CAAC,IAI3B;IACG,MAAM,EAAC,SAAS,EAAE,eAAe,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC;IACxD,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAC7B,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,eAAe,CAC5C,CAAC,CAAC,CAAiC,CAAC;IAErC,OAAO,eAAe,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC;AACrD,CAAC;AAXD,kCAWC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yfmlint.js","sourceRoot":"","sources":["../../src/transform/yfmlint/yfmlint.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"yfmlint.js","sourceRoot":"","sources":["../../src/transform/yfmlint/yfmlint.ts"],"names":[],"mappings":";AAAA,gCAAiC;AAIjC,MAAM,KAAK,GAAe;IACtB,8BAA8B;IAC9B,OAAO,EAAE,IAAI;IAEb,YAAY,EAAE;QACV,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,E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AE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,eAAS,CAAC,QAAQ;QAEzB,MAAM,EAAE,eAAS,CAAC,IAAI;QACtB,MAAM,EAAE,eAAS,CAAC,IAAI;QACtB,MAAM,EAAE,eAAS,CAAC,KAAK;QACvB,MAAM,EAAE,eAAS,CAAC,KAAK;QACvB,MAAM,EAAE,eAAS,CAAC,KAAK;QACvB,MAAM,EAAE,eAAS,CAAC,IAAI;QACtB,MAAM,EAAE,eAAS,CAAC,IAAI;QACtB,MAAM,EAAE,eAAS,CAAC,IAAI;QACtB,MAAM,EAAE,eAAS,CAAC,KAAK,EAAE,8CAA8C;KAC1E;IAED,qBAAqB;IACrB,MAAM,EAAE;QACJ,OAAO,EAAE,GAAG;KACf;CACJ,CAAC;AAEF,iBAAS,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diplodoc/transform",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.30.2",
|
|
4
4
|
"description": "A simple transformer of text in YFM (Yandex Flavored Markdown) to HTML",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -30,20 +30,21 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "npm run build:lib && npm run build:dist",
|
|
33
|
-
"build:dist": "./esbuild/build.
|
|
33
|
+
"build:dist": "./esbuild/build.mjs",
|
|
34
34
|
"build:lib": "tsc -p tsconfig.transform.json",
|
|
35
|
-
"lint": "eslint --max-warnings=0 \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
36
|
-
"lint:fix": "eslint --fix --max-warnings=0 \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
|
|
37
|
-
"precommit": "npm run lint && npm run test",
|
|
38
35
|
"prepublishOnly": "npm run lint && npm run test && npm run build",
|
|
39
36
|
"test": "jest --coverage",
|
|
40
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"lint": "lint update && lint",
|
|
39
|
+
"lint:fix": "lint update && lint fix",
|
|
40
|
+
"pre-commit": "lint update && lint-staged",
|
|
41
|
+
"prepare": "husky"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@diplodoc/cut-extension": "^0.2.5",
|
|
44
|
-
"@diplodoc/tabs-extension": "^3.3.
|
|
45
|
+
"@diplodoc/tabs-extension": "^3.3.1",
|
|
45
46
|
"chalk": "^4.1.2",
|
|
46
|
-
"cheerio": "^1.0.0
|
|
47
|
+
"cheerio": "^1.0.0",
|
|
47
48
|
"css": "^3.0.0",
|
|
48
49
|
"cssfilter": "0.0.10",
|
|
49
50
|
"get-root-node-polyfill": "1.0.0",
|
|
@@ -63,15 +64,14 @@
|
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
66
|
"@diplodoc/babel-preset": "^1.0.2",
|
|
66
|
-
"@diplodoc/
|
|
67
|
-
"@diplodoc/prettier-config": "^2.0.0",
|
|
67
|
+
"@diplodoc/lint": "^1.2.0",
|
|
68
68
|
"@diplodoc/tsconfig": "^1.0.2",
|
|
69
69
|
"@types/css": "0.0.34",
|
|
70
70
|
"@types/github-slugger": "^1.3.0",
|
|
71
71
|
"@types/jest": "28.1.7",
|
|
72
72
|
"@types/js-yaml": "^4.0.5",
|
|
73
73
|
"@types/lodash": "4.14.183",
|
|
74
|
-
"@types/markdown-it": "
|
|
74
|
+
"@types/markdown-it": "^13.0.9",
|
|
75
75
|
"@types/markdown-it-attrs": "4.1.0",
|
|
76
76
|
"@types/node": "17.0.10",
|
|
77
77
|
"@types/sanitize-html": "^2.9.3",
|
|
@@ -80,9 +80,11 @@
|
|
|
80
80
|
"esbuild-sass-plugin": "^2.12.0",
|
|
81
81
|
"highlight.js": "^11.8.0",
|
|
82
82
|
"jest": "28.1.3",
|
|
83
|
+
"jest-serializer-html": "^7.1.0",
|
|
83
84
|
"markdown-it-testgen": "^0.1.6",
|
|
84
85
|
"postcss": "^8.4.27",
|
|
85
86
|
"postcss-preset-env": "^9.1.1",
|
|
87
|
+
"ts-dedent": "^2.2.0",
|
|
86
88
|
"ts-jest": "28.0.8",
|
|
87
89
|
"typescript": "4.7.4"
|
|
88
90
|
},
|
package/src/.eslintrc.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
process.env.ESLINT_ENV = 'client';
|
|
2
|
-
|
|
3
1
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
extends: ['@diplodoc/eslint-config'],
|
|
6
|
-
overrides: [
|
|
7
|
-
{
|
|
8
|
-
files: ['*'],
|
|
9
|
-
rules: {
|
|
10
|
-
"no-shadow": "off",
|
|
11
|
-
'new-cap': [2, {capIsNew: false}],
|
|
12
|
-
'@typescript-eslint/no-namespace': [1, {allowDeclarations: true}],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
files: ['*.ts', '*.tsx'],
|
|
17
|
-
parser: '@typescript-eslint/parser',
|
|
18
|
-
parserOptions: {
|
|
19
|
-
sourceType: 'module',
|
|
20
|
-
project: ['./tsconfig.transform.json', './tsconfig.json'],
|
|
21
|
-
tsconfigRootDir: __dirname + '/../',
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
],
|
|
2
|
+
extends: require.resolve('@diplodoc/lint/eslint-config/client'),
|
|
25
3
|
};
|
package/src/js/index.ts
CHANGED
package/src/js/term/index.ts
CHANGED
package/src/transform/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
|
+
|
|
3
|
+
import {log} from '../log';
|
|
4
|
+
|
|
2
5
|
import {NoValue, evalExp} from './evaluation';
|
|
3
6
|
import {tagLine} from './lexical';
|
|
4
|
-
import {log} from '../log';
|
|
5
7
|
import {SourceMapApi, createSourceMapApi, getLineNumber} from './sourceMap';
|
|
6
8
|
|
|
7
9
|
interface SourceMap {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
2
|
|
|
3
|
+
import {log} from '../log';
|
|
4
|
+
|
|
3
5
|
import {evalExp} from './evaluation';
|
|
4
6
|
import {tagLine, variable} from './lexical';
|
|
5
|
-
import {log} from '../log';
|
|
6
7
|
import {getPreparedLeftContent} from './utils';
|
|
7
8
|
import {createSourceMapApi, getLineNumber} from './sourceMap';
|
|
9
|
+
|
|
8
10
|
import applyLiquid from './index';
|
|
9
11
|
|
|
10
12
|
type Options = {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import type {Dictionary} from 'lodash';
|
|
2
|
+
|
|
1
3
|
import applySubstitutions from './substitutions';
|
|
2
4
|
import {prepareSourceMap} from './sourceMap';
|
|
3
|
-
|
|
4
5
|
import applyCycles from './cycles';
|
|
5
6
|
import applyConditions from './conditions';
|
|
6
|
-
|
|
7
7
|
import ArgvService, {ArgvSettings} from './services/argv';
|
|
8
|
-
import type {Dictionary} from 'lodash';
|
|
9
8
|
|
|
10
9
|
const fence = '```';
|
|
11
10
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
2
|
|
|
3
|
-
import ArgvService from './services/argv';
|
|
4
3
|
import getObject from '../getObject';
|
|
5
|
-
import {evalExp} from './evaluation';
|
|
6
4
|
import {log} from '../log';
|
|
5
|
+
|
|
6
|
+
import ArgvService from './services/argv';
|
|
7
|
+
import {evalExp} from './evaluation';
|
|
7
8
|
import {
|
|
8
9
|
isSingleVariable,
|
|
9
10
|
isVariable,
|
package/src/transform/md.ts
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import type {EnvType, MarkdownIt, OptionsType} from './typings';
|
|
1
|
+
import type {EnvType, MarkdownIt, MarkdownItPluginOpts, OptionsType} from './typings';
|
|
2
2
|
import type Token from 'markdown-it/lib/token';
|
|
3
3
|
|
|
4
4
|
import DefaultMarkdownIt from 'markdown-it';
|
|
5
|
+
import attrs from 'markdown-it-attrs';
|
|
6
|
+
|
|
5
7
|
import DefaultPlugins from './plugins';
|
|
8
|
+
import DefaultPreprocessors from './preprocessors';
|
|
6
9
|
import {log} from './log';
|
|
7
10
|
import makeHighlight from './highlight';
|
|
8
|
-
import attrs from 'markdown-it-attrs';
|
|
9
11
|
import extractTitle from './title';
|
|
10
12
|
import getHeadings from './headings';
|
|
11
13
|
import sanitizeHtml from './sanitize';
|
|
12
14
|
|
|
13
15
|
function initMarkdownit(options: OptionsType) {
|
|
14
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
allowHTML = false,
|
|
18
|
+
linkify = false,
|
|
19
|
+
breaks = true,
|
|
20
|
+
highlightLangs = {},
|
|
21
|
+
disableRules = [],
|
|
22
|
+
} = options;
|
|
15
23
|
|
|
16
24
|
const highlight = makeHighlight(highlightLangs);
|
|
17
25
|
const md = new DefaultMarkdownIt({html: allowHTML, linkify, highlight, breaks}) as MarkdownIt;
|
|
26
|
+
|
|
27
|
+
if (disableRules?.length) {
|
|
28
|
+
md.disable(disableRules);
|
|
29
|
+
}
|
|
30
|
+
|
|
18
31
|
const env = {
|
|
19
32
|
// TODO: move md.meta directly to env
|
|
20
33
|
get meta() {
|
|
@@ -38,30 +51,32 @@ function initMarkdownit(options: OptionsType) {
|
|
|
38
51
|
title: '',
|
|
39
52
|
} as EnvType;
|
|
40
53
|
|
|
41
|
-
|
|
54
|
+
// Plugin options is the plugin context that remains during the build of one file
|
|
55
|
+
const pluginOptions = getPluginOptions(options);
|
|
56
|
+
|
|
57
|
+
// Init the plugins. Which install the md rules (core, block, ...)
|
|
58
|
+
initPlugins(md, options, pluginOptions);
|
|
59
|
+
|
|
60
|
+
// Init preprocessor and MD parser
|
|
61
|
+
const parse = initParser(md, options, env, pluginOptions);
|
|
42
62
|
|
|
43
|
-
|
|
63
|
+
// Init render to HTML compiler
|
|
44
64
|
const compile = initCompiler(md, options, env);
|
|
45
65
|
|
|
46
66
|
return {parse, compile, env};
|
|
47
67
|
}
|
|
48
68
|
|
|
49
|
-
function
|
|
69
|
+
function getPluginOptions(options: OptionsType) {
|
|
50
70
|
const {
|
|
51
71
|
vars = {},
|
|
52
72
|
path,
|
|
53
73
|
extractTitle,
|
|
54
74
|
conditionsInCode = false,
|
|
55
75
|
disableLiquid = false,
|
|
56
|
-
linkify = false,
|
|
57
|
-
linkifyTlds,
|
|
58
|
-
leftDelimiter = '{',
|
|
59
|
-
rightDelimiter = '}',
|
|
60
|
-
plugins = DefaultPlugins,
|
|
61
76
|
...customOptions
|
|
62
77
|
} = options;
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
return {
|
|
65
80
|
...customOptions,
|
|
66
81
|
conditionsInCode,
|
|
67
82
|
vars,
|
|
@@ -69,7 +84,17 @@ function initPlugins(md: MarkdownIt, options: OptionsType) {
|
|
|
69
84
|
extractTitle,
|
|
70
85
|
disableLiquid,
|
|
71
86
|
log,
|
|
72
|
-
};
|
|
87
|
+
} as MarkdownItPluginOpts;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function initPlugins(md: MarkdownIt, options: OptionsType, pluginOptions: MarkdownItPluginOpts) {
|
|
91
|
+
const {
|
|
92
|
+
linkify = false,
|
|
93
|
+
linkifyTlds,
|
|
94
|
+
leftDelimiter = '{',
|
|
95
|
+
rightDelimiter = '}',
|
|
96
|
+
plugins = DefaultPlugins,
|
|
97
|
+
} = options;
|
|
73
98
|
|
|
74
99
|
// Need for ids of headers
|
|
75
100
|
md.use(attrs, {leftDelimiter, rightDelimiter});
|
|
@@ -81,17 +106,30 @@ function initPlugins(md: MarkdownIt, options: OptionsType) {
|
|
|
81
106
|
}
|
|
82
107
|
}
|
|
83
108
|
|
|
84
|
-
function initParser(
|
|
109
|
+
function initParser(
|
|
110
|
+
md: MarkdownIt,
|
|
111
|
+
options: OptionsType,
|
|
112
|
+
env: EnvType,
|
|
113
|
+
pluginOptions: MarkdownItPluginOpts,
|
|
114
|
+
) {
|
|
85
115
|
return (input: string) => {
|
|
86
116
|
const {
|
|
87
117
|
extractTitle: extractTitleOption,
|
|
88
118
|
needTitle,
|
|
89
119
|
needFlatListHeadings = false,
|
|
90
120
|
getPublicPath,
|
|
121
|
+
preprocessors = DefaultPreprocessors,
|
|
91
122
|
} = options;
|
|
92
123
|
|
|
124
|
+
// Run input preprocessor
|
|
125
|
+
for (const preprocessor of preprocessors) {
|
|
126
|
+
input = preprocessor(input, pluginOptions, md);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Generate global href link
|
|
93
130
|
const href = getPublicPath ? getPublicPath(options) : '';
|
|
94
131
|
|
|
132
|
+
// Generate MD tokens
|
|
95
133
|
let tokens = md.parse(input, env);
|
|
96
134
|
|
|
97
135
|
if (extractTitleOption) {
|
|
@@ -121,12 +159,15 @@ function initCompiler(md: MarkdownIt, options: OptionsType, env: EnvType) {
|
|
|
121
159
|
const {needToSanitizeHtml = true, renderInline = false, sanitizeOptions} = options;
|
|
122
160
|
|
|
123
161
|
return (tokens: Token[]) => {
|
|
162
|
+
// Remove inline tokens if inline mode is activated
|
|
124
163
|
if (renderInline) {
|
|
125
164
|
tokens = tokens.filter((token) => token.type === 'inline');
|
|
126
165
|
}
|
|
127
166
|
|
|
167
|
+
// Generate HTML
|
|
128
168
|
const html = md.renderer.render(tokens, md.options, env);
|
|
129
169
|
|
|
170
|
+
// Sanitize the page
|
|
130
171
|
return needToSanitizeHtml ? sanitizeHtml(html, sanitizeOptions) : html;
|
|
131
172
|
};
|
|
132
173
|
}
|
|
@@ -3,10 +3,11 @@ import {sep} from 'path';
|
|
|
3
3
|
|
|
4
4
|
import {getSinglePageAnchorId, resolveRelativePath} from '../../utilsFS';
|
|
5
5
|
import {transformLinkToOriginalArticle} from '../../utils';
|
|
6
|
-
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
7
6
|
import {сarriage} from '../utils';
|
|
8
7
|
import {MarkdownItPluginOpts} from '../typings';
|
|
9
8
|
|
|
9
|
+
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
10
|
+
|
|
10
11
|
const slugify: (str: string, opts: {}) => string = require('slugify');
|
|
11
12
|
|
|
12
13
|
/* eslint-disable max-len */
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
2
|
import GithubSlugger from 'github-slugger';
|
|
3
|
-
|
|
4
|
-
import {headingInfo} from '../../utils';
|
|
5
|
-
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
6
3
|
import StateCore from 'markdown-it/lib/rules_core/state_core';
|
|
7
4
|
import Token from 'markdown-it/lib/token';
|
|
8
5
|
import {escapeHtml} from 'markdown-it/lib/common/utils';
|
|
6
|
+
|
|
7
|
+
import {headingInfo} from '../../utils';
|
|
9
8
|
import {MarkdownItPluginCb} from '../typings';
|
|
10
9
|
|
|
10
|
+
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
11
|
+
|
|
11
12
|
const slugify: (str: string, opts: {}) => string = require('slugify');
|
|
12
13
|
|
|
13
14
|
function createLinkTokens(
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import initMarkdownit from '../../md';
|
|
4
|
-
import changelogPlugin from './index';
|
|
5
4
|
import imsize from '../imsize';
|
|
6
5
|
import {MarkdownItPluginOpts} from '../typings';
|
|
7
6
|
|
|
7
|
+
import {ChangelogItem} from './types';
|
|
8
|
+
|
|
9
|
+
import changelogPlugin from './index';
|
|
10
|
+
|
|
8
11
|
const BLOCK_START = '{% changelog %}';
|
|
9
12
|
const BLOCK_END = '{% endchangelog %}';
|
|
10
13
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {MarkdownItPluginCb} from '../typings';
|
|
2
1
|
import Core from 'markdown-it/lib/parser_core';
|
|
3
2
|
import Token from 'markdown-it/lib/token';
|
|
4
3
|
import {bold} from 'chalk';
|
|
5
4
|
import yaml from 'js-yaml';
|
|
6
5
|
import StateCore from 'markdown-it/lib/rules_core/state_core';
|
|
7
6
|
|
|
7
|
+
import {MarkdownItPluginCb} from '../typings';
|
|
8
|
+
|
|
8
9
|
interface Options {
|
|
9
10
|
extractChangelogs?: boolean;
|
|
10
11
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {join, sep} from 'path';
|
|
2
2
|
import {bold} from 'chalk';
|
|
3
3
|
import {optimize} from 'svgo';
|
|
4
|
+
import Token from 'markdown-it/lib/token';
|
|
5
|
+
import {readFileSync} from 'fs';
|
|
4
6
|
|
|
5
7
|
import {isFileExists, resolveRelativePath} from '../../utilsFS';
|
|
6
8
|
import {isExternalHref, isLocalUrl} from '../../utils';
|
|
7
|
-
import Token from 'markdown-it/lib/token';
|
|
8
9
|
import {MarkdownItPluginCb, MarkdownItPluginOpts} from '../typings';
|
|
9
10
|
import {StateCore} from '../../typings';
|
|
10
|
-
import {readFileSync} from 'fs';
|
|
11
11
|
|
|
12
12
|
interface ImageOpts extends MarkdownItPluginOpts {
|
|
13
13
|
assetsPublicPath: string;
|