-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Show HTML tag on TOC, not escaping them #1703
Comments
The approach here is to first strip the HTML from the heading's content, then rendered it with markdown to get the HTML content for the TOC entry, then to strip the HTML from the rendered content again, as to get the text for the TOC entry's link. Adds an additional dependency of striptags (MIT licensed) Example TOC Entry, given the heading of: ```markdown ``` ```javascript { hashLink: 'foo', rawContent: '<a name="foo"></a> _Foo_', content: '<em>Foo</em>', children: [] } ``` Previously this TOC entry would be: ```javascript { hashLink: 'a-name-foo-a-_foo_', rawContent: '<a name="foo"></a> _Foo_', content: '<a name="foo"></a> <em>Foo</em>', children: [] } ``` closes issue #1703
This can now be closed as it's fixed @yangshun |
Oh, wait, actually, no; I'm wrong there. @leavesster can you check with the current master of docusaurus as to whether the change in #1762 has the desired results for you? |
I'm glad to try. In #1671 I said It only render wrong headers on my website, so I will produce it on my website. I'm unfamiliar with dependencies with GitHub URL (not the whole git repo, only a directory in it). I've read the npm document. And I could not find a way to add a URL (not git homepage, just https://github.com/facebook/docusaurus/tree/master/packages/docusaurus-1.x) to package.json ? It just failed, and give me this message: https://github.com/facebook/docusaurus/tree/master/packages/docusaurus-1.x: Extracting tar content of undefined failed, the file appears to be corrupt: "Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped? I read package.json It seems I want to know if you have any idea of testing unreleased but already on website package? If there is no way I can use unreleased package. I think I can release a forked package tomorrow to check if it ok. |
@leavesster We just published v1.13.0, see if upgrading to that fixes your problems! |
It works. Thank you ^_^ |
🐛 Bug Report
TOC content doesn't show header as they show on H2/H3 tags.
As I mentioned in #1671 TOC content doesn't show HTML tags, TOC has escaped these HTML tags.
In that issue, I just said that localhost is different from the website. But my real problem is could the TOC allow HTML tag, not escape them ?
Have you read the Contributing Guidelines on issues?
YES
To Reproduce
Expected behavior
Actual Behavior
Reproducible Demo
(Paste the link to an example repo, including a
siteConfig.js
, and exact instructions to reproduce the issue.)fork-demo
the way to fix it
and I find the way to fix it.
just change code
from
<Link hashLink={heading.hashLink} content={heading.content} />
to
<Link hashLink={heading.hashLink} content={heading.rawContent} />
It seems the master branch is on developing v2.x, so I think maybe open a pull request to fix this is not a very good way.
I think this maybe also help for #1011 .
Thank you for creating this project ^_^.
The text was updated successfully, but these errors were encountered: