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

KaTeX does not work #12

Closed
BohuTANG opened this issue Oct 15, 2019 · 2 comments
Closed

KaTeX does not work #12

BohuTANG opened this issue Oct 15, 2019 · 2 comments

Comments

@BohuTANG
Copy link

Hi reuixiy,

meme is so cool for me, thank guys!
But there is an issue about KaTeX in my markdown(I'm New At Web...) with meme lastest version:

  1. the single line mode works fine here:
$$x^2 + y^2 = 1$$
  1. this mode dost not work(copy from https://katex.org/docs/support_table.html)
$$\begin{darray}{cc}
   a & b \\
   c & d
\end{darray}$$

outputs are:

\begin{array}{cc} a & b
c & d \end{array}

But it works well in test.html:

<!DOCTYPE html>
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
<html>
  <head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.css" crossorigin="anonymous">
 
    <!-- The loading of KaTeX is deferred to speed up page rendering -->
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/katex.min.js" crossorigin="anonymous"></script> 
 
    <!-- To automatically render math in text elements, include the auto-render extension: -->
    <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.0/dist/contrib/auto-render.min.js"  crossorigin="anonymous"
        onload="renderMathInElement(document.body);"></script> 
  </head>
<body>
$$
\begin{darray}{cc}
   a & b \\
   c & d
\end{darray}
$$
    <script>
      renderMathInElement(
          document.getElementById("test"),
          {
              delimiters: [
                  {left: "$$", right: "$$", display: true},
                  {left: "\\[", right: "\\]", display: true},
                  {left: "$", right: "$", display: false},
                  {left: "\\(", right: "\\)", display: false}
              ]
          }
      );
    </script>
  </body>
</html>

Thanks!

@reuixiy
Copy link
Owner

reuixiy commented Oct 15, 2019

Hi @BohuTANG,

This problem is caused by the syntax conflict between Markdown and LaTeX. To solve that, you need to add some backslashes to escape some characters. For example:

  1. _ -> \_
  2. \\ -> \\\\
  3.  $$\begin{darray}{cc}
        a & b \\\\
        c & d
     \end{darray}$$

Also, make sure you have enabled KaTeX in that post’s Front Matter (katex: true or katex = true) and added the following code in config.toml:

[blackfriday]
extensionsmask = ["hardLineBreak", "backslashLineBreak"]

For more information, see: https://gohugo.io/content-management/formats/#issues-with-markdown

@BohuTANG
Copy link
Author

Thanks, all it works now.
You save me, today.

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