Rebase markedjs bug fixes (#2419)

This commit is contained in:
Felix Häusler 2020-12-17 23:18:55 +01:00 committed by GitHub
parent 05fd316daf
commit 2634f42204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1810 additions and 2507 deletions

View File

@ -1,6 +1,6 @@
# Marked
This folder contains a patched [Marked.js](https://github.com/markedjs/marked/) version based on `v0.7.0` commit [16a6495326b2fe7623840d4054b0deba5afbc00a](https://github.com/markedjs/marked/commit/16a6495326b2fe7623840d4054b0deba5afbc00a).
This folder contains a patched [Marked.js](https://github.com/markedjs/marked/) version based on `v0.8.2` and bug fixes from `v1.2.5`, no breaking changes from `v1.0.0` are included.
## Changes

View File

@ -9,17 +9,17 @@ import { edit, noop } from './utils'
export const block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html: '^ {0,3}(?:' + // optional indentation
'<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' + // (1)
'|comment[^\\n]*(\\n+|$)' + // (2)
'|<\\?[\\s\\S]*?\\?>\\n*' + // (3)
'|<![A-Z][\\s\\S]*?>\\n*' + // (4)
'|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' + // (5)
'|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' + // (3)
'|<![A-Z][\\s\\S]*?(?:>\\n*|$)' + // (4)
'|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' + // (5)
'|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' + // (6)
'|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' + // (7) open tag
'|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' + // (7) closing tag
@ -68,7 +68,7 @@ block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' +
'|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' +
'|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' +
'|track|ul'
block._comment = /<!--(?!-?>)[\s\S]*?-->/
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/
block.html = edit(block.html, 'i')
.replace('comment', block._comment)
.replace('tag', block._tag)
@ -77,10 +77,10 @@ block.html = edit(block.html, 'i')
block.paragraph = edit(block._paragraph)
.replace('hr', block.hr)
.replace('heading', ' {0,3}#{1,6} +')
.replace('heading', ' {0,3}#{1,6} ')
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
.replace('blockquote', ' {0,3}>')
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
@ -101,10 +101,36 @@ export const normal = Object.assign({}, block)
*/
export const gfm = Object.assign({}, normal, {
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
nptable: '^ *([^|\\n ].*\\|.*)\\n' + // Header
' {0,3}([-:]+ *\\|[-| :]*)' + // Align
'(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)', // Cells
table: '^ *\\|(.+)\\n' + // Header
' {0,3}\\|?( *[-:]+[-| :]*)' + // Align
'(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
})
gfm.nptable = edit(gfm.nptable)
.replace('hr', block.hr)
.replace('heading', ' {0,3}#{1,6} ')
.replace('blockquote', ' {0,3}>')
.replace('code', ' {4}[^\\n]')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
.getRegex()
gfm.table = edit(gfm.table)
.replace('hr', block.hr)
.replace('heading', ' {0,3}#{1,6} ')
.replace('blockquote', ' {0,3}>')
.replace('code', ' {4}[^\\n]')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
.getRegex()
/**
* Pedantic grammar (original John Gruber's loose markdown specification)
*/
@ -121,7 +147,7 @@ export const pedantic = Object.assign({}, normal, {
'\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
.getRegex(),
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
heading: /^(#{1,6})(.*)(?:\n+|$)/,
fences: noop, // fences not supported
paragraph: edit(normal._paragraph)
.replace('hr', block.hr)

View File

@ -1,7 +1,7 @@
import Renderer from './renderer'
import { normal, breaks, gfm, pedantic } from './inlineRules'
import defaultOptions from './options'
import { escape, findClosingBracket, getUniqueId } from './utils'
import { escape, findClosingBracket, getUniqueId, rtrim } from './utils'
import { validateEmphasize, lowerPriority } from '../utils'
/**
@ -107,42 +107,65 @@ InlineLexer.prototype.output = function (src) {
src = src.substring(cap[0].length)
lastChar = cap[0].charAt(cap[0].length - 1)
out += this.options.sanitize
? this.options.sanitizer
out += this.renderer.html(this.options.sanitize
? (this.options.sanitizer
? this.options.sanitizer(cap[0])
: escape(cap[0])
: cap[0]
: escape(cap[0]))
: cap[0])
continue
}
// link
cap = this.rules.link.exec(src)
if (cap && lowerPriority(src, cap[0].length, this.highPriorityLinkRules)) {
const lastParenIndex = findClosingBracket(cap[2], '()')
if (lastParenIndex > -1) {
const start = cap[0].indexOf('!') === 0 ? 5 : 4
const linkLen = start + cap[1].length + lastParenIndex
cap[2] = cap[2].substring(0, lastParenIndex)
cap[0] = cap[0].substring(0, linkLen).trim()
cap[3] = ''
const trimmedUrl = cap[2].trim()
if (!this.options.pedantic && trimmedUrl.startsWith('<')) {
// commonmark requires matching angle brackets
if (!trimmedUrl.endsWith('>')) {
return
}
// ending angle bracket cannot be escaped
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\')
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
return
}
} else {
// find closing parenthesis
const lastParenIndex = findClosingBracket(cap[2], '()')
if (lastParenIndex > -1) {
const start = cap[0].indexOf('!') === 0 ? 5 : 4
const linkLen = start + cap[1].length + lastParenIndex
cap[2] = cap[2].substring(0, lastParenIndex)
cap[0] = cap[0].substring(0, linkLen).trim()
cap[3] = ''
}
}
src = src.substring(cap[0].length)
lastChar = cap[0].charAt(cap[0].length - 1)
this.inLink = true
href = cap[2]
if (this.options.pedantic) {
// split pedantic href and title
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href)
if (link) {
href = link[1]
title = link[3]
} else {
title = ''
}
} else {
title = cap[3] ? cap[3].slice(1, -1) : ''
}
href = href.trim().replace(/^<([\s\S]*)>$/, '$1')
href = href.trim()
if (href.startsWith('<')) {
if (this.options.pedantic && !trimmedUrl.endsWith('>')) {
// pedantic allows starting angle bracket without ending angle bracket
href = href.slice(1)
} else {
href = href.slice(1, -1)
}
}
this.inLink = true
out += this.outputLink(cap, {
href: this.escapes(href),
title: this.escapes(title)
@ -234,7 +257,15 @@ InlineLexer.prototype.output = function (src) {
if (cap) {
src = src.substring(cap[0].length)
lastChar = cap[0].charAt(cap[0].length - 1)
out += this.renderer.codespan(escape(cap[2].trim(), true))
let text = cap[2].replace(/\n/g, ' ')
const hasNonSpaceChars = /[^ ]/.test(text)
const hasSpaceCharsOnBothEnds = text.startsWith(' ') && text.endsWith(' ')
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
text = text.substring(1, text.length - 1)
}
text = escape(text, true)
out += this.renderer.codespan(text)
continue
}
@ -252,7 +283,7 @@ InlineLexer.prototype.output = function (src) {
if (cap) {
src = src.substring(cap[0].length)
lastChar = cap[0].charAt(cap[0].length - 1)
out += this.renderer.del(this.output(cap[1]))
out += this.renderer.del(this.output(cap[2]))
continue
}
@ -329,10 +360,11 @@ InlineLexer.prototype.escapes = function (text) {
InlineLexer.prototype.outputLink = function (cap, link) {
const href = link.href
const title = link.title ? escape(link.title) : null
const text = cap[1].replace(/\\([\[\]])/g, '$1') // eslint-disable-line no-useless-escape
return cap[0].charAt(0) !== '!'
? this.renderer.link(href, title, this.output(cap[1]))
: this.renderer.image(href, title, escape(cap[1]))
? this.renderer.link(href, title, this.output(text))
: this.renderer.image(href, title, escape(text))
}
/**

View File

@ -30,7 +30,7 @@ const inline = {
// patched
// allow inline math "$" and superscript ("?=[\\<!\[`*]" to "?=[\\<!\[`*\$^]")
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*\$^]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/, // emoji is patched in gfm
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*\$^]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/, // emoji is patched in gfm
// ------------------------
// extra
@ -47,7 +47,11 @@ const inline = {
// list of punctuation marks from common mark spec
// without ` and ] to workaround Rule 17 (inline code blocks/links)
inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~'
// without , to work around example 393
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~'
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex()
inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex()
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g
@ -62,12 +66,12 @@ inline.autolink = edit(inline.autolink)
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/
inline.tag = edit(inline.tag)
.replace('comment', block._comment)
.replace('comment', inline._comment)
.replace('attribute', inline._attribute)
.getRegex()
inline._label = /(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/
inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/ // eslint-disable-line no-control-regex
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/ // eslint-disable-line no-control-regex
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/
inline.link = edit(inline.link)
@ -110,13 +114,13 @@ export const gfm = Object.assign({}, normal, {
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~+(?=\S)([\s\S]*?\S)~+/,
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
// ------------------------
// patched
// allow inline math "$" and emoji ":" and superscrpt "^" ("?=[\\<!\[`*~]|" to "?=[\\<!\[`*~:\$^]|")
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~:\$^]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/,
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*~:\$^]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/,
// ------------------------
// extra

View File

@ -214,11 +214,13 @@ Lexer.prototype.token = function (src, top) {
cap = this.rules.fences.exec(src)
if (cap) {
src = src.substring(cap[0].length)
const raw = cap[0]
const text = indentCodeCompensation(raw, cap[3] || '')
this.tokens.push({
type: 'code',
codeBlockStyle: 'fenced',
lang: cap[2] ? cap[2].trim() : cap[2],
text: cap[3] || ''
text
})
continue
}
@ -227,10 +229,19 @@ Lexer.prototype.token = function (src, top) {
cap = this.rules.heading.exec(src)
if (cap) {
src = src.substring(cap[0].length)
let text = cap[2] || ''
if (cap[3] && !cap[3].startsWith(' ') && !/ +#+ *(?:\n+|$)/.test(cap[0])) {
text = (text + cap[3]).trim()
let text = cap[2] ? cap[2].trim() : ''
if (text.endsWith('#')) {
var trimmed = rtrim(text, '#')
if (this.options.pedantic) {
text = trimmed.trim()
} else if (!trimmed || trimmed.endsWith(' ')) {
// CommonMark requires space before trailing #s
text = trimmed.trim()
}
}
this.tokens.push({
type: 'heading',
headingStyle: 'atx',
@ -621,4 +632,32 @@ Lexer.prototype.token = function (src, top) {
}
}
function indentCodeCompensation (raw, text) {
const matchIndentToCode = raw.match(/^(\s+)(?:```)/)
if (matchIndentToCode === null) {
return text
}
const indentToCode = matchIndentToCode[1]
return text
.split('\n')
.map(node => {
const matchIndentInNode = node.match(/^\s+/)
if (matchIndentInNode === null) {
return node
}
const [indentInNode] = matchIndentInNode
if (indentInNode.length >= indentToCode.length) {
return node.slice(indentToCode.length)
}
return node
})
.join('\n')
}
export default Lexer

View File

@ -14,6 +14,9 @@ Slugger.prototype.slug = function (value) {
let slug = value
.toLowerCase()
.trim()
// remove html tags
.replace(/<[!\/a-z].*?>/ig, '') // eslint-disable-line no-useless-escape
// remove unwanted chars
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
.replace(/\s/g, '-')

View File

@ -15,6 +15,10 @@ TextRenderer.prototype.text = function (text) {
return text
}
TextRenderer.prototype.html = function (html) {
return html
}
TextRenderer.prototype.inlineMath = function (math, displayMode) {
return math
}

View File

@ -421,8 +421,7 @@
"example": 53,
"start_line": 1046,
"end_line": 1055,
"section": "Setext headings",
"shouldFail": true
"section": "Setext headings"
},
{
"markdown": " Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n",
@ -502,8 +501,7 @@
"example": 63,
"start_line": 1186,
"end_line": 1196,
"section": "Setext headings",
"shouldFail": true
"section": "Setext headings"
},
{
"markdown": "- Foo\n---\n",
@ -927,8 +925,7 @@
"example": 116,
"start_line": 1996,
"end_line": 2003,
"section": "Fenced code blocks",
"shouldFail": true
"section": "Fenced code blocks"
},
{
"markdown": "```\n``` aaa\n```\n",
@ -1312,8 +1309,7 @@
"example": 164,
"start_line": 2845,
"end_line": 2853,
"section": "Link reference definitions",
"shouldFail": true
"section": "Link reference definitions"
},
{
"markdown": "[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n",
@ -1353,8 +1349,7 @@
"example": 169,
"start_line": 2916,
"end_line": 2922,
"section": "Link reference definitions",
"shouldFail": true
"section": "Link reference definitions"
},
{
"markdown": "[foo]: <bar>(baz)\n\n[foo]\n",
@ -1370,8 +1365,7 @@
"example": 171,
"start_line": 2940,
"end_line": 2946,
"section": "Link reference definitions",
"shouldFail": true
"section": "Link reference definitions"
},
{
"markdown": "[foo]\n\n[foo]: url\n",
@ -1643,8 +1637,7 @@
"example": 205,
"start_line": 3464,
"end_line": 3476,
"section": "Block quotes",
"shouldFail": true
"section": "Block quotes"
},
{
"markdown": "> foo\n bar\n",
@ -1652,8 +1645,7 @@
"example": 206,
"start_line": 3482,
"end_line": 3492,
"section": "Block quotes",
"shouldFail": true
"section": "Block quotes"
},
{
"markdown": "> ```\nfoo\n```\n",
@ -1661,8 +1653,7 @@
"example": 207,
"start_line": 3495,
"end_line": 3505,
"section": "Block quotes",
"shouldFail": true
"section": "Block quotes"
},
{
"markdown": "> foo\n - bar\n",
@ -1806,8 +1797,7 @@
"example": 225,
"start_line": 3834,
"end_line": 3843,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "- one\n\n two\n",
@ -1823,8 +1813,7 @@
"example": 227,
"start_line": 3860,
"end_line": 3870,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": " - one\n\n two\n",
@ -1864,8 +1853,7 @@
"example": 232,
"start_line": 3954,
"end_line": 3966,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n",
@ -1881,8 +1869,7 @@
"example": 234,
"start_line": 3999,
"end_line": 4017,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "123456789. ok\n",
@ -1954,8 +1941,7 @@
"example": 243,
"start_line": 4133,
"end_line": 4149,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "1. indented code\n\n paragraph\n\n more code\n",
@ -1963,8 +1949,7 @@
"example": 244,
"start_line": 4155,
"end_line": 4171,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": " foo\n\nbar\n",
@ -1980,8 +1965,7 @@
"example": 246,
"start_line": 4192,
"end_line": 4201,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "- foo\n\n bar\n",
@ -1997,8 +1981,7 @@
"example": 248,
"start_line": 4237,
"end_line": 4258,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "- \n foo\n",
@ -2014,8 +1997,7 @@
"example": 250,
"start_line": 4277,
"end_line": 4286,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "- foo\n-\n- bar\n",
@ -2047,8 +2029,7 @@
"example": 254,
"start_line": 4336,
"end_line": 4342,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "foo\n*\n\nfoo\n1.\n",
@ -2136,8 +2117,7 @@
"example": 265,
"start_line": 4578,
"end_line": 4590,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "10) foo\n - bar\n",
@ -2153,8 +2133,7 @@
"example": 267,
"start_line": 4611,
"end_line": 4621,
"section": "List items",
"shouldFail": true
"section": "List items"
},
{
"markdown": "- - foo\n",
@ -2210,8 +2189,7 @@
"example": 274,
"start_line": 5005,
"end_line": 5011,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "The number of windows in my house is\n1. The number of doors is 6.\n",
@ -2227,8 +2205,7 @@
"example": 276,
"start_line": 5029,
"end_line": 5048,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- foo\n - bar\n - baz\n\n\n bim\n",
@ -2236,8 +2213,7 @@
"example": 277,
"start_line": 5050,
"end_line": 5072,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- foo\n- bar\n\n<!-- -->\n\n- baz\n- bim\n",
@ -2261,8 +2237,7 @@
"example": 280,
"start_line": 5132,
"end_line": 5150,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "1. a\n\n 2. b\n\n 3. c\n",
@ -2270,8 +2245,7 @@
"example": 281,
"start_line": 5153,
"end_line": 5171,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- a\n - b\n - c\n - d\n - e\n",
@ -2279,8 +2253,7 @@
"example": 282,
"start_line": 5177,
"end_line": 5191,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "1. a\n\n 2. b\n\n 3. c\n",
@ -2288,8 +2261,7 @@
"example": 283,
"start_line": 5197,
"end_line": 5214,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- a\n- b\n\n- c\n",
@ -2305,8 +2277,7 @@
"example": 285,
"start_line": 5242,
"end_line": 5257,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- a\n- b\n\n c\n- d\n",
@ -2322,8 +2293,7 @@
"example": 287,
"start_line": 5286,
"end_line": 5304,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- a\n- ```\n b\n\n\n ```\n- c\n",
@ -2331,8 +2301,7 @@
"example": 288,
"start_line": 5309,
"end_line": 5328,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- a\n - b\n\n c\n- d\n",
@ -2340,8 +2309,7 @@
"example": 289,
"start_line": 5335,
"end_line": 5353,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "* a\n > b\n >\n* c\n",
@ -2357,8 +2325,7 @@
"example": 291,
"start_line": 5379,
"end_line": 5397,
"section": "Lists",
"shouldFail": true
"section": "Lists"
},
{
"markdown": "- a\n",
@ -2502,8 +2469,7 @@
"example": 309,
"start_line": 5628,
"end_line": 5634,
"section": "Backslash escapes",
"shouldFail": true
"section": "Backslash escapes"
},
{
"markdown": "``` foo\\+bar\nfoo\n```\n",
@ -2543,8 +2509,7 @@
"example": 314,
"start_line": 5715,
"end_line": 5725,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "&copy\n",
@ -2576,8 +2541,7 @@
"example": 318,
"start_line": 5760,
"end_line": 5764,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "[foo]\n\n[foo]: /f&ouml;&ouml; \"f&ouml;&ouml;\"\n",
@ -2585,8 +2549,7 @@
"example": 319,
"start_line": 5767,
"end_line": 5773,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "``` f&ouml;&ouml;\nfoo\n```\n",
@ -2770,8 +2733,7 @@
"example": 342,
"start_line": 6012,
"end_line": 6016,
"section": "Code spans",
"shouldFail": true
"section": "Code spans"
},
{
"markdown": "`<a href=\"`\">`\n",
@ -2979,8 +2941,7 @@
"example": 368,
"start_line": 6465,
"end_line": 6469,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo*bar\n",
@ -3012,8 +2973,7 @@
"example": 372,
"start_line": 6506,
"end_line": 6510,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "_foo_bar\n",
@ -3141,8 +3101,7 @@
"example": 388,
"start_line": 6648,
"end_line": 6652,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "foo-__(bar)__\n",
@ -3158,8 +3117,7 @@
"example": 390,
"start_line": 6672,
"end_line": 6676,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "**(**foo)\n",
@ -3247,8 +3205,7 @@
"example": 401,
"start_line": 6775,
"end_line": 6779,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "__(bar)__.\n",
@ -3288,8 +3245,7 @@
"example": 406,
"start_line": 6824,
"end_line": 6828,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "__foo_ bar_\n",
@ -3297,8 +3253,7 @@
"example": 407,
"start_line": 6831,
"end_line": 6835,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo *bar**\n",
@ -3338,8 +3293,7 @@
"example": 412,
"start_line": 6888,
"end_line": 6892,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo **bar***\n",
@ -3347,8 +3301,7 @@
"example": 413,
"start_line": 6895,
"end_line": 6899,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo**bar***\n",
@ -3356,8 +3309,7 @@
"example": 414,
"start_line": 6902,
"end_line": 6906,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "foo***bar***baz\n",
@ -3365,8 +3317,7 @@
"example": 415,
"start_line": 6913,
"end_line": 6917,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "foo******bar*********baz\n",
@ -3374,8 +3325,7 @@
"example": 416,
"start_line": 6919,
"end_line": 6923,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo **bar *baz* bim** bop*\n",
@ -3383,8 +3333,7 @@
"example": 417,
"start_line": 6928,
"end_line": 6932,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo [*bar*](/url)*\n",
@ -3392,8 +3341,7 @@
"example": 418,
"start_line": 6935,
"end_line": 6939,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "** is not an empty emphasis\n",
@ -3441,8 +3389,7 @@
"example": 424,
"start_line": 6990,
"end_line": 6994,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "____foo__ bar__\n",
@ -3450,8 +3397,7 @@
"example": 425,
"start_line": 6997,
"end_line": 7001,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "**foo **bar****\n",
@ -3499,8 +3445,7 @@
"example": 431,
"start_line": 7041,
"end_line": 7047,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "**foo [*bar*](/url)**\n",
@ -3580,8 +3525,7 @@
"example": 441,
"start_line": 7122,
"end_line": 7126,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo**\n",
@ -3589,8 +3533,7 @@
"example": 442,
"start_line": 7129,
"end_line": 7133,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "***foo**\n",
@ -3598,8 +3541,7 @@
"example": 443,
"start_line": 7136,
"end_line": 7140,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "****foo*\n",
@ -3607,8 +3549,7 @@
"example": 444,
"start_line": 7143,
"end_line": 7147,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "**foo***\n",
@ -3616,8 +3557,7 @@
"example": 445,
"start_line": 7150,
"end_line": 7154,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo****\n",
@ -3625,8 +3565,7 @@
"example": 446,
"start_line": 7157,
"end_line": 7161,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "foo ___\n",
@ -3682,8 +3621,7 @@
"example": 453,
"start_line": 7209,
"end_line": 7213,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "_foo__\n",
@ -3691,8 +3629,7 @@
"example": 454,
"start_line": 7220,
"end_line": 7224,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "___foo__\n",
@ -3700,8 +3637,7 @@
"example": 455,
"start_line": 7227,
"end_line": 7231,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "____foo_\n",
@ -3709,8 +3645,7 @@
"example": 456,
"start_line": 7234,
"end_line": 7238,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "__foo___\n",
@ -3718,8 +3653,7 @@
"example": 457,
"start_line": 7241,
"end_line": 7245,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "_foo____\n",
@ -3727,8 +3661,7 @@
"example": 458,
"start_line": 7248,
"end_line": 7252,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "**foo**\n",
@ -3784,8 +3717,7 @@
"example": 465,
"start_line": 7307,
"end_line": 7311,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "***foo***\n",
@ -3793,8 +3725,7 @@
"example": 466,
"start_line": 7316,
"end_line": 7320,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "_____foo_____\n",
@ -3802,8 +3733,7 @@
"example": 467,
"start_line": 7323,
"end_line": 7327,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo _bar* baz_\n",
@ -3827,8 +3757,7 @@
"example": 470,
"start_line": 7348,
"end_line": 7352,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*foo *bar baz*\n",
@ -3836,8 +3765,7 @@
"example": 471,
"start_line": 7355,
"end_line": 7359,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "*[bar*](/url)\n",
@ -3885,8 +3813,7 @@
"example": 477,
"start_line": 7399,
"end_line": 7403,
"section": "Emphasis and strong emphasis",
"shouldFail": true
"section": "Emphasis and strong emphasis"
},
{
"markdown": "_a `_`_\n",
@ -3958,8 +3885,7 @@
"example": 486,
"start_line": 7543,
"end_line": 7547,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link](foo\nbar)\n",
@ -3983,8 +3909,7 @@
"example": 489,
"start_line": 7571,
"end_line": 7575,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link](<foo\\>)\n",
@ -3992,8 +3917,7 @@
"example": 490,
"start_line": 7579,
"end_line": 7583,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[a](<b)c\n[a](<b)c>\n[a](<b>c)\n",
@ -4001,8 +3925,7 @@
"example": 491,
"start_line": 7588,
"end_line": 7596,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link](\\(foo\\))\n",
@ -4066,8 +3989,7 @@
"example": 499,
"start_line": 7676,
"end_line": 7680,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link](\"title\")\n",
@ -4099,8 +4021,7 @@
"example": 503,
"start_line": 7720,
"end_line": 7724,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link](/url \"title \"and\" title\")\n",
@ -4140,8 +4061,7 @@
"example": 508,
"start_line": 7783,
"end_line": 7787,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link] bar](/uri)\n",
@ -4189,8 +4109,7 @@
"example": 514,
"start_line": 7829,
"end_line": 7833,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[foo *[bar [baz](/uri)](/uri)*](/uri)\n",
@ -4198,8 +4117,7 @@
"example": 515,
"start_line": 7836,
"end_line": 7840,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "![[[foo](uri1)](uri2)](uri3)\n",
@ -4207,8 +4125,7 @@
"example": 516,
"start_line": 7843,
"end_line": 7847,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "*[foo*](/uri)\n",
@ -4272,8 +4189,7 @@
"example": 524,
"start_line": 7947,
"end_line": 7953,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n",
@ -4305,8 +4221,7 @@
"example": 528,
"start_line": 7987,
"end_line": 7993,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n",
@ -4314,8 +4229,7 @@
"example": 529,
"start_line": 7996,
"end_line": 8002,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "*[foo*][ref]\n\n[ref]: /uri\n",
@ -4339,8 +4253,7 @@
"example": 532,
"start_line": 8032,
"end_line": 8038,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[foo`][ref]`\n\n[ref]: /uri\n",
@ -4348,8 +4261,7 @@
"example": 533,
"start_line": 8041,
"end_line": 8047,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[foo<http://example.com/?search=][ref]>\n\n[ref]: /uri\n",
@ -4357,8 +4269,7 @@
"example": 534,
"start_line": 8050,
"end_line": 8056,
"section": "Links",
"shouldFail": true
"section": "Links"
},
{
"markdown": "[foo][BaR]\n\n[bar]: /url \"title\"\n",
@ -4646,8 +4557,7 @@
"example": 570,
"start_line": 8499,
"end_line": 8503,
"section": "Images",
"shouldFail": true
"section": "Images"
},
{
"markdown": "![foo [bar](/url)](/url2)\n",
@ -4655,8 +4565,7 @@
"example": 571,
"start_line": 8506,
"end_line": 8510,
"section": "Images",
"shouldFail": true
"section": "Images"
},
{
"markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n",
@ -4872,8 +4781,7 @@
"example": 598,
"start_line": 8787,
"end_line": 8791,
"section": "Autolinks",
"shouldFail": true
"section": "Autolinks"
},
{
"markdown": "<http://example.com/\\[\\>\n",
@ -4921,8 +4829,7 @@
"example": 604,
"start_line": 8850,
"end_line": 8854,
"section": "Autolinks",
"shouldFail": true
"section": "Autolinks"
},
{
"markdown": "<m:abc>\n",
@ -4946,8 +4853,7 @@
"example": 607,
"start_line": 8871,
"end_line": 8875,
"section": "Autolinks",
"shouldFail": true
"section": "Autolinks"
},
{
"markdown": "foo@bar.example.com\n",
@ -4955,8 +4861,7 @@
"example": 608,
"start_line": 8878,
"end_line": 8882,
"section": "Autolinks",
"shouldFail": true
"section": "Autolinks"
},
{
"markdown": "<a><bab><c2c>\n",
@ -5068,8 +4973,7 @@
"example": 622,
"start_line": 9087,
"end_line": 9091,
"section": "Raw HTML",
"shouldFail": true
"section": "Raw HTML"
},
{
"markdown": "foo <!--> foo -->\n\nfoo <!-- foo--->\n",
@ -5077,8 +4981,7 @@
"example": 623,
"start_line": 9096,
"end_line": 9103,
"section": "Raw HTML",
"shouldFail": true
"section": "Raw HTML"
},
{
"markdown": "foo <?php echo $a; ?>\n",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,34 @@
## Compare with `marked.js`
Marked.js failed examples count: 1
Mark Text failed examples count: 1
Mark Text failed examples count: 0
There are 0 examples are different with marked.js.
**Example653**
Mark Text success and marked.js fail
```markdown
Markdown content
<strong> <title> <style> <em>
<blockquote>
<xmp> is disallowed. <XMP> is also disallowed.
</blockquote>
Expected Html
<p><strong> &lt;title> &lt;style> <em></p>
<blockquote>
&lt;xmp> is disallowed. &lt;XMP> is also disallowed.
</blockquote>
Actural Html
<p><strong> <title> <style> <em></p>
<blockquote>
<xmp> is disallowed. <XMP> is also disallowed.
</blockquote>
marked.js html
<p><strong> <title> <style> <em></p>
<blockquote>
<xmp> is disallowed. <XMP> is also disallowed.
</blockquote>
```
There are 1 examples are different with marked.js.

View File

@ -115,8 +115,8 @@
},
{
"section": "Autolinks",
"html": "<p><a href=\"http://commonmark.org\">http://commonmark.org</a></p>\n<p>(Visit <a href=\"https://encrypted.google.com/search?q=Markup+(business)\">https://encrypted.google.com/search?q=Markup+(business)</a>)</p>\n<p>Anonymous FTP is available at <a href=\"ftp://foo.bar.baz\">ftp://foo.bar.baz</a>.</p>",
"markdown": "http://commonmark.org\n\n(Visit https://encrypted.google.com/search?q=Markup+(business))\n\nAnonymous FTP is available at ftp://foo.bar.baz.",
"html": "<p><a href=\"http://commonmark.org\">http://commonmark.org</a></p>\n<p>(Visit <a href=\"https://encrypted.google.com/search?q=Markup+(business)\">https://encrypted.google.com/search?q=Markup+(business)</a>)</p>",
"markdown": "http://commonmark.org\n\n(Visit https://encrypted.google.com/search?q=Markup+(business))",
"example": 628
},
{
@ -141,7 +141,6 @@
"section": "Disallowed Raw HTML",
"html": "<p><strong> &lt;title> &lt;style> <em></p>\n<blockquote>\n &lt;xmp> is disallowed. &lt;XMP> is also disallowed.\n</blockquote>",
"markdown": "<strong> <title> <style> <em>\n\n<blockquote>\n <xmp> is disallowed. <XMP> is also disallowed.\n</blockquote>",
"example": 653,
"shouldFail": true
"example": 653
}
]

View File

@ -1,6 +1,6 @@
## Test Result
Total test 24 examples, and failed 1 examples:
Total test 24 examples, and failed 0 examples:
| Section | Failed/Total | Percentage |
|:-----------------:|:-------------:|:-------------:|
@ -8,26 +8,5 @@ Total test 24 examples, and failed 1 examples:
| Task list items | 0/2 | 100.00% |
| Strikethrough | 0/2 | 100.00% |
| Autolinks | 0/11 | 100.00% |
|Disallowed Raw HTML| 1/1 | 0.00% |
**Example653**
```markdown
Markdown content
<strong> <title> <style> <em>
<blockquote>
<xmp> is disallowed. <XMP> is also disallowed.
</blockquote>
Expected Html
<p><strong> &lt;title> &lt;style> <em></p>
<blockquote>
&lt;xmp> is disallowed. &lt;XMP> is also disallowed.
</blockquote>
Actural Html
<p><strong> <title> <style> <em></p>
<blockquote>
<xmp> is disallowed. <XMP> is also disallowed.
</blockquote>
```
|Disallowed Raw HTML| 0/1 | 100.00% |