Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
UlyssesZh opened this issue Nov 20, 2023 · 4 comments
Open

Comments

@UlyssesZh
Copy link

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>
@UlyssesZh
Copy link
Author

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}'

@lierdakil
Copy link
Owner

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>

@UlyssesZh
Copy link
Author

Is it a problem with the YAML parser?

@lierdakil
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants