git ssb

16+

Dominic / patchbay



Tree: d0b1c05b483fa6de9080159f9713c98893cdb358

Files: d0b1c05b483fa6de9080159f9713c98893cdb358 / modules_basic / markdown.js

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

Built with git-ssb-web