-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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: Render strikethrough and emojis in TOC entries #11784
Conversation
@lyind There's a failing test, and you need to add conditions to test the issues that this PR addresses. Also, please capitalize the first letter of the commit message (after the |
cb25276
to
49a8c90
Compare
It seems like the rendering test fails, because the output is more correct now: ...
line diff (-got +want):
[]string{
"<nav id=\"TableOfContents\">\n",
" <ul>\n",
" <li><a href=\"#a--b--c--d\">A < B & C > D</a></li>\n",
strings.Join({
` <li><a href="#a--b--c--d-divfoodiv">A < B & C > D `,
"<",
- "!-- raw HTML omitted -->foo<!-- raw HTML omitted --",
+ "div>foo</div",
... But I might confuse "got" with "want", so will have another look at the code of that test case. |
49a8c90
to
c6cc57b
Compare
@jmooring I applied the following changes to fix the test and be more aligned in general:
Is my assumption correct that the test expectations were slightly incorrect, in regard to the |
635fb4d
to
a6d8a5c
Compare
Why do we need to do this? The Although I have not looked into the details, I find it curious that the strikethrough and emoji extensions are not used when enabled, but the typographer extension is used when enabled. Can you explain why that is? Here's simple but (I think) comprehensive test:
Neither the strikethrough nor the emoji extensions are used when rendering the TOC entry. I think we broke the emoji part when we started using yuin's extension (#11593). |
Let's re-task this PR to fix these open issues:
I've revised the test cases, replacing toc_test.go with toc_integration_test.go. The last two cases are commented out; they fail due to the first two open issues above. https://github.com/gohugoio/hugo/blob/master/markup/goldmark/toc_integration_test.go#L255-L265 Without digging into the details, I am surprised that the typographer extension affects TOC entries, but the emoji and strikethrough extensions do not. |
True. Just passed the options down out of "stubborn completeness", will change that again. |
a6d8a5c
to
bf22c3e
Compare
These three issues should be properly fixed now, testsuite passes:
@jmooring Please review. |
Functionally this is great! Thank you. The next step is a review by bep. |
Configure the TOC (table of contents,
toc.go
) goldmark renderer instance to always enable the Strikethrough extension.This allows handling
ast.KindStrikethrough
within an AST node avoiding a crash.Fixes #7169
Fixes #8087
Fixes #11783