mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-04 05:04:44 +00:00
fix syntax highlighting on the javascript
This commit is contained in:
parent
ea6b87c24b
commit
b6bc6c2ddf
2 changed files with 10 additions and 5 deletions
|
|
@ -307,10 +307,10 @@ describe('ngdoc', function(){
|
||||||
|
|
||||||
describe('@description', function(){
|
describe('@description', function(){
|
||||||
it('should support pre blocks', function(){
|
it('should support pre blocks', function(){
|
||||||
var doc = new Doc("@description <pre>abc</pre>");
|
var doc = new Doc("@description <pre><b>abc</b></pre>");
|
||||||
doc.parse();
|
doc.parse();
|
||||||
expect(doc.description).
|
expect(doc.description).
|
||||||
toBe('<div ng:non-bindable><pre class="brush: js; html-script: true;">abc</pre></div>');
|
toBe('<div ng:non-bindable><pre class="brush: js; html-script: true;"><b>abc</b></pre></div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support multiple pre blocks', function() {
|
it('should support multiple pre blocks', function() {
|
||||||
|
|
@ -318,10 +318,10 @@ describe('ngdoc', function(){
|
||||||
doc.parse();
|
doc.parse();
|
||||||
expect(doc.description).
|
expect(doc.description).
|
||||||
toBe('<p>foo </p>' +
|
toBe('<p>foo </p>' +
|
||||||
'<div ng:non-bindable><pre class="brush: js; html-script: true;">abc</pre></div>' +
|
'<div ng:non-bindable><pre class="brush: js;">abc</pre></div>' +
|
||||||
'<h1>bah</h1>\n\n' +
|
'<h1>bah</h1>\n\n' +
|
||||||
'<p>foo </p>' +
|
'<p>foo </p>' +
|
||||||
'<div ng:non-bindable><pre class="brush: js; html-script: true;">cba</pre></div>');
|
'<div ng:non-bindable><pre class="brush: js;">cba</pre></div>');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,12 @@ Doc.prototype = {
|
||||||
parts.forEach(function(text, i){
|
parts.forEach(function(text, i){
|
||||||
if (text.match(/^<pre>/)) {
|
if (text.match(/^<pre>/)) {
|
||||||
text = text.replace(/^<pre>([\s\S]*)<\/pre>/mi, function(_, content){
|
text = text.replace(/^<pre>([\s\S]*)<\/pre>/mi, function(_, content){
|
||||||
return '<div ng:non-bindable><pre class="brush: js; html-script: true;">' +
|
var clazz = 'brush: js;'
|
||||||
|
if (content.match(/\<\w/)) {
|
||||||
|
// we are HTML
|
||||||
|
clazz += ' html-script: true;';
|
||||||
|
}
|
||||||
|
return '<div ng:non-bindable><pre class="' + clazz +'">' +
|
||||||
content.replace(/</g, '<').replace(/>/g, '>') +
|
content.replace(/</g, '<').replace(/>/g, '>') +
|
||||||
'</pre></div>';
|
'</pre></div>';
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue