mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Merge pull request #578 from aidantwoods/fix/setext-heading-spaces
Fix setext heading space handling
This commit is contained in:
commit
cac63f6fcb
@ -705,8 +705,10 @@ class Parsedown
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chop($Line['text'], $Line['text'][0]) === '')
|
if (
|
||||||
{
|
chop(chop($Line['text'], ' '), $Line['text'][0]) === ''
|
||||||
|
and $Line['indent'] < 4
|
||||||
|
) {
|
||||||
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
|
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
|
||||||
|
|
||||||
return $Block;
|
return $Block;
|
||||||
|
12
test/data/setext_header_spaces.html
Normal file
12
test/data/setext_header_spaces.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<h1>trailing space</h1>
|
||||||
|
<h2>trailing space</h2>
|
||||||
|
<h1>leading and trailing space</h1>
|
||||||
|
<h2>leading and trailing space</h2>
|
||||||
|
<h1>1 leading space</h1>
|
||||||
|
<h2>1 leading space</h2>
|
||||||
|
<h1>3 leading spaces</h1>
|
||||||
|
<h2>3 leading spaces</h2>
|
||||||
|
<p>too many leading spaces
|
||||||
|
==</p>
|
||||||
|
<p>too many leading spaces
|
||||||
|
--</p>
|
29
test/data/setext_header_spaces.md
Normal file
29
test/data/setext_header_spaces.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
trailing space
|
||||||
|
==
|
||||||
|
|
||||||
|
trailing space
|
||||||
|
--
|
||||||
|
|
||||||
|
leading and trailing space
|
||||||
|
==
|
||||||
|
|
||||||
|
leading and trailing space
|
||||||
|
--
|
||||||
|
|
||||||
|
1 leading space
|
||||||
|
==
|
||||||
|
|
||||||
|
1 leading space
|
||||||
|
--
|
||||||
|
|
||||||
|
3 leading spaces
|
||||||
|
==
|
||||||
|
|
||||||
|
3 leading spaces
|
||||||
|
--
|
||||||
|
|
||||||
|
too many leading spaces
|
||||||
|
==
|
||||||
|
|
||||||
|
too many leading spaces
|
||||||
|
--
|
Loading…
Reference in New Issue
Block a user