Skip to content

Commit cfc3d41

Browse files
committed
Strip the dynamically generated ID from SyntaxHighlighter from element before it is placed into rendered HTML. Respect the "data-linenum" attr and pass it to node-syntaxhighlighter. Partially resolves #5
1 parent 60e400e commit cfc3d41

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tasks/build.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,12 @@ grunt.registerHelper("syntax-highlight", function( options, callback ) {
111111
var $t = $(this),
112112
code = $t.html(),
113113
lang = $t.attr("data-lang") || $t.attr("class") || crudeHTMLcheck( code ),
114+
linenum = $t.attr("data-linenum") || 1,
114115
brush = nsh.getLanguage( lang ) || nsh.getLanguage( "js" ),
115-
highlighted = nsh.highlight( code, brush );
116-
$t.parent().replaceWith( highlighted );
116+
highlighted = nsh.highlight( code, brush, {
117+
"first-line": linenum
118+
});
119+
$t.parent().replaceWith( $(highlighted).removeAttr("id") );
117120
});
118121
}
119122
catch ( excp ) {

0 commit comments

Comments
 (0)