@@ -10,7 +10,7 @@ var File = require('vinyl'),
10
10
getTemplate = require ( '../get_template' ) ,
11
11
resolveTheme = require ( '../resolve_theme' ) ,
12
12
helpers = require ( '../html_helpers' ) ,
13
- highlight = require ( '../ highlight' ) ;
13
+ hljs = require ( 'highlight.js ' ) ;
14
14
15
15
/**
16
16
* Make slugg a unary so we can use it in functions
@@ -23,6 +23,31 @@ function slug(input) {
23
23
return input ? slugg ( input ) : '' ;
24
24
}
25
25
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
+
26
51
/**
27
52
* Formats documentation as HTML.
28
53
*
0 commit comments