seek and thou shalt find

see the archives for a complete list
of past blog entries

Markdown - the Renaissance of plain text

posted on
Feb 17, 2012 @ 20:45
filed under
,

Plain text is readable and can be edited by most applications. It’s light, virtually indestructable, and great for jotting down quick notes. However, getting from text to a visually appealing format usually means giving up all these virtues.

This is where Markdown shines. Markdown is a way of formatting plain text so it can be rendered as formatted HTML, PDF and many other formats. Markdown usage and support in OS X writing applications is soaring these days, so I thought I’d show you how I’m using Markdown every day.

If you just take a few notes in a text only app you might have intuitively tried to format that text. Or even in Mail, if you are like me and prefer to use plain text, you might have tried formatting your mails with the visual tools at hand. You might have ended up writing something like this.

My list for the weekend
=======================
Stuff to buy:
* Butter
* Milk
   * 1l low fat
   * 500 ml soy milk
* Jam (any)

If you have ever created something similar, you already know how to write some Markdown1 formatting. This can then be converted by a Markdown-capable editor into nicely styled HTML, PDF, RTF and maybe even LaTeX.

In Markdown most formatting rules are equal or very close to how most people would try to structure or format plain text anyway. Here’s an example of some ways to format text using Markdown:

This is a title  
===============

Which will be interpreted as a title and displayed as a header in a large font (or with similar emphasis), like this:

This is a title

From this text you could create the following HTML:

<h1>This is a title</h1>

Creating unordered lists is just as easy, simply type this:

- List item 1
   - list subitem
   - and another one

You can also use asterisks * instead of the hyphens. The above Markdown formatting could be displayed like this:

  • List item
    • list subitem
    • and another one

You can also produce HTML code as below:

<ul>
<li>List item 1</li>
<ul>
<li>list subitem</li>
<li>and another one</li>
</ul>
</ul>

But wait, there’s more

Formatting quotes is a simple as doing it in your mail app. Just start (the first or) every line of the quote with a greater than “>” sign.

> Since typography appertains to each and all, 
> it leaves no room for revolutionary changes. 
> We cannot alter the essential shape of a single letter 
> without at the same time destroying the familiar printed 
> face of our language, and thereby rendering it useless.
> — Jan Tschichold

Since typography appertains to each and all, it leaves no room for revolutionary changes. We cannot alter the essential shape of a single letter without at the same time destroying the familiar printed face of our language, and thereby rendering it useless.
— Jan Tschichold

Even complex layouts like tables are a piece of cake, when done in Markdown. Here’s an example, how to create one:

| Apples | Oranges |  Lemons |
------------------------------
|  lots  |   of    |  fruit  |
|  with  |   no    | meaning |
Apple Oranges Lemons
lots of fruit
with no meaning

Looking at these few basic examples it should be pretty clear that Markdown is highly readable – much more than raw HTML – and you don’t really have to learn much. It’s very close to what anyone would probably intuitively type anyway, trying to format plain text. Plus it has all the advantages of plain text, which are being a cross-platform, extremely robust format that is very light and can be handled by most applications.

If you’d like to know more about Markdown formatting and its Syntax hop over to John Gruber’s site and have a read

How I’m using Markdown

I have been using Evernote for a long time. It’s a fantastic tool, but the biggest gripe I have with it is that exporting your notes in any usable format is virtually impossible. Yes, it does allow export as HTML, and an Evernote-only XML format, but how useful and how editable is that? So looking for alternatives, I stumbled upon nvALT.

nvALT is a modified version of a note-taking and organising application called Notational Velocity. nvALT adds support for Markdown and Textile2 formatting. Furthermore it has built-in preview functionality to show you a rendered nice-looking version of your Markdown plain text notes (including several different pre-made design styles).

It also lets you convert the text into RTF, HTML, PDF or as a Word document (.doc and docx). Quite something for a free application. And it supports using file extensions like .md, .markdown etc. instead of .txt. So you can keep your “plain” plain text documents separated from Markdown ones.

