Skip to content

Commit 431bee3

Browse files
committed
Merge branch 'feature/highlight'
2 parents a4bdca2 + e42f9c1 commit 431bee3

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

lib/helpers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
var hljs = require('highlight.js');
2+
13
module.exports = function (hbs) {
24

35
var context;
46

7+
hbs.registerHelper('highlightBlock', function (block) {
8+
9+
return hljs.highlightAuto(block).value;
10+
11+
});
12+
513
hbs.registerHelper('ifCond', function (a, b, options) {
614

715
return a === b ? options.fn(this) : options.inverse(this);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"license": "MIT",
77
"dependencies": {
88
"chalk": "0.5.1",
9-
"dox": "0.5.1",
10-
"handlebars": "2.0.0"
9+
"dox": "0.5.3",
10+
"handlebars": "2.0.0",
11+
"highlight.js": "8.3.0"
1112
},
1213
"keywords": [
1314
"documentation",

templates/bootstrap.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pre .hljs {
7878
7979
</style>
8080
<script>
81-
(function(e,i,t){"use strict";var c=e.location.protocol==="file:"?"http:":e.location.protocol,o=["//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css","//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/styles/github.min.css","//code.jquery.com/jquery-2.1.1.js","//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/highlight.min.js"];function s(e){var l;if(e.match(/\.js$/)){l=i.createElement("script");l.setAttribute("src",c+e)}else if(e.match(/\.css$/)){l=i.createElement("link");l.setAttribute("rel","stylesheet");l.setAttribute("href",c+e)}l.addEventListener("load",function(){if(o.length){s(o.shift())}else{if($.isReady){t()}else{$(document).ready(t)}}});i.head.appendChild(l)}s(o.shift())})(window,document,function(){"use strict";var e=window.location.hash,i=$('[id="'+e.replace(/#/,"")+'"]'),t=$(".code"),c=$(".scope-private"),o=$(".toggle-code-blocks"),s=$(".toggle-private"),l=$(".back-to-top");function n(){if(window.scrollY>100&&l.not(":visible")){l.fadeIn()}else if(window.scrollY<100&&l.is(":visible")){l.fadeOut()}}o.on("click",function(){if(o.is(":checked")){t.show()}else{t.hide()}});s.on("click",function(){if(s.is(":checked")){c.show()}else{c.hide()}});t.hide();c.hide();if(i.length&&!i.is(":visible")){s.trigger("click")}$(".examples pre code, .code pre code").each(function(){hljs.highlightBlock(this)});$(window).on("scroll",n);n()});
81+
(function(e,i,t){"use strict";var o=e.location.protocol==="file:"?"http:":e.location.protocol,s=["//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css","//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css","//code.jquery.com/jquery-2.1.1.js","//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"];function c(e){var l;if(e.match(/\.js$/)){l=i.createElement("script");l.setAttribute("src",o+e)}else if(e.match(/\.css$/)){l=i.createElement("link");l.setAttribute("rel","stylesheet");l.setAttribute("href",o+e)}l.addEventListener("load",function(){if(s.length){c(s.shift())}else{if($.isReady){t()}else{$(document).ready(t)}}});i.head.appendChild(l)}c(s.shift())})(window,document,function(){"use strict";var e=window.location.hash,i=$('[id="'+e.replace(/#/,"")+'"]'),t=$(".code"),o=$(".scope-private"),s=$(".toggle-code-blocks"),c=$(".toggle-private"),l=$(".back-to-top");function n(){if(window.scrollY>100&&l.not(":visible")){l.fadeIn()}else if(window.scrollY<100&&l.is(":visible")){l.fadeOut()}}s.on("click",function(){if(s.is(":checked")){t.show()}else{t.hide()}});c.on("click",function(){if(c.is(":checked")){o.show()}else{o.hide()}});t.hide();o.hide();if(i.length&&!i.is(":visible")){c.trigger("click")}$("pre code:not(.hljs)").each(function(){hljs.highlightBlock(this)});$(window).on("scroll",n);n()});
8282
</script>
8383
</head>
8484

@@ -250,7 +250,7 @@ pre .hljs {
250250

251251
{{#ifCond type "example"}}
252252

253-
<pre><code>{{string}}</code></pre>
253+
<pre><code class="hljs">{{{highlightBlock string}}}</code></pre>
254254

255255
{{/ifCond}}
256256

@@ -262,7 +262,7 @@ pre .hljs {
262262

263263
<h3>Code</h3>
264264

265-
<pre><code>{{code}}</code></pre>
265+
<pre><code class="hljs">{{{highlightBlock code}}}</code></pre>
266266

267267
</section>
268268

templates/bootstrap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
var protocol = w.location.protocol === 'file:' ? 'http:' : w.location.protocol,
99
resource = [
1010
'//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css',
11-
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/styles/github.min.css',
11+
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css',
1212
'//code.jquery.com/jquery-2.1.1.js',
13-
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/highlight.min.js'
13+
'//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js'
1414
];
1515

1616
function loadResource(url) {
@@ -113,7 +113,7 @@
113113

114114
}
115115

116-
$('.examples pre code, .code pre code').each(function () {
116+
$('pre code:not(.hljs)').each(function () {
117117
hljs.highlightBlock(this);
118118
});
119119

0 commit comments

Comments
 (0)