When I was first investigating John Gruber‘s excellent text-formatting system Markdown, one of the things that caught my eye on his demonstration pages was the ability to see the ‘source’ for any of the pages by simply replacing the .html extension with .text. I’d been wondering if it would be possible to pull such a trick for my site for a while, and got it figured out tonight.
You’ll now notice that just after the post date for each entry, there’s the option to go to a ‘text’ version of the entry. The URL is the same as the normal archive, except that it ends with .txt rather than .html. Clicking on the link will send you to the text-only version of the entry, which is simply the entry without any formatting applied to it whatsoever — just what I’ve typed, nothing more, nothing less.
For instance, here’s the text version of this entry.
I’m honestly not sure if there’s a huge use for this, actually, but that’s never stopped me from trying something before. ;) The biggest benefit I can see is that it allows for very easy copy-and-paste operations without having to worry about “smart quotes” fouling things up along the line. It also allows visitors to see the posts as they were written, of course — and thanks to Markdown, the text-only versions are generally just as readable as the formatted HTML versions, without lots of HTML code cluttering things up. Essentially, they look very similar to what a text e-mail might look like, with URLs placed after each paragraph, and references to each link at the appropriate point in the text.
I have noticed some caveats to this technique, however, which may put the usefulness of this entire technique into question.
- Safari doesn’t seem to display text files as pure text — rather, it treats them as HTML. This has the effect of running all paragraphs together as a single line, and rendering any HTML it might find. This has the rather unfortunate effect of defeating the purpose. If anyone has any suggestions as how to force Safari to actually display the text as text rather than rendering the HTML, I’d love to hear them.
Update: Well, now Safari’s behaving and displaying the text versions as I’d expect them to display — as pure text, with un-rendered HTML. I have no idea why it didn’t do so the first time. This first caveat may be moot, then (which is a good thing).
Update: John Gruber was kind enough to fill me in on why Safari will sometimes display the text as text, and other times will render it as HTML:
Oh, and the reason that Safari sometimes refuses to show your text
pages as plain text is because it tries to be clever. If anything
that resembles an HTML tag appears in the first 100 KB or so of your
document, Safari treats it as HTML, even if the HTTP headers state
that it should be “text/plain”.Very frustrating, IMO. Apparently it’s a workaround for
misconfigured servers that send HTML as “text/plain”, and it matches
a similar workaround in IE/Win. - Firefox will not wrap text files at the end of the screen, so each paragraph ends up as a single long line. Admittedly, this is technically correct, but without the word wrap, it’s a bit difficult to find something in the midst of a long paragraph. You could, of course, copy-and-paste the entire thing into a text editor before doing anything else, but that adds another step when working with anything.
-
I have no idea what Internet Explorer will do with this, as I don’t have any version of IE on my computer.
If you’re still interested in implementing this yourself — or just curious — read on for the gory details. This is written for Movable Type users, of course, other systems will have to find their own techniques.

