@depup/markdown-it 14.1.1-depup.1 → 14.3.0-depup.13

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 (42) hide show
  1. package/README.md +7 -5
  2. package/changes.json +11 -3
  3. package/dist/index.cjs.js +3661 -5307
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/markdown-it.js +1451 -4445
  6. package/dist/markdown-it.js.map +1 -0
  7. package/dist/markdown-it.min.js +3 -2
  8. package/dist/markdown-it.min.js.map +1 -0
  9. package/lib/common/html_re.mjs +9 -9
  10. package/lib/common/utils.mjs +32 -12
  11. package/lib/index.mjs +1 -1
  12. package/lib/parser_block.mjs +9 -9
  13. package/lib/parser_core.mjs +7 -7
  14. package/lib/parser_inline.mjs +16 -16
  15. package/lib/renderer.mjs +2 -2
  16. package/lib/rules_block/blockquote.mjs +6 -6
  17. package/lib/rules_block/code.mjs +2 -2
  18. package/lib/rules_block/fence.mjs +4 -4
  19. package/lib/rules_block/heading.mjs +8 -8
  20. package/lib/rules_block/hr.mjs +2 -2
  21. package/lib/rules_block/html_block.mjs +18 -7
  22. package/lib/rules_block/lheading.mjs +12 -9
  23. package/lib/rules_block/list.mjs +6 -6
  24. package/lib/rules_block/paragraph.mjs +8 -6
  25. package/lib/rules_block/reference.mjs +1 -1
  26. package/lib/rules_block/state_block.mjs +6 -6
  27. package/lib/rules_block/table.mjs +4 -4
  28. package/lib/rules_core/block.mjs +3 -3
  29. package/lib/rules_core/linkify.mjs +15 -15
  30. package/lib/rules_core/normalize.mjs +2 -2
  31. package/lib/rules_core/smartquotes.mjs +37 -21
  32. package/lib/rules_inline/autolink.mjs +17 -17
  33. package/lib/rules_inline/balance_pairs.mjs +2 -2
  34. package/lib/rules_inline/emphasis.mjs +8 -8
  35. package/lib/rules_inline/entity.mjs +9 -9
  36. package/lib/rules_inline/escape.mjs +15 -1
  37. package/lib/rules_inline/html_inline.mjs +1 -1
  38. package/lib/rules_inline/link.mjs +1 -1
  39. package/lib/rules_inline/state_inline.mjs +39 -8
  40. package/lib/rules_inline/strikethrough.mjs +10 -10
  41. package/lib/token.mjs +12 -12
  42. package/package.json +54 -42
@@ -1,22 +1,22 @@
1
1
  // Regexps to match html elements
2
2
 
3
- const attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*'
3
+ const attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*'
4
4
 
5
- const unquoted = '[^"\'=<>`\\x00-\\x20]+'
5
+ const unquoted = '[^"\'=<>`\\x00-\\x20]+'
6
6
  const single_quoted = "'[^']*'"
7
7
  const double_quoted = '"[^"]*"'
8
8
 
9
- const attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')'
9
+ const attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')'
10
10
 
11
- const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)'
11
+ const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)'
12
12
 
13
- const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'
13
+ const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'
14
14
 
15
- const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'
16
- const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->'
17
- const processing = '<[?][\\s\\S]*?[?]>'
15
+ const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'
16
+ const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->'
17
+ const processing = '<[?][\\s\\S]*?[?]>'
18
18
  const declaration = '<![A-Za-z][^>]*>'
19
- const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'
19
+ const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'
20
20
 
21
21
  const HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
22
22
  '|' + processing + '|' + declaration + '|' + cdata + ')')
@@ -42,7 +42,6 @@ function arrayReplaceAt (src, pos, newElements) {
42
42
  }
43
43
 
44
44
  function isValidEntityCode (c) {
45
- /* eslint no-bitwise:0 */
46
45
  // broken sequence
47
46
  if (c >= 0xD800 && c <= 0xDFFF) { return false }
48
47
  // never used
@@ -70,8 +69,8 @@ function fromCodePoint (c) {
70
69
  return String.fromCharCode(c)
71
70
  }
72
71
 
73
- const UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g
74
- const ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi
72
+ const UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g
73
+ const ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi
75
74
  const UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi')
76
75
 
77
76
  const DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i
@@ -97,12 +96,6 @@ function replaceEntityPattern (match, name) {
97
96
  return match
98
97
  }
99
98
 
100
- /* function replaceEntities(str) {
101
- if (str.indexOf('&') < 0) { return str; }
102
-
103
- return str.replace(ENTITY_RE, replaceEntityPattern);
104
- } */
105
-
106
99
  function unescapeMd (str) {
107
100
  if (str.indexOf('\\') < 0) { return str }
108
101
  return str.replace(UNESCAPE_MD_RE, '$1')
@@ -172,13 +165,15 @@ function isWhiteSpace (code) {
172
165
  return false
173
166
  }
174
167
 
175
- /* eslint-disable max-len */
176
-
177
168
  // Currently without astral characters support.
178
169
  function isPunctChar (ch) {
179
170
  return ucmicro.P.test(ch) || ucmicro.S.test(ch)
180
171
  }
181
172
 
173
+ function isPunctCharCode (code) {
174
+ return isPunctChar(fromCodePoint(code))
175
+ }
176
+
182
177
  // Markdown ASCII punctuation characters.
183
178
  //
184
179
  // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
@@ -240,6 +235,7 @@ function normalizeReference (str) {
240
235
  // (remove this when node v10 is no longer supported).
241
236
  //
242
237
  if ('ẞ'.toLowerCase() === 'Ṿ') {
238
+ /* c8 ignore next 2 */
243
239
  str = str.replace(/ẞ/g, 'ß')
244
240
  }
245
241
 
@@ -278,6 +274,28 @@ function normalizeReference (str) {
278
274
  return str.toLowerCase().toUpperCase()
279
275
  }
280
276
 
277
+ function isAsciiTrimmable (c) {
278
+ return c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d
279
+ }
280
+
281
+ // "Light" .trim() for blocks (headers, paragraphs), where unicode spaces
282
+ // should be preserved.
283
+ function asciiTrim (str) {
284
+ let start = 0
285
+ for (; start < str.length; start++) {
286
+ if (!isAsciiTrimmable(str.charCodeAt(start))) {
287
+ break
288
+ }
289
+ }
290
+ let end = str.length - 1
291
+ for (; end >= start; end--) {
292
+ if (!isAsciiTrimmable(str.charCodeAt(end))) {
293
+ break
294
+ }
295
+ }
296
+ return str.slice(start, end + 1)
297
+ }
298
+
281
299
  // Re-export libraries commonly used in both markdown-it and its plugins,
282
300
  // so plugins won't have to depend on them explicitly, which reduces their
283
301
  // bundled size (e.g. a browser build).
@@ -299,6 +317,8 @@ export {
299
317
  isWhiteSpace,
300
318
  isMdAsciiPunct,
301
319
  isPunctChar,
320
+ isPunctCharCode,
302
321
  escapeRE,
303
- normalizeReference
322
+ normalizeReference,
323
+ asciiTrim
304
324
  }
package/lib/index.mjs CHANGED
@@ -352,7 +352,7 @@ function MarkdownIt (presetName, options) {
352
352
  * ```javascript
353
353
  * var md = require('markdown-it')()
354
354
  * .set({ html: true, breaks: true })
355
- * .set({ typographer, true });
355
+ * .set({ typographer: true });
356
356
  * ```
357
357
  *
358
358
  * __Note:__ To achieve the best possible performance, don't modify a
@@ -22,17 +22,17 @@ import r_paragraph from './rules_block/paragraph.mjs'
22
22
  const _rules = [
23
23
  // First 2 params - rule name & source. Secondary array - list of rules,
24
24
  // which can be terminated by this one.
25
- ['table', r_table, ['paragraph', 'reference']],
26
- ['code', r_code],
27
- ['fence', r_fence, ['paragraph', 'reference', 'blockquote', 'list']],
25
+ ['table', r_table, ['paragraph', 'reference']],
26
+ ['code', r_code],
27
+ ['fence', r_fence, ['paragraph', 'reference', 'blockquote', 'list']],
28
28
  ['blockquote', r_blockquote, ['paragraph', 'reference', 'blockquote', 'list']],
29
- ['hr', r_hr, ['paragraph', 'reference', 'blockquote', 'list']],
30
- ['list', r_list, ['paragraph', 'reference', 'blockquote']],
31
- ['reference', r_reference],
29
+ ['hr', r_hr, ['paragraph', 'reference', 'blockquote', 'list']],
30
+ ['list', r_list, ['paragraph', 'reference', 'blockquote']],
31
+ ['reference', r_reference],
32
32
  ['html_block', r_html_block, ['paragraph', 'reference', 'blockquote']],
33
- ['heading', r_heading, ['paragraph', 'reference', 'blockquote']],
34
- ['lheading', r_lheading],
35
- ['paragraph', r_paragraph]
33
+ ['heading', r_heading, ['paragraph', 'reference', 'blockquote']],
34
+ ['lheading', r_lheading],
35
+ ['paragraph', r_paragraph]
36
36
  ]
37
37
 
38
38
  /**
@@ -17,15 +17,15 @@ import r_smartquotes from './rules_core/smartquotes.mjs'
17
17
  import r_text_join from './rules_core/text_join.mjs'
18
18
 
19
19
  const _rules = [
20
- ['normalize', r_normalize],
21
- ['block', r_block],
22
- ['inline', r_inline],
23
- ['linkify', r_linkify],
24
- ['replacements', r_replacements],
25
- ['smartquotes', r_smartquotes],
20
+ ['normalize', r_normalize],
21
+ ['block', r_block],
22
+ ['inline', r_inline],
23
+ ['linkify', r_linkify],
24
+ ['replacements', r_replacements],
25
+ ['smartquotes', r_smartquotes],
26
26
  // `text_join` finds `text_special` tokens (for escape sequences)
27
27
  // and joins them with the rest of the text
28
- ['text_join', r_text_join]
28
+ ['text_join', r_text_join]
29
29
  ]
30
30
 
31
31
  /**
@@ -26,18 +26,18 @@ import r_fragments_join from './rules_inline/fragments_join.mjs'
26
26
  // Parser rules
27
27
 
28
28
  const _rules = [
29
- ['text', r_text],
30
- ['linkify', r_linkify],
31
- ['newline', r_newline],
32
- ['escape', r_escape],
33
- ['backticks', r_backticks],
34
- ['strikethrough', r_strikethrough.tokenize],
35
- ['emphasis', r_emphasis.tokenize],
36
- ['link', r_link],
37
- ['image', r_image],
38
- ['autolink', r_autolink],
39
- ['html_inline', r_html_inline],
40
- ['entity', r_entity]
29
+ ['text', r_text],
30
+ ['linkify', r_linkify],
31
+ ['newline', r_newline],
32
+ ['escape', r_escape],
33
+ ['backticks', r_backticks],
34
+ ['strikethrough', r_strikethrough.tokenize],
35
+ ['emphasis', r_emphasis.tokenize],
36
+ ['link', r_link],
37
+ ['image', r_image],
38
+ ['autolink', r_autolink],
39
+ ['html_inline', r_html_inline],
40
+ ['entity', r_entity]
41
41
  ]
42
42
 
43
43
  // `rule2` ruleset was created specifically for emphasis/strikethrough
@@ -46,12 +46,12 @@ const _rules = [
46
46
  // Don't use this for anything except pairs (plugins working with `balance_pairs`).
47
47
  //
48
48
  const _rules2 = [
49
- ['balance_pairs', r_balance_pairs],
50
- ['strikethrough', r_strikethrough.postProcess],
51
- ['emphasis', r_emphasis.postProcess],
49
+ ['balance_pairs', r_balance_pairs],
50
+ ['strikethrough', r_strikethrough.postProcess],
51
+ ['emphasis', r_emphasis.postProcess],
52
52
  // rules for pairs separate '**' into its own text tokens, which may be left unused,
53
53
  // rule below merges unused segments back with the rest of the text
54
- ['fragments_join', r_fragments_join]
54
+ ['fragments_join', r_fragments_join]
55
55
  ]
56
56
 
57
57
  /**
package/lib/renderer.mjs CHANGED
@@ -13,7 +13,7 @@ const default_rules = {}
13
13
  default_rules.code_inline = function (tokens, idx, options, env, slf) {
14
14
  const token = tokens[idx]
15
15
 
16
- return '<code' + slf.renderAttrs(token) + '>' +
16
+ return '<code' + slf.renderAttrs(token) + '>' +
17
17
  escapeHtml(token.content) +
18
18
  '</code>'
19
19
  }
@@ -21,7 +21,7 @@ default_rules.code_inline = function (tokens, idx, options, env, slf) {
21
21
  default_rules.code_block = function (tokens, idx, options, env, slf) {
22
22
  const token = tokens[idx]
23
23
 
24
- return '<pre' + slf.renderAttrs(token) + '><code>' +
24
+ return '<pre' + slf.renderAttrs(token) + '><code>' +
25
25
  escapeHtml(tokens[idx].content) +
26
26
  '</code></pre>\n'
27
27
  }
@@ -18,10 +18,10 @@ export default function blockquote (state, startLine, endLine, silent) {
18
18
  // so no point trying to find the end of it in silent mode
19
19
  if (silent) { return true }
20
20
 
21
- const oldBMarks = []
21
+ const oldBMarks = []
22
22
  const oldBSCount = []
23
- const oldSCount = []
24
- const oldTShift = []
23
+ const oldSCount = []
24
+ const oldTShift = []
25
25
 
26
26
  const terminatorRules = state.md.block.ruler.getRules('blockquote')
27
27
 
@@ -181,14 +181,14 @@ export default function blockquote (state, startLine, endLine, silent) {
181
181
  const oldIndent = state.blkIndent
182
182
  state.blkIndent = 0
183
183
 
184
- const token_o = state.push('blockquote_open', 'blockquote', 1)
184
+ const token_o = state.push('blockquote_open', 'blockquote', 1)
185
185
  token_o.markup = '>'
186
186
  const lines = [startLine, 0]
187
- token_o.map = lines
187
+ token_o.map = lines
188
188
 
189
189
  state.md.block.tokenize(state, startLine, nextLine)
190
190
 
191
- const token_c = state.push('blockquote_close', 'blockquote', -1)
191
+ const token_c = state.push('blockquote_close', 'blockquote', -1)
192
192
  token_c.markup = '>'
193
193
 
194
194
  state.lineMax = oldLineMax
@@ -22,9 +22,9 @@ export default function code (state, startLine, endLine/*, silent */) {
22
22
 
23
23
  state.line = last
24
24
 
25
- const token = state.push('code_block', 'code', 0)
25
+ const token = state.push('code_block', 'code', 0)
26
26
  token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n'
27
- token.map = [startLine, state.line]
27
+ token.map = [startLine, state.line]
28
28
 
29
29
  return true
30
30
  }
@@ -84,11 +84,11 @@ export default function fence (state, startLine, endLine, silent) {
84
84
 
85
85
  state.line = nextLine + (haveEndMarker ? 1 : 0)
86
86
 
87
- const token = state.push('fence', 'code', 0)
88
- token.info = params
87
+ const token = state.push('fence', 'code', 0)
88
+ token.info = params
89
89
  token.content = state.getLines(startLine + 1, nextLine, len, true)
90
- token.markup = markup
91
- token.map = [startLine, state.line]
90
+ token.markup = markup
91
+ token.map = [startLine, state.line]
92
92
 
93
93
  return true
94
94
  }
@@ -1,6 +1,6 @@
1
1
  // heading (#, ##, ...)
2
2
 
3
- import { isSpace } from '../common/utils.mjs'
3
+ import { isSpace, asciiTrim } from '../common/utils.mjs'
4
4
 
5
5
  export default function heading (state, startLine, endLine, silent) {
6
6
  let pos = state.bMarks[startLine] + state.tShift[startLine]
@@ -9,7 +9,7 @@ export default function heading (state, startLine, endLine, silent) {
9
9
  // if it's indented more than 3 spaces, it should be a code block
10
10
  if (state.sCount[startLine] - state.blkIndent >= 4) { return false }
11
11
 
12
- let ch = state.src.charCodeAt(pos)
12
+ let ch = state.src.charCodeAt(pos)
13
13
 
14
14
  if (ch !== 0x23/* # */ || pos >= max) { return false }
15
15
 
@@ -35,16 +35,16 @@ export default function heading (state, startLine, endLine, silent) {
35
35
 
36
36
  state.line = startLine + 1
37
37
 
38
- const token_o = state.push('heading_open', 'h' + String(level), 1)
38
+ const token_o = state.push('heading_open', 'h' + String(level), 1)
39
39
  token_o.markup = '########'.slice(0, level)
40
- token_o.map = [startLine, state.line]
40
+ token_o.map = [startLine, state.line]
41
41
 
42
- const token_i = state.push('inline', '', 0)
43
- token_i.content = state.src.slice(pos, max).trim()
44
- token_i.map = [startLine, state.line]
42
+ const token_i = state.push('inline', '', 0)
43
+ token_i.content = asciiTrim(state.src.slice(pos, max))
44
+ token_i.map = [startLine, state.line]
45
45
  token_i.children = []
46
46
 
47
- const token_c = state.push('heading_close', 'h' + String(level), -1)
47
+ const token_c = state.push('heading_close', 'h' + String(level), -1)
48
48
  token_c.markup = '########'.slice(0, level)
49
49
 
50
50
  return true
@@ -32,8 +32,8 @@ export default function hr (state, startLine, endLine, silent) {
32
32
 
33
33
  state.line = startLine + 1
34
34
 
35
- const token = state.push('hr', 'hr', 0)
36
- token.map = [startLine, state.line]
35
+ const token = state.push('hr', 'hr', 0)
36
+ token.map = [startLine, state.line]
37
37
  token.markup = Array(cnt + 1).join(String.fromCharCode(marker))
38
38
 
39
39
  return true
@@ -8,12 +8,12 @@ import { HTML_OPEN_CLOSE_TAG_RE } from '../common/html_re.mjs'
8
8
  //
9
9
  const HTML_SEQUENCES = [
10
10
  [/^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true],
11
- [/^<!--/, /-->/, true],
12
- [/^<\?/, /\?>/, true],
13
- [/^<![A-Z]/, />/, true],
11
+ [/^<!--/, /-->/, true],
12
+ [/^<\?/, /\?>/, true],
13
+ [/^<![A-Z]/, />/, true],
14
14
  [/^<!\[CDATA\[/, /\]\]>/, true],
15
15
  [new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true],
16
- [new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false]
16
+ [new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false]
17
17
  ]
18
18
 
19
19
  export default function html_block (state, startLine, endLine, silent) {
@@ -42,11 +42,22 @@ export default function html_block (state, startLine, endLine, silent) {
42
42
 
43
43
  let nextLine = startLine + 1
44
44
 
45
+ // Block types 6 and 7 (the only ones whose end condition is a blank line)
46
+ // have `/^$/` as their closing regexp. For all other types (1-5, e.g.
47
+ // `<!--` comments), a blank line is regular content and must not terminate
48
+ // the block - it ends only when its closing sequence is found.
49
+ const endsOnBlankLine = HTML_SEQUENCES[i][1].test('')
50
+
45
51
  // If we are here - we detected HTML block.
46
52
  // Let's roll down till block end.
47
53
  if (!HTML_SEQUENCES[i][1].test(lineText)) {
48
54
  for (; nextLine < endLine; nextLine++) {
49
- if (state.sCount[nextLine] < state.blkIndent) { break }
55
+ if (state.sCount[nextLine] < state.blkIndent) {
56
+ // An outdented blank line shouldn't end a block that doesn't end on a
57
+ // blank line (e.g. a `<!--` comment inside a list item). Such blocks
58
+ // must continue until their closing sequence regardless of indent.
59
+ if (endsOnBlankLine || !state.isEmpty(nextLine)) { break }
60
+ }
50
61
 
51
62
  pos = state.bMarks[nextLine] + state.tShift[nextLine]
52
63
  max = state.eMarks[nextLine]
@@ -61,8 +72,8 @@ export default function html_block (state, startLine, endLine, silent) {
61
72
 
62
73
  state.line = nextLine
63
74
 
64
- const token = state.push('html_block', '', 0)
65
- token.map = [startLine, nextLine]
75
+ const token = state.push('html_block', '', 0)
76
+ token.map = [startLine, nextLine]
66
77
  token.content = state.getLines(startLine, nextLine, state.blkIndent, true)
67
78
 
68
79
  return true
@@ -1,5 +1,7 @@
1
1
  // lheading (---, ===)
2
2
 
3
+ import { asciiTrim } from '../common/utils.mjs'
4
+
3
5
  export default function lheading (state, startLine, endLine/*, silent */) {
4
6
  const terminatorRules = state.md.block.ruler.getRules('paragraph')
5
7
 
@@ -57,24 +59,25 @@ export default function lheading (state, startLine, endLine/*, silent */) {
57
59
 
58
60
  if (!level) {
59
61
  // Didn't find valid underline
62
+ state.parentType = oldParentType
60
63
  return false
61
64
  }
62
65
 
63
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim()
66
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false))
64
67
 
65
68
  state.line = nextLine + 1
66
69
 
67
- const token_o = state.push('heading_open', 'h' + String(level), 1)
68
- token_o.markup = String.fromCharCode(marker)
69
- token_o.map = [startLine, state.line]
70
+ const token_o = state.push('heading_open', 'h' + String(level), 1)
71
+ token_o.markup = String.fromCharCode(marker)
72
+ token_o.map = [startLine, state.line]
70
73
 
71
- const token_i = state.push('inline', '', 0)
72
- token_i.content = content
73
- token_i.map = [startLine, state.line - 1]
74
+ const token_i = state.push('inline', '', 0)
75
+ token_i.content = content
76
+ token_i.map = [startLine, state.line - 1]
74
77
  token_i.children = []
75
78
 
76
- const token_c = state.push('heading_close', 'h' + String(level), -1)
77
- token_c.markup = String.fromCharCode(marker)
79
+ const token_c = state.push('heading_close', 'h' + String(level), -1)
80
+ token_c.markup = String.fromCharCode(marker)
78
81
 
79
82
  state.parentType = oldParentType
80
83
 
@@ -156,16 +156,16 @@ export default function list (state, startLine, endLine, silent) {
156
156
  const listTokIdx = state.tokens.length
157
157
 
158
158
  if (isOrdered) {
159
- token = state.push('ordered_list_open', 'ol', 1)
159
+ token = state.push('ordered_list_open', 'ol', 1)
160
160
  if (markerValue !== 1) {
161
161
  token.attrs = [['start', markerValue]]
162
162
  }
163
163
  } else {
164
- token = state.push('bullet_list_open', 'ul', 1)
164
+ token = state.push('bullet_list_open', 'ul', 1)
165
165
  }
166
166
 
167
167
  const listLines = [nextLine, 0]
168
- token.map = listLines
168
+ token.map = listLines
169
169
  token.markup = String.fromCharCode(markerCharCode)
170
170
 
171
171
  //
@@ -218,10 +218,10 @@ export default function list (state, startLine, endLine, silent) {
218
218
  const indent = initial + indentAfterMarker
219
219
 
220
220
  // Run subparser & write tokens
221
- token = state.push('list_item_open', 'li', 1)
221
+ token = state.push('list_item_open', 'li', 1)
222
222
  token.markup = String.fromCharCode(markerCharCode)
223
223
  const itemLines = [nextLine, 0]
224
- token.map = itemLines
224
+ token.map = itemLines
225
225
  if (isOrdered) {
226
226
  token.info = state.src.slice(start, posAfterMarker - 1)
227
227
  }
@@ -270,7 +270,7 @@ export default function list (state, startLine, endLine, silent) {
270
270
  state.sCount[nextLine] = oldSCount
271
271
  state.tight = oldTight
272
272
 
273
- token = state.push('list_item_close', 'li', -1)
273
+ token = state.push('list_item_close', 'li', -1)
274
274
  token.markup = String.fromCharCode(markerCharCode)
275
275
 
276
276
  nextLine = state.line
@@ -1,5 +1,7 @@
1
1
  // Paragraph
2
2
 
3
+ import { asciiTrim } from '../common/utils.mjs'
4
+
3
5
  export default function paragraph (state, startLine, endLine) {
4
6
  const terminatorRules = state.md.block.ruler.getRules('paragraph')
5
7
  const oldParentType = state.parentType
@@ -26,16 +28,16 @@ export default function paragraph (state, startLine, endLine) {
26
28
  if (terminate) { break }
27
29
  }
28
30
 
29
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim()
31
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false))
30
32
 
31
33
  state.line = nextLine
32
34
 
33
- const token_o = state.push('paragraph_open', 'p', 1)
34
- token_o.map = [startLine, state.line]
35
+ const token_o = state.push('paragraph_open', 'p', 1)
36
+ token_o.map = [startLine, state.line]
35
37
 
36
- const token_i = state.push('inline', '', 0)
37
- token_i.content = content
38
- token_i.map = [startLine, state.line]
38
+ const token_i = state.push('inline', '', 0)
39
+ token_i.content = content
40
+ token_i.map = [startLine, state.line]
39
41
  token_i.children = []
40
42
 
41
43
  state.push('paragraph_close', 'p', -1)
@@ -134,7 +134,7 @@ export default function reference (state, startLine, _endLine, silent) {
134
134
  nextLine++
135
135
  }
136
136
  } else if (isSpace(ch)) {
137
- /* eslint no-empty:0 */
137
+ /* Nothing */
138
138
  } else {
139
139
  break
140
140
  }
@@ -7,7 +7,7 @@ function StateBlock (src, md, env, tokens) {
7
7
  this.src = src
8
8
 
9
9
  // link to parser instance
10
- this.md = md
10
+ this.md = md
11
11
 
12
12
  this.env = env
13
13
 
@@ -38,11 +38,11 @@ function StateBlock (src, md, env, tokens) {
38
38
 
39
39
  // required block content indent (for example, if we are
40
40
  // inside a list, it would be positioned after list marker)
41
- this.blkIndent = 0
42
- this.line = 0 // line index in src
43
- this.lineMax = 0 // lines count
44
- this.tight = false // loose/tight mode for lists
45
- this.ddIndent = -1 // indent of the current dd block (-1 if there isn't any)
41
+ this.blkIndent = 0
42
+ this.line = 0 // line index in src
43
+ this.lineMax = 0 // lines count
44
+ this.tight = false // loose/tight mode for lists
45
+ this.ddIndent = -1 // indent of the current dd block (-1 if there isn't any)
46
46
  this.listIndent = -1 // indent of the current list block (-1 if there isn't any)
47
47
 
48
48
  // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
@@ -151,11 +151,11 @@ export default function table (state, startLine, endLine, silent) {
151
151
  for (let i = 0; i < columns.length; i++) {
152
152
  const token_ho = state.push('th_open', 'th', 1)
153
153
  if (aligns[i]) {
154
- token_ho.attrs = [['style', 'text-align:' + aligns[i]]]
154
+ token_ho.attrs = [['style', 'text-align:' + aligns[i]]]
155
155
  }
156
156
 
157
157
  const token_il = state.push('inline', '', 0)
158
- token_il.content = columns[i].trim()
158
+ token_il.content = columns[i].trim()
159
159
  token_il.children = []
160
160
 
161
161
  state.push('th_close', 'th', -1)
@@ -202,11 +202,11 @@ export default function table (state, startLine, endLine, silent) {
202
202
  for (let i = 0; i < columnCount; i++) {
203
203
  const token_tdo = state.push('td_open', 'td', 1)
204
204
  if (aligns[i]) {
205
- token_tdo.attrs = [['style', 'text-align:' + aligns[i]]]
205
+ token_tdo.attrs = [['style', 'text-align:' + aligns[i]]]
206
206
  }
207
207
 
208
208
  const token_il = state.push('inline', '', 0)
209
- token_il.content = columns[i] ? columns[i].trim() : ''
209
+ token_il.content = columns[i] ? columns[i].trim() : ''
210
210
  token_il.children = []
211
211
 
212
212
  state.push('td_close', 'td', -1)
@@ -2,9 +2,9 @@ export default function block (state) {
2
2
  let token
3
3
 
4
4
  if (state.inlineMode) {
5
- token = new state.Token('inline', '', 0)
6
- token.content = state.src
7
- token.map = [0, 1]
5
+ token = new state.Token('inline', '', 0)
6
+ token.content = state.src
7
+ token.map = [0, 1]
8
8
  token.children = []
9
9
  state.tokens.push(token)
10
10
  } else {