lierdakil/pandoc-crossref

Unwanted `<br />` are inserted when using `eqnBlockTemplate` with HTML output

UlyssesZh opened this issue · 4 comments

test.yml:

tableEqns: true
eqnBlockTemplate: '<table><tr><td>$$t$$</td><td>$$i$$</td></tr></table>'

test.md:

$$x=y$$ {#eq:test}

Command:

pandoc -f markdown -t html5 -M crossrefYaml=test.yml -F pandoc-crossref test.md

Output:

<div id="eq:test">
<table><br />
<tr><br />
<td><br />
<span class="math display"><em>x</em> = <em>y</em></span><br />
</td><br />
<td><br />
<span class="math display">(1)</span><br />
</td><br />
</tr><br />
</table>
</div>

Seems that it is intended that we should use raw blocks.

tableEqns: true
eqnBlockTemplate: '`<table><tr><td>`{=html}$$t$$`</td><td>`{=html}$$i$$`</td></tr></table>`{=html}'

So there's some weirdness in the parser, but the <br/>s go away if you use the multiline yaml syntax:

---
tableEqns: true
eqnBlockTemplate: |
  <table><tr><td>$$t$$</td><td>$$i$$</td></tr></table>
---

$$e^{i\pi} = -1$${#eq:eq}

@eq:eq

nets us

<div id="eq:eq">
<table>
<tr>
<td>
<span
class="math display"><em>e</em><sup><em>i</em><em>π</em></sup> =  − 1</span>
</td>
<td>
<span class="math display">(1)</span>
</td>
</tr>
</table>
</div>
<p>eq. 1</p>

Is it a problem with the YAML parser?

Dunno, but AFAICT it's on the pandoc side. If you feed the following Markdown

---
eqnBlockTemplate: <table><tr><td>$$t$$</td><td>$$i$$</td></tr></table>
---

into pandoc -t native -s, you can see it inserts line breaks after each tag:

Pandoc
  Meta
    { unMeta =
        fromList
          [ ( "eqnBlockTemplate"
            , MetaInlines
                [ RawInline (Format "html") "<table>"
                , LineBreak
                , RawInline (Format "html") "<tr>"
                , LineBreak
                , RawInline (Format "html") "<td>"
                , LineBreak
                , Math DisplayMath "t"
                , LineBreak
                , RawInline (Format "html") "</td>"
                , LineBreak
                , RawInline (Format "html") "<td>"
                , LineBreak
                , Math DisplayMath "i"
                , LineBreak
                , RawInline (Format "html") "</td>"
                , LineBreak
                , RawInline (Format "html") "</tr>"
                , LineBreak
                , RawInline (Format "html") "</table>"
                ]
            )
          ]
    }
  []

You can also notice it's treating tags as inline, which it doesn't if you use multiline syntax. The <br/> seems unintentional, but the inline thing seems not.