-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
markup/goldmark: Support passthrough extension #11866
Conversation
4dda0ef
to
3f5e9e4
Compare
b5ea64e
to
30feac3
Compare
Trying the initial integration with my blog, I'm seeing some issues with the renderer. When I configure my personal block via https://github.com/j2kun/math-intersect-programming/commit/892f42db29a388ae18e7aab70f6b3d4a579b66a4:
I see
Based on the But I'm not sure how to narrow this down further. Could be an issue with my building hugo at head (a541e3b) + this PR Note this only occurs due to the inclusion of the |
I may have some time to look at this tomorrow, but the config structure is different that what we (I) discussed here: Of the two options, I like the second one better. Whether a delim is an opener or a closer should be inferred from its position in the array. There's an example of this in the config structure for tdewolff/minify, e.g.,
I took what you have done so far for quick test drive with the test cases repo/branch:
Works great! |
I haven't tried to reproduce the error you encountered, but I noticed that your config is probably not what you intended:
|
On the Hugo side of this (not the extension), the default config should include the four pairs of delimiters described here, with the ability to override to replace, remove, or add pairs of delimiters. For example, if my markdown includes LaTeX mathematical expressions/equations, this should be all I need to do1: markup:
goldmark:
extensions:
passthrough:
enable: true If I want to avoid fighting with dollar signs in markdown (e.g., "the price is $2.00"), I should be able to do this: markup:
goldmark:
extensions:
passthrough:
enable: true
delimiters:
inline:
- ['\(','\)']
block:
- ['\[','\]'] Footnotes
|
@j2kun Here is one of several posts that is triggering the error:
Specifically, this is the bit that is causing the problem:
Which can be reduced to:
The error is not specific to your site or theme. It can be reproduced in a test case with:
or
So, any time you have two or more passthrough blocks in the same markdown paragraph. This test panics in passthrough/passthrough_test.go: func TestExample27(t *testing.T) {
input := `$$x$$ $$x$$`
fmt.Println(Parse(t, input))
} |
I made the changes requested to the hugo extension:
Fixing the double-block bug in the parser next |
$
and $$
I think it should be good now, tested against gohugoio/hugo-goldmark-extensions@2ce467c with my whole blog and at least it doesn't crash. I will have to do some more investigating on my blog posts, because the Wordpress->hugo export chain I used did some funky stuff with my typeset math (e.g., all backslashes are escaped, all brackets are escaped, which led to that funky |
I wanted to disable the
|
My previous test was invalid... this works great to disable the
However, the stored config is incorrect:
result
|
@j2kun I think we should remove the single
Neither KaTeX.js nor MathJax.js enables the single Thoughts? |
Related to a previous comment... I expected that I would be able to disable inline parsing with this:
But the config is unchanged.
|
If the goal is to have an extension that is agnostic of LaTeX, then my thought is to have no default configured delimiters. Make the user explicitly set them always. It would cause fewer surprises for people who want to use it for something besides TeX math mode, and would result in less code on the hugo side. If you disagree, I'll go ahead and fix both the issues above (defaults not cleared and remove |
You're right; thank you. We have to document this functionality anyway, including how to add and remove delimiter pairs. Please proceed. |
Also, please squash the commits with a new commit message:
We capitalize the first word after the "foo/bar: " bit per: EDIT: bep intends to roll a release shortly, and it will include this PR when it goes green. |
e493401
to
a8b440a
Compare
Address all comments. |
This looks solid, great work! |
Fixes #10894
Creating as a draft so that it can be discussed in the issue, and while I work on adding additional tests. Implementation by @janhuenermann, tests by me.