Skip to content

Commit 8c9caa1

Browse files
committed
Custom escaping for code blocks to fix syntax highlighting.
1 parent 7273502 commit 8c9caa1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tasks/build.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ grunt.registerHelper( "parse-markdown", function( src, generateToc ) {
258258
tokens = marked.lexer( toc ).concat( tokens );
259259
}
260260

261+
// Override the default encoding of code blocks so that syntax highlighting
262+
// works properly.
263+
tokens.forEach(function( token ) {
264+
if ( token.type === "code" ) {
265+
token.escaped = true;
266+
token.text = token.text
267+
.replace( /</g, "&lt;" )
268+
.replace( />/g, "&gt;" );
269+
}
270+
});
271+
261272
return marked.parser( tokens );
262273
});
263274

0 commit comments

Comments
 (0)