mugiwara85 / CodeblockCustomizer

Codeblock Customizer plugin for Obsidian
MIT License
147 stars 7 forks source link

Can't specify literal values for | or : #93

Open Truncated opened 1 week ago

Truncated commented 1 week ago

The parsing of the abc:xyz and | for constraining lines is nice. However I'm trying to highlight starting or ending on colons and pipes for regex and it doesn't appear that I can start or end on spaces, pipes, or colons as literal values.

Here's an example of one of the documentation lines I am trying to highlight to demonstrate how the reg-ex groups apply: {(workflow)(:name=.*??)(\\|.*??})

{workflow:name=any combo of characters until the first pipe...|after which any combo of characters until an end bracket...}

To highlight three parts of this: workflow :name=any combo of characters until the first pipe... |after which any combo of characters until an end bracket...}

Obviously, straight forward as-is you might want:

hl:workflow,::...,|:}

...of course, that didn't work at all... I tried a bunch of combinations which came up with some interesting results: image image image image image image These last few are interesting... having the pipe specified didn't break it when in the middle of the value, but the highlight doesn't start in the literal spot identified either...

Either being able to optionally wrap abc:xyz in quotes to be explicit a'la "abc":"xyz" or maybe implementing some way to escape the characters for literal use would be helpful.

With quotes, it might become: hl:"workflow",":":"...","|":"}"

As an imperfect workaround, when using the alternative colors (especially if they aren't transparent), the layering did allow me to fake it with: G1:workflow G2:w:... G5:.|:} image

Truncated commented 1 week ago

Couple other characters can't be used to start the abc:xyz elements include:

dash (-) and double-quotes (")

mugiwara85 commented 1 week ago

yeah, this might have to do how I parse the string. I will look at it, and get back to you.

Truncated commented 1 week ago

I think it depends on whether your library / API has a command for "automatically escape anything that needs it to take this string literally as-is" without having to make that parsing and swapping yourself. :)