If you don’t use Emacs to write MJT code then stop reading now.
nXhtmlMode will dramatically improve your productivity if you write MJT code in Emacs. It highlights invalid XHTML as you type so you never have strange MJT bugs due to unclosed DIVs. You can also add a MJT schema to avoid unnecessary warnings about proprietary attributes.
Step by step guide to installing nXhtml mode
- Download the latest version of nXhtml.zip
- Unzip into a directory, for example: ~/.emacs.d
- Edit your .emacs and add
- Run emacs, open an HTML file and type
Accept the default customization:
- Click “remove this message”
- Set Nxhtml Skip Welcome: “toggle” to on
- Click “Save for future sessions”
- Click “Finish”
Install the MJT schema
(At this stage, any errors in your HTML should be highlighted. Unfortunately all the special MJT attrbitues will be highlighted as errors too. We can fix this by overriding the XHTML schema with a MJT schema)
- Download mjt.rnc
- Move mjt.rnc to ~/.emacs.d/nxml/nxml-mode-20041004/schema/
- Edit mjt.rnc and change the first line from
include "emacs/lisp/nxml-mode/schema/xhtml.rnc"to this:
- Load a MJT html file and type
M-x nxhtml-mode. Check the mjt.task attributes are now accepted
Make nxhtml-mode load automatically on opening .html files
Add the following to your .emacs
;;WILL: there should be a cleaner way to do this
(fset 'html-helper-mode 'nxhtml-mode)
(fset 'html-mode 'nxhtml-mode)
Now whenever you open an HTML file with Emacs you will automatically see any markup errors. This can save a lot of debug time!
Thanks to Nick for the pointer to nxml-mode and to Jessica for prompting me to write this doc.
Please leave a comment if you try these steps. I’d like to know if it works for other people (or if you know a better way)