-
-
Notifications
You must be signed in to change notification settings - Fork 144
update markdown rendering approach #1133
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
update markdown rendering approach #1133
Conversation
@@ -5,7 +5,6 @@ import hljs from 'highlight.js/lib/core'; | |||
import javascript from 'highlight.js/lib/languages/javascript'; | |||
import css from 'highlight.js/lib/languages/css'; | |||
import handlebars from 'highlight.js/lib/languages/handlebars'; | |||
import htmlbars from 'highlight.js/lib/languages/htmlbars'; |
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.
htmlbars
is no longer a thing in highlight.js, being replaced with just handlebars
.
@@ -28,6 +27,6 @@ hljs.registerLanguage('ts', typescript); | |||
|
|||
export default class DocsCodeHighlight extends Component { | |||
setupElement(element) { | |||
hljs.highlightBlock(element); |
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.
highlightBlock
method was deprecated, being replaced with highlightElement
.
@miguelcobain This is great! Thanks for working on this! |
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.
This looks amazing to me, thanks for doing this @miguelcobain!
What this PR does:
marked
andhighlight.js
to the latest versionsPreviously we were parsing the markdown with the vanilla tokenizer from marked. This meant that we had to make some massaging of the tokens to successfully remove extra paragraphs when inside a curly or angle bracket syntax (see
compactParagraphs
function).This new proposal makes use of marked's extensions, trying to accomplish a similar same thing.
One advantage is that the content inside an html or hbs block now is preserved, including whitespace.
As an example, previously compiling this markdown:
{{#foo-bar}} hello {{/foo-bar}}
resulted in the following hbs:
But now it results in the the following:
Notice how everything inside
{{#foo-bar}}
and{{/foo-bar}}
is preserved. Same thing happens for html/angle bracket components.This explains why I had to change tests.
Test coverage was good, but I went manually to every single page in the docs app and everything looks good.
Since @dfreeman seems to have worked on this code in the past, I'm going to mention him. Would be great to get another pair of eyes, at least in the test changes. :)