I hand-code constantly, from php to html, but I find formatting simple text documents – such as a blog post – a real pain.
WYSIWYG editors often create clumsy, untidy code that might prove unpredictable when viewed with a finicky web browser. Writing clean html is not hard, but all the extra formatting tags make the text much less readable when re-reading and editing.
Markdown – a simple, direct means of adding formatting to a piece of text – has been around for some time. Now that I have got around to using the system, I find myself wishing I had embraced it years ago.
Markdown has been around for a while now: a simple, text-only markup syntax, allowing you to type in whichever text editor you prefer, but retain formatting options that will later be translated into html.
For example, if I want a h2 header, I type
## This is the header ##
The final translated html document will be
<h2>This is the header</h2>
HTML tables are annoying to say the least – moreso with a wysiwyg editor, I find. Markdown (remember how it is simple and minimalist?) provides no relief, requiring direct input of standard html table syntax (normal HTML code can be directly entered into a markdown document). Multimarkdown (see below) does have table support, like this:
| TableHeader | Header2 | |:------------|--------:| |item 1 |item2 | |item 3 spans columns ||
which would create (depending on the processor you use to make the conversion):
<table> <thead> <tr><th align="left">TableHeader</th><th align="right">Header2</th></tr> </thead> <tbody> <tr> <td align="left">item 1</td><td align="right">item2</td></tr> <tr><td align="left" colspan="2">item 3 spans columns</td></tr> </tbody> </table>
For a chaotic, cluttered brain like mine, markdown offers a much clean – yet formatted – text to work with. My mind no longer must filter-out all those html tags which add to the visual noise of the content I am editing. I find I am writing and editing much more since adopting markdown.
Consider also online writing tools such as Autocrit.com. These text analysis and editing tools can only accept raw text – they do not cope well with html tags. Markdown, on the either hand, because of its minimalism, works beautifully when copied and pasted into an online form field.
Tools make life easier
Any text editor
I use everything from BBedit, through Writeroom, Devonthink, and sometimes others. Any text editor that can write in plain text will do, whatever you prefer – the whole point of markdown is the styling information is independent of where and how you compose your text.
This is all you need to compose a document in markdown – with perhaps with a cheat-sheet handy while you learn the dead-simple syntax.
This little app acts as a slick preview of your markdown document. Each time you save your changes to your text file, Marked updates the HTML version of your markdown so you can see exactly how it will look. All you need to do is to save your document, drop into Marked, continue writing and editing.
It also has the added bonus of processing the conversion to html for you. Unlike many other markdown compatible apps, it will also convert to RTF, and even let you save a PDF of your formatted text.
Devonthink is not natively compatible with markdown, but it does handle plain text documents (in addition to RTF) very well. Use a “Show in Finder” menu item to reveal your markdown file’s location, then open that in Marked. If you’re up to the task, a small Applescript could easily do the job of finding the file and dropping into Marked.
WordPress markdown plugin
Here’s where markdown gets particularly useful. With a simple wordpress plugin, you can compose and save your posts in markdown syntax, but have them appear on your blog as fully-formed HTML. Need to edit? If you have selected the correct plugin, the markdown version is saved alongside the html version, so edits are also done in markup!
Multimarkdown might be described as “markdown on steroids”. Markdown’s minimalist simplicity is a little too simplistic for some, so multimarkdown was developed to add an extended set of more complex markups to help you format your text.
Table handling, image attribute handling (i.e. width, height, etc), are all available with multimarkdown if you need them. The majority of processors now handle both markdown and multimarkdown – but do check first, otherwise your tables might not show up as you expect.