[markdown] Remove client-side syntax highlighting (#189)

* Remove client side highlighting

* Update CSS rules to render plain code blocks with expected left border

* Add back codeColor background color config

* Ensure all pre code blocks use Highlight.js classes
This commit is contained in:
Héctor Ramos 2017-10-26 12:07:02 -07:00 committed by GitHub
parent f72df94dd3
commit fb294ab845
4 changed files with 25 additions and 17 deletions

View file

@ -7,6 +7,9 @@ const toSlug = require("./toSlug.js");
const CWD = process.cwd();
/**
* The anchors plugin adds GFM-style anchors to headings.
*/
function anchors(md) {
md.renderer.rules.heading_open = function(tokens, idx /*, options, env */) {
return '<h' + tokens[idx].hLevel + '>' + '<a class="anchor" name="' + toSlug(tokens[idx+1].content) + '"></a>';
@ -53,6 +56,9 @@ class Remarkable extends React.Component {
renderMarkdown(source) {
if (!this.md) {
this.md = new Markdown({
// Highlight.js expects hljs css classes on the code element.
// This results in <pre><code class="hljs css javascript">
langPrefix: 'hljs css ',
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
@ -64,7 +70,7 @@ class Remarkable extends React.Component {
return hljs.highlightAuto(str).value;
} catch (err) {}
return ''; // use external default escaping
return '';
}
});
@ -81,7 +87,9 @@ class Remarkable extends React.Component {
}
return 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">');
}
}