Chapter 8. Markup Language Support
It's true that many of the people who use Emacs are
developers, writing code, tweaking it, recompiling it, and just
generally enjoying the services of an amazingly extensible work
environment. A variety of people, including developers, need to
produce text for publication, whether internally, online, or in book
format. This chapter describes the markup language support that Emacs
offers, a topic relevant to both information publishers and
developers, as more and more development work uses variants of the
Extensible Markup
Language, XML.
Choosing a format for producing documents isn't all
that straightforward these days, especially if you eschew Microsoft
Word. Some people write HTML, and Emacs offers a few options for
this. HTML gives you some control over formatting but displays
differently on various browsers. Of course,
it is important as the lingua franca of the
Web.
Other text publishing options
include
the TEX family. TEX (pronounced
"tek") is a formatter that was
developed by Donald Knuth for generating books. LATEX (pronounced
"lay-tek") is a set of TEX commands
created by Leslie Lamport. With TEX and LATEX , you can produce very
precisely formatted text with equations, interesting fonts, graphics,
headers and footers, and the like. Whether using filters or features
of the program itself, you can publish TEX documents in a variety of
formats.
Another option for publishing text—as well as
programming—is XML. XML, when combined with a
Document
Type Definition (DTD) or schema, enables you to write text once and
publish it in a variety of formats. Extensible Style Language (XSL)
is also important in this regard. Because the standards are still
being defined, organizations involved in document production may
choose an established XML dialect, such as DocBook, as their
publication format. XML at this point provides less precise control
over format, but maximizes flexibility.
XML bridges the programming and publishing worlds, and what you do
with XML will in part determine what tools you use and what support
you need. We discuss a few options for writing XML in Emacs,
including psgml mode and Jim Clark's nxml mode,
which uses Relax NG schemas rather than DTDs for validation.
Some word processors and other tools integrate formatting and
editing. These tools are often called WYSIWYG (what you see is what
you get) tools. What's the
advantage of using Emacs versus a WYSIWYG tool? Well, whether
you're writing LATEX, XML, or HTML, you can be
crystal clear about what's in the file and how
it's structured if you use Emacs. Save a Microsoft
Word file as HTML and then open the resulting file in Emacs. Word
bloats the file with additional tags and formatting that is not
strictly required. In terms of output, the streamlined and
straightforward code you picture in your mind's eye
when viewing a page is definitely not what you get, an ironic
consequence of using a WYSIWYG tool like Word to create markup files.
Chances are, if you've read this far,
you're planning to use Emacs anyway, so we
won't belabor the point.
In this chapter, we talk about these markup modes:
For writing HTML, Emacs HTML mode (a subset of SGML mode) and the
add-on HTML helper mode are discussed. For writing XML, Emacs SGML mode and the add-on modes psgml mode and
nxml mode are described in brief. For writing LATEX documents, Emacs LaTeX mode is discussed.
These major modes help you insert formatting commands, or markup,
into your text. While the amount of help that Emacs offers varies,
using the mode designed for your text formatter will streamline your
work.
At this point we must insert a caveat. We provide a barebones
introduction to the markup modes described in this chapter. What we
say here will get you started, but not much more than that. Entire
books could be and have been written about using each of the markup
tools described here. Now that that's out of the
way, let's talk about a few features that are
important in all the modes: comment handling and font-lock mode.
|