diff options
| -rw-r--r-- | docs/spec/ngdocSpec.js | 8 | ||||
| -rw-r--r-- | docs/src/ngdoc.js | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index 72ad69ff..367f91b4 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -89,6 +89,14 @@ describe('ngdoc', function() { '<pre class="doc-source">\n<>\n</pre></doc:example><p>after</p>'); }); + it('should preserve the source attribute', function() { + var doc = new Doc('@description before <doc:example>' + + '<doc:source source="false">lala</doc:source></doc:example> after'); + doc.parse(); + expect(doc.description).toContain('<p>before </p><doc:example>' + + '<pre class="doc-source" source="false">lala</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'); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index c5da18e6..3ed9198a 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -117,9 +117,9 @@ Doc.prototype = { '</pre></div>'; }); } else if (isDocWidget('example')) { - text = text.replace(/<doc:source(\s+jsfiddle="[^"]+")?>([\s\S]*)<\/doc:source>/mi, - function(_, jsfiddle, content){ - return '<pre class="doc-source"' + (jsfiddle || '') +'>' + + text = text.replace(/<doc:source(\s+[^>]*)?>([\s\S]*)<\/doc:source>/mi, + function(_, attrs, content){ + return '<pre class="doc-source"' + (attrs || '') +'>' + htmlEscape(content) + '</pre>'; }); |
