@diplodoc/transform 4.36.0 → 4.37.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/README.md +61 -0
- package/README.ru.md +61 -0
- package/dist/css/_yfm-only.css.map +1 -1
- package/dist/css/_yfm-only.min.css.map +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/base.min.css.map +1 -1
- package/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css.map +1 -1
- package/dist/css/yfm.min.css.map +1 -1
- package/lib/md.js +4 -6
- package/lib/md.js.map +1 -1
- package/lib/plugins/includes/collect.js +8 -7
- package/lib/plugins/includes/collect.js.map +1 -1
- package/lib/plugins/includes/index.js +3 -4
- package/lib/plugins/includes/index.js.map +1 -1
- package/lib/plugins/includes/types.d.ts +1 -1
- package/lib/plugins/links/index.js +10 -7
- package/lib/plugins/links/index.js.map +1 -1
- package/lib/preprocessors/included/index.js +8 -3
- package/lib/preprocessors/included/index.js.map +1 -1
- package/lib/preprocessors/index.d.ts +7 -0
- package/lib/preprocessors/index.js +18 -0
- package/lib/preprocessors/index.js.map +1 -0
- package/lib/utilsFS.d.ts +1 -1
- package/lib/utilsFS.js +4 -2
- package/lib/utilsFS.js.map +1 -1
- package/lib/yfmlint/index.js +4 -5
- package/lib/yfmlint/index.js.map +1 -1
- package/package.json +1 -1
- package/src/transform/md.ts +3 -6
- package/src/transform/plugins/file/README.md +0 -54
- package/src/transform/plugins/includes/collect.ts +10 -8
- package/src/transform/plugins/includes/index.ts +5 -15
- package/src/transform/plugins/includes/types.ts +1 -1
- package/src/transform/plugins/links/index.ts +29 -14
- package/src/transform/preprocessors/included/index.ts +9 -3
- package/src/transform/preprocessors/index.ts +25 -0
- package/src/transform/utilsFS.ts +10 -2
- package/src/transform/yfmlint/index.ts +4 -11
- package/lib/preprocessors.d.ts +0 -3
- package/lib/preprocessors.js +0 -8
- package/lib/preprocessors.js.map +0 -1
- package/src/scss/_cut.scss +0 -55
- package/src/transform/preprocessors.ts +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transform/preprocessors/included/index.ts"],"names":[],"mappings":";AAAA,2CAAiD;AAIjD,MAAM,cAAc,GAAG,wCAAwC,CAAC;AAChE,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD,MAAM,cAAc,GAAG,CACnB,KAAe,EACf,KAAa,EACb,EACI,IAAI,EACJ,IAAI,GAIP,EACD,EAAuB,EACzB,EAAE;IACA,MAAM,gBAAgB,GAAG,EAAE,IAAI,IAAI,IAAI,IAAI,CAAC;IAC5C,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAEzC,iCAAiC;IACjC,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,KAAK,CAAC;KAChB;IAED,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transform/preprocessors/included/index.ts"],"names":[],"mappings":";AAAA,2CAAiD;AAIjD,MAAM,cAAc,GAAG,wCAAwC,CAAC;AAChE,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD,MAAM,cAAc,GAAG,CACnB,KAAe,EACf,KAAa,EACb,EACI,IAAI,EACJ,IAAI,GAIP,EACD,EAAuB,EACzB,EAAE;IACA,MAAM,gBAAgB,GAAG,EAAE,IAAI,IAAI,IAAI,IAAI,CAAC;IAC5C,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAEzC,iCAAiC;IACjC,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,KAAK,CAAC;KAChB;IAED,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,C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CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAErC,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,KAAK,GAEN,CAAC,KAAK,EAAE,OAAO,EAAE,EAAuB,EAAE,EAAE;IAC7C,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAC,GAAG,OAAO,CAAC;IAEvC,oFAAoF;IACpF,IAAI,QAAQ,EAAE;QACV,MAAM,KAAK,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,IAAI,CAAC,KAAI,EAAE,CAAC;QAEvC,8GAA8G;QAC9G,gIAAgI;QAChI,wDAAwD;QACxD,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,EAAE;YAClB,IAAI,QAAQ,GAAG,KAAK,CAAC;YACrB,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE;gBACjD,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,EAAE,EAAE,CAAC,CAAC;gBACzD,IAAI,QAAQ,EAAE;oBACV,MAAM;iBACT;aACJ;YACD,IAAI,CAAC,QAAQ,EAAE;gBACX,MAAM;aACT;SACJ;QAED,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5B;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,iBAAS,KAAK,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MarkdownIt, MarkdownItPluginOpts, MarkdownItPreprocessorCb } from '../plugins/typings';
|
|
2
|
+
import type { PluginOptions } from '../yfmlint';
|
|
3
|
+
declare const defaultPreprocessors: MarkdownItPreprocessorCb<{}>[];
|
|
4
|
+
export default defaultPreprocessors;
|
|
5
|
+
export declare function preprocess(content: string, pluginOptions: MarkdownItPluginOpts | PluginOptions | unknown, options?: Partial<MarkdownItPluginOpts> & {
|
|
6
|
+
preprocessors?: MarkdownItPreprocessorCb[];
|
|
7
|
+
}, md?: MarkdownIt): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
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.preprocess = void 0;
|
|
7
|
+
const included_1 = __importDefault(require("./included"));
|
|
8
|
+
const defaultPreprocessors = [included_1.default];
|
|
9
|
+
exports.default = defaultPreprocessors;
|
|
10
|
+
function preprocess(content, pluginOptions, options, md) {
|
|
11
|
+
const { preprocessors = defaultPreprocessors } = options !== null && options !== void 0 ? options : {};
|
|
12
|
+
for (const preprocessor of preprocessors) {
|
|
13
|
+
content = preprocessor(content, pluginOptions, md);
|
|
14
|
+
}
|
|
15
|
+
return content;
|
|
16
|
+
}
|
|
17
|
+
exports.preprocess = preprocess;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/preprocessors/index.ts"],"names":[],"mappings":";;;;;;AAGA,0DAAkC;AAElC,MAAM,oBAAoB,GAAG,CAAC,kBAAQ,CAA+B,CAAC;AAEtE,kBAAe,oBAAoB,CAAC;AAEpC,SAAgB,UAAU,CACtB,OAAe,EACf,aAA6D,EAC7D,OAEC,EACD,EAAe;IAEf,MAAM,EAAC,aAAa,GAAG,oBAAoB,EAAC,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAE7D,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACtC,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,aAAqC,EAAE,EAAE,CAAC,CAAC;KAC9E;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAfD,gCAeC"}
|
package/lib/utilsFS.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare type GetFileTokensOpts = {
|
|
|
18
18
|
conditionsInCode?: boolean;
|
|
19
19
|
content?: string;
|
|
20
20
|
};
|
|
21
|
-
export declare function getFileTokens(path: string, state: StateCore, options: GetFileTokensOpts): import("markdown-it/lib/token")[];
|
|
21
|
+
export declare function getFileTokens(path: string, state: StateCore, options: GetFileTokensOpts, content?: string): import("markdown-it/lib/token")[];
|
|
22
22
|
export declare const getFullIncludePath: (includePath: string, root: string, path: string) => string;
|
|
23
23
|
export declare function getSinglePageAnchorId(args: {
|
|
24
24
|
root: string;
|
package/lib/utilsFS.js
CHANGED
|
@@ -9,6 +9,7 @@ const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
|
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const liquid_1 = __importDefault(require("./liquid"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const preprocessors_1 = require("./preprocessors");
|
|
12
13
|
const filesCache = {};
|
|
13
14
|
function isFileExists(file) {
|
|
14
15
|
try {
|
|
@@ -25,9 +26,8 @@ function resolveRelativePath(fromPath, relativePath) {
|
|
|
25
26
|
return (0, path_1.resolve)(fromDir, relativePath);
|
|
26
27
|
}
|
|
27
28
|
exports.resolveRelativePath = resolveRelativePath;
|
|
28
|
-
function getFileTokens(path, state, options) {
|
|
29
|
+
function getFileTokens(path, state, options, content) {
|
|
29
30
|
const { getVarsPerFile, vars, disableLiquid, disableLint, lintMarkdown, disableTitleRefSubstitution, disableCircularError, inheritVars = true, conditionsInCode, } = options;
|
|
30
|
-
let { content } = options;
|
|
31
31
|
const builtVars = (getVarsPerFile && !inheritVars ? getVarsPerFile(path) : vars) || {};
|
|
32
32
|
// Read the content only if we dont have one in the args
|
|
33
33
|
if (!content) {
|
|
@@ -48,6 +48,8 @@ function getFileTokens(path, state, options) {
|
|
|
48
48
|
content = liquidResult.output;
|
|
49
49
|
sourceMap = liquidResult.sourceMap;
|
|
50
50
|
}
|
|
51
|
+
// Run preprocessor
|
|
52
|
+
content = (0, preprocessors_1.preprocess)(content, options);
|
|
51
53
|
if (!disableLint && lintMarkdown) {
|
|
52
54
|
lintMarkdown({
|
|
53
55
|
input: content,
|
package/lib/utilsFS.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsFS.js","sourceRoot":"","sources":["../src/transform/utilsFS.ts"],"names":[],"mappings":";;;;;;AAEA,2BAA0C;AAC1C,uEAA+C;AAC/C,+BAAyD;AAEzD,sDAAqC;AAErC,mCAA6C;
|
|
1
|
+
{"version":3,"file":"utilsFS.js","sourceRoot":"","sources":["../src/transform/utilsFS.ts"],"names":[],"mappings":";;;;;;AAEA,2BAA0C;AAC1C,uEAA+C;AAC/C,+BAAyD;AAEzD,sDAAqC;AAErC,mCAA6C;AAC7C,mDAA2C;AAE3C,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,CAAC;AAJD,kDAIC;AAeD,SAAgB,aAAa,CACzB,IAAY,EACZ,KAAgB,EAChB,OAA0B,EAC1B,OAAgB;IAEhB,MAAM,EACF,cAAc,EACd,IAAI,EACJ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,2BAA2B,EAC3B,oBAA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xC,MAAM,QAAQ,GAAG,IAAA,eAAQ,EAAC,IAAA,cAAO,EAAC,IAAI,IAAI,EAAE,EAAE,cAAc,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IAClF,MAAM,WAAW,GAAG,aAAa,IAAI,4BAAoB,CAAC;IAC1D,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC;AAChB,CAAC;AAnBD,sCAmBC;AAED,SAAgB,eAAe,CAAC,IAAY,EAAE,MAAc;IACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,UAAG,CAAC,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,CAAC;IACf,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAG,CAAC,CAAC;IACtC,OAAO,IAAA,eAAQ,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AALD,0CAKC"}
|
package/lib/yfmlint/index.js
CHANGED
|
@@ -6,7 +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 =
|
|
9
|
+
const preprocessors_1 = require("../preprocessors");
|
|
10
10
|
const yfmlint_1 = __importDefault(require("./yfmlint"));
|
|
11
11
|
const markdownlint_custom_rule_1 = require("./markdownlint-custom-rule");
|
|
12
12
|
const utils_1 = require("./utils");
|
|
@@ -15,7 +15,7 @@ const defaultLintRules = [markdownlint_custom_rule_1.yfm001, markdownlint_custom
|
|
|
15
15
|
const lintCache = new Set();
|
|
16
16
|
function yfmlint(opts) {
|
|
17
17
|
let { input } = opts;
|
|
18
|
-
const { plugins: customPlugins,
|
|
18
|
+
const { plugins: customPlugins, pluginOptions, customLintRules, sourceMap } = opts;
|
|
19
19
|
const { path = 'input', log } = pluginOptions;
|
|
20
20
|
pluginOptions.isLintRun = true;
|
|
21
21
|
const { LogLevels: { ERROR, WARN, DISABLED }, } = log;
|
|
@@ -34,9 +34,8 @@ function yfmlint(opts) {
|
|
|
34
34
|
}
|
|
35
35
|
const plugins = customPlugins && [markdown_it_attrs_1.default, ...customPlugins];
|
|
36
36
|
const preparedPlugins = plugins && plugins.map((plugin) => [plugin, pluginOptions]);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
37
|
+
// Run preprocessor
|
|
38
|
+
input = (0, preprocessors_1.preprocess)(input, pluginOptions, opts);
|
|
40
39
|
let result;
|
|
41
40
|
try {
|
|
42
41
|
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":";;;;AAEA,+CAAwC;AACxC,yDAAiC;AACjC,yDAAiC;AACjC,0EAAsC;AAGtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/yfmlint/index.ts"],"names":[],"mappings":";;;;AAEA,+CAAwC;AACxC,yDAAiC;AACjC,yDAAiC;AACjC,0EAAsC;AAGtC,oDAA4C;AAE5C,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,EAAC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,SAAS,EAAC,GAAG,IA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YAClB,WAAW,EAAE,SAAS;SACzB,CAAC,CAAC;KACN;IAAC,WAAM,GAAE;IAEV,MAAM,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,EAAE;QACT,OAAO;KACV;IAED,MAAM,eAAe,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEjD,KAAK,MAAM,KAAK,IAAI,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"}
|
package/package.json
CHANGED
package/src/transform/md.ts
CHANGED
|
@@ -5,7 +5,7 @@ import DefaultMarkdownIt from 'markdown-it';
|
|
|
5
5
|
import attrs from 'markdown-it-attrs';
|
|
6
6
|
|
|
7
7
|
import DefaultPlugins from './plugins';
|
|
8
|
-
import
|
|
8
|
+
import {preprocess} from './preprocessors';
|
|
9
9
|
import {log} from './log';
|
|
10
10
|
import makeHighlight from './highlight';
|
|
11
11
|
import extractTitle from './title';
|
|
@@ -118,13 +118,10 @@ function initParser(
|
|
|
118
118
|
needTitle,
|
|
119
119
|
needFlatListHeadings = false,
|
|
120
120
|
getPublicPath,
|
|
121
|
-
preprocessors = DefaultPreprocessors,
|
|
122
121
|
} = options;
|
|
123
122
|
|
|
124
|
-
// Run
|
|
125
|
-
|
|
126
|
-
input = preprocessor(input, pluginOptions, md);
|
|
127
|
-
}
|
|
123
|
+
// Run preprocessor
|
|
124
|
+
input = preprocess(input, pluginOptions, options, md);
|
|
128
125
|
|
|
129
126
|
// Generate global href link
|
|
130
127
|
const href = getPublicPath ? getPublicPath(options) : '';
|
|
@@ -32,57 +32,3 @@
|
|
|
32
32
|
|
|
33
33
|
- `--yfm-file-icon` – sets custom file icon image
|
|
34
34
|
- `--yfm-file-icon-color` – sets custom file icon color
|
|
35
|
-
|
|
36
|
-
_common_
|
|
37
|
-
|
|
38
|
-
- `--yfm-color-text`
|
|
39
|
-
- `--yfm-color-link`
|
|
40
|
-
- `--yfm-color-base`
|
|
41
|
-
- `--yfm-color-link-hover`
|
|
42
|
-
- `--yfm-color-table`
|
|
43
|
-
- `--yfm-color-table-row-background`
|
|
44
|
-
- `--yfm-color-border`
|
|
45
|
-
- `--yfm-color-accent`
|
|
46
|
-
|
|
47
|
-
_code_
|
|
48
|
-
|
|
49
|
-
- `--yfm-color-inline-code`
|
|
50
|
-
- `--yfm-color-inline-code-background`
|
|
51
|
-
- `--yfm-color-code-background`
|
|
52
|
-
|
|
53
|
-
_hightlight_
|
|
54
|
-
|
|
55
|
-
- `--yfm-color-hljs-background`
|
|
56
|
-
- `--yfm-color-hljs-subst`
|
|
57
|
-
- `--yfm-color-hljs-comment`
|
|
58
|
-
- `--yfm-color-hljs-deletion`
|
|
59
|
-
- `--yfm-color-hljs-section`
|
|
60
|
-
- `--yfm-color-hljs-pseudo`
|
|
61
|
-
- `--yfm-color-hljs-literal`
|
|
62
|
-
- `--yfm-color-hljs-addition`
|
|
63
|
-
- `--yfm-color-hljs-meta`
|
|
64
|
-
- `--yfm-color-hljs-meta-string`
|
|
65
|
-
|
|
66
|
-
_note_
|
|
67
|
-
|
|
68
|
-
- `--yfm-color-note-tip`
|
|
69
|
-
- `--yfm-color-note-tip-background`
|
|
70
|
-
- `--yfm-color-note-warning`
|
|
71
|
-
- `--yfm-color-note-warning-background`
|
|
72
|
-
- `--yfm-color-note-important-background`
|
|
73
|
-
- `--yfm-color-note-info-background`
|
|
74
|
-
|
|
75
|
-
_term_
|
|
76
|
-
|
|
77
|
-
- `--yfm-color-term-title`
|
|
78
|
-
- `--yfm-color-term-title-hover`
|
|
79
|
-
- `--yfm-color-term-dfn-background`
|
|
80
|
-
- `--yfm-color-term-dfn-shadow`
|
|
81
|
-
- `--yfm-color-term-dfn-pseudo-shadow`
|
|
82
|
-
|
|
83
|
-
_modal_
|
|
84
|
-
|
|
85
|
-
- `--yfm-color-modal-content`
|
|
86
|
-
- `--yfm-color-modal-actions-hover`
|
|
87
|
-
- `--yfm-color-modal-wide-content`
|
|
88
|
-
- `--yfm-color-modal-wide-content-overlay`
|
|
@@ -2,19 +2,20 @@ import {relative} from 'path';
|
|
|
2
2
|
import {bold} from 'chalk';
|
|
3
3
|
import {readFileSync} from 'fs';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {isFileExists, resolveRelativePath} from '../../utilsFS';
|
|
6
6
|
|
|
7
7
|
import {IncludeCollectOpts} from './types';
|
|
8
8
|
|
|
9
9
|
const includesPaths: string[] = [];
|
|
10
10
|
|
|
11
11
|
function processRecursive(
|
|
12
|
+
relativePath: string,
|
|
12
13
|
includePath: string,
|
|
13
14
|
targetDestPath: string,
|
|
14
15
|
options: IncludeCollectOpts,
|
|
15
16
|
) {
|
|
16
17
|
const {path, log, copyFile, includedParentPath: includedParentPathNullable, included} = options;
|
|
17
|
-
const includedParentPath = includedParentPathNullable ||
|
|
18
|
+
const includedParentPath = includedParentPathNullable || [];
|
|
18
19
|
|
|
19
20
|
const includeOptions = {
|
|
20
21
|
...options,
|
|
@@ -30,21 +31,22 @@ function processRecursive(
|
|
|
30
31
|
const content = contentProcessed ?? readFileSync(targetDestPath, 'utf8');
|
|
31
32
|
|
|
32
33
|
if (content) {
|
|
33
|
-
const
|
|
34
|
+
const key = [...includedParentPath, relativePath];
|
|
35
|
+
const hash = key.join(':');
|
|
34
36
|
|
|
35
37
|
// The appendix is the map that protects from multiple include files
|
|
36
|
-
if (!options.appendix?.has(
|
|
38
|
+
if (!options.appendix?.has(hash)) {
|
|
37
39
|
// Recursive function to include the depth structure
|
|
38
40
|
const includeContent = collectRecursive(content, {
|
|
39
41
|
...options,
|
|
40
42
|
path: includePath,
|
|
41
|
-
includedParentPath,
|
|
43
|
+
includedParentPath: key,
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
// Add to appendix set structure
|
|
45
47
|
options.appendix?.set(
|
|
46
|
-
|
|
47
|
-
`{% included (${
|
|
48
|
+
relativePath,
|
|
49
|
+
`{% included (${hash}) %}\n${includeContent}\n{% endincluded %}`,
|
|
48
50
|
);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -91,7 +93,7 @@ function collectRecursive(result: string, options: IncludeCollectOpts) {
|
|
|
91
93
|
|
|
92
94
|
includesPaths.push(includePath);
|
|
93
95
|
|
|
94
|
-
processRecursive(includePath, targetDestPath, options);
|
|
96
|
+
processRecursive(relativePath, includePath, targetDestPath, options);
|
|
95
97
|
|
|
96
98
|
includesPaths.pop();
|
|
97
99
|
}
|
|
@@ -2,13 +2,7 @@ import {bold} from 'chalk';
|
|
|
2
2
|
import Token from 'markdown-it/lib/token';
|
|
3
3
|
|
|
4
4
|
import {StateCore} from '../../typings';
|
|
5
|
-
import {
|
|
6
|
-
GetFileTokensOpts,
|
|
7
|
-
getFileTokens,
|
|
8
|
-
getFullIncludePath,
|
|
9
|
-
isFileExists,
|
|
10
|
-
resolveRelativePath,
|
|
11
|
-
} from '../../utilsFS';
|
|
5
|
+
import {GetFileTokensOpts, getFileTokens, getFullIncludePath, isFileExists} from '../../utilsFS';
|
|
12
6
|
import {findBlockTokens} from '../../utils';
|
|
13
7
|
import {MarkdownItPluginCb, MarkdownItPluginOpts} from '../typings';
|
|
14
8
|
|
|
@@ -49,10 +43,6 @@ function unfoldIncludes(md: MarkdownItIncluded, state: StateCore, path: string,
|
|
|
49
43
|
const [, keyword /* description */, , includePath] = match;
|
|
50
44
|
|
|
51
45
|
const fullIncludePath = getFullIncludePath(includePath, root, path);
|
|
52
|
-
const relativeIncludePath = resolveRelativePath(path, includePath);
|
|
53
|
-
|
|
54
|
-
// Check the existed included store and extract it
|
|
55
|
-
const included = md.included?.[relativeIncludePath];
|
|
56
46
|
|
|
57
47
|
let pathname = fullIncludePath;
|
|
58
48
|
let hash = '';
|
|
@@ -68,10 +58,10 @@ function unfoldIncludes(md: MarkdownItIncluded, state: StateCore, path: string,
|
|
|
68
58
|
continue;
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
// Check the existed included store and extract it
|
|
62
|
+
const included = md.included?.[pathname];
|
|
63
|
+
|
|
64
|
+
const fileTokens = getFileTokens(pathname, state, options, included);
|
|
75
65
|
|
|
76
66
|
let includedTokens;
|
|
77
67
|
if (hash) {
|
|
@@ -12,7 +12,7 @@ export type IncludeCollectOpts = MarkdownItPluginOpts & {
|
|
|
12
12
|
copyFile(path: string, dest: string, opts: IncludeCollectOpts): string | null | undefined;
|
|
13
13
|
singlePage: Boolean;
|
|
14
14
|
included: Boolean;
|
|
15
|
-
includedParentPath?: string;
|
|
15
|
+
includedParentPath?: string[];
|
|
16
16
|
additionalIncludedList?: string[];
|
|
17
17
|
appendix?: Map<string, string>;
|
|
18
18
|
};
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import {getFileTokens, isFileExists} from '../../utilsFS';
|
|
17
17
|
import {CacheContext, StateCore} from '../../typings';
|
|
18
18
|
import {MarkdownItPluginCb, MarkdownItPluginOpts} from '../typings';
|
|
19
|
+
import {MarkdownItIncluded} from '../includes/types';
|
|
19
20
|
|
|
20
21
|
function getTitleFromTokens(tokens: Token[]) {
|
|
21
22
|
let title = '';
|
|
@@ -51,27 +52,35 @@ type Options = {
|
|
|
51
52
|
cache?: CacheContext;
|
|
52
53
|
};
|
|
53
54
|
|
|
54
|
-
const getTitle = (id: string | null, options: Options) => {
|
|
55
|
+
const getTitle = (md: MarkdownItIncluded, id: string | null, options: Options) => {
|
|
55
56
|
const {file, state, opts} = options;
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
// Check the existed included store and extract it
|
|
59
|
+
const included = md.included?.[file];
|
|
60
|
+
|
|
61
|
+
const fileTokens = getFileTokens(
|
|
62
|
+
file,
|
|
63
|
+
state,
|
|
64
|
+
{
|
|
65
|
+
...opts,
|
|
66
|
+
disableLint: true,
|
|
67
|
+
disableTitleRefSubstitution: true,
|
|
68
|
+
disableCircularError: true,
|
|
69
|
+
inheritVars: false,
|
|
70
|
+
},
|
|
71
|
+
included,
|
|
72
|
+
);
|
|
64
73
|
const sourceTokens = id ? findBlockTokens(fileTokens, id) : fileTokens;
|
|
65
74
|
return getTitleFromTokens(sourceTokens);
|
|
66
75
|
};
|
|
67
76
|
|
|
68
|
-
const addTitle = (options: Options) => {
|
|
77
|
+
const addTitle = (md: MarkdownItIncluded, options: Options) => {
|
|
69
78
|
const {hash, state, isEmptyLink, tokens, idx, nextToken, href, currentPath, log, cache} =
|
|
70
79
|
options;
|
|
71
80
|
|
|
72
81
|
const id = hash && hash.slice(1);
|
|
73
82
|
const key = [id, path].join('::');
|
|
74
|
-
const title = cache?.get(key) ?? getTitle(id, options);
|
|
83
|
+
const title = cache?.get(key) ?? getTitle(md, id, options);
|
|
75
84
|
cache?.set(key, title);
|
|
76
85
|
|
|
77
86
|
if (title) {
|
|
@@ -111,7 +120,13 @@ function getDefaultPublicPath(
|
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
// eslint-disable-next-line complexity
|
|
114
|
-
function processLink(
|
|
123
|
+
function processLink(
|
|
124
|
+
md: MarkdownItIncluded,
|
|
125
|
+
state: StateCore,
|
|
126
|
+
tokens: Token[],
|
|
127
|
+
idx: number,
|
|
128
|
+
opts: ProcOpts,
|
|
129
|
+
) {
|
|
115
130
|
const {
|
|
116
131
|
path: startPath,
|
|
117
132
|
root,
|
|
@@ -180,7 +195,7 @@ function processLink(state: StateCore, tokens: Token[], idx: number, opts: ProcO
|
|
|
180
195
|
isPageFile &&
|
|
181
196
|
!state.env.disableTitleRefSubstitution
|
|
182
197
|
) {
|
|
183
|
-
addTitle({
|
|
198
|
+
addTitle(md, {
|
|
184
199
|
hash,
|
|
185
200
|
file,
|
|
186
201
|
state,
|
|
@@ -213,7 +228,7 @@ function processLink(state: StateCore, tokens: Token[], idx: number, opts: ProcO
|
|
|
213
228
|
}
|
|
214
229
|
}
|
|
215
230
|
|
|
216
|
-
const index: MarkdownItPluginCb<ProcOpts & Options> = (md, opts) => {
|
|
231
|
+
const index: MarkdownItPluginCb<ProcOpts & Options> = (md: MarkdownItIncluded, opts) => {
|
|
217
232
|
const plugin = (state: StateCore) => {
|
|
218
233
|
const tokens = state.tokens;
|
|
219
234
|
let i = 0;
|
|
@@ -231,7 +246,7 @@ const index: MarkdownItPluginCb<ProcOpts & Options> = (md, opts) => {
|
|
|
231
246
|
const isYfmAnchor = tokenClass ? tokenClass.includes('yfm-anchor') : false;
|
|
232
247
|
|
|
233
248
|
if (isLinkOpenToken && !isYfmAnchor) {
|
|
234
|
-
processLink(state, childrenTokens, j, opts);
|
|
249
|
+
processLink(md, state, childrenTokens, j, opts);
|
|
235
250
|
}
|
|
236
251
|
|
|
237
252
|
j++;
|
|
@@ -26,13 +26,15 @@ const preprocessLine = (
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const includePathKey = match[1];
|
|
30
30
|
|
|
31
31
|
// Protect from empty path
|
|
32
|
-
if (!
|
|
32
|
+
if (!includePathKey) {
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
const includePaths = includePathKey.split(':');
|
|
37
|
+
|
|
36
38
|
// Read all content from top to bottom(!) char of the included block
|
|
37
39
|
const data = [];
|
|
38
40
|
let line = start;
|
|
@@ -55,7 +57,11 @@ const preprocessLine = (
|
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
// Normalize the path to absolute
|
|
58
|
-
|
|
60
|
+
let includePath = getFullIncludePath(includePaths[0], root, path);
|
|
61
|
+
for (let index = 1; index < includePaths.length; index++) {
|
|
62
|
+
const pathname = includePaths[index];
|
|
63
|
+
includePath = getFullIncludePath(pathname, root, includePath);
|
|
64
|
+
}
|
|
59
65
|
|
|
60
66
|
// Store the included content
|
|
61
67
|
md.included[includePath] = data.join('\n');
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {MarkdownIt, MarkdownItPluginOpts, MarkdownItPreprocessorCb} from '../plugins/typings';
|
|
2
|
+
import type {PluginOptions} from '../yfmlint';
|
|
3
|
+
|
|
4
|
+
import included from './included';
|
|
5
|
+
|
|
6
|
+
const defaultPreprocessors = [included] as MarkdownItPreprocessorCb[];
|
|
7
|
+
|
|
8
|
+
export default defaultPreprocessors;
|
|
9
|
+
|
|
10
|
+
export function preprocess(
|
|
11
|
+
content: string,
|
|
12
|
+
pluginOptions: MarkdownItPluginOpts | PluginOptions | unknown,
|
|
13
|
+
options?: Partial<MarkdownItPluginOpts> & {
|
|
14
|
+
preprocessors?: MarkdownItPreprocessorCb[];
|
|
15
|
+
},
|
|
16
|
+
md?: MarkdownIt,
|
|
17
|
+
) {
|
|
18
|
+
const {preprocessors = defaultPreprocessors} = options ?? {};
|
|
19
|
+
|
|
20
|
+
for (const preprocessor of preprocessors) {
|
|
21
|
+
content = preprocessor(content, pluginOptions as MarkdownItPluginOpts, md);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return content;
|
|
25
|
+
}
|
package/src/transform/utilsFS.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {join, parse, relative, resolve, sep} from 'path';
|
|
|
7
7
|
import liquidSnippet from './liquid';
|
|
8
8
|
import {StateCore} from './typings';
|
|
9
9
|
import {defaultTransformLink} from './utils';
|
|
10
|
+
import {preprocess} from './preprocessors';
|
|
10
11
|
|
|
11
12
|
const filesCache: Record<string, string> = {};
|
|
12
13
|
|
|
@@ -39,7 +40,12 @@ export type GetFileTokensOpts = {
|
|
|
39
40
|
content?: string;
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
export function getFileTokens(
|
|
43
|
+
export function getFileTokens(
|
|
44
|
+
path: string,
|
|
45
|
+
state: StateCore,
|
|
46
|
+
options: GetFileTokensOpts,
|
|
47
|
+
content?: string,
|
|
48
|
+
) {
|
|
43
49
|
const {
|
|
44
50
|
getVarsPerFile,
|
|
45
51
|
vars,
|
|
@@ -51,7 +57,6 @@ export function getFileTokens(path: string, state: StateCore, options: GetFileTo
|
|
|
51
57
|
inheritVars = true,
|
|
52
58
|
conditionsInCode,
|
|
53
59
|
} = options;
|
|
54
|
-
let {content} = options;
|
|
55
60
|
|
|
56
61
|
const builtVars = (getVarsPerFile && !inheritVars ? getVarsPerFile(path) : vars) || {};
|
|
57
62
|
|
|
@@ -77,6 +82,9 @@ export function getFileTokens(path: string, state: StateCore, options: GetFileTo
|
|
|
77
82
|
sourceMap = liquidResult.sourceMap;
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
// Run preprocessor
|
|
86
|
+
content = preprocess(content, options);
|
|
87
|
+
|
|
80
88
|
if (!disableLint && lintMarkdown) {
|
|
81
89
|
lintMarkdown({
|
|
82
90
|
input: content,
|
|
@@ -6,7 +6,7 @@ import union from 'lodash/union';
|
|
|
6
6
|
import attrs from 'markdown-it-attrs';
|
|
7
7
|
|
|
8
8
|
import {LogLevels, Logger} from '../log';
|
|
9
|
-
import
|
|
9
|
+
import {preprocess} from '../preprocessors';
|
|
10
10
|
|
|
11
11
|
import baseDefaultLintConfig from './yfmlint';
|
|
12
12
|
import {
|
|
@@ -29,13 +29,7 @@ const lintCache = new Set();
|
|
|
29
29
|
|
|
30
30
|
function yfmlint(opts: Options) {
|
|
31
31
|
let {input} = opts;
|
|
32
|
-
const {
|
|
33
|
-
plugins: customPlugins,
|
|
34
|
-
preprocessors = defaultPreprocessors,
|
|
35
|
-
pluginOptions,
|
|
36
|
-
customLintRules,
|
|
37
|
-
sourceMap,
|
|
38
|
-
} = opts;
|
|
32
|
+
const {plugins: customPlugins, pluginOptions, customLintRules, sourceMap} = opts;
|
|
39
33
|
const {path = 'input', log} = pluginOptions;
|
|
40
34
|
|
|
41
35
|
pluginOptions.isLintRun = true;
|
|
@@ -65,9 +59,8 @@ function yfmlint(opts: Options) {
|
|
|
65
59
|
const plugins = customPlugins && [attrs, ...customPlugins];
|
|
66
60
|
const preparedPlugins = plugins && plugins.map((plugin) => [plugin, pluginOptions]);
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
62
|
+
// Run preprocessor
|
|
63
|
+
input = preprocess(input, pluginOptions, opts);
|
|
71
64
|
|
|
72
65
|
let result;
|
|
73
66
|
try {
|
package/lib/preprocessors.d.ts
DELETED
package/lib/preprocessors.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
const included_1 = __importDefault(require("./preprocessors/included"));
|
|
6
|
-
const defaultPreprocessors = [included_1.default];
|
|
7
|
-
module.exports = defaultPreprocessors;
|
|
8
|
-
//# sourceMappingURL=preprocessors.js.map
|
package/lib/preprocessors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preprocessors.js","sourceRoot":"","sources":["../src/transform/preprocessors.ts"],"names":[],"mappings":";;;;AAEA,wEAAgD;AAEhD,MAAM,oBAAoB,GAAG,CAAC,kBAAQ,CAA+B,CAAC;AAEtE,iBAAS,oBAAoB,CAAC"}
|
package/src/scss/_cut.scss
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.yfm-cut {
|
|
2
|
-
$class: &;
|
|
3
|
-
margin-bottom: 15px;
|
|
4
|
-
|
|
5
|
-
&-title {
|
|
6
|
-
list-style: none;
|
|
7
|
-
cursor: pointer;
|
|
8
|
-
position: relative;
|
|
9
|
-
user-select: none;
|
|
10
|
-
padding: 5px 0 5px 30px;
|
|
11
|
-
|
|
12
|
-
&::-webkit-details-marker {
|
|
13
|
-
display: none;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&:focus {
|
|
17
|
-
outline-color: var(--yfm-color-accent);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&:before {
|
|
21
|
-
content: '';
|
|
22
|
-
z-index: 1;
|
|
23
|
-
left: 0;
|
|
24
|
-
top: 50%;
|
|
25
|
-
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiI+CiAgICA8cGF0aCBzdHJva2U9ImN1cnJlbnRDb2xvciIgZmlsbD0ibm9uZSIgZD0iTTMgNmw1IDUgNS01Ii8+Cjwvc3ZnPgo=');
|
|
26
|
-
transform: translateY(-50%) rotate(-90deg);
|
|
27
|
-
transition: transform 0.3s ease;
|
|
28
|
-
height: 20px;
|
|
29
|
-
width: 20px;
|
|
30
|
-
position: absolute;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&-content {
|
|
35
|
-
padding: 5px 0 15px 30px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&.open {
|
|
39
|
-
> #{$class}-title:before {
|
|
40
|
-
transform: translateY(-50%);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.yfm:not(.yfm_no-list-reset) & ol {
|
|
45
|
-
counter-reset: cut-list;
|
|
46
|
-
|
|
47
|
-
& > li {
|
|
48
|
-
counter-increment: cut-list;
|
|
49
|
-
|
|
50
|
-
&::before {
|
|
51
|
-
content: counters(cut-list, '.') '. ';
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|