Hi and welcome to Ode (pronounced oh-dee). Glad you stopped by.
Important: Ode is very new.
In the coming weeks I intend to post a lot of information to this site, and of course the complete project (including a set of sample themes and documentation) will be available for you to download.
Please do check back or subscribe to this site's feed if you're interested.
-Rob
If you're unfamiliar with Ode, you may want to take a look at the Intro to Ode presentation.
The presentation includes 29 slides that attempt to address the first questions you might have, i.e. the what and why of Ode (from basics to design goals).
Do we need another publishing platform? You might guess that my answer to that question is, "Yes! At least I think we need this one."
Let's start by talking about what Ode isn't. It's not antoher WordPress. I think the people responsible for that platform are doing just about as good a job with it as is possible.
If you're looking for something with a relational database management system like MySQL at the backend and 4+ MB worth of PHP, Javascript and CSS then you really should check out that project. I'm not being insincere or cynical I really do think WordPress is pretty fantastic, but Ode is something different.
That package (and many others) do more than Ode at the moment but as I've already said, Ode is different.
Different how? Ode is simple.
Is that all there is to it?
Are Legos just interconnectable plastic blocks?
No, that's just the beginning...
Because posts are plain-text files you're free to use any editor you like. That's a big deal. There are many fantastic editors available, many of the best are open source apps and of course there are also some great commercial applications.
These editors are as varied as the people who use them and the jobs they're asked to do. If you were to ask enough people, the answer to the question, "Which is the best editor?" is likely to result in nearly as many answers as the total number of choices. One thing is for sure, editors, as a class, are some of the most mature, subtlety brilliant software applications available. Why then, when it comes to writing online, are we asked to abandon these finely honed tools in favor of the blunt instrument that is the HTML form? Even with all of the new spiffy 'Ajax-ified' features that have come to define the new wave of web apps, the best web-based option is a poor substitute for even a mediocre standalone editor.
Ahh, but being able to write in a browser is so much more convenient. I agree... Ode's simple posts allows us to do both :) (More on web-based posting later.)
The purpose of XHTML and CSS is two-fold.
Firstly, to allow the developer or designer to control the structure and layout of a site, and secondly to style or format content.
The structural bit is the responsibility of XHTML and the job of formatting and style falls to CSS.
The past several years have seen a lot of work in this area. From those efforts we have the emergence of standards based on CSS and the formalization of HTML as an application of XML. Combined, these technologies make a solid architecture for publication, they're terrible authoring or writing tools. They're just not simple enough for the job.
For these reasons various lightweight markup languages have been developed for the purpose of presenting a minimal syntax intended to facilitate a more natural style of writing. These languages are typically implemented as both a syntax and a program capable of translating between its own grammar and XHTML.
These are intended to address many of the problems associated with writing on the web by:
The unofficial but preferred syntax for Ode is Markdown. There are a few alternatives, most prominent among them, Textile, which is another very nice implementation of a lightweight language.
So why Markdown?
Because more than the others, Markdown emphasizes readability of the plain-text document and that seems very much in agreement with Ode.
The other reason to choose Markdown is that it is written first in Perl and Ode is itself a Perl app.
Is this a big deal? Are we limited only to Perl when working with Ode?
No, but keeping as much of what is distributed with Ode in Perl will simplify things for new developers (more on development later).
I'll let the author of Markdown explain its advantages and raison d'être:
Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
Thus, “Markdown” is two things: (1) a plain text formatting syntax; and (2) a software tool, written in Perl, that converts the plain text formatting to HTML. See the Syntax page for details pertaining to Markdown’s formatting syntax. You can try it out, right now, using the online Dingus.
The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email.
Does that mean that you're stuck with Markdown?
No, Markdown is implemented as an addin. You're free to replace it with some other syntax using Ode's addin architecture (more on addins and development later).
It does mean that Markdown will always be distributed with Ode, that you should expect Markdown to work, and discussion of Markdown is considered relevant to this project.
In addition to Markdown, posts support HTML. Just keep in mind that they are contained within a larger page structure. So for example a body tag (
) should never find its way into your posts.We've already hinted that Ode uses the filesystem as a content database, which of course is different than saying that there is no content database. Decades worth of effort speak to the effectiveness of filesystems at storing and organizing files and the data they contain. Modern filesystems are made to handle the rigors and requirements of modern operating systems and include numerous features designed to ensure the scalability, security, integrity, and availability of data. That's good enough for me.
Sure a filesystem is different than a relational database and we need to take advantage of its strengths rather than railing against its limitations. For example, filesystems are strongly hierarchical so we should take advantage of that organization.
Posts are organized hierarchically according to a topic-based categorization scheme. For example, the root of the weblog may contain any number of folders, which are categories, such as 'Technology', 'Politics', 'Music', 'School', etc. Each of these categories may contain any number of posts as well as subcategories (i.e. subdirectories). For example, 'School' may contain subdirectories for each of a number of different courses. Within each of these subcategories there may be more posts and additional categories.
As long as we are willing to organize posts hierarchically the advantages of using the file system as content database are numerous.
If you know how to manage and organize other types of files then you already know how to manage your Ode site (simple, right?). Even if you're new to computing, the skills you develop working with Ode are applicable to just about everything else you'll do with a computer.
That's just one aspect of simple content management. Here are some others:
Adding, editing, and deleting posts - your operating system's file manager and/or your editor are all you need.
Importing and exporting content - because posts are discrete text files, there are no distinct import/export procedures. With plain-text files you are in great shape to migrate your data to any other platform and if you are using something else now, at the very least you should be able to recover your content as text. You do not need to worry about being locked into Ode or losing access to your data.
Backing up and restoring - your posts are dicrete files which, as far as your operating system and backup routines are concerned, are no different than the other files on your computer. In fact the same thing goes for the rest of your Ode installation (not just your content). You can continue to use whatever backup mechanism you're using now. What's more your site can be backed up and restored incrementally at the level of a single post.
If your're not backing up your files currently, you really should start. In this case Ode doesn't complicate the decision about how to manage it or limit your range of options.
Permissions - Permissions for Ode are governed by the file and folder permissions and access controls dictated by your operating system. There's nothing special that you need to be conerned about. Even if you're not comfortable with permissions, for the vast majority of installations a simple permissions 'recipe', i.e. a straightforward set of rules is all you need. (See the documentation for more info.)
Interacting with a remote server - This is no more complicated than file transfer. Use sFTP/SSH/WebDAV/HTTP or any other file sharing protocol that works for you/your hosting provider/your environment.
File synchronization - Let's say that you want to run an instance of Ode locally on a laptop and also run a publically available server with the same content. For those times when you have your laptop but no internet access, you'd like to be able to create and edit posts locally. At other times, you may not have your laptop but you do have access to the internet from some other computer. You'd like to be able to sync the local and public sites.
This is the sort of thing that is very difficult to do with other packages and trivial with Ode. Taking advantage of best in class file synchonization utilities for your platform, you have the ability to mirror changes in either direction.
Well, that's probably enough of the simple content management shtick and there is so much more to discuss. Before moving on I want to point out that simple content management does not mean stupid content management. As simple as it is, we can do some clever things with Ode. Some examples:
In addition to the hierarchical categorization scheme that results naturally from the organization of files and directories, Ode is capable of interpreting date based requests.
For example:
(put in a table) sample.net/weblog/2007/ All posts created in 2007 sample.net/weblog/2007/01/ Posts from January 2007 sample.net/weblog/2007/01/02/ Only those posts dated January 2nd.
What's more we can combine the date and categorization schemes to limit posts in a given category by date, e.g.:
(put in a table) sample.net/weblog/Technology/Apple/MacOSX/2007/01/ Only posts in the MacOSX category created in January of 2007.
This scheme, which is ideal for date-based navigation and browsing, is built into Ode. Other schemes can be implemented using Ode's addin architecture. (More about addins later.)
Furthermore these date-based 'paths' make for perfect permalinks allowing you to reorganize your site at will without breaking links or violating one of the key tenants of the web, namely 'Cool URIs don't change'.
But that's not all. Because Ode sites are organized hierarchically (by date or category) they play nicely with search engines like Google. Just as simple posting means that we can write more efficiently, simple content management means that what we write can be shared and discovered by others more efficiently.
But we still haven't extracted all of the simple goodness.
Simple content management, in combination with Ode's themes, allows us to syndicate the entire site and every category separately. Maybe one of our visitors is interested in everything we write and another only in what we have to say about 'Technology', or just 'Technology/Apple'. Ode has the flexibility to do that, and without requiring that we make any special arrangements.
Themes allow for customization of an Ode site.
The most remarkable thing about Ode's themes is that they're almost completely unremarkable. Themes are pure HTML and CSS. The entire page layout is described by a single file that looks like any other (X)HTML file to your text editor or web design and development app.
There is no need for you to change how you work with HTML/CSS for Ode. Repurposing your existing themes for use with Ode or reworking your Ode themes to work with any other package with a reasonable templating scheme should be relatively straightforward.
Here is the complete structure for the default theme at ode-is-simple.com
theme/ content_type.html date.html page.html logic.css
images/
cod_header.png
ode_tag.png
ode_title.png
xml_badge_bw_sml.png
Of these files, page.html and logic.css are almost entirely responsible for the look and layout of the site.
What's more, page.html starts with a doctype declaration
and ends with the closing html tag
Everything you know about HTML and CSS applies. There is nothing new to learn... no need to hop around among dozens of files inserting bits of HTML here and there being careful not to disturb sections of PHP and Javascript. Not only is this beneficial for users new to HTML and CSS, but experienced designers and developers can quickly implement an Ode theme, work out the kinks and then repurpose it for any other platform without rolling back the Ode specific elements (there aren't any).
Again simple doesn't mean limited. You can have any number of themes with Ode and switch among them at will. For example, you can display any page using any installed theme without changing the configuration of your site. Furthermore, you can apply a different default theme for any category. Themes associated with a category carry through to all subcategories but can be easily overridden.
So for example, you can establish a default theme for the entire site simply by associating one with the root category. If we want a consistent look for the entire site then that's all there is to it. However, if the 'Technology' and 'Music' categories should have different themes we can easily override the default for those two without affecting the rest of the site.
How does this work?
Each category can contain a 'Themes' directory. Each 'Themes' directory can contain any number of individual themes, each of which is contained in its own folder along with all of the associated files.
When a visitor requests an address, that request specifies one of either:
the root of the weblog (ode-is-simple.com/weblog/),
some subcategory (ode-is-simple.com/weblog/meta/),
or an individual post (ode-is-simple.com/weblog/meta/hello_world).
Ode determines which theme to use by starting at the most specific path to the request and working back toward the root. As soon as it finds a theme that matches the request (or a default if no specific theme was specified), it stops looking.
Themes are flexible enough that we can create any look we might want.
Bundled with Ode you will find one, two, and three column themes as well as several specialty themes including:
print theme text page theme (suitable for longer posts) RSS 2.0 theme presentation theme (compliant with the S5 standard)
All of these themes are standards compliant (XHTML 1.0 Strict).
What's more, care has been taken to insure that the themes are logically organized and as simple as possible. Working from these you should be able to create a site of your own design with a minimum amount of fuss.
Ode implements an addin architecture. Addins are modules that extend or redefine how Ode operates. You may be familiar with other projects where this same sort of thing is referred to as an extension, module, addon, plugin, etc.
I chose the term addin because
'add in' describes more accurately than the other terms how modules work with Ode, i.e. simply add them to your installation and you're done. The term 'addon' seems a little disparaging, as if the modules are of lesser importance. Moreover, because it's possible to replace core routines included in the script itself and not just 'add on' new functionality addon seems not entirely accurate.
addin is not as commonly used as some of the other terms. So it is less likely that references to Ode addins in documentation or tutorials will be confused with something else, for example Perl or Apache 'modules'.
Essentially addins allow anyone familiar with Perl and Ode to redefine just about any aspect of the script (by redefining key subroutines) or extend the functionality of Ode in an infinite number of ways by introducing entirely new routines (more on developement later).
To install an addin simply download and copy it to Ode's addins directory. Each addin is completely self-contained. No need to worry about becoming confused over which what goes where.
These individual addin directories are referred to as bundles.
Is there anything that makes Ode's addins simple? I'm glad you asked.
Addins are managed by directly manipulating corresponding files via the filesystem, in much the same way as posts.
Interacting with the addin files directly avoids the problems and confusion that can result from using a web form that deals with the state of addins on your behalf.
For example,
With Ode you will deal with addins in exactly the same way whether everything is running smoothly or you're having trouble.
With many other packages if a module malfunctions you may lose control over it from the administration interface, or what's worse a malfunctioning or misconfigured module may prevent the software from running at all, which means that you cannot access the admin interface, and in turn cannot fix or remove the problem module. Or at least you can't do these things in the way that you would normally manage the software.
With Ode you specify an absolute order in which installed addins are run. This simplifies interaction among addins and puts you in control. After all, no one else has exactly the same installation that you do.
Modules can be disabled without being moved or uninstalled.
Addins are disabled by appending a trailing underscore to the bundle name. The advantage here is that it's possible to see at a glance whether a module is enabled or disabled.
Disabled modules do not affect the behavior of Ode and do not impact performance.
Without talking too much about development here, I do want to make a couple of points about the philosophy of addin development under Ode.
Addins should be self-sufficient with a minimum of dependencies.
External dependencis are problematic because they add to the minimum requirements necessary to use the software, and while adding one or another library may not be a problem for some installations it may be very nearly impossible for others. Furthermore, external dependencies complicate installation, configuration, and documentation.
Internal dependencies among addins should also be avoided. Things get tricky when, as an end-user, I can install the module I want but not some other module it requires because of a conflict.
In the interest of minimizing internal dependencies, addins should be single purpose.
If, as an end user, I'm installing a module to pick up one feature, it can complicate things for me if a bunch of other (unwanted) routines come along for the ride.
Small, single purpose modules should mean faster, more reliable development and finer granularity of control for the end user over what's running on her site.
All addins should be made available here at ode-is-simple.com.
This means that we won't need to worry about hunting for these things all over the internet.
Let me qualify that, of course developers are free to create addins only for themselves or put them up at their own site rather than submitting them to ode-is-simple. But, in order to keep things simple (and safe), addins which are not submitted to and downloaded from ode-is-simple.com are considered outside of the scope of the project.
Obviously, all developers are encouraged to submit their addins.
The following addins are available with Ode immediately:
Indexette - indexes posts so that Ode doesn't need to completely traverse its content directory with every request. Instead, Ode discovers posts by examining the index.
Additionally, Indexette allows new posts to be included without rebuilding the entire index.
Finally, Indexette helps to preserve the creation dates for posts. This is an important aspect of the addin. Without Indexette Ode considers the modification time of the file to be the post date. The trouble with this arrangement is that modification times may be updated when posts are edited and may change as a result of other actions. These 'other actions' are not always predictable or consistent from one installation to another (depending on various factors).
Indexette adds a tag to each post with the original modification time when the post is created. Post dates can be updated by manually changing the date and time recorded in the tag or by deleting the tag altogether (which causes indexette to add a new tag corresponding to the current modification time).
Taking this a step further, Indexette can be made to keep the modification time of the files in sync with the post date as recorded in the tag. This makes it possible to disable the Indexette addin without affecting the post dates or migrate posts to some other platform with the original modification times intact.
Everyone is encouraged to use Indexette.
Editedit - Pronounced 'Edited it', Editedit, in combination with the included edit theme allows posts to be added and updated using only a web browser.
The bundled edit theme includes a live preview of the post that understands Markdown (based on Showdown, a Javascript implementation). In other words, as you edit the text of the post, the addin provides a formatted preview.
Additionally, you can inspect the corresponding HTML markup and the previous revision of your post.
Editedit includes a basic password mechanism but because the password is transmitted as plain-text you should not use Editedit without taking additional security measures (more on security later).
Editedit is very convenient, but don't forget about your editor! Also, please be careful when posting this way because Editedit does not (yet) autosave. If you navigate away from the page while you are editing a post, close your browser window, or if your your browser or operating system malfunctions, you may lose any unsaved changes.
To be safe, if you want to use the web form and you have a long post, use a text editor and copy and paste the finished post to the Editedit form.
Markdown - Markdown has already been dicussed (see Simple Writing). The Markdown addin is nothing more than a wrapper around the Markdown script itself.
Exscape - Allows you to define various escape sequences, for example replacing special characters with corresponding HTML entity references. Keep in mind that some of this is handled by Markdown (See the Markdown syntax reference for more information about how Markdown handles escape sequences).
Many more addins are on the way. I'll shortly post a list of the addins I'm working on and invite other developers to do the same, i.e. start working on new addins and post a list of addins they're working on and a 'best-estimate' timeframe so that other developers and end-users can anticipate work that is being done related to the project.
Note that Ode does not use a package manager (like CPAN). Why? Doing so adds an external dependency, potentially fractures support and maintenance issues between multiple projects, and complicates initial setup and configuration, especially for users new to both Ode and the package manager who must, at the outset, contend with multiple new projects.
Upgrading Ode involves replacing a single file. Because configuration details are kept out of the script itself (and your content, themes, and addins are unaffected by an upgrade) all that's required is replacing the current version of the script with the new one.
Simple Configuration
There is a single configuration file. A default config file is available for download (and included in the bundles and XAMPP packages). All of the configuration options are well documented and include sample settings to help resolve any ambiguity in the description of what these options do and how they should be set.
What's more, you won't find dozens or hundreds of options. Expect to spend no more than 5 - 10 minutes configuring Ode, the majority of it reading through the descriptions of the various settings. That time will save you potentially many hours trying to resolve problems due to misconfiguration.
Let's be honest, security isn't that simple. W can keep security simple for Ode by doing as little as possible. Anything we do in Ode itself is unlikely to improve the security outlook and in fact may introduce more risk. Instead, let's rely on some trusted friends: SSH, sFTP, SSL.
SSH is a network protocol that allows for secure data exchange between computers. SSH is a well tested, widely distributed, open standard and is very well regarded. What's more, SSH is very flexible, making possible a wide range of communications from remote administration through a secure console, file transfer, and tunneling of other protocols (whereby unsecure applications and there protocols are redirected through the SSH to a remote host over the encrypted SSH connection).
SFTP is a file transfer protocol which is typically implemented on top of SSH. Using SFTP is no more difficult than using FTP, in fact many people confuse confuse the two. Chances are that your file transfer client supports SFTP (if not it's time to get a new client).
Both SSH/SFTP are relatively easy to use. The details of how they work to establish and maintain a secure channel are actually quite complex. Support for SSH and SFTP is built into most modern mainstream operating systems, and available for every one. Furthermore, if you plan on hosting your site, you should expect your provider to support at least SFTP in addition to possibly other secure mechanisms for interacting with your site (all of which will work well with Ode). See the documentation for help enabling and using SSH and SFTP for Linux, Mac OS X, and Windows.
Last but not least there is TLS (Transport Layer Security)/SSL (Secure Sockets Layer). If you have heard of SSL but not TLS, it is an update to SSL intended to bring SSL into the fold as a standard internet protocol (under the auspices of the IETF) as well as introduce some new features and resolve outstanding issues with SSL.
These protocols provide for secure transactions between browser and server on the web, i.e. secure HTTP transactions. HTTP is the application protocol of the web and is itself is not secure. SSL is a secure lower level protocol whcih can be used to encrypt and transport HTTP data. Support for the protocol is included in all mainstream web browsers in such a way that it is easy to secure transactions between the brower and a web server using SSL. Like SSH and SFTP, SSL is easy to use. Unlike SSH and SFTP the web server must be configured properly to use SSL. Configuring your web server to use SSL is not necessary difficult to do but it is not trivial either.
If you are hosting your site, your provider may be able to help you configure your website to use SSL (they will probably charge you a fee for this service). If you are hosting your own server you can configure your server to use SSL on your own. See the documentation for help setting up SSL for Apache.
Do you need to use SSL? It depends. If you are sending sensitive information between your web browser and a web server then yes, you really should use SSL. OK, well do I need to do that then? Normally no, but there is an exception.
The rule
Typically the information you transmit between your computer and your web browser is not secure. The whole idea of having a public web server is to share information. If anyone is free to browse the content of your site there is little point in encrypting and otherwise securing that same content as it is en route. You should never store information you do not intend to make public on a public web server unless you are absolutely confident you know what you're doing.
The exception
The Editedit addin allows you to post to your site through a browser. Presumably the post is intended to be public so as discussed above we don't necessary care about encrypting the post. However, so that not just anyone can edit your posts, Editedit includes a basic password mechanism. When the option to use a password is enabled, the correct password must be specified to add or edit content on the site. Without SSL, this password will be transmitted as clear text. Unlike the post, the password is sensitive because with the password anyone can edit your site. So you really should enable SSL to secure the password whenever you use the Editedit addin.
Generally speaking, it is not super difficult to configure SSL, though it is a bit of a pain. Unfortunately, for those of you with a hosting provider, you are subject to their requirements, restrictions (and fees).
The final point I want to make about SSL. Typically setting up SSL involves creating a certificate, which is essentially an identifier and a key and having that certificate signed by a certificate authority, which a third party well known to be reputable and capable of verifying and endorsing the identity of the entity represented by the certificate.
If you don't know anything about cryptography its enough for the discussion here to know that a key is randomly generated string of sufficient length and complexity that they cannot be guessed or discovered through trial and error.
The Certificate Authority (CA) plays an integral role in guaranteeing the security of public key cryptography. Communication cannot be considered secure unless the authenticity of all entites involved can be established, i.e. there must be a guarentee that you know with whom you are communicating.
That having been said, if you are setting up SSL on your own server solely for your own use then you can forgo the CA and 'self-sign' your own certificate. You can know that the key is valid without the CA's validation. This may be sufficient for your Ode blog, as long as you are the only person who needs to trust that the certificate is valid. If on the other hand you are using Ode in such a way that visitors to use SSL, then please do work with a certificate authority in the process of setting up SSL. See the documentation for help setting up SSL for Apache.
Please do invest the reasonable amount of time and effort required to configure SSL. You'll only need to do it up once.
The final point I want to make about security has to do with passwords.
It is highly recommended that any password you use with Ode be different from any other password used on your system!
Otherwise, please be careful to choose a good password.
Some simple guidelines:
That's the end of this short introduction to Ode.
This site will be updated frequently. Everything posted will show up on the home page with the exception of presentations and anything in the sandbox. So you can subscribe to ode-is-simple.com/home/ and not miss a thing.
Alternatively join the Google Group. Subscribe by entering your email address in the box in the sidebar labeled Ode-Discussion at Google Groups.
To create a new paragraph - type a blank line
Create your first paragraph simply start typing. To end the paragraph and start a new one, insert one or more blank lines. The number of blank lines you add is unimportant. A single blank line is enough to start a new paragraph and adding additional blank lines has no effect.
Note that a blank line is a line containing only whitespace. If you finish typing a line of text press the return key to type only spaces and tabs, press the return key again and start typing text again, you've just created a new paragraph. On the other hand, if you typed even a single character other than a space, tab or return then you're continuing the same paragraph.
Extraneous spaces and tabs are ignored (i.e. they collapse to a single space).
So something like this:
words scattered
around
like so
Becomes this:
words scattered around like so
Paragraphs should not be indented with spaces or tabs unless you are trying to do something special (e.g. create a pre-formatted block like the one above).
Two styles of specifying headings are supported.
You can produce (only) first and second level headings (H1 and H2) using Setext-style markup.
You can produce level 1 - 6 headings (H1 - H6) using atx-style markup.
Start the line containing the heading text with the number of hash characters (# - also referred to as pound signs) corresponding to the desired heading level.
You can optionally add an equal number of trailing hashes at the end of the line. There is no functional advantage to adding the trauling hash characters, but doing so may improve the readability of the source document (i.e. the document as it appears in a text editor).
Keep in mind that headings are primarily structural elements of a page. You should not use headings simply as a way of emphasizing text, forcing breaks, or in any other inappropriate way.
From the [W3C]'s(w3c) HTML 4.01 Specifiication document
A heading element briefly describes the topic of the section it introduces. Heading information may be used by user agents, for example, to construct a table of contents for a document automatically.
There are six levels of headings in HTML with H1 as the most important and H6 as the least. Visual browsers usually render more important headings in larger fonts than less important ones.
First-level heading - underline the heading text with (one or more) equal signs (=).
For example
My First-level Heading
=
or alternatively
My First-level Heading
======================
The number of equal signs you use is unimportant. The rule is 'one or more' equal signs (and nothing else) on the line immediately following the heading text. Underlining the entire heading with equal signs is arguably easier to read than the 'just enough to get the job done' alternative with only a single equal sign.
Second-level heading - underline the heading text with (one or more) dashes (-).
For example
My Second-level Heading
-
or alternatively
My Second-level Heading
-----------------------
Again, the number of dashes you use is unimportant. The rule is 'one or more' dashes (and nothing else) on the line immediately following the heading text. Underlining the entire heading with dashes is arguably easier to read than the 'just enough to get the job done' alternative with only a single dash.
For H3 - H6 headings you must use atx-style headings (described next).
You must use atx-style headings to produce H3 - H6 headings. Of course, you can also use atx-style markup for H1 and H3 headings. So if you only want to commit one of these two heading styles to memory then stick to the atx-style.
The good news is that atx-style headings are relatively intutive and easy to remember.
For example, this markup:
# First-level heading
## Second-level heading ##
### Third-level heading
#### Fourth-level heading ####
##### Fifth-level heading
###### Sixth-level heading ######
Results in this:
To add a blockquote - Start one or more consecutive lines with a '>' character.
Note that this is the same as how you might quote a block of text in an email message.
markdown allows you to use only a single '>' at the start of the quote. All consecutive lines are quoted until the first newline. Alternatively you can start each line of the blockquote with it's own '>' character. Consecutive lines will contribute to a single blockquote.
Blcokquoting couldn't be any easier than it is with markdown. Futhermore, blockquotes in markdown while easy to produce do not lose any of their sophistication.
Because of the combination of it's simple inspired inspired syntax maybe no other element captures the spirit of markdown as well as blockquotes.
To create a blockquote simply start a line with a greater than symbol, '>'. Without doing anything else, all consecutive lines are included in the quote.
For example:
> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Alternatively, you can start each line with it's own '>' character. All of the consecutive lines taken together still constitute a single blockquote.
For example:
> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
> set eiusmod tempor incidunt et labore et dolore magna aliquam.
> Ut enim unt ut labore et dolore magna aliqua.
> Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Note that in the block qbove all of the lines are hard-wrapped (i.e. all end in a return). You are free to wrap the text wherever it looks best to you. Remember that returns do not translate to paragraph or line breaks with markdown. So though you may wrap the text of a blockquote to improve the readability of the source document, you do not need to worry about how those return will affect the look at the blockquoted passage in a web browser.
I said that blockquotes did not lose any of their sophistication in markdown. More specifically, you can include markdown text inside a blockquote and it will be interpreted exactly as it would be normally (i.e. outside of a blockquote). You can even have a blockquote within a blockquote (nested quotes) by using more than one '>' character.
For example
> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
> set eiusmod tempor incidunt et labore et dolore magna aliquam.
> > Lorem ipsum dolor sit amet, consectetur adipiscing elit,
> > set eiusmod tempor incidunt et labore et dolore magna aliquam.
> > Ut enim unt ut labore et dolore magna aliqua.
> > Ut enim ad trenz ucu hugh ipsum monugor.
> Ut enim unt ut labore et dolore magna aliqua.
> Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Again this is exactly how quoting is handled in email.
To make the use of blockquoting even easier, keep in mind that many text editors are capable of helping you with this style of quoting (search the menus for items titled something similar to 'increase quote level' and 'decrease quote level').
HTML supports two types of lists
Markdown allows you to specify either type.
Specify unordered lists as a series of consecutive lines, where each line is a separate list item, and each line begins with an asterisk ('*'), plus ('+'), or hyphen ('-').
For example:
* item one
* item two
* item three
Specify ordered lists as a series of consecutive lines, where each line is a separate list item and each line begins with a number and a period (e.g. '1.').
Important: The numbers used are unimportant in that they have no effect on how the rendered list is interpreted by markdown.
For example the following are all equivalent:
Example 1
1. item one
2. item two
3. item three
Example 2
1. item one
1. item two
1. item three
Example 3
6. item one
5. item two
9. item three
List markers typically start at the left margin, but may be indented by up to three spaces.
Compare:
* item one (w/o indentation)
* item two (w/o indentation)
* item three (w/o indentation)
Which results in the following list:
with
* item one (indented three spaces)
* item two (indented three spaces)
* item three (indented three spaces)
Which results in the following list:
Note: Don't mix different levels of indentation within the same list unless you are intending to create a nested list.
For example:
* item one (w/o indentation)
* item two (indented two spaces)
* item three (indented one space)
Results in the folllowing list:
Where items two and three are placed in a second unordered list which is an item of the first unordered list.
<ul>
<li>item one (w/o indentation)</li>
<li>
<ul>
<il>item two (indented two spaces)</il>
<il>item three (indented two spaces)</il>
</ul>
</li>
</ul>
This sort of construction can be useful but it is not a simple list of three items.
List markers must be followed by one or more spaces or a tab.
So this for example is not a valid list
1.item one
2.item two
3.item three
Compare that with the following (which is valid)
1. item one
2. item two
3. item three
Note that the number of spaces or tabs following the list marker is not significant.
When your list items span multiple lines, you may choose to indent all of the lines after the first.
For example:
* Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
* Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
But this isn't required.
The following is also valid:
* Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
* Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
The first of the two examples above is arguably easier to read.
If list items are separated by blank lines, markdown will wrap each list item in a paragraph tag in the resulting HTML markup.
Compare
* item one
* item two
* item three
with
* item one
* item two
* item three
The first results in the following HTML markup
<ul>
<li>item one</li>
<li>item two</li>
<li>item three</li>
</ul>
The second results in the following HTML
<ul>
<li><p>item one</p></li>
<li><p>item two</p></li>
<li><p>item three</p></li>
</ul>
List items may consist of multiple paragraphs. To accomplish this, each paragraph after the first must be indented by at least 4 spaces or a single tab.
Just as we saw with list items spanning multiple lines, every line in these additional paragraphs may be indented but this is not required.
Compare
1. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
2. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
with
1. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
2. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
set eiusmod tempor incidunt et labore et dolore magna aliquam.
Ut enim unt ut labore et dolore magna aliqua.
Ut enim ad trenz ucu hugh ipsum monugor.
The first of the two examples above is arguably easier to read but they will be interpreted identically. Either will produce the following list:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
We can use markdown within lists. Just like blockquotes, the synax is interpreted as it normally is within a list, however it's important to note that any feature that requires that text be indented (for example preformatted text - discussed below), we must first indent for the list and then again for the feature included in the list.
For example, pre-formatted text requires that each line of the block be indented by at least four spaces or one tab. To include a pre-formatted block within a list, the block must first be indented by four spaces or one tab to indicate that it is part of a list item, and indented four more spaces or another tab so that it will be interpreted as a preformatted block (a total of 8 spaces).
We'll end the discussion of list syntax with a couple a warning (or two).
First, it is possible to create a list unintentionally. Remember that any series of digits followed immediately by a period and then any number of spaces or tabs (at least one) will be interpreted as a list item and result in the creation of a list.
For example (example taken from markdown's own website:
1986. was an important year
which is interpreted as:
To avoid this being mistaken for a list, backslash-escape the period.
1986\. was an important year
In general 'escaping' a special characters is a way to tell an interpreter, like markdown interpreter, to disregard the characters special function (Use of escape sequences is discussed elsewhere in this document - refer to the index).
Finally, we have this warning from the developer of the markdown syntax:
If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.
This is telling us that if we choose to number an ordered list out of sequence,
for example
6. item one
5. item two
9. item three
or
2. item one
2. item two
2. item three
We should always start the list with '1.'. So, those two examples should b rewritten as:
1. item one
5. item two
9. item three
and
1. item one
1. item two
1. item three
This is not because the current version of markdown will misinterpret the list but to accomodate a potential future revision of the syntax.
Preformatted blocks are useful for writing about markup, programming languages, or other very structured block of text that should be interpreted literally (i.e. left untouched).
To produce a preformatted block, indent every line of the block by at least 4 spaces or one tab.
Preformatted code blocks are the answer to the otherwise insoluble riddle, 'how do you write about a markup syntax, exposing the syntax itself, using the syntax you are writing about without it being interpreted?'
For example, it is not very useful to do something like...
Use the following syntax to create a blockquote:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, set eiusmod tempor incidunt et labore et dolore magna aliquam. Ut enim unt ut labore et dolore magna aliqua. Ut enim ad trenz ucu hugh ipsum monugor.
Huh? What was that?
I can see the blockquote but not the syntax that is responsible for creating the blockquote. What's worse, if I look at the source code for the page in my browser all I'll see is the HTML resulting from the markdown syntax I was to create the blockquote (not the markdown syntax itself).
What I wanted to do was this...
Use the following syntax to create a blockquote:
> Lorem ipsum dolor sit amet, consectetur adipiscing elit,
> set eiusmod tempor incidunt et labore et dolore magna aliquam.
> Ut enim unt ut labore et dolore magna aliqua.
> Ut enim ad trenz ucu hugh ipsum monugor.
And preformatted code blocks make that possible.
The [W3C]'s(w3c) HTML 4.01 Specifiication document tells us this about preformatted blocks:
The PRE element tells visual user agents that the enclosed text is "preformatted". When handling preformatted text, visual user agents:
May leave white space intact. May render text with a fixed-pitch font. May disable automatic word wrap. Must not disable bidirectional processing.
To produce a preformatted code block in markdown, indent every line of the block by at least 4 spaces or one tab.
In response, markdown wraps the block in both <pre> and <code> tags.
For example:
This is a line of normal text.
It is wrapped in <p> (paragraph) tags in the resulting HTML by markdown, which looks like this:
<p>This is a line of normal text.</p>
For comparison the same line as preformatted text (indented by at least four spaces or one tab) is wrapped in <pre> and <code> tags, which looks like this:
<pre><code>This is a line of preformatted text.</code></pre>
Because preformatted blocks leave whitespace intact (i.e. consecutive whitespace is not collapsed down to a single space as it normally is) and can be rendered using a monospaced font, these blocks are very useful for representing source code in which spacing and indentation is crucially important to communicating the structure of the code which determines how the code is executed.
There is one subtly here. Because we must indent each line of the block by at least 4 spaces or one tab to indicate to markdown that we want a preformatted code block, markdown removes 4 spaces or one tabe from each line (keep in mind that whitespace is not removed from the block itself). This means that the structure of the block remains intact.
For example the following simple structured block:
loop
first statement in the loop
second statement in the loop
third statement in the loop
end loop
Will be rendered as:
loop
first statement in the loop
second statement in the loop
third statement in the loop
end loop
Notice that the indentation is preserved. The first four spaces are stripped from every line leaving the nested structure intact. Though this is a simple example, it does illustrate the idea. Your more complicated code blocks will behave the same way.
Keep in mind that a code block continues until the first line encountered that is not indented.
A code block continues until it reaches a line that is not indented (or the end of the article).
Within a code block, ampersands (&) and angle brackets (< and >)
are automatically converted into HTML entities. This makes it very
easy to include example HTML source code using Markdown -- just paste
it and indent it, and Markdown will handle the hassle of encoding the
ampersands and angle brackets. For example, this:
<div class="footer">
© 2004 Foo Corporation
</div>
will turn into:
<pre><code><div class="footer">
© 2004 Foo Corporation
</div>
</code></pre>
Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it's also easy to use Markdown to write about Markdown's own syntax.
The implication of the "one or more consecutive lines of text" rule is
that Markdown supports "hard-wrapped" text paragraphs. This differs
significantly from most other text-to-HTML formatters (including Movable
Type's "Convert Line Breaks" option) which translate every line break
character in a paragraph into a `<br />` tag.
When you *do* want to insert a `<br />` break tag using Markdown, you
end a line with two or more spaces, then type return.
Yes, this takes a tad more effort to create a `<br />`, but a simplistic
"every line break is a `<br />`" rule wouldn't work for Markdown.
Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
work best -- and look better -- when you format them with hard breaks.
[bq]: #blockquote
[l]: #list
Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters -- including Setext, atx, Textile, reStructuredText, Grutatext, and EtText -- the single biggest source of inspiration for Markdown's syntax is the format of plain text email.
To this end, Markdown's syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like *emphasis*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you've ever used email.
Markdown's syntax is intended for one purpose: to be used as a format for writing for the web.
Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown's formatting syntax only addresses issues that can be conveyed in plain text.
For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to indicate that you're switching from Markdown to HTML; you just use the tags.
The only restrictions are that block-level HTML elements -- e.g. <div>,
<table>, <pre>, <p>, etc. -- must be separated from surrounding
content by blank lines, and the start and end tags of the block should
not be indented with tabs or spaces. Markdown is smart enough not
to add extra (unwanted) <p> tags around HTML block-level tags.
For example, to add an HTML table to a Markdown article:
This is a regular paragraph.
<table>
<tr>
<td>Foo</td>
</tr>
</table>
This is another regular paragraph.
Note that Markdown formatting syntax is not processed within block-level
HTML tags. E.g., you can't use Markdown-style *emphasis* inside an
HTML block.
Span-level HTML tags -- e.g. <span>, <cite>, or <del> -- can be
used anywhere in a Markdown paragraph, list item, or header. If you
want, you can even use HTML tags instead of Markdown formatting; e.g. if
you'd prefer to use HTML <a> or <img> tags instead of Markdown's
link or image syntax, go right ahead.
Unlike block-level HTML tags, Markdown syntax is processed within span-level tags.
In HTML, there are two characters that demand special treatment: <
and &. Left angle brackets are used to start tags; ampersands are
used to denote HTML entities. If you want to use them as literal
characters, you must escape them as entities, e.g. <, and
&.
Ampersands in particular are bedeviling for web writers. If you want to
write about 'AT&T', you need to write 'AT&T'. You even need to
escape ampersands within URLs. Thus, if you want to link to:
http://images.google.com/images?num=30&q=larry+bird
you need to encode the URL as:
http://images.google.com/images?num=30&q=larry+bird
in your anchor tag href attribute. Needless to say, this is easy to
forget, and is probably the single most common source of HTML validation
errors in otherwise well-marked-up web sites.
Markdown allows you to use these characters naturally, taking care of
all the necessary escaping for you. If you use an ampersand as part of
an HTML entity, it remains unchanged; otherwise it will be translated
into &.
So, if you want to include a copyright symbol in your article, you can write:
©
and Markdown will leave it alone. But if you write:
AT&T
Markdown will translate it to:
AT&T
Similarly, because Markdown supports inline HTML, if you use angle brackets as delimiters for HTML tags, Markdown will treat them as such. But if you write:
4 < 5
Markdown will translate it to:
4 < 5
However, inside Markdown code spans and blocks, angle brackets and
ampersands are always encoded automatically. This makes it easy to use
Markdown to write about HTML code. (As opposed to raw HTML, which is a
terrible format for writing about HTML syntax, because every single <
and & in your example code needs to be escaped.)
A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.
The implication of the "one or more consecutive lines of text" rule is
that Markdown supports "hard-wrapped" text paragraphs. This differs
significantly from most other text-to-HTML formatters (including Movable
Type's "Convert Line Breaks" option) which translate every line break
character in a paragraph into a <br /> tag.
When you do want to insert a <br /> break tag using Markdown, you
end a line with two or more spaces, then type return.
Yes, this takes a tad more effort to create a <br />, but a simplistic
"every line break is a <br />" rule wouldn't work for Markdown.
Markdown's email-style blockquoting and multi-paragraph list items
work best -- and look better -- when you format them with hard breaks.
You can produce a horizontal rule tag (<hr />) by placing three or
more hyphens, asterisks, or underscores on a line by themselves. If you
wish, you may use spaces between the hyphens or asterisks. Each of the
following lines will produce a horizontal rule:
* * *
***
*****
- - -
---------------------------------------
Markdown supports two style of links: inline and reference.
In both styles, the link text is delimited by [square brackets].
To create an inline link, use a set of regular parentheses immediately after the link text's closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an optional title for the link, surrounded in quotes. For example:
This is [an example](http://example.com/ "Title") inline link.
[This link](http://example.net/) has no title attribute.
Will produce:
<p>This is <a href="http://example.com/" title="Title">
an example</a> inline link.</p>
<p><a href="http://example.net/">This link</a> has no
title attribute.</p>
If you're referring to a local resource on the same server, you can use relative paths:
See my [About](/about/) page for details.
Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link:
This is [an example][id] reference-style link.
You can optionally use a space to separate the sets of brackets:
This is [an example] [id] reference-style link.
Then, anywhere in the document, you define your link label like this, on a line by itself:
[id]: http://example.com/ "Optional Title Here"
That is:
The following three link definitions are equivalent:
[foo]: http://example.com/ "Optional Title Here"
[foo]: http://example.com/ 'Optional Title Here'
[foo]: http://example.com/ (Optional Title Here)
Note: There is a known bug in Markdown.pl 1.0.1 which prevents single quotes from being used to delimit link titles.
The link URL may, optionally, be surrounded by angle brackets:
[id]: <http://example.com/> "Optional Title Here"
You can put the title attribute on the next line and use extra spaces or tabs for padding, which tends to look better with longer URLs:
[id]: http://example.com/longish/path/to/resource/here
"Optional Title Here"
Link definitions are only used for creating links during Markdown processing, and are stripped from your document in the HTML output.
Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are not case sensitive. E.g. these two links:
[link text][a]
[link text][A]
are equivalent.
The implicit link name shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets -- e.g., to link the word "Google" to the google.com web site, you could simply write:
[Google][]
And then define the link:
[Google]: http://google.com/
Because link names may contain spaces, this shortcut even works for multiple words in the link text:
Visit [Daring Fireball][] for more information.
And then define the link:
[Daring Fireball]: http://daringfireball.net/
Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they're used, but if you want, you can put them all at the end of your document, sort of like footnotes.
Here's an example of reference links in action:
I get 10 times more traffic from [Google] [1] than from
[Yahoo] [2] or [MSN] [3].
[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"
Using the implicit link name shortcut, you could instead write:
I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].
[google]: http://google.com/ "Google"
[yahoo]: http://search.yahoo.com/ "Yahoo Search"
[msn]: http://search.msn.com/ "MSN Search"
Both of the above examples will produce the following HTML output:
<p>I get 10 times more traffic from <a href="http://google.com/"
title="Google">Google</a> than from
<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
For comparison, here is the same paragraph written using Markdown's inline link style:
I get 10 times more traffic from [Google](http://google.com/ "Google")
than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
[MSN](http://search.msn.com/ "MSN Search").
The point of reference-style links is not that they're easier to write. The point is that with reference-style links, your document source is vastly more readable. Compare the above examples: using reference-style links, the paragraph itself is only 81 characters long; with inline-style links, it's 176 characters; and as raw HTML, it's 234 characters. In the raw HTML, there's more markup than there is text.
With Markdown's reference-style links, a source document much more closely resembles the final output, as rendered in a browser. By allowing you to move the markup-related metadata out of the paragraph, you can add links without interrupting the narrative flow of your prose.
Markdown treats asterisks (*) and underscores (_) as indicators of
emphasis. Text wrapped with one * or _ will be wrapped with an
HTML <em> tag; double *'s or _'s will be wrapped with an HTML
<strong> tag. E.g., this input:
*single asterisks*
_single underscores_
**double asterisks**
__double underscores__
will produce:
<em>single asterisks</em>
<em>single underscores</em>
<strong>double asterisks</strong>
<strong>double underscores</strong>
You can use whichever style you prefer; the lone restriction is that the same character must be used to open and close an emphasis span.
Emphasis can be used in the middle of a word:
un*fucking*believable
But if you surround an * or _ with spaces, it'll be treated as a
literal asterisk or underscore.
To produce a literal asterisk or underscore at a position where it would otherwise be used as an emphasis delimiter, you can backslash escape it:
\*this text is surrounded by literal asterisks\*
To indicate a span of code, wrap it with backtick quotes (`).
Unlike a pre-formatted code block, a code span indicates code within a
normal paragraph. For example:
Use the `printf()` function.
will produce:
<p>Use the <code>printf()</code> function.</p>
To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters:
``There is a literal backtick (`) here.``
which will produce this:
<p><code>There is a literal backtick (`) here.</code></p>
The backtick delimiters surrounding a code span may include spaces -- one after the opening, one before the closing. This allows you to place literal backtick characters at the beginning or end of a code span:
A single backtick in a code span: `` ` ``
A backtick-delimited string in a code span: `` `foo` ``
will produce:
<p>A single backtick in a code span: <code>`</code></p>
<p>A backtick-delimited string in a code span: <code>`foo`</code></p>
With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags. Markdown will turn this:
Please don't use any `<blink>` tags.
into:
<p>Please don't use any <code><blink></code> tags.</p>
You can write this:
`—` is the decimal-encoded equivalent of `—`.
to produce:
<p><code>—</code> is the decimal-encoded
equivalent of <code>—</code>.</p>
Admittedly, it's fairly difficult to devise a "natural" syntax for placing images into a plain text document format.
Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: inline and reference.
Inline image syntax looks like this:


That is:
!;alt
attribute text for the image;title attribute enclosed in double
or single quotes.Reference-style image syntax looks like this:
![Alt text][id]
Where "id" is the name of a defined image reference. Image references are defined using syntax identical to link references:
[id]: url/to/image "Optional title attribute"
As of this writing, Markdown has no syntax for specifying the
dimensions of an image; if this is important to you, you can simply
use regular HTML <img> tags.
Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
<http://example.com/>
Markdown will turn this into:
<a href="http://example.com/">http://example.com/</a>
Automatic links for email addresses work similarly, except that Markdown will also perform a bit of randomized decimal and hex entity-encoding to help obscure your address from address-harvesting spambots. For example, Markdown will turn this:
<address@example.com>
into something like this:
<a href="mailto:addre
ss@example.co
m">address@exa
mple.com</a>
which will render in a browser as a clickable link to "address@example.com".
(This sort of entity-encoding trick will indeed fool many, if not most, address-harvesting bots, but it definitely won't fool all of them. It's better than nothing, but an address published in this way will probably eventually start receiving spam.)
Markdown allows you to use backslash escapes to generate literal
characters which would otherwise have special meaning in Markdown's
formatting syntax. For example, if you wanted to surround a word with
literal asterisks (instead of an HTML <em> tag), you can backslashes
before the asterisks, like this:
\*literal asterisks\*
Markdown provides backslash escapes for the following characters:
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamation mark