alshedivat / al-folio

A beautiful, simple, clean, and responsive Jekyll theme for academics
https://alshedivat.github.io/al-folio/
MIT License
11.19k stars 11.24k forks source link

Vertical bar | within $$..$$ breaks equation #2189

Closed dinh-toan closed 9 months ago

dinh-toan commented 9 months ago

Have you checked that your issue isn't already filed?

Bug description

Markdown rendering problem with vertical bar '|' inside math delimiters '$$'

How to reproduce the bug

Description

Every time I need to write an inline math expression with a vertical bar |, for example abc $$m|n$$ def It seems that al-folio does not recognize math delimiters, but instead thinks I am trying to write a markdown table. Moreover, the problem worsens when there are multiple math expressions within a single paragraph.

How to reproduce the issue

  1. Open any markdown post.
  2. Insert in any line an inline math expression with |, for example: This theme supports rendering beautiful $$\mid |$$ ... inside a paragraph, it will produce an inline expression $$m^2$$....
  3. Expected behaviour:

This theme supports rendering beautiful $\mid |$ ... inside a paragraph, it will produce an inline expression $m^2$....

  1. Resulted bevaviour:
    <table>
    <tbody>
    <tr>
    <td>This theme supports rendering beautiful $$\mid</td>
    <td>\(... inside a paragraph, it will produce an inline expression\)m^2$$…</td>
    </tr>
    </tbody>
    </table>

Illustrated images

Code

Screenshot 2024-02-13 at 11 53 32 AM

Site

Screenshot 2024-02-13 at 11 53 46 AM

Error messages and logs

No response

What operating system are you using?

Mac

Where are you seeing the problem on?

Deployed site

More info

No response

george-gca commented 9 months ago

Using it as $$\mid$$ it renders as |.

dinh-toan commented 9 months ago

Thanks and it does not render double bars. Another example for my case is writing the absolute value. More precisely, $$|p|$$ stills breaks equation.

george-gca commented 9 months ago

Note that this symbol can be generated in numerous different ways, so just try a different one.

But what you are trying to achieve has more adequate ways in LaTeX. I recommend using an online tool to help you build your equations.

dinh-toan commented 9 months ago

Is it possible to address the parsing problem in Al Folio? I think ensuring robust math rendering is a crucial aspect of Al Folio's functionality.

george-gca commented 9 months ago

$$\|a\|$$ renders ||a||.

Also, are you sure only |a| is a valid LaTeX equation? If so, I am afraid we may be with our hands tied here, since we rely on MathJax to convert LaTeX equations.

dinh-toan commented 9 months ago

Yes, |a| is indeed valid LaTex code. I believe we are not with our hands tied here as this code renders correctly in MathJax—I've confirmed this using the MathJax Live demo available at https://www.mathjax.org/#demo.

In my opinion, this issue might stem from Al Folio automatically converting inline delimiters from $$..$$ to \( ..\) before employing MathJax for math expression rendering. Perhaps, I'm wrong.

george-gca commented 9 months ago

Hummm interesting. Did a quick search on this, and maybe it can be customized inside MathJax, since it seems to be a limitation of kramdown, which is the markdown flavor of jekyll. But I don't think this is worth the trouble, since kramdown docs itself states:

Note that LaTeX code that uses the pipe symbol | in inline math statements may lead to a line being recognized as a table line. This problem can be avoided by using the \vert command instead of |!

dinh-toan commented 9 months ago

Thank you Geogre.