This post is for Swift developers interested in the implementation details of Bike’s outline paths. It’s inspired by Swift Blog Carnival: Tiny Languages.
This is a companion discussion topic for the original entry at https://www.hogbaysoftware.com/posts/bike-outline-path-implementation
2 Likes
Questions/Suggestions welcome. I’m not sure if the Claude Code extraction is enough to get you started with syntax highlight, but it seems to work pretty well in practice. I can provide more details if you get far enough to need them.
Is there anywhere that we can look for details of the regular expression idiom that works with the matches keyword ?
( I haven’t yet figured out how to match word boundaries or white space – I don’t think that \b or \s, for example, seem to be available ?)
UPDATE
Got it. We just need a doubled backslash, at least in ordinary filtering …
//@text matches "\\bsum\\b"
but perhaps style-sheet path matching has slightly different requirements ?
This matches and applies a style as expected (assumes only one class name in @classes)
row(`.@classes matches "^term$"`, (_, row) => {
row.text.color = Color.systemRed();
})
but neither of these seem to (\b or \\b)
row(`.@classes matches "\bterm\b"`, (_, row) => {
row.text.color = Color.systemRed();
})
row(`.@classes matches "\\bterm\\b"`, (_, row) => {
row.text.color = Color.systemRed();
})
I think this can be cleaned up some on Bike’s side, but for now just keep adding escapes, or use String.raw for paths in stylesheets. I think either of these should work:
row(`.@classes matches "\\\\bterm\\\\b"`, (_, row) => {
row.text.color = Color.systemRed();
})
row(String.raw`.@classes matches "\\bterm\\b"`, (_, row) => {
row.text.color = Color.systemRed();
})
The issue is that we want to enter /b for the regex, but we have to go through two layers of escapes. I am parsing the "" as a JSON string, and that means need to escape once. And then when the outline path is in a stylesheet (which is javascript), that adds another level of escaping.
1 Like
Thanks !
I shouldn’t have given up at 3 … 
( 貴在堅持 – persistence unlocks most things )
1 Like
Also, currently Bike outline path predicates have modifies i s n d. For case insensitive, sensitive, numeric, and date. TaskPaper also had l for list, and it was partially implemented in Bike, but not fully. I’m implementing that for next release. Which would allow you to use:
row(`.@classes contains[l] "term"`, (_, row) => {
row.text.color = Color.systemRed();
})
Edit Also realizing that [d] was only implemented in parser, not evaluator. Fixing that too…
1 Like