Secondary Language Highlighting, CSS in web languages

Two improvements have recently been pushed to RSTA. First, inline CSS is highlighted in HTML, PHP, and JSP files. Previously, inline CSS was rendered as plain text; now it’s rendered just as if CSS highlighting were enabled.

CSS Highlighting in an HTML document

These days, TokenMakers for web-based languages are each actually highlighting several languages – JavaScript, CSS, HTML, and possibly JSP/PHP. This means in documents with lots of inline scripts and styles, it’s not immediately obvious with a visual scan what you’re looking at with syntax highlighting alone. Which brings me to the second new feature – secondary language highlighting. When enabled, this allows TokenMakers to specify Tokens as belonging to specific “secondary” languages. When secondary language highlighting is enabled, such Tokens are painted with a special background color. This results in regions of code such as JavaScript and CSS blocks to be painted with a different background, as seen in the screenshot above. It can be extra useful when viewing generated HTML with poor formatting:

Secondary Language Highlighting – JS and CSS in HTML

The bad news is, this feature comes at a fair performance penalty (since the background is painted for each individual Token, not for the entire region at once). On good hardware (especially Windows machines) this shouldn’t really be a problem, but for this reason, this feature is disabled by default. To enable and query it, use these methods in the RSyntaxTextArea class:

There are currently three secondary language backgrounds, which I’m assuming is a sufficient and practical number until someone proves otherwise. The Theme DTD and API have been updated so that themes specify the background colors for secondary languages as well.

This entry was posted
on Wednesday, July 11th, 2012 at 9:46 pm and is filed under RSyntaxTextArea.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

One Response to “Secondary Language Highlighting, CSS in web languages”