You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
basically, when converting (possibly rendered) html <pre> or <code> block that contains some tags inside them, these extra tags will be included in the converted markdown output verbatim, which could results in the converted markdown that looks quite different from what the source markdown was or what the input html would renders to, and from what I could make out from <pre> and <code> docs, these tags does allow its content to contain some other tags.
some cases where this could happen:
converting output from whatever html renderer that really, really likes using <br> for newline even in these blocks
converting a code block that used <span> inside the block for the purpose of syntax highlighting
How to reproduce
note: all these examples were run with strip_tags option enabled, but otherwise using default converters and options
first case: <br> usage for newlines inside <pre><code>
input
(yes it's all in one line)
<pre><code># When I first wrote this regex I thought it was slick.<br># I still think that, but 2y after doing it the first time<br># it just hurt to look at. So, /x modifier we go!<br><br>my @Set = map { [ split( m/\s*:\s*/, $_, 2 ) ] } $args =~ m/<br> \s* # ignore preceeding whitespace<br> ( # begin capturing<br> (?: # grab characters we want<br> \\. # skip over escapes<br> | <br> [^;] # or anything but a ; <br> )+? # ? greedyness hack lets the \s* actually match<br> ) # end capturing<br> \s* # ignore whitespace between value and ; or end of line<br> (?: # stop anchor at ...<br> ; # semicolon<br> | # or<br> $ # end of line<br> ) <br> \s*/gx;<br></code></pre>
expected
(no actual markdown source to compare so this is an approximation of what I expect to see)
```# When I first wrote this regex I thought it was slick.# I still think that, but 2y after doing it the first time# it just hurt to look at. So, /x modifier we go!my @Set = map { [ split( m/\s*:\s*/, $_, 2 ) ] } $args =~ m/ \s* # ignore preceeding whitespace ( # begin capturing (?: # grab characters we want \\. # skip over escapes | [^;] # or anything but a ; )+? # ? greedyness hack lets the \s* actually match ) # end capturing \s* # ignore whitespace between value and ; or end of line (?: # stop anchor at ... ; # semicolon | # or $ # end of line ) \s*/gx;```
html-to-markdown output
```# When I first wrote this regex I thought it was slick.<br></br># I still think that, but 2y after doing it the first time<br></br># it just hurt to look at. So, /x modifier we go!<br></br><br></br>my @Set = map { [ split( m/\s*:\s*/, $_, 2 ) ] } $args =~ m/<br></br> \s* # ignore preceeding whitespace<br></br> ( # begin capturing<br></br> (?: # grab characters we want<br></br> \. # skip over escapes<br></br> | <br></br> [^;] # or anything but a ; <br></br> )+? # ? greedyness hack lets the \s* actually match<br></br> ) # end capturing<br></br> \s* # ignore whitespace between value and ; or end of line<br></br> (?: # stop anchor at ...<br></br> ; # semicolon<br></br> | # or<br></br> $ # end of line<br></br> ) <br></br> \s*/gx;<br></br>```
Version(s) affected
5.1.1
Description
basically, when converting (possibly rendered) html
<pre>
or<code>
block that contains some tags inside them, these extra tags will be included in the converted markdown output verbatim, which could results in the converted markdown that looks quite different from what the source markdown was or what the input html would renders to, and from what I could make out from<pre>
and<code>
docs, these tags does allow its content to contain some other tags.some cases where this could happen:
<br>
for newline even in these blocks<span>
inside the block for the purpose of syntax highlightingHow to reproduce
note: all these examples were run with
strip_tags
option enabled, but otherwise using default converters and optionsfirst case:
<br>
usage for newlines inside<pre><code>
input
(yes it's all in one line)
expected
(no actual markdown source to compare so this is an approximation of what I expect to see)
html-to-markdown
outputsecond case: mixing
<span>
inside<pre>
/<code>
input
expected
html-to-markdown
outputThe text was updated successfully, but these errors were encountered: