Friday 26 February 2016

What Is Markdown, And Should You Use It?

What Is Markdown, And Should You Use It

This markup language is slowly and steadily gaining acceptance. Roland Waddilove shows how to use it to write and format text for a variety of uses

Have you heard of Markdown? It’s becoming a popular way to format text, especially for use on the web, and it’s supported by an increasing number of Windows applications, websites and mobile apps. Markdown is a markup language, which sounds confusing, but it’s basically a way to specify the formatting of text using various symbols and conventions. It enables you to mark text so it’s displayed as a headline, in bold, as a numbered list, in italic, as a link to a website and so on.


There are other markup languages, with HTML being the most common one. You might be familiar with some of its simpler conventions. It uses tags, such as <h1> to represent a heading, <b> for bold, and <li> for a list item. Tags are used to specify the formatting of text and when interpreted with a suitable program, such as a web browser, the tags are hidden, and just the formatted is displayed.

The aim of Markdown is to provide similar facilities to HTML and to specify formatting, but in a simpler way. It aims to make it easier for the writer to mark text without having to learn the syntax and tags of HTML. However, Markdown is related to HTML and is designed to be converted into it. Text marked up with Markdown is often used to output HTML, which can then be used in web pages. It enables a non-technical writer to generate web pages using nothing more than a text editor and with no special knowledge of tags and syntax.

The History Of Markdown


Markdown was created by John Gruber in 2004, and the original blog post on the Daring Fireball website is still available (daringfireball.net/projects/markdown). This page is the main place to go when looking for information about the language. Here, you’ll find three tabs: the introductory Main tab, a Basics tab and Syntax.

Like a lot of ideas, it was built on the work of others. It was not completely original, but was a development of Setext (Structured Enhanced Text), which is a lightweight markup language that was created by Ian Feldman in 1991, 13 years before Markdown. Other people have created similar markup languages, such as reStructuredText by David Goodger, which predates Markdown by a couple of years. Markdown is simply the most popular version of a markup language that has been in development for around 25 years by several different people.

Given how old Markdown and Setext are, it’s taken a long time to catch on. It’s slowly increasing in popularity and has risen from obscurity to become… well, perhaps popular isn’t quite the right word, but it is bordering on it in some areas. For example, if you have a blog and use WordPress, you can write blog posts using Markdown to format the text. There’s a word processor, Writemonkey, that supports Markdown, and some note-taking apps on Android and iOS phones support it, as well as other applications.

What Is Markdown?


Let’s take a look at some examples of Markdown and how it’s used to specify the formatting of text. To write a heading for an article or web page, you double underline it by typing a row of equals symbols like this:

The headline
=========

Text that is written using Markdown is intended to be converted to HTML, so this would end up as <h1>The headline</h1>. The output is not necessarily HTML though and a text editor, word processor, or other utility would simply display a headline on the screen or print it on paper.

A document or web page might have subheadings, which would be indicated using a single underline using minus signs:

A subheading
------------------

The HTML equivalent would be an <h2> tag. You can also use hash symbols, which is even easier than underlines. A single hash is the largest heading, two hashes is a smaller heading, three is even smaller, and so on. They correspond to the <h1>, <h2>, <h3>... and other HTML heading tags:

### A third level heading

To mark some text so it would be displayed in italics, you would start and end with a single asterisk. To specify that text should be displayed in bold font, you would use two asterisks:

Ordinary text, *italic text*, back to normal
Plain text, **bold text** and normal text

One of the advantages of Markdown is its simplicity and compactness. It’s very easy to type two asterisks, and it requires more effort to select and format the text using an application’s menus. It’s also easier when the output is HTML and ** is better than having to enter <strong>.

Bulleted lists of items are also simplified, straightforward and quick to enter. Three characters can be used to specify bullets: *, - and +. Here is a list of items that would produce a list of bullet points:

* dog
* cat
* hamster
* parrot

This is what is called an unordered list in HTML. In the short example above, the HTML tags would account for more characters than the list itself. Using an asterisk is much easier. An ordered list is one that is numbered 1, 2, 3 and so on. Using Markdown, you just write it as you want it displayed, which is far simpler than the equivalent HTML code:

1. Potatoes
2. Carrots
3. Peas
4. Beans

Learning the basics of Markdown is so easy, you could do it in a few minutes. If you’re writing a blog post or article that has links to websites, you can specify the text and the links in a very simple way using square and round parentheses:

Go to the [Gadgets, games, hard'n'soft](www.geekfolk.blogspot.com) website.

The square brackets are used to specify the text used for the link and the round brackets are used to specify the link. When this is converted to HTML it would look like this:

Go to the <a href=”http://geekfolk.blogspot.com”>Gadgets, games, hard'n'soft</a> website.

There are more advanced ways to specify links, though. It’s possible to create a numbered list of links and then to refer to them in the text. However, it adds a complication that is best avoided, and the simplest form is the best one to use. An image can be inserted into the text in a similar way to a hyperlink. You provide some text, which describes the image, and a link to the image’s location on the web. For example:

![A ferrari](/img/ferrari.jpg “Nice car”)

It starts with an exclamation symbol, the square brackets contain the description (the alt tag in HTML), the round brackets contain the URL to display the image, and the quotes at the end contain the image title. It all gets converted into the correct HTML code.

Writemonkey


Writemonkey (writemonkey.com) is a word processor for people who like to focus on the words without the distractions that you normally have when working on your computer. Although it can run in a window, it works best when it’s full screen, because it blocks everything else out. There’s no desktop, no browser window urging you to post on social networks, no taskbar with icons begging to be clicked – just plain text.

It supports Markdown, and you can style the text using the standard methods, such as underlining headings, creating numbered lists, adding links and so on. Files are saved as plain text with no other formatting.

The lack of menus and toolbars is a bit disorienting at first, but everything you need is available on the right-click menu, including Markup Export. You don’t see the results of the Markdown formatting until the file is exported, which is perfectly normal. Select Markup Export on the right-click menu and use the options to either save the file, export the document to a web browser or an editor, or print it. Saving to a browser or editor results in an HTML file.

Writemonkey isn’t an alternative to Word, but it is useful for distraction-free writing and for creating HTML for pasting into web pages.

StackEdit


StackEdit (stackedit.io) is a browser-based editor that enables you to create and publish web pages using Markdown. It’s probably unlike anything else you’ve used, but it doesn’t take long to get to grips with its features. You can simply go to the website using Chrome to start the editor, but there’s also an app in the Chrome Web Store that makes it even easier to start. The first time your visit, a welcome document greets you, which contains help and instructions on how to use StackEdit. If you know Markdown, though, there isn’t a lot to learn and you can just start typing.

You don’t even need to be a Markdown expert to use it. A toolbar at the top of the window provides mouse access to the formatting functions like a regular word processor. Click the B button for **bold** text, I for *italic*, [web links](stackedit.io) and so on. One of the best features of StackEdit is the split screen view. On the left is the source text and on the right is a live preview. You can instantly see the effect of formatting and see how the document looks.

Documents are stored locally on your computer in the browser. StackEdit creates a sort of filing system that enables you to create documents, save them, browse the storage and so on. The way that it does this is quite clever. However, documents are not synced between computers, so if you use Chrome on different computers you will not have access to the same documents.

The solution to this is to use Google Drive or Dropbox. StackEdit can load and save to your online storage, which enables you to access files from any computer.  Documents can be published to Blogger, WordPress, Tumblr, Google Drive and Dropbox. Select the StackEdit Viewer, and the document is displayed in the browser window. This provides access to the browser’s print facility so documents can be printed. Documents can be saved to disk as Markdown text, HTML or, if you sponsor StackEdit for $5 a year, as a PDF file.

