git ssb

0+

ev / microbay



forked from Dominic / patchbay

Tree: 07376795ee2a1eb1ec1c2ae45fe872324b1edeea

Files: 07376795ee2a1eb1ec1c2ae45fe872324b1edeea / 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