diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js
index a184c5df1523..f16bef46d0cd 100644
--- a/docs/spec/ngdocSpec.js
+++ b/docs/spec/ngdocSpec.js
@@ -89,6 +89,14 @@ describe('ngdoc', function(){
'
\n<>\n
after
');
});
+ it('should preserve the jsfiddle attribute', function(){
+ var doc = new Doc('@description before ' +
+ 'lala after');
+ doc.parse();
+ expect(doc.description).toContain('before
' +
+ 'lala
after
');
+ });
+
it('should escape element', function(){
var doc = new Doc('@description before ' +
'\n<>\n after');
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js
index 91c4662af5e8..8fcf3cd5841b 100644
--- a/docs/src/ngdoc.js
+++ b/docs/src/ngdoc.js
@@ -111,9 +111,11 @@ Doc.prototype = {
'';
});
} else if (isDocWidget('example')) {
- text = text.replace(/()([\s\S]*)(<\/doc:source>)/mi,
- function(_, before, content, after){
- return '' + htmlEscape(content) + '
';
+ text = text.replace(/([\s\S]*)<\/doc:source>/mi,
+ function(_, jsfiddle, content){
+ return '' +
+ htmlEscape(content) +
+ '
';
});
text = text.replace(/()([\s\S]*)(<\/doc:scenario>)/mi,
function(_, before, content, after){
diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js
index 31600ccc742e..a55797206d35 100644
--- a/docs/src/templates/doc_widgets.js
+++ b/docs/src/templates/doc_widgets.js
@@ -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);