@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/src/transform/utilsFS.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {readFileSync, statSync} from 'fs';
|
|
2
1
|
import type {Dictionary} from 'lodash';
|
|
2
|
+
|
|
3
|
+
import {readFileSync, statSync} from 'fs';
|
|
3
4
|
import escapeRegExp from 'lodash/escapeRegExp';
|
|
4
5
|
import {join, parse, relative, resolve, sep} from 'path';
|
|
5
6
|
|
|
@@ -35,6 +36,7 @@ export type GetFileTokensOpts = {
|
|
|
35
36
|
disableCircularError?: boolean;
|
|
36
37
|
inheritVars?: boolean;
|
|
37
38
|
conditionsInCode?: boolean;
|
|
39
|
+
content?: string;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
export function getFileTokens(path: string, state: StateCore, options: GetFileTokensOpts) {
|
|
@@ -49,15 +51,18 @@ export function getFileTokens(path: string, state: StateCore, options: GetFileTo
|
|
|
49
51
|
inheritVars = true,
|
|
50
52
|
conditionsInCode,
|
|
51
53
|
} = options;
|
|
52
|
-
let content;
|
|
54
|
+
let {content} = options;
|
|
53
55
|
|
|
54
56
|
const builtVars = (getVarsPerFile && !inheritVars ? getVarsPerFile(path) : vars) || {};
|
|
55
57
|
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// Read the content only if we dont have one in the args
|
|
59
|
+
if (!content) {
|
|
60
|
+
if (filesCache[path]) {
|
|
61
|
+
content = filesCache[path];
|
|
62
|
+
} else {
|
|
63
|
+
content = readFileSync(path, 'utf8');
|
|
64
|
+
filesCache[path] = content;
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
let sourceMap;
|
|
@@ -148,3 +153,10 @@ export function getPublicPath(
|
|
|
148
153
|
const href = transformer(filePath);
|
|
149
154
|
return href;
|
|
150
155
|
}
|
|
156
|
+
|
|
157
|
+
export function getRelativePath(path: string, toPath: string) {
|
|
158
|
+
const pathDirs = path.split(sep);
|
|
159
|
+
pathDirs.pop();
|
|
160
|
+
const parentPath = pathDirs.join(sep);
|
|
161
|
+
return relative(parentPath, toPath);
|
|
162
|
+
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import type {Dictionary} from 'lodash';
|
|
2
|
+
|
|
1
3
|
import {Rule, sync} from 'markdownlint';
|
|
2
4
|
import merge from 'lodash/merge';
|
|
3
5
|
import union from 'lodash/union';
|
|
4
6
|
import attrs from 'markdown-it-attrs';
|
|
5
|
-
import baseDefaultLintConfig from './yfmlint';
|
|
6
7
|
|
|
8
|
+
import {LogLevels, Logger} from '../log';
|
|
9
|
+
import defaultPreprocessors from '../preprocessors';
|
|
10
|
+
|
|
11
|
+
import baseDefaultLintConfig from './yfmlint';
|
|
7
12
|
import {
|
|
8
13
|
yfm001,
|
|
9
14
|
yfm002,
|
|
@@ -14,11 +19,8 @@ import {
|
|
|
14
19
|
yfm007,
|
|
15
20
|
yfm008,
|
|
16
21
|
} from './markdownlint-custom-rule';
|
|
17
|
-
|
|
18
22
|
import {errorToString, getLogLevel} from './utils';
|
|
19
23
|
import {Options} from './typings';
|
|
20
|
-
import type {Dictionary} from 'lodash';
|
|
21
|
-
import {LogLevels, Logger} from '../log';
|
|
22
24
|
import {yfm009} from './markdownlint-custom-rule/yfm009';
|
|
23
25
|
|
|
24
26
|
const defaultLintRules = [yfm001, yfm002, yfm003, yfm004, yfm005, yfm006, yfm007, yfm008, yfm009];
|
|
@@ -26,7 +28,14 @@ const defaultLintRules = [yfm001, yfm002, yfm003, yfm004, yfm005, yfm006, yfm007
|
|
|
26
28
|
const lintCache = new Set();
|
|
27
29
|
|
|
28
30
|
function yfmlint(opts: Options) {
|
|
29
|
-
|
|
31
|
+
let {input} = opts;
|
|
32
|
+
const {
|
|
33
|
+
plugins: customPlugins,
|
|
34
|
+
preprocessors = defaultPreprocessors,
|
|
35
|
+
pluginOptions,
|
|
36
|
+
customLintRules,
|
|
37
|
+
sourceMap,
|
|
38
|
+
} = opts;
|
|
30
39
|
const {path = 'input', log} = pluginOptions;
|
|
31
40
|
|
|
32
41
|
pluginOptions.isLintRun = true;
|
|
@@ -56,6 +65,10 @@ function yfmlint(opts: Options) {
|
|
|
56
65
|
const plugins = customPlugins && [attrs, ...customPlugins];
|
|
57
66
|
const preparedPlugins = plugins && plugins.map((plugin) => [plugin, pluginOptions]);
|
|
58
67
|
|
|
68
|
+
for (const preprocessor of preprocessors) {
|
|
69
|
+
input = preprocessor(input, pluginOptions);
|
|
70
|
+
}
|
|
71
|
+
|
|
59
72
|
let result;
|
|
60
73
|
try {
|
|
61
74
|
result = sync({
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type {Dictionary} from 'lodash';
|
|
2
|
+
|
|
2
3
|
import {Plugin, Rule} from 'markdownlint';
|
|
4
|
+
|
|
5
|
+
import {MarkdownItPreprocessorCb} from '../typings';
|
|
6
|
+
|
|
3
7
|
import {LintConfig, PluginOptions} from '.';
|
|
4
8
|
|
|
5
9
|
export interface Options {
|
|
6
10
|
input: string;
|
|
7
11
|
plugins?: Function[] | Plugin;
|
|
12
|
+
preprocessors?: MarkdownItPreprocessorCb[];
|
|
8
13
|
pluginOptions: PluginOptions;
|
|
9
14
|
defaultLintConfig?: LintConfig;
|
|
10
15
|
lintConfig?: LintConfig;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {LogLevels} from '../log';
|
|
2
|
-
import {LintError} from 'markdownlint';
|
|
3
1
|
import type {Dictionary} from 'lodash';
|
|
2
|
+
|
|
3
|
+
import {LintError} from 'markdownlint';
|
|
4
4
|
import {sep} from 'path';
|
|
5
5
|
|
|
6
|
+
import {LogLevels} from '../log';
|
|
7
|
+
|
|
6
8
|
export function errorToString(path: string, error: LintError, sourceMap?: Dictionary<string>) {
|
|
7
9
|
const ruleMoniker = error.ruleNames
|
|
8
10
|
? error.ruleNames.join(sep)
|