mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(headers): Ensures that Markdown headers are preceded by a space
Changes subParser for headers to require a space or tab character before a header, so that ```md # Header ``` Is a valid header, whereas: ```md #Header ``` Is **not** rendered as a header.
This commit is contained in:
parent
be2ffc1845
commit
e6aaf3a1c9
|
@ -40,7 +40,7 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||
// ...
|
||||
// ###### Header 6
|
||||
//
|
||||
text = text.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) {
|
||||
text = text.replace(/^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) {
|
||||
var span = showdown.subParser('spanGamut')(m2, options, globals),
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
|
||||
hLevel = headerLevelStart - 1 + m1.length,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#Given
|
||||
# Given
|
||||
|
||||
#When
|
||||
# When
|
||||
|
||||
#Then
|
||||
# Then
|
||||
|
||||
foo
|
||||
===
|
||||
|
|
3
test/issues/#nnn.headers-require-spaces.html
Normal file
3
test/issues/#nnn.headers-require-spaces.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<h1 id="iamaheader">I am a header</h1>
|
||||
|
||||
<p>#I am not a header</p>
|
3
test/issues/#nnn.headers-require-spaces.md
Normal file
3
test/issues/#nnn.headers-require-spaces.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# I am a header
|
||||
|
||||
#I am not a header
|
Loading…
Reference in New Issue
Block a user