@diplodoc/transform 4.57.7 → 4.58.1

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 (161) hide show
  1. package/dist/css/_yfm-only.css.map +1 -1
  2. package/dist/css/_yfm-only.min.css.map +1 -1
  3. package/dist/css/base.css.map +1 -1
  4. package/dist/css/base.min.css.map +1 -1
  5. package/dist/css/print.css.map +1 -1
  6. package/dist/css/yfm.css.map +1 -1
  7. package/dist/css/yfm.min.css.map +1 -1
  8. package/dist/js/base.js +1 -1
  9. package/dist/js/base.js.map +2 -2
  10. package/dist/js/base.min.js +1 -1
  11. package/dist/js/base.min.js.map +2 -2
  12. package/dist/js/yfm.js +1 -1
  13. package/dist/js/yfm.js.map +2 -2
  14. package/dist/js/yfm.min.js +1 -1
  15. package/dist/js/yfm.min.js.map +2 -2
  16. package/lib/constants.d.ts +1 -1
  17. package/lib/headings.d.ts +2 -2
  18. package/lib/headings.js.map +1 -1
  19. package/lib/highlight.d.ts +1 -1
  20. package/lib/highlight.js.map +1 -1
  21. package/lib/liquid/conditions.js.map +1 -1
  22. package/lib/liquid/index.d.ts +1 -1
  23. package/lib/liquid/index.js.map +1 -1
  24. package/lib/plugins/anchors/collect.d.ts +1 -1
  25. package/lib/plugins/anchors/collect.js.map +1 -1
  26. package/lib/plugins/anchors/constants.d.ts +1 -1
  27. package/lib/plugins/anchors/index.d.ts +1 -1
  28. package/lib/plugins/anchors/index.js.map +1 -1
  29. package/lib/plugins/block-anchor/block-anchor.d.ts +2 -2
  30. package/lib/plugins/block-anchor/index.d.ts +1 -1
  31. package/lib/plugins/changelog/collect.d.ts +2 -2
  32. package/lib/plugins/changelog/collect.js.map +1 -1
  33. package/lib/plugins/changelog/index.d.ts +1 -1
  34. package/lib/plugins/changelog/index.js.map +1 -1
  35. package/lib/plugins/checkbox/index.d.ts +1 -1
  36. package/lib/plugins/checkbox/index.js.map +1 -1
  37. package/lib/plugins/code.d.ts +1 -1
  38. package/lib/plugins/code.js +1 -1
  39. package/lib/plugins/code.js.map +1 -1
  40. package/lib/plugins/deflist.d.ts +1 -1
  41. package/lib/plugins/deflist.js.map +1 -1
  42. package/lib/plugins/images/collect.d.ts +1 -1
  43. package/lib/plugins/images/collect.js.map +1 -1
  44. package/lib/plugins/images/index.d.ts +1 -1
  45. package/lib/plugins/images/index.js.map +1 -1
  46. package/lib/plugins/imsize/index.d.ts +2 -2
  47. package/lib/plugins/imsize/index.js.map +1 -1
  48. package/lib/plugins/includes/collect.d.ts +1 -1
  49. package/lib/plugins/includes/collect.js.map +1 -1
  50. package/lib/plugins/includes/index.d.ts +2 -2
  51. package/lib/plugins/includes/index.js +1 -1
  52. package/lib/plugins/includes/index.js.map +1 -1
  53. package/lib/plugins/includes/types.d.ts +2 -2
  54. package/lib/plugins/links/index.d.ts +4 -4
  55. package/lib/plugins/links/index.js.map +1 -1
  56. package/lib/plugins/meta.d.ts +1 -1
  57. package/lib/plugins/meta.js.map +1 -1
  58. package/lib/plugins/monospace.d.ts +1 -1
  59. package/lib/plugins/notes/constants.d.ts +1 -1
  60. package/lib/plugins/notes/index.d.ts +1 -1
  61. package/lib/plugins/notes/index.js.map +1 -1
  62. package/lib/plugins/ol-attr-conversion.d.ts +1 -1
  63. package/lib/plugins/sup.d.ts +1 -1
  64. package/lib/plugins/sup.js.map +1 -1
  65. package/lib/plugins/table/index.d.ts +3 -2
  66. package/lib/plugins/table/index.js +152 -28
  67. package/lib/plugins/table/index.js.map +1 -1
  68. package/lib/plugins/table/types.d.ts +34 -0
  69. package/lib/plugins/table/types.js +3 -0
  70. package/lib/plugins/table/types.js.map +1 -0
  71. package/lib/plugins/term/index.d.ts +1 -1
  72. package/lib/plugins/term/termDefinitions.d.ts +3 -3
  73. package/lib/plugins/term/termDefinitions.js.map +1 -1
  74. package/lib/plugins/utils.d.ts +2 -2
  75. package/lib/plugins/utils.js.map +1 -1
  76. package/lib/preprocessors/included/index.d.ts +1 -1
  77. package/lib/preprocessors/included/index.js.map +1 -1
  78. package/lib/sanitize.d.ts +1 -1
  79. package/lib/sanitize.js.map +1 -1
  80. package/lib/title.d.ts +1 -1
  81. package/lib/typings.d.ts +7 -6
  82. package/lib/utils.d.ts +1 -1
  83. package/lib/utils.js.map +1 -1
  84. package/lib/utilsFS.d.ts +1 -1
  85. package/lib/utilsFS.js.map +1 -1
  86. package/lib/yfmlint/index.d.ts +3 -3
  87. package/lib/yfmlint/index.js.map +1 -1
  88. package/lib/yfmlint/markdownlint-custom-rule/yfm001.d.ts +1 -1
  89. package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -1
  90. package/lib/yfmlint/markdownlint-custom-rule/yfm002.d.ts +1 -1
  91. package/lib/yfmlint/markdownlint-custom-rule/yfm003.d.ts +1 -1
  92. package/lib/yfmlint/markdownlint-custom-rule/yfm004.d.ts +1 -1
  93. package/lib/yfmlint/markdownlint-custom-rule/yfm005.d.ts +1 -1
  94. package/lib/yfmlint/markdownlint-custom-rule/yfm006.d.ts +1 -1
  95. package/lib/yfmlint/markdownlint-custom-rule/yfm007.d.ts +1 -1
  96. package/lib/yfmlint/markdownlint-custom-rule/yfm008.d.ts +1 -1
  97. package/lib/yfmlint/markdownlint-custom-rule/yfm009.d.ts +1 -1
  98. package/lib/yfmlint/typings.d.ts +3 -3
  99. package/lib/yfmlint/utils.d.ts +2 -2
  100. package/lib/yfmlint/utils.js.map +1 -1
  101. package/lib/yfmlint/yfmlint.d.ts +1 -1
  102. package/lib/yfmlint/yfmlint.js.map +1 -1
  103. package/package.json +2 -1
  104. package/src/js/code.ts +1 -1
  105. package/src/transform/constants.ts +1 -1
  106. package/src/transform/headings.ts +2 -3
  107. package/src/transform/highlight.ts +2 -2
  108. package/src/transform/liquid/conditions.ts +3 -1
  109. package/src/transform/liquid/index.ts +2 -1
  110. package/src/transform/plugins/anchors/collect.ts +2 -1
  111. package/src/transform/plugins/anchors/constants.ts +1 -1
  112. package/src/transform/plugins/anchors/index.ts +4 -3
  113. package/src/transform/plugins/block-anchor/block-anchor.ts +2 -2
  114. package/src/transform/plugins/block-anchor/index.ts +1 -1
  115. package/src/transform/plugins/changelog/collect.ts +3 -3
  116. package/src/transform/plugins/changelog/index.ts +5 -5
  117. package/src/transform/plugins/checkbox/index.ts +2 -1
  118. package/src/transform/plugins/code.ts +3 -2
  119. package/src/transform/plugins/deflist.ts +2 -2
  120. package/src/transform/plugins/images/collect.ts +2 -1
  121. package/src/transform/plugins/images/index.ts +4 -3
  122. package/src/transform/plugins/imsize/index.ts +3 -2
  123. package/src/transform/plugins/includes/collect.ts +2 -2
  124. package/src/transform/plugins/includes/index.ts +8 -13
  125. package/src/transform/plugins/includes/types.ts +2 -2
  126. package/src/transform/plugins/links/index.ts +6 -6
  127. package/src/transform/plugins/meta.ts +2 -2
  128. package/src/transform/plugins/monospace.ts +3 -3
  129. package/src/transform/plugins/notes/constants.ts +1 -1
  130. package/src/transform/plugins/notes/index.ts +6 -4
  131. package/src/transform/plugins/ol-attr-conversion.ts +1 -1
  132. package/src/transform/plugins/sup.ts +2 -2
  133. package/src/transform/plugins/table/index.ts +190 -31
  134. package/src/transform/plugins/table/types.ts +35 -0
  135. package/src/transform/plugins/term/index.ts +3 -3
  136. package/src/transform/plugins/term/termDefinitions.ts +3 -4
  137. package/src/transform/plugins/utils.ts +3 -3
  138. package/src/transform/plugins/video/parsers.ts +2 -2
  139. package/src/transform/preprocessors/included/index.ts +3 -2
  140. package/src/transform/sanitize.ts +4 -2
  141. package/src/transform/title.ts +1 -1
  142. package/src/transform/typings.ts +7 -7
  143. package/src/transform/utils.ts +2 -1
  144. package/src/transform/utilsFS.ts +1 -1
  145. package/src/transform/yfmlint/index.ts +4 -3
  146. package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +2 -1
  147. package/src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts +1 -1
  148. package/src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts +1 -1
  149. package/src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts +1 -1
  150. package/src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts +1 -1
  151. package/src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts +1 -1
  152. package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +1 -1
  153. package/src/transform/yfmlint/markdownlint-custom-rule/yfm008.ts +1 -1
  154. package/src/transform/yfmlint/markdownlint-custom-rule/yfm009.ts +1 -1
  155. package/src/transform/yfmlint/typings.ts +3 -6
  156. package/src/transform/yfmlint/utils.ts +2 -3
  157. package/src/transform/yfmlint/yfmlint.ts +2 -2
  158. package/lib/plugins/table/attrs.d.ts +0 -18
  159. package/lib/plugins/table/attrs.js +0 -172
  160. package/lib/plugins/table/attrs.js.map +0 -1
  161. package/src/transform/plugins/table/attrs.ts +0 -199
