Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 140
Refactor markdown syntax highlighting.#720
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9d9aa6e103fcb5f679951cc70aed6c98c28f80bf28b2893edb679a6adff9f8c6bad06d37d34eb3ca7aa2a3fb7013ebf65678aaeda0fd28a0a2ba931File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,12 +2,18 @@ import React, {Component} from 'react'; | ||
| import {type} from 'ramda'; | ||
| import Markdown from 'react-markdown'; | ||
| import MarkdownHighlighter from '../utils/MarkdownHighlighter'; | ||
| import {propTypes, defaultProps} from '../components/Markdown.react'; | ||
| import '../components/css/highlight.css'; | ||
| export default class DashMarkdown extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
| if (MarkdownHighlighter.isReady !== true) { | ||
| MarkdownHighlighter.isReady.then(() => { | ||
| this.setState({}); | ||
| }); | ||
| } | ||
| this.highlightCode = this.highlightCode.bind(this); | ||
| this.dedent = this.dedent.bind(this); | ||
| } | ||
| @@ -21,15 +27,15 @@ export default class DashMarkdown extends Component { | ||
| } | ||
| highlightCode() { | ||
| if (!window.hljs) { | ||
| // skip highlighting if highlight.js isn't found | ||
| return; | ||
| } | ||
| if (this.mdContainer) { | ||
| const nodes = this.mdContainer.querySelectorAll('pre code'); | ||
| for (let i = 0; i < nodes.length; i++) { | ||
| window.hljs.highlightBlock(nodes[i]); | ||
| if (MarkdownHighlighter.hljs) { | ||
| for (let i = 0; i < nodes.length; i++) { | ||
| MarkdownHighlighter.hljs.highlightBlock(nodes[i]); | ||
| } | ||
| } else { | ||
| MarkdownHighlighter.loadhljs(); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the existing implementation does not take full advantage of the Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue created: #724, will not be addressed as part of this PR. | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
🎉