From e0a0b25f6586cdf1b1284d97bedadfce5535ba96 Mon Sep 17 00:00:00 2001
From: s-ol
Date: Thu, 3 Dec 2020 17:38:43 +0100
Subject: move plugins into root
---
.../converts: text$moonscript -> table.moon | 67 ++++++++++++++++++++++
.../plugins/markdown/scripts: text$html+frag.html | 1 +
2 files changed, 68 insertions(+)
create mode 100644 root/$mmm/plugins/markdown/converts: text$moonscript -> table.moon
create mode 100644 root/$mmm/plugins/markdown/scripts: text$html+frag.html
(limited to 'root/$mmm/plugins/markdown')
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) => "
%s*', '' + html = html\gsub '%s*
%s*$', '' + 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 @@ + -- cgit v1.2.3