mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-02 09:00:34 +08:00
fix syntax highlighting on the javascript
This commit is contained in:
@@ -307,10 +307,10 @@ describe('ngdoc', function(){
|
||||
|
||||
describe('@description', 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();
|
||||
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() {
|
||||
@@ -318,10 +318,10 @@ describe('ngdoc', function(){
|
||||
doc.parse();
|
||||
expect(doc.description).
|
||||
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' +
|
||||
'<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){
|
||||
if (text.match(/^<pre>/)) {
|
||||
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, '>') +
|
||||
'</pre></div>';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user