nxml-mode and html 5

2009-09-26T10:25:25
Dave Pawson.  link
Home

html5

nxml-mode setup

Read this ;-)

Installation. Read .

Install all the files from here into a directory of your choosing, say <inst>.

Assuming you already have a file for nxml-mode to locate an appropriate schema... then simply add this section to it. If not... then I guess you need to learn how to use nxml-mode!

 <uri pattern="*.html" typeId="XHTML5"/>
  <uri pattern="*.xhtml" typeId="XHTML5"/>
  <namespace ns="http://www.w3.org/1999/xhtml" typeId="XHTML5"/>
  <documentElement localName="html" typeId="XHTML5"/>
  <ttypeId id="XHTML5" uri="relaxng/xhtml5.rnc"/>

My only bugbear on this.... is picking up the uri for a ttypeid of XHTML5. The schema location should be <inst>/xhtml5.rnc (or even <inst>/xhtml.rnc depending on whether you want to use xhtml or html. I haven't figured that one as yet. Either way, modify the last line to reflect the location of where you've put the schema files.

Now go get the schema files.... this is the source. wget is your friend. Retrieve the tests and datatypes (the latter only if you want some work towards Jing support)

That leaves a mix of elisp files, rnc schema files and a few oddments in the <inst> directory.

next step is to tell emacs about these files. Firstly let emacs know where they all are: In your .emacs file:


(add-to-list 'load-path "<inst>")

Provides initial access to the .el files and the rnc files

Finally, for datatype validation, emacs needs to load the code in whattf-dt.el . Do this using

(add-hook 'nxml-mode-hook 
(function (lambda()
(require 'whattf-dt)
)))

This 'requires' the functionality only when you are in nxml-mode, rather than each time emacs is loaded

You should now be able to select the schema and have syntax directed editing for html 5!

Of note, from Henri,

Of note (2009-09-26T10:28:19Z)

The whattf schema is the most complete HTML5 schema that I'm aware of. It's not quite up-to-date regarding the spec changes in the last couple of weeks.

And a test document

test file, a test document, from a quick skim of the html WD. See how it displays in your browser! I originally named it html5.xml but my FF didn't like that, so changed it to html which fails to show the svg and mathml. back to .xhml on the advice of @shelleypowers, with application/xhtml+xml as the content-type and .htaccess entry! Finally found a use for the .xhtml extension!

Keywords: html5

Comments (View)

Return to main index