forked from 0x2620/oxjs
use markdown
This commit is contained in:
parent
c831b89944
commit
9269b96469
4 changed files with 44 additions and 47 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue