Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ var MAX_CODE_LINE = 20

function Renderer() {}

var rawRenderer = marked.Renderer
function escape(text) {
return text.replace(/\{/g, ' { ').replace(/\}/g, ' } ').replace(/\[/g, '\[').replace(/\]/g, '\]');
}

var rawRenderer = marked.Renderer
var langArr = 'actionscript3 bash csharp coldfusion cpp css delphi diff erlang groovy java javafx javascript perl php none powershell python ruby scala sql vb html/xml'.split(/\s+/)
var langMap = {
shell: 'bash',
Expand All @@ -36,19 +39,19 @@ _.extend(Renderer.prototype, rawRenderer.prototype, {
return 'h' + level + '. ' + text + '\n\n'
}
, strong: function(text) {
return '*' + text + '*'
return '*' + escape(text) + '*'
}
, em: function(text) {
return '_' + text + '_'
return '_' + escape(text) + '_'
}
, del: function(text) {
return '-' + text + '-'
return '-' + escape(text) + '-'
}
, codespan: function(text) {
return '{{' + text + '}}'
return '{{' + escape(text) + '}}'
}
, blockquote: function(quote) {
return '{quote}' + quote + '{quote}'
return '{quote}' + escape(quote) + '{quote}'
}
, br: function() {
return '\n'
Expand All @@ -74,7 +77,7 @@ _.extend(Renderer.prototype, rawRenderer.prototype, {

}
, listitem: function(body, ordered) {
return body + '\n'
return escape(body) + '\n'
}
, image: function(href, title, text) {
return '!' + href + '!'
Expand All @@ -87,7 +90,7 @@ _.extend(Renderer.prototype, rawRenderer.prototype, {
}
, tablecell: function(content, flags) {
var type = flags.header ? '||' : '|'
return type + content
return type + escape(content)
}
, code: function(code, lang) {
// {code:language=java|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
Expand Down