markdown-it
Advanced tools
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| // Regexps to match html elements | ||
| const attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*' | ||
| const attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*' | ||
| const unquoted = '[^"\'=<>`\\x00-\\x20]+' | ||
| const unquoted = '[^"\'=<>`\\x00-\\x20]+' | ||
| const single_quoted = "'[^']*'" | ||
| const double_quoted = '"[^"]*"' | ||
| const attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')' | ||
| const attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')' | ||
| const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)' | ||
| const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)' | ||
| const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>' | ||
| const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>' | ||
| const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>' | ||
| const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->' | ||
| const processing = '<[?][\\s\\S]*?[?]>' | ||
| const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>' | ||
| const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->' | ||
| const processing = '<[?][\\s\\S]*?[?]>' | ||
| const declaration = '<![A-Za-z][^>]*>' | ||
| const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>' | ||
| const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>' | ||
@@ -21,0 +21,0 @@ const HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment + |
+2
-11
@@ -45,3 +45,2 @@ // Utilities | ||
| function isValidEntityCode (c) { | ||
| /* eslint no-bitwise:0 */ | ||
| // broken sequence | ||
@@ -74,4 +73,4 @@ if (c >= 0xD800 && c <= 0xDFFF) { return false } | ||
| const UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g | ||
| const ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi | ||
| const UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g | ||
| const ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi | ||
| const UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi') | ||
@@ -102,8 +101,2 @@ | ||
| /* function replaceEntities(str) { | ||
| if (str.indexOf('&') < 0) { return str; } | ||
| return str.replace(ENTITY_RE, replaceEntityPattern); | ||
| } */ | ||
| function unescapeMd (str) { | ||
@@ -178,4 +171,2 @@ if (str.indexOf('\\') < 0) { return str } | ||
| /* eslint-disable max-len */ | ||
| // Currently without astral characters support. | ||
@@ -182,0 +173,0 @@ function isPunctChar (ch) { |
@@ -25,13 +25,13 @@ /** internal | ||
| // which can be terminated by this one. | ||
| ['table', r_table, ['paragraph', 'reference']], | ||
| ['code', r_code], | ||
| ['fence', r_fence, ['paragraph', 'reference', 'blockquote', 'list']], | ||
| ['table', r_table, ['paragraph', 'reference']], | ||
| ['code', r_code], | ||
| ['fence', r_fence, ['paragraph', 'reference', 'blockquote', 'list']], | ||
| ['blockquote', r_blockquote, ['paragraph', 'reference', 'blockquote', 'list']], | ||
| ['hr', r_hr, ['paragraph', 'reference', 'blockquote', 'list']], | ||
| ['list', r_list, ['paragraph', 'reference', 'blockquote']], | ||
| ['reference', r_reference], | ||
| ['hr', r_hr, ['paragraph', 'reference', 'blockquote', 'list']], | ||
| ['list', r_list, ['paragraph', 'reference', 'blockquote']], | ||
| ['reference', r_reference], | ||
| ['html_block', r_html_block, ['paragraph', 'reference', 'blockquote']], | ||
| ['heading', r_heading, ['paragraph', 'reference', 'blockquote']], | ||
| ['lheading', r_lheading], | ||
| ['paragraph', r_paragraph] | ||
| ['heading', r_heading, ['paragraph', 'reference', 'blockquote']], | ||
| ['lheading', r_lheading], | ||
| ['paragraph', r_paragraph] | ||
| ] | ||
@@ -38,0 +38,0 @@ |
@@ -20,11 +20,11 @@ /** internal | ||
| const _rules = [ | ||
| ['normalize', r_normalize], | ||
| ['block', r_block], | ||
| ['inline', r_inline], | ||
| ['linkify', r_linkify], | ||
| ['replacements', r_replacements], | ||
| ['smartquotes', r_smartquotes], | ||
| ['normalize', r_normalize], | ||
| ['block', r_block], | ||
| ['inline', r_inline], | ||
| ['linkify', r_linkify], | ||
| ['replacements', r_replacements], | ||
| ['smartquotes', r_smartquotes], | ||
| // `text_join` finds `text_special` tokens (for escape sequences) | ||
| // and joins them with the rest of the text | ||
| ['text_join', r_text_join] | ||
| ['text_join', r_text_join] | ||
| ] | ||
@@ -31,0 +31,0 @@ |
+16
-16
@@ -29,14 +29,14 @@ /** internal | ||
| const _rules = [ | ||
| ['text', r_text], | ||
| ['linkify', r_linkify], | ||
| ['newline', r_newline], | ||
| ['escape', r_escape], | ||
| ['backticks', r_backticks], | ||
| ['strikethrough', r_strikethrough.tokenize], | ||
| ['emphasis', r_emphasis.tokenize], | ||
| ['link', r_link], | ||
| ['image', r_image], | ||
| ['autolink', r_autolink], | ||
| ['html_inline', r_html_inline], | ||
| ['entity', r_entity] | ||
| ['text', r_text], | ||
| ['linkify', r_linkify], | ||
| ['newline', r_newline], | ||
| ['escape', r_escape], | ||
| ['backticks', r_backticks], | ||
| ['strikethrough', r_strikethrough.tokenize], | ||
| ['emphasis', r_emphasis.tokenize], | ||
| ['link', r_link], | ||
| ['image', r_image], | ||
| ['autolink', r_autolink], | ||
| ['html_inline', r_html_inline], | ||
| ['entity', r_entity] | ||
| ] | ||
@@ -50,8 +50,8 @@ | ||
| const _rules2 = [ | ||
| ['balance_pairs', r_balance_pairs], | ||
| ['strikethrough', r_strikethrough.postProcess], | ||
| ['emphasis', r_emphasis.postProcess], | ||
| ['balance_pairs', r_balance_pairs], | ||
| ['strikethrough', r_strikethrough.postProcess], | ||
| ['emphasis', r_emphasis.postProcess], | ||
| // 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 | ||
| ['fragments_join', r_fragments_join] | ||
| ['fragments_join', r_fragments_join] | ||
| ] | ||
@@ -58,0 +58,0 @@ |
+2
-2
@@ -16,3 +16,3 @@ /** | ||
| return '<code' + slf.renderAttrs(token) + '>' + | ||
| return '<code' + slf.renderAttrs(token) + '>' + | ||
| escapeHtml(token.content) + | ||
@@ -25,3 +25,3 @@ '</code>' | ||
| return '<pre' + slf.renderAttrs(token) + '><code>' + | ||
| return '<pre' + slf.renderAttrs(token) + '><code>' + | ||
| escapeHtml(tokens[idx].content) + | ||
@@ -28,0 +28,0 @@ '</code></pre>\n' |
@@ -21,6 +21,6 @@ // Block quotes | ||
| const oldBMarks = [] | ||
| const oldBMarks = [] | ||
| const oldBSCount = [] | ||
| const oldSCount = [] | ||
| const oldTShift = [] | ||
| const oldSCount = [] | ||
| const oldTShift = [] | ||
@@ -185,10 +185,10 @@ const terminatorRules = state.md.block.ruler.getRules('blockquote') | ||
| const token_o = state.push('blockquote_open', 'blockquote', 1) | ||
| const token_o = state.push('blockquote_open', 'blockquote', 1) | ||
| token_o.markup = '>' | ||
| const lines = [startLine, 0] | ||
| token_o.map = lines | ||
| token_o.map = lines | ||
| state.md.block.tokenize(state, startLine, nextLine) | ||
| const token_c = state.push('blockquote_close', 'blockquote', -1) | ||
| const token_c = state.push('blockquote_close', 'blockquote', -1) | ||
| token_c.markup = '>' | ||
@@ -195,0 +195,0 @@ |
@@ -25,7 +25,7 @@ // Code block (4 spaces padded) | ||
| 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.map = [startLine, state.line] | ||
| token.map = [startLine, state.line] | ||
| return true | ||
| } |
@@ -87,9 +87,9 @@ // fences (``` lang, ~~~ lang) | ||
| const token = state.push('fence', 'code', 0) | ||
| token.info = params | ||
| const token = state.push('fence', 'code', 0) | ||
| token.info = params | ||
| token.content = state.getLines(startLine + 1, nextLine, len, true) | ||
| token.markup = markup | ||
| token.map = [startLine, state.line] | ||
| token.markup = markup | ||
| token.map = [startLine, state.line] | ||
| return true | ||
| } |
@@ -12,3 +12,3 @@ // heading (#, ##, ...) | ||
| let ch = state.src.charCodeAt(pos) | ||
| let ch = state.src.charCodeAt(pos) | ||
@@ -39,12 +39,12 @@ if (ch !== 0x23/* # */ || pos >= max) { return false } | ||
| 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.map = [startLine, state.line] | ||
| token_o.map = [startLine, state.line] | ||
| const token_i = state.push('inline', '', 0) | ||
| token_i.content = asciiTrim(state.src.slice(pos, max)) | ||
| token_i.map = [startLine, state.line] | ||
| const token_i = state.push('inline', '', 0) | ||
| token_i.content = asciiTrim(state.src.slice(pos, max)) | ||
| token_i.map = [startLine, state.line] | ||
| 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) | ||
| token_c.markup = '########'.slice(0, level) | ||
@@ -51,0 +51,0 @@ |
@@ -35,4 +35,4 @@ // Horizontal rule | ||
| const token = state.push('hr', 'hr', 0) | ||
| token.map = [startLine, state.line] | ||
| const token = state.push('hr', 'hr', 0) | ||
| token.map = [startLine, state.line] | ||
| token.markup = Array(cnt + 1).join(String.fromCharCode(marker)) | ||
@@ -39,0 +39,0 @@ |
@@ -11,8 +11,8 @@ // HTML block | ||
| [/^<(script|pre|style|textarea)(?=(\s|>|$))/i, /<\/(script|pre|style|textarea)>/i, true], | ||
| [/^<!--/, /-->/, true], | ||
| [/^<\?/, /\?>/, true], | ||
| [/^<![A-Z]/, />/, true], | ||
| [/^<!--/, /-->/, true], | ||
| [/^<\?/, /\?>/, true], | ||
| [/^<![A-Z]/, />/, true], | ||
| [/^<!\[CDATA\[/, /\]\]>/, 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] | ||
| ] | ||
@@ -76,4 +76,4 @@ | ||
| const token = state.push('html_block', '', 0) | ||
| token.map = [startLine, nextLine] | ||
| const token = state.push('html_block', '', 0) | ||
| token.map = [startLine, nextLine] | ||
| token.content = state.getLines(startLine, nextLine, state.blkIndent, true) | ||
@@ -80,0 +80,0 @@ |
@@ -70,13 +70,13 @@ // lheading (---, ===) | ||
| const token_o = state.push('heading_open', 'h' + String(level), 1) | ||
| token_o.markup = String.fromCharCode(marker) | ||
| token_o.map = [startLine, state.line] | ||
| const token_o = state.push('heading_open', 'h' + String(level), 1) | ||
| token_o.markup = String.fromCharCode(marker) | ||
| token_o.map = [startLine, state.line] | ||
| const token_i = state.push('inline', '', 0) | ||
| token_i.content = content | ||
| token_i.map = [startLine, state.line - 1] | ||
| const token_i = state.push('inline', '', 0) | ||
| token_i.content = content | ||
| token_i.map = [startLine, state.line - 1] | ||
| token_i.children = [] | ||
| const token_c = state.push('heading_close', 'h' + String(level), -1) | ||
| token_c.markup = String.fromCharCode(marker) | ||
| const token_c = state.push('heading_close', 'h' + String(level), -1) | ||
| token_c.markup = String.fromCharCode(marker) | ||
@@ -83,0 +83,0 @@ state.parentType = oldParentType |
@@ -159,3 +159,3 @@ // Lists | ||
| if (isOrdered) { | ||
| token = state.push('ordered_list_open', 'ol', 1) | ||
| token = state.push('ordered_list_open', 'ol', 1) | ||
| if (markerValue !== 1) { | ||
@@ -165,7 +165,7 @@ token.attrs = [['start', markerValue]] | ||
| } else { | ||
| token = state.push('bullet_list_open', 'ul', 1) | ||
| token = state.push('bullet_list_open', 'ul', 1) | ||
| } | ||
| const listLines = [nextLine, 0] | ||
| token.map = listLines | ||
| token.map = listLines | ||
| token.markup = String.fromCharCode(markerCharCode) | ||
@@ -223,6 +223,6 @@ | ||
| // 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) | ||
| const itemLines = [nextLine, 0] | ||
| token.map = itemLines | ||
| token.map = itemLines | ||
| if (isOrdered) { | ||
@@ -276,3 +276,3 @@ token.info = state.src.slice(start, posAfterMarker - 1) | ||
| token = state.push('list_item_close', 'li', -1) | ||
| token = state.push('list_item_close', 'li', -1) | ||
| token.markup = String.fromCharCode(markerCharCode) | ||
@@ -279,0 +279,0 @@ |
@@ -35,8 +35,8 @@ // Paragraph | ||
| const token_o = state.push('paragraph_open', 'p', 1) | ||
| token_o.map = [startLine, state.line] | ||
| const token_o = state.push('paragraph_open', 'p', 1) | ||
| token_o.map = [startLine, state.line] | ||
| const token_i = state.push('inline', '', 0) | ||
| token_i.content = content | ||
| token_i.map = [startLine, state.line] | ||
| const token_i = state.push('inline', '', 0) | ||
| token_i.content = content | ||
| token_i.map = [startLine, state.line] | ||
| token_i.children = [] | ||
@@ -43,0 +43,0 @@ |
@@ -137,3 +137,3 @@ import { isSpace, normalizeReference } from '../common/utils.mjs' | ||
| } else if (isSpace(ch)) { | ||
| /* eslint no-empty:0 */ | ||
| /* Nothing */ | ||
| } else { | ||
@@ -140,0 +140,0 @@ break |
@@ -10,3 +10,3 @@ // Parser state class | ||
| // link to parser instance | ||
| this.md = md | ||
| this.md = md | ||
@@ -42,7 +42,7 @@ this.env = env | ||
| // inside a list, it would be positioned after list marker) | ||
| this.blkIndent = 0 | ||
| this.line = 0 // line index in src | ||
| this.lineMax = 0 // lines count | ||
| this.tight = false // loose/tight mode for lists | ||
| this.ddIndent = -1 // indent of the current dd block (-1 if there isn't any) | ||
| this.blkIndent = 0 | ||
| this.line = 0 // line index in src | ||
| this.lineMax = 0 // lines count | ||
| this.tight = false // loose/tight mode for lists | ||
| this.ddIndent = -1 // indent of the current dd block (-1 if there isn't any) | ||
| this.listIndent = -1 // indent of the current list block (-1 if there isn't any) | ||
@@ -49,0 +49,0 @@ |
@@ -154,7 +154,7 @@ // GFM table, https://github.github.com/gfm/#tables-extension- | ||
| 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) | ||
| token_il.content = columns[i].trim() | ||
| token_il.content = columns[i].trim() | ||
| token_il.children = [] | ||
@@ -206,7 +206,7 @@ | ||
| 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) | ||
| token_il.content = columns[i] ? columns[i].trim() : '' | ||
| token_il.content = columns[i] ? columns[i].trim() : '' | ||
| token_il.children = [] | ||
@@ -213,0 +213,0 @@ |
@@ -5,5 +5,5 @@ export default function block (state) { | ||
| if (state.inlineMode) { | ||
| token = new state.Token('inline', '', 0) | ||
| token.content = state.src | ||
| token.map = [0, 1] | ||
| token = new state.Token('inline', '', 0) | ||
| token.content = state.src | ||
| token.map = [0, 1] | ||
| token.children = [] | ||
@@ -10,0 +10,0 @@ state.tokens.push(token) |
@@ -96,24 +96,24 @@ // Replace link-like texts with link nodes. | ||
| if (pos > lastPos) { | ||
| const token = new state.Token('text', '', 0) | ||
| const token = new state.Token('text', '', 0) | ||
| token.content = text.slice(lastPos, pos) | ||
| token.level = level | ||
| token.level = level | ||
| nodes.push(token) | ||
| } | ||
| const token_o = new state.Token('link_open', 'a', 1) | ||
| token_o.attrs = [['href', fullUrl]] | ||
| token_o.level = level++ | ||
| token_o.markup = 'linkify' | ||
| token_o.info = 'auto' | ||
| const token_o = new state.Token('link_open', 'a', 1) | ||
| token_o.attrs = [['href', fullUrl]] | ||
| token_o.level = level++ | ||
| token_o.markup = 'linkify' | ||
| token_o.info = 'auto' | ||
| nodes.push(token_o) | ||
| const token_t = new state.Token('text', '', 0) | ||
| const token_t = new state.Token('text', '', 0) | ||
| token_t.content = urlText | ||
| token_t.level = level | ||
| token_t.level = level | ||
| nodes.push(token_t) | ||
| const token_c = new state.Token('link_close', 'a', -1) | ||
| token_c.level = --level | ||
| token_c.markup = 'linkify' | ||
| token_c.info = 'auto' | ||
| const token_c = new state.Token('link_close', 'a', -1) | ||
| token_c.level = --level | ||
| token_c.markup = 'linkify' | ||
| token_c.info = 'auto' | ||
| nodes.push(token_c) | ||
@@ -124,5 +124,5 @@ | ||
| if (lastPos < text.length) { | ||
| const token = new state.Token('text', '', 0) | ||
| const token = new state.Token('text', '', 0) | ||
| token.content = text.slice(lastPos) | ||
| token.level = level | ||
| token.level = level | ||
| nodes.push(token) | ||
@@ -129,0 +129,0 @@ } |
| // Normalize input string | ||
| // https://spec.commonmark.org/0.29/#line-ending | ||
| const NEWLINES_RE = /\r\n?|\n/g | ||
| const NULL_RE = /\0/g | ||
| const NEWLINES_RE = /\r\n?|\n/g | ||
| const NULL_RE = /\0/g | ||
@@ -7,0 +7,0 @@ export default function normalize (state) { |
| // Process autolinks '<protocol:...>' | ||
| /* eslint max-len:0 */ | ||
| const EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/ | ||
| const EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/ | ||
| /* eslint-disable-next-line no-control-regex */ | ||
@@ -32,13 +32,13 @@ const AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/ | ||
| if (!silent) { | ||
| const token_o = state.push('link_open', 'a', 1) | ||
| token_o.attrs = [['href', fullUrl]] | ||
| token_o.markup = 'autolink' | ||
| token_o.info = 'auto' | ||
| const token_o = state.push('link_open', 'a', 1) | ||
| token_o.attrs = [['href', fullUrl]] | ||
| token_o.markup = 'autolink' | ||
| token_o.info = 'auto' | ||
| const token_t = state.push('text', '', 0) | ||
| const token_t = state.push('text', '', 0) | ||
| token_t.content = state.md.normalizeLinkText(url) | ||
| const token_c = state.push('link_close', 'a', -1) | ||
| token_c.markup = 'autolink' | ||
| token_c.info = 'auto' | ||
| const token_c = state.push('link_close', 'a', -1) | ||
| token_c.markup = 'autolink' | ||
| token_c.info = 'auto' | ||
| } | ||
@@ -55,13 +55,13 @@ | ||
| if (!silent) { | ||
| const token_o = state.push('link_open', 'a', 1) | ||
| token_o.attrs = [['href', fullUrl]] | ||
| token_o.markup = 'autolink' | ||
| token_o.info = 'auto' | ||
| const token_o = state.push('link_open', 'a', 1) | ||
| token_o.attrs = [['href', fullUrl]] | ||
| token_o.markup = 'autolink' | ||
| token_o.info = 'auto' | ||
| const token_t = state.push('text', '', 0) | ||
| const token_t = state.push('text', '', 0) | ||
| token_t.content = state.md.normalizeLinkText(url) | ||
| const token_c = state.push('link_close', 'a', -1) | ||
| token_c.markup = 'autolink' | ||
| token_c.info = 'auto' | ||
| const token_c = state.push('link_close', 'a', -1) | ||
| token_c.markup = 'autolink' | ||
| token_c.info = 'auto' | ||
| } | ||
@@ -68,0 +68,0 @@ |
@@ -88,4 +88,4 @@ // For each opening emphasis-like marker find a matching closing one | ||
| closer.open = false | ||
| opener.end = closerIdx | ||
| closer.open = false | ||
| opener.end = closerIdx | ||
| opener.close = false | ||
@@ -92,0 +92,0 @@ newMinOpenerIdx = -1 |
@@ -83,14 +83,14 @@ // Process *this* and _that_ | ||
| const token_o = state.tokens[startDelim.token] | ||
| token_o.type = isStrong ? 'strong_open' : 'em_open' | ||
| token_o.tag = isStrong ? 'strong' : 'em' | ||
| const token_o = state.tokens[startDelim.token] | ||
| token_o.type = isStrong ? 'strong_open' : 'em_open' | ||
| token_o.tag = isStrong ? 'strong' : 'em' | ||
| token_o.nesting = 1 | ||
| token_o.markup = isStrong ? ch + ch : ch | ||
| token_o.markup = isStrong ? ch + ch : ch | ||
| token_o.content = '' | ||
| const token_c = state.tokens[endDelim.token] | ||
| token_c.type = isStrong ? 'strong_close' : 'em_close' | ||
| token_c.tag = isStrong ? 'strong' : 'em' | ||
| const token_c = state.tokens[endDelim.token] | ||
| token_c.type = isStrong ? 'strong_close' : 'em_close' | ||
| token_c.tag = isStrong ? 'strong' : 'em' | ||
| token_c.nesting = -1 | ||
| token_c.markup = isStrong ? ch + ch : ch | ||
| token_c.markup = isStrong ? ch + ch : ch | ||
| token_c.content = '' | ||
@@ -97,0 +97,0 @@ |
@@ -7,3 +7,3 @@ // Process html entity - {, ¯, ", ... | ||
| const DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i | ||
| const NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i | ||
| const NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i | ||
@@ -26,6 +26,6 @@ export default function entity (state, silent) { | ||
| const token = state.push('text_special', '', 0) | ||
| const token = state.push('text_special', '', 0) | ||
| token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD) | ||
| token.markup = match[0] | ||
| token.info = 'entity' | ||
| token.markup = match[0] | ||
| token.info = 'entity' | ||
| } | ||
@@ -41,6 +41,6 @@ state.pos += match[0].length | ||
| if (!silent) { | ||
| const token = state.push('text_special', '', 0) | ||
| const token = state.push('text_special', '', 0) | ||
| token.content = decoded | ||
| token.markup = match[0] | ||
| token.info = 'entity' | ||
| token.markup = match[0] | ||
| token.info = 'entity' | ||
| } | ||
@@ -47,0 +47,0 @@ state.pos += match[0].length |
@@ -41,2 +41,16 @@ // Process escaped chars and hardbreaks | ||
| // '\' before a space is a literal backslash. Don't consume the space, so a | ||
| // trailing two-space hard line break is still detected by the newline rule. | ||
| if (ch1 === 0x20) { | ||
| if (!silent) { | ||
| const token = state.push('text_special', '', 0) | ||
| token.content = '\\' | ||
| token.markup = '\\' | ||
| token.info = 'escape' | ||
| } | ||
| state.pos = pos | ||
| return true | ||
| } | ||
| let escapedStr = state.src[pos] | ||
@@ -65,3 +79,3 @@ | ||
| token.markup = origStr | ||
| token.info = 'escape' | ||
| token.info = 'escape' | ||
| } | ||
@@ -68,0 +82,0 @@ |
@@ -45,3 +45,3 @@ // Process html tags | ||
| if (isLinkOpen(token.content)) state.linkLevel++ | ||
| if (isLinkOpen(token.content)) state.linkLevel++ | ||
| if (isLinkClose(token.content)) state.linkLevel-- | ||
@@ -48,0 +48,0 @@ } |
@@ -124,3 +124,3 @@ // Process [link](<to> "stuff") | ||
| const attrs = [['href', href]] | ||
| token_o.attrs = attrs | ||
| token_o.attrs = attrs | ||
| if (title) { | ||
@@ -127,0 +127,0 @@ attrs.push(['title', title]) |
@@ -145,4 +145,4 @@ // Inline parser state | ||
| const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar) | ||
| const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar) | ||
| const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar) | ||
| const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar) | ||
@@ -149,0 +149,0 @@ return { can_open, can_close, length: count } |
@@ -23,3 +23,3 @@ // ~~strike through~~ | ||
| if (len % 2) { | ||
| token = state.push('text', '', 0) | ||
| token = state.push('text', '', 0) | ||
| token.content = ch | ||
@@ -30,3 +30,3 @@ len-- | ||
| for (let i = 0; i < len; i += 2) { | ||
| token = state.push('text', '', 0) | ||
| token = state.push('text', '', 0) | ||
| token.content = ch + ch | ||
@@ -67,14 +67,14 @@ | ||
| token = state.tokens[startDelim.token] | ||
| token.type = 's_open' | ||
| token.tag = 's' | ||
| token = state.tokens[startDelim.token] | ||
| token.type = 's_open' | ||
| token.tag = 's' | ||
| token.nesting = 1 | ||
| token.markup = '~~' | ||
| token.markup = '~~' | ||
| token.content = '' | ||
| token = state.tokens[endDelim.token] | ||
| token.type = 's_close' | ||
| token.tag = 's' | ||
| token = state.tokens[endDelim.token] | ||
| token.type = 's_close' | ||
| token.tag = 's' | ||
| token.nesting = -1 | ||
| token.markup = '~~' | ||
| token.markup = '~~' | ||
| token.content = '' | ||
@@ -81,0 +81,0 @@ |
+12
-12
@@ -18,3 +18,3 @@ // Token class | ||
| **/ | ||
| this.type = type | ||
| this.type = type | ||
@@ -26,3 +26,3 @@ /** | ||
| **/ | ||
| this.tag = tag | ||
| this.tag = tag | ||
@@ -34,3 +34,3 @@ /** | ||
| **/ | ||
| this.attrs = null | ||
| this.attrs = null | ||
@@ -42,3 +42,3 @@ /** | ||
| **/ | ||
| this.map = null | ||
| this.map = null | ||
@@ -54,3 +54,3 @@ /** | ||
| **/ | ||
| this.nesting = nesting | ||
| this.nesting = nesting | ||
@@ -62,3 +62,3 @@ /** | ||
| **/ | ||
| this.level = 0 | ||
| this.level = 0 | ||
@@ -78,3 +78,3 @@ /** | ||
| **/ | ||
| this.content = '' | ||
| this.content = '' | ||
@@ -86,3 +86,3 @@ /** | ||
| **/ | ||
| this.markup = '' | ||
| this.markup = '' | ||
@@ -98,3 +98,3 @@ /** | ||
| **/ | ||
| this.info = '' | ||
| this.info = '' | ||
@@ -106,3 +106,3 @@ /** | ||
| **/ | ||
| this.meta = null | ||
| this.meta = null | ||
@@ -115,3 +115,3 @@ /** | ||
| **/ | ||
| this.block = false | ||
| this.block = false | ||
@@ -124,3 +124,3 @@ /** | ||
| **/ | ||
| this.hidden = false | ||
| this.hidden = false | ||
| } | ||
@@ -127,0 +127,0 @@ |
+25
-34
| { | ||
| "name": "markdown-it", | ||
| "version": "14.2.0", | ||
| "version": "14.3.0", | ||
| "description": "Markdown-it - modern pluggable markdown parser.", | ||
@@ -41,3 +41,9 @@ "keywords": [ | ||
| "lint": "eslint .", | ||
| "test": "npm run lint && cross-env CJS_ONLY=1 npm run build && c8 --exclude dist --exclude test -r text -r html -r lcov mocha && node support/specsplit.mjs", | ||
| "test": "npm run lint && npm run test:cmspec && npm run test:markdown-it && npm run test:build", | ||
| "test:cmspec": "node --test --test-reporter=dot test/cmspec/**/*.test.mjs", | ||
| "test:markdown-it": "node --test test/markdown-it/**/*.test.mjs", | ||
| "test:build": "npm run build && node --test test/build/**/*.test.mjs", | ||
| "pathological:track-ref": "node support/track-ref-pathological.mjs", | ||
| "pathological:update-hash": "node support/track-ref-pathological.mjs --update", | ||
| "coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test --test-reporter=dot", | ||
| "doc": "node support/build_doc.mjs", | ||
@@ -47,7 +53,8 @@ "gh-doc": "npm run doc && gh-pages -d apidoc -f", | ||
| "gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git", | ||
| "build": "rollup -c support/rollup.config.mjs", | ||
| "benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1", | ||
| "build": "node support/build-dist.mjs", | ||
| "benchmark-deps": "npm install --prefix benchmark/extra/", | ||
| "specsplit": "support/specsplit.mjs good -o test/fixtures/commonmark/good.txt && support/specsplit.mjs bad -o test/fixtures/commonmark/bad.txt && support/specsplit.mjs", | ||
| "todo": "grep 'TODO' -n -r ./lib 2>/dev/null", | ||
| "prepublishOnly": "npm test && npm run build && npm run gh-demo && npm run gh-doc" | ||
| "prepack": "npm test && npm run build && npm run demo && npm run doc", | ||
| "postpublish": "npm run gh-demo && npm run gh-doc" | ||
| }, | ||
@@ -61,4 +68,4 @@ "files": [ | ||
| "argparse": "^2.0.1", | ||
| "entities": "^4.4.0", | ||
| "linkify-it": "^5.0.1", | ||
| "entities": "^4.5.0", | ||
| "linkify-it": "^5.0.2", | ||
| "mdurl": "^2.0.0", | ||
@@ -69,20 +76,9 @@ "punycode.js": "^2.3.1", | ||
| "devDependencies": { | ||
| "@rollup/plugin-babel": "^6.0.4", | ||
| "@rollup/plugin-commonjs": "^25.0.7", | ||
| "@rollup/plugin-node-resolve": "^15.2.3", | ||
| "@rollup/plugin-terser": "^0.4.4", | ||
| "ansi": "^0.3.0", | ||
| "benchmark": "~2.1.0", | ||
| "c8": "^8.0.1", | ||
| "chai": "^4.2.0", | ||
| "cross-env": "^7.0.3", | ||
| "eslint": "^8.4.1", | ||
| "eslint-config-standard": "^17.1.0", | ||
| "express": "^4.14.0", | ||
| "gh-pages": "^6.1.0", | ||
| "highlight.js": "^11.9.0", | ||
| "jest-worker": "^29.7.0", | ||
| "c8": "^11.0.0", | ||
| "eslint": "^9.39.4", | ||
| "gh-pages": "^6.3.0", | ||
| "highlight.js": "^11.11.1", | ||
| "markdown-it-abbr": "^2.0.0", | ||
| "markdown-it-container": "^4.0.0", | ||
| "markdown-it-deflist": "^3.0.0", | ||
| "markdown-it-deflist": "^3.0.1", | ||
| "markdown-it-emoji": "^3.0.0", | ||
@@ -95,14 +91,9 @@ "markdown-it-footnote": "^4.0.0", | ||
| "markdown-it-sup": "^2.0.0", | ||
| "markdown-it-testgen": "^0.1.3", | ||
| "mocha": "^10.2.0", | ||
| "ndoc": "^6.0.0", | ||
| "needle": "^3.0.0", | ||
| "rollup": "^4.5.0", | ||
| "shelljs": "^0.8.4", | ||
| "supertest": "^6.0.1" | ||
| }, | ||
| "mocha": { | ||
| "inline-diffs": true, | ||
| "timeout": 60000 | ||
| "ndoc": "^6.0.1", | ||
| "neostandard": "^0.13.0", | ||
| "terser": "^5.48.0", | ||
| "tinybench": "^6.0.2", | ||
| "vite": "^8.1.2", | ||
| "vite-plugin-singlefile": "^2.3.3" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1679991
116.23%20
-37.5%63
5%13739
-23.68%Updated
Updated