git ssb

16+

Dominic / patchbay



Tree: 6d8c497b8410ed867ce8d18379bf732e0cf1e5f6

Files: 6d8c497b8410ed867ce8d18379bf732e0cf1e5f6 / 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