StackEdit is a brilliant web-based utility and is very useful when you want to quickly type out a document without the usual clutter of a word processor.

MarkdownPad


If you prefer to use a standard Windows application on your PC instead of a browser, MarkdownPad (markdownpad.com) is basically StackEdit running as a program. The list of features is almost identical to StackEdit, with a split-screen display that has a text editor on the left and a live preview on the right.

Markdown can be typed in directly to format the text, but there’s a toolbar and a menu that enables you to use the mouse instead. Better still are the keyboard shortcuts that insert formatting, such as Ctrl+B for bold, Ctrl+I for italic, Ctrl+U for a bullet list and so on. You can highlight some text, click the link button in the toolbar and enter a URL. The correct markdown is applied for you.

Files can be loaded and saved to the disk drive, printed as HTML or Markdown, exported to HTML and PDF. Nearly all features are available for free, with a small number that can be unlocked by upgrading to the Pro version for around £10.

There’s a version of Markdown that can be installed and a portable version that you just unzip and run from anywhere, even a USB memory stick. The portable version is preferred, because it’s always best to avoid installing software if you can. It runs fine on Windows 7, but the live preview facility doesn’t work on Windows 8 and 10. However, there is a plug-in that can be downloaded and installed to provide this facility.

WordPress


The most popular content management system for building websites is WordPress, which you can either install on your own server (your web host will do it for you) or get for free at wordpress.com. Both support Markdown when writing blog posts and pages for your website.

Wordpress.com has patchy support that accepts some Markdown, but not everything. For example, you can use one to six hashes to mark headings and subheadings, numbered lists are correctly formatted, unordered lists can be created using an asterisk, and blockquotes can be inserted by typing > at the start of the line. It doesn’t support links, but there is a menu option to insert links anyway.

If you run your own WordPress installation and have the popular Jetpack plug-in, there is an option in Jetpack settings to turn on support for Markdown. Like wordpress.com, it supports some Markdown without the Jetpack plug-in, and you can create subheadings, bullet and numbered lists, and add blockquotes.

When Markdown is enabled in the Jetpack plug-in, all the formatting commands are supported. You can copy and paste a Markdown document from MarkdownPad, for example, and paste it into the WordPress editor. When the post is published, all the formatting is correctly applied. WordPress has a post-by-email feature, whereby you can send an email to your website that is then turned into a blog post. With Markdown support, you can produce perfectly formatted blog posts simply by sending an email. You could even blog from your mobile phone, because it’s such a simple text markup language.

More Ways To Use Markdown


Once you start looking for Markdown support, you will discover lots of web applications, Windows programs and mobile apps for your phone and tablet. Markable.in (markable.in) is an online browser-based editor that is similar in function to StackEdit. It supports Tumblr, Dropbox and Evernote, which is interesting, and it could be useful if you use those services. Registration is required, but it’s free.

Dillinger (dillinger.io), InstantMark (jrham.es/instantmark) and Backpager (backpager.amasan.co.uk) are also web-based edtors with similar feature sets that let you create Markdown documents online. Scrivener (literatureandlatte.com) is a popular application for writers creating ebooks, and it supports Markdown.

Markdown Here (markdown-here.com) is a fascinating application of the language, which can be added as an extension to Chrome, Firefox, Safari, Thunderbird and Opera. It is designed to enable you to write emails using Markdown. The email is written in the standard new mail edit window as usual, and when it’s finished, you right-click in the email and select Markdown Toggle. This converts the text with Markdown into the formatted output text. It can be used within Gmail, for example, and you might find it easier than the usual formatting commands. It also works in other places where you enter text in a browser window.

There are many Android apps in Google Play that support Markdown. Just search for ‘markdown’ and take a look at Writeily, Easy Writer, JotterPad, Write and dozens more. Markdown is perfect for mobile, because it is so simple and works with plain text files.