CodeblockCustomizer icon indicating copy to clipboard operation
CodeblockCustomizer copied to clipboard

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

Open hackerman-Dan opened this issue 1 year ago • 17 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

hackerman-Dan avatar Mar 22 '24 10:03 hackerman-Dan

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

mugiwara85 avatar Mar 22 '24 10:03 mugiwara85

yeah that could work

hackerman-Dan avatar Mar 22 '24 10:03 hackerman-Dan

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?

mugiwara85 avatar Mar 22 '24 11:03 mugiwara85

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

hackerman-Dan avatar Mar 22 '24 11:03 hackerman-Dan

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

mugiwara85 avatar Mar 22 '24 11:03 mugiwara85

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

hackerman-Dan avatar Mar 22 '24 11:03 hackerman-Dan

you can highlight text and also the line: image

Or I don't understand what you want.

mugiwara85 avatar Mar 22 '24 11:03 mugiwara85

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

hackerman-Dan avatar Mar 22 '24 11:03 hackerman-Dan

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

hackerman-Dan avatar Mar 22 '24 11:03 hackerman-Dan

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?

hackerman-Dan avatar Mar 22 '24 11:03 hackerman-Dan

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

mugiwara85 avatar Mar 22 '24 11:03 mugiwara85

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

hackerman-Dan avatar Mar 22 '24 14:03 hackerman-Dan

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

hackerman-Dan avatar Mar 22 '24 14:03 hackerman-Dan

exactly :)

mugiwara85 avatar Mar 26 '24 14:03 mugiwara85

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

hackerman-Dan avatar Apr 24 '24 19:04 hackerman-Dan

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

hackerman-Dan avatar Apr 24 '24 19:04 hackerman-Dan

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?

mugiwara85 avatar Apr 24 '24 22:04 mugiwara85

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

mugiwara85 avatar Jun 05 '24 22:06 mugiwara85

@hackerman-Dan : it is available in version 1.2.7

mugiwara85 avatar Jun 13 '24 21:06 mugiwara85