From 2c0f7ffe3af2b2c7c84cea49456728d1ac9b3bfe Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 19 Jan 2011 13:02:50 -0800 Subject: ngdoc should escape content of pre in markdown --- docs/spec/ngdocSpec.js | 6 +++--- docs/src/ngdoc.js | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js index cf469063..4abaf0c4 100644 --- a/docs/spec/ngdocSpec.js +++ b/docs/spec/ngdocSpec.js @@ -62,12 +62,12 @@ describe('ngdoc', function(){ toEqual('
<angular/>
'); }); - it('should not replace anything in', function(){
- expect(markdown('bah x\n\nangular.k\n
\n asdf x')).
+ it('should not replace anything in , but escape the html escape the content', function(){
+ expect(markdown('bah x\n\nangular.k\n
\n asdf x')).
toEqual(
'bah x
' +
'\n' +
- 'angular.k\n' +
+ '<b>angular</b>.k\n' +
'' +
'asdf x
');
});
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js
index f1ca8d7e..038dda06 100644
--- a/docs/src/ngdoc.js
+++ b/docs/src/ngdoc.js
@@ -421,9 +421,11 @@ function markdown (text) {
parts.forEach(function(text, i){
if (text.match(/^/)) {
- text = text.
- replace(/^/, '').
- replace(/<\/pre>/, '
');
+ text = text.replace(/^([\s\S]*)<\/pre>/mi, function(_, content){
+ return '' +
+ content.replace(//g, '>') +
+ '
';
+ });
} else {
text = text.replace(/ /gm, '<angular/>');
text = new Showdown.converter().makeHtml(text.replace(/^#/gm, '###'));
--
cgit v1.2.3