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
Install nXhtml:
- Download the latest version of nXhtml.zip
- Unzip into a directory, for example: ~/.emacs.d
- Edit your .emacs and add
(load "~/.emacs.d/nxml/autostart.el") - Run emacs, open an HTML file and type
M-x nxhtml-mode
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:
include "xhtml.rnc" - 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
;; nXhtml-mode
(load "~/.emacs.d/nxml/autostart.el")
;;WILL: there should be a cleaner way to do this
(fset 'html-helper-mode 'nxhtml-mode)
(fset 'html-mode 'nxhtml-mode)
Conclusion
Now whenever you open an HTML file with Emacs you will automatically see any markup errors. This can save a lot of debug time!
TODO: make multiple modes work so that mjt.script appears as formatted javascript inside an HTML file.
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)
July 11, 2007 at 8:27 pm |
Please notice that the download link for nXhtml should be
http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl
The latest released version can be found there (at the bottom of the page).
July 11, 2007 at 8:41 pm |
Will, can you please contact me about the problems with MJT and syntax problems in nXhtml?
July 11, 2007 at 11:18 pm |
Hi LeoB, thanks for pointing out the broken link. I’ve fixed the post.