mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-27 11:40:27 +00:00
feat(docs): allow custom attributes on <doc:source>
Allow any attributes, not only jsfiddle...
This commit is contained in:
parent
eb01fe593d
commit
4afad1da29
2 changed files with 11 additions and 3 deletions
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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>';
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue