aboutsummaryrefslogtreecommitdiff
path: root/lib/render.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/render.js')
-rw-r--r--lib/render.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/render.js b/lib/render.js
index f3dcfe0..fc2407e 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -12,6 +12,7 @@ var u = require('./util')
var multicb = require('multicb')
var RenderMsg = require('./render-msg')
var Highlight = require('highlight.js')
+var md = require('ssb-markdown')
module.exports = Render
@@ -166,8 +167,9 @@ function fixSymbols(str) {
}
*/
-Render.prototype.markdown = function (text, mentions) {
+Render.prototype.markdown = function (text, mentions, opts) {
if (!text) return ''
+ var ssbcMd = opts && opts.ssbcMd
var mentionsObj = this._mentions = {}
var mentionsByLink = this._mentionsByLink = {}
if (Array.isArray(mentions)) mentions.forEach(function (link) {
@@ -184,7 +186,11 @@ Render.prototype.markdown = function (text, mentions) {
'?unbox=' + link.query.unbox.replace(/\s/g, '+') : '') +
(link.key ? '#' + link.key : '')] = link
})
- var out = marked(String(text), this.markedOpts)
+ var self = this
+ var out = ssbcMd ? md.block(String(text), {
+ toUrl: function (ref) { return self.toUrl(ref) },
+ imageLink: function (ref) { return self.imageUrl(ref) }
+ }) : marked(String(text), this.markedOpts)
delete this._mentions
delete this._mentionsByLink
return out //fixSymbols(out)