git ssb

0+

ev / microbay



forked from Dominic / patchbay

Tree: c6fc57f70589db3b77746a523628b797dae2341f

Files: c6fc57f70589db3b77746a523628b797dae2341f / modules / markdown.js

705 bytesRaw
1var markdown = require('ssb-markdown')
2var h = require('hyperscript')
3var ref = require('ssb-ref')
4//
5
6var blob_url = require('../plugs').first(exports.blob_url = [])
7
8exports.markdown = function (content) {
9 if('string' === typeof content)
10 content = {text: content}
11 //handle patchwork style mentions.
12 var mentions = {}
13 if(Array.isArray(content.mentions))
14 content.mentions.forEach(function (link) {
15 if(link.name) mentions["@"+link.name] = link.link
16 })
17
18 var md = h('div.markdown')
19 md.innerHTML = markdown.block(content.text, {
20 toUrl: function (id) {
21 if(ref.isBlob(id)) return blob_url(id)
22 return '#'+(mentions[id]?mentions[id]:id)
23 }
24 })
25
26 return md
27
28}
29
30
31
32

Built with git-ssb-web