`\mathrm` after rendering generate unwanted '>' char
Sped0n opened this issue · 8 comments
Please tell me your mdBook-KaTeX version, provide me the related section in your book.toml
.
Please also copy the rendered HTML if you know how to do that.
preprcocessor version
Polling registry 'https://index.crates.io/'.
Package Installed Latest Needs update
mdbook-katex v0.5.3 v0.5.3 No
No packages need updating.
Overall updated 0 packages.
bool.toml
[book]
authors = ["Sped0n"]
language = "en"
multilingual = false
src = "src"
title = "data-structure"
[preprocessor.katex]
after = ["links"]
rendered html
first one
<blockquote>
<p>
<span class="katex-display">
<span class="katex">
<span class="katex-html" aria-hidden="true">
<span class="base"><span class="strut" style="height: 0.5782em; vertical-align: -0.0391em;"></span><span class="mrel">></span><span class="mspace" style="margin-right: 0.2778em;"></span></span>
<span class="base">
<span class="strut" style="height: 2.2954em; vertical-align: -0.7693em;"></span>
<span class="mord">
<span class="mord">
<span class="mord mathrm">n</span>
<span class="msupsub">
<span class="vlist-t vlist-t2">
<span class="vlist-r">
<span class="vlist" style="height: 0.1514em;">
<span style="top: -2.55em; margin-left: 0em; margin-right: 0.05em;">
<span class="pstrut" style="height: 2.7em;"></span>
<span class="sizing reset-size6 size3 mtight">
<span class="mord mtight"><span class="mord mathrm mtight">max</span></span>
</span>
</span>
</span>
<span class="vlist-s"></span>
</span>
<span class="vlist-r">
<span class="vlist" style="height: 0.15em;"><span></span></span>
</span>
</span>
</span>
</span>
<span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span>
<span class="mord">
<span class="mopen nulldelimiter"></span>
<span class="mfrac">
<span class="vlist-t vlist-t2">
<span class="vlist-r">
<span class="vlist" style="height: 1.5261em;">
<span style="top: -2.314em;">
<span class="pstrut" style="height: 3em;"></span>
<span class="mord">
<span class="mord mathrm">m</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span>
<span class="mord mathrm">1</span>
</span>
</span>
<span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span>
<span style="top: -3.677em;">
<span class="pstrut" style="height: 3em;"></span>
<span class="mord">
<span class="mord">
<span class="mord mathrm">m</span>
<span class="msupsub">
<span class="vlist-t">
<span class="vlist-r">
<span class="vlist" style="height: 0.8491em;">
<span style="top: -3.063em; margin-right: 0.05em;">
<span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">h</span></span>
</span>
</span>
</span>
</span>
</span>
</span>
<span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathrm">1</span>
</span>
</span>
</span>
<span class="vlist-s"></span>
</span>
<span class="vlist-r">
<span class="vlist" style="height: 0.7693em;"><span></span></span>
</span>
</span>
</span>
<span class="mclose nulldelimiter"></span>
</span>
</span>
<span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">></span>
</span>
</span>
</span>
</span>
</p>
</blockquote>
second one
<blockquote>
<p>
<span class="katex-display">
<span class="katex">
<span class="katex-html" aria-hidden="true">
<span class="base"><span class="strut" style="height: 0.5782em; vertical-align: -0.0391em;"></span><span class="mrel">></span><span class="mspace" style="margin-right: 0.2778em;"></span></span>
<span class="base">
<span class="strut" style="height: 2.2954em; vertical-align: -0.7693em;"></span>
<span class="mord">
<span class="mrel amsrm">∵</span><span class="mspace" style="margin-right: 0.2778em;"></span>
<span class="mord">
<span class="mord mathrm">n</span>
<span class="msupsub">
<span class="vlist-t vlist-t2">
<span class="vlist-r">
<span class="vlist" style="height: 0.1514em;">
<span style="top: -2.55em; margin-left: 0em; margin-right: 0.05em;">
<span class="pstrut" style="height: 2.7em;"></span>
<span class="sizing reset-size6 size3 mtight">
<span class="mord mtight"><span class="mord mathrm mtight">max</span></span>
</span>
</span>
</span>
<span class="vlist-s"></span>
</span>
<span class="vlist-r">
<span class="vlist" style="height: 0.15em;"><span></span></span>
</span>
</span>
</span>
</span>
<span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span>
<span class="mord">
<span class="mopen nulldelimiter"></span>
<span class="mfrac">
<span class="vlist-t vlist-t2">
<span class="vlist-r">
<span class="vlist" style="height: 1.5261em;">
<span style="top: -2.314em;">
<span class="pstrut" style="height: 3em;"></span>
<span class="mord">
<span class="mord mathrm">m</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span>
<span class="mord mathrm">1</span>
</span>
</span>
<span style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span>
<span style="top: -3.677em;">
<span class="pstrut" style="height: 3em;"></span>
<span class="mord">
<span class="mord">
<span class="mord mathrm">m</span>
<span class="msupsub">
<span class="vlist-t">
<span class="vlist-r">
<span class="vlist" style="height: 0.8491em;">
<span style="top: -3.063em; margin-right: 0.05em;">
<span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">h</span></span>
</span>
</span>
</span>
</span>
</span>
</span>
<span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathrm">1</span>
</span>
</span>
</span>
<span class="vlist-s"></span>
</span>
<span class="vlist-r">
<span class="vlist" style="height: 0.7693em;"><span></span></span>
</span>
</span>
</span>
<span class="mclose nulldelimiter"></span>
</span>
</span>
</span>
<span class="mspace newline"></span>
<span class="base"><span class="strut" style="height: 0.5782em; vertical-align: -0.0391em;"></span><span class="mrel">></span><span class="mspace" style="margin-right: 0.2778em;"></span></span>
<span class="base">
<span class="strut" style="height: 1em; vertical-align: -0.25em;"></span>
<span class="mord">
<span class="mrel amsrm">∴</span><span class="mspace" style="margin-right: 0.2778em;"></span>
<span class="mord">
<span class="mord mathrm">h</span>
<span class="msupsub">
<span class="vlist-t vlist-t2">
<span class="vlist-r">
<span class="vlist" style="height: 0.3175em;">
<span style="top: -2.55em; margin-left: 0em; margin-right: 0.05em;">
<span class="pstrut" style="height: 2.7em;"></span>
<span class="sizing reset-size6 size3 mtight">
<span class="mord mtight"><span class="mord mathrm mtight">min</span></span>
</span>
</span>
</span>
<span class="vlist-s"></span>
</span>
<span class="vlist-r">
<span class="vlist" style="height: 0.15em;"><span></span></span>
</span>
</span>
</span>
</span>
<span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span>
<span class="mop">
<span class="mop">lo<span style="margin-right: 0.01389em;">g</span></span>
<span class="msupsub">
<span class="vlist-t vlist-t2">
<span class="vlist-r">
<span class="vlist" style="height: 0.0573em;">
<span style="top: -2.4559em; margin-right: 0.05em;">
<span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">m</span></span>
</span>
</span>
<span class="vlist-s"></span>
</span>
<span class="vlist-r">
<span class="vlist" style="height: 0.2441em;"><span></span></span>
</span>
</span>
</span>
</span>
<span class="mopen">(</span><span class="mord mathrm">n</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right: 0.2222em;"></span>
<span class="mopen">(</span><span class="mord mathrm">m</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span>
<span class="mord mathrm">1</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span>
<span class="mord mathrm">1</span><span class="mclose">)</span>
</span>
<span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">></span>
</span>
</span>
</span>
</span>
</p>
</blockquote>
Thanks for your clear version and book.toml
.
I see that you have these expressions in blockquotes. I am guessting that you put >
before every line of math expressions. The correct way (to use mdBook-KaTeX) would be to put >
only before the starting line of each math expression, no matter they have empty lines in them or not.
This is because mdBook-KaTeX takes everything between the delimiters as a math expression, pre-renders it into one single line of HTML, and sends the whole book back to mdBook, where mdBook renders it as ordinary Markdown.
Does this solve the problem for you?
This is the code for the above example.
```markdown
> $$
\mathrm{n_{max} = \frac{m^h-1}{m-1}}
$$
```
> $$
\mathrm{n_{max} = \frac{m^h-1}{m-1}}
$$
```markdown
> $$
> \mathrm{n_{max} = \frac{m^h-1}{m-1}}
> $$
```
> $$
> \mathrm{n_{max} = \frac{m^h-1}{m-1}}
> $$
```markdown
> $$
\mathrm{\because n_{max} = \frac{m^h-1}{m-1}}\\
\mathrm{\therefore h_{min} = \log_m(n\times (m-1) + 1)}
$$
```
> $$
\mathrm{\because n_{max} = \frac{m^h-1}{m-1}}\\
\mathrm{\therefore h_{min} = \log_m(n\times (m-1) + 1)}
$$
oops, my bad🤯
thanks for the thorough explanation
I'm glad that the problem is solved for you.
Apparently, some other renderers behave differently and prioritize quoteblocks over math expressions. mdBook-KaTeX is a pre-renderer, so I think it makes sense that we prioritize math expressions the most. However, we could prioritize quoteblocks, but it would require parsing them—we currently don't—and a more complicated codebase.