January 22, 2013

Tech Pubs Tuesday: Don't Write Directly in HTML

Since most of the documentation you produce is going to be hosted as HTML anyway, you might be wondering: why not just cut out the middleman and write all your documentation in plain HTML? Instead of learning some weird intermediate format that transforms to HTML, wouldn’t it make sense to handcraft whatever markup, CSS, and JS that you need directly?

Actually, since most documentation tools and formats range from mediocre to awful, plain HTML isn’t necessarily a bad choice. I’ve seen some beautiful documentation authored in handcrafted HTML. That said, using a more specialized format will make things easier on you. Here’s why.

First, typing out HTML open and close tags is annoying and breaks your writing flow, even if you have a good text editor or IDE. If you’ve used a lightweight markup language like Markdown or reStructuredText, you know the difference. Creating a new paragraph with newline, newline is more natural than angle-bracket, p, angle-bracket. Creating a bullet list with leading *s is much more natural than typing <ul>s and <li>s.

Second, maybe you do want multiple output formats! Are you sure you don’t want PDF? What about man pages? If you want man pages, you’re going to have to invent some mechanism for transforming your HTML into TROFF (a venal sin), or you’re going to have to write the same material twice (a mortal sin).

Third, and perhaps most important, HTML is deliberately primitive and general-purpose. It lacks the semantics that you want for describing technical documentation. For example, when writing a sophisticated book, you might want things like:

… and so on.

I think my bottom line is, you can get away with writing a small amount of documentation in plain HTML, such as a README or a short install guide. But the larger your book, the harder this gets. The pattern you really want to avoid is:

  1. Start authoring a substantial book in HTML.
  2. Part way through, discover that you need some of the features on the list above.
  3. Start hacking those features in with some kind of special ad-hoc syntax. No worries — it’s not too hard, it’s just one or two “special tags” or “macros”…
  4. Eventually end up re-inventing a bad version of reStructuredText or Pandoc-flavored Markdown. Except with way more angle brackets.

Don’t be that guy.

Comments

  1. So what specialized format do you recommend to make things easier? This post was spell checked per your advice in last week’s tech pub :)

    Posted by Patrick Becker on Jan. 23, 2013 at 7:51 AM [#]

  2. I’m sure Evan would recommend writing DocBook XML by hand. Right, Evan?

    Posted by Dave Ranney on Jan. 23, 2013 at 10:57 AM [#]

  3. Do you recommend Markdown, reStructuredText, or something else?

    Posted by Ryan Hamilton on Jan. 23, 2013 at 2:20 PM [#]

  4. Oh thank G0d, someone else remembers TROFF.

    Given that it’s unlikely I’ll ever write a book in html, how do you feel about writing blogs directly in, say, WordPress? Does it even matter?

    Posted by Robin Rosenberg on Jan. 23, 2013 at 6:35 PM [#]

  5. Dave — ha!

    Patrick, Ryan — I recommend reStructuredText, specifically Sphinx. Markdown is decent too, though not my favorite. For a book-length technical work, you really want a superset of Markdown, something like MultiMarkdown or Pandoc Markdown.

    Robin — I think writing blogs in WordPress is a great idea. If you ever want to collect your blog posts and turn them into a book, you’ll figure it out without too much trouble. :) I’m sure there are some nice WordPress plugins that can automate this for you.

    Posted by Evan on Jan. 23, 2013 at 9:38 PM [#]

Post a Comment

(Optional, will not be shown)

(Optional)

Are you sentient?

Comments use Markdown syntax. HTML will be stripped out.

  • New para: two carriage returns
  • Emphasis: *emphasis*
  • Bulleted list: - bullet item
  • Ordered list: 1. numbered item
  • Blockquote: > "To the Batcave!"
  • URLs get automatically linked: http://yahoo.com
  • To create an inline link like Yahoo!: [Yahoo!](http://yahoo.com/)