@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.
Files changed (41) hide show
  1. package/dist/css/print.css.map +1 -1
  2. package/dist/css/yfm.css +4 -2
  3. package/dist/css/yfm.css.map +3 -3
  4. package/dist/css/yfm.min.css +1 -1
  5. package/dist/css/yfm.min.css.map +3 -3
  6. package/dist/js/yfm.js +39 -39
  7. package/dist/js/yfm.js.map +1 -1
  8. package/dist/js/yfm.min.js +1 -1
  9. package/dist/js/yfm.min.js.map +1 -1
  10. package/lib/plugins/anchors/collect.js +2 -1
  11. package/lib/plugins/anchors/collect.js.map +1 -1
  12. package/lib/plugins/block-anchor/index.d.ts +1 -1
  13. package/lib/plugins/block-anchor/index.js +1 -2
  14. package/lib/plugins/block-anchor/index.js.map +1 -1
  15. package/lib/plugins/cut.js +4 -1
  16. package/lib/plugins/cut.js.map +1 -1
  17. package/lib/plugins/notes.js +1 -0
  18. package/lib/plugins/notes.js.map +1 -1
  19. package/lib/yfmlint/index.d.ts +1 -1
  20. package/lib/yfmlint/markdownlint-custom-rule/yfm007.js.map +1 -1
  21. package/package.json +4 -10
  22. package/src/.eslintrc.js +16 -0
  23. package/src/js/term/index.ts +2 -2
  24. package/src/transform/index.ts +1 -1
  25. package/src/transform/liquid/substitutions.ts +1 -1
  26. package/src/transform/log.ts +1 -1
  27. package/src/transform/md.ts +1 -1
  28. package/src/transform/plugins/anchors/collect.ts +3 -4
  29. package/src/transform/plugins/anchors/index.ts +1 -1
  30. package/src/transform/plugins/block-anchor/index.ts +2 -2
  31. package/src/transform/plugins/cut.ts +5 -1
  32. package/src/transform/plugins/file/file.ts +2 -2
  33. package/src/transform/plugins/images/index.ts +2 -2
  34. package/src/transform/plugins/includes/index.ts +1 -1
  35. package/src/transform/plugins/links/index.ts +2 -2
  36. package/src/transform/plugins/notes.ts +1 -0
  37. package/src/transform/plugins/video/index.ts +1 -1
  38. package/src/transform/utilsFS.ts +1 -1
  39. package/src/transform/yfmlint/index.ts +1 -1
  40. package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +15 -14
  41. 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 {CUSTOM_ID_REGEXP, CUSTOM_ID_EXCEPTION} from './constants';
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
- i
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 {CUSTOM_ID_REGEXP, CUSTOM_ID_EXCEPTION} from './constants';
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, TOKEN_NAME} from './block-anchor';
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 default blockAnchor;
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
- ...tokens.slice(i + 3, closeTokenIdx),
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 {resolveRelativePath, isFileExists} from '../../utilsFS';
6
- import {isLocalUrl, isExternalHref} from '../../utils';
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 {getFileTokens, GetFileTokensOpts, getFullIncludePath, isFileExists} from '../../utilsFS';
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 {isLocalUrl, findBlockTokens, headingInfo, getHrefTokenAttr} from '../../utils';
4
- import {isFileExists, getFileTokens} from '../../utilsFS';
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 {defaults, VideoService} from './const';
15
+ import {VideoService, defaults} from './const';
16
16
 
17
17
  // eslint-disable-next-line valid-jsdoc
18
18
  /**
@@ -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, join, sep} from 'path';
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 {Logger, LogLevels} from '../log';
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((el) =>
13
- el.children
14
- ?.filter((token) => {
15
- return token.type === '__yfm_lint';
16
- })
17
- .forEach((term) => {
18
- // @ts-expect-error bad markdownlint typings
19
- if (term.attrGet('YFM007')) {
20
- onError({
21
- lineNumber: term.lineNumber,
22
- context: term.line,
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
  };
package/src/.eslintrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@yandex-cloud/eslint-config/client",
3
- "overrides": [{
4
- "files": ["*"],
5
- "rules": {
6
- "new-cap": [2, { "capIsNew": false }],
7
- "@typescript-eslint/no-namespace": [1, { "allowDeclarations": true }]
8
- }
9
- }]
10
- }