Closed cabo closed 2 years ago
The backslash insert is done here: https://github.com/gettalong/kramdown/blob/master/lib/kramdown/converter/kramdown.rb#L78-L80
I think the code should actually read:
end.gsub(/\s+/, ' ').gsub(ESCAPED_CHAR_RE) do
$1 || !opts[:prev] || opts[:prev].type == :br ? "\\#{$1 || $2}" : $&
end
But have to think a bit more about it.
Ah. I now understand the bug.
$ kramdown -o kramdown <<HERE
a:
*a*:
a*:*
HERE
➔
a:
*a*\:
a*\:*
So the code is trying to protect against spuriously generating definition lists?
But ^[ ]{0,3}(:)
is matching against the text item, so starting a new text item with a ":" triggers the backslash.
Instead, it needs to see whether the text item starting with a ":" lands on a new line on the output.
Couldn't a ":" start a new line in convert_p
with :line_width set?
Yep:
kramdown -o kramdown <<HERE | kramdown
aa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa : aa aaaa aaaa aaaa
HERE
➔
<dl>
<dt>aa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa</dt>
<dd>aa aaaa aaaa aaaa</dd>
</dl>
It's really not that easy to generate markdown...
I'd probably do this two-pass:
:
for the dt:
to \:
and:
Thanks for the second test case which needed another fix. I will push the commit with the fix later (when it is actually committed and tested ;-)
@cabo The latest commit contains the fixes for the bugs.
I can report that the fix works for my use case. Thank you!
Now what I need is a release so this bug fix trickles into a few production servers...
@cabo Will do when I have time, probably on the weekend
@cabo Release follows shortly
➔
I can't find the code that does this backslash insertion. The inserted backslash is stable over further
kramdown -o kramdown
sequences, but other processors don't like a backslash there (i.e., show it).