mugiwara85/CodeblockCustomizer

Can't specify literal values for | or :

Opened this issue · 6 comments

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

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

dash (-) and double-quotes (")

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

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. :)

@Truncated This was also implemented. Unfortunately, this was more problematic as it seems, but I solved using a workaround.
The reason you couldn't specify | or : for highlighting is, because these chars are used to split the parameter, to get the values. There could be a lot of problems with, for example if you want to do something like: hlt:string:sdf:sdf:fg Which : would here mean the separator? And many other cases.

But to cut to the chase, I did the following. In the settings page there is a line sperator, and text separator option, where you can define them globally. You can also use the lsep (Line Separator) and tsep (Text separator) option to define these specifically for code blocks. So for example if you want to highlight text which has a : in it, you could do something like : hlt:mystring:/end lsep:/ This way the string would be splitted at the / char and not at :.

Hopefully, this is ok, but I think this way everyone can cover every possible case.

As always, I would appreciate a good test, and a feedback before releasing it.

Will do!

Oh wait, I found a few bugs. Don't test it yet please.