mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-04 02:18:04 +02:00
Use RegExp with global flag to ensure all fenced code blocks have the hljs class applied
This commit is contained in:
parent
fb294ab845
commit
9bb4f906fc
1 changed files with 13 additions and 12 deletions
|
@ -20,17 +20,6 @@ function anchors(md) {
|
|||
}
|
||||
|
||||
class Remarkable extends React.Component {
|
||||
|
||||
render() {
|
||||
var Container = this.props.container;
|
||||
|
||||
return (
|
||||
<Container>
|
||||
{this.content()}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps, nextState) {
|
||||
if (nextProps.options !== this.props.options) {
|
||||
this.md = new Markdown(nextProps.options);
|
||||
|
@ -87,9 +76,21 @@ class Remarkable extends React.Component {
|
|||
|
||||
}
|
||||
|
||||
const html = this.md.render(source);
|
||||
|
||||
// Ensure fenced code blocks use Highlight.js hljs class
|
||||
// https://github.com/jonschlinkert/remarkable/issues/224
|
||||
return this.md.render(source).replace('<pre><code>','<pre><code class="hljs">');
|
||||
return html.replace(/<pre><code>/g,'<pre><code class="hljs">');
|
||||
}
|
||||
|
||||
render() {
|
||||
var Container = this.props.container;
|
||||
|
||||
return (
|
||||
<Container>
|
||||
{this.content()}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue