Sublime Forum

HTML Comments and multiple ----

#1

Hi there, i have this issue…

Sometimes you download an html template and it has comments for sections… Like this
But sometimes it has <!-------- This is a comment -------->

Which results in uncolored code like this (Sublime Text 2 and 3):
https://pbs.twimg.com/media/B87oeqiIgAEyaNN.png:large

Any idea how to fix this?

0 Likes

#2

I noticed that the lack of highlighting in code following those “fancy” comment blocks happens when the dashes are in odd numbers, let’s say 3 " —>" in the closing comment tag, if you add one more to make them even, the syntax highlight should be restored…
This even/odd issue happens for closing comment only, the starting one is not affected.

Anyway adding dashes to comments tag is out of spec and a technical syntax error and should be avoided, you could perform a sanitize batch to reset comment tags at file opening :smile:

0 Likes

#3

Impressive, you are right adding one dash fixes it.

I’m agree with you about don’t add extra dashes to comments.

Thanks about batch idea too.

0 Likes

#4

to catch replace you can also use replace with:
find: ()
replace: $1$2$3

note that this is just a quick attempt, i know there should be a better regexp out there :wink:

0 Likes

#5

Awesome… by the way, the replace string should be corrected by $1$3$5 :mrgreen:
By doing this works like a charm.

Thanks :smiley:

0 Likes

#6

[quote=“quakeglen”]Awesome… by the way, the replace string should be corrected by $1$3$5 :mrgreen:
By doing this works like a charm.

Thanks :smiley:[/quote]

yeah I typed it wrong :stuck_out_tongue:
should be $1$3$5 of course :smiley:
sorry my bad

0 Likes

#7

Hi there!

I have a very similar problem (actually the same…), but I cannot solve it by changing the number of dashes. For my project I use Intershop, which has its own scripting lnaguage called ISML. It is almost the same as HTML, but has some additional tags AND - most important - it has a syntax for server side comments (so these are not compiled and so they are not rendered to the client’s). These comments are <!— ---> with 3 dashes each.

So, I cannot simply change them to 2-dashed html-comments or add a 4th dash (would end up in a syntax error). For this reason I am looking for a way of changing or - even better - extending the HTML-syntax so it will fit my needs. In ST2 I simply changed the html-syntax-definitions, but in ST3 this is not possible that easily…

I would be very happy about any suggestions!

0 Likes