Markdown is, unfortunately, not standardized. Different tools will support different markup syntax and process them differently. The Markdown described in the previous chapter will work in most, if not all, tools. The table syntax is usually less well supported, but the rest of the markup will ordinarily work.
Pandoc provides several extensions to the Markdown language described in the previous chapter. In this chapter, we will see some useful extensions for lists and tables. To get a complete list of Pandoc extensions to Markdown, you should consult the Pandoc documentation at https://tinyurl.com/y87mstzf.
Lists
3. This lists start at number three.
4. Although we used “5.” to start this item, it still gets the number 4.
This is a good way to continue lists, but you will have to update the initial number when you have added or removed items in the previous list.
- (1)
Starting a list
- (2)
Continuing the list
- (3)
This continues the list, numbered from where we left off the list.
- (4)
This item is labelled so that we can refer back to it. Like this: see item (4).
This can be very useful for lists of examples or such, but the “@” counter is global so you cannot restart the counter. Unfortunately, there is currently no support for both automatically numbered items and restarting counters.
- 1)
This is a
- 2)
list
- 3)
it really is
- a.
This list uses letters instead of numbers.
- b.We can make a sublist with roman numerals:
- i.
This sublist also uses parenthesis
- ii.
Cool, isn’t it?
- i.
- a.
This list uses letters instead of numbers.
- b.We can make a sublist with a roman numerals:
- i.
This sublist also uses parenthesis
- ii.
Cool, isn’t it?
- i.
You can mix the different list notations so you have different list formats as sublists, but if you mix them at the same level, you will start a new list.
Lists are frequently used to define terms or concepts, and in Pandoc you can create definition lists by following a term with a colon and indenting the start of the definition with a tab or at least four spaces. So you can create definition lists like this:
Something we want to define. Definition of the thing
As long as we indent the following lines, they become part of the definition.
Here starts the next thing we define. Here we write the definition.
More of the definition
Term 1 Definition 1
Term 2 Definition 2a
Definition 2b
Either syntax will do.
Tables
Right | Left | Center | Default |
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
How you align the elements in the columns determine how you align the headers above the dashes. If the text is to the right, the column will be right-aligned. The same for left and center alignment, if the text is on the left or in the middle, the table column will be left-aligned or centered. If you start the header at the same position as the dashes, you get the default alignment, which is left alignment.
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
If you do not provide a header, the alignment is determined by the first line in the table. In the preceding example, in the last column, the reason it isn’t right-aligned is that there is a space after the first number in the column before the end of the dashes that specify the column. Move the first number one position to the right, and that column would also be right-aligned.
Tables are the Markdown markups with the least consistent support in different tools. The table syntax described often frequently works, but in the two editors I use for writing my books, they are not supported. In all the Markdown viewers I am familiar with, though, they display correctly.
In Pandoc, there is excellent support for tables, and Pandoc provides some extensions to table markup beyond the preceding notation.
The result looks like this :
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
You can leave out the “Table” part if you want; just having the colon will give you a caption.
Centred Header | Default Aligned | Right Aligned | Left Aligned |
---|---|---|---|
First | row | 12.0 | Example of a row that spans multiple lines. |
Second | row | 5.0 | Here’s another one. Note the blank line between rows. |
First | row | 12.0 | Example of a row that spans multiple lines. |
Second | row | 5.0 | Here’s another one. Note the blank line between rows. |
Right | Left | Centered |
Right | Left | Centered |
Right | Left | Centered |
For these types of headers, the colons determine the alignment. Put a colon at the end of the “=” or “-” of the cell-border to get right-aligned columns, at the left to get left-aligned columns, and at both ends to get centered columns, and leave them out for the default alignment.
Right | Left | Default | Center |
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
Smart Punctuation
Proper text typography uses different types of dashes—hyphens in words, en-dashes for numeric intervals, and em-dashes for parenthetical sentences and emphasis. Quotes are usually different at the beginning and end of a text in quotation marks. Three dots are different from ellipses. Many word editors will automatically substitute some dashes and translate straight quotes into the correct form, but not all. Since you are writing Markdown in plain text, and since most keyboards do not give you access to all typographic symbols, Pandoc can help you out with getting these symbols. To enable this, you need to call Pandoc with the option --smart (we see how to invoke Pandoc in Chapter 5).
If you turn on smart punctuation , quotes will be handled correctly, three dots will be translated into ellipses, a single “-” will be a hyphen, two dashes will give you an en-dash, and three dashes will give you an em-dash.
Footnotes
When you add a footnote this way, the caret has to go inside the brackets. If it goes before the brackets, you are adding the footnote inside the text.
The output of the two approaches should look like this: Footnote inside a paragraph.1
Reference to a footnote.2
Exercises
Lists
Write a list with five items. Between two and three, add a paragraph of text, but make sure that the numbers continue with four.
Add a label to item three and refer to it in item five. Create a list of definitions as well. Make them multi-line.
Tables
Make a table with three columns where you left-justify the first column, center the second column, and right-justify the third.
Write a table with a caption. Until we format the Markdown with Pandoc in the next chapter, you will not see the result but keep the text so you can test it there
Footnotes
Write a text with a footnote. Use both notations for footnotes.