diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-11-08 14:39:07 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-11-08 14:46:09 -1000 |
commit | a989374f143a885920e640296902d5bbf4fe8086 (patch) | |
tree | fdc67fabd09a199980ed426551c58da033cb9e80 /lib/render.js | |
parent | c9f375a151cc8caa74c341f054e8a3e0cdc96b52 (diff) | |
download | patchfoo-a989374f143a885920e640296902d5bbf4fe8086.tar.gz patchfoo-a989374f143a885920e640296902d5bbf4fe8086.zip |
Add dualMarkdownPreview option
Diffstat (limited to 'lib/render.js')
-rw-r--r-- | lib/render.js | 10 |
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) |