Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Minor HTML syntax highlighting issue in "style" element

When LMD SyntaxEdit uses HTML.xml to parse HTML documents, is it possible to stop parsing "<!-- xxx -->" in "style" elements as comments? Comments in "style" elements should only be in the form "/* comment */".

Currently, when this is used:
<style>
<!--
 a{background:blue;}
-->
</style>

The CSS is highlighted in green like it is in a comment, but because it's in a "style" element, browsers will see and apply the CSS... so it's not really a comment and shouldn't be highlighted as such.

Instead, it might be nice if "<!--" and "-->" were highlighted in red when they're used in "style" elements.... or at least not treated as comment markers in "style" elements.

Not a big deal as it's been like this for years, but it would be nice if the above could be done. Hopefully it is an easy update to HTML.xml. I haven't tried to make the change myself though.

That same applies within "script" elements as well.

Thanks.

Comments

  • 4 Comments sorted by Votes Date Added
  • This is not easy to fix, if possible at all. Since mentioned rules breaks underlying XML syntax.
    I will consider it as a todo item for futher investigation.
  • I understand. It's not that important so if it's not easy to fix then it would be better to spend time on something else.

    I'd much rather see some new features.... like a vertical bar in the gutter that shows which lines have been modified and whether the modified lines have been saved or not (based on color), like the RAD Studio IDE. Any chance of that being added? I find this feature very useful.
  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Fixed. As I understand Xml style comments are not allowed even in general CSS, not only in CSS embedded into <style> tags.
  • Great! "<!-- -->" should not highlight as comments in both "style" and "script" elements in HTML files.

    As for "pure" CSS *.css files, you're right that the comments shouldn't work there either (just /* ... */). I just checked and it looks like "<!-- -->" is highlighting as comments in CSS files so I assume you have fixed this as well.

    Off the top of my head, "<!-- -->" comments should only work in HTML when not in "style" and "script" and in XML files.

    Hmm.. I guess this brings up another issue.... in XHTML, "<!-- -->" should work everywhere including in "style" and "script" elements... but I suppose this can be ignored unless there's an easy fix.

    Thank you.
Sign In or Register to comment.