Markup Language Enhancements in RSTA

I decided to give the markup languages (XML, HTML, JSP and PHP) a little love  in RSyntaxTextArea.  Their syntax is so structured it should be easier to support more advanced features with them than with more abstract languages.

The first thing I did was “soften” the default color scheme used for markup languages.  Here’s how an HTML file looks out-of-the-box now:

Softer color scheme

Softer color scheme

Note that element names are now differentiated from attributes.  I may end up softening the string color as well, as that’s still a little obnoxious.

With things looking nicer, I decided to implement a new time-saving feature.  Now, typing “</” in an XML file will automatically complete the closing tag with the correct tag name.  e.g. typing:

<foo></

will type the following into the editor:

<foo></foo>

A welcome time-saver.  This feature can also be toggled on with HTML, JSP and PHP, but by default it is off, due to HTML often accepting unclosed tags such as <p>, <hr>, etc., which would mess up close-tag completions.

Going one step further from completing closing tags, I also used the AutoComplete library to add auto-completion for HTML, JSP and PHP.  The completion is very smart:

  • It only offers tag names as suggestions when you’re at the start of a tag (e.g. “<” or “<ht”).
  • If you’ve already typed a tag name, only the attributes valid for that tag will be offered as completion choices until the tag is closed.
  • No completion choices are offered if it doesn’t make sense (you’re in a comment, a string literal, in embedded JavaScript, etc.).
Auto-completing an HTML tag

Auto-completing an HTML tag

Intelligent attribute completion

Intelligent attribute completion

HTML/JSP/PHP code completion will definitely be integrated into the next RText release, but I’d like to figure out a way to release it alongside the standard AutoComplete library.  I don’t think it should be a part of the main library itself (why bloat the library with completion support for a language that might not be needed by all users?), but perhaps some kind of additional jar, that includes pre-built support for certain languages such as this?

If anybody would like to help filling in the gaps in the description for HTML tags and their attributes for this HTML code completion, get in contact with me.  I scraped some basic info off the web, but it’s really lacking.  You would of course receive credit for your input.

Comments are closed.