@diplodoc/transform 4.65.3 → 4.67.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 +56 -3
- package/dist/css/_yfm-only.css +3 -1
- 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 +2 -0
- package/dist/css/base.css.map +3 -3
- package/dist/css/base.min.css.map +3 -3
- package/dist/css/print.css.map +3 -3
- package/dist/css/yfm.css +5 -1
- 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/dist/js/base.js +2 -22
- package/dist/js/base.js.map +1 -1
- package/dist/js/base.min.js +3 -3
- package/dist/js/base.min.js.map +2 -2
- package/dist/js/yfm.js +27 -57
- package/dist/js/yfm.js.map +3 -3
- package/dist/js/yfm.min.js +3 -3
- package/dist/js/yfm.min.js.map +3 -3
- package/dist/scss/_common.scss +6 -4
- package/dist/scss/_note.scss +10 -8
- package/dist/scss/print/code.scss +1 -1
- package/dist/scss/print/common.scss +3 -2
- package/dist/scss/print/table.scss +3 -2
- package/dist/scss/print/term.scss +1 -1
- package/lib/frontmatter.d.ts +1 -1
- package/lib/frontmatter.js.map +1 -1
- package/lib/getObject.js.map +1 -1
- package/lib/headings.js.map +1 -1
- package/lib/highlight.js +1 -1
- package/lib/highlight.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +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 +21 -11
- package/lib/liquid/evaluation.js.map +1 -1
- package/lib/liquid/filters.js +3 -4
- package/lib/liquid/filters.js.map +1 -1
- package/lib/liquid/index.js +3 -4
- package/lib/liquid/index.js.map +1 -1
- package/lib/liquid/legacyConditions.js.map +1 -1
- package/lib/liquid/lexical.js +5 -5
- package/lib/liquid/lexical.js.map +1 -1
- package/lib/liquid/services/argv.d.ts +1 -1
- package/lib/liquid/services/argv.js +3 -4
- package/lib/liquid/services/argv.js.map +1 -1
- package/lib/liquid/sourceMap.d.ts +2 -2
- package/lib/liquid/sourceMap.js +3 -4
- package/lib/liquid/sourceMap.js.map +1 -1
- package/lib/liquid/substitutions.js.map +1 -1
- package/lib/liquid/utils.d.ts +1 -1
- package/lib/liquid/utils.js +2 -3
- package/lib/liquid/utils.js.map +1 -1
- package/lib/log.d.ts +1 -1
- package/lib/log.js +1 -1
- package/lib/log.js.map +1 -1
- package/lib/md.d.ts +5 -5
- package/lib/md.js +31 -22
- package/lib/md.js.map +1 -1
- package/lib/plugins/anchors/collect.js.map +1 -1
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/plugins/block-anchor/block-anchor.js +3 -3
- package/lib/plugins/block-anchor/block-anchor.js.map +1 -1
- package/lib/plugins/block-anchor/index.js +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.map +1 -1
- package/lib/plugins/changelog/index.js +6 -3
- package/lib/plugins/changelog/index.js.map +1 -1
- package/lib/plugins/checkbox/checkbox.d.ts +1 -1
- package/lib/plugins/checkbox/checkbox.js +83 -23
- package/lib/plugins/checkbox/checkbox.js.map +1 -1
- package/lib/plugins/code.js.map +1 -1
- package/lib/plugins/cut.d.ts +1 -1
- package/lib/plugins/deflist.d.ts +1 -1
- package/lib/plugins/images/collect.d.ts +1 -1
- package/lib/plugins/images/collect.js.map +1 -1
- package/lib/plugins/images/index.d.ts +1 -1
- package/lib/plugins/images/index.js +16 -7
- package/lib/plugins/images/index.js.map +1 -1
- package/lib/plugins/imsize/const.js +1 -1
- package/lib/plugins/imsize/const.js.map +1 -1
- package/lib/plugins/imsize/helpers.js +1 -2
- package/lib/plugins/imsize/helpers.js.map +1 -1
- package/lib/plugins/imsize/plugin.d.ts +1 -1
- package/lib/plugins/imsize/plugin.js.map +1 -1
- package/lib/plugins/includes/collect.js +11 -3
- package/lib/plugins/includes/collect.js.map +1 -1
- package/lib/plugins/includes/index.d.ts +1 -1
- package/lib/plugins/includes/index.js +5 -3
- package/lib/plugins/includes/index.js.map +1 -1
- package/lib/plugins/includes/types.d.ts +1 -1
- package/lib/plugins/links/collect.d.ts +1 -1
- package/lib/plugins/links/collect.js +1 -1
- package/lib/plugins/links/collect.js.map +1 -1
- package/lib/plugins/links/index.d.ts +1 -1
- package/lib/plugins/links/index.js +35 -12
- package/lib/plugins/links/index.js.map +1 -1
- package/lib/plugins/meta.js.map +1 -1
- package/lib/plugins/monospace.js +1 -1
- package/lib/plugins/monospace.js.map +1 -1
- package/lib/plugins/notes/index.d.ts +1 -1
- package/lib/plugins/notes/index.js +1 -1
- package/lib/plugins/notes/index.js.map +1 -1
- package/lib/plugins/ol-attr-conversion.js.map +1 -1
- package/lib/plugins/sup.d.ts +1 -1
- package/lib/plugins/table/index.js +7 -18
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/types.d.ts +1 -1
- package/lib/plugins/tabs.d.ts +3 -3
- package/lib/plugins/term/index.js.map +1 -1
- package/lib/plugins/term/termDefinitions.js +1 -2
- package/lib/plugins/term/termDefinitions.js.map +1 -1
- package/lib/plugins/utils.d.ts +1 -1
- package/lib/plugins/utils.js +3 -3
- package/lib/plugins/utils.js.map +1 -1
- package/lib/plugins/video/const.js +1 -1
- package/lib/plugins/video/const.js.map +1 -1
- package/lib/plugins/video/index.js +1 -1
- package/lib/plugins/video/index.js.map +1 -1
- package/lib/plugins/video/parsers.js +9 -10
- package/lib/plugins/video/parsers.js.map +1 -1
- package/lib/plugins/video/types.d.ts +8 -8
- package/lib/plugins/video/utils.js.map +1 -1
- package/lib/plugins.d.ts +1 -1
- package/lib/preprocessors/included/index.js.map +1 -1
- package/lib/preprocessors/index.d.ts +1 -1
- package/lib/preprocessors/index.js +1 -2
- package/lib/preprocessors/index.js.map +1 -1
- package/lib/sanitize.d.ts +1 -1
- package/lib/sanitize.js +54 -26
- package/lib/sanitize.js.map +1 -1
- package/lib/title.js.map +1 -1
- package/lib/typings.d.ts +10 -10
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +16 -13
- package/lib/utils.js.map +1 -1
- package/lib/utilsFS.d.ts +2 -1
- package/lib/utilsFS.js +45 -15
- package/lib/utilsFS.js.map +1 -1
- package/lib/yfmlint/index.js +4 -1
- package/lib/yfmlint/index.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.js.map +1 -1
- package/lib/yfmlint/utils.js +6 -6
- package/lib/yfmlint/utils.js.map +1 -1
- package/lib/yfmlint/yfmlint.js +60 -60
- package/lib/yfmlint/yfmlint.js.map +1 -1
- package/package.json +12 -11
- package/src/scss/_common.scss +6 -4
- package/src/scss/_note.scss +10 -8
- package/src/scss/print/code.scss +1 -1
- package/src/scss/print/common.scss +3 -2
- package/src/scss/print/table.scss +3 -2
- package/src/scss/print/term.scss +1 -1
- package/src/transform/highlight.ts +1 -1
- package/src/transform/liquid/evaluation.ts +2 -2
- package/src/transform/plugins/block-anchor/index.ts +1 -1
- package/src/transform/plugins/changelog/index.ts +1 -1
- package/src/transform/plugins/checkbox/checkbox.ts +104 -26
- package/src/transform/plugins/images/index.ts +8 -6
- package/src/transform/plugins/includes/collect.ts +1 -1
- package/src/transform/plugins/includes/index.ts +5 -3
- package/src/transform/plugins/links/index.ts +7 -3
- package/src/transform/plugins/notes/index.ts +1 -1
- package/src/transform/plugins/video/types.ts +1 -1
- package/src/transform/sanitize.ts +1 -1
- package/src/transform/utils.ts +2 -2
- package/src/transform/utilsFS.ts +33 -6
- package/src/transform/yfmlint/index.ts +5 -1
- package/src/transform/yfmlint/utils.ts +4 -4
|
@@ -32,8 +32,8 @@ function replaceImageSrc(
|
|
|
32
32
|
|
|
33
33
|
const relativeToRoot = path.replace(root + sep, '');
|
|
34
34
|
const publicSrc = join(assetsPublicPath, relativeToRoot);
|
|
35
|
-
|
|
36
|
-
return publicSrc;
|
|
35
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
36
|
+
return publicSrc.replace(/\\/g, '/');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
interface InlineOptions {
|
|
@@ -50,12 +50,14 @@ interface SVGOpts extends MarkdownItPluginOpts {
|
|
|
50
50
|
function getSvgContent(file: string, from: string, {rawContent, notFoundCb, log, root = ''}: Opts) {
|
|
51
51
|
try {
|
|
52
52
|
return rawContent(file);
|
|
53
|
-
} catch
|
|
53
|
+
} catch {
|
|
54
54
|
const path = file.replace(root, '');
|
|
55
|
-
|
|
55
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
56
|
+
const normalizedPath = path.replace(/\\/g, '/');
|
|
57
|
+
log.error(`SVG ${normalizedPath} from ${from} not found`);
|
|
56
58
|
|
|
57
59
|
if (notFoundCb) {
|
|
58
|
-
notFoundCb(
|
|
60
|
+
notFoundCb(normalizedPath);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
return null;
|
|
@@ -168,7 +170,7 @@ const index: MarkdownItPluginCb<Opts> = (md, opts) => {
|
|
|
168
170
|
|
|
169
171
|
try {
|
|
170
172
|
md.core.ruler.before('includes', 'images', plugin);
|
|
171
|
-
} catch
|
|
173
|
+
} catch {
|
|
172
174
|
md.core.ruler.push('images', plugin);
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -91,11 +91,13 @@ function unfoldIncludes(md: MarkdownItIncluded, state: StateCore, path: string,
|
|
|
91
91
|
} catch (e) {
|
|
92
92
|
// @ts-ignore for some reason typescript fails here
|
|
93
93
|
const errPath = e.path?.replace(root, '');
|
|
94
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
95
|
+
const normalizedPath = errPath ? errPath.replace(/\\/g, '/') : errPath;
|
|
94
96
|
|
|
95
97
|
if (notFoundCb) {
|
|
96
|
-
notFoundCb(
|
|
98
|
+
notFoundCb(normalizedPath);
|
|
97
99
|
}
|
|
98
|
-
log.error(`Skip error: ${e} in ${
|
|
100
|
+
log.error(`Skip error: ${e} in ${normalizedPath}`);
|
|
99
101
|
|
|
100
102
|
i++;
|
|
101
103
|
}
|
|
@@ -132,7 +134,7 @@ const index: MarkdownItPluginCb<Options> = (md: MarkdownItIncluded, options) =>
|
|
|
132
134
|
|
|
133
135
|
try {
|
|
134
136
|
md.core.ruler.before('curly_attributes', 'includes', plugin);
|
|
135
|
-
} catch
|
|
137
|
+
} catch {
|
|
136
138
|
md.core.ruler.push('includes', plugin);
|
|
137
139
|
}
|
|
138
140
|
};
|
|
@@ -117,7 +117,9 @@ function getDefaultPublicPath(
|
|
|
117
117
|
},
|
|
118
118
|
input?: string | null,
|
|
119
119
|
) {
|
|
120
|
-
|
|
120
|
+
const relativePath = relative(parse(path || '').dir, input || file || '');
|
|
121
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
122
|
+
return relativePath.replace(/\\/g, '/');
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
// eslint-disable-next-line complexity
|
|
@@ -174,7 +176,9 @@ function processLink(
|
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
if (notFoundCb && needShowError) {
|
|
177
|
-
|
|
179
|
+
const relativePath = file.replace(root, '');
|
|
180
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
181
|
+
notFoundCb(relativePath.replace(/\\/g, '/'));
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
if (needShowError) {
|
|
@@ -262,7 +266,7 @@ const index: MarkdownItPluginCb<ProcOpts & Options> = (md: MarkdownItIncluded, o
|
|
|
262
266
|
|
|
263
267
|
try {
|
|
264
268
|
md.core.ruler.before('includes', 'links', plugin);
|
|
265
|
-
} catch
|
|
269
|
+
} catch {
|
|
266
270
|
md.core.ruler.push('links', plugin);
|
|
267
271
|
}
|
|
268
272
|
};
|
|
@@ -660,7 +660,7 @@ function normalizeCssValue(value: string): string {
|
|
|
660
660
|
// unicode normalization (NFKC) to prevent homograph attacks
|
|
661
661
|
try {
|
|
662
662
|
normalized = normalized.normalize('NFKC');
|
|
663
|
-
} catch
|
|
663
|
+
} catch {
|
|
664
664
|
// silent fail: logging the value could expose sensitive data
|
|
665
665
|
}
|
|
666
666
|
|
package/src/transform/utils.ts
CHANGED
|
@@ -87,7 +87,7 @@ export function getHrefTokenAttr(token: Token) {
|
|
|
87
87
|
let href = token.attrGet('href') || '';
|
|
88
88
|
try {
|
|
89
89
|
href = decodeURI(href);
|
|
90
|
-
} catch
|
|
90
|
+
} catch {}
|
|
91
91
|
|
|
92
92
|
return href;
|
|
93
93
|
}
|
|
@@ -97,7 +97,7 @@ export function getSrcTokenAttr(token: Token) {
|
|
|
97
97
|
try {
|
|
98
98
|
// decodeURI can throw an error https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError
|
|
99
99
|
src = decodeURI(src);
|
|
100
|
-
} catch
|
|
100
|
+
} catch {}
|
|
101
101
|
|
|
102
102
|
return src;
|
|
103
103
|
}
|
package/src/transform/utilsFS.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {StateCore} from './typings';
|
|
|
3
3
|
|
|
4
4
|
import {readFileSync, realpathSync, statSync} from 'fs';
|
|
5
5
|
import escapeRegExp from 'lodash/escapeRegExp';
|
|
6
|
-
import {join, parse, relative, resolve, sep} from 'path';
|
|
6
|
+
import {basename, join, parse, relative, resolve, sep} from 'path';
|
|
7
7
|
import QuickLRU from 'quick-lru';
|
|
8
8
|
|
|
9
9
|
import liquidSnippet from './liquid';
|
|
@@ -17,7 +17,7 @@ export function isFileExists(file: string) {
|
|
|
17
17
|
const stats = statSync(file);
|
|
18
18
|
|
|
19
19
|
return stats.isFile();
|
|
20
|
-
} catch
|
|
20
|
+
} catch {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -39,6 +39,7 @@ export type GetFileTokensOpts = {
|
|
|
39
39
|
inheritVars?: boolean;
|
|
40
40
|
conditionsInCode?: boolean;
|
|
41
41
|
content?: string;
|
|
42
|
+
root?: string;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
export function getFileTokens(
|
|
@@ -87,9 +88,31 @@ export function getFileTokens(
|
|
|
87
88
|
content = preprocess(content, options);
|
|
88
89
|
|
|
89
90
|
if (!disableLint && lintMarkdown) {
|
|
91
|
+
// Make path relative to root if root is provided, otherwise use absolute path
|
|
92
|
+
let lintPath = path;
|
|
93
|
+
if (options.root) {
|
|
94
|
+
try {
|
|
95
|
+
// Use path.relative for proper cross-platform path handling
|
|
96
|
+
const relativePath = relative(options.root, path);
|
|
97
|
+
// If relative path doesn't start with '..', it's within root
|
|
98
|
+
if (!relativePath.startsWith('..')) {
|
|
99
|
+
lintPath = relativePath;
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
// If relative fails, fall back to string replacement
|
|
103
|
+
if (path.startsWith(options.root)) {
|
|
104
|
+
lintPath = path.replace(options.root, '').replace(/^[/\\]/, '');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
109
|
+
const normalizedPath = lintPath.replace(/\\/g, '/');
|
|
110
|
+
// Use only basename for lint error messages to match test expectations
|
|
111
|
+
// This ensures consistent error message format across platforms
|
|
112
|
+
const lintPathForMessage = basename(normalizedPath);
|
|
90
113
|
lintMarkdown({
|
|
91
114
|
input: content,
|
|
92
|
-
path,
|
|
115
|
+
path: lintPathForMessage,
|
|
93
116
|
sourceMap,
|
|
94
117
|
});
|
|
95
118
|
}
|
|
@@ -158,8 +181,10 @@ export function getPublicPath(
|
|
|
158
181
|
) {
|
|
159
182
|
const currentPath = input || path || '';
|
|
160
183
|
const filePath = relative(resolve(root || '', rootPublicPath || ''), currentPath);
|
|
184
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
185
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
161
186
|
const transformer = transformLink || defaultTransformLink;
|
|
162
|
-
const href = transformer(
|
|
187
|
+
const href = transformer(normalizedPath);
|
|
163
188
|
return href;
|
|
164
189
|
}
|
|
165
190
|
|
|
@@ -167,13 +192,15 @@ export function getRelativePath(path: string, toPath: string) {
|
|
|
167
192
|
const pathDirs = path.split(sep);
|
|
168
193
|
pathDirs.pop();
|
|
169
194
|
const parentPath = pathDirs.join(sep);
|
|
170
|
-
|
|
195
|
+
const relativePath = relative(parentPath, toPath);
|
|
196
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
197
|
+
return relativePath.replace(/\\/g, '/');
|
|
171
198
|
}
|
|
172
199
|
|
|
173
200
|
export function getRealPath(symlinkPath: string): string {
|
|
174
201
|
try {
|
|
175
202
|
return realpathSync(symlinkPath);
|
|
176
|
-
} catch
|
|
203
|
+
} catch {
|
|
177
204
|
return symlinkPath;
|
|
178
205
|
}
|
|
179
206
|
}
|
|
@@ -31,7 +31,11 @@ const lintCache = new Set();
|
|
|
31
31
|
function yfmlint(opts: Options) {
|
|
32
32
|
let {input} = opts;
|
|
33
33
|
const {plugins: customPlugins, pluginOptions, customLintRules, sourceMap} = opts;
|
|
34
|
-
const {
|
|
34
|
+
const {log} = pluginOptions;
|
|
35
|
+
let {path = 'input'} = pluginOptions;
|
|
36
|
+
|
|
37
|
+
// Normalize path separators to forward slashes for cross-platform compatibility
|
|
38
|
+
path = path.replace(/\\/g, '/');
|
|
35
39
|
|
|
36
40
|
pluginOptions.isLintRun = true;
|
|
37
41
|
|
|
@@ -2,13 +2,13 @@ import type {Dictionary} from 'lodash';
|
|
|
2
2
|
import type {LintError} from 'markdownlint';
|
|
3
3
|
import type {LogLevels} from '../log';
|
|
4
4
|
|
|
5
|
-
import {sep} from 'path';
|
|
6
|
-
|
|
7
5
|
export function errorToString(path: string, error: LintError, sourceMap?: Dictionary<string>) {
|
|
6
|
+
// Use forward slash for rule moniker separator for cross-platform compatibility
|
|
7
|
+
// Rule names like 'YFM001/inline-code-length' should use '/' not platform-specific separator
|
|
8
8
|
const ruleMoniker = error.ruleNames
|
|
9
|
-
? error.ruleNames.join(
|
|
9
|
+
? error.ruleNames.join('/')
|
|
10
10
|
: // @ts-expect-error bad markdownlint typings
|
|
11
|
-
error.ruleName +
|
|
11
|
+
error.ruleName + '/' + error.ruleAlias;
|
|
12
12
|
const lineNumber = sourceMap ? sourceMap[error.lineNumber] : error.lineNumber;
|
|
13
13
|
|
|
14
14
|
return (
|