Open marc-thieme opened 9 months ago
Thanks for the PR! I think allowing custom arguments to be passed to the styling function definitely makes sense (I thought I already added this, but apparently I did not). By that I mean extending create-theorem
with an argument sink (probably only allowing named arguments as you suggested) and just passing them along to the styling function.
What I'm not so sure about is adding a specific argument like "tags", as to me it looks quite specific to your use-case. But with the above approach this should be reasonably simple to implement.
Also I'm not sure when/if I want to release this refactored version since I'm still not quite happy with how it turned out (see #23), and I want to avoid too many breaking changes. Unfortunately adding this feature to main is probably not possible.
This PR adds a tags field to the numbering attachment of the theorem figures. For each instance of a theorem by the document author, they can provide a list of named tags the want to attach to the theorem. These tags will be available to the styling function through params.tags..
I would still need to add tests and some documentation for discoverability of the feature. But before that, I would like to know if you would be open to merging this feature:
Use case for the feature
When each instance of a theorem in your document needs instance-specific metadata to be styled correctly.
For example, I recently prepared for an exam and compiled a collections of theorems we needed to know. I wanted to annotate my theorems with the exam that they were questioned for. The only way this was really possible was by jumbling them up into the name attribute, which was very limiting.
Note this example using my proposed implementation.
The code relies on knowing the theorem name and the exam separately, so it can inject the theorem in between them.
Design and considerations
The proposal at hand:
theorem-kind
function, you may now provide a dictionary of allowed tag values and default values for them.Possible alterations and their downsides:
theorem-kind(..., tags: (exam: (content, str, array), ...)
would clutter code. Also, this is more in line with the (lack of) typing in function signaturesThe implementation at hand is the most conservative one imo