git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit ae04202f98d04cb5fc34599b6ffa72a4936080b3

separate markdown into it's own plugin

Dominic Tarr committed on 7/21/2016, 4:44:35 AM
Parent: 302459fcfd96994394020eeaaf783bc356fa3311

Files changed

modules/markdown.jschanged
modules/markdown.jsView
@@ -1,7 +1,31 @@
1+var markdown = require('ssb-markdown')
2+var h = require('hyperscript')
3+var ref = require('ssb-ref')
4+//
15
2-//
3-//exports.markdown = function (body, msg
4-//
5-//function (text, ref, title) {
6-// return <h
7-//}
6+var blob_url = require('../plugs').first(exports.blob_url = [])
7+
8+exports.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+

Built with git-ssb-web