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

fix(v1): markdown content and toc should render the same #2022

Merged
merged 3 commits into from
Nov 21, 2019
Merged

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Nov 21, 2019

Motivation

Close #2021

Sort of continuation from #2019 but this is dealing with consistent rendered content. That PR is consistent hash-link and slug

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

  • Added test passes
## function1 [array\<string>]

## <a name="foo"></a> _Foo_

render same

@endiliey endiliey added the pr: bug fix This PR fixes a bug in a past release. label Nov 21, 2019
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 21, 2019
@endiliey endiliey changed the title fix(v1): autogenerated_toc and sidebar toc should render the same fix(v1): markdown content and toc should render the same Nov 21, 2019
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Nov 21, 2019

Deploy preview for docusaurus-2 ready!

Built with commit 8ebd111

https://deploy-preview-2022--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 7988079

https://deploy-preview-2022--docusaurus-preview.netlify.com

const headings = mdToc(content).json;
const toc = [];
const slugger = new GithubSlugger();
let current;

headings.forEach(heading => {
const rawContent = heading.content;
const safeContent = striptags(rawContent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should find out when/why this was added. We could be regressing on a bug.

Copy link
Contributor Author

@endiliey endiliey Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of #1762 which was a wrong solution.

So the reason why #2021 happens (inconsistent) is because in right TOC, we try to strip tags, and then render with remarkable.

In markdown itself, we only render with remarkable.

The remarkable render function is also different.

new Remarkable({html: true});

vs

const md = new Remarkable();

which is equivalent to

new Remarkable({
  html:         false,  // this is default

Pretty sure this is 99.99% the right fix

Copy link
Contributor Author

@endiliey endiliey Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1762 attempted to fix a bug whereby

## Referencing Site Documents <span id="jump">

image

Should be rendered on the right without the span text in TOC.

But its causing inconsistent content.

This PR on other hand fixed that bug but is still consistent

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit 8ebd111

https://deploy-preview-2022--docusaurus-preview.netlify.com

@endiliey endiliey merged commit bd68dce into master Nov 21, 2019
@endiliey endiliey deleted the endi/tocfix branch November 21, 2019 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Side navbar (TOC) doesn't display content in escaped angle brackets
4 participants