mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(sample): Fix for jsFiddle integration
This commit is contained in:
parent
dc0b0c77c7
commit
774db0aecb
3 changed files with 14 additions and 4 deletions
|
|
@ -89,6 +89,14 @@ describe('ngdoc', function(){
|
|||
'<pre class="doc-source">\n<>\n</pre></doc:example><p>after</p>');
|
||||
});
|
||||
|
||||
it('should preserve the jsfiddle attribute', function(){
|
||||
var doc = new Doc('@description before <doc:example>' +
|
||||
'<doc:source jsfiddle="foo">lala</doc:source></doc:example> after');
|
||||
doc.parse();
|
||||
expect(doc.description).toContain('<p>before </p><doc:example>' +
|
||||
'<pre class="doc-source" jsfiddle="foo">lala</pre></doc:example><p>after</p>');
|
||||
});
|
||||
|
||||
it('should escape <doc:scenario> element', function(){
|
||||
var doc = new Doc('@description before <doc:example>' +
|
||||
'<doc:scenario>\n<>\n</doc:scenario></doc:example> after');
|
||||
|
|
|
|||
|
|
@ -111,9 +111,11 @@ Doc.prototype = {
|
|||
'</pre></div>';
|
||||
});
|
||||
} else if (isDocWidget('example')) {
|
||||
text = text.replace(/(<doc:source>)([\s\S]*)(<\/doc:source>)/mi,
|
||||
function(_, before, content, after){
|
||||
return '<pre class="doc-source">' + htmlEscape(content) + '</pre>';
|
||||
text = text.replace(/<doc:source(\s+jsfiddle="[^"]+")?>([\s\S]*)<\/doc:source>/mi,
|
||||
function(_, jsfiddle, content){
|
||||
return '<pre class="doc-source"' + (jsfiddle || '') +'>' +
|
||||
htmlEscape(content) +
|
||||
'</pre>';
|
||||
});
|
||||
text = text.replace(/(<doc:scenario>)([\s\S]*)(<\/doc:scenario>)/mi,
|
||||
function(_, before, content, after){
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
//jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName!
|
||||
var example = element.find('pre').eq(0), //doc-source
|
||||
exampleSrc = example.text(),
|
||||
jsfiddle = element.find('doc:source').attr('jsfiddle') || true,
|
||||
jsfiddle = example.attr('jsfiddle') || true,
|
||||
scenario = element.find('pre').eq(1); //doc-scenario
|
||||
|
||||
var code = indent(exampleSrc);
|
||||
|
|
|
|||
Loading…
Reference in a new issue