-
When working on "generic" styling, inputters and programmatic command creation, I got some design issues which I'll try to explain here...
We use the latter quite a bit in the code base. Let's illustrate this strategy with some dumb and naive commands ("approach 1"):
So far so good, or so it seems: It outputs "see my little example", with my "default" style hook applied, so I get "see my little example" which was expected... But say I now want a different style to be applied, so I override the hook as follows:
Guess what happens... It errors.
Text casing uses an input filter, and those choke on functions. They always expect a structure AST (i.e. tables). Well, back to what I said in the very first sentence, maybe we should have used a structured AST table, rather than a functional call? Let's try it and re-implement our command ("approach 2"):
All of a sudden, it works with the initial italicizing hook or my overridden upper-casing hook as well. Yay!? But here we need to know a bit more about what SILE expects as an AST.
Regarding the latter point, it's because the
So yeah, we have to extract the sub content tree (i.e. the array elements, ignoring the toplevel key-value elements), since we already are processing the "see" command... Let's call this issue B.
In my packages, I realize I am more and more moving from "approach 1" (functional calls) to "approach 2" (AST hacking)... But I am not sure how else the issue may be addressed.
EDIT: References for cases where I used "approach 2" recently:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I don't really expect an answer now - I'll definitively move towards removing as many Additional question of the day: why |
Beta Was this translation helpful? Give feedback.
#1914 proposes its removal (addressing B1 and B2 concerns)