Skip to content

Commit

Permalink
improve heading
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Jul 1, 2019
1 parent 900114a commit 57f6d89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 4 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
fences: noop // fences not supported
});

/**
Expand Down
12 changes: 4 additions & 8 deletions test/specs/commonmark/commonmark.0.29.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,15 @@
"example": 33,
"start_line": 787,
"end_line": 791,
"section": "ATX headings",
"shouldFail": true
"section": "ATX headings"
},
{
"markdown": "#5 bolt\n\n#hashtag\n",
"html": "<p>#5 bolt</p>\n<p>#hashtag</p>\n",
"example": 34,
"start_line": 802,
"end_line": 809,
"section": "ATX headings",
"shouldFail": true
"section": "ATX headings"
},
{
"markdown": "\\## foo\n",
Expand Down Expand Up @@ -360,17 +358,15 @@
"example": 45,
"start_line": 915,
"end_line": 919,
"section": "ATX headings",
"shouldFail": true
"section": "ATX headings"
},
{
"markdown": "### foo \\###\n## foo #\\##\n# foo \\#\n",
"html": "<h3>foo ###</h3>\n<h2>foo ###</h2>\n<h1>foo #</h1>\n",
"example": 46,
"start_line": 925,
"end_line": 933,
"section": "ATX headings",
"shouldFail": true
"section": "ATX headings"
},
{
"markdown": "****\n## foo\n****\n",
Expand Down
1 change: 1 addition & 0 deletions test/specs/new/nogfm_hashtag.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
gfm: false
pedantic: true
---
#header

Expand Down

0 comments on commit 57f6d89

Please sign in to comment.