commit 506f79111bd3b44c6c5d7d743d54d074a2f40e84 parent c3d4b91b1ac16d71080dfacec9f2a692762b1344 Author: Daniel Barlow <dan@telent.net> Date: Sun, 20 Jul 2025 23:56:28 +0100 textile to-html renders a href ... more generally, the intermediate form generated by parsing can model elements as e.g. [:b "bold text"] or as [[:b { :attr "foo } ] "bold text"] but we weren't converting the latter form to html and now we are Diffstat:
| M | textile.fnl | | | 14 | +++++++++++--- |
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/textile.fnl b/textile.fnl @@ -272,11 +272,19 @@ (fn to-html [out-stream el] (if (= (type el) :string) (out-stream:write el) - (let [[tag & content] el] - (out-stream:write (string.format "<%s>" tag)) + (let [[tag & content] el + (name attrstring) + (case tag + [name attrs] + (values name (accumulate [s "" + name value (pairs attrs)] + (.. s " " (string.format "%s=%q" name value)))) + name + (values name ""))] + (out-stream:write (string.format "<%s %s>" name attrstring)) (each [_ child (ipairs content)] (to-html out-stream child)) - (out-stream:write (string.format "</%s>" tag))))) + (out-stream:write (string.format "</%s>" name))))) (define-tests :parse-stream