diff options
| author | s-ol <s+removethis@s-ol.nu> | 2020-12-03 16:38:43 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2020-12-03 16:38:43 +0000 |
| commit | e0a0b25f6586cdf1b1284d97bedadfce5535ba96 (patch) | |
| tree | 50cf646dc673faeda648e7135d84e46f2dbd5262 /root/$mmm/plugins/markdown | |
| parent | fix typo break text/html+interactive (diff) | |
| download | mmm-e0a0b25f6586cdf1b1284d97bedadfce5535ba96.tar.gz mmm-e0a0b25f6586cdf1b1284d97bedadfce5535ba96.zip | |
move plugins into root
Diffstat (limited to 'root/$mmm/plugins/markdown')
| -rw-r--r-- | root/$mmm/plugins/markdown/converts: text$moonscript -> table.moon | 67 | ||||
| -rw-r--r-- | root/$mmm/plugins/markdown/scripts: text$html+frag.html | 1 |
2 files changed, 68 insertions, 0 deletions
diff --git a/root/$mmm/plugins/markdown/converts: text$moonscript -> table.moon b/root/$mmm/plugins/markdown/converts: text$moonscript -> table.moon new file mode 100644 index 0000000..4e0da31 --- /dev/null +++ b/root/$mmm/plugins/markdown/converts: text$moonscript -> table.moon @@ -0,0 +1,67 @@ +markdown = if MODE == 'SERVER' + success, discount = pcall require, 'discount' + assert success, "couldn't require 'discount'" + + (md) -> + res = assert discount.compile md, 'githubtags', 'fencedcode' + res.body +else + assert window and window.marked, "marked.js not found" + + o = do + mkobj = window\eval "(function () { return {}; })" + (tbl) -> + with obj = mkobj! + for k,v in pairs(tbl) + obj[k] = v + + trim = (str) -> str\match '^ *(..-) *$' + + window.marked\setOptions o { + gfm: true + smartypants: true + langPrefix: 'lang-' + highlight: (code, lang) => + code = trim code + result = if lang and #lang > 0 + window.hljs\highlight lang, code, true + else + window.hljs\highlightAuto code + + result.value + } + + window\marked + +assert markdown, "no markdown implementation found" + +{ + { + inp: 'text/markdown' + out: 'text/html+frag' + cost: 1 + transform: (md) => "<div class=\"markdown\">#{markdown md}</div>" + } + { + inp: 'text/markdown%+sidenotes' + out: 'text/html+frag' + cost: 1 + transform: (md) => "<div class=\"markdown sidenote-container\">#{markdown md}</div>" + } + { + inp: 'text/markdown%+wide' + out: 'text/html+frag' + cost: 1 + transform: (md) => "<div class=\"markdown wide\">#{markdown md}</div>" + } + { + inp: 'text/markdown%+span' + out: 'text/html+frag' + cost: 1 + transform: (source) => + html = markdown source + html = html\gsub '^%s*<p>%s*', '<span>' + html = html\gsub '%s*</p>%s*$', '</span>' + html + } +} diff --git a/root/$mmm/plugins/markdown/scripts: text$html+frag.html b/root/$mmm/plugins/markdown/scripts: text$html+frag.html new file mode 100644 index 0000000..5bfb275 --- /dev/null +++ b/root/$mmm/plugins/markdown/scripts: text$html+frag.html @@ -0,0 +1 @@ + <script type="text/javascript" src="//unpkg.com/marked@0.7.0/marked.min.js"></script> |