@@ -1,9 +1,9 @@
1
- import StateBlock from 'markdown-it/lib/rules_block/state_block';
2
- import Token from 'markdown-it/lib/token';
1
+ import type StateBlock from 'markdown-it/lib/rules_block/state_block';
2
+ import type Token from 'markdown-it/lib/token';
3
+ import type {MarkdownItPluginCb} from '../typings';
4
+ import type {YfmTablePluginOptions} from './types';
3
5
 
4
- import {MarkdownItPluginCb} from '../typings';
5
-
6
- import {AttrsParser} from './attrs';
6
+ import {AttrsParser} from '@diplodoc/utils';
7
7
 
8
8
  const pluginName = 'yfm_table';
9
9
  const pipeChar = 0x7c; // |
@@ -12,6 +12,7 @@ const hashChar = 0x23; // #
12
12
  const backSlashChar = 0x5c; // \
13
13
  const curlyBraceOpen = 123;
14
14
  const curlyBraceClose = 125;
15
+ const dollarChar = 36; // $
15
16
 
16
17
  const checkCharsOrder = (order: number[], src: string, pos: number) => {
17
18
  const currentOrder = [...order];
@@ -39,10 +40,21 @@ const isLiquidVariableEnd: CheckFn = (src, pos) =>
39
40
  const codeBlockOrder = [apostropheChar, apostropheChar, apostropheChar];
40
41
  const isCodeBlockOrder: CheckFn = (src, pos) => checkCharsOrder(codeBlockOrder, src, pos);
41
42
 
43
+ const mathBlockOrder = [dollarChar, dollarChar];
44
+ const isMathBlockOrder: CheckFn = (src, pos) => checkCharsOrder(mathBlockOrder, src, pos);
45
+
42
46
  const openTableOrder = [hashChar, pipeChar];
43
47
  const isOpenTableOrder: CheckFn = (src, pos) => checkCharsOrder(openTableOrder, src, pos);
44
48
 
45
- const notEscaped: CheckFn = (src, pos) => src.charCodeAt(pos - 1) !== backSlashChar;
49
+ const isEscaped: CheckFn = (src, pos) => {
50
+ const start = pos;
51
+ pos--;
52
+ while (src.charCodeAt(pos) === backSlashChar) {
53
+ pos--;
54
+ }
55
+ return (start - pos) % 2 === 0;
56
+ };
57
+ const notEscaped: CheckFn = (src, pos) => !isEscaped(src, pos);
46
58
 
47
59
  const rowStartOrder = [pipeChar, pipeChar];
48
60
  const isRowOrder: CheckFn = (src, pos) =>
@@ -55,41 +67,159 @@ const isCellOrder: CheckFn = (src, pos) =>
55
67
  const closeTableOrder = [pipeChar, hashChar];
56
68
  const isCloseTableOrder: CheckFn = (src, pos) => checkCharsOrder(closeTableOrder, src, pos);
57
69
 
70
+ type SkipInlineFn = (src: string, pos: number, max: number) => false | SkipInlineResult;
71
+ type SkipInlineResult = {
72
+ end: number;
73
+ steps: number;
74
+ };
75
+
76
+ const skipInlineCode: SkipInlineFn = (src, pos, max) => {
77
+ // this function is an adaptation of original markdown-it backticks plugin
78
+ // https://github.com/markdown-it/markdown-it/blob/master/lib/rules_inline/backticks.mjs
79
+
80
+ if (src.charCodeAt(pos) !== apostropheChar) {
81
+ return false;
82
+ }
83
+ if (pos > 0 && isEscaped(src, pos)) {
84
+ return false;
85
+ }
86
+
87
+ const start = pos;
88
+
89
+ // scan marker length
90
+ while (pos < max && src.charCodeAt(pos) === apostropheChar) {
91
+ pos++;
92
+ }
93
+
94
+ const marker = src.slice(start, pos);
95
+ const openerLength = marker.length;
96
+
97
+ let matchEnd = pos;
98
+ let matchStart: number;
99
+
100
+ while ((matchStart = src.indexOf('`', matchEnd)) !== -1) {
101
+ matchEnd = matchStart + 1;
102
+
103
+ // scan marker length
104
+ while (matchEnd < max && src.charCodeAt(matchEnd) === apostropheChar) {
105
+ matchEnd++;
106
+ }
107
+
108
+ const closerLength = matchEnd - matchStart;
109
+
110
+ if (closerLength === openerLength) {
111
+ return {
112
+ end: matchEnd,
113
+ steps: matchEnd - start,
114
+ };
115
+ }
116
+ }
117
+
118
+ return false;
119
+ };
120
+
121
+ const skipInlineMath: SkipInlineFn = (src, pos, max) => {
122
+ // this function is an adaptation of latex-extension plugin
123
+ // https://github.com/diplodoc-platform/latex-extension/blob/master/src/plugin/transform.ts
124
+
125
+ if (src.charCodeAt(pos) !== dollarChar) {
126
+ return false;
127
+ }
128
+ if (pos > 0 && !notEscaped(src, pos)) {
129
+ return false;
130
+ }
131
+
132
+ {
133
+ const nextChar = pos + 1 <= max ? src.charCodeAt(pos + 1) : -1;
134
+ if (nextChar === 0x20 /* " " */ || nextChar === 0x09 /* \t */) {
135
+ return false;
136
+ }
137
+ if (nextChar === dollarChar) {
138
+ return {
139
+ end: pos + 2,
140
+ steps: 2,
141
+ };
142
+ }
143
+ }
144
+
145
+ const start = pos + 1;
146
+ let match = start;
147
+ // eslint-disable-next-line no-cond-assign
148
+ while ((match = src.indexOf('$', match))) {
149
+ if (match === -1 || match > max) {
150
+ return false;
151
+ }
152
+ if (isEscaped(src, match)) {
153
+ match++;
154
+ continue;
155
+ }
156
+
157
+ const prevChar = src.charCodeAt(match - 1);
158
+ const nextChar = match + 1 <= max ? src.charCodeAt(match + 1) : -1;
159
+ if (
160
+ prevChar === 0x20 /* " " */ ||
161
+ prevChar === 0x09 /* \t */ ||
162
+ (nextChar >= 0x30 /* "0" */ && nextChar <= 0x39) /* "9" */
163
+ ) {
164
+ return false;
165
+ }
166
+
167
+ return {
168
+ end: match + 1,
169
+ steps: match + 1 - start,
170
+ };
171
+ }
172
+
173
+ return false;
174
+ };
175
+
58
176
  type Stats = {line: number; pos: number};
59
177
 
60
178
  class StateIterator {
61
- pos: number;
62
- line: number;
179
+ private _pos: number;
180
+ private _line: number;
181
+ private _lineEnds: number;
63
182
 
64
183
  private state: StateBlock;
65
- private lineEnds: number;
184
+
185
+ get pos() {
186
+ return this._pos;
187
+ }
188
+
189
+ get line() {
190
+ return this._line;
191
+ }
192
+
193
+ get lineEnds() {
194
+ return this._lineEnds;
195
+ }
66
196
 
67
197
  constructor(state: StateBlock, pos: number, line: number) {
68
198
  this.state = state;
69
- this.line = line;
70
- this.pos = pos;
71
- this.lineEnds = this.state.eMarks[this.line];
199
+ this._line = line;
200
+ this._pos = pos;
201
+ this._lineEnds = this.state.eMarks[this._line];
72
202
  }
73
203
 
74
204
  stats(): Stats {
75
205
  return {
76
- line: this.line,
77
- pos: this.pos,
206
+ line: this._line,
207
+ pos: this._pos,
78
208
  };
79
209
  }
80
210
 
81
211
  get symbol() {
82
- return this.state.src[this.pos];
212
+ return this.state.src[this._pos];
83
213
  }
84
214
 
85
215
  next(steps = 1) {
86
216
  for (let i = 0; i < steps; i++) {
87
- this.pos++;
217
+ this._pos++;
88
218
 
89
- if (this.pos > this.lineEnds) {
90
- this.line++;
91
- this.pos = this.state.bMarks[this.line] + this.state.tShift[this.line];
92
- this.lineEnds = this.state.eMarks[this.line];
219
+ if (this._pos > this._lineEnds) {
220
+ this._line++;
221
+ this._pos = this.state.bMarks[this._line] + this.state.tShift[this._line];
222
+ this._lineEnds = this.state.eMarks[this._line];
93
223
  }
94
224
  }
95
225
  }
@@ -101,11 +231,13 @@ interface RowPositions {
101
231
  pos: number;
102
232
  }
103
233
 
234
+ // eslint-disable-next-line complexity
104
235
  function getTableRowPositions(
105
236
  state: StateBlock,
106
237
  startPosition: number,
107
238
  endPosition: number,
108
239
  startLine: number,
240
+ opts: YfmTablePluginOptions = {},
109
241
  ): RowPositions {
110
242
  let endOfTable = null;
111
243
  let tableLevel = 0;
@@ -118,7 +250,7 @@ function getTableRowPositions(
118
250
  const rows: [number, number, typeof currentRow][] = [];
119
251
 
120
252
  let isInsideCode = false;
121
- let isInsideTable = false;
253
+ let isInsideMath = false;
122
254
  let isInsideLiquidVariable = false;
123
255
  const rowMap = new Map();
124
256
 
@@ -139,12 +271,21 @@ function getTableRowPositions(
139
271
  break;
140
272
  }
141
273
 
142
- if (isCodeBlockOrder(state.src, iter.pos)) {
143
- isInsideCode = !isInsideCode;
144
- iter.next(codeBlockOrder.length);
274
+ if (opts.table_ignoreSplittersInBlockCode !== false) {
275
+ if (!isInsideMath && isCodeBlockOrder(state.src, iter.pos)) {
276
+ isInsideCode = !isInsideCode;
277
+ iter.next(codeBlockOrder.length);
278
+ }
279
+ }
280
+
281
+ if (opts.table_ignoreSplittersInBlockMath) {
282
+ if (!isInsideCode && isMathBlockOrder(state.src, iter.pos)) {
283
+ isInsideMath = !isInsideMath;
284
+ iter.next(mathBlockOrder.length);
285
+ }
145
286
  }
146
287
 
147
- if (isInsideCode) {
288
+ if (isInsideCode || isInsideMath) {
148
289
  iter.next();
149
290
  continue;
150
291
  }
@@ -164,8 +305,23 @@ function getTableRowPositions(
164
305
  continue;
165
306
  }
166
307
 
308
+ if (opts.table_ignoreSplittersInInlineCode) {
309
+ const result = skipInlineCode(state.src, iter.pos, iter.lineEnds);
310
+ if (result !== false) {
311
+ iter.next(result.steps);
312
+ continue;
313
+ }
314
+ }
315
+
316
+ if (opts.table_ignoreSplittersInInlineMath) {
317
+ const result = skipInlineMath(state.src, iter.pos, iter.lineEnds);
318
+ if (result !== false) {
319
+ iter.next(result.steps);
320
+ continue;
321
+ }
322
+ }
323
+
167
324
  if (isOpenTableOrder(state.src, iter.pos)) {
168
- isInsideTable = true;
169
325
  tableLevel++;
170
326
  iter.next(openTableOrder.length);
171
327
  continue;
@@ -178,16 +334,18 @@ function getTableRowPositions(
178
334
  endOfTable = iter.line + 2;
179
335
  break;
180
336
  } else {
181
- isInsideTable = false;
182
337
  tableLevel--;
183
338
  iter.next(closeTableOrder.length);
184
339
  continue;
185
340
  }
186
341
  }
187
342
 
188
- if (isInsideTable) {
189
- iter.next();
190
- continue;
343
+ {
344
+ const isInsideTable = tableLevel > 0;
345
+ if (isInsideTable) {
346
+ iter.next();
347
+ continue;
348
+ }
191
349
  }
192
350
 
193
351
  if (isRowOrder(state.src, iter.pos)) {
@@ -359,7 +517,7 @@ const clearTokens = (tableStart: number, tokens: Token[]): void => {
359
517
  });
360
518
  };
361
519
 
362
- const yfmTable: MarkdownItPluginCb = (md) => {
520
+ const yfmTable: MarkdownItPluginCb<YfmTablePluginOptions> = (md, opts) => {
363
521
  md.block.ruler.before(
364
522
  'code',
365
523
  pluginName,
@@ -386,6 +544,7 @@ const yfmTable: MarkdownItPluginCb = (md) => {
386
544
  startPosition,
387
545
  endPosition,
388
546
  startLine,
547
+ opts,
389
548
  );
390
549
 
391
550
  const attrs = extractAttributes(state, pos);
@@ -0,0 +1,35 @@
1
+ export type YfmTablePluginOptions = {
2
+ /**
3
+ * Sets whether to interpret the pipe symbol inside the code block as a table separator.
4
+ *
5
+ * Set to false if the fence rule is disabled in the parser.
6
+ *
7
+ * @default true
8
+ */
9
+ table_ignoreSplittersInBlockCode?: boolean;
10
+ // TODO: set table_ignoreSplittersInInlineCode=true by default in next major version
11
+ /**
12
+ * Sets whether to interpret the pipe symbol inside the inline code as a table separator.
13
+ *
14
+ * Set to true if the code_inline rule is enabled in the parser.
15
+ *
16
+ * @default false
17
+ */
18
+ table_ignoreSplittersInInlineCode?: boolean;
19
+ /**
20
+ * Sets whether to interpret the pipe symbol inside the math block as a table separator.
21
+ *
22
+ * Set to true if the math_block rule is enabled in the parser.
23
+ *
24
+ * @default false
25
+ */
26
+ table_ignoreSplittersInBlockMath?: boolean;
27
+ /**
28
+ * Sets whether to interpret the pipe symbol inside the inline math as a table separator.
29
+ *
30
+ * Set to true if the math_inline rule is enabled in the parser.
31
+ *
32
+ * @default false
33
+ */
34
+ table_ignoreSplittersInInlineMath?: boolean;
35
+ };
@@ -1,7 +1,7 @@
1
- import StateCore from 'markdown-it/lib/rules_core/state_core';
2
- import Token from 'markdown-it/lib/token';
1
+ import type StateCore from 'markdown-it/lib/rules_core/state_core';
2
+ import type Token from 'markdown-it/lib/token';
3
+ import type {MarkdownItPluginCb} from '../typings';
3
4
 
4
- import {MarkdownItPluginCb} from '../typings';
5
5
  import {generateID} from '../utils';
6
6
 
7
7
  import {termDefinitions} from './termDefinitions';
@@ -1,7 +1,6 @@
1
- import StateBlock from 'markdown-it/lib/rules_block/state_block';
2
-
3
- import {MarkdownIt} from '../../typings';
4
- import {MarkdownItPluginOpts} from '../typings';
1
+ import type StateBlock from 'markdown-it/lib/rules_block/state_block';
2
+ import type {MarkdownIt} from '../../typings';
3
+ import type {MarkdownItPluginOpts} from '../typings';
5
4
 
6
5
  import {BASIC_TERM_REGEXP} from './constants';
7
6
 
@@ -1,8 +1,8 @@
1
+ import type Token from 'markdown-it/lib/token';
2
+ import type {Logger} from '../log';
3
+
1
4
  import {bold} from 'chalk';
2
5
  import {platform} from 'process';
3
- import Token from 'markdown-it/lib/token';
4
-
5
- import {Logger} from '../log';
6
6
 
7
7
  export type MatchTokenFunction = (
8
8
  tokens: Token[],
@@ -1,5 +1,5 @@
1
- import {VideoService} from './const';
2
- import {Services} from './types';
1
+ import type {VideoService} from './const';
2
+ import type {Services} from './types';
3
3
 
4
4
  const ytRegex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
5
5
  export function youtubeParser(url: string) {
@@ -1,6 +1,7 @@
1
+ import type {MarkdownItPreprocessorCb} from '../../typings';
2
+ import type {MarkdownItIncluded} from '../../plugins/includes/types';
3
+
1
4
  import {getFullIncludePath} from '../../utilsFS';
2
- import {MarkdownItPreprocessorCb} from '../../typings';
3
- import {MarkdownItIncluded} from '../../plugins/includes/types';
4
5
 
5
6
  const INCLUDE_REGEXP = /^\s*{%\s*included\s*\((.+?)\)\s*%}\s*$/;
6
7
  const INCLUDE_END_REGEXP = /^\s*{% endincluded %}\s*$/;
@@ -1,10 +1,12 @@
1
- import sanitizeHtml, {Attributes, Tag} from 'sanitize-html';
1
+ import type {Attributes, Tag} from 'sanitize-html';
2
+ import type {CssWhiteList} from './typings';
3
+
4
+ import sanitizeHtml from 'sanitize-html';
2
5
  // @ts-ignore
3
6
  import cssfilter from 'cssfilter';
4
7
  import * as cheerio from 'cheerio';
5
8
  import css from 'css';
6
9
 
7
- import {CssWhiteList} from './typings';
8
10
  import log from './log';
9
11
 
10
12
  export type SanitizeFunction = (
@@ -1,4 +1,4 @@
1
- import Token from 'markdown-it/lib/token';
1
+ import type Token from 'markdown-it/lib/token';
2
2
 
3
3
  export = function extractTitle(tokens: Token[]) {
4
4
  let title = '',
@@ -1,10 +1,10 @@
1
- import {LanguageFn} from 'highlight.js';
2
- import DefaultMarkdownIt, {Token} from 'markdown-it';
3
- import DefaultStateCore from 'markdown-it/lib/rules_core/state_core';
4
-
5
- import {SanitizeFunction, SanitizeOptions} from './sanitize';
6
- import {LogLevels, Logger} from './log';
7
- import {ChangelogItem} from './plugins/changelog/types';
1
+ import type {LanguageFn} from 'highlight.js';
2
+ import type {Token} from 'markdown-it';
3
+ import type DefaultMarkdownIt from 'markdown-it';
4
+ import type DefaultStateCore from 'markdown-it/lib/rules_core/state_core';
5
+ import type {SanitizeFunction, SanitizeOptions} from './sanitize';
6
+ import type {LogLevels, Logger} from './log';
7
+ import type {ChangelogItem} from './plugins/changelog/types';
8
8
 
9
9
  export interface MarkdownIt extends DefaultMarkdownIt {
10
10
  assets?: string[];
@@ -1,5 +1,6 @@
1
+ import type Token from 'markdown-it/lib/token';
2
+
1
3
  import url from 'url';
2
- import Token from 'markdown-it/lib/token';
3
4
 
4
5
  export function isLocalUrl(url: string) {
5
6
  return !/^(?:[a-z]+:)?\/\//i.test(url);
@@ -1,4 +1,5 @@
1
1
  import type {Dictionary} from 'lodash';
2
+ import type {StateCore} from './typings';
2
3
 
3
4
  import {readFileSync, realpathSync, statSync} from 'fs';
4
5
  import escapeRegExp from 'lodash/escapeRegExp';
@@ -6,7 +7,6 @@ import {join, parse, relative, resolve, sep} from 'path';
6
7
  import QuickLRU from 'quick-lru';
7
8
 
8
9
  import liquidSnippet from './liquid';
9
- import {StateCore} from './typings';
10
10
  import {defaultTransformLink} from './utils';
11
11
  import {preprocess} from './preprocessors';
12
12
 
@@ -1,11 +1,13 @@
1
1
  import type {Dictionary} from 'lodash';
2
+ import type {Rule} from 'markdownlint';
3
+ import type {LogLevels, Logger} from '../log';
4
+ import type {Options} from './typings';
2
5
 
3
- import {Rule, sync} from 'markdownlint';
6
+ import {sync} from 'markdownlint';
4
7
  import merge from 'lodash/merge';
5
8
  import union from 'lodash/union';
6
9
  import attrs from 'markdown-it-attrs';
7
10
 
8
- import {LogLevels, Logger} from '../log';
9
11
  import {preprocess} from '../preprocessors';
10
12
 
11
13
  import baseDefaultLintConfig from './yfmlint';
@@ -20,7 +22,6 @@ import {
20
22
  yfm008,
21
23
  } from './markdownlint-custom-rule';
22
24
  import {errorToString, getLogLevel} from './utils';
23
- import {Options} from './typings';
24
25
  import {yfm009} from './markdownlint-custom-rule/yfm009';
25
26
 
26
27
  const defaultLintRules = [yfm001, yfm002, yfm003, yfm004, yfm005, yfm006, yfm007, yfm008, yfm009];
@@ -1,6 +1,7 @@
1
+ import type {MarkdownItToken, Rule} from 'markdownlint';
2
+
1
3
  // @ts-expect-error
2
4
  import {addErrorDetailIf, filterTokens, forEachInlineCodeSpan} from 'markdownlint-rule-helpers';
3
- import {MarkdownItToken, Rule} from 'markdownlint';
4
5
 
5
6
  export const yfm001: Rule = {
6
7
  names: ['YFM001', 'inline-code-length'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm002: Rule = {
4
4
  names: ['YFM002', 'no-header-found-for-link'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm003: Rule = {
4
4
  names: ['YFM003', 'unreachable-link'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm004: Rule = {
4
4
  names: ['YFM004', 'table-not-closed'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm005: Rule = {
4
4
  names: ['YFM005', 'tab-list-not-closed'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm006: Rule = {
4
4
  names: ['YFM006', 'term-definition-duplicated'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm007: Rule = {
4
4
  names: ['YFM007', 'term-used-without-definition'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm008: Rule = {
4
4
  names: ['YFM008', 'term-inside-definition-not-allowed'],
@@ -1,4 +1,4 @@
1
- import {Rule} from 'markdownlint';
1
+ import type {Rule} from 'markdownlint';
2
2
 
3
3
  export const yfm009: Rule = {
4
4
  names: ['YFM009', 'no-term-definition-in-content'],
@@ -1,11 +1,8 @@
1
1
  import type {Dictionary} from 'lodash';
2
-
3
2
  // eslint-disable-next-line @typescript-eslint/no-redeclare
4
- import {Plugin, Rule} from 'markdownlint';
5
-
6
- import {MarkdownItPreprocessorCb} from '../typings';
7
-
8
- import {LintConfig, PluginOptions} from '.';
3
+ import type {Plugin, Rule} from 'markdownlint';
4
+ import type {MarkdownItPreprocessorCb} from '../typings';
5
+ import type {LintConfig, PluginOptions} from '.';
9
6
 
10
7
  export interface Options {
11
8
  input: string;
@@ -1,10 +1,9 @@
1
1
  import type {Dictionary} from 'lodash';
2
+ import type {LintError} from 'markdownlint';
3
+ import type {LogLevels} from '../log';
2
4
 
3
- import {LintError} from 'markdownlint';
4
5
  import {sep} from 'path';
5
6
 
6
- import {LogLevels} from '../log';
7
-
8
7
  export function errorToString(path: string, error: LintError, sourceMap?: Dictionary<string>) {
9
8
  const ruleMoniker = error.ruleNames
10
9
  ? error.ruleNames.join(sep)
@@ -1,6 +1,6 @@
1
- import {LogLevels} from '../log';
1
+ import type {LintConfig} from '.';
2
2
 
3
- import {LintConfig} from '.';
3
+ import {LogLevels} from '../log';
4
4
 
5
5
  const index: LintConfig = {
6
6
  // Default state for all rules
@@ -1,18 +0,0 @@
1
- export declare class AttrsParser {
2
- #private;
3
- DELIMITER: string;
4
- SEPARATOR: string;
5
- QUOTATION: string;
6
- ALLOWED_CHARS: RegExp;
7
- VALIDATION_CHARS: RegExp;
8
- parse(target: string): Record<string, string[]>;
9
- private extract;
10
- private next;
11
- private type;
12
- private append;
13
- private clear;
14
- private isDelimiter;
15
- private isSeparator;
16
- private isQuotation;
17
- private isAllowedChar;
18
- }