Attempting a DSL on top of htmlgen for fun/learning

2024-04-07 Thread RegularAlias
I made a bit more progress: import macros, htmlgen, strutils macro ph(e: varargs[untyped]): untyped = ## Generates the HTML `merror` element. MathML https://wikipedia.org/wiki/MathML ## https://developer.mozilla.org/en-US/docs/Web/MathML/Element/merror resu

Attempting a DSL on top of htmlgen for fun/learning

2024-04-02 Thread RegularAlias
What do you mean accidentally valid? I also found that if I preassign h1 and p then I can concatenate them as siblings so long as I use &, but the goal here is to have a DSL which has a YAML-like syntax. Do you have any hints as to how I can achieve that? And thanks for the pointer about repr,

Attempting a DSL on top of htmlgen for fun/learning

2024-04-02 Thread PMunch
You seem to be generating macro output which is only accidentally valid for htmlgen. If you change your code to this then it works fine: let html = traverseTree: dv(id = "1", h1(style = "value", "hello world"), p("This is a paragraph")) echo html

Attempting a DSL on top of htmlgen for fun/learning

2024-04-01 Thread RegularAlias
So far this is what I've got: import macros, htmlgen macro traverseTree(body: untyped): untyped = proc processNode(node: NimNode): NimNode = case node.kind of nnkCall: let callee = node[0] var children: seq[Nim