fix formatting bugs related to optional replacements

This commit is contained in:
rolux 2012-05-29 12:14:58 +02:00
parent 8cd27bca2f
commit b151a0c9a8

View file

@ -45,7 +45,7 @@ Ox.SourceViewer = function(options, self) {
if (!/^\/\//.test(token.value)) { if (!/^\/\//.test(token.value)) {
if (type == 'comment') { if (type == 'comment') {
i && sections.push({comment: '', code: ''}); 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) { self.options.replaceComment.forEach(function(replace) {
token.value = token.value.replace( token.value = token.value.replace(
replace[0], replace[1] replace[0], replace[1]
@ -60,7 +60,7 @@ Ox.SourceViewer = function(options, self) {
.appendTo(self.$table), .appendTo(self.$table),
$comment = $('<td>') $comment = $('<td>')
.addClass('OxComment OxSerif') .addClass('OxComment OxSerif')
.html(quote(trim(section.comment))) .html(Ox.addLinks(section.comment, true))
.appendTo($section), .appendTo($section),
$code = $('<td>') $code = $('<td>')
.addClass('OxCode') .addClass('OxCode')
@ -74,8 +74,10 @@ Ox.SourceViewer = function(options, self) {
}); });
}); });
function quote(str) { function expand(str) {
return str.replace(/\s`(.*?)`/g, ' <code>$1</code>') return str.replace(/(\W)`([\s\S]+?)`/g, function(match, outer, inner) {
return outer + '<code>' + Ox.encodeHTMLEntities(inner) + '</code>';
})
} }
function trim(str) { function trim(str) {