Giter Site home page Giter Site logo

Comments (4)

SichangHe avatar SichangHe commented on June 10, 2024 2

You're welcome. mdBook-KaTeX is designed for the user to have simple normal experience, not to work in a pipeline. For that purpose, it would probably be easier to use mdBook-KaTeX as a library. This is the function you want:

pub fn process_chapter(
raw_content: String,
inline_opts: Opts,
display_opts: Opts,
stylesheet_header: String,
extra_opts: ExtraOpts,
) -> String {

from mdbook-katex.

mgeisler avatar mgeisler commented on June 10, 2024

Hi @Demian101, actually, looking at this again, I don't think the output would ever have four backslashes.

The code above is what you see in the Gettext PO file: it backslash-escapes the \\ once more and so you end up with \\\\. However, when we generate Markdown using this translation, we remove one layer of backslashes.

So we should ultimately be converting

$$
\begin{array}{|c|c|c|c|c|}
\hline
1 & x_1 & x_2 & x_3 & out \\
\hline
0 & 1 & 1 & 0 & 0 \\
\hline
\end{array}
$$

into

$$ \\begin{array}{|c|c|c|c|c|} \\hline 1 & x_1 & x_2 & x_3 & out \\ \\hline 0 & 1 & 1 & 0 & 0 \\ \\hline \\end{array} $$

with the single backslashes turned into escaped backslashes.

Note: \\ becomes \\ after the conversion since \\ is already an escaped backslash according to the normal CommonMark rules for Backslash escapes. I don't know how mdbook-katex works, but I think this could be an important point: how does it distinguish between the escaped backslash in \\begin and in \\ where the latter is supposed to create a line break?

from mdbook-katex.

SichangHe avatar SichangHe commented on June 10, 2024
  • What is the error?
  • You should feed in mdBook-KaTeX normal math expressions, i.e., without escaping backslashes. Because, it runs before the markdown processor.

from mdbook-katex.

mgeisler avatar mgeisler commented on June 10, 2024
  • You should feed in mdBook-KaTeX normal math expressions, i.e., without escaping backslashes. Because, it runs before the markdown processor.

Oh, thank you for that, this clears up my questions! I somehow expected it to work with the parsed Markdown, but doing this on the raw input is of course much simpler 🙂

It does make the task of mdbook-i18n-helpers a bit more complex since the tools there work on the Markdown AST. We now somehow have to emit Markdown as-if we were working on the raw input.

I think we can close the issue/question here — making this work is a matter between google/mdbook-i18n-helpers#105 and possibly Byron/pulldown-cmark-to-cmark#60.

Thanks for the help!

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.