rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
18.11k stars 1.63k forks source link

Some underscores replaced with `<em>` in equation blocks #2469

Closed alexdewar closed 2 hours ago

alexdewar commented 2 hours ago

Problem

I'm trying to render the following equation using mdbook's MathJax support:

$$ q_{r,a,c,ts} \leq process.commodity.constraint.value(up)_{r,a,c,ts} * \left( \sum_{flexible\ c} q_{r,a,c,ts} \right) $$

Which should look like this:

Image

Unfortunately, with mdbook it doesn't render at all and I'm just left with the raw text.

Steps

  1. Make a new markdown document containing the above equation
  2. Build it with mdbook
  3. View the result in your browser

Possible Solution(s)

Looking at the HTML output reveals:

<p>$$ q_{r,a,c,ts} \leq process.commodity.constraint.value(up)<em>{r,a,c,ts} * \left( \sum</em>{flexible\ c} q_{r,a,c,ts} \right) $$</p>

Notice the random <em> block in the middle of the equation. Presumably mdbook shouldn't be inserting any HTML into equation blocks, but in any case it's definitely wrong here.

Notes

No response

Version

v0.4.40

ehuss commented 2 hours ago

Thanks for the report! I believe you need to escape underscores with a backslash so they are not interpreted as emphasis. I think this is a duplicate of #662, so closing in favor of that. You may also want to check out mdbook-katex which has better math support.

alexdewar commented 1 hour ago

Ahhh I see. That did the trick. Thanks for your speedy response!