Browse Source

standard: no spaces near array brackets

pull/979/head
Vitaly Puzrin 1 year ago
parent
commit
7dfcf69b71
  1. 2
      .eslintrc.yml
  2. 2
      benchmark/benchmark.mjs
  3. 12
      lib/index.mjs
  4. 22
      lib/parser_block.mjs
  5. 14
      lib/parser_core.mjs
  6. 32
      lib/parser_inline.mjs
  7. 2
      lib/renderer.mjs
  8. 8
      lib/ruler.mjs
  9. 2
      lib/rules_block/blockquote.mjs
  10. 2
      lib/rules_block/code.mjs
  11. 2
      lib/rules_block/fence.mjs
  12. 4
      lib/rules_block/heading.mjs
  13. 2
      lib/rules_block/hr.mjs
  14. 16
      lib/rules_block/html_block.mjs
  15. 4
      lib/rules_block/lheading.mjs
  16. 6
      lib/rules_block/list.mjs
  17. 4
      lib/rules_block/paragraph.mjs
  18. 14
      lib/rules_block/table.mjs
  19. 2
      lib/rules_core/block.mjs
  20. 2
      lib/rules_core/linkify.mjs
  21. 4
      lib/rules_inline/autolink.mjs
  22. 2
      lib/rules_inline/balance_pairs.mjs
  23. 4
      lib/rules_inline/image.mjs
  24. 4
      lib/rules_inline/link.mjs
  25. 2
      lib/rules_inline/linkify.mjs
  26. 6
      lib/token.mjs
  27. 2
      support/demo_template/index.mjs
  28. 2
      support/specsplit.mjs
  29. 2
      test/babelmark-responder.mjs
  30. 18
      test/misc.mjs
  31. 8
      test/ruler.mjs
  32. 4
      test/token.mjs

2
.eslintrc.yml

@ -25,7 +25,7 @@ rules:
prefer-const: 2 prefer-const: 2
no-const-assign: 2 no-const-assign: 2
accessor-pairs: 2 accessor-pairs: 2
array-bracket-spacing: [ 2, "always", { "singleValue": true, "objectsInArrays": true, "arraysInArrays": true } ] array-bracket-spacing: [ 2, never ]
block-scoped-var: 2 block-scoped-var: 2
block-spacing: 2 block-spacing: 2
brace-style: [ 2, '1tbs', { allowSingleLine: true } ] brace-style: [ 2, '1tbs', { allowSingleLine: true } ]

2
benchmark/benchmark.mjs

@ -71,7 +71,7 @@ function select (patterns) {
const result = [] const result = []
if (!(patterns instanceof Array)) { if (!(patterns instanceof Array)) {
patterns = [ patterns ] patterns = [patterns]
} }
function checkName (name) { function checkName (name) {

12
lib/index.mjs

@ -42,7 +42,7 @@ function validateLink (url) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ] const RECODE_HOSTNAME_FOR = ['http:', 'https:', 'mailto:']
function normalizeLink (url) { function normalizeLink (url) {
const parsed = mdurl.parse(url, true) const parsed = mdurl.parse(url, true)
@ -431,9 +431,9 @@ MarkdownIt.prototype.configure = function (presets) {
MarkdownIt.prototype.enable = function (list, ignoreInvalid) { MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
let result = [] let result = []
if (!Array.isArray(list)) { list = [ list ] } if (!Array.isArray(list)) { list = [list] }
[ 'core', 'block', 'inline' ].forEach(function (chain) { ['core', 'block', 'inline'].forEach(function (chain) {
result = result.concat(this[chain].ruler.enable(list, true)) result = result.concat(this[chain].ruler.enable(list, true))
}, this) }, this)
@ -459,9 +459,9 @@ MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
MarkdownIt.prototype.disable = function (list, ignoreInvalid) { MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
let result = [] let result = []
if (!Array.isArray(list)) { list = [ list ] } if (!Array.isArray(list)) { list = [list] }
[ 'core', 'block', 'inline' ].forEach(function (chain) { ['core', 'block', 'inline'].forEach(function (chain) {
result = result.concat(this[chain].ruler.disable(list, true)) result = result.concat(this[chain].ruler.disable(list, true))
}, this) }, this)
@ -493,7 +493,7 @@ MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
* ``` * ```
**/ **/
MarkdownIt.prototype.use = function (plugin /*, params, ... */) { MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
const args = [ this ].concat(Array.prototype.slice.call(arguments, 1)) const args = [this].concat(Array.prototype.slice.call(arguments, 1))
plugin.apply(plugin, args) plugin.apply(plugin, args)
return this return this
} }

22
lib/parser_block.mjs

@ -22,17 +22,17 @@ import r_paragraph from './rules_block/paragraph.mjs'
const _rules = [ const _rules = [
// First 2 params - rule name & source. Secondary array - list of rules, // First 2 params - rule name & source. Secondary array - list of rules,
// which can be terminated by this one. // which can be terminated by this one.
[ 'table', r_table, [ 'paragraph', 'reference' ] ], ['table', r_table, ['paragraph', 'reference']],
[ 'code', r_code ], ['code', r_code],
[ 'fence', r_fence, [ 'paragraph', 'reference', 'blockquote', 'list' ] ], ['fence', r_fence, ['paragraph', 'reference', 'blockquote', 'list']],
[ 'blockquote', r_blockquote, [ 'paragraph', 'reference', 'blockquote', 'list' ] ], ['blockquote', r_blockquote, ['paragraph', 'reference', 'blockquote', 'list']],
[ 'hr', r_hr, [ 'paragraph', 'reference', 'blockquote', 'list' ] ], ['hr', r_hr, ['paragraph', 'reference', 'blockquote', 'list']],
[ 'list', r_list, [ 'paragraph', 'reference', 'blockquote' ] ], ['list', r_list, ['paragraph', 'reference', 'blockquote']],
[ 'reference', r_reference ], ['reference', r_reference],
[ 'html_block', r_html_block, [ 'paragraph', 'reference', 'blockquote' ] ], ['html_block', r_html_block, ['paragraph', 'reference', 'blockquote']],
[ 'heading', r_heading, [ 'paragraph', 'reference', 'blockquote' ] ], ['heading', r_heading, ['paragraph', 'reference', 'blockquote']],
[ 'lheading', r_lheading ], ['lheading', r_lheading],
[ 'paragraph', r_paragraph ] ['paragraph', r_paragraph]
] ]

14
lib/parser_core.mjs

@ -18,15 +18,15 @@ import r_text_join from './rules_core/text_join.mjs'
const _rules = [ const _rules = [
[ 'normalize', r_normalize ], ['normalize', r_normalize],
[ 'block', r_block ], ['block', r_block],
[ 'inline', r_inline ], ['inline', r_inline],
[ 'linkify', r_linkify ], ['linkify', r_linkify],
[ 'replacements', r_replacements ], ['replacements', r_replacements],
[ 'smartquotes', r_smartquotes ], ['smartquotes', r_smartquotes],
// `text_join` finds `text_special` tokens (for escape sequences) // `text_join` finds `text_special` tokens (for escape sequences)
// and joins them with the rest of the text // and joins them with the rest of the text
[ 'text_join', r_text_join ] ['text_join', r_text_join]
] ]

32
lib/parser_inline.mjs

@ -29,18 +29,18 @@ import r_fragments_join from './rules_inline/fragments_join.mjs'
// Parser rules // Parser rules
const _rules = [ const _rules = [
[ 'text', r_text ], ['text', r_text],
[ 'linkify', r_linkify ], ['linkify', r_linkify],
[ 'newline', r_newline ], ['newline', r_newline],
[ 'escape', r_escape ], ['escape', r_escape],
[ 'backticks', r_backticks ], ['backticks', r_backticks],
[ 'strikethrough', r_strikethrough.tokenize ], ['strikethrough', r_strikethrough.tokenize],
[ 'emphasis', r_emphasis.tokenize ], ['emphasis', r_emphasis.tokenize],
[ 'link', r_link ], ['link', r_link],
[ 'image', r_image ], ['image', r_image],
[ 'autolink', r_autolink ], ['autolink', r_autolink],
[ 'html_inline', r_html_inline ], ['html_inline', r_html_inline],
[ 'entity', r_entity ] ['entity', r_entity]
] ]
// `rule2` ruleset was created specifically for emphasis/strikethrough // `rule2` ruleset was created specifically for emphasis/strikethrough
@ -49,12 +49,12 @@ const _rules = [
// Don't use this for anything except pairs (plugins working with `balance_pairs`). // Don't use this for anything except pairs (plugins working with `balance_pairs`).
// //
const _rules2 = [ const _rules2 = [
[ 'balance_pairs', r_balance_pairs ], ['balance_pairs', r_balance_pairs],
[ 'strikethrough', r_strikethrough.postProcess ], ['strikethrough', r_strikethrough.postProcess],
[ 'emphasis', r_emphasis.postProcess ], ['emphasis', r_emphasis.postProcess],
// rules for pairs separate '**' into its own text tokens, which may be left unused, // rules for pairs separate '**' into its own text tokens, which may be left unused,
// rule below merges unused segments back with the rest of the text // rule below merges unused segments back with the rest of the text
[ 'fragments_join', r_fragments_join ] ['fragments_join', r_fragments_join]
] ]

2
lib/renderer.mjs

@ -62,7 +62,7 @@ default_rules.fence = function (tokens, idx, options, env, slf) {
const tmpAttrs = token.attrs ? token.attrs.slice() : [] const tmpAttrs = token.attrs ? token.attrs.slice() : []
if (i < 0) { if (i < 0) {
tmpAttrs.push([ 'class', options.langPrefix + langName ]) tmpAttrs.push(['class', options.langPrefix + langName])
} else { } else {
tmpAttrs[i] = tmpAttrs[i].slice() tmpAttrs[i] = tmpAttrs[i].slice()
tmpAttrs[i][1] += ' ' + options.langPrefix + langName tmpAttrs[i][1] += ' ' + options.langPrefix + langName

8
lib/ruler.mjs

@ -60,7 +60,7 @@ Ruler.prototype.__find__ = function (name) {
// //
Ruler.prototype.__compile__ = function () { Ruler.prototype.__compile__ = function () {
const self = this const self = this
const chains = [ '' ] const chains = ['']
// collect unique names // collect unique names
self.__rules__.forEach(function (rule) { self.__rules__.forEach(function (rule) {
@ -256,7 +256,7 @@ Ruler.prototype.push = function (ruleName, fn, options) {
* See also [[Ruler.disable]], [[Ruler.enableOnly]]. * See also [[Ruler.disable]], [[Ruler.enableOnly]].
**/ **/
Ruler.prototype.enable = function (list, ignoreInvalid) { Ruler.prototype.enable = function (list, ignoreInvalid) {
if (!Array.isArray(list)) { list = [ list ] } if (!Array.isArray(list)) { list = [list] }
const result = [] const result = []
@ -288,7 +288,7 @@ Ruler.prototype.enable = function (list, ignoreInvalid) {
* See also [[Ruler.disable]], [[Ruler.enable]]. * See also [[Ruler.disable]], [[Ruler.enable]].
**/ **/
Ruler.prototype.enableOnly = function (list, ignoreInvalid) { Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
if (!Array.isArray(list)) { list = [ list ] } if (!Array.isArray(list)) { list = [list] }
this.__rules__.forEach(function (rule) { rule.enabled = false }) this.__rules__.forEach(function (rule) { rule.enabled = false })
@ -309,7 +309,7 @@ Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
* See also [[Ruler.enable]], [[Ruler.enableOnly]]. * See also [[Ruler.enable]], [[Ruler.enableOnly]].
**/ **/
Ruler.prototype.disable = function (list, ignoreInvalid) { Ruler.prototype.disable = function (list, ignoreInvalid) {
if (!Array.isArray(list)) { list = [ list ] } if (!Array.isArray(list)) { list = [list] }
const result = [] const result = []

2
lib/rules_block/blockquote.mjs

@ -183,7 +183,7 @@ export default function blockquote (state, startLine, endLine, silent) {
const token_o = state.push('blockquote_open', 'blockquote', 1) const token_o = state.push('blockquote_open', 'blockquote', 1)
token_o.markup = '>' token_o.markup = '>'
const lines = [ startLine, 0 ] const lines = [startLine, 0]
token_o.map = lines token_o.map = lines
state.md.block.tokenize(state, startLine, nextLine) state.md.block.tokenize(state, startLine, nextLine)

2
lib/rules_block/code.mjs

@ -24,7 +24,7 @@ export default function code (state, startLine, endLine/*, silent*/) {
const token = state.push('code_block', 'code', 0) const token = state.push('code_block', 'code', 0)
token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n' token.content = state.getLines(startLine, last, 4 + state.blkIndent, false) + '\n'
token.map = [ startLine, state.line ] token.map = [startLine, state.line]
return true return true
} }

2
lib/rules_block/fence.mjs

@ -88,7 +88,7 @@ export default function fence (state, startLine, endLine, silent) {
token.info = params token.info = params
token.content = state.getLines(startLine + 1, nextLine, len, true) token.content = state.getLines(startLine + 1, nextLine, len, true)
token.markup = markup token.markup = markup
token.map = [ startLine, state.line ] token.map = [startLine, state.line]
return true return true
} }

4
lib/rules_block/heading.mjs

@ -37,11 +37,11 @@ export default function heading (state, startLine, endLine, silent) {
const token_o = state.push('heading_open', 'h' + String(level), 1) const token_o = state.push('heading_open', 'h' + String(level), 1)
token_o.markup = '########'.slice(0, level) token_o.markup = '########'.slice(0, level)
token_o.map = [ startLine, state.line ] token_o.map = [startLine, state.line]
const token_i = state.push('inline', '', 0) const token_i = state.push('inline', '', 0)
token_i.content = state.src.slice(pos, max).trim() token_i.content = state.src.slice(pos, max).trim()
token_i.map = [ startLine, state.line ] token_i.map = [startLine, state.line]
token_i.children = [] token_i.children = []
const token_c = state.push('heading_close', 'h' + String(level), -1) const token_c = state.push('heading_close', 'h' + String(level), -1)

2
lib/rules_block/hr.mjs

@ -33,7 +33,7 @@ export default function hr (state, startLine, endLine, silent) {
state.line = startLine + 1 state.line = startLine + 1
const token = state.push('hr', 'hr', 0) const token = state.push('hr', 'hr', 0)
token.map = [ startLine, state.line ] token.map = [startLine, state.line]
token.markup = Array(cnt + 1).join(String.fromCharCode(marker)) token.markup = Array(cnt + 1).join(String.fromCharCode(marker))
return true return true

16
lib/rules_block/html_block.mjs

@ -7,13 +7,13 @@ import { HTML_OPEN_CLOSE_TAG_RE } from '../common/html_re.mjs'
// last argument defines whether it can terminate a paragraph or not // last argument defines whether it can terminate a paragraph or not
// //
const HTML_SEQUENCES = [ const HTML_SEQUENCES = [
[ /^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true ], [/^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true],
[ /^<!--/, /-->/, true ], [/^<!--/, /-->/, true],
[ /^<\?/, /\?>/, true ], [/^<\?/, /\?>/, true],
[ /^<![A-Z]/, />/, true ], [/^<![A-Z]/, />/, true],
[ /^<!\[CDATA\[/, /\]\]>/, true ], [/^<!\[CDATA\[/, /\]\]>/, true],
[ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ], [new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true],
[ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ] [new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false]
] ]
@ -63,7 +63,7 @@ export default function html_block (state, startLine, endLine, silent) {
state.line = nextLine state.line = nextLine
const token = state.push('html_block', '', 0) const token = state.push('html_block', '', 0)
token.map = [ startLine, nextLine ] token.map = [startLine, nextLine]
token.content = state.getLines(startLine, nextLine, state.blkIndent, true) token.content = state.getLines(startLine, nextLine, state.blkIndent, true)
return true return true

4
lib/rules_block/lheading.mjs

@ -66,11 +66,11 @@ export default function lheading (state, startLine, endLine/*, silent*/) {
const token_o = state.push('heading_open', 'h' + String(level), 1) const token_o = state.push('heading_open', 'h' + String(level), 1)
token_o.markup = String.fromCharCode(marker) token_o.markup = String.fromCharCode(marker)
token_o.map = [ startLine, state.line ] token_o.map = [startLine, state.line]
const token_i = state.push('inline', '', 0) const token_i = state.push('inline', '', 0)
token_i.content = content token_i.content = content
token_i.map = [ startLine, state.line - 1 ] token_i.map = [startLine, state.line - 1]
token_i.children = [] token_i.children = []
const token_c = state.push('heading_close', 'h' + String(level), -1) const token_c = state.push('heading_close', 'h' + String(level), -1)

6
lib/rules_block/list.mjs

@ -166,14 +166,14 @@ export default function list (state, startLine, endLine, silent) {
if (isOrdered) { if (isOrdered) {
token = state.push('ordered_list_open', 'ol', 1) token = state.push('ordered_list_open', 'ol', 1)
if (markerValue !== 1) { if (markerValue !== 1) {
token.attrs = [ [ 'start', markerValue ] ] token.attrs = [['start', markerValue]]
} }
} else { } else {
token = state.push('bullet_list_open', 'ul', 1) token = state.push('bullet_list_open', 'ul', 1)
} }
const listLines = [ nextLine, 0 ] const listLines = [nextLine, 0]
token.map = listLines token.map = listLines
token.markup = String.fromCharCode(markerCharCode) token.markup = String.fromCharCode(markerCharCode)
@ -229,7 +229,7 @@ export default function list (state, startLine, endLine, silent) {
// Run subparser & write tokens // Run subparser & write tokens
token = state.push('list_item_open', 'li', 1) token = state.push('list_item_open', 'li', 1)
token.markup = String.fromCharCode(markerCharCode) token.markup = String.fromCharCode(markerCharCode)
const itemLines = [ nextLine, 0 ] const itemLines = [nextLine, 0]
token.map = itemLines token.map = itemLines
if (isOrdered) { if (isOrdered) {
token.info = state.src.slice(start, posAfterMarker - 1) token.info = state.src.slice(start, posAfterMarker - 1)

4
lib/rules_block/paragraph.mjs

@ -31,11 +31,11 @@ export default function paragraph (state, startLine, endLine) {
state.line = nextLine state.line = nextLine
const token_o = state.push('paragraph_open', 'p', 1) const token_o = state.push('paragraph_open', 'p', 1)
token_o.map = [ startLine, state.line ] token_o.map = [startLine, state.line]
const token_i = state.push('inline', '', 0) const token_i = state.push('inline', '', 0)
token_i.content = content token_i.content = content
token_i.map = [ startLine, state.line ] token_i.map = [startLine, state.line]
token_i.children = [] token_i.children = []
state.push('paragraph_close', 'p', -1) state.push('paragraph_close', 'p', -1)

14
lib/rules_block/table.mjs

@ -132,19 +132,19 @@ export default function table (state, startLine, endLine, silent) {
const terminatorRules = state.md.block.ruler.getRules('blockquote') const terminatorRules = state.md.block.ruler.getRules('blockquote')
const token_to = state.push('table_open', 'table', 1) const token_to = state.push('table_open', 'table', 1)
const tableLines = [ startLine, 0 ] const tableLines = [startLine, 0]
token_to.map = tableLines token_to.map = tableLines
const token_tho = state.push('thead_open', 'thead', 1) const token_tho = state.push('thead_open', 'thead', 1)
token_tho.map = [ startLine, startLine + 1 ] token_tho.map = [startLine, startLine + 1]
const token_htro = state.push('tr_open', 'tr', 1) const token_htro = state.push('tr_open', 'tr', 1)
token_htro.map = [ startLine, startLine + 1 ] token_htro.map = [startLine, startLine + 1]
for (let i = 0; i < columns.length; i++) { for (let i = 0; i < columns.length; i++) {
const token_ho = state.push('th_open', 'th', 1) const token_ho = state.push('th_open', 'th', 1)
if (aligns[i]) { if (aligns[i]) {
token_ho.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ] token_ho.attrs = [['style', 'text-align:' + aligns[i]]]
} }
const token_il = state.push('inline', '', 0) const token_il = state.push('inline', '', 0)
@ -180,16 +180,16 @@ export default function table (state, startLine, endLine, silent) {
if (nextLine === startLine + 2) { if (nextLine === startLine + 2) {
const token_tbo = state.push('tbody_open', 'tbody', 1) const token_tbo = state.push('tbody_open', 'tbody', 1)
token_tbo.map = tbodyLines = [ startLine + 2, 0 ] token_tbo.map = tbodyLines = [startLine + 2, 0]
} }
const token_tro = state.push('tr_open', 'tr', 1) const token_tro = state.push('tr_open', 'tr', 1)
token_tro.map = [ nextLine, nextLine + 1 ] token_tro.map = [nextLine, nextLine + 1]
for (let i = 0; i < columnCount; i++) { for (let i = 0; i < columnCount; i++) {
const token_tdo = state.push('td_open', 'td', 1) const token_tdo = state.push('td_open', 'td', 1)
if (aligns[i]) { if (aligns[i]) {
token_tdo.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ] token_tdo.attrs = [['style', 'text-align:' + aligns[i]]]
} }
const token_il = state.push('inline', '', 0) const token_il = state.push('inline', '', 0)

2
lib/rules_core/block.mjs

@ -4,7 +4,7 @@ export default function block (state) {
if (state.inlineMode) { if (state.inlineMode) {
token = new state.Token('inline', '', 0) token = new state.Token('inline', '', 0)
token.content = state.src token.content = state.src
token.map = [ 0, 1 ] token.map = [0, 1]
token.children = [] token.children = []
state.tokens.push(token) state.tokens.push(token)
} else { } else {

2
lib/rules_core/linkify.mjs

@ -103,7 +103,7 @@ export default function linkify (state) {
} }
const token_o = new state.Token('link_open', 'a', 1) const token_o = new state.Token('link_open', 'a', 1)
token_o.attrs = [ [ 'href', fullUrl ] ] token_o.attrs = [['href', fullUrl]]
token_o.level = level++ token_o.level = level++
token_o.markup = 'linkify' token_o.markup = 'linkify'
token_o.info = 'auto' token_o.info = 'auto'

4
lib/rules_inline/autolink.mjs

@ -30,7 +30,7 @@ export default function autolink (state, silent) {
if (!silent) { if (!silent) {
const token_o = state.push('link_open', 'a', 1) const token_o = state.push('link_open', 'a', 1)
token_o.attrs = [ [ 'href', fullUrl ] ] token_o.attrs = [['href', fullUrl]]
token_o.markup = 'autolink' token_o.markup = 'autolink'
token_o.info = 'auto' token_o.info = 'auto'
@ -52,7 +52,7 @@ export default function autolink (state, silent) {
if (!silent) { if (!silent) {
const token_o = state.push('link_open', 'a', 1) const token_o = state.push('link_open', 'a', 1)
token_o.attrs = [ [ 'href', fullUrl ] ] token_o.attrs = [['href', fullUrl]]
token_o.markup = 'autolink' token_o.markup = 'autolink'
token_o.info = 'auto' token_o.info = 'auto'

2
lib/rules_inline/balance_pairs.mjs

@ -40,7 +40,7 @@ function processDelimiters (delimiters) {
// and for whether this closer can be an opener; // and for whether this closer can be an opener;
// https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460 // https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
if (!openersBottom.hasOwnProperty(closer.marker)) { if (!openersBottom.hasOwnProperty(closer.marker)) {
openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ] openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1]
} }
const minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)] const minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)]

4
lib/rules_inline/image.mjs

@ -130,13 +130,13 @@ export default function image (state, silent) {
) )
const token = state.push('image', 'img', 0) const token = state.push('image', 'img', 0)
const attrs = [ [ 'src', href ], [ 'alt', '' ] ] const attrs = [['src', href], ['alt', '']]
token.attrs = attrs token.attrs = attrs
token.children = tokens token.children = tokens
token.content = content token.content = content
if (title) { if (title) {
attrs.push([ 'title', title ]) attrs.push(['title', title])
} }
} }

4
lib/rules_inline/link.mjs

@ -123,10 +123,10 @@ export default function link (state, silent) {
state.posMax = labelEnd state.posMax = labelEnd
const token_o = state.push('link_open', 'a', 1) const token_o = state.push('link_open', 'a', 1)
const attrs = [ [ 'href', href ] ] const attrs = [['href', href]]
token_o.attrs = attrs token_o.attrs = attrs
if (title) { if (title) {
attrs.push([ 'title', title ]) attrs.push(['title', title])
} }
state.linkLevel++ state.linkLevel++

2
lib/rules_inline/linkify.mjs

@ -40,7 +40,7 @@ export default function linkify (state, silent) {
state.pending = state.pending.slice(0, -proto.length) state.pending = state.pending.slice(0, -proto.length)
const token_o = state.push('link_open', 'a', 1) const token_o = state.push('link_open', 'a', 1)
token_o.attrs = [ [ 'href', fullUrl ] ] token_o.attrs = [['href', fullUrl]]
token_o.markup = 'linkify' token_o.markup = 'linkify'
token_o.info = 'auto' token_o.info = 'auto'

6
lib/token.mjs

@ -140,7 +140,7 @@ Token.prototype.attrPush = function attrPush (attrData) {
if (this.attrs) { if (this.attrs) {
this.attrs.push(attrData) this.attrs.push(attrData)
} else { } else {
this.attrs = [ attrData ] this.attrs = [attrData]
} }
} }
@ -152,7 +152,7 @@ Token.prototype.attrPush = function attrPush (attrData) {
**/ **/
Token.prototype.attrSet = function attrSet (name, value) { Token.prototype.attrSet = function attrSet (name, value) {
const idx = this.attrIndex(name), const idx = this.attrIndex(name),
attrData = [ name, value ] attrData = [name, value]
if (idx < 0) { if (idx < 0) {
this.attrPush(attrData) this.attrPush(attrData)
@ -187,7 +187,7 @@ Token.prototype.attrJoin = function attrJoin (name, value) {
const idx = this.attrIndex(name) const idx = this.attrIndex(name)
if (idx < 0) { if (idx < 0) {
this.attrPush([ name, value ]) this.attrPush([name, value])
} else { } else {
this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value
} }

2
support/demo_template/index.mjs

@ -343,7 +343,7 @@ function loadPermalink () {
}) })
// sanitize for sure // sanitize for sure
if ([ 'html', 'src', 'debug' ].indexOf(defaults._view) === -1) { if (['html', 'src', 'debug'].indexOf(defaults._view) === -1) {
defaults._view = 'html' defaults._view = 'html'
} }
} }

2
support/specsplit.mjs

@ -16,7 +16,7 @@ const cli = new argparse.ArgumentParser({
cli.add_argument('type', { cli.add_argument('type', {
help: 'type of examples to filter', help: 'type of examples to filter',
nargs: '?', nargs: '?',
choices: [ 'good', 'bad' ] choices: ['good', 'bad']
}) })
cli.add_argument('-s', '--spec', { cli.add_argument('-s', '--spec', {

2
test/babelmark-responder.mjs

@ -13,7 +13,7 @@ describe('babelmark responder app', function () {
before(async () => { before(async () => {
app = execFile( app = execFile(
'node', 'node',
[ '../support/babelmark-responder.mjs' ], ['../support/babelmark-responder.mjs'],
{ {
cwd: new URL('.', import.meta.url), cwd: new URL('.', import.meta.url),
env: Object.assign({}, process.env, { PORT: PORT }) env: Object.assign({}, process.env, { PORT: PORT })

18
test/misc.mjs

@ -106,7 +106,7 @@ describe('API', function () {
} }
// Disable 2 rule in each chain & compare result // Disable 2 rule in each chain & compare result
md.disable([ 'block', 'inline', 'code', 'fence', 'emphasis', 'entity' ]) md.disable(['block', 'inline', 'code', 'fence', 'emphasis', 'entity'])
const now = { const now = {
core: md.core.ruler.getRules('').length + 2, core: md.core.ruler.getRules('').length + 2,
@ -117,7 +117,7 @@ describe('API', function () {
assert.deepEqual(was, now) assert.deepEqual(was, now)
// Enable the same rules back // Enable the same rules back
md.enable([ 'block', 'inline', 'code', 'fence', 'emphasis', 'entity' ]) md.enable(['block', 'inline', 'code', 'fence', 'emphasis', 'entity'])
const back = { const back = {
core: md.core.ruler.getRules('').length, core: md.core.ruler.getRules('').length,
@ -132,16 +132,16 @@ describe('API', function () {
const md = markdownit() const md = markdownit()
assert.throws(function () { assert.throws(function () {
md.enable([ 'link', 'code', 'invalid' ]) md.enable(['link', 'code', 'invalid'])
}) })
assert.throws(function () { assert.throws(function () {
md.disable([ 'link', 'code', 'invalid' ]) md.disable(['link', 'code', 'invalid'])
}) })
assert.doesNotThrow(function () { assert.doesNotThrow(function () {
md.enable([ 'link', 'code' ]) md.enable(['link', 'code'])
}) })
assert.doesNotThrow(function () { assert.doesNotThrow(function () {
md.disable([ 'link', 'code' ]) md.disable(['link', 'code'])
}) })
}) })
@ -198,7 +198,7 @@ describe('Plugins', function () {
const pos = state.bMarks[startLine] + state.tShift[startLine] const pos = state.bMarks[startLine] + state.tShift[startLine]
if (state.src.charCodeAt(pos) !== 0x40/* @ */) return false if (state.src.charCodeAt(pos) !== 0x40/* @ */) return false
return true return true
}, { alt: [ 'paragraph' ] }) }, { alt: ['paragraph'] })
assert.throws(() => md.render('foo\n@bar\nbaz'), /block rule didn't increment state.line/) assert.throws(() => md.render('foo\n@bar\nbaz'), /block rule didn't increment state.line/)
assert.throws(() => md.render('foo\n\n@bar\n\nbaz'), /block rule didn't increment state.line/) assert.throws(() => md.render('foo\n\n@bar\n\nbaz'), /block rule didn't increment state.line/)
@ -268,7 +268,7 @@ describe('Misc', function () {
it('Should render link target attr', function () { it('Should render link target attr', function () {
const md = markdownit() const md = markdownit()
.use(forInline, 'target', 'link_open', function (tokens, idx) { .use(forInline, 'target', 'link_open', function (tokens, idx) {
tokens[idx].attrs.push([ 'target', '_blank' ]) tokens[idx].attrs.push(['target', '_blank'])
}) })
assert.strictEqual(md.render('[foo](bar)'), '<p><a href="bar" target="_blank">foo</a></p>\n') assert.strictEqual(md.render('[foo](bar)'), '<p><a href="bar" target="_blank">foo</a></p>\n')
@ -380,7 +380,7 @@ describe('smartquotes', function () {
// all strings have different length to make sure // all strings have different length to make sure
// we didn't accidentally count the wrong one // we didn't accidentally count the wrong one
quotes: [ '[[[', ']]', '(((((', '))))' ] quotes: ['[[[', ']]', '(((((', '))))']
}) })
it('Should support multi-character quotes', function () { it('Should support multi-character quotes', function () {

8
test/ruler.mjs

@ -71,10 +71,10 @@ describe('Ruler', function () {
ruler.push('test', function foo () {}) ruler.push('test', function foo () {})
ruler.push('test2', function bar () {}) ruler.push('test2', function bar () {})
ruler.disable([ 'test', 'test2' ]) ruler.disable(['test', 'test2'])
rules = ruler.getRules('') rules = ruler.getRules('')
assert.strictEqual(rules.length, 0) assert.strictEqual(rules.length, 0)
ruler.enable([ 'test', 'test2' ]) ruler.enable(['test', 'test2'])
rules = ruler.getRules('') rules = ruler.getRules('')
assert.strictEqual(rules.length, 2) assert.strictEqual(rules.length, 2)
}) })
@ -97,8 +97,8 @@ describe('Ruler', function () {
let rules let rules
ruler.push('test', function foo () {}) ruler.push('test', function foo () {})
ruler.push('test2', function bar () {}, { alt: [ 'alt1' ] }) ruler.push('test2', function bar () {}, { alt: ['alt1'] })
ruler.push('test2', function bar () {}, { alt: [ 'alt1', 'alt2' ] }) ruler.push('test2', function bar () {}, { alt: ['alt1', 'alt2'] })
rules = ruler.getRules('') rules = ruler.getRules('')
assert.strictEqual(rules.length, 3) assert.strictEqual(rules.length, 3)

4
test/token.mjs

@ -10,8 +10,8 @@ describe('Token', function () {
assert.strictEqual(t.attrs, null) assert.strictEqual(t.attrs, null)
assert.equal(t.attrIndex('foo'), -1) assert.equal(t.attrIndex('foo'), -1)
t.attrPush([ 'foo', 'bar' ]) t.attrPush(['foo', 'bar'])
t.attrPush([ 'baz', 'bad' ]) t.attrPush(['baz', 'bad'])
assert.equal(t.attrIndex('foo'), 0) assert.equal(t.attrIndex('foo'), 0)
assert.equal(t.attrIndex('baz'), 1) assert.equal(t.attrIndex('baz'), 1)

Loading…
Cancel
Save