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

Show HTML tag on TOC, not escaping them #1703

Closed
leavesster opened this issue Jul 25, 2019 · 5 comments
Closed

Show HTML tag on TOC, not escaping them #1703

leavesster opened this issue Jul 25, 2019 · 5 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin.

Comments

@leavesster
Copy link

leavesster commented Jul 25, 2019

🐛 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

image

Actual Behavior

image

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 ^_^.

@endiliey endiliey added bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. labels Aug 3, 2019
gimdongwoo added a commit to gimdongwoo/Docusaurus that referenced this issue Aug 4, 2019
yangshun pushed a commit that referenced this issue Sep 13, 2019
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: '&lt;a name=&quot;foo&quot;&gt;&lt;/a&gt; <em>Foo</em>',
  children: []
}
```

closes issue #1703
@ThisIsMissEm
Copy link
Contributor

This can now be closed as it's fixed @yangshun

@ThisIsMissEm
Copy link
Contributor

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?

@leavesster
Copy link
Author

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
urls-as-dependencies only support tarball.
And Git URLs as Dependencies only support the whole git, not a directory in git.

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.

@yangshun
Copy link
Contributor

@leavesster We just published v1.13.0, see if upgrading to that fixes your problems!

@leavesster
Copy link
Author

@leavesster We just published v1.13.0, see if upgrading to that fixes your problems!

It works. Thank you ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin.
Projects
None yet
Development

No branches or pull requests

4 participants