git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: More improvements to 'plain' output, updated tests.

Math now appears in unicode if possible, without the distracting italics around identifiers. Blank lines around headers are more consistent. Footnotes appear in regular [n] style.

commitc302ab31332fa7ee2fe9659d7a9f6abcd76ba114 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 27 Jul 2014, 07:57 (12 years ago) parentcc24a1f
4 files changed+187−128
src/Text/Pandoc/Writers/Markdown.hs+26−21 tests/writer.markdown+27−13 tests/writer.opml+13−13 tests/writer.plain+121−81
src/Text/Pandoc/Writers/Markdown.hs+26−21
@@ -37,7 +37,7 @@ import Text.Pandoc.Templates (renderTemplate')
3737import Text.Pandoc.Shared
3838import Text.Pandoc.Writers.Shared
3939import Text.Pandoc.Options
40−import Text.Pandoc.Parsing hiding (blankline, char, space)
40+import Text.Pandoc.Parsing hiding (blankline, blanklines, char, space)
4141import Data.List ( group, isPrefixOf, find, intersperse, transpose, sortBy )
4242import Data.Char ( isSpace, isPunctuation, toUpper )
4343import Data.Ord ( comparing )
@@ -79,6 +79,9 @@ writePlain opts document =
7979 writerExtensions = Set.delete Ext_escaped_line_breaks $
8080 Set.delete Ext_pipe_tables $
8181 Set.delete Ext_raw_html $
82+ Set.delete Ext_footnotes $
83+ Set.delete Ext_tex_math_dollars $
84+ Set.delete Ext_citations $
8285 writerExtensions opts }
8386 document) def{ stPlain = True }
8487
@@ -171,7 +174,7 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
171174 then tableOfContents opts headerBlocks
172175 else empty
173176 -- Strip off final 'references' header if markdown citations enabled
174− let blocks' = if not isPlain && isEnabled Ext_citations opts
177+ let blocks' = if isEnabled Ext_citations opts
175178 then case reverse blocks of
176179 (Div (_,["references"],_) _):xs -> reverse xs
177180 _ -> blocks
@@ -355,11 +358,11 @@ blockToMarkdown opts (Header level attr inlines) = do
355358 let setext = writerSetextHeaders opts
356359 return $ nowrap
357360 $ case level of
358− 1 | plain -> blankline <> text "\n\n" <> contents <> blankline <> text "\n"
361+ 1 | plain -> blanklines 3 <> contents <> blanklines 2
359362 | setext ->
360363 contents <> attr' <> cr <> text (replicate (offset contents) '=') <>
361364 blankline
362− 2 | plain -> blankline <> text "\n" <> contents <> blankline
365+ 2 | plain -> blanklines 2 <> contents <> blankline
363366 | setext ->
364367 contents <> attr' <> cr <> text (replicate (offset contents) '-') <>
365368 blankline
@@ -695,23 +698,15 @@ inlineToMarkdown opts (Strikeout lst) = do
695698 then "~~" <> contents <> "~~"
696699 else "<s>" <> contents <> "</s>"
697700inlineToMarkdown opts (Superscript lst) = do
698− plain <- gets stPlain
699− if plain
700− then inlineListToMarkdown opts lst
701− else do
702− contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
703− return $ if isEnabled Ext_superscript opts
704− then "^" <> contents <> "^"
705− else "<sup>" <> contents <> "</sup>"
701+ contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
702+ return $ if isEnabled Ext_superscript opts
703+ then "^" <> contents <> "^"
704+ else "<sup>" <> contents <> "</sup>"
706705inlineToMarkdown opts (Subscript lst) = do
707− plain <- gets stPlain
708− if plain
709− then inlineListToMarkdown opts lst
710− else do
711− contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
712− return $ if isEnabled Ext_subscript opts
713− then "~" <> contents <> "~"
714− else "<sub>" <> contents <> "</sub>"
706+ contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
707+ return $ if isEnabled Ext_subscript opts
708+ then "~" <> contents <> "~"
709+ else "<sub>" <> contents <> "</sub>"
715710inlineToMarkdown opts (SmallCaps lst) = do
716711 plain <- gets stPlain
717712 if plain
@@ -753,7 +748,11 @@ inlineToMarkdown opts (Math InlineMath str)
753748 return $ "\\(" <> text str <> "\\)"
754749 | isEnabled Ext_tex_math_double_backslash opts =
755750 return $ "\\\\(" <> text str <> "\\\\)"
756− | otherwise = inlineListToMarkdown opts $ texMathToInlines InlineMath str
751+ | otherwise = do
752+ plain <- gets stPlain
753+ inlineListToMarkdown opts $
754+ (if plain then makeMathPlainer else id) $
755+ texMathToInlines InlineMath str
757756inlineToMarkdown opts (Math DisplayMath str)
758757 | isEnabled Ext_tex_math_dollars opts =
759758 return $ "$$" <> text str <> "$$"
@@ -853,3 +852,9 @@ inlineToMarkdown opts (Note contents) = do
853852 if isEnabled Ext_footnotes opts
854853 then return $ "[^" <> ref <> "]"
855854 else return $ "[" <> ref <> "]"
855+
856+makeMathPlainer :: [Inline] -> [Inline]
857+makeMathPlainer = walk go
858+ where
859+ go (Emph xs) = Span nullAttr xs
860+ go x = x
tests/writer.markdown+27−13
@@ -9,7 +9,7 @@ title: Pandoc Test Suite
99This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
1010markdown test suite.
1111
12−* * * * *
12+------------------------------------------------------------------------------
1313
1414Headers
1515=======
@@ -38,7 +38,7 @@ Level 2
3838
3939with no blank line
4040
41−* * * * *
41+------------------------------------------------------------------------------
4242
4343Paragraphs
4444==========
@@ -54,7 +54,7 @@ Here’s one with a bullet. \* criminey.
5454There should be a hard line break\
5555here.
5656
57−* * * * *
57+------------------------------------------------------------------------------
5858
5959Block Quotes
6060============
@@ -84,7 +84,7 @@ This should not be a block quote: 2 \> 1.
8484
8585And a following paragraph.
8686
87−* * * * *
87+------------------------------------------------------------------------------
8888
8989Code Blocks
9090===========
@@ -105,7 +105,7 @@ And:
105105
106106 These should not be escaped: \$ \\ \> \[ \{
107107
108−* * * * *
108+------------------------------------------------------------------------------
109109
110110Lists
111111=====
@@ -268,7 +268,7 @@ M.A. 2007
268268
269269B. Williams
270270
271−* * * * *
271+------------------------------------------------------------------------------
272272
273273Definition Lists
274274================
@@ -277,8 +277,10 @@ Tight using spaces:
277277
278278apple
279279: red fruit
280+
280281orange
281282: orange fruit
283+
282284banana
283285: yellow fruit
284286
@@ -286,30 +288,37 @@ Tight using tabs:
286288
287289apple
288290: red fruit
291+
289292orange
290293: orange fruit
294+
291295banana
292296: yellow fruit
293297
294298Loose:
295299
296300apple
301+
297302: red fruit
298303
299304orange
305+
300306: orange fruit
301307
302308banana
309+
303310: yellow fruit
304311
305312Multiple blocks with italics:
306313
307314*apple*
315+
308316: red fruit
309317
310318 contains seeds, crisp, pleasant to taste
311319
312320*orange*
321+
313322: orange fruit
314323
315324 { orange code block }
@@ -321,6 +330,7 @@ Multiple definitions, tight:
321330apple
322331: red fruit
323332: computer
333+
324334orange
325335: orange fruit
326336: bank
@@ -328,11 +338,13 @@ orange
328338Multiple definitions, loose:
329339
330340apple
341+
331342: red fruit
332343
333344: computer
334345
335346orange
347+
336348: orange fruit
337349
338350: bank
@@ -340,11 +352,13 @@ orange
340352Blank line after term, indented marker, alternate markers:
341353
342354apple
355+
343356: red fruit
344357
345358: computer
346359
347360orange
361+
348362: orange fruit
349363
350364 1. sublist
@@ -465,7 +479,7 @@ Hr’s:
465479<hr class="foo" id="bar" />
466480<hr class="foo" id="bar">
467481
468−* * * * *
482+------------------------------------------------------------------------------
469483
470484Inline Markup
471485=============
@@ -495,7 +509,7 @@ Subscripts: H~2~O, H~23~O, H~many of them~O.
495509These should not be superscripts or subscripts, because of the unescaped
496510spaces: a\^b c\^d, a\~b c\~d.
497511
498−* * * * *
512+------------------------------------------------------------------------------
499513
500514Smart quotes, ellipses, dashes
501515==============================
@@ -517,7 +531,7 @@ Dashes between numbers: 5–7, 255–66, 1987–1999.
517531
518532Ellipses…and…and….
519533
520−* * * * *
534+------------------------------------------------------------------------------
521535
522536LaTeX
523537=====
@@ -548,7 +562,7 @@ Dog & 2 \\
548562Cat & 1 \\ \hline
549563\end{tabular}
550564
551−* * * * *
565+------------------------------------------------------------------------------
552566
553567Special Characters
554568==================
@@ -603,7 +617,7 @@ Plus: +
603617
604618Minus: -
605619
606−* * * * *
620+------------------------------------------------------------------------------
607621
608622Links
609623=====
@@ -685,7 +699,7 @@ Auto-links should not occur here: `<http://example.com/>`
685699
686700 or here: <http://example.com/>
687701
688−* * * * *
702+------------------------------------------------------------------------------
689703
690704Images
691705======
@@ -696,7 +710,7 @@ From “Voyage dans la Lune” by Georges Melies (1902):
696710
697711Here is a movie ![movie](movie.jpg) icon.
698712
699−* * * * *
713+------------------------------------------------------------------------------
700714
701715Footnotes
702716=========
tests/writer.opml+13−13
@@ -21,14 +21,14 @@
2121 <outline text="Level 3" _note="with no blank line&#10;">
2222 </outline>
2323 </outline>
24− <outline text="Level 2" _note="with no blank line&#10;&#10;* * * * *">
24+ <outline text="Level 2" _note="with no blank line&#10;&#10;------------------------------------------------------------------------">
2525 </outline>
2626</outline>
27−<outline text="Paragraphs" _note="Here’s a regular paragraph.&#10;&#10;In Markdown 1.0.0 and earlier. Version 8. This line turns into a list&#10;item. Because a hard-wrapped line in the middle of a paragraph looked&#10;like a list item.&#10;&#10;Here’s one with a bullet. \* criminey.&#10;&#10;There should be a hard line break\&#10;here.&#10;&#10;* * * * *">
27+<outline text="Paragraphs" _note="Here’s a regular paragraph.&#10;&#10;In Markdown 1.0.0 and earlier. Version 8. This line turns into a list&#10;item. Because a hard-wrapped line in the middle of a paragraph looked&#10;like a list item.&#10;&#10;Here’s one with a bullet. \* criminey.&#10;&#10;There should be a hard line break\&#10;here.&#10;&#10;------------------------------------------------------------------------">
2828</outline>
29−<outline text="Block Quotes" _note="E-mail style:&#10;&#10;&gt; This is a block quote. It is pretty short.&#10;&#10;&gt; Code in a block quote:&#10;&gt;&#10;&gt; sub status {&#10;&gt; print &quot;working&quot;;&#10;&gt; }&#10;&gt;&#10;&gt; A list:&#10;&gt;&#10;&gt; 1. item one&#10;&gt; 2. item two&#10;&gt;&#10;&gt; Nested block quotes:&#10;&gt;&#10;&gt; &gt; nested&#10;&gt;&#10;&gt; &gt; nested&#10;&#10;This should not be a block quote: 2 \&gt; 1.&#10;&#10;And a following paragraph.&#10;&#10;* * * * *">
29+<outline text="Block Quotes" _note="E-mail style:&#10;&#10;&gt; This is a block quote. It is pretty short.&#10;&#10;&gt; Code in a block quote:&#10;&gt;&#10;&gt; sub status {&#10;&gt; print &quot;working&quot;;&#10;&gt; }&#10;&gt;&#10;&gt; A list:&#10;&gt;&#10;&gt; 1. item one&#10;&gt; 2. item two&#10;&gt;&#10;&gt; Nested block quotes:&#10;&gt;&#10;&gt; &gt; nested&#10;&gt;&#10;&gt; &gt; nested&#10;&#10;This should not be a block quote: 2 \&gt; 1.&#10;&#10;And a following paragraph.&#10;&#10;------------------------------------------------------------------------">
3030</outline>
31−<outline text="Code Blocks" _note="Code:&#10;&#10; ---- (should be four hyphens)&#10;&#10; sub status {&#10; print &quot;working&quot;;&#10; }&#10;&#10; this code block is indented by one tab&#10;&#10;And:&#10;&#10; this code block is indented by two tabs&#10;&#10; These should not be escaped: \$ \\ \&gt; \[ \{&#10;&#10;* * * * *">
31+<outline text="Code Blocks" _note="Code:&#10;&#10; ---- (should be four hyphens)&#10;&#10; sub status {&#10; print &quot;working&quot;;&#10; }&#10;&#10; this code block is indented by one tab&#10;&#10;And:&#10;&#10; this code block is indented by two tabs&#10;&#10; These should not be escaped: \$ \\ \&gt; \[ \{&#10;&#10;------------------------------------------------------------------------">
3232</outline>
3333<outline text="Lists">
3434 <outline text="Unordered" _note="Asterisks tight:&#10;&#10;- asterisk 1&#10;- asterisk 2&#10;- asterisk 3&#10;&#10;Asterisks loose:&#10;&#10;- asterisk 1&#10;&#10;- asterisk 2&#10;&#10;- asterisk 3&#10;&#10;Pluses tight:&#10;&#10;- Plus 1&#10;- Plus 2&#10;- Plus 3&#10;&#10;Pluses loose:&#10;&#10;- Plus 1&#10;&#10;- Plus 2&#10;&#10;- Plus 3&#10;&#10;Minuses tight:&#10;&#10;- Minus 1&#10;- Minus 2&#10;- Minus 3&#10;&#10;Minuses loose:&#10;&#10;- Minus 1&#10;&#10;- Minus 2&#10;&#10;- Minus 3&#10;&#10;">
@@ -39,20 +39,20 @@
3939 </outline>
4040 <outline text="Tabs and spaces" _note="- this is a list item indented with tabs&#10;&#10;- this is a list item indented with spaces&#10;&#10; - this is an example list item indented with tabs&#10;&#10; - this is an example list item indented with spaces&#10;&#10;">
4141 </outline>
42− <outline text="Fancy list markers" _note="(2) begins with 2&#10;(3) and now 3&#10;&#10; with a continuation&#10;&#10; iv. sublist with roman numerals, starting with 4&#10; v. more items&#10; (A) a subsublist&#10; (B) a subsublist&#10;&#10;Nesting:&#10;&#10;A. Upper Alpha&#10; I. Upper Roman.&#10; (6) Decimal start with 6&#10; c) Lower alpha with paren&#10;&#10;Autonumbering:&#10;&#10;1. Autonumber.&#10;2. More.&#10; 1. Nested.&#10;&#10;Should not be a list item:&#10;&#10;M.A. 2007&#10;&#10;B. Williams&#10;&#10;* * * * *">
42+ <outline text="Fancy list markers" _note="(2) begins with 2&#10;(3) and now 3&#10;&#10; with a continuation&#10;&#10; iv. sublist with roman numerals, starting with 4&#10; v. more items&#10; (A) a subsublist&#10; (B) a subsublist&#10;&#10;Nesting:&#10;&#10;A. Upper Alpha&#10; I. Upper Roman.&#10; (6) Decimal start with 6&#10; c) Lower alpha with paren&#10;&#10;Autonumbering:&#10;&#10;1. Autonumber.&#10;2. More.&#10; 1. Nested.&#10;&#10;Should not be a list item:&#10;&#10;M.A. 2007&#10;&#10;B. Williams&#10;&#10;------------------------------------------------------------------------">
4343 </outline>
4444</outline>
45−<outline text="Definition Lists" _note="Tight using spaces:&#10;&#10;apple&#10;: red fruit&#10;orange&#10;: orange fruit&#10;banana&#10;: yellow fruit&#10;&#10;Tight using tabs:&#10;&#10;apple&#10;: red fruit&#10;orange&#10;: orange fruit&#10;banana&#10;: yellow fruit&#10;&#10;Loose:&#10;&#10;apple&#10;: red fruit&#10;&#10;orange&#10;: orange fruit&#10;&#10;banana&#10;: yellow fruit&#10;&#10;Multiple blocks with italics:&#10;&#10;*apple*&#10;: red fruit&#10;&#10; contains seeds, crisp, pleasant to taste&#10;&#10;*orange*&#10;: orange fruit&#10;&#10; { orange code block }&#10;&#10; &gt; orange block quote&#10;&#10;Multiple definitions, tight:&#10;&#10;apple&#10;: red fruit&#10;: computer&#10;orange&#10;: orange fruit&#10;: bank&#10;&#10;Multiple definitions, loose:&#10;&#10;apple&#10;: red fruit&#10;&#10;: computer&#10;&#10;orange&#10;: orange fruit&#10;&#10;: bank&#10;&#10;Blank line after term, indented marker, alternate markers:&#10;&#10;apple&#10;: red fruit&#10;&#10;: computer&#10;&#10;orange&#10;: orange fruit&#10;&#10; 1. sublist&#10; 2. sublist&#10;&#10;">
45+<outline text="Definition Lists" _note="Tight using spaces:&#10;&#10;apple&#10;: red fruit&#10;&#10;orange&#10;: orange fruit&#10;&#10;banana&#10;: yellow fruit&#10;&#10;Tight using tabs:&#10;&#10;apple&#10;: red fruit&#10;&#10;orange&#10;: orange fruit&#10;&#10;banana&#10;: yellow fruit&#10;&#10;Loose:&#10;&#10;apple&#10;&#10;: red fruit&#10;&#10;orange&#10;&#10;: orange fruit&#10;&#10;banana&#10;&#10;: yellow fruit&#10;&#10;Multiple blocks with italics:&#10;&#10;*apple*&#10;&#10;: red fruit&#10;&#10; contains seeds, crisp, pleasant to taste&#10;&#10;*orange*&#10;&#10;: orange fruit&#10;&#10; { orange code block }&#10;&#10; &gt; orange block quote&#10;&#10;Multiple definitions, tight:&#10;&#10;apple&#10;: red fruit&#10;: computer&#10;&#10;orange&#10;: orange fruit&#10;: bank&#10;&#10;Multiple definitions, loose:&#10;&#10;apple&#10;&#10;: red fruit&#10;&#10;: computer&#10;&#10;orange&#10;&#10;: orange fruit&#10;&#10;: bank&#10;&#10;Blank line after term, indented marker, alternate markers:&#10;&#10;apple&#10;&#10;: red fruit&#10;&#10;: computer&#10;&#10;orange&#10;&#10;: orange fruit&#10;&#10; 1. sublist&#10; 2. sublist&#10;&#10;">
4646</outline>
47−<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;And nested without indentation:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;bar&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;Interpreted markdown in a table:&#10;&#10;&lt;table&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&#10;This is *emphasized*&#10;&lt;/td&gt;&#10;&lt;td&gt;&#10;And this is **strong**&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/table&gt;&#10;&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;&#10;Here’s a simple block:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;This should be a code block, though:&#10;&#10; &lt;div&gt;&#10; foo&#10; &lt;/div&gt;&#10;&#10;As should this:&#10;&#10; &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;This should just be an HTML comment:&#10;&#10;&lt;!-- Comment --&gt;&#10;Multiline:&#10;&#10;&lt;!--&#10;Blah&#10;Blah&#10;--&gt;&#10;&lt;!--&#10; This is another comment.&#10;--&gt;&#10;Code block:&#10;&#10; &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;&lt;!-- foo --&gt;&#10;Code:&#10;&#10; &lt;hr /&gt;&#10;&#10;Hr’s:&#10;&#10;&lt;hr&gt;&#10;&lt;hr /&gt;&#10;&lt;hr /&gt;&#10;&lt;hr&gt;&#10;&lt;hr /&gt;&#10;&lt;hr /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;&#10;&#10;* * * * *">
47+<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;And nested without indentation:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;bar&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;Interpreted markdown in a table:&#10;&#10;&lt;table&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&#10;This is *emphasized*&#10;&lt;/td&gt;&#10;&lt;td&gt;&#10;And this is **strong**&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/table&gt;&#10;&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;&#10;Here’s a simple block:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;This should be a code block, though:&#10;&#10; &lt;div&gt;&#10; foo&#10; &lt;/div&gt;&#10;&#10;As should this:&#10;&#10; &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;This should just be an HTML comment:&#10;&#10;&lt;!-- Comment --&gt;&#10;Multiline:&#10;&#10;&lt;!--&#10;Blah&#10;Blah&#10;--&gt;&#10;&lt;!--&#10; This is another comment.&#10;--&gt;&#10;Code block:&#10;&#10; &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;&lt;!-- foo --&gt;&#10;Code:&#10;&#10; &lt;hr /&gt;&#10;&#10;Hr’s:&#10;&#10;&lt;hr&gt;&#10;&lt;hr /&gt;&#10;&lt;hr /&gt;&#10;&lt;hr&gt;&#10;&lt;hr /&gt;&#10;&lt;hr /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;&#10;&#10;------------------------------------------------------------------------">
4848</outline>
49−<outline text="Inline Markup" _note="This is *emphasized*, and so *is this*.&#10;&#10;This is **strong**, and so **is this**.&#10;&#10;An *[emphasized link](/url)*.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;This is code: `&gt;`, `$`, `\`, `\$`, `&lt;html&gt;`.&#10;&#10;~~This is *strikeout*.~~&#10;&#10;Superscripts: a^bc^d a^*hello*^ a^hello there^.&#10;&#10;Subscripts: H~2~O, H~23~O, H~many of them~O.&#10;&#10;These should not be superscripts or subscripts, because of the unescaped&#10;spaces: a\^b c\^d, a\~b c\~d.&#10;&#10;* * * * *">
49+<outline text="Inline Markup" _note="This is *emphasized*, and so *is this*.&#10;&#10;This is **strong**, and so **is this**.&#10;&#10;An *[emphasized link](/url)*.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;This is code: `&gt;`, `$`, `\`, `\$`, `&lt;html&gt;`.&#10;&#10;~~This is *strikeout*.~~&#10;&#10;Superscripts: a^bc^d a^*hello*^ a^hello there^.&#10;&#10;Subscripts: H~2~O, H~23~O, H~many of them~O.&#10;&#10;These should not be superscripts or subscripts, because of the unescaped&#10;spaces: a\^b c\^d, a\~b c\~d.&#10;&#10;------------------------------------------------------------------------">
5050</outline>
51−<outline text="Smart quotes, ellipses, dashes" _note="“Hello,” said the spider. “‘Shelob’ is my name.”&#10;&#10;‘A’, ‘B’, and ‘C’ are letters.&#10;&#10;‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’&#10;&#10;‘He said, “I want to go.”’ Were you alive in the 70’s?&#10;&#10;Here is some quoted ‘`code`’ and a “[quoted&#10;link](http://example.com/?foo=1&amp;bar=2)”.&#10;&#10;Some dashes: one—two — three—four — five.&#10;&#10;Dashes between numbers: 5–7, 255–66, 1987–1999.&#10;&#10;Ellipses…and…and….&#10;&#10;* * * * *">
51+<outline text="Smart quotes, ellipses, dashes" _note="“Hello,” said the spider. “‘Shelob’ is my name.”&#10;&#10;‘A’, ‘B’, and ‘C’ are letters.&#10;&#10;‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’&#10;&#10;‘He said, “I want to go.”’ Were you alive in the 70’s?&#10;&#10;Here is some quoted ‘`code`’ and a “[quoted&#10;link](http://example.com/?foo=1&amp;bar=2)”.&#10;&#10;Some dashes: one—two — three—four — five.&#10;&#10;Dashes between numbers: 5–7, 255–66, 1987–1999.&#10;&#10;Ellipses…and…and….&#10;&#10;------------------------------------------------------------------------">
5252</outline>
53−<outline text="LaTeX" _note="- \cite[22-23]{smith.1899}&#10;- $2+2=4$&#10;- $x \in y$&#10;- $\alpha \wedge \omega$&#10;- $223$&#10;- $p$-Tree&#10;- Here’s some display math:&#10; $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$&#10;- Here’s one that has a line break in it:&#10; $\alpha + \omega \times x^2$.&#10;&#10;These shouldn’t be math:&#10;&#10;- To get the famous equation, write `$e = mc^2$`.&#10;- \$22,000 is a *lot* of money. So is \$34,000. (It worked if “lot” is&#10; emphasized.)&#10;- Shoes (\$20) and socks (\$5).&#10;- Escaped `$`: \$73 *this should be emphasized* 23\$.&#10;&#10;Here’s a LaTeX table:&#10;&#10;\begin{tabular}{|l|l|}\hline&#10;Animal &amp; Number \\ \hline&#10;Dog &amp; 2 \\&#10;Cat &amp; 1 \\ \hline&#10;\end{tabular}&#10;&#10;* * * * *">
53+<outline text="LaTeX" _note="- \cite[22-23]{smith.1899}&#10;- $2+2=4$&#10;- $x \in y$&#10;- $\alpha \wedge \omega$&#10;- $223$&#10;- $p$-Tree&#10;- Here’s some display math:&#10; $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$&#10;- Here’s one that has a line break in it:&#10; $\alpha + \omega \times x^2$.&#10;&#10;These shouldn’t be math:&#10;&#10;- To get the famous equation, write `$e = mc^2$`.&#10;- \$22,000 is a *lot* of money. So is \$34,000. (It worked if “lot” is&#10; emphasized.)&#10;- Shoes (\$20) and socks (\$5).&#10;- Escaped `$`: \$73 *this should be emphasized* 23\$.&#10;&#10;Here’s a LaTeX table:&#10;&#10;\begin{tabular}{|l|l|}\hline&#10;Animal &amp; Number \\ \hline&#10;Dog &amp; 2 \\&#10;Cat &amp; 1 \\ \hline&#10;\end{tabular}&#10;&#10;------------------------------------------------------------------------">
5454</outline>
55−<outline text="Special Characters" _note="Here is some unicode:&#10;&#10;- I hat: Î&#10;- o umlaut: ö&#10;- section: §&#10;- set membership: ∈&#10;- copyright: ©&#10;&#10;AT&amp;T has an ampersand in their name.&#10;&#10;AT&amp;T is another way to write it.&#10;&#10;This &amp; that.&#10;&#10;4 \&lt; 5.&#10;&#10;6 \&gt; 5.&#10;&#10;Backslash: \\&#10;&#10;Backtick: \`&#10;&#10;Asterisk: \*&#10;&#10;Underscore: \_&#10;&#10;Left brace: {&#10;&#10;Right brace: }&#10;&#10;Left bracket: [&#10;&#10;Right bracket: ]&#10;&#10;Left paren: (&#10;&#10;Right paren: )&#10;&#10;Greater-than: \&gt;&#10;&#10;Hash: \#&#10;&#10;Period: .&#10;&#10;Bang: !&#10;&#10;Plus: +&#10;&#10;Minus: -&#10;&#10;* * * * *">
55+<outline text="Special Characters" _note="Here is some unicode:&#10;&#10;- I hat: Î&#10;- o umlaut: ö&#10;- section: §&#10;- set membership: ∈&#10;- copyright: ©&#10;&#10;AT&amp;T has an ampersand in their name.&#10;&#10;AT&amp;T is another way to write it.&#10;&#10;This &amp; that.&#10;&#10;4 \&lt; 5.&#10;&#10;6 \&gt; 5.&#10;&#10;Backslash: \\&#10;&#10;Backtick: \`&#10;&#10;Asterisk: \*&#10;&#10;Underscore: \_&#10;&#10;Left brace: {&#10;&#10;Right brace: }&#10;&#10;Left bracket: [&#10;&#10;Right bracket: ]&#10;&#10;Left paren: (&#10;&#10;Right paren: )&#10;&#10;Greater-than: \&gt;&#10;&#10;Hash: \#&#10;&#10;Period: .&#10;&#10;Bang: !&#10;&#10;Plus: +&#10;&#10;Minus: -&#10;&#10;------------------------------------------------------------------------">
5656</outline>
5757<outline text="Links">
5858 <outline text="Explicit" _note="Just a [URL](/url/).&#10;&#10;[URL and title](/url/ &quot;title&quot;).&#10;&#10;[URL and title](/url/ &quot;title preceded by two spaces&quot;).&#10;&#10;[URL and title](/url/ &quot;title preceded by a tab&quot;).&#10;&#10;[URL and title](/url/ &quot;title with &quot;quotes&quot; in it&quot;)&#10;&#10;[URL and title](/url/ &quot;title with single quotes&quot;)&#10;&#10;[with\_underscore](/url/with_underscore)&#10;&#10;[Email link](mailto:nobody@nowhere.net)&#10;&#10;[Empty]().&#10;">
@@ -61,10 +61,10 @@
6161 </outline>
6262 <outline text="With ampersands" _note="Here’s a [link with an ampersand in the&#10;URL](http://example.com/?foo=1&amp;bar=2).&#10;&#10;Here’s a link with an amersand in the link text:&#10;[AT&amp;T](http://att.com/ &quot;AT&amp;T&quot;).&#10;&#10;Here’s an [inline link](/script?foo=1&amp;bar=2).&#10;&#10;Here’s an [inline link in pointy braces](/script?foo=1&amp;bar=2).&#10;">
6363 </outline>
64− <outline text="Autolinks" _note="With an ampersand: &lt;http://example.com/?foo=1&amp;bar=2&gt;&#10;&#10;- In a list?&#10;- &lt;http://example.com/&gt;&#10;- It should.&#10;&#10;An e-mail address: &lt;nobody@nowhere.net&gt;&#10;&#10;&gt; Blockquoted: &lt;http://example.com/&gt;&#10;&#10;Auto-links should not occur here: `&lt;http://example.com/&gt;`&#10;&#10; or here: &lt;http://example.com/&gt;&#10;&#10;* * * * *">
64+ <outline text="Autolinks" _note="With an ampersand: &lt;http://example.com/?foo=1&amp;bar=2&gt;&#10;&#10;- In a list?&#10;- &lt;http://example.com/&gt;&#10;- It should.&#10;&#10;An e-mail address: &lt;nobody@nowhere.net&gt;&#10;&#10;&gt; Blockquoted: &lt;http://example.com/&gt;&#10;&#10;Auto-links should not occur here: `&lt;http://example.com/&gt;`&#10;&#10; or here: &lt;http://example.com/&gt;&#10;&#10;------------------------------------------------------------------------">
6565 </outline>
6666</outline>
67−<outline text="Images" _note="From “Voyage dans la Lune” by Georges Melies (1902):&#10;&#10;![lalune](lalune.jpg &quot;Voyage dans la Lune&quot;)&#10;&#10;Here is a movie ![movie](movie.jpg) icon.&#10;&#10;* * * * *">
67+<outline text="Images" _note="From “Voyage dans la Lune” by Georges Melies (1902):&#10;&#10;![lalune](lalune.jpg &quot;Voyage dans la Lune&quot;)&#10;&#10;Here is a movie ![movie](movie.jpg) icon.&#10;&#10;------------------------------------------------------------------------">
6868</outline>
6969<outline text="Footnotes" _note="Here is a footnote reference,[^1] and another.[^2] This should *not* be&#10;a footnote reference, because it contains a space.[\^my note] Here is an&#10;inline note.[^3]&#10;&#10;&gt; Notes can go in quotes.[^4]&#10;&#10;1. And in list items.[^5]&#10;&#10;This paragraph should not be part of the note, as it is not indented.&#10;&#10;[^1]: Here is the footnote. It can go anywhere after the footnote&#10; reference. It need not be placed at the end of the document.&#10;&#10;[^2]: Here’s the long note. This one contains multiple blocks.&#10;&#10; Subsequent blocks are indented to show that they belong to the&#10; footnote (as with list items).&#10;&#10; { &lt;code&gt; }&#10;&#10; If you want, you can indent every line, but you can also be lazy and&#10; just indent the first line of each block.&#10;&#10;[^3]: This is *easier* to type. Inline notes may contain&#10; [links](http://google.com) and `]` verbatim characters, as well as&#10; [bracketed text].&#10;&#10;[^4]: In quote.&#10;&#10;[^5]: In list.&#10;">
7070</outline>
tests/writer.plain+121−81
@@ -5,39 +5,43 @@ July 17, 2006
55This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
66markdown test suite.
77
8−* * * * *
8+------------------------------------------------------------------------------
9+
10+
911
1012Headers
11−=======
13+
1214
1315Level 2 with an embedded link
14−-----------------------------
1516
16−Level 3 with emphasis
17+Level 3 with _emphasis_
1718
1819Level 4
1920
2021Level 5
2122
23+
24+
2225Level 1
23−=======
2426
25−Level 2 with emphasis
26−---------------------
27+
28+Level 2 with _emphasis_
2729
2830Level 3
2931
3032with no blank line
3133
34+
3235Level 2
33−-------
3436
3537with no blank line
3638
37−* * * * *
39+------------------------------------------------------------------------------
40+
41+
3842
3943Paragraphs
40−==========
44+
4145
4246Here’s a regular paragraph.
4347
@@ -47,13 +51,15 @@ item.
4751
4852Here’s one with a bullet. * criminey.
4953
50−There should be a hard line break
54+There should be a hard line break
5155here.
5256
53−* * * * *
57+------------------------------------------------------------------------------
58+
59+
5460
5561Block Quotes
56−============
62+
5763
5864E-mail style:
5965
@@ -80,10 +86,12 @@ This should not be a block quote: 2 > 1.
8086
8187And a following paragraph.
8288
83−* * * * *
89+------------------------------------------------------------------------------
90+
91+
8492
8593Code Blocks
86−===========
94+
8795
8896Code:
8997
@@ -101,13 +109,14 @@ And:
101109
102110 These should not be escaped: \$ \\ \> \[ \{
103111
104−* * * * *
112+------------------------------------------------------------------------------
113+
114+
105115
106116Lists
107−=====
117+
108118
109119Unordered
110−---------
111120
112121Asterisks tight:
113122
@@ -151,8 +160,8 @@ Minuses loose:
151160
152161- Minus 3
153162
163+
154164Ordered
155−-------
156165
157166Tight:
158167
@@ -192,8 +201,8 @@ Multiple paragraphs:
192201
1932023. Item 3.
194203
204+
195205Nested
196−------
197206
198207- Tab
199208 - Tab
@@ -221,8 +230,8 @@ Same thing but with paragraphs:
221230
2222313. Third
223232
233+
224234Tabs and spaces
225−---------------
226235
227236- this is a list item indented with tabs
228237
@@ -232,8 +241,8 @@ Tabs and spaces
232241
233242 - this is an example list item indented with spaces
234243
244+
235245Fancy list markers
236−------------------
237246
238247(2) begins with 2
239248(3) and now 3
@@ -264,17 +273,21 @@ M.A. 2007
264273
265274B. Williams
266275
267−* * * * *
276+------------------------------------------------------------------------------
277+
278+
268279
269280Definition Lists
270−================
281+
271282
272283Tight using spaces:
273284
274285apple
275286 red fruit
287+
276288orange
277289 orange fruit
290+
278291banana
279292 yellow fruit
280293
@@ -282,30 +295,37 @@ Tight using tabs:
282295
283296apple
284297 red fruit
298+
285299orange
286300 orange fruit
301+
287302banana
288303 yellow fruit
289304
290305Loose:
291306
292307apple
308+
293309 red fruit
294310
295311orange
312+
296313 orange fruit
297314
298315banana
316+
299317 yellow fruit
300318
301319Multiple blocks with italics:
302320
303−apple
321+_apple_
322+
304323 red fruit
305324
306325 contains seeds, crisp, pleasant to taste
307326
308−orange
327+_orange_
328+
309329 orange fruit
310330
311331 { orange code block }
@@ -317,6 +337,7 @@ Multiple definitions, tight:
317337apple
318338 red fruit
319339 computer
340+
320341orange
321342 orange fruit
322343 bank
@@ -324,11 +345,13 @@ orange
324345Multiple definitions, loose:
325346
326347apple
348+
327349 red fruit
328350
329351 computer
330352
331353orange
354+
332355 orange fruit
333356
334357 bank
@@ -336,18 +359,22 @@ orange
336359Blank line after term, indented marker, alternate markers:
337360
338361apple
362+
339363 red fruit
340364
341365 computer
342366
343367orange
368+
344369 orange fruit
345370
346371 1. sublist
347372 2. sublist
348373
374+
375+
349376HTML Blocks
350−===========
377+
351378
352379Simple block on one line:
353380
@@ -361,8 +388,8 @@ bar
361388
362389Interpreted markdown in a table:
363390
364−This is emphasized
365−And this is strong
391+This is _emphasized_
392+And this is STRONG
366393Here’s a simple block:
367394
368395foo
@@ -397,40 +424,44 @@ Code:
397424
398425Hr’s:
399426
400−* * * * *
427+------------------------------------------------------------------------------
428+
429+
401430
402431Inline Markup
403−=============
404432
405−This is emphasized, and so is this.
406433
407−This is strong, and so is this.
434+This is _emphasized_, and so _is this_.
435+
436+This is STRONG, and so IS THIS.
408437
409−An emphasized link.
438+An _emphasized link_.
410439
411−This is strong and em.
440+_THIS IS STRONG AND EM._
412441
413−So is this word.
442+So is _THIS_ word.
414443
415−This is strong and em.
444+_THIS IS STRONG AND EM._
416445
417−So is this word.
446+So is _THIS_ word.
418447
419448This is code: >, $, \, \$, <html>.
420449
421−This is strikeout.
450+~~This is _strikeout_.~~
422451
423−Superscripts: abcd ahello ahello there.
452+Superscripts: a^bc^d a^_hello_^ a^hello there^.
424453
425−Subscripts: H2O, H23O, Hmany of themO.
454+Subscripts: H~2~O, H~23~O, H~many of them~O.
426455
427456These should not be superscripts or subscripts, because of the unescaped
428457spaces: a^b c^d, a~b c~d.
429458
430−* * * * *
459+------------------------------------------------------------------------------
460+
461+
431462
432463Smart quotes, ellipses, dashes
433−==============================
464+
434465
435466“Hello,” said the spider. “‘Shelob’ is my name.”
436467
@@ -448,35 +479,39 @@ Dashes between numbers: 5–7, 255–66, 1987–1999.
448479
449480Ellipses…and…and….
450481
451−* * * * *
482+------------------------------------------------------------------------------
483+
484+
452485
453486LaTeX
454−=====
455487
456−-
457−- 2+2=4
458−- x \in y
459−- \alpha \wedge \omega
488+
489+- \cite[22-23]{smith.1899}
490+- 2 + 2 = 4
491+- x ∈ y
492+- α ∧ ω
460493- 223
461494- p-Tree
462495- Here’s some display math:
463− \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
464−- Here’s one that has a line break in it: \alpha + \omega \times x^2.
496+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
497+- Here’s one that has a line break in it: α + ω × x^2^.
465498
466499These shouldn’t be math:
467500
468501- To get the famous equation, write $e = mc^2$.
469−- $22,000 is a lot of money. So is $34,000. (It worked if “lot” is
502+- $22,000 is a _lot_ of money. So is $34,000. (It worked if “lot” is
470503 emphasized.)
471504- Shoes ($20) and socks ($5).
472−- Escaped $: $73 this should be emphasized 23$.
505+- Escaped $: $73 _this should be emphasized_ 23$.
473506
474507Here’s a LaTeX table:
475508
476−* * * * *
509+------------------------------------------------------------------------------
510+
511+
477512
478513Special Characters
479−==================
514+
480515
481516Here is some unicode:
482517
@@ -528,13 +563,14 @@ Plus: +
528563
529564Minus: -
530565
531−* * * * *
566+------------------------------------------------------------------------------
567+
568+
532569
533570Links
534−=====
571+
535572
536573Explicit
537−--------
538574
539575Just a URL.
540576
@@ -554,8 +590,8 @@ Email link
554590
555591Empty.
556592
593+
557594Reference
558−---------
559595
560596Foo bar.
561597
@@ -581,8 +617,8 @@ Foo bar.
581617
582618Foo biz.
583619
620+
584621With ampersands
585−---------------
586622
587623Here’s a link with an ampersand in the URL.
588624
@@ -592,8 +628,8 @@ Here’s an inline link.
592628
593629Here’s an inline link in pointy braces.
594630
631+
595632Autolinks
596−---------
597633
598634With an ampersand: http://example.com/?foo=1&bar=2
599635
@@ -609,10 +645,12 @@ Auto-links should not occur here: <http://example.com/>
609645
610646 or here: <http://example.com/>
611647
612−* * * * *
648+------------------------------------------------------------------------------
649+
650+
613651
614652Images
615−======
653+
616654
617655From “Voyage dans la Lune” by Georges Melies (1902):
618656
@@ -620,37 +658,39 @@ From “Voyage dans la Lune” by Georges Melies (1902):
620658
621659Here is a movie [movie] icon.
622660
623−* * * * *
661+------------------------------------------------------------------------------
662+
663+
624664
625665Footnotes
626−=========
627666
628−Here is a footnote reference,[^1] and another.[^2] This should not be a
667+
668+Here is a footnote reference,[1] and another.[2] This should _not_ be a
629669footnote reference, because it contains a space.[^my note] Here is an inline
630−note.[^3]
670+note.[3]
631671
632− Notes can go in quotes.[^4]
672+ Notes can go in quotes.[4]
633673
634−1. And in list items.[^5]
674+1. And in list items.[5]
635675
636676This paragraph should not be part of the note, as it is not indented.
637677
638−[^1]: Here is the footnote. It can go anywhere after the footnote reference.
639− It need not be placed at the end of the document.
678+[1] Here is the footnote. It can go anywhere after the footnote reference. It
679+need not be placed at the end of the document.
640680
641−[^2]: Here’s the long note. This one contains multiple blocks.
681+[2] Here’s the long note. This one contains multiple blocks.
642682
643− Subsequent blocks are indented to show that they belong to the footnote
644− (as with list items).
683+Subsequent blocks are indented to show that they belong to the footnote (as
684+with list items).
645685
646− { <code> }
686+ { <code> }
647687
648− If you want, you can indent every line, but you can also be lazy and just
649− indent the first line of each block.
688+If you want, you can indent every line, but you can also be lazy and just
689+indent the first line of each block.
650690
651−[^3]: This is easier to type. Inline notes may contain links and ] verbatim
652− characters, as well as [bracketed text].
691+[3] This is _easier_ to type. Inline notes may contain links and ] verbatim
692+characters, as well as [bracketed text].
653693
654−[^4]: In quote.
694+[4] In quote.
655695
656−[^5]: In list.
696+[5] In list.