mugiwara85/CodeblockCustomizer

Feature request, highlighting in code block until the specified character/phrase is reached

Closed this issue · 19 comments

It would be nice to be able to specify in the highlighting when you want it to highlight in a line from word to word, instead of having to exactly type the entire string of words you want highlighted

The main reason I want it is to highlight in comments in codeblocks, without needing to retype the entire phrase I want highlighted

In my own comments like I use //# and then can end with #// and want all text within highlighted

how would you want to use it? I mean use the hl parameter, like: hl:fromtext-totext?

yeah that could work

if i understand it correctly, the from and totext must not be in one line, right?
so if the fromtext is in line 2 and the totext is is line 10, then all the text should be highlighted? or both of them must be in one line?
Also what if there are multiple fromtext and totext in the text of the code block?

hm for my usecase it is just for highlighting in one line

ok, I'll think about it, what would be the best way to implement it

currently, there is no way for me to highlight a line and then also highlight a sentence again within the line.
because you can say like hl:2|"this is a sentence" which will work

but if you want to highlight a line and then also again a sentence it ignores the string section since you specify a line already
but like you can do hl:2,//# where line 2 is:

this is code //# this is my comment which I also want highlighted

which will highlight line 2, and then also //# but the rest is obviously not highlighted in the 2nd level of highlighting

at least for me I think it would be nice if I could say to highlight between the characters wherever it is in the code block
so all my custom comments will be highlighted

you can highlight text and also the line:
image

Or I don't understand what you want.

huh if I use php File:functions.lib.php imp:"checks if contains ::" hl:4,5,//#
it doesnt do the additional highlight for the text within imp like in your example
image

ah wait is imp a defined alternative highlight color in your example?

how do I use the same alternative highlight multiple times for different sentence instances in the same codeblock?
image
so like if I wanted to highlight also my comment in line 5?
do I need to just create duplicate alternate colours and then say like imp1 imp2 imp3?

you could just say imp:"//# check if contains :: #//", "//# return value #//"
but in this case you are right, it would be better to define a from and to text to highlight between so you dont have to retype the whole comment

huh weird, I can't get it to work using imp:"text1","text2"
image

for now my workaround is to create many alternative highlights and just reference a different one each time in the code block which works

ah i see it has to be imp:"text1, text2" then it works

exactly :)

hi @mugiwara85 I'm having some difficulties when it's a big codeblock, the header appears to be limited by the length of the screen? i.e. the work around I was using, doesn't work if the comments/things I want to highlight are very long at some point. It is limited by the length of the codeblock it seems. At some point I think it would be better to implement some way to highlight between some specified characters

I'm imagining using a character combination of sorts, that anything between is highlighted. like if you put ~ ~ or something

The header is not limited by length. It might be caused by the theme you are using. Which theme are you using? Can you show me a screenshot?

Yes, we talked about this earlier. But there are a few questions/problems:

  • How do you want to define it exactly? using a from and to parameter, or something like that?
  • What happens when the from and to text are found multiple times in a codeblock? There should be probably a way to also define that only specific lines/ranges should be highlighted, otherwise the from first found from char to the last found to char?

I decided that you could use your highlight colors like this: hl:<startphrase>:<endphrase> or hl:5|<startphrase>:<endphrase> or hl:5-9|<startphrase>:<endphrase>
In editing view it is already working. I do reading view tomorrow, and will be released with the next release.
image

@hackerman-Dan : it is available in version 1.2.7