Question

What's the best solution for authoring HTML5 in Emacs? Is there a mode that will do conformance checking?

Was it helpful?

Solution

My best suggestion is to use nxml-mode (available as packages in several linux distributions if you're on that platform) and load the html5 RelaxNG compact format specifications from HTML5 specification page (or any other source if you have one).

Nxml-mode validates xml files on the fly according to relaxNG specifications and give you nice customization features and handy functions for writing documents faster like inserting end-tags and such. Written by James Clark, so you know the author knows his XML.

If you load it like a system package you can probably just add it to your auto-mode-alist and be good to go. I have just set the following two variables for auto-completion and more docs is available at the first link.

(nxml-bind-meta-tab-to-complete-flag t)
(nxml-slash-auto-complete-flag t)

When it is loaded, just load the file you want and specify the location of the schema for html5, save its location through the menu and you should be on your way. There are also more links to documentation on nxml-mode in the link I provided.

OTHER TIPS

I've just seen this project, which apparently takes care of the necessary work to teach nxml-mode about HTML5:

http://github.com/hober/html5-el/tree/master

An easier to install solution may be web-mode. It definitely plays well with HTML5 and doesn't require you to jump through the XHTML hoops.

JavaScript and CSS blocks work as you would hope.

It also includes the ability to handle common templating languages like php, erb, handlebars, etc.

Check out http://web-mode.org for more details. It's available as a package, at least on MELPA.

I had nXML previously but found the schemas quite cumbersome to install, meaning I didn't get it to work with HTML5. I now use web-mode. Drawback is that there is no real-time validation. But that's cool as there are online-tools for that.

I recommend emmet mode. https://emmet.io/download/ This mode can be enabled in other editors rather than Emacs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top