Skip to content

Commit b6bc6c2

Browse files
mheveryIgorMinar
authored andcommitted
fix syntax highlighting on the javascript
1 parent ea6b87c commit b6bc6c2

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

docs/spec/ngdocSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,21 +307,21 @@ describe('ngdoc', function(){
307307

308308
describe('@description', function(){
309309
it('should support pre blocks', function(){
310-
var doc = new Doc("@description <pre>abc</pre>");
310+
var doc = new Doc("@description <pre><b>abc</b></pre>");
311311
doc.parse();
312312
expect(doc.description).
313-
toBe('<div ng:non-bindable><pre class="brush: js; html-script: true;">abc</pre></div>');
313+
toBe('<div ng:non-bindable><pre class="brush: js; html-script: true;">&lt;b&gt;abc&lt;/b&gt;</pre></div>');
314314
});
315315

316316
it('should support multiple pre blocks', function() {
317317
var doc = new Doc("@description foo \n<pre>abc</pre>\n#bah\nfoo \n<pre>cba</pre>");
318318
doc.parse();
319319
expect(doc.description).
320320
toBe('<p>foo </p>' +
321-
'<div ng:non-bindable><pre class="brush: js; html-script: true;">abc</pre></div>' +
321+
'<div ng:non-bindable><pre class="brush: js;">abc</pre></div>' +
322322
'<h1>bah</h1>\n\n' +
323323
'<p>foo </p>' +
324-
'<div ng:non-bindable><pre class="brush: js; html-script: true;">cba</pre></div>');
324+
'<div ng:non-bindable><pre class="brush: js;">cba</pre></div>');
325325

326326
});
327327

docs/src/ngdoc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ Doc.prototype = {
7070
parts.forEach(function(text, i){
7171
if (text.match(/^<pre>/)) {
7272
text = text.replace(/^<pre>([\s\S]*)<\/pre>/mi, function(_, content){
73-
return '<div ng:non-bindable><pre class="brush: js; html-script: true;">' +
73+
var clazz = 'brush: js;'
74+
if (content.match(/\<\w/)) {
75+
// we are HTML
76+
clazz += ' html-script: true;';
77+
}
78+
return '<div ng:non-bindable><pre class="' + clazz +'">' +
7479
content.replace(/</g, '&lt;').replace(/>/g, '&gt;') +
7580
'</pre></div>';
7681
});

0 commit comments

Comments
 (0)