There are also Browser extensions for Chrome and Safari and a Bookmarklet to quickly add the page you’re looking at as a Markdown formatted note to nvALT (there’s even an option to process URLs dropped on nvALT with Readability to strip unnecessary code from the page).

A screenshot of nvALT
On the left you have the notes list, then the editing area and a preview window to the right.

Any thinkable note I write I put into nvALT. I usually also tag the entries on-the-fly, so I can find the entries easier later (yes nvALT also supports tagging). I can search for entries either via the built-in search or Spotlight (remember it’s just a text file so spotlight can index the file without problems) and in Spotlight on Lion I can even preview the file via QuickLook as rendered HTML (with a free plugin).

QuickLook Markdown from Spotlight
For a quick preview of Markdown documents you can either grab a copy of Marked or you can get a QuickLook plugin to preview Markdown files via QuickLook in the Finder and Spotlight. It doesn’t get any cooler than this.

On the go

Now the trick is to have nvALT save all its notes in Dropbox this way you can not only sync them between Macs, but you can also access them on your iPhone with Markdown capable editors, that also support Dropbox such as: Elements, Nocs, WriteUp

Even a free Dropbox account will give you 2GB of space, so you won’t ever fill this up with plain text.

Alternatives

When I write a lengthy blog entry or article I tend to prefer ByWord iA Writer it’s visually more pleasing and gives a few more visual hints to the formatting even when in editing mode.

Markdown supporting utilities

And if you don’t like the editors I just introduced, get some others! Just take a look at some of the incredibly useful software available that can handle Markdown.

Other Markdown Editors, tools

  • Nocs For me the perfect companion to nvALT. This is an iPhone (iPad) text editor supporting Markdown and even better it can access all the notes you’re synching via Dropbox from nvALT. And it’s free, too.
  • Byword has a few interesting features (available for Mac OS X and iOS), when in editing mode you get what I’d call partial WYSIWYG, because it will bold headers and strong emphasis (while displaying the markup). You can switch to a pure render view and export to not only HTML, PDF, RTF and Word format but also LaTeX!
  • iA writer The be-all and end-all of text only writing. Quintessential writing focus. Available for Mac and iPad. iA writer fully supports iCloud for document synching.
  • Marked From Brett Terpstra, who brought us nvALT comes another ingenious tool. This little gem will give any text editor Markdown preview and export capabilities. Just keep on using your text editor of choice, Marked.app will do the rest.
  • MarkdownNote Another tool available for Mac OS X and iOS. Supports Markdown and comes with a real-time preview.
  • Markdown Pro This editor also comes with a real-time preview and supports many other Lion only features. It also comes with some quite nicely designed preview rendering themes.
  • Markdown Service Tools Brett Terpstra seems to be unstoppable when it comes to providing us with countless Markdown tools. This one will give you formatting tools for Markdown in the context menu of OS X via OS X Services

Another goodie at the end

Quite a lot of cloud based apps do support Markdown for entering and displaying text. In cloud based apps like Lighthouse, Basecamp you can format most of the text you’d input into a text field for messages with Markdown.


1 Markdown: A lightweight markup language, originally created by John Gruber and Aaron Swartz allowing people “to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML)”. The language takes many cues from existing conventions for marking up plain text in email.

2 Textile: Textile is a lightweight markup language, originally developed by Dean Allen and billed as a “human Web text generator”. Textile converts its marked-up text input to valid, well-formed XHTML and also inserts character entity references for apostrophes, opening and closing single and double quotation marks, ellipses and em dashes.

comments

from monologue to dialogue

  • July 28, 2012 @ 22:43

    > “And it supports using file extensions like .md, .markdown etc. instead of .txt. So you can keep your “plain” plain text documents separated from Markdown ones.”

    I had to go dig into Prefs on nvALT for this, but now I’ve changed Prefs (notes > recognize… > plus sign) so that nvALT recognizes *.md files, and saves plain text files as *.md by default.

    Since I write in Markdown by habit, and I often want apps outside of nvALT to recognize its plain text files as Markdown, this is huge.

    Thanks for the heads up on that!