@diplodoc/transform 4.57.7 → 4.58.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/dist/css/_yfm-only.css.map +1 -1
- package/dist/css/_yfm-only.min.css.map +1 -1
- 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.map +1 -1
- package/dist/css/yfm.min.css.map +1 -1
- package/lib/constants.d.ts +1 -1
- package/lib/headings.d.ts +2 -2
- package/lib/headings.js.map +1 -1
- package/lib/highlight.d.ts +1 -1
- package/lib/highlight.js.map +1 -1
- package/lib/liquid/conditions.js.map +1 -1
- package/lib/liquid/index.d.ts +1 -1
- package/lib/liquid/index.js.map +1 -1
- package/lib/plugins/anchors/collect.d.ts +1 -1
- package/lib/plugins/anchors/collect.js.map +1 -1
- package/lib/plugins/anchors/constants.d.ts +1 -1
- package/lib/plugins/anchors/index.d.ts +1 -1
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/plugins/block-anchor/block-anchor.d.ts +2 -2
- package/lib/plugins/block-anchor/index.d.ts +1 -1
- package/lib/plugins/changelog/collect.d.ts +2 -2
- package/lib/plugins/changelog/collect.js.map +1 -1
- package/lib/plugins/changelog/index.d.ts +1 -1
- package/lib/plugins/changelog/index.js.map +1 -1
- package/lib/plugins/checkbox/index.d.ts +1 -1
- package/lib/plugins/checkbox/index.js.map +1 -1
- package/lib/plugins/code.d.ts +1 -1
- package/lib/plugins/code.js +1 -1
- package/lib/plugins/code.js.map +1 -1
- package/lib/plugins/deflist.d.ts +1 -1
- package/lib/plugins/deflist.js.map +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.map +1 -1
- package/lib/plugins/imsize/index.d.ts +2 -2
- package/lib/plugins/imsize/index.js.map +1 -1
- package/lib/plugins/includes/collect.d.ts +1 -1
- package/lib/plugins/includes/collect.js.map +1 -1
- package/lib/plugins/includes/index.d.ts +2 -2
- package/lib/plugins/includes/index.js +1 -1
- package/lib/plugins/includes/index.js.map +1 -1
- package/lib/plugins/includes/types.d.ts +2 -2
- package/lib/plugins/links/index.d.ts +4 -4
- package/lib/plugins/links/index.js.map +1 -1
- package/lib/plugins/meta.d.ts +1 -1
- package/lib/plugins/meta.js.map +1 -1
- package/lib/plugins/monospace.d.ts +1 -1
- package/lib/plugins/notes/constants.d.ts +1 -1
- package/lib/plugins/notes/index.d.ts +1 -1
- package/lib/plugins/notes/index.js.map +1 -1
- package/lib/plugins/ol-attr-conversion.d.ts +1 -1
- package/lib/plugins/sup.d.ts +1 -1
- package/lib/plugins/sup.js.map +1 -1
- package/lib/plugins/table/index.d.ts +3 -2
- package/lib/plugins/table/index.js +152 -28
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/types.d.ts +34 -0
- package/lib/plugins/table/types.js +3 -0
- package/lib/plugins/table/types.js.map +1 -0
- package/lib/plugins/term/index.d.ts +1 -1
- package/lib/plugins/term/termDefinitions.d.ts +3 -3
- package/lib/plugins/term/termDefinitions.js.map +1 -1
- package/lib/plugins/utils.d.ts +2 -2
- package/lib/plugins/utils.js.map +1 -1
- package/lib/preprocessors/included/index.d.ts +1 -1
- package/lib/preprocessors/included/index.js.map +1 -1
- package/lib/sanitize.d.ts +1 -1
- package/lib/sanitize.js.map +1 -1
- package/lib/title.d.ts +1 -1
- package/lib/typings.d.ts +7 -6
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js.map +1 -1
- package/lib/utilsFS.d.ts +1 -1
- package/lib/utilsFS.js.map +1 -1
- package/lib/yfmlint/index.d.ts +3 -3
- package/lib/yfmlint/index.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm001.js.map +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm002.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm003.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm004.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm005.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm006.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm007.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm008.d.ts +1 -1
- package/lib/yfmlint/markdownlint-custom-rule/yfm009.d.ts +1 -1
- package/lib/yfmlint/typings.d.ts +3 -3
- package/lib/yfmlint/utils.d.ts +2 -2
- package/lib/yfmlint/utils.js.map +1 -1
- package/lib/yfmlint/yfmlint.d.ts +1 -1
- package/lib/yfmlint/yfmlint.js.map +1 -1
- package/package.json +2 -1
- package/src/transform/constants.ts +1 -1
- package/src/transform/headings.ts +2 -3
- package/src/transform/highlight.ts +2 -2
- package/src/transform/liquid/conditions.ts +3 -1
- package/src/transform/liquid/index.ts +2 -1
- package/src/transform/plugins/anchors/collect.ts +2 -1
- package/src/transform/plugins/anchors/constants.ts +1 -1
- package/src/transform/plugins/anchors/index.ts +4 -3
- package/src/transform/plugins/block-anchor/block-anchor.ts +2 -2
- package/src/transform/plugins/block-anchor/index.ts +1 -1
- package/src/transform/plugins/changelog/collect.ts +3 -3
- package/src/transform/plugins/changelog/index.ts +5 -5
- package/src/transform/plugins/checkbox/index.ts +2 -1
- package/src/transform/plugins/code.ts +3 -2
- package/src/transform/plugins/deflist.ts +2 -2
- package/src/transform/plugins/images/collect.ts +2 -1
- package/src/transform/plugins/images/index.ts +4 -3
- package/src/transform/plugins/imsize/index.ts +3 -2
- package/src/transform/plugins/includes/collect.ts +2 -2
- package/src/transform/plugins/includes/index.ts +8 -13
- package/src/transform/plugins/includes/types.ts +2 -2
- package/src/transform/plugins/links/index.ts +6 -6
- package/src/transform/plugins/meta.ts +2 -2
- package/src/transform/plugins/monospace.ts +3 -3
- package/src/transform/plugins/notes/constants.ts +1 -1
- package/src/transform/plugins/notes/index.ts +6 -4
- package/src/transform/plugins/ol-attr-conversion.ts +1 -1
- package/src/transform/plugins/sup.ts +2 -2
- package/src/transform/plugins/table/index.ts +190 -31
- package/src/transform/plugins/table/types.ts +35 -0
- package/src/transform/plugins/term/index.ts +3 -3
- package/src/transform/plugins/term/termDefinitions.ts +3 -4
- package/src/transform/plugins/utils.ts +3 -3
- package/src/transform/plugins/video/parsers.ts +2 -2
- package/src/transform/preprocessors/included/index.ts +3 -2
- package/src/transform/sanitize.ts +4 -2
- package/src/transform/title.ts +1 -1
- package/src/transform/typings.ts +7 -7
- package/src/transform/utils.ts +2 -1
- package/src/transform/utilsFS.ts +1 -1
- package/src/transform/yfmlint/index.ts +4 -3
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm001.ts +2 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm002.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm003.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm004.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm005.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm006.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm007.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm008.ts +1 -1
- package/src/transform/yfmlint/markdownlint-custom-rule/yfm009.ts +1 -1
- package/src/transform/yfmlint/typings.ts +3 -6
- package/src/transform/yfmlint/utils.ts +2 -3
- package/src/transform/yfmlint/yfmlint.ts +2 -2
- package/lib/plugins/table/attrs.d.ts +0 -18
- package/lib/plugins/table/attrs.js +0 -172
- package/lib/plugins/table/attrs.js.map +0 -1
- 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 {
|
|
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
|
|
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
|
-
|
|
62
|
-
|
|
179
|
+
private _pos: number;
|
|
180
|
+
private _line: number;
|
|
181
|
+
private _lineEnds: number;
|
|
63
182
|
|
|
64
183
|
private state: StateBlock;
|
|
65
|
-
|
|
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.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
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.
|
|
77
|
-
pos: this.
|
|
206
|
+
line: this._line,
|
|
207
|
+
pos: this._pos,
|
|
78
208
|
};
|
|
79
209
|
}
|
|
80
210
|
|
|
81
211
|
get symbol() {
|
|
82
|
-
return this.state.src[this.
|
|
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.
|
|
217
|
+
this._pos++;
|
|
88
218
|
|
|
89
|
-
if (this.
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
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
|
|
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 (
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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 {
|
|
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
|
|
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 = (
|
package/src/transform/title.ts
CHANGED
package/src/transform/typings.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {LanguageFn} from 'highlight.js';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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[];
|
package/src/transform/utils.ts
CHANGED
package/src/transform/utilsFS.ts
CHANGED
|
@@ -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 {
|
|
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,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 {
|
|
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,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
|
-
}
|