-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
fix(v1): markdown content and toc should render the same #2022
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 8ebd111 |
Deploy preview for docusaurus-preview ready! Built with commit 7988079 |
const headings = mdToc(content).json; | ||
const toc = []; | ||
const slugger = new GithubSlugger(); | ||
let current; | ||
|
||
headings.forEach(heading => { | ||
const rawContent = heading.content; | ||
const safeContent = striptags(rawContent); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
html: true, |
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
There was a problem hiding this comment.
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">
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
Deploy preview for docusaurus-preview ready! Built with commit 8ebd111 |
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