From b151a0c9a820a09395a2429e9b814a941f1a3561 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 29 May 2012 12:14:58 +0200 Subject: [PATCH] fix formatting bugs related to optional replacements --- source/Ox.UI/js/Code/SourceViewer.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Code/SourceViewer.js b/source/Ox.UI/js/Code/SourceViewer.js index dc499717..0a92d591 100644 --- a/source/Ox.UI/js/Code/SourceViewer.js +++ b/source/Ox.UI/js/Code/SourceViewer.js @@ -45,7 +45,7 @@ Ox.SourceViewer = function(options, self) { if (!/^\/\//.test(token.value)) { if (type == 'comment') { i && sections.push({comment: '', code: ''}); - token.value = token.value.slice(2, -2); + token.value = expand(trim(token.value.slice(2, -2))); self.options.replaceComment.forEach(function(replace) { token.value = token.value.replace( replace[0], replace[1] @@ -60,7 +60,7 @@ Ox.SourceViewer = function(options, self) { .appendTo(self.$table), $comment = $('') .addClass('OxComment OxSerif') - .html(quote(trim(section.comment))) + .html(Ox.addLinks(section.comment, true)) .appendTo($section), $code = $('') .addClass('OxCode') @@ -74,8 +74,10 @@ Ox.SourceViewer = function(options, self) { }); }); - function quote(str) { - return str.replace(/\s`(.*?)`/g, ' $1') + function expand(str) { + return str.replace(/(\W)`([\s\S]+?)`/g, function(match, outer, inner) { + return outer + '' + Ox.encodeHTMLEntities(inner) + ''; + }) } function trim(str) {