mugiwara85 / CodeblockCustomizer

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

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

Closed hackerman-Dan closed 2 weeks ago

hackerman-Dan commented 3 months ago

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

mugiwara85 commented 3 months ago

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

hackerman-Dan commented 3 months ago

yeah that could work

mugiwara85 commented 3 months ago

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?

hackerman-Dan commented 3 months ago

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

mugiwara85 commented 3 months ago

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

hackerman-Dan commented 3 months ago

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

mugiwara85 commented 3 months ago

you can highlight text and also the line: image

Or I don't understand what you want.

hackerman-Dan commented 3 months ago

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 commented 3 months ago

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

hackerman-Dan commented 3 months ago

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?

mugiwara85 commented 3 months ago

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

hackerman-Dan commented 3 months ago

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

hackerman-Dan commented 3 months ago

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

mugiwara85 commented 3 months ago

exactly :)

hackerman-Dan commented 2 months ago

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 commented 2 months ago

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

mugiwara85 commented 2 months ago

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:

mugiwara85 commented 3 weeks ago

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 commented 2 weeks ago

@hackerman-Dan : it is available in version 1.2.7