Post #2280776
2025-10-30 18:30 UTC
Replies (1)
-
@sminez@hachyderm.io 2025-11-01 16:22
@jbert@hachyderm.io OK, still very much a work in progress but I've pushed it up to crates.io in order to nab the "structex" name while I finish things off. https://github.com/sminez/structex This example shows how to use it alongside something like handlebars in order to get string templated printing working as an action ๐ https://github.com/sminez/structex/blob/main/examples/fancy_impl_blocks.rs It's only had minimal testing so far and I suspect there's a bunch of things that don't work quite right but I think as a proof of concept it gets the idea across? The idea is to split the problem into two parts in order to avoid a bunch of issues with how actions interleave with the regex search: 1. Apply the structural regular expression terms to an input in order to locate sub-strings. Each match may then be assigned a tag with optional content that will be emitted along with matches when they are found. 2. Consume that stream of tagged matches and handle the actions as needed. I have some more ideas on making the construction of a structex more robust (setting allowed tags etc) which I'll add once I've sorted out the testing and docs. (@oac@fosstodon.org you might find this fun as well!)