From 257672152b93c08f573db2912eef2b9a4145d5f5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 1 Jun 2023 20:20:40 -0700 Subject: New feature: deftag macro. The deftag macro targets the HTML markup syntax itself rather than Lisp forms within it. deftag macros masquerade as tag markup, but rewrite themselves into other markup. They can produce multiple elements using (progn ...) and can move element attribute material into the avlue position and vice versa. They can destructure attributes using keyword parameters, and easily default the values of required attributes and such. * packages.tl (tl-who): New symbol, deftag. * specials.tl (*tag-macro*): New special variable, holding a hash table of deftag definitions. * who.tl (process-tag): After a tag is parsed, we check whether there is a macro defined for it. If so we call its expander lambda. This is done here because this function has the parsed pieces of the tag. The higher level above this function doesn't, and after this function, everything is just a flat list of strings and other objects. Here we recognize whether the macro put out a progn shape, and iterate over the multiple items it contains. (scrub-kw-args): New function. This is a helper function used by deftag expanders to remove, from the attribute rest parameter, those keyword arguments which were captured by the named parameters. (deftag): New macro. * test/simple.tl: New test cases 50-54 targeting deftag. * README.md: Documented. --- packages.tl | 1 + 1 file changed, 1 insertion(+) (limited to 'packages.tl') diff --git a/packages.tl b/packages.tl index bad0c40..0eaca09 100644 --- a/packages.tl +++ b/packages.tl @@ -38,6 +38,7 @@ "conc" "convert-attributes" "convert-tag-to-string-list" + "deftag" "esc" "escq" "escj" -- cgit v1.2.3