Code Monkey home page Code Monkey logo

Comments (8)

SichangHe avatar SichangHe commented on September 28, 2024 1

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.

from mdbook-katex.

Sped0n avatar Sped0n commented on September 28, 2024

btw inline rendering works fine

\mathrm{O(n)}
image

from mdbook-katex.

SichangHe avatar SichangHe commented on September 28, 2024

I cannot reproduce. This is what I see:
image

from mdbook-katex.

SichangHe avatar SichangHe commented on September 28, 2024

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.

from mdbook-katex.

Sped0n avatar Sped0n commented on September 28, 2024

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">&gt;</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">&gt;</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">&gt;</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">&gt;</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">&gt;</span>
          </span>
        </span>
      </span>
    </span>
  </p>
</blockquote>

from mdbook-katex.

SichangHe avatar SichangHe commented on September 28, 2024

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.

image

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?

from mdbook-katex.

SichangHe avatar SichangHe commented on September 28, 2024
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)}
$$

from mdbook-katex.

Sped0n avatar Sped0n commented on September 28, 2024

oops, my bad🀯
thanks for the thorough explanation

from mdbook-katex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.