@@ -10,7 +10,7 @@ var File = require('vinyl'),
1010 getTemplate = require ( '../get_template' ) ,
1111 resolveTheme = require ( '../resolve_theme' ) ,
1212 helpers = require ( '../html_helpers' ) ,
13- highlight = require ( '../ highlight' ) ;
13+ hljs = require ( 'highlight.js ' ) ;
1414
1515/**
1616 * Make slugg a unary so we can use it in functions
@@ -23,6 +23,31 @@ function slug(input) {
2323 return input ? slugg ( input ) : '' ;
2424}
2525
26+ /**
27+ * Given a string of JavaScript, return a string of HTML representing
28+ * that JavaScript highlighted.
29+ *
30+ * @param {string } example string of javascript
31+ * @returns {string } highlighted html
32+ */
33+ function highlightString ( example ) {
34+ return hljs . highlight ( 'js' , example ) . value ;
35+ }
36+
37+ /**
38+ * Highlights the contents of the `example` tag.
39+ *
40+ * @name highlight
41+ * @param {Object } comment parsed comment
42+ * @return {Object } comment with highlighted code
43+ */
44+ function highlight ( comment ) {
45+ if ( comment . examples ) {
46+ comment . examples = comment . examples . map ( highlightString ) ;
47+ }
48+ return comment ;
49+ }
50+
2651/**
2752 * Formats documentation as HTML.
2853 *
0 commit comments