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

Single equal symbol is parsed as a Markdown header inside a $$ ... $$ block. #17

Open
carlohamalainen opened this issue Mar 21, 2024 · 5 comments

Comments

@carlohamalainen
Copy link

Hi,

This is more of a question than an issue.

I had a problem with a math block when I migrated from Jekyll to Hugo. A minimal example:

	input := `$$
P
=
Q
$$
`

P and Q were large matrices so I put them on separate lines.

Goldmark runs the block parsers first and the = is recognised as a header, so it renders to

<h1>$$
P</h1>
<p>Q
$$</p>

I guess this is an inherent limitation because passthrough is an inline parser? So even changing its priority wouldn't help because the block parsers run before the inline parsers?

adding block parser: *parser.setextHeadingParser
adding block parser: *parser.thematicBreakPraser
adding block parser: *parser.listParser
adding block parser: *parser.listItemParser
adding block parser: *parser.codeBlockParser
adding block parser: *parser.atxHeadingParser
adding block parser: *parser.fencedCodeBlockParser
adding block parser: *parser.blockquoteParser
adding block parser: *parser.htmlBlockParser
adding block parser: *parser.paragraphParser
adding inline parser: *parser.codeSpanParser
adding inline parser: *parser.linkParser
adding inline parser: *passthrough.inlinePassthroughParser
adding inline parser: *parser.autoLinkParser
adding inline parser: *parser.rawHTMLParser
adding inline parser: *parser.emphasisParser

An easy workaround is to indent the == by 4 spaces.

@jmooring
Copy link
Member

jmooring commented Mar 21, 2024

Do this instead:

$$
P
\\=
Q
$$

Lines beginning with these Markdown block level indicators are not passed through: =, -, #, and >.

$$
=
$$

$$
-
$$

$$
#
$$

$$
>
$$

@jmooring
Copy link
Member

@j2kun Comments?

@carlohamalainen
Copy link
Author

@jmooring thanks for the quick reply.

Do this instead:

$$
P
\\=
Q
$$

Unfortunately that introduces a newline in the equation:

image

I'm expecting:

image

@jmooring
Copy link
Member

jmooring commented Mar 22, 2024

@carlohamalainen With this:

$$
P
\\=
Q
$$

I get this when using the MathJax engine:

image

And I get this when using the KaTeX engine:

image

This is a known KaTeX issue:
KaTeX/KaTeX#437

Usage of the Passthrough extension with Hugo is described here:
https://gohugo.io/content-management/mathematics

@j2kun
Copy link
Contributor

j2kun commented Mar 23, 2024

I'm at conferences through the weekend but will take a look after. My initial impression is that a good workaround is to use the aligned environment.

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

3 participants