diff --git a/.tool-versions b/.tool-versions index b825aa9..7033136 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ elm 0.19.1 +python 3.13.1-v2 diff --git a/TODO.md b/TODO.md index b804b83..c10d2a5 100644 --- a/TODO.md +++ b/TODO.md @@ -18,10 +18,11 @@ # Minor -- [ ] support for Elm debug mode (qjs does not implement `console.warn`, only `console.log`) +- [ ] support for Elm debug (`-d`) mode (qjs does not implement `console.warn`, only `console.log`) - [ ] in debug mode, keep the output -- [ ] allow to specify or guess the main module name -- [ ] allow to create standalone (`s`) HTML document instead of fragment +- [x] allow to specify or guess the main module name +- [x] if `innerHTML` attribute is set, output its value instead of the node tree +- [ ] allow to create standalone (`-s`) HTML document instead of fragment - [ ] silence elm compiler message when successful - [ ] skip compilation steps if source has not been modified ; run directly ; this mean keeping the output - [ ] add proper copyright and license diff --git a/build.debug.sh b/build.debug.sh index 9427117..2d16c97 100755 --- a/build.debug.sh +++ b/build.debug.sh @@ -2,8 +2,7 @@ w1="$(mktemp out_$$_1_XXXX.js)" -#elm make --optimize --output=${w1} src/Main.elm 1>&2 -elm make --output=${w1} src/Main.elm 1>&2 +elm make --output=${w1} $1 1>&2 sed -i -e 's!console.warn(!console.log(!g' ${w1} w2="$(mktemp out_$$_XXXX.js)" diff --git a/dom.js b/dom.js index 8122322..7e70b6b 100644 --- a/dom.js +++ b/dom.js @@ -21,6 +21,10 @@ function Node(parent, tag) { print(this.text); return } + if (this.innerHTML) { + print(this.innerHTML); + return + } std.printf("<%s", this.tagName) // Set.difference(other) is not avalable in qjs for (a of Object.keys(this)) { @@ -52,3 +56,9 @@ document.getElementById = (_id) => { return target} document.createElement = (tag) => new Node(null, tag); document.createTextNode = (text) => { t = new Node(null, "#text" ); t.text = text; return t } + + +// workaround for elm-explorations/markdown Markdown.toHtml +global = {}; + + diff --git a/uloc.sh b/uloc.sh index 64d0bca..bcbbca5 100755 --- a/uloc.sh +++ b/uloc.sh @@ -1,3 +1,3 @@ #!/bin/sh -eu -countuniq0 build.sh dom.js launch.js +countuniq0 build.sh dom.js postelm.js preelm.js