From 57f6d89aff3022077f0ecc7773bbe7d1f285b82d Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Mon, 1 Jul 2019 08:30:41 -0500 Subject: [PATCH] improve heading --- lib/marked.js | 6 ++++-- test/specs/commonmark/commonmark.0.29.json | 12 ++++-------- test/specs/new/nogfm_hashtag.md | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index 905d30eb17..9b0878872f 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -16,7 +16,7 @@ var block = { code: /^( {4}[^\n]+\n*)+/, fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/, hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, - heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/, + heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\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 @@ -125,7 +125,9 @@ block.pedantic = merge({}, block.normal, { + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b') .getRegex(), - def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/ + def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, + heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/, + fences: noop // fences not supported }); /** diff --git a/test/specs/commonmark/commonmark.0.29.json b/test/specs/commonmark/commonmark.0.29.json index 60cad5d726..1050702822 100644 --- a/test/specs/commonmark/commonmark.0.29.json +++ b/test/specs/commonmark/commonmark.0.29.json @@ -262,8 +262,7 @@ "example": 33, "start_line": 787, "end_line": 791, - "section": "ATX headings", - "shouldFail": true + "section": "ATX headings" }, { "markdown": "#5 bolt\n\n#hashtag\n", @@ -271,8 +270,7 @@ "example": 34, "start_line": 802, "end_line": 809, - "section": "ATX headings", - "shouldFail": true + "section": "ATX headings" }, { "markdown": "\\## foo\n", @@ -360,8 +358,7 @@ "example": 45, "start_line": 915, "end_line": 919, - "section": "ATX headings", - "shouldFail": true + "section": "ATX headings" }, { "markdown": "### foo \\###\n## foo #\\##\n# foo \\#\n", @@ -369,8 +366,7 @@ "example": 46, "start_line": 925, "end_line": 933, - "section": "ATX headings", - "shouldFail": true + "section": "ATX headings" }, { "markdown": "****\n## foo\n****\n", diff --git a/test/specs/new/nogfm_hashtag.md b/test/specs/new/nogfm_hashtag.md index 4b805db481..a058b3eb44 100644 --- a/test/specs/new/nogfm_hashtag.md +++ b/test/specs/new/nogfm_hashtag.md @@ -1,5 +1,6 @@ --- gfm: false +pedantic: true --- #header