git ssb

16+

Dominic / patchbay



Commit a48b8e932c4ae4ce8ffaf7d73f6a8ab26057700c

Merge pull request #76 from ssbc/markdown_module_css

add Markdown mcss
mix irving authored on 1/25/2017, 7:56:23 AM
GitHub committed on 1/25/2017, 7:56:23 AM
Parent: afb86dcf033be6fdcb0a54989c55a37a00162d23
Parent: f5019994e9135c7fd3dd5614b1006254d170cf63

Files changed

modules_basic/markdown.jschanged
modules_basic/markdown.mcssadded
modules_basic/markdown.jsView
@@ -1,27 +1,26 @@
1-var markdown = require('ssb-markdown')
2-var h = require('hyperscript')
3-var ref = require('ssb-ref')
1 +const renderer = require('ssb-markdown')
2 +const fs = require('fs')
3 +const h = require('../h')
4 +const ref = require('ssb-ref')
45
56 exports.needs = {
67 blob_url: 'first',
78 emoji_url: 'first'
89 }
910
10-exports.gives = 'markdown'
11 +exports.gives = {
12 + markdown: true,
13 + mcss: true
14 +}
1115
1216 exports.create = function (api) {
13-
14- function renderEmoji(emoji) {
15- var url = api.emoji_url(emoji)
16- if (!url) return ':' + emoji + ':'
17- return '<img src="' + encodeURI(url) + '"'
18- + ' alt=":' + escape(emoji) + ':"'
19- + ' title=":' + escape(emoji) + ':"'
20- + ' class="emoji">'
17 + return {
18 + markdown,
19 + mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
2120 }
2221
23- return function (content) {
22 + function markdown (content) {
2423 if('string' === typeof content)
2524 content = {text: content}
2625 //handle patchwork style mentions.
2726 var mentions = {}
@@ -29,10 +28,10 @@
2928 content.mentions.forEach(function (link) {
3029 if(link.name) mentions["@"+link.name] = link.link
3130 })
3231
33- var md = h('div.markdown')
34- md.innerHTML = markdown.block(content.text, {
32 + var md = h('Markdown')
33 + md.innerHTML = renderer.block(content.text, {
3534 emoji: renderEmoji,
3635 toUrl: (id) => {
3736 if(ref.isBlob(id)) return api.blob_url(id)
3837 return '#'+(mentions[id]?mentions[id]:id)
@@ -42,6 +41,16 @@
4241
4342 return md
4443
4544 }
45 +
46 + function renderEmoji(emoji) {
47 + var url = api.emoji_url(emoji)
48 + if (!url) return ':' + emoji + ':'
49 + return '<img src="' + encodeURI(url) + '"'
50 + + ' alt=":' + escape(emoji) + ':"'
51 + + ' title=":' + escape(emoji) + ':"'
52 + + ' class="emoji">'
53 + }
54 +
4655 }
4756
modules_basic/markdown.mcssView
@@ -1,0 +1,14 @@
1 +Markdown {
2 +
3 + blockquote {
4 + margin: 1rem 0;
5 + padding-left: 1rem;
6 +
7 + border-left: 3px gainsboro solid
8 + }
9 +
10 + (ul) {
11 + padding-left: 1rem;
12 + }
13 +}
14 +

Built with git-ssb-web