diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-10-27 21:58:35 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-10-27 21:58:35 +0000 |
| commit | da4d5283a6cb563758ff3678d98e9358c53266d7 (patch) | |
| tree | da8fb7f49b624435f703869f3b4986c2240545d2 /root | |
| parent | fix the damn text width problem, once and for all ???? (diff) | |
| download | mmm-da4d5283a6cb563758ff3678d98e9358c53266d7.tar.gz mmm-da4d5283a6cb563758ff3678d98e9358c53266d7.zip | |
fix syntax highlighting in markdown
Diffstat (limited to 'root')
| -rw-r--r-- | root/articles/mmmfs/ba_log/2019-10-27/text$markdown.md | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/root/articles/mmmfs/ba_log/2019-10-27/text$markdown.md b/root/articles/mmmfs/ba_log/2019-10-27/text$markdown.md index 752c355..3e9f886 100644 --- a/root/articles/mmmfs/ba_log/2019-10-27/text$markdown.md +++ b/root/articles/mmmfs/ba_log/2019-10-27/text$markdown.md @@ -19,35 +19,37 @@ First, here is the convert itself: and the main part of the code, the `Editor` widget: - class Editor - new: (value, mode, @fileder, @key) => - @node = div class: 'editor' - -- 'o' is a little helper for converting a Lua table to a JS object - @cm = window\CodeMirror @node, o { - :value - :mode - lineNumber: true - lineWrapping: true - autoRefresh: true - theme: 'hybrid' - } +```moonscript +class Editor + new: (value, mode, @fileder, @key) => + @node = div class: 'editor' + -- 'o' is a little helper for converting a Lua table to a JS object + @cm = window\CodeMirror @node, o { + :value + :mode + lineNumber: true + lineWrapping: true + autoRefresh: true + theme: 'hybrid' + } - @cm\on 'changes', (_, mirr) -> - window\clearTimeout @timeout if @timeout - @timeout = window\setTimeout (-> @change!), 300 + @cm\on 'changes', (_, mirr) -> + window\clearTimeout @timeout if @timeout + @timeout = window\setTimeout (-> @change!), 300 - change: => - @timeout = nil - doc = @cm\getDoc! - if @lastState and doc\isClean @lastState - -- no changes since last event - return - - @lastState = doc\changeGeneration true - value = doc\getValue! + change: => + @timeout = nil + doc = @cm\getDoc! + if @lastState and doc\isClean @lastState + -- no changes since last event + return + + @lastState = doc\changeGeneration true + value = doc\getValue! - @fileder.facets[@key] = value - BROWSER\refresh! + @fileder.facets[@key] = value + BROWSER\refresh! +``` I chose the [CodeMirror][codemirror] library as the basis for the editor, because it seemed like one of the leanest ones I could find |
