@diplodoc/transform 4.35.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 +7 -7
- package/dist/css/_yfm-only.css.map +3 -3
- package/dist/css/_yfm-only.min.css +1 -1
- package/dist/css/_yfm-only.min.css.map +3 -3
- 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 +7 -7
- package/dist/css/yfm.css.map +3 -3
- package/dist/css/yfm.min.css +1 -1
- package/dist/css/yfm.min.css.map +3 -3
- package/lib/md.d.ts +1 -0
- package/lib/md.js +7 -7
- package/lib/md.js.map +1 -1
- package/lib/plugins/anchors/index.d.ts +1 -0
- package/lib/plugins/anchors/index.js +5 -3
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/plugins/imsize/const.d.ts +2 -1
- package/lib/plugins/imsize/const.js +1 -0
- package/lib/plugins/imsize/const.js.map +1 -1
- package/lib/plugins/imsize/index.d.ts +3 -2
- package/lib/plugins/imsize/index.js +2 -2
- package/lib/plugins/imsize/index.js.map +1 -1
- package/lib/plugins/imsize/plugin.d.ts +4 -1
- package/lib/plugins/imsize/plugin.js +26 -1
- package/lib/plugins/imsize/plugin.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/plugins/notes/index.js +5 -10
- package/lib/plugins/notes/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/sanitize.d.ts +2 -4
- package/lib/sanitize.js +4 -1
- package/lib/sanitize.js.map +1 -1
- package/lib/typings.d.ts +4 -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/scss/_note.scss +2 -3
- package/src/transform/md.ts +6 -7
- package/src/transform/plugins/anchors/index.ts +13 -4
- package/src/transform/plugins/file/README.md +0 -54
- package/src/transform/plugins/imsize/const.ts +1 -0
- package/src/transform/plugins/imsize/index.ts +4 -4
- package/src/transform/plugins/imsize/plugin.ts +32 -1
- 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/plugins/notes/index.ts +8 -6
- package/src/transform/preprocessors/included/index.ts +9 -3
- package/src/transform/preprocessors/index.ts +25 -0
- package/src/transform/sanitize.ts +14 -3
- package/src/transform/typings.ts +3 -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
package/lib/sanitize.js
CHANGED
|
@@ -569,9 +569,12 @@ function sanitizeStyles(html, options) {
|
|
|
569
569
|
const content = $('body').html() || '';
|
|
570
570
|
return styles + content;
|
|
571
571
|
}
|
|
572
|
-
function sanitize(html, options) {
|
|
572
|
+
function sanitize(html, options, additionalOptions) {
|
|
573
573
|
var _a;
|
|
574
574
|
const sanitizeOptions = options || exports.defaultOptions;
|
|
575
|
+
if (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.cssWhiteList) {
|
|
576
|
+
sanitizeOptions.cssWhiteList = Object.assign(Object.assign({}, sanitizeOptions.cssWhiteList), additionalOptions.cssWhiteList);
|
|
577
|
+
}
|
|
575
578
|
const needToSanitizeStyles = !((_a = sanitizeOptions.disableStyleSanitizer) !== null && _a !== void 0 ? _a : false);
|
|
576
579
|
const modifiedHtml = needToSanitizeStyles ? sanitizeStyles(html, sanitizeOptions) : html;
|
|
577
580
|
return (0, sanitize_html_1.default)(modifiedHtml, sanitizeOptions);
|
package/lib/sanitize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/transform/sanitize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAyC;AACzC,aAAa;AACb,0DAAkC;AAClC,iDAAmC;AACnC,8CAAsB;
|
|
1
|
+
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../src/transform/sanitize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAyC;AACzC,aAAa;AACb,0DAAkC;AAClC,iDAAmC;AACnC,8CAAsB;AAItB,MAAM,QAAQ,GAAG;IACb,GAAG;IACH,MAAM;IACN,SAAS;IACT,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,OAAO;IACP,GAAG;IACH,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,YAAY;IACZ,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,MAAM;IACN,KAAK;IACL,UAAU;IACV,SAAS;IACT,MAAM;IACN,UAAU;IACV,IAAI;IACJ,WAAW;IACX,KAAK;IACL,SAAS;IACT,KAAK;IACL,QAAQ;IACR,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,SAAS;IACT,IAAI;IACJ,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,I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AAC,IAAI,CAAC;IAEzF,OAAO,IAAA,uBAAY,EAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AAnBD,2BAmBC"}
|
package/lib/typings.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare type EnvType<Extras extends {} = {}> = {
|
|
|
64
64
|
assets?: unknown[];
|
|
65
65
|
meta?: object;
|
|
66
66
|
changelogs?: ChangelogItem[];
|
|
67
|
+
additionalOptionsCssWhiteList?: CssWhiteList;
|
|
67
68
|
} & Extras;
|
|
68
69
|
export interface MarkdownItPluginOpts {
|
|
69
70
|
path: string;
|
|
@@ -84,3 +85,6 @@ export declare type MarkdownItPluginCb<T extends {} = {}> = {
|
|
|
84
85
|
export declare type MarkdownItPreprocessorCb<T extends unknown = {}> = {
|
|
85
86
|
(input: string, opts: T & Partial<MarkdownItPluginOpts>, md?: MarkdownIt): string;
|
|
86
87
|
};
|
|
88
|
+
export declare type CssWhiteList = {
|
|
89
|
+
[property: string]: boolean;
|
|
90
|
+
};
|
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,Y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 +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,0EAAs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C,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/scss/_note.scss
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
font-weight: 700;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
& >
|
|
11
|
+
& > * {
|
|
12
12
|
margin: 0 0 10px;
|
|
13
13
|
|
|
14
14
|
&:first-child {
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
// @todo replace with variables
|
|
34
33
|
|
|
35
34
|
$colors: (
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
);
|
|
41
40
|
|
|
42
41
|
@each $type, $color in $colors {
|
|
43
|
-
&.#{$type} >
|
|
42
|
+
&.#{$type} > :first-child::before {
|
|
44
43
|
$r: red($color);
|
|
45
44
|
$g: green($color);
|
|
46
45
|
$b: blue($color);
|
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) : '';
|
|
@@ -168,7 +165,9 @@ function initCompiler(md: MarkdownIt, options: OptionsType, env: EnvType) {
|
|
|
168
165
|
const html = md.renderer.render(tokens, md.options, env);
|
|
169
166
|
|
|
170
167
|
// Sanitize the page
|
|
171
|
-
return needToSanitizeHtml
|
|
168
|
+
return needToSanitizeHtml
|
|
169
|
+
? sanitizeHtml(html, sanitizeOptions, {cssWhiteList: env.additionalOptionsCssWhiteList})
|
|
170
|
+
: html;
|
|
172
171
|
};
|
|
173
172
|
}
|
|
174
173
|
|
|
@@ -76,12 +76,14 @@ const removeCustomIds = (token: Token) => {
|
|
|
76
76
|
interface Options {
|
|
77
77
|
extractTitle?: boolean;
|
|
78
78
|
supportGithubAnchors?: boolean;
|
|
79
|
+
disableCommonAnchors?: boolean;
|
|
79
80
|
transformLink: (v: string) => string;
|
|
80
81
|
getPublicPath?: (options: Options, v?: string) => string;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
const index: MarkdownItPluginCb<Options> = (md, options) => {
|
|
84
|
-
const {extractTitle, path, log, supportGithubAnchors, getPublicPath} =
|
|
85
|
+
const {extractTitle, path, log, supportGithubAnchors, getPublicPath, disableCommonAnchors} =
|
|
86
|
+
options;
|
|
85
87
|
|
|
86
88
|
const plugin = (state: StateCore) => {
|
|
87
89
|
/* Do not use the plugin if it is included in the file */
|
|
@@ -143,9 +145,16 @@ const index: MarkdownItPluginCb<Options> = (md, options) => {
|
|
|
143
145
|
const anchorTitle = removeCustomId(title).replace(/`/g, '');
|
|
144
146
|
allAnchorIds.forEach((customId) => {
|
|
145
147
|
const setId = id !== customId;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
if (!disableCommonAnchors) {
|
|
149
|
+
const linkTokens = createLinkTokens(
|
|
150
|
+
state,
|
|
151
|
+
customId,
|
|
152
|
+
anchorTitle,
|
|
153
|
+
setId,
|
|
154
|
+
href,
|
|
155
|
+
);
|
|
156
|
+
inlineToken.children?.unshift(...linkTokens);
|
|
157
|
+
}
|
|
149
158
|
|
|
150
159
|
if (supportGithubAnchors) {
|
|
151
160
|
const ghLinkTokens = createLinkTokens(state, ghId, anchorTitle, true, href);
|
|
@@ -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`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {PluginWithOptions} from 'markdown-it';
|
|
2
2
|
|
|
3
|
-
import {imageWithSize} from './plugin';
|
|
3
|
+
import {ImsizeOptions, imageWithSize} from './plugin';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Imsize plugin for markdown-it.
|
|
@@ -8,8 +8,8 @@ import {imageWithSize} from './plugin';
|
|
|
8
8
|
* Forked from https://github.com/tatsy/markdown-it-imsize
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const imsize:
|
|
12
|
-
md.inline.ruler.before('emphasis', 'image', imageWithSize(md));
|
|
11
|
+
const imsize: PluginWithOptions<ImsizeOptions> = (md, opts) => {
|
|
12
|
+
md.inline.ruler.before('emphasis', 'image', imageWithSize(md, opts));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export = imsize;
|
|
@@ -5,7 +5,11 @@ import type Token from 'markdown-it/lib/token';
|
|
|
5
5
|
import {ImsizeAttr} from './const';
|
|
6
6
|
import {parseImageSize} from './helpers';
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export type ImsizeOptions = {
|
|
9
|
+
enableInlineStyling?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const imageWithSize = (md: MarkdownIt, opts?: ImsizeOptions): ParserInline.RuleInline => {
|
|
9
13
|
// eslint-disable-next-line complexity
|
|
10
14
|
return (state, silent) => {
|
|
11
15
|
if (state.src.charCodeAt(state.pos) !== 0x21 /* ! */) {
|
|
@@ -206,6 +210,33 @@ export const imageWithSize = (md: MarkdownIt): ParserInline.RuleInline => {
|
|
|
206
210
|
if (height !== '') {
|
|
207
211
|
token.attrs.push([ImsizeAttr.Height, height]);
|
|
208
212
|
}
|
|
213
|
+
|
|
214
|
+
if (opts?.enableInlineStyling) {
|
|
215
|
+
let style: string | undefined = '';
|
|
216
|
+
|
|
217
|
+
const widthWithPercent = width.includes('%');
|
|
218
|
+
const heightWithPercent = height.includes('%');
|
|
219
|
+
|
|
220
|
+
if (width !== '') {
|
|
221
|
+
const widthString = widthWithPercent ? width : `${width}px`;
|
|
222
|
+
style += `width: ${widthString};`;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (height !== '') {
|
|
226
|
+
if (width !== '' && !heightWithPercent && !widthWithPercent) {
|
|
227
|
+
style += `aspect-ratio: ${width} / ${height};height: auto;`;
|
|
228
|
+
state.env.additionalOptionsCssWhiteList ??= {};
|
|
229
|
+
state.env.additionalOptionsCssWhiteList['aspect-ratio'] = true;
|
|
230
|
+
} else {
|
|
231
|
+
const heightString = heightWithPercent ? height : `${height}px`;
|
|
232
|
+
style += `height: ${heightString};`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (style) {
|
|
237
|
+
token.attrs.push([ImsizeAttr.Style, style]);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
209
240
|
}
|
|
210
241
|
|
|
211
242
|
state.pos = pos;
|
|
@@ -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++;
|
|
@@ -108,16 +108,18 @@ const index: MarkdownItPluginCb = (md, {lang, notesAutotitle, path: optPath, log
|
|
|
108
108
|
titleInline.children,
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
const insideTokens = [
|
|
112
|
-
|
|
113
|
-
titleOpen,
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
const insideTokens = [newOpenToken];
|
|
112
|
+
if (titleInline.content) {
|
|
113
|
+
insideTokens.push(titleOpen, titleInline, titleClose);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
insideTokens.push(
|
|
116
117
|
contentOpen,
|
|
117
118
|
...tokens.slice(i + 3, closeTokenIdx),
|
|
118
119
|
contentClose,
|
|
119
120
|
newCloseToken,
|
|
120
|
-
|
|
121
|
+
);
|
|
122
|
+
|
|
121
123
|
tokens.splice(i, closeTokenIdx - i + 3, ...insideTokens);
|
|
122
124
|
|
|
123
125
|
i++;
|