Skip to content

Commit

Permalink
chore: adjust code highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanyf committed Jul 5, 2023
1 parent 4f43924 commit 47bf449
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var md = new MarkdownIt({
}

return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
// return '<pre class="hljs"><code>' + hljs.highlightAuto(str).value + '</code></pre>';
}
});

Expand Down
7 changes: 6 additions & 1 deletion test/turpan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var test = require('tape');
var md = require('../lib');

test('markdown test', function (t) {
t.plan(21);
t.plan(22);

t.equal(
md.render('`x = 2`'),
Expand All @@ -21,6 +21,11 @@ test('markdown test', function (t) {
'<pre class="hljs"><code>x = <span class="hljs-number">2</span>\n</code></pre>\n'
);

t.equal(
md.render('```\nif (x > 2) {\n console.log(x);\n}\n```'),
'<pre class="hljs"><code>if (x &gt; 2) {\n console.log(x);\n}\n</code></pre>\n'
);

t.equal(
md.render('http://www.yahoo.com'),
'<p><a href="http://www.yahoo.com" target="_blank" rel="noopener">http://www.yahoo.com</a></p>\n'
Expand Down

0 comments on commit 47bf449

Please sign in to comment.