@diplodoc/transform 4.7.0 → 4.7.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 +4 -2
- 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/yfm.js +39 -39
- package/dist/js/yfm.js.map +1 -1
- package/dist/js/yfm.min.js +1 -1
- package/dist/js/yfm.min.js.map +1 -1
- package/lib/plugins/anchors/collect.js +2 -1
- package/lib/plugins/anchors/collect.js.map +1 -1
- package/lib/plugins/block-anchor/index.d.ts +1 -1
- package/lib/plugins/block-anchor/index.js +1 -2
- package/lib/plugins/block-anchor/index.js.map +1 -1
- package/lib/plugins/cut.js +4 -1
- package/lib/plugins/cut.js.map +1 -1
- package/lib/plugins/notes.js +1 -0
- package/lib/plugins/notes.js.map +1 -1
- package/lib/yfmlint/index.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.js.map +1 -1
- package/package.json +4 -10
- package/src/.eslintrc.js +16 -0
- package/src/js/term/index.ts +2 -2
- package/src/transform/index.ts +1 -1
- package/src/transform/liquid/substitutions.ts +1 -1
- package/src/transform/log.ts +1 -1
- package/src/transform/md.ts +1 -1
- package/src/transform/plugins/anchors/collect.ts +3 -4
- package/src/transform/plugins/anchors/index.ts +1 -1
- package/src/transform/plugins/block-anchor/index.ts +2 -2
- package/src/transform/plugins/cut.ts +5 -1
- package/src/transform/plugins/file/file.ts +2 -2
- package/src/transform/plugins/images/index.ts +2 -2
- package/src/transform/plugins/includes/index.ts +1 -1
- package/src/transform/plugins/links/index.ts +2 -2
- package/src/transform/plugins/notes.ts +1 -0
- package/src/transform/plugins/video/index.ts +1 -1
- package/src/transform/utilsFS.ts +1 -1
- package/src/transform/yfmlint/index.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +15 -14
- package/src/.eslintrc +0 -10
|
@@ -3,7 +3,7 @@ import {sep} from 'path';
|
|
|
3
3
|
|
|
4
4
|
import {getSinglePageAnchorId, resolveRelativePath} from '../../utilsFS';
|
|
5
5
|
import {transformLinkToOriginalArticle} from '../../utils';
|
|
6
|
-
import {
|
|
6
|
+
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
7
7
|
import {сarriage} from '../utils';
|
|
8
8
|
import {MarkdownItPluginOpts} from '../typings';
|
|
9
9
|
|
|
@@ -84,9 +84,8 @@ const collect = (input: string, options: MarkdownItPluginOpts & {singlePage: boo
|
|
|
84
84
|
|
|
85
85
|
if (needToSetOriginalPathAttr) {
|
|
86
86
|
const originalArticleHref = transformLinkToOriginalArticle({root, currentPath});
|
|
87
|
-
lines[
|
|
88
|
-
|
|
89
|
-
] = `${baseHeaderSyntax} {data-original-article=${originalArticleHref}} ${newCustomHeadersStr}`;
|
|
87
|
+
lines[i] =
|
|
88
|
+
`${baseHeaderSyntax} {data-original-article=${originalArticleHref}} ${newCustomHeadersStr}`;
|
|
90
89
|
|
|
91
90
|
needToSetOriginalPathAttr = false;
|
|
92
91
|
}
|
|
@@ -2,7 +2,7 @@ import {bold} from 'chalk';
|
|
|
2
2
|
import GithubSlugger from 'github-slugger';
|
|
3
3
|
|
|
4
4
|
import {headingInfo} from '../../utils';
|
|
5
|
-
import {
|
|
5
|
+
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
6
6
|
import StateCore from 'markdown-it/lib/rules_core/state_core';
|
|
7
7
|
import Token from 'markdown-it/lib/token';
|
|
8
8
|
import {escapeHtml} from 'markdown-it/lib/common/utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MarkdownIt from 'markdown-it';
|
|
2
|
-
import {renderTokens, replaceTokens
|
|
2
|
+
import {TOKEN_NAME, renderTokens, replaceTokens} from './block-anchor';
|
|
3
3
|
|
|
4
4
|
const blockAnchor = (md: MarkdownIt) => {
|
|
5
5
|
md.core.ruler.before('curly_attributes', TOKEN_NAME, replaceTokens);
|
|
@@ -8,4 +8,4 @@ const blockAnchor = (md: MarkdownIt) => {
|
|
|
8
8
|
return md;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export = blockAnchor;
|
|
@@ -68,15 +68,19 @@ const cut: MarkdownItPluginCb = (md, {path, log}) => {
|
|
|
68
68
|
const newCloseToken = new state.Token('yfm_cut_close', 'div', -1);
|
|
69
69
|
newCloseToken.map = tokens[closeTokenIdx].map;
|
|
70
70
|
|
|
71
|
+
const insertTokens = tokens.slice(i + 3, closeTokenIdx);
|
|
72
|
+
const rest = insertTokens.length % 3;
|
|
73
|
+
|
|
71
74
|
const insideTokens = [
|
|
72
75
|
newOpenToken,
|
|
73
76
|
titleOpen,
|
|
74
77
|
titleInline,
|
|
75
78
|
titleClose,
|
|
76
79
|
contentOpen,
|
|
77
|
-
...
|
|
80
|
+
...insertTokens.slice(0, insertTokens.length - rest),
|
|
78
81
|
contentClose,
|
|
79
82
|
newCloseToken,
|
|
83
|
+
...insertTokens.slice(insertTokens.length - rest),
|
|
80
84
|
];
|
|
81
85
|
|
|
82
86
|
tokens.splice(i, closeTokenIdx - i + 3, ...insideTokens);
|
|
@@ -3,10 +3,10 @@ import type ParserInline from 'markdown-it/lib/parser_inline';
|
|
|
3
3
|
import type Renderer from 'markdown-it/lib/renderer';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
FileClassName,
|
|
7
|
-
FileSpecialAttr,
|
|
8
6
|
FILE_TOKEN,
|
|
9
7
|
FILE_TO_LINK_ATTRS_MAP,
|
|
8
|
+
FileClassName,
|
|
9
|
+
FileSpecialAttr,
|
|
10
10
|
KNOWN_ATTRS,
|
|
11
11
|
PREFIX,
|
|
12
12
|
PREFIX_LENGTH,
|
|
@@ -2,8 +2,8 @@ import {readFileSync} from 'fs';
|
|
|
2
2
|
import {join, sep} from 'path';
|
|
3
3
|
import {bold} from 'chalk';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {isFileExists, resolveRelativePath} from '../../utilsFS';
|
|
6
|
+
import {isExternalHref, isLocalUrl} from '../../utils';
|
|
7
7
|
import Token from 'markdown-it/lib/token';
|
|
8
8
|
import {MarkdownItPluginCb, MarkdownItPluginOpts} from '../typings';
|
|
9
9
|
import {StateCore} from '../../typings';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {GetFileTokensOpts, getFileTokens, getFullIncludePath, isFileExists} from '../../utilsFS';
|
|
4
4
|
import {findBlockTokens} from '../../utils';
|
|
5
5
|
import Token from 'markdown-it/lib/token';
|
|
6
6
|
import {MarkdownItPluginCb, MarkdownItPluginOpts} from '../typings';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import url from 'url';
|
|
2
2
|
import {bold} from 'chalk';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import {findBlockTokens, getHrefTokenAttr, headingInfo, isLocalUrl} from '../../utils';
|
|
4
|
+
import {getFileTokens, isFileExists} from '../../utilsFS';
|
|
5
5
|
import {PAGE_LINK_REGEXP} from './constants';
|
|
6
6
|
import Token from 'markdown-it/lib/token';
|
|
7
7
|
import {Logger} from 'src/transform/log';
|
|
@@ -87,6 +87,7 @@ const notes: MarkdownItPluginCb = (md, {lang, path: optPath, log}) => {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const newCloseToken = new state.Token('yfm_note_close', 'div', -1);
|
|
90
|
+
newCloseToken.map = tokens[closeTokenIdx].map;
|
|
90
91
|
|
|
91
92
|
// Add extra paragraph
|
|
92
93
|
const titleOpen = new state.Token('yfm_note_title_open', 'p', 1);
|
|
@@ -12,7 +12,7 @@ import type Renderer from 'markdown-it/lib/renderer';
|
|
|
12
12
|
|
|
13
13
|
import type {VideoFullOptions, VideoPluginOptions, VideoToken} from './types';
|
|
14
14
|
import {parseVideoUrl} from './parsers';
|
|
15
|
-
import {
|
|
15
|
+
import {VideoService, defaults} from './const';
|
|
16
16
|
|
|
17
17
|
// eslint-disable-next-line valid-jsdoc
|
|
18
18
|
/**
|
package/src/transform/utilsFS.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {readFileSync, statSync} from 'fs';
|
|
|
2
2
|
import type {Dictionary} from 'lodash';
|
|
3
3
|
import escapeRegExp from 'lodash/escapeRegExp';
|
|
4
4
|
|
|
5
|
-
import {parse, resolve,
|
|
5
|
+
import {join, parse, resolve, sep} from 'path';
|
|
6
6
|
|
|
7
7
|
import liquid from './liquid';
|
|
8
8
|
import {StateCore} from './typings';
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {errorToString, getLogLevel} from './utils';
|
|
19
19
|
import {Options} from './typings';
|
|
20
20
|
import type {Dictionary} from 'lodash';
|
|
21
|
-
import {
|
|
21
|
+
import {LogLevels, Logger} from '../log';
|
|
22
22
|
import {yfm009} from './markdownlint-custom-rule/yfm009';
|
|
23
23
|
|
|
24
24
|
const defaultLintRules = [yfm001, yfm002, yfm003, yfm004, yfm005, yfm006, yfm007, yfm008, yfm009];
|
|
@@ -9,20 +9,21 @@ export const yfm007: Rule = {
|
|
|
9
9
|
if (!config) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
params.tokens.forEach(
|
|
13
|
-
el
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
params.tokens.forEach(
|
|
13
|
+
(el) =>
|
|
14
|
+
el.children
|
|
15
|
+
?.filter((token) => {
|
|
16
|
+
return token.type === '__yfm_lint';
|
|
17
|
+
})
|
|
18
|
+
.forEach((term) => {
|
|
19
|
+
// @ts-expect-error bad markdownlint typings
|
|
20
|
+
if (term.attrGet('YFM007')) {
|
|
21
|
+
onError({
|
|
22
|
+
lineNumber: term.lineNumber,
|
|
23
|
+
context: term.line,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
26
27
|
);
|
|
27
28
|
},
|
|
28
29
|
};
|