There are many tools available on Linux to create text-based content: text editors, word processors, content management systems, and desktop publishing applications. The most appropriate one will depend on how your content will be distributed, whether on paper, electronically in a format such as PDF, or online.
But traditionally, the process of drafting this content is often different from the final layout, as evidenced by the recent popularity of “distraction-free” editors (such as WriteRoom for Mac OS X and iOS or the cross-platform FocusWriter). One advantage of these is that you can draft your work in plain text, which is a great format for a number of reasons:
- Using plain text lets you concentrate on the words, rather than their formatting
- It’s one of the most portable formats out there
- You can use lots of tools to help you manage it, such as DropBox, which comes with its own built-in text editor, or concurrent versioning systems (such as Subversion, as described here) as you make changes
The problem lies when you need to transform those plain-text words into something nicely-formatted and readable. Fortunately, Linux provides two programs that allow you to draft in plain text, then convert to other, more graphical formats.
Markdown is what is called a “lightweight mark-up language.” It’s similar to HTML (and, in fact, allows you to insert HTML directly in your Markdown documents), and if you install the companion program, you can convert what you create into clean HTML. But you just need to know a little bit of the syntax in order to start writing in Markdown with any text editor:
- Heading (e.g. Level 1, Level 2, etc…) lines begin with a hash tag (#), one for each level of the heading (i.e. a Level 3 heading needs three hash tags)
- Text in bold should be enclosed with two underscores or asterisks, **like this**
- Text in italics should be enclosed in one underscore or asterisk, *like this*
- Bulleted items begin the line with a dash (-), a plus (+), or a single asterisk (*), followed by a single space.
- Numbered items begin the line with a number, followed by a period and a single space (e.g. “1. “). Note that the actual numbers you use don’t matter, so don’t worry about making sure they’re in order – I use all 1’s when doing these lists.
- When inserting a hyperlink, put the text to be linked in [square brackets], followed immediately by the URL to link to (in parentheses).
With these few items, it’s entirely possible to draft up blog posts without having to worry about HTML tags (more information on formatting, such as inserting images, tables, and references throughout the Markdown content, can be found on the project’s home page).
Markdown Conversion Tool
To convert this to HTML (to be pasted into a CMS, for example, the command to install this in Linux is as follows:
Once installed, converting content in Markdown to HTML is as simple as the following command:
The HTML you get from this command can be easily pasted into blogging and content management systems – some of them (like WordPress and Movable Type) even have plugins that will handle the formatting when you place Markdown directly into the editor. On its own, Markdown is an excellent way to quickly draft web-based content. In my next article, I will discuss how to pair Markdown with the tool Pandoc to convert your Markdown content to other formats including OpenDocument Text format (.odt), Microsoft Word (.docx), ePub, PDF, and typesetting formats such as LaTeX. By the way, this post was drafted in, and converted by, Markdown.