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
{{ message }}
This repository was archived by the owner on Jul 2, 2026. It is now read-only.
I'm parsing markdown files with earkmark and hooking into the postprocess to highlight the code with makeup. I noticed that the code earmark parsed does not properly preserve whitespace and therefore also the highlighted code doesn't render correctly:
"""
```xml
<!-- Basic element with attributes -->
<book id="b1" category="fiction" inStock="yes">
<title>The Great Gatsby</title>
<!-- Multiple elements of same type -->
<author>F. Scott Fitzgerald</author>
<published>1925</published>
<!-- CDATA section for text with special characters -->
<description><![CDATA[A story about the American Dream & society in the 1920s]]></description>
</book>
```
"""
|> Earmark.as_html!(
escape: false,
postprocessor: fn
{"code", _attrs, [body], _meta} = node ->
IO.puts(body)
node
node ->
node
end
)
This outputs
<!-- Basic element with attributes -->
<book id="b1" category="fiction" inStock="yes">
<title>The Great Gatsby</title>
<!-- Multiple elements of same type -->
<author>F. Scott Fitzgerald</author>
<published>1925</published>
<!-- CDATA section for text with special characters -->
<description><![CDATA[A story about the American Dream & society in the 1920s]]></description>
</book>
while it should output
<!-- Basic element with attributes -->
<book id="b1" category="fiction" inStock="yes">
<title>The Great Gatsby</title>
<!-- Multiple elements of same type -->
<author>F. Scott Fitzgerald</author>
<published>1925</published>
<!-- CDATA section for text with special characters -->
<description><![CDATA[A story about the American Dream & society in the 1920s]]></description>
</book>
Hi there,
I'm parsing markdown files with earkmark and hooking into the postprocess to highlight the code with makeup. I noticed that the code earmark parsed does not properly preserve whitespace and therefore also the highlighted code doesn't render correctly:
This outputs
while it should output
Using earmark 1.4.47.