srid/emanote

Wrong rendering of HTML blocks

kukimik opened this issue · 4 comments

Describe the bug
HTML blocks in markdown documents are not rendered properly. Check the example below.

To Reproduce
I use the current HEAD version of Emanote (i.e. 7063381).

Create a .md file with the following content:

aaaa

<details>

**bbb** ccc *ddd*

</details>

eee

Emanote generates the following HTML:

    <p class="mb-3">
      aaaa
    </p>
  <div xmlhtmlraw=""><details>
</details></div>
    <p class="mb-3">
      <strong>bbb</strong> ccc <em>ddd</em>
    </p>
  <div xmlhtmlraw="">
</div>
    <p class="mb-3">
      eee
    </p>

Expected behavior

See the CommonMark Spec on HTML blocks.
The reference Commonmark implementation https://spec.commonmark.org/dingus/ converts this to:

<p>aaaa</p>
<details>
<p><strong>bbb</strong> ccc <em>ddd</em></p>
</details>
<p>eee</p>

I would expect similar output.

Additional context
I'm especially interested in the <details> tag to create an effect similar to this:

bbb ccc ddd

However, the problem probably also applies to other HTML tags.

#23 may be related.

srid commented

Isn't this an issue with upstream library which emanote uses? https://github.com/jgm/commonmark-hs

Probably not. The commonmark-cli tool with all extensions turned on (commonmark -x all) parses this correctly. This could be something about the order of the extensions, but I don't think so. Unfortunately at the moment I don't have time to diagnose this properly.

Emanote.Model.Note.parseNoteMarkdown returns (checked via traceShowId):

[
Para [Str "aaaa"]
,RawBlock (Format "html") "<details>\n"
,Para [Strong [Str "bbb"],Space,Str "ccc",Space,Emph [Str "ddd"]]
,RawBlock (Format "html") "</details>\n"
,Para [Str "eee"]
]

This looks correct.

<span><span> just outright errors out for me which is fun /s to see.

[Info#ema.ws.364] Connected
span cannot contain text looking like its end tag
CallStack (from HasCallStack):
  error, called at src/Text/XmlHtml/HTML/Render.hs:133:9 in xmlhtml-0.2.5.4-DHjeAs4exZFKFYPJOci4Cd:Text.XmlHtml.HTML.Render