1
0
Fork 0
forked from 0x2620/oxjs

use markdown

This commit is contained in:
rolux 2012-05-30 13:34:57 +02:00
commit 9269b96469
4 changed files with 44 additions and 47 deletions

View file

@ -42,10 +42,13 @@ Ox.SourceViewer = function(options, self) {
var sections = [{comment: '', code: ''}];
Ox.tokenize(source).forEach(function(token, i) {
var type = token.type == 'comment' ? 'comment' : 'code';
// ignore '//' comments
if (!/^\/\//.test(token.value)) {
if (type == 'comment') {
i && sections.push({comment: '', code: ''});
token.value = expand(trim(token.value.slice(2, -2)));
token.value = Ox.parseMarkdown(
trim(token.value.slice(2, -2))
);
self.options.replaceComment.forEach(function(replace) {
token.value = token.value.replace(
replace[0], replace[1]
@ -77,7 +80,7 @@ Ox.SourceViewer = function(options, self) {
function expand(str) {
return str.replace(/(\W)`([\s\S]+?)`/g, function(match, outer, inner) {
return outer + '<code>' + Ox.encodeHTMLEntities(inner) + '</code>';
})
});
}
function trim(str) {