summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Benchmark.hs45
-rw-r--r--COPYRIGHT14
-rw-r--r--INSTALL21
-rw-r--r--MakeManPage.hs97
-rw-r--r--README1850
-rw-r--r--Setup.hs65
-rw-r--r--changelog412
-rw-r--r--default.csl369
-rw-r--r--man/man1/markdown2pdf.1165
-rw-r--r--man/man1/markdown2pdf.1.md55
-rw-r--r--man/man1/pandoc.1905
-rw-r--r--man/man1/pandoc.1.md394
-rw-r--r--man/man1/pandoc.1.template16
-rw-r--r--man/man5/pandoc_markdown.51692
-rw-r--r--man/man5/pandoc_markdown.5.template11
-rw-r--r--pandoc.cabal189
-rw-r--r--src/Tests/Arbitrary.hs181
-rw-r--r--src/Tests/Helpers.hs116
-rw-r--r--src/Tests/Old.hs201
-rw-r--r--src/Tests/Readers/LaTeX.hs161
-rw-r--r--src/Tests/Readers/Markdown.hs29
-rw-r--r--src/Tests/Readers/RST.hs46
-rw-r--r--src/Tests/Shared.hs21
-rw-r--r--src/Tests/Writers/ConTeXt.hs72
-rw-r--r--src/Tests/Writers/HTML.hs41
-rw-r--r--src/Tests/Writers/Native.hs20
-rw-r--r--src/Text/Pandoc.hs73
-rw-r--r--src/Text/Pandoc/Biblio.hs199
-rw-r--r--src/Text/Pandoc/Blocks.hs146
-rw-r--r--src/Text/Pandoc/CharacterReferences.hs277
-rw-r--r--src/Text/Pandoc/Definition.hs151
-rw-r--r--src/Text/Pandoc/Highlighting.hs12
-rw-r--r--src/Text/Pandoc/Parsing.hs235
-rw-r--r--src/Text/Pandoc/Pretty.hs429
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs1105
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs357
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs481
-rw-r--r--src/Text/Pandoc/Readers/Native.hs81
-rw-r--r--src/Text/Pandoc/Readers/RST.hs203
-rw-r--r--src/Text/Pandoc/Readers/TeXMath.hs47
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs523
-rw-r--r--src/Text/Pandoc/Shared.hs274
-rw-r--r--src/Text/Pandoc/Templates.hs4
-rw-r--r--src/Text/Pandoc/UTF8.hs50
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs159
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs72
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs9
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs108
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs349
-rw-r--r--src/Text/Pandoc/Writers/Man.hs58
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs382
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs24
-rw-r--r--src/Text/Pandoc/Writers/Native.hs86
-rw-r--r--src/Text/Pandoc/Writers/ODT.hs5
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs33
-rw-r--r--src/Text/Pandoc/Writers/Org.hs284
-rw-r--r--src/Text/Pandoc/Writers/RST.hs177
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs34
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs108
-rw-r--r--src/Text/Pandoc/Writers/Textile.hs422
-rw-r--r--src/Text/Pandoc/XML.hs19
-rw-r--r--src/markdown2pdf.hs2
-rw-r--r--src/pandoc.hs327
-rw-r--r--src/test-pandoc.hs32
-rw-r--r--templates/context.template4
-rw-r--r--templates/docbook.template4
-rw-r--r--templates/html.template29
-rw-r--r--templates/latex.template38
-rw-r--r--templates/mediawiki.template3
-rw-r--r--templates/org.template24
-rw-r--r--templates/rtf.template4
-rw-r--r--templates/s5.template2
-rw-r--r--templates/slidy.template2
-rw-r--r--templates/texinfo.template4
-rw-r--r--templates/textile.template9
-rw-r--r--tests/RunTests.hs181
-rw-r--r--tests/biblio.bib26
-rw-r--r--tests/chicago-author-date.csl369
-rw-r--r--tests/html-reader.html6
-rw-r--r--tests/html-reader.native683
-rw-r--r--tests/ieee.csl129
-rw-r--r--tests/latex-reader.latex4
-rw-r--r--tests/latex-reader.native741
-rw-r--r--tests/lhs-test.fragment.html+lhs21
-rw-r--r--tests/lhs-test.html51
-rw-r--r--tests/lhs-test.html+lhs51
-rw-r--r--tests/lhs-test.latex12
-rw-r--r--tests/lhs-test.latex+lhs12
-rw-r--r--tests/lhs-test.markdown18
-rw-r--r--tests/lhs-test.markdown+lhs10
-rw-r--r--tests/lhs-test.native18
-rw-r--r--tests/lhs-test.nohl.html39
-rw-r--r--tests/lhs-test.nohl.html+lhs39
-rw-r--r--tests/lhs-test.rst11
-rw-r--r--tests/lhs-test.rst+lhs11
-rw-r--r--tests/markdown-citations.chicago-author-date.txt43
-rw-r--r--tests/markdown-citations.ieee.txt43
-rw-r--r--tests/markdown-citations.mhra.txt61
-rw-r--r--tests/markdown-citations.txt37
-rw-r--r--tests/markdown-reader-more.native92
-rw-r--r--tests/markdown-reader-more.txt25
-rw-r--r--tests/mhra.csl390
-rw-r--r--tests/rst-reader.native617
-rw-r--r--tests/rst-reader.rst28
-rw-r--r--tests/s5.basic.html2
-rw-r--r--tests/s5.fancy.html2
-rw-r--r--tests/s5.fragment.html2
-rw-r--r--tests/s5.inserts.html2
-rw-r--r--tests/s5.native15
-rw-r--r--tests/tables-rstsubset.native235
-rw-r--r--tests/tables.docbook2
-rw-r--r--tests/tables.html2
-rw-r--r--tests/tables.latex174
-rw-r--r--tests/tables.markdown18
-rw-r--r--tests/tables.mediawiki1
-rw-r--r--tests/tables.native229
-rw-r--r--tests/tables.opendocument38
-rw-r--r--tests/tables.org52
-rw-r--r--tests/tables.plain18
-rw-r--r--tests/tables.rst1
-rw-r--r--tests/tables.rtf1
-rw-r--r--tests/tables.textile212
-rw-r--r--tests/testsuite.native813
-rw-r--r--tests/testsuite.txt11
-rw-r--r--tests/textile-reader.native148
-rw-r--r--tests/textile-reader.textile216
-rw-r--r--tests/writer.context179
-rw-r--r--tests/writer.docbook235
-rw-r--r--tests/writer.html44
-rw-r--r--tests/writer.latex129
-rw-r--r--tests/writer.man47
-rw-r--r--tests/writer.markdown119
-rw-r--r--tests/writer.mediawiki1
-rw-r--r--tests/writer.native813
-rw-r--r--tests/writer.opendocument405
-rw-r--r--tests/writer.org774
-rw-r--r--tests/writer.plain118
-rw-r--r--tests/writer.rst211
-rw-r--r--tests/writer.rtf5
-rw-r--r--tests/writer.texinfo16
-rw-r--r--tests/writer.textile716
141 files changed, 17135 insertions, 7287 deletions
diff --git a/Benchmark.hs b/Benchmark.hs
new file mode 100644
index 000000000..1fd787945
--- /dev/null
+++ b/Benchmark.hs
@@ -0,0 +1,45 @@
+import Text.Pandoc
+import Text.Pandoc.Shared (readDataFile, normalize)
+import Criterion.Main
+import Data.List (isSuffixOf)
+import Text.JSON.Generic
+
+readerBench :: Pandoc
+ -> (String, ParserState -> String -> Pandoc)
+ -> Benchmark
+readerBench doc (name, reader) =
+ let writer = case lookup name writers of
+ Just w -> w
+ Nothing -> error $ "Could not find writer for " ++ name
+ inp = writer defaultWriterOptions{ writerWrapText = True
+ , writerLiterateHaskell =
+ "+lhs" `isSuffixOf` name } doc
+ -- we compute the length to force full evaluation
+ getLength (Pandoc (Meta a b c) d) =
+ length a + length b + length c + length d
+ in bench (name ++ " reader") $ whnf (getLength .
+ reader defaultParserState{ stateSmart = True
+ , stateStandalone = True
+ , stateLiterateHaskell =
+ "+lhs" `isSuffixOf` name }) inp
+
+writerBench :: Pandoc
+ -> (String, WriterOptions -> Pandoc -> String)
+ -> Benchmark
+writerBench doc (name, writer) = bench (name ++ " writer") $ nf
+ (writer defaultWriterOptions{
+ writerWrapText = True
+ , writerLiterateHaskell = "+lhs" `isSuffixOf` name }) doc
+
+normalizeBench :: Pandoc -> [Benchmark]
+normalizeBench doc = [ bench "normalize - with" $ nf (encodeJSON . normalize) doc
+ , bench "normalize - without" $ nf encodeJSON doc
+ ]
+
+main = do
+ inp <- readDataFile (Just ".") "README"
+ let ps = defaultParserState{ stateSmart = True }
+ let doc = readMarkdown ps inp
+ let readerBs = map (readerBench doc) readers
+ defaultMain $ map (writerBench doc) writers ++ readerBs ++ normalizeBench doc
+
diff --git a/COPYRIGHT b/COPYRIGHT
index fecf1332d..050eb07c0 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -44,8 +44,20 @@ Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane
Released under the GPL.
----------------------------------------------------------------------
+src/Text/Pandoc/Writers/Org.hs
+Copyright (C) 2010 Puneeth Chaganti
+
+Released under the GPL.
+
+----------------------------------------------------------------------
+src/Text/Pandoc/Readers/Textile.hs
+Copyright (C) 2010 Paul Rivier
+
+Released under the GPL.
+
+----------------------------------------------------------------------
src/Text/Pandoc/Biblio.hs
-Copyright (C) 2008 Andrea Rossato
+Copyright (C) 2008-2010 Andrea Rossato
Released under the GPL.
diff --git a/INSTALL b/INSTALL
index f405e2c4a..ea47c94e6 100644
--- a/INSTALL
+++ b/INSTALL
@@ -73,8 +73,6 @@ you will need [zip-archive] and (if you want syntax highlighting)
- `wrappers`: build the wrapper `markdown2pdf` (default yes)
- `highlighting`: compile with syntax highlighting support (increases
the size of the executable) (default no)
- - `citeproc`: compile with bibliographic support using `citeproc-hs`
- (default no)
So, for example,
@@ -109,22 +107,3 @@ you will need [zip-archive] and (if you want syntax highlighting)
[highlighting-kate]: http://hackage.haskell.org/package/highlighting-kate
[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths
-Optional citeproc support
--------------------------
-
-Pandoc can optionally be compiled with support for bibliographic citations
-using Andrea Rossato's [`citeproc-hs` library]. This allows you
-to specify citations in markdown using an intuitive syntax (for example,
-`[jones2005@p. 3; smith2006]`). These are automatically changed into
-appropriately styled citations in the output, and a bibliography is
-added. The bibliography data and style information are taken from XML
-files that must be specified on the command line. (Note: `citeproc-hs`
-support is experimental, and the interface may change in the future.)
-
-If you are using Cabal to compile pandoc, specify the `citeproc` flag in
-the configure step:
-
- runhaskell Setup configure --flags="citeproc"
-
-[`citeproc-hs` library]: http://code.haskell.org/citeproc-hs/
-
diff --git a/MakeManPage.hs b/MakeManPage.hs
new file mode 100644
index 000000000..47b284380
--- /dev/null
+++ b/MakeManPage.hs
@@ -0,0 +1,97 @@
+-- Create pandoc.1 man page from README
+import Text.Pandoc
+import Data.ByteString.UTF8 (toString, fromString)
+import Data.Char (toUpper)
+import qualified Data.ByteString as B
+import Control.Monad
+import System.FilePath
+import System.Environment (getArgs)
+import Text.Pandoc.Shared (normalize)
+import System.Directory (getModificationTime)
+import System.IO.Error (isDoesNotExistError)
+import System.Time (ClockTime(..))
+import Data.Maybe (catMaybes)
+
+main = do
+ rmContents <- liftM toString $ B.readFile "README"
+ let (Pandoc meta blocks) = readMarkdown defaultParserState rmContents
+ let manBlocks = removeSect [Str "Wrappers"]
+ $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks
+ let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks
+ args <- getArgs
+ let verbose = "--verbose" `elem` args
+ makeManPage verbose ("man" </> "man1" </> "pandoc.1")
+ meta manBlocks
+ makeManPage verbose ("man" </> "man5" </> "pandoc_markdown.5")
+ meta syntaxBlocks
+ let markdown2pdfpage = "man" </> "man1" </> "markdown2pdf.1"
+ modDeps <- modifiedDependencies markdown2pdfpage [markdown2pdfpage <.> "md"]
+ unless (null modDeps) $ do
+ mpdfContents <- liftM toString $ B.readFile $ markdown2pdfpage <.> "md"
+ templ <- liftM toString $ B.readFile $ "templates" </> "man.template"
+ let doc = readMarkdown defaultParserState{ stateStandalone = True }
+ mpdfContents
+ writeManPage markdown2pdfpage templ doc
+ when verbose $
+ putStrLn $ "Created " ++ markdown2pdfpage
+
+makeManPage :: Bool -> FilePath -> Meta -> [Block] -> IO ()
+makeManPage verbose page meta blocks = do
+ let templ = page <.> "template"
+ modDeps <- modifiedDependencies page ["README", templ]
+ unless (null modDeps) $ do
+ manTemplate <- liftM toString $ B.readFile templ
+ writeManPage page manTemplate (Pandoc meta blocks)
+ when verbose $
+ putStrLn $ "Created " ++ page
+
+writeManPage :: FilePath -> String -> Pandoc -> IO ()
+writeManPage page templ doc = do
+ let opts = defaultWriterOptions{ writerStandalone = True
+ , writerTemplate = templ }
+ let manPage = writeMan opts $
+ bottomUp (concatMap removeLinks) $
+ bottomUp capitalizeHeaders doc
+ B.writeFile page $ fromString manPage
+
+-- | Returns a list of 'dependencies' that have been modified after 'file'.
+modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath]
+modifiedDependencies file dependencies = do
+ fileModTime <- catch (getModificationTime file) $
+ \e -> if isDoesNotExistError e
+ then return (TOD 0 0) -- the minimum ClockTime
+ else ioError e
+ depModTimes <- mapM getModificationTime dependencies
+ let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes
+ return $ catMaybes modified
+
+removeLinks :: Inline -> [Inline]
+removeLinks (Link l _) = l
+removeLinks x = [x]
+
+capitalizeHeaders :: Block -> Block
+capitalizeHeaders (Header 1 xs) = Header 1 $ bottomUp capitalize xs
+capitalizeHeaders x = x
+
+capitalize :: Inline -> Inline
+capitalize (Str xs) = Str $ map toUpper xs
+capitalize x = x
+
+removeSect :: [Inline] -> [Block] -> [Block]
+removeSect ils (Header 1 x:xs) | normalize x == normalize ils =
+ dropWhile (not . isHeader1) xs
+removeSect ils (x:xs) = x : removeSect ils xs
+removeSect _ [] = []
+
+extractSect :: [Inline] -> [Block] -> [Block]
+extractSect ils (Header 1 z:xs) | normalize z == normalize ils =
+ bottomUp promoteHeader $ takeWhile (not . isHeader1) xs
+ where promoteHeader (Header n x) = Header (n-1) x
+ promoteHeader x = x
+extractSect ils (x:xs) = extractSect ils xs
+extractSect _ [] = []
+
+isHeader1 :: Block -> Bool
+isHeader1 (Header 1 _) = True
+isHeader1 _ = False
+
diff --git a/README b/README
index 47f9456ea..deb3a7b2f 100644
--- a/README
+++ b/README
@@ -1,21 +1,30 @@
% Pandoc User's Guide
% John MacFarlane
-% March 20, 2010
+% January 29, 2011
+
+Synopsis
+========
+
+pandoc [*options*] [*input-file*]...
+
+Description
+===========
Pandoc is a [Haskell] library for converting from one markup format to
another, and a command-line tool that uses this library. It can read
-[markdown] and (subsets of) [reStructuredText], [HTML], and [LaTeX]; and
-it can write plain text, [markdown], [reStructuredText], [HTML], [LaTeX],
-[ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT], [GNU Texinfo],
-[MediaWiki markup], [EPUB], [groff man] pages, and [Slidy] or [S5]
-HTML slide shows.
+[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
+and [LaTeX]; and it can write plain text, [markdown], [reStructuredText],
+[HTML], [LaTeX], [ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT],
+[GNU Texinfo], [MediaWiki markup], [EPUB], [Textile], [groff man] pages,
+[Emacs Org-Mode], and [Slidy] or [S5] HTML slide shows.
Pandoc's enhanced version of markdown includes syntax for footnotes,
tables, flexible ordered lists, definition lists, delimited code blocks,
superscript, subscript, strikeout, title blocks, automatic tables of
-contents, embedded LaTeX math, and markdown inside HTML block elements.
-(These enhancements can be disabled if a drop-in replacement for
-`Markdown.pl` is desired.)
+contents, embedded LaTeX math, citations, and markdown inside HTML block
+elements. (These enhancements, described below under
+[Pandoc's markdown](#pandocs-markdown), can be disabled using the `--strict`
+option.)
In contrast to most existing tools for converting markdown to HTML, which
use regex substitutions, Pandoc has a modular design: it consists of a
@@ -24,60 +33,25 @@ representation of the document, and a set of writers, which convert
this native representation into a target format. Thus, adding an input
or output format requires only adding a reader or writer.
-[markdown]: http://daringfireball.net/projects/markdown/
-[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
-[S5]: http://meyerweb.com/eric/tools/s5/
-[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
-[HTML]: http://www.w3.org/TR/html40/
-[LaTeX]: http://www.latex-project.org/
-[ConTeXt]: http://www.pragma-ade.nl/
-[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
-[DocBook XML]: http://www.docbook.org/
-[OpenDocument XML]: http://opendocument.xml.org/
-[ODT]: http://en.wikipedia.org/wiki/OpenDocument
-[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
-[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
-[Haskell]: http://www.haskell.org/
-[GNU Texinfo]: http://www.gnu.org/software/texinfo/
-[EPUB]: http://www.idpf.org/
-
-© 2006-2010 John MacFarlane (jgm at berkeley dot edu). Released under the
-[GPL], version 2 or greater. This software carries no warranty of
-any kind. (See COPYRIGHT for full copyright and warranty notices.)
-Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
-Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
-rodja.trappe, Bradley Kuhn, thsutton, Justin Bogner.
-
-[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
-
Using Pandoc
-============
-
-If you run `pandoc` without arguments, it will accept input from
-stdin. If you run it with file names as arguments, it will take input
-from those files. By default, `pandoc` writes its output to stdout.[^1]
-If you want to write to a file, use the `-o` option:
-
- pandoc -o hello.html hello.txt
-
-[^1]: The exceptions are for `odt` and `epub`. Since these are
- a binary output formats, an output file must be specified explicitly.
-
-Note that you can specify multiple input files on the command line.
-`pandoc` will concatenate them all (with blank lines between them)
-before parsing:
+------------
- pandoc -s ch1.txt ch2.txt refs.txt > book.html
+If no *input-file* is specified, input is read from *stdin*.
+Otherwise, the *input-files* are concatenated (with a blank
+line between each) and used as input. Output goes to *stdout* by
+default (though output to *stdout* is disabled for the `odt` and
+`epub` output formats). For output to a file, use the `-o` option:
-(The `-s` option here tells `pandoc` to produce a standalone HTML file,
-with a proper header, rather than a fragment. For more details on this
-and many other command-line options, see below.)
+ pandoc -o output.html input.txt
-Instead of a filename, you can specify an absolute URI. In this
-case pandoc will attempt to download the content via HTTP:
+Instead of a file, an absolute URI may be given. In this case
+pandoc will fetch the content using HTTP:
pandoc -f html -t markdown http://www.fsf.org
+If multiple input files are given, `pandoc` will concatenate them all (with
+blank lines between them) before parsing.
+
The format of the input and output can be specified explicitly using
command-line options. The input format can be specified using the
`-r/--read` or `-f/--from` options, the output format using the
@@ -90,46 +64,29 @@ To convert `hello.html` from html to markdown:
pandoc -f html -t markdown hello.html
-Supported output formats include `markdown`, `latex`, `context`
-(ConTeXt), `html`, `rtf` (rich text format), `rst`
-(reStructuredText), `docbook` (DocBook XML), `opendocument`
-(OpenDocument XML), `odt` (OpenOffice text document), `texinfo`, (GNU
-Texinfo), `mediawiki` (MediaWiki markup), `epub` (EPUB ebook),
-`man` (groff man), `slidy` (slidy HTML and javascript slide show), or
-`s5` (S5 HTML and javascript slide show).
-
-Supported input formats include `markdown`, `html`, `latex`, and `rst`.
-Note that the `rst` reader only parses a subset of reStructuredText
-syntax. For example, it doesn't handle tables, option lists, or
-footnotes. But for simple documents it should be adequate. The `latex`
-and `html` readers are also limited in what they can do.
-
-If you don't specify a reader or writer explicitly, `pandoc` will
-try to determine the input and output format from the extensions of
+Supported output formats are listed below under the `-t/--to` option.
+Supported input formats are listed below under the `-f/--from` option. Note
+that the `rst`, `textile`, `latex`, and `html` readers are not complete;
+there are some constructs that they do not parse.
+
+If the input or output format is not specified explicitly, `pandoc`
+will attempt to guess it from the extensions of
the input and output filenames. Thus, for example,
pandoc -o hello.tex hello.txt
will convert `hello.txt` from markdown to LaTeX. If no output file
-is specified (so that output goes to stdout), or if the output file's
+is specified (so that output goes to *stdout*), or if the output file's
extension is unknown, the output format will default to HTML.
-If no input file is specified (so that input comes from stdin), or
+If no input file is specified (so that input comes from *stdin*), or
if the input files' extensions are unknown, the input format will
be assumed to be markdown unless explicitly specified.
-Character encodings
--------------------
-
-All input is assumed to be in the UTF-8 encoding, and all output
-is in UTF-8. If your local character encoding is not UTF-8 and you use
-accented or foreign characters, you should pipe the input and output
-through [`iconv`]. For example,
+Pandoc uses the UTF-8 character encoding for both input and output.
+If your local character encoding is not UTF-8, you
+should pipe input and output through `iconv`:
- iconv -t utf-8 source.txt | pandoc | iconv -f utf-8 > output.html
-
-will convert `source.txt` from the local encoding to UTF-8, then
-convert it to HTML, then convert back to the local encoding,
-putting the output in `output.html`.
+ iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
Wrappers
========
@@ -151,7 +108,7 @@ name can be specified explicitly using the `-o` option:
markdown2pdf -o book.pdf chap1 chap2
-If no input file is specified, input will be taken from stdin.
+If no input file is specified, input will be taken from *stdin*.
All of `pandoc`'s options will work with `markdown2pdf` as well.
`markdown2pdf` assumes that `pdflatex` is in the path. It also
@@ -179,140 +136,246 @@ problems with its simulation of symbolic links.
[TeX Live]: http://www.tug.org/texlive/
[MacTeX]: http://www.tug.org/mactex/
-Command-line options
-====================
+Options
+=======
+
+`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*
+: Specify input format. *FORMAT* can be `native` (native Haskell),
+ `json` (JSON version of native AST), `markdown` (markdown),
+ `textile` (Textile), `rst` (reStructuredText), `html` (HTML),
+ or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,
+ or `latex`, the input will be treated as literate Haskell source:
+ see [Literate Haskell support](#literate-haskell-support),
+ below.
+
+`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
+: Specify output format. *FORMAT* can be `native` (native Haskell),
+ `json` (JSON version of native AST), `plain` (plain text),
+ `markdown` (markdown), `rst` (reStructuredText),
+ `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man),
+ `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs
+ Org-Mode), `texinfo` (GNU Texinfo), `docbook` (DocBook XML),
+ `opendocument` (OpenDocument XML), `odt` (OpenOffice text document),
+ `epub` (EPUB book), `slidy` (Slidy HTML and javascript slide show),
+ `s5` (S5 HTML and javascript slide show), or `rtf` (rich text
+ format). Note that `odt` and `epub` output will not be directed to
+ *stdout*; an output filename must be specified using the `-o/--output`
+ option. If `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`,
+ the output will be rendered as literate Haskell source:
+ see [Literate Haskell support](#literate-haskell-support),
+ below.
+
+`-s`, `--standalone`
+: Produce output with an appropriate header and footer (e.g. a
+ standalone HTML, LaTeX, or RTF file, not a fragment).
+
+`-o` *FILE*, `--output=`*FILE*
+: Write output to *FILE* instead of *stdout*. If *FILE* is
+ `-`, output will go to *stdout*. (Exception: if the output
+ format is `odt` or `epub`, output to stdout is disabled.)
+
+`-p`, `--preserve-tabs`
+: Preserve tabs instead of converting them to spaces (the default).
+
+`--tab-stop=`*NUMBER*
+: Specify the number of spaces per tab (default is 4).
-Various command-line options can be used to customize the output.
-For further documentation, see the `pandoc(1)` man page.
+`--strict`
+: Use strict markdown syntax, with no pandoc extensions or variants.
+ When the input format is HTML, this means that constructs that have no
+ equivalents in standard markdown (e.g. definition lists or strikeout
+ text) will be parsed as raw HTML.
-`-f`, `--from`, `-r`, or `--read` *format*
-: specifies the input format (the format Pandoc will be converting
- *from*). *format* can be `native`, `markdown`, `rst`, `html`, or
- `latex`. (`+lhs` can be appended to indicate that the input should
- be treated as literate Haskell source. See
- [Literate Haskell support](#literate-haskell-support), below.)
+`--normalize`
+: Normalize the document after reading: merge adjacent
+ `Str` or `Emph` elements, for example, and remove repeated `Space`s.
-`-t`, `--to`, `-w`, or `--write` *format*
-: specifies the output format -- the format Pandoc will
- be converting *to*. *format* can be `native`, `html`, `slidy`, `s5`,
- `docbook`, `opendocument`, `latex`, `context`, `markdown`, `man`,
- `plain`, `rst`, and `rtf`. (`+lhs` can be appended to indicate that
- the output should be treated as literate Haskell source. See
- [Literate Haskell support](#literate-haskell-support), below.)
+`--reference-links`
+: Use reference-style links, rather than inline links, in writing markdown
+ or reStructuredText. By default inline links are used.
+
+`-R`, `--parse-raw`
+: Parse untranslatable HTML codes and LaTeX environments as raw HTML
+ or LaTeX, instead of ignoring them. Affects only HTML and LaTeX
+ input. Raw HTML can be printed in markdown, reStructuredText, HTML, Slidy,
+ and S5 output; raw LaTeX can be printed in markdown, reStructuredText,
+ LaTeX, and ConTeXt output. The default is for the readers to omit
+ untranslatable HTML codes and LaTeX environments. (The LaTeX reader
+ does pass through untranslatable LaTeX *commands*, even if `-R` is not
+ specified.)
+
+`-S`, `--smart`
+: Produce typographically correct output, converting straight quotes
+ to curly quotes, `---` and `--` to dashes, ande `...` to ellipses.
+ Nonbreaking spaces are inserted after certain abbreviations, such
+ as "Mr." (Note: This option is significant only when the input format is
+ `markdown` or `textile`. It is selected automatically when the input
+ format is `textile` or the output format is `latex` or `context`.)
+
+`-5`, `--html5`
+: Produce HTML5 instead of HTML4. This option has no effect for writers
+ other than `html`.
+
+`-m` *URL*, `--latexmathml=`*URL*
+: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
+ To insert a link to a local copy of the `LaTeXMathML.js` script,
+ provide a *URL*. If no *URL* is provided, the contents of the
+ script will be inserted directly into the HTML header, preserving
+ portability at the price of efficiency. If you plan to use math on
+ several pages, it is much better to link to a copy of the script,
+ so it can be cached.
-`-s` or `--standalone`
-: indicates that a standalone document is to be produced (with
- appropriate headers and footers), rather than a fragment.
+`--mathml`
+: Convert TeX math to MathML. In standalone mode, a small javascript
+ will be inserted that allows the MathML to be viewed on some browsers.
-`-o` or `--output` *filename*
-: sends output to *filename*. If this option is not specified,
- or if its argument is `-`, output will be sent to stdout.
- (Exception: if the output format is `odt` or `epub`, output to
- stdout is disabled.)
+`--jsmath=`*URL*
+: Use [jsMath] to display embedded TeX math in HTML output.
+ The *URL* should point to the jsMath load script (e.g.
+ `jsMath/easy/load.js`); if provided, it will be linked to in
+ the header of standalone HTML documents.
-`-p` or `--preserve-tabs`
-: causes tabs in the source text to be preserved, rather than converted
- to spaces (the default).
+`--mathjax=`*URL*
+: Use [MathJax] to display embedded TeX math in HTML output.
+ The *URL* should point to the `MathJax.js` load script.
-`--tab-stop` *tabstop*
-: sets the number of spaces per tab to *tabstop* (defaults to 4).
+`--gladtex`
+: Enclose TeX math in `<eq>` tags in HTML output. These can then
+ be processed by [gladTeX] to produce links to images of the typeset
+ formulas.
-`--strict`
-: specifies that strict markdown syntax is to be used, without
- pandoc's usual extensions and variants (described below). When the
- input format is HTML, this means that constructs that have no
- equivalents in standard markdown (e.g. definition lists or strikeout
- text) will be parsed as raw HTML.
+`--mimetex=`*URL*
+: Render TeX math using the [mimeTeX] CGI script. If *URL* is not
+ specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
-`--reference-links`
-: causes reference-style links to be used in markdown
- and reStructuredText output. By default inline links are used.
-
-`-R` or `--parse-raw`
-: causes the HTML and LaTeX readers to parse HTML codes and LaTeX
- environments that it can't translate as raw HTML or LaTeX. Raw HTML can
- be printed in markdown, reStructuredText, HTML, Slidy, and S5
- output; raw LaTeX can be printed in markdown, reStructuredText,
- LaTeX, and ConTeXt output. The default is for the readers to omit
- untranslatable HTML codes and LaTeX environments. (The LaTeX reader
- does pass through untranslatable LaTeX *commands*, even if `-R` is
- not specified.)
+`--webtex=`*URL*
+: Render TeX formulas using an external script that converts TeX
+ formulas to images. The formula will be concatenated with the URL
+ provided. If *URL* is not specified, the Google Chart API will be used.
+
+`-i`, `--incremental`
+: Make list items in Slidy or S5 display incrementally (one by one).
+ The default is for lists to be displayed all at once.
+
+`--offline`
+: Include all the CSS and javascript needed for a Slidy or S5 slide
+ show in the output, so that the slide show will work even when no
+ internet connection is available.
+
+`--xetex`
+: Create LaTeX outut suitable for processing by XeTeX.
+
+`--chapters`
+: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
+ output.
+
+`-N`, `--number-sections`
+: Number section headings in LaTeX, ConTeXt, or HTML output.
+ By default, sections are not numbered.
+
+`--listings`
+: Use listings package for LaTeX code blocks
+
+`--section-divs`
+: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
+ and attach identifiers to the enclosing `<div>` (or `<section>`)
+ rather than the header itself.
+ See [Section identifiers](#header-identifiers-in-html), below.
+
+`--no-wrap`
+: Disable text wrapping in output. By default, text is wrapped
+ appropriately for the output format.
+
+`--columns`=*NUMBER*
+: Specify length of lines in characters (for text wrapping).
+
+`--email-obfuscation=`*none|javascript|references*
+: Specify a method for obfuscating `mailto:` links in HTML documents.
+ *none* leaves `mailto:` links as they are. *javascript* obfuscates
+ them using javascript. *references* obfuscates them by printing their
+ letters as decimal or hexadecimal character references.
+ If `--strict` is specified, *references* is used regardless of the
+ presence of this option.
+
+`--id-prefix`=*STRING*
+: Specify a prefix to be added to all automatically generated identifiers
+ in HTML output. This is useful for preventing duplicate identifiers
+ when generating fragments to be included in other pages.
-`-C` or `--custom-header` *filename*
-: can be used to specify a custom document header. Implies `--standalone`.
- *Note: this option is deprecated. Use of `--template` is preferred.*
+`--indented-code-classes=`*CLASSES*
+: Specify classes to use for indented code blocks--for example,
+ `perl,numberLines` or `haskell`. Multiple classes may be separated
+ by spaces or commas.
-`--toc` or `--table-of-contents`
-: includes an automatically generated table of contents (or, in the
- case of `latex`, `context`, and `rst`, an instruction to create
- one) in the output document. This option has no effect with `man`,
- `docbook`, `slidy`, or `s5` output formats.
+`--toc`, `--table-of-contents`
+: Include an automatically generated table of contents (or, in
+ the case of `latex`, `context`, and `rst`, an instruction to create
+ one) in the output document. This option has no effect on `man`,
+ `docbook`, `slidy`, or `s5` output.
-`--base-header-level` *level*
-: specifies the base level for headers (defaults to 1).
+`--base-header-level=`*NUMBER*
+: Specify the base level for headers (defaults to 1).
-`--template=`*file*
-: uses *file* as a custom template for the generated document. Implies
- `-s`. See [Templates](#templates) below for a description
+`--template=`*FILE*
+: Use *FILE* as a custom template for the generated document. Implies
+ `--standalone`. See [Templates](#templates) below for a description
of template syntax. If this option is not used, a default
template appropriate for the output format will be used. See also
`-D/--print-default-template`.
-`-V` *key=val*, `--variable=`*key:val*
-: sets the template variable *key* to the value *val* when rendering the
+`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
+: Set the template variable *KEY* to the value *VAL* when rendering the
document in standalone mode. This is only useful when the
`--template` option is used to specify a custom template, since
pandoc automatically sets the variables used in the default
templates.
-`-c` or `--css` *filename*
-: allows the user to specify a custom stylesheet that will be linked to
- in HTML, Slidy, and S5 output. This option can be used repeatedly
- to include multiple stylesheets. They will be included in the order
- specified. Implies `--standalone`.
+`-c` *URL*, `--css=`*URL*
+: Link to a CSS style sheet.
-`-H` or `--include-in-header` *filename*
-: includes the contents of *filename* (verbatim) at the end of the
- document header. This can be used, for example, to include special
+`-H` *FILE*, `--include-in-header=`*FILE*
+: Include contents of *FILE*, verbatim, at the end of the header.
+ This can be used, for example, to include special
CSS or javascript in HTML documents. This option can be used
repeatedly to include multiple files in the header. They will be
included in the order specified. Implies `--standalone`.
-`-B` or `--include-before-body` *filename*
-: includes the contents of *filename* (verbatim) at the beginning of
- the document body (e.g. after the `<body>` tag in HTML, or the
+`-B` *FILE*, `--include-before-body=`*FILE*
+: Include contents of *FILE*, verbatim, at the beginning of the
+ document body (e.g. after the `<body>` tag in HTML, or the
`\begin{document}` command in LaTeX). This can be used to include
navigation bars or banners in HTML documents. This option can be
used repeatedly to include multiple files. They will be included in
the order specified. Implies `--standalone`.
-`-A` or `--include-after-body` *filename*
-: includes the contents of *filename* (verbatim) at the end of
- the document body (before the `</body>` tag in HTML, or the
+`-A` *FILE*, `--include-after-body=`*FILE*
+: Include contents of *FILE*, verbatim, at the end of the document
+ body (before the `</body>` tag in HTML, or the
`\end{document}` command in LaTeX). This option can be be used
repeatedly to include multiple files. They will be included in the
order specified. Implies `--standalone`.
-`--reference-odt` *filename*
-: uses the specified file as a style reference in producing an ODT.
+`--reference-odt=`*FILE*
+: Use the specified file as a style reference in producing an ODT.
For best results, the reference ODT should be a modified version
of an ODT produced using pandoc. The contents of the reference ODT
are ignored, but its stylesheets are used in the new ODT. If no
reference ODT is specified on the command line, pandoc will look
for a file `reference.odt` in the user data directory (see
- `--data-dir`, below). If it is not found there, sensible defaults
- will be used.
+ `--data-dir`). If this is not found either, sensible defaults will be
+ used.
-`--epub-stylesheet` *filename*
-: uses the specified CSS file to style the EPUB. If no stylesheet
+`--epub-stylesheet=`*FILE*
+: Use the specified CSS file to style the EPUB. If no stylesheet
is specified, pandoc will look for a file `epub.css` in the
user data directory (see `--data-dir`, below). If it is not
found there, sensible defaults will be used.
-`--epub-metadata` *filename*
-: looks in the specified XML file for metadata for the EPUB.
- The file should contain a series of [Dublin Core elements],
- for example:
+`--epub-metadata=`*FILE*
+: Look in the specified XML file for metadata for the EPUB.
+ The file should contain a series of Dublin Core elements,
+ as documented at <http://dublincore.org/documents/dces/>.
+ For example:
<dc:rights>Creative Commons</dc:rights>
<dc:language>es-AR</dc:language>
@@ -323,123 +386,45 @@ For further documentation, see the `pandoc(1)` man page.
`<dc:identifier id="BookId">` (a randomly generated UUID). Any of
these may be overridden by elements in the metadata file.
-`-D` or `--print-default-template` *format*
-: prints the default template for an output *format*. (See `-t`
- for a list of possible *format*s.)
-
-`-T` or `--title-prefix` *string*
-: includes *string* as a prefix at the beginning of the title that
- appears in the HTML header (but not in the title as it appears at
- the beginning of the HTML body). (See below on
- [Title Blocks](#title-blocks).) Implies `--standalone`.
-
-`-S` or `--smart`
-: causes `pandoc` to produce typographically correct output, along the
- lines of John Gruber's [Smartypants]. Straight quotes are converted
- to curly quotes, `---` to dashes, and `...` to ellipses. Nonbreaking
- spaces are inserted after certain abbreviations, such as "Mr."
- (Note: This option is only significant when the input format is
- `markdown`. It is selected automatically when the output format is
- `latex` or `context`.)
-
-`-m`*[url]* or `--latexmathml`*[=url]*
-: causes `pandoc` to use the [LaTeXMathML] script to display
- TeX math in HTML, Slidy, or S5. If a local copy of `LaTeXMathML.js`
- is available on the webserver where the page will be viewed, provide
- a *url* and a link will be inserted in the generated HTML. If
- no *url* is provided, the contents of the script will be inserted
- directly; this provides portability at the price of efficiency. If
- you plan to use math on several pages, it is much better to link to
- a copy of `LaTeXMathML.js`, which can be cached. (See `--jsmath`,
- `--gladtex`, `--webtex`, and `--mimetex` for alternative ways of
- dealing with math in HTML.)
-
-`--mathml`
-: causes `pandoc` to convert all TeX math to MathML.
- In standalone mode, a small javascript will be inserted that allows
- the MathML to be viewed on some browsers.
-
-`--jsmath`*=[url]*
-: causes `pandoc` to use the [jsMath] script to display
- TeX math in HTML, Slidy, or S5. The *url* should point to the jsMath
- load script (e.g. `jsMath/easy/load.js`). If it is provided, a link
- to it will be included in the header of standalone HTML documents.
- (See `--latexmathml`, `--mimetex`, `--webtex`, and `--gladtex` for
- alternative ways of dealing with math in HTML.)
-
-`--gladtex`*[=url]*
-: causes TeX formulas to be enclosed in `<eq>` tags in HTML, Slidy, or
- S5 output. This output can then be processed by [gladTeX] to produce
- links to images with the typeset formulas. (See `--latexmathml`,
- `--jsmath`, `--webtex`, and `--mimetex` for alternative ways of
- dealing with math in HTML.)
-
-`--mimetex`*[=url]*
-: causes TeX formulas to be replaced by `<img>` tags linking to the
- [mimeTeX] CGI script, which will produce images with the typeset
- formulas. (See `--latexmathml`, `--jsmath`, `--webtex`, and
- `--gladtex` for alternative ways of dealing with math in HTML.)
-
-`--webtex`*[=url]*
-: causes TeX formulas to be replaced by `<img>` tags linking to an
- external service that converts TeX formulas to images. The formula
- will be concatenated with the URL provided. If no URL
- is specified, the Google Chart API is used. (See `--latexmathml`,
- `--jsmath`, `--mimetex`, and `--gladtex` for alternative ways of
- dealing with math in HTML.)
-
-`-i` or `--incremental`
-: causes all lists in Slidy or S5 output to be displayed incrementally by
- default (one item at a time). The normal default is for lists to be
- displayed all at once.
-
-`--offline`
-: causes all the CSS and javascript needed for a Slidy or S5 slide show
- to be included in the output, so that the slide show will work even
- when no internet connection is available.
-
-`--xetex`
-: creates LaTeX outut suitable for processing by XeTeX.
+`-D` *FORMAT*, `--print-default-template=`*FORMAT*
+: Print the default template for an output *FORMAT*. (See `-t`
+ for a list of possible *FORMAT*s.)
+
+`-T` *STRING*, `--title-prefix=`*STRING*
+: Specify *STRING* as a prefix at the beginning of the title
+ that appears in the HTML header (but not in the title as it
+ appears at the beginning of the HTML body). Implies
+ `--standalone`.
+
+`--bibliography=`*FILE*
+: Specify bibliography database to be used in resolving
+ citations. The database type will be determined from the
+ extension of *FILE*, which may be `.mods` (MODS format),
+ `.bib` (BibTeX format), `.bbx` (BibLaTeX format),
+ `.ris` (RIS format), `.enl` (EndNote format),
+ `.xml` (EndNote XML format), `.wos` (ISI format),
+ `.medline` (MEDLINE format), `.copac` (Copac format),
+ or `.json` (citeproc JSON). If you want to use multiple
+ bibliographies, just use this option repeatedly.
+
+`--csl=`*FILE*
+: Specify [CSL] style to be used in formatting citations and
+ the bibliography. If *FILE* is not found, pandoc will look
+ for it in
+
+ $HOME/.csl
-`-N` or `--number-sections`
-: causes sections to be numbered in LaTeX, ConTeXt, or HTML output.
- By default, sections are not numbered.
-
-`--section-divs`
-: causes sections to be wrapped in `<div>` tags. In this case,
- [section identifiers](#header-identifiers-in-html)
- are attached to the enclosing `<div>` rather than the header itself.
-
-`--no-wrap`
-: disables text-wrapping in output. By default, text is wrapped
- appropriately for the output format.
+ in unix and
-`--sanitize-html`
-: sanitizes HTML (in markdown or HTML input) using a whitelist.
- Unsafe tags are replaced by HTML comments; unsafe attributes
- are omitted. URIs in links and images are also checked against a
- whitelist of URI schemes.
+ C:\Documents And Settings\USERNAME\Application Data\csl
-`--email-obfuscation`*=none|javascript|references*
-: specifies a method for obfuscating `mailto:` links in HTML documents.
- *none* leaves `mailto:` links as they are. *javascript* obfuscates
- them using javascript. *references* obfuscates them by printing their
- letters as decimal or hexadecimal character references. If `--strict`
- is specified, *references* is used regardless of the presence
- of this option.
+ in Windows. If the `--csl` option is not specified, pandoc
+ will use a default style: either `default.csl` in the
+ user data directory (see `--data-dir`), or, if that is
+ not present, the Chicago author-date style.
-`--id-prefix`*=string*
-: specifies a prefix to be added to all automatically generated identifiers
- in HTML output. This is useful for preventing duplicate identifiers
- when generating fragments to be included in other pages.
-
-`--indented-code-classes`*=classes*
-: specifies classes to use for indented code blocks--for example,
- `perl,numberLines` or `haskell`. Multiple classes may be separated
- by spaces or commas.
-
-`--data-dir`*=directory*
-: specifies the user data directory to search for pandoc data files.
+`--data-dir=`*DIRECTORY*
+: Specify the user data directory to search for pandoc data files.
If this option is not specified, the default user data directory
will be used:
@@ -454,24 +439,17 @@ For further documentation, see the `pandoc(1)` man page.
normal defaults.
`--dump-args`
-: is intended to make it easier to create wrapper scripts that use
- Pandoc. It causes Pandoc to dump information about the arguments
- with which it was called to stdout, then exit. The first line
- printed is the name of the output file specified using the `-o`
- or `--output` option, or `-` if output would go to stdout. The
- remaining lines, if any, list command-line arguments. These will
- include the names of input files and any special options passed
- after ` -- ` on the command line. So, for example,
-
- pandoc --dump-args -o foo.html -s foo.txt \
- appendix.txt -- -e latin1
-
- will cause the following to be printed to stdout:
-
- foo.html foo.txt appendix.txt -e latin1
+: Print information about command-line arguments to *stdout*, then exit.
+ This option is intended primarily for use in wrapper scripts.
+ The first line of output contains the name of the output file specified
+ with the `-o` option, or `-` (for *stdout*) if no output file was
+ specified. The remaining lines contain the command-line arguments,
+ one per line, in the order they appear. These do not include regular
+ Pandoc options and their arguments, but do include any options appearing
+ after a `--` separator at the end of the line.
`--ignore-args`
-: causes Pandoc to ignore all command-line arguments.
+: Ignore command-line arguments (for use in wrapper scripts).
Regular Pandoc options are not ignored. Thus, for example,
pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
@@ -480,18 +458,18 @@ For further documentation, see the `pandoc(1)` man page.
pandoc -o foo.html -s
-`-v` or `--version`
-: prints the version number to STDERR.
+`-v`, `--version`
+: Print version.
-`-h` or `--help`
-: prints a usage message to STDERR.
+`-h`, `--help`
+: Show usage message.
-[Smartypants]: http://daringfireball.net/projects/smartypants/
[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
+[MathJax]: http://www.mathjax.org/
[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
[mimeTeX]: http://www.forkosh.com/mimetex.html
-[Dublin Core elements]: http://dublincore.org/documents/dces/
+[CSL]: http://CitationStyles.org
Templates
=========
@@ -522,8 +500,6 @@ To write a literal `$` in a template, use `$$`.
Some variables are set automatically by pandoc. These vary somewhat
depending on the output format, but include:
-`legacy-header`
-: contents specified by `-C/--custom-header`
`header-includes`
: contents specified by `-H/--include-in-header` (may have multiple
values)
@@ -544,6 +520,8 @@ depending on the output format, but include:
multiple values)
`date`
: date of document, as specified in title block
+`lang`
+: language code for HTML documents
Variables may be set at the command line using the `-V/--variable`
option. This allows users to include custom variables in their
@@ -574,103 +552,347 @@ consecutive items:
$for(author)$$author$$sep$, $endfor$
-Pandoc's markdown vs. standard markdown
-=======================================
+Pandoc's markdown
+=================
-In parsing markdown, Pandoc departs from and extends [standard markdown]
-in a few respects. Except where noted, these differences can
-be suppressed by specifying the `--strict` command-line option.
+Pandoc understands an extended and slightly revised version of
+John Gruber's [markdown] syntax. This document explains the syntax,
+noting differences from standard markdown. Except where noted, these
+differences can be suppressed by specifying the `--strict` command-line
+option.
-[standard markdown]: http://daringfireball.net/projects/markdown/syntax
- "Markdown syntax description"
+Philosophy
+----------
-Backslash escapes
------------------
+Markdown is designed to be easy to write, and, even more importantly,
+easy to read:
-Except inside a code block or inline code, any punctuation or space
-character preceded by a backslash will be treated literally, even if it
-would normally indicate formatting. Thus, for example, if one writes
+> 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.
+> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)
- *\*hello\**
+This principle has guided pandoc's decisions in finding syntax for
+tables, footnotes, and other extensions.
-one will get
+There is, however, one respect in which pandoc's aims are different
+from the original aims of markdown. Whereas markdown was originally
+designed with HTML generation in mind, pandoc is designed for multiple
+output formats. Thus, while pandoc allows the embedding of raw HTML,
+it discourages it, and provides other, non-HTMLish ways of representing
+important document elements like definition lists, tables, mathematics, and
+footnotes.
- <em>*hello*</em>
+Paragraphs
+----------
-instead of
+A paragraph is one or more lines of text followed by one or more blank line.
+Newlines are treated as spaces, so you can reflow your paragraphs as you like.
+If you need a hard line break, put two or more spaces at the end of a line,
+or or type a backslash followed by a newline.
- <strong>hello</strong>
+Headers
+-------
-This rule is easier to remember than standard markdown's rule,
-which allows only the following characters to be backslash-escaped:
+There are two kinds of headers, Setext and atx.
- \`*_{}[]()>#+-.!
+### Setext-style headers ###
-A backslash-escaped space is parsed as a nonbreaking space. It will
-appear in TeX output as `~` and in HTML and XML as `\&#160;` or
-`\&nbsp;`.
+A setext-style header is a line of text "underlined" with a row of `=` signs
+(for a level one header) of `-` signs (for a level two header):
-A backslash-escaped newline (i.e. a backslash occurring at the end of
-a line) is parsed as a hard line break. It will appear in TeX output as
-`\\` and in HTML as `<br />`. This is a nice alternative to
-markdown's "invisible" way of indicating hard line breaks using
-two trailing spaces on a line.
+ A level-one header
+ ==================
-Subscripts and superscripts
----------------------------
+ A level-two header
+ ------------------
-Superscripts may be written by surrounding the superscripted text by `^`
-characters; subscripts may be written by surrounding the subscripted
-text by `~` characters. Thus, for example,
+The header text can contain inline formatting, such as emphasis (see
+[Inline formatting](#inline-formatting), below).
- H~2~O is a liquid. 2^10^ is 1024.
-If the superscripted or subscripted text contains spaces, these spaces
-must be escaped with backslashes. (This is to prevent accidental
-superscripting and subscripting through the ordinary use of `~` and `^`.)
-Thus, if you want the letter P with 'a cat' in subscripts, use
-`P~a\ cat~`, not `P~a cat~`.
+### Atx-style headers ###
-Strikeout
----------
+An Atx-style header consists of one to six `#` signs and a line of
+text, optionally followed by any number of `#` signs. The number of
+`#` signs at the beginning of the line is the header level:
-To strikeout a section of text with a horizontal line, begin and end it
-with `~~`. Thus, for example,
+ ## A level-two header
- This ~~is deleted text.~~
+ ### A level-three header ###
-Nested Lists
-------------
+As with setext-style headers, the header text can contain formatting:
-Pandoc behaves differently from standard markdown on some "edge
-cases" involving lists. Consider this source:
+ # A level-one header with a [link](/url) and *emphasis*
- 1. First
- 2. Second:
- - Fee
- - Fie
- - Foe
+Standard markdown syntax does not require a blank line before a header.
+Pandoc does require this (except, of course, at the beginning of the
+document). The reason for the requirement is that it is all too easy for a
+`#` to end up at the beginning of a line by accident (perhaps through line
+wrapping). Consider, for example:
- 3. Third
+ I like several of their flavors of ice cream:
+ #22, for example, and #5.
+
+
+### Header identifiers in HTML ###
+
+*Pandoc extension*.
+
+Each header element in pandoc's HTML output is given a unique
+identifier. This identifier is based on the text of the header. To
+derive the identifier from the header text,
+
+ - Remove all formatting, links, etc.
+ - Remove all punctuation, except underscores, hyphens, and periods.
+ - Replace all spaces and newlines with hyphens.
+ - Convert all alphabetic characters to lowercase.
+ - Remove everything up to the first letter (identifiers may
+ not begin with a number or punctuation mark).
+ - If nothing is left after this, use the identifier `section`.
+
+Thus, for example,
+
+ Header Identifier
+ ------------------------------- ----------------------------
+ Header identifiers in HTML `header-identifiers-in-html`
+ *Dogs*?--in *my* house? `dogs--in-my-house`
+ [HTML], [S5], or [RTF]? `html-s5-or-rtf`
+ 3. Applications `applications`
+ 33 `section`
+
+These rules should, in most cases, allow one to determine the identifier
+from the header text. The exception is when several headers have the
+same text; in this case, the first will get an identifier as described
+above; the second will get the same identifier with `-1` appended; the
+third with `-2`; and so on.
+
+These identifiers are used to provide link targets in the table of
+contents generated by the `--toc|--table-of-contents` option. They
+also make it easy to provide links from one section of a document to
+another. A link to this section, for example, might look like this:
+
+ See the section on
+ [header identifiers](#header-identifiers-in-html).
+
+Note, however, that this method of providing links to sections works
+only in HTML.
+
+If the `--section-divs` option is specified, then each section will
+be wrapped in a `div` (or a `section`, if `--html5` was specified),
+and the identifier will be attached to the enclosing `<div>`
+(or `<section>`) tag rather than the header itself. This allows entire
+sections to be manipulated using javascript or treated differently in
+CSS.
-Pandoc transforms this into a "compact list" (with no `<p>` tags around
-"First", "Second", or "Third"), while markdown puts `<p>` tags around
-"Second" and "Third" (but not "First"), because of the blank space
-around "Third". Pandoc follows a simple rule: if the text is followed by
-a blank line, it is treated as a paragraph. Since "Second" is followed
-by a list, and not a blank line, it isn't treated as a paragraph. The
-fact that the list is followed by a blank line is irrelevant. (Note:
-Pandoc works this way even when the `--strict` option is specified. This
-behavior is consistent with the official markdown syntax description,
-even though it is different from that of `Markdown.pl`.)
-Ordered Lists
--------------
+Block quotations
+----------------
+
+Markdown uses email conventions for quoting blocks of text.
+A block quotation is one or more paragraphs or other block elements
+(such as lists or headers), with each line preceded by a `>` character
+and a space. (The `>` need not start at the left margin, but it should
+not be indented more than three spaces.)
+
+ > This is a block quote. This
+ > paragraph has two lines.
+ >
+ > 1. This is a list inside a block quote.
+ > 2. Second item.
+
+A "lazy" form, which requires the `>` character only on the first
+line of each block, is also allowed:
+
+ > This is a block quote. This
+ paragraph has two lines.
+
+ > 1. This is a list inside a block quote.
+ 2. Second item.
+
+Among the block elements that can be contained in a block quote are
+other block quotes. That is, block quotes can be nested:
+
+ > This is a block quote.
+ >
+ > > A block quote within a block quote.
+
+Standard markdown syntax does not require a blank line before a block
+quote. Pandoc does require this (except, of course, at the beginning of the
+document). The reason for the requirement is that it is all too easy for a
+`>` to end up at the beginning of a line by accident (perhaps through line
+wrapping). So, unless `--strict` is used, the following does not produce
+a nested block quote in pandoc:
+
+ > This is a block quote.
+ >> Nested.
+
+
+Verbatim (code) blocks
+----------------------
+
+### Indented code blocks ###
+
+A block of text indented four spaces (or one tab) is treated as verbatim
+text: that is, special characters do not trigger special formatting,
+and all spaces and line breaks are preserved. For example,
+
+ if (a > 3) {
+ moveShip(5 * gravity, DOWN);
+ }
+
+The initial (four space or one tab) indentation is not considered part
+of the verbatim text, and is removed in the output.
+
+Note: blank lines in the verbatim text need not begin with four spaces.
+
+
+### Delimited code blocks ###
+
+*Pandoc extension*.
+
+In addition to standard indented code blocks, Pandoc supports
+*delimited* code blocks. These begin with a row of three or more
+tildes (`~`) and end with a row of tildes that must be at least
+as long as the starting row. Everything between the tilde-lines
+is treated as code. No indentation is necessary:
+
+ ~~~~~~~
+ if (a > 3) {
+ moveShip(5 * gravity, DOWN);
+ }
+ ~~~~~~~
+
+Like regular code blocks, delimited code blocks must be separated
+from surrounding text by blank lines.
+
+If the code itself contains a row of tildes, just use a longer
+row of tildes at the start and end:
+
+ ~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~
+ code including tildes
+ ~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~
+
+Optionally, you may specify the language of the code block using
+this syntax:
+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
+ qsort [] = []
+ qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
+ qsort (filter (>= x) xs)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some output formats can use this information to do syntax highlighting.
+Currently, the only output format that uses this information is HTML.
+
+If pandoc has been compiled with syntax highlighting support, then the
+code block above will appear highlighted, with numbered lines. (To see
+which languages are supported, do `pandoc --version`.)
+
+If pandoc has not been compiled with syntax highlighting support, the
+code block above will appear as follows:
+
+ <pre class="haskell">
+ <code>
+ ...
+ </code>
+ </pre>
+
+
+Lists
+-----
+
+### Bullet lists ###
+
+A bullet list is a list of bulleted list items. A bulleted list
+item begins with a bullet (`*`, `+`, or `-`). Here is a simple
+example:
+
+ * one
+ * two
+ * three
+
+This will produce a "compact" list. If you want a "loose" list, in which
+each item is formatted as a paragraph, put spaces between the items:
+
+ * one
+
+ * two
+
+ * three
+
+The bullets need not be flush with the left margin; they may be
+indented one, two, or three spaces. The bullet must be followed
+by whitespace.
+
+A list item may contain multiple paragraphs and other block-level
+content. Subsequent paragraphs must be preceded by a blank line
+and indented four spaces or a tab. The list will look better if
+the first paragraph is aligned with the rest:
+
+ * First paragraph.
+
+ Continued.
+
+ * Second paragraph. With a code block, which must be indented
+ eight spaces:
+
+ { code }
+
+List items may include other lists. In this case the preceding blank
+line is optional. The nested list must be indented four spaces or
+one tab:
+
+ * fruits
+ + apples
+ - macintosh
+ - red delicious
+ + pears
+ + peaches
+ * vegetables
+ + brocolli
+ + chard
+
+Markdown allows you to write list items "lazily," instead of
+indenting continuation lines. However, if there are multiple paragraphs
+or other blocks in a list item, the first line of each must be indented.
+
+ + A lazy, lazy, list
+ item.
+
+ + Another one; this looks
+ bad but is legal.
+
+ Second paragraph of second
+ list item.
+
+
+### Ordered lists ###
+
+Ordered lists work just like bulleted lists, except that the items
+begin with enumerators rather than bullets.
+
+In standard markdown, enumerators are decimal numbers followed
+by a period and a space. The numbers themselves are ignored, so
+there is no difference between this list:
+
+ 1. one
+ 2. two
+ 3. three
+
+and this one:
+
+ 5. one
+ 7. two
+ 1. three
+
+*Pandoc extension*.
Unlike standard markdown, Pandoc allows ordered list items to be marked
with uppercase and lowercase letters and roman numerals, in addition to
-arabic numerals. (This behavior can be turned off using the `--strict`
-option.) List markers may be enclosed in parentheses or followed by a
+arabic numerals. List markers may be enclosed in parentheses or followed by a
single right-parentheses or period. They must be separated from the
text that follows by at least one space, and, if the list marker is a
capital letter with a period, by at least two spaces.[^2]
@@ -718,34 +940,10 @@ If default list markers are desired, use `#.`:
#. two
#. three
-Numbered examples
------------------
-
-The special list marker `@` can be used for sequentially numbered
-examples. The first list item with a `@` marker will be numbered '1',
-the next '2', and so on, throughout the document. The numbered examples
-need not occur in a single list; each new list using `@` will take up
-where the last stopped. So, for example:
-
- (@) My first example will be numbered (1).
- (@) My second example will be numbered (2).
- Explanation of examples.
-
- (@) My third example will be numbered (3).
-
-Numbered examples can be labeled and referred to elsewhere in the
-document:
-
- (@good) This is a good example.
-
- As (@good) illustrates, ...
-
-The label can be any string of alphanumeric characters, underscores,
-or hyphens.
+### Definition lists ###
-Definition lists
-----------------
+*Pandoc extension*.
Pandoc supports definition lists, using a syntax inspired by
[PHP Markdown Extra] and [reStructuredText]:[^3]
@@ -785,63 +983,114 @@ definition and the next term:
[PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
-Reference links
----------------
-Pandoc allows implicit reference links with just a single set of
-brackets. So, the following links are equivalent:
+### Numbered example lists ###
- 1. Here's my [link]
- 2. Here's my [link][]
+*Pandoc extension*.
- [link]: linky.com
+The special list marker `@` can be used for sequentially numbered
+examples. The first list item with a `@` marker will be numbered '1',
+the next '2', and so on, throughout the document. The numbered examples
+need not occur in a single list; each new list using `@` will take up
+where the last stopped. So, for example:
-(Note: Pandoc works this way even if `--strict` is specified, because
-`Markdown.pl` 1.0.2b7 allows single-bracket links.)
+ (@) My first example will be numbered (1).
+ (@) My second example will be numbered (2).
-Footnotes
----------
+ Explanation of examples.
-Pandoc's markdown allows footnotes, using the following syntax:
+ (@) My third example will be numbered (3).
- Here is a footnote reference,[^1] and another.[^longnote]
+Numbered examples can be labeled and referred to elsewhere in the
+document:
- [^1]: Here is the footnote.
+ (@good) This is a good example.
- [^longnote]: Here's one with multiple blocks.
+ As (@good) illustrates, ...
- Subsequent paragraphs are indented to show that they
- belong to the previous footnote.
+The label can be any string of alphanumeric characters, underscores,
+or hyphens.
- { some.code }
- The whole paragraph can be indented, or just the first
- line. In this way, multi-paragraph footnotes work like
- multi-paragraph list items.
+### Compact and loose lists ###
- This paragraph won't be part of the note, because it isn't indented.
+Pandoc behaves differently from `Markdown.pl` on some "edge
+cases" involving lists. Consider this source:
-The identifiers in footnote references may not contain spaces, tabs,
-or newlines. These identifiers are used only to correlate the
-footnote reference with the note itself; in the output, footnotes
-will be numbered sequentially.
+ + First
+ + Second:
+ - Fee
+ - Fie
+ - Foe
-The footnotes themselves need not be placed at the end of the
-document. They may appear anywhere except inside other block elements
-(lists, block quotes, tables, etc.).
+ + Third
-Inline footnotes are also allowed (though, unlike regular notes,
-they cannot contain multiple paragraphs). The syntax is as follows:
+Pandoc transforms this into a "compact list" (with no `<p>` tags around
+"First", "Second", or "Third"), while markdown puts `<p>` tags around
+"Second" and "Third" (but not "First"), because of the blank space
+around "Third". Pandoc follows a simple rule: if the text is followed by
+a blank line, it is treated as a paragraph. Since "Second" is followed
+by a list, and not a blank line, it isn't treated as a paragraph. The
+fact that the list is followed by a blank line is irrelevant. (Note:
+Pandoc works this way even when the `--strict` option is specified. This
+behavior is consistent with the official markdown syntax description,
+even though it is different from that of `Markdown.pl`.)
- Here is an inline note.^[Inlines notes are easier to write, since
- you don't have to pick an identifier and move down to type the
- note.]
-Inline and regular footnotes may be mixed freely.
+### Ending a list ###
+
+What if you want to put an indented code block after a list?
+
+ - item one
+ - item two
+
+ { my code block }
+
+Trouble! Here pandoc (like other markdown implementations) will treat
+`{ my code block }` as the second paragraph of item two, and not as
+a code block.
+
+To "cut off" the list after item two, you can insert some non-indented
+content, like an HTML comment, which won't produce visible output in
+any format:
+
+ - item one
+ - item two
+
+ <!-- end of list -->
+
+ { my code block }
+
+You can use the same trick if you want two consecutive lists instead
+of one big list:
+
+ 1. one
+ 2. two
+ 3. three
+
+ <!-- -->
+
+ a. uno
+ b. dos
+ c. tres
+
+
+Horizontal rules
+----------------
+
+A line containing a row of three or more `*`, `-`, or `_` characters
+(optionally separated by spaces) produces a horizontal rule:
+
+ * * * *
+
+ ---------------
+
Tables
------
+*Pandoc extension*.
+
Three kinds of tables may be used. All three kinds presuppose the use of
a fixed-width font, such as Courier.
@@ -891,7 +1140,8 @@ of the first line of the table body. So, in the tables above, the columns
would be right, left, center, and right aligned, respectively.
**Multiline tables** allow headers and table rows to span multiple lines
-of text. Here is an example:
+of text (but cells that span multiple columns or rows of the table are
+not supported). Here is an example:
-------------------------------------------------------------
Centered Default Right Left
@@ -940,7 +1190,7 @@ the table), or the table may be interpreted as a simple table.
**Grid tables** look like this:
: Sample grid table.
-
+
+---------------+---------------+--------------------+
| Fruit | Price | Advantages |
+===============+===============+====================+
@@ -954,84 +1204,16 @@ the table), or the table may be interpreted as a simple table.
The row of `=`s separates the header from the table body, and can be
omitted for a headerless table. The cells of grid tables may contain
arbitrary block elements (multiple paragraphs, code blocks, lists,
-etc.). Alignments are not supported, nor are multi-column or multi-row
-cells. Grid tables can be created easily using [Emacs table mode].
+etc.). Alignments are not supported, nor are cells that span multiple
+columns or rows. Grid tables can be created easily using [Emacs table mode].
[Emacs table mode]: http://table.sourceforge.net/
-Delimited Code blocks
----------------------
-
-In addition to standard indented code blocks, Pandoc supports
-*delimited* code blocks. These begin with a row of three or more
-tildes (`~`) and end with a row of tildes that must be at least
-as long as the starting row. Everything between the tilde-lines
-is treated as code. No indentation is necessary:
-
- ~~~~~~~
- {code here}
- ~~~~~~~
-Like regular code blocks, delimited code blocks must be separated
-from surrounding text by blank lines.
+Title block
+-----------
-If the code itself contains a row of tildes, just use a longer
-row of tildes at the start and end:
-
- ~~~~~~~~~~~~~~~~
- ~~~~~~~~~~
- code including tildes
- ~~~~~~~~~~
- ~~~~~~~~~~~~~~~~
-
-Optionally, you may specify the language of the code block using
-this syntax:
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
- qsort [] = []
- qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
- qsort (filter (>= x) xs)
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Some output formats can use this information to do syntax highlighting.
-Currently, the only output format that uses this information is HTML.
-
-If pandoc has been compiled with syntax highlighting support, then the
-code block above will appear highlighted, with numbered lines. (To see
-which languages are supported, do `pandoc --version`.)
-
-If pandoc has not been compiled with syntax highlighting support, the
-code block above will appear as follows:
-
- <pre class="haskell">
- <code>
- ...
- </code>
- </pre>
-
-Images with captions
---------------------
-
-An image occurring by itself in a paragraph will be rendered as
-a figure with a caption.[^5] (In LaTeX, a figure environment will be
-used; in HTML, the image will be placed in a `div` with class
-`figure`, together with a caption in a `p` with class `caption`.)
-The image's alt text will be used as the caption.
-
- ![This is the caption](/url/of/image.png)
-
-[^5]: This feature is not yet implemented for RTF, OpenDocument, or
- ODT. In those formats, you'll just get an image in a paragraph by
- itself, with no caption.
-
-If you just want a regular inline image, just make sure it is not
-the only thing in the paragraph. One way to do this is to insert a
-nonbreaking space after the image:
-
- ![This image won't be a figure](/url/of/image.png)\
-
-Title blocks
-------------
+*Pandoc extension*.
If the file begins with a title block
@@ -1107,12 +1289,233 @@ will also have "Pandoc User Manuals" in the footer.
will also have "Version 4.0" in the header.
-Markdown in HTML blocks
------------------------
-While standard markdown leaves HTML blocks exactly as they are, Pandoc
-treats text between HTML tags as markdown. Thus, for example, Pandoc
-will turn
+Backslash escapes
+-----------------
+
+Except inside a code block or inline code, any punctuation or space
+character preceded by a backslash will be treated literally, even if it
+would normally indicate formatting. Thus, for example, if one writes
+
+ *\*hello\**
+
+one will get
+
+ <em>*hello*</em>
+
+instead of
+
+ <strong>hello</strong>
+
+This rule is easier to remember than standard markdown's rule,
+which allows only the following characters to be backslash-escaped:
+
+ \`*_{}[]()>#+-.!
+
+(However, if the `--strict` option is supplied, the standard
+markdown rule will be used.)
+
+A backslash-escaped space is parsed as a nonbreaking space. It will
+appear in TeX output as `~` and in HTML and XML as `\&#160;` or
+`\&nbsp;`.
+
+A backslash-escaped newline (i.e. a backslash occurring at the end of
+a line) is parsed as a hard line break. It will appear in TeX output as
+`\\` and in HTML as `<br />`. This is a nice alternative to
+markdown's "invisible" way of indicating hard line breaks using
+two trailing spaces on a line.
+
+Backslash escapes do not work in verbatim contexts.
+
+Smart punctuation
+-----------------
+
+If the `--smart` option is specified, pandoc will produce typographically
+correct output, converting straight quotes to curly quotes, `---` and `--`
+to Em-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after
+certain abbreviations, such as "Mr."
+
+Inline formatting
+-----------------
+
+### Emphasis ###
+
+To *emphasize* some text, surround it with `*`s or `_`, like this:
+
+ This text is _emphasized with underscores_, and this
+ is *emphasized with asterisks*.
+
+Double `*` or `_` produces **strong emphasis**:
+
+ This is **strong emphasis** and __with underscores__.
+
+A `*` or `_` character surrounded by spaces, or backslash-escaped,
+will not trigger emphasis:
+
+ This is * not emphasized *, and \*neither is this\*.
+
+Because `_` is sometimes used inside words and identifiers,
+pandoc does not interpret a `_` surrounded by alphanumeric
+characters as an emphasis marker. If you want to emphasize
+just part of a word, use `*`:
+
+ feas*ible*, not feas*able*.
+
+
+### Strikeout ###
+
+*Pandoc extension*.
+
+To strikeout a section of text with a horizontal line, begin and end it
+with `~~`. Thus, for example,
+
+ This ~~is deleted text.~~
+
+
+### Superscripts and subscripts ###
+
+*Pandoc extension*.
+
+Superscripts may be written by surrounding the superscripted text by `^`
+characters; subscripts may be written by surrounding the subscripted
+text by `~` characters. Thus, for example,
+
+ H~2~O is a liquid. 2^10^ is 1024.
+
+If the superscripted or subscripted text contains spaces, these spaces
+must be escaped with backslashes. (This is to prevent accidental
+superscripting and subscripting through the ordinary use of `~` and `^`.)
+Thus, if you want the letter P with 'a cat' in subscripts, use
+`P~a\ cat~`, not `P~a cat~`.
+
+
+### Verbatim ###
+
+To make a short span of text verbatim, put it inside backticks:
+
+ What is the difference between `>>=` and `>>`?
+
+If the verbatim text includes a backtick, use double backticks:
+
+ Here is a literal backtick `` ` ``.
+
+(The spaces after the opening backticks and before the closing
+backticks will be ignored.)
+
+The general rule is that a verbatim span starts with a string
+of consecutive backticks (optionally followed by a space)
+and ends with a string of the same number of backticks (optionally
+preceded by a space).
+
+Note that backslash-escapes (and other markdown constructs) do not
+work in verbatim contexts:
+
+ This is a backslash followed by an asterisk: `\*`.
+
+
+Math
+----
+
+*Pandoc extension*.
+
+Anything between two `$` characters will be treated as TeX math. The
+opening `$` must have a character immediately to its right, while the
+closing `$` must have a character immediately to its left. Thus,
+`$20,000 and $30,000` won't parse as math. If for some reason
+you need to enclose text in literal `$` characters, backslash-escape
+them and they won't be treated as math delimiters.
+
+TeX math will be printed in all output formats. How it is rendered
+depends on the output format:
+
+Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
+ ~ It will appear verbatim between `$` characters.
+
+reStructuredText
+ ~ It will be rendered using an interpreted text role `:math:`, as described
+ [here](http://www.american.edu/econ/itex2mml/mathhack.rst).
+
+Texinfo
+ ~ It will be rendered inside a `@math` command.
+
+groff man
+ ~ It will be rendered verbatim without `$`'s.
+
+MediaWiki
+ ~ It will be rendered inside `<math>` tags.
+
+Textile
+ ~ It will be rendered inside `<span class="math">` tags.
+
+RTF, Docbook, OpenDocument, ODT
+ ~ It will be rendered, if possible, using unicode characters,
+ and will otherwise appear verbatim.
+
+HTML, Slidy, S5, EPUB
+ ~ The way math is rendered in HTML will depend on the
+ command-line options selected:
+
+ 1. The default is to render TeX math as far as possible using unicode
+ characters, as with RTF, Docbook, and OpenDocument output. Formulas
+ are put inside a `span` with `class="math"`, so that they may be
+ styled differently from the surrounding text if needed.
+
+ 2. If the `--latexmathml` option is used, TeX math will be displayed
+ between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
+ The [LaTeXMathML] script will be used to render it as formulas.
+ (This trick does not work in all browsers, but it works in Firefox.
+ In browsers that do not support LaTeXMathML, TeX math will appear
+ verbatim between $ characters.)
+
+ 3. If the `--jsmath` option is used, TeX math will be put inside
+ `<span>` tags (for inline math) or `<div>` tags (for display math)
+ with class `math`. The [jsMath] script will be used to render
+ it.
+
+ 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
+ be called to generate images for each TeX formula. This should
+ work in all browsers. The `--mimetex` option takes an optional URL
+ as argument. If no URL is specified, it will be assumed that the
+ mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
+
+ 5. If the `--gladtex` option is used, TeX formulas will be enclosed
+ in `<eq>` tags in the HTML output. The resulting `htex` file may then
+ be processed by [gladTeX], which will produce image files for each
+ formula and an `html` file with links to these images. So, the
+ procedure is:
+
+ pandoc -s --gladtex myfile.txt -o myfile.htex
+ gladtex -d myfile-images myfile.htex
+ # produces myfile.html and images in myfile-images
+
+ 6. If the `--webtex` option is used, TeX formulas will be converted
+ to `<img>` tags that link to an external script that converts
+ formulas to images. The formula will be URL-encoded and concatenated
+ with the URL provided. If no URL is specified, the Google Chart
+ API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
+
+
+Raw HTML
+--------
+
+Markdown allows you to insert raw HTML anywhere in a document
+(except verbatim contexts, where `<`, `>`, and `&` are interpreted
+literally).
+
+The raw HTML is passed through unchanged in HTML, S5, Slidy, EPUB,
+Markdown, and Textile output, and suppressed in other formats.
+
+*Pandoc extension*.
+
+Standard markdown allows you to include HTML "blocks": blocks
+of HTML between balanced tags that are separated from the surrounding text
+with blank lines, and start and end at the left margin. Within
+these blocks, everything is interpreted as HTML, not markdown;
+so (for example), `*` does not signify emphasis.
+
+Pandoc behaves this way when `--strict` is specified; but by default,
+pandoc interprets material between HTML block tags as markdown.
+Thus, for example, Pandoc will turn
<table>
<tr>
@@ -1133,168 +1536,272 @@ into
whereas `Markdown.pl` will preserve it as is.
There is one exception to this rule: text between `<script>` and
-`</script>` tags is not interpreted as markdown.
+`<style>` tags is not interpreted as markdown.
This departure from standard markdown should make it easier to mix
markdown with HTML block elements. For example, one can surround
a block of markdown text with `<div>` tags without preventing it
from being interpreted as markdown.
-Header identifiers in HTML
---------------------------
-Each header element in pandoc's HTML output is given a unique
-identifier. This identifier is based on the text of the header. To
-derive the identifier from the header text,
+Raw TeX
+-------
- - Remove all formatting, links, etc.
- - Remove all punctuation, except underscores, hyphens, and periods.
- - Replace all spaces and newlines with hyphens.
- - Convert all alphabetic characters to lowercase.
- - Remove everything up to the first letter (identifiers may
- not begin with a number or punctuation mark).
- - If nothing is left after this, use the identifier `section`.
+*Pandoc extension*.
-Thus, for example,
+In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
+included in a document. Inline TeX commands will be preserved and passed
+unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
+LaTeX to include BibTeX citations:
- Header Identifier
- ------------------------------------- ---------------------------
- Header identifiers in HTML `header-identifiers-in-html`
- *Dogs*?--in *my* house? `dogs--in-my-house`
- [HTML], [S5], or [RTF]? `html-s5-or-rtf`
- 3. Applications `applications`
- 33 `section`
+ This result was proved in \cite{jones.1967}.
-These rules should, in most cases, allow one to determine the identifier
-from the header text. The exception is when several headers have the
-same text; in this case, the first will get an identifier as described
-above; the second will get the same identifier with `-1` appended; the
-third with `-2`; and so on.
+Note that in LaTeX environments, like
-These identifiers are used to provide link targets in the table of
-contents generated by the `--toc|--table-of-contents` option. They
-also make it easy to provide links from one section of a document to
-another. A link to this section, for example, might look like this:
+ \begin{tabular}{|l|l|}\hline
+ Age & Frequency \\ \hline
+ 18--25 & 15 \\
+ 26--35 & 33 \\
+ 36--45 & 22 \\ \hline
+ \end{tabular}
- See the section on [header identifiers](#header-identifiers-in-html).
+the material between the begin and end tags will be interpreted as raw
+LaTeX, not as markdown.
-Note, however, that this method of providing links to sections works
-only in HTML.
+Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
+and ConTeXt.
-If the `--section-divs` option is specified, then each section will
-be wrapped in a `div`, and the identifier will be attached to the
-enclosing `<div>` tag rather than the header itself. This allows entire
-sections to be manipulated using javascript or treated differently in
-CSS.
+### Macros ###
-Blank lines before headers and blockquotes
-------------------------------------------
+For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
+`\renewcommand` definitions and apply the resulting macros to all LaTeX
+math. So, for example, the following will work in all output formats,
+not just LaTeX:
-Standard markdown syntax does not require a blank line before a header
-or blockquote. Pandoc does require this (except, of course, at the
-beginning of the document). The reason for the requirement is that
-it is all too easy for a `>` or `#` to end up at the beginning of a
-line by accident (perhaps through line wrapping). Consider, for
-example:
+ \newcommand{\tuple}[1]{\langle #1 \rangle}
- I like several of their flavors of ice cream: #22, for example, and
- #5.
+ $\tuple{a, b, c}$
-Math
-----
+In LaTeX output, the `\newcommand` definition will simply be passed
+unchanged to the output.
-Anything between two $ characters will be treated as TeX math. The
-opening $ must have a character immediately to its right, while the
-closing $ must have a character immediately to its left. Thus,
-`$20,000 and $30,000` won't parse as math. If for some reason
-you need to enclose text in literal $ characters, backslash-escape
-them and they won't be treated as math delimiters.
-TeX math will be printed in all output formats. In Markdown,
-reStructuredText, LaTeX, and ConTeXt output, it will appear verbatim
-between $ characters.
-
-In reStructuredText output, it will be rendered using an interpreted
-text role `:math:`, as described
-[here](http://www.american.edu/econ/itex2mml/mathhack.rst).
-
-In Texinfo output, it will be rendered inside a `@math` command.
-
-In groff man output, it will be rendered verbatim without $'s.
-
-In MediaWiki output, it will be rendered inside `<math>` tags.
-
-In RTF, Docbook, and OpenDocument output, it will be rendered, as far as
-possible, using unicode characters, and will otherwise appear verbatim.
-Unknown commands and symbols, and commands that cannot be dealt with
-this way (like `\frac`), will be rendered verbatim. So the results may
-be a mix of raw TeX code and properly rendered unicode math.
-
-In HTML, Slidy, and S5 output, the way math is rendered will depend on the
-command-line options selected:
-
-1. The default is to render TeX math as far as possible using unicode
- characters, as with RTF, Docbook, and OpenDocument output. Formulas
- are put inside a `span` with `class="math"`, so that they may be
- styled differently from the surrounding text if needed.
-
-2. If the `--latexmathml` option is used, TeX math will be displayed
- between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
- The [LaTeXMathML] script will be used to render it as formulas.
- (This trick does not work in all browsers, but it works in Firefox.
- In browsers that do not support LaTeXMathML, TeX math will appear
- verbatim between $ characters.)
-
-3. If the `--jsmath` option is used, TeX math will be put inside
- `<span>` tags (for inline math) or `<div>` tags (for display math)
- with class `math`. The [jsMath] script will be used to render
- it.
-
-4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
- be called to generate images for each TeX formula. This should
- work in all browsers. The `--mimetex` option takes an optional URL
- as argument. If no URL is specified, it will be assumed that the
- mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
-
-5. If the `--gladtex` option is used, TeX formulas will be enclosed
- in `<eq>` tags in the HTML output. The resulting `htex` file may then
- be processed by [gladTeX], which will produce image files for each
- formula and an `html` file with links to these images. So, the
- procedure is:
-
- pandoc -s --gladtex myfile.txt -o myfile.htex
- gladtex -d myfile-images myfile.htex
- # produces myfile.html and images in myfile-images
-
-6. If the `--webtex` option is used, TeX formulas will be converted
- to `<img>` tags that link to an external script that converts
- formulas to images. The formula will be URL-encoded and concatenated
- with the URL provided. If no URL is specified, the Google Chart
- API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
-
-Inline TeX
-----------
+Links
+-----
-Inline TeX commands will be preserved and passed unchanged to the
-LaTeX and ConTeXt writers. Thus, for example, you can use LaTeX to
-include BibTeX citations:
+Markdown allows links to be specified in several ways.
- This result was proved in \cite{jones.1967}.
+### Automatic links ###
-Note that in LaTeX environments, like
+If you enclose a URL or email address in pointy brackets, it
+will become a link:
- \begin{tabular}{|l|l|}\hline
- Age & Frequency \\ \hline
- 18--25 & 15 \\
- 26--35 & 33 \\
- 36--45 & 22 \\ \hline
- \end{tabular}
+ <http://google.com>
+ <sam@green.eggs.ham>
-the material between the begin and end tags will be interpreted as raw
-LaTeX, not as markdown.
-Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
-and ConTeXt.
+### Inline links ###
+
+An inline link consists of the link text in square brackets,
+followed by the URL in parentheses. (Optionally, the URL can
+be followed by a link title, in quotes.)
+
+ This is an [inline link](/url), and here's [one with
+ a title](http://fsf.org "click here for a good time!").
+
+There can be no space between the bracketed part and the parenthesized part.
+The link text can contain formatting (such as emphasis), but the title cannot.
+
+
+### Reference links ###
+
+An *explicit* reference link has two parts, the link itself and the link
+definition, which may occur elsewhere in the document (either
+before or after the link).
+
+The link consists of link text in square brackets, followed by a label in
+square brackets. (There can be space between the two.) The link definition
+must begin at the left margin or indented no more than three spaces. It
+consists of the bracketed label, followed by a colon and a space, followed by
+the URL, and optionally (after a space) a link title either in quotes or in
+parentheses.
+
+Here are some examples:
+
+ [my label 1]: /foo/bar.html "My title, optional"
+ [my label 2]: /foo
+ [my label 3]: http://fsf.org (The free software foundation)
+ [my label 4]: /bar#special 'A title in single quotes'
+
+The URL may optionally be surrounded by angle brackets:
+
+ [my label 5]: <http://foo.bar.baz>
+
+The title may go on the next line:
+
+ [my label 3]: http://fsf.org
+ "The free software foundation"
+
+Note that link labels are not case sensitive. So, this will work:
+
+ Here is [my link][FOO]
+
+ [Foo]: /bar/baz
+
+In an *implicit* reference link, the second pair of brackets is
+empty, or omitted entirely:
+
+ See [my website][], or [my website].
+
+ [my website]: http://foo.bar.baz
+
+
+Images
+------
+
+A link immediately preceded by a `!` will be treated as an image.
+The link text will be used as the image's alt text:
+
+ ![la lune](lalune.jpg "Voyage to the moon")
+
+ ![movie reel]
+
+ [movie reel]: movie.gif
+
+### Pictures with captions ###
+
+*Pandoc extension*.
+
+An image occurring by itself in a paragraph will be rendered as
+a figure with a caption.[^5] (In LaTeX, a figure environment will be
+used; in HTML, the image will be placed in a `div` with class
+`figure`, together with a caption in a `p` with class `caption`.)
+The image's alt text will be used as the caption.
+
+ ![This is the caption](/url/of/image.png)
+
+[^5]: This feature is not yet implemented for RTF, OpenDocument, or
+ ODT. In those formats, you'll just get an image in a paragraph by
+ itself, with no caption.
+
+If you just want a regular inline image, just make sure it is not
+the only thing in the paragraph. One way to do this is to insert a
+nonbreaking space after the image:
+
+ ![This image won't be a figure](/url/of/image.png)\
+
+
+Footnotes
+---------
+
+*Pandoc extension*.
+
+Pandoc's markdown allows footnotes, using the following syntax:
+
+ Here is a footnote reference,[^1] and another.[^longnote]
+
+ [^1]: Here is the footnote.
+
+ [^longnote]: Here's one with multiple blocks.
+
+ Subsequent paragraphs are indented to show that they
+ belong to the previous footnote.
+
+ { some.code }
+
+ The whole paragraph can be indented, or just the first
+ line. In this way, multi-paragraph footnotes work like
+ multi-paragraph list items.
+
+ This paragraph won't be part of the note, because it
+ isn't indented.
+
+The identifiers in footnote references may not contain spaces, tabs,
+or newlines. These identifiers are used only to correlate the
+footnote reference with the note itself; in the output, footnotes
+will be numbered sequentially.
+
+The footnotes themselves need not be placed at the end of the
+document. They may appear anywhere except inside other block elements
+(lists, block quotes, tables, etc.).
+
+Inline footnotes are also allowed (though, unlike regular notes,
+they cannot contain multiple paragraphs). The syntax is as follows:
+
+ Here is an inline note.^[Inlines notes are easier to write, since
+ you don't have to pick an identifier and move down to type the
+ note.]
+
+Inline and regular footnotes may be mixed freely.
+
+
+Citations
+---------
+
+*Pandoc extension*.
+
+Pandoc can automatically generate citations and a bibliography in a number of
+styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
+you will need a bibliographic database in one of the following formats:
+
+ Format File extension
+ ------------ --------------
+ MODS .mods
+ BibTeX .bib
+ BibLaTeX .bbx
+ RIS .ris
+ EndNote .enl
+ EndNote XML .xml
+ ISI .wos
+ MEDLINE .medline
+ Copac .copac
+ JSON citeproc .json
+
+You will need to specify the bibliography file using the `--bibliography`
+command-line option (which may be repeated if you have several
+bibliographies).
+
+By default, pandoc will use a Chicago author-date format for citations
+and references. To use another style, you will need to use the
+`--csl` option to specify a [CSL] 1.0 style file. A primer on
+creating and modifying CSL styles can be found at
+<http://citationstyles.org/downloads/primer.html>.
+A repository of CSL styles can be found at
+<https://github.com/citation-style-language/styles>.
+
+Citations go inside square brackets and are separated by semicolons.
+Each citation must have a key, composed of '@' + the citation
+identifier from the database, and may optionally have a prefix,
+a locator, and a suffix. Here are some examples:
+
+ Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
+
+ Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
+
+ Blah blah [@smith04; @doe99].
+
+A minus sign (`-`) before the `@` will suppress mention of
+the author in the citation. This can be useful when the
+author is already mentioned in the text:
+
+ Smith says blah [-@smith04].
+
+You can also write an in-text citation, as follows:
+
+ @smith04 says blah.
+
+ @smith04 [p. 33] says blah.
+
+If the style calls for a list of works cited, it will be placed
+at the end of the document. Normally, you will want to end your
+document with an appropriate header:
+
+ last paragraph...
+
+ # References
+
+The bibliography will be inserted after this header.
+
Producing HTML slide shows with Pandoc
======================================
@@ -1410,3 +1917,34 @@ ordinary HTML (without bird tracks).
writes HTML with the Haskell code in bird tracks, so it can be copied
and pasted as literate Haskell source.
+Authors
+=======
+
+© 2006-2011 John MacFarlane (jgm at berkeley dot edu). Released under the
+[GPL], version 2 or greater. This software carries no warranty of
+any kind. (See COPYRIGHT for full copyright and warranty notices.)
+Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
+Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
+Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
+Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner.
+
+[markdown]: http://daringfireball.net/projects/markdown/
+[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
+[S5]: http://meyerweb.com/eric/tools/s5/
+[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
+[HTML]: http://www.w3.org/TR/html40/
+[LaTeX]: http://www.latex-project.org/
+[ConTeXt]: http://www.pragma-ade.nl/
+[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
+[DocBook XML]: http://www.docbook.org/
+[OpenDocument XML]: http://opendocument.xml.org/
+[ODT]: http://en.wikipedia.org/wiki/OpenDocument
+[Textile]: http://redcloth.org/textile
+[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
+[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
+[Haskell]: http://www.haskell.org/
+[GNU Texinfo]: http://www.gnu.org/software/texinfo/
+[Emacs Org-Mode]: http://org-mode.org
+[EPUB]: http://www.idpf.org/
+[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
+
diff --git a/Setup.hs b/Setup.hs
index aa007576e..e942b0da2 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -10,10 +10,9 @@ import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest))
import Distribution.Simple.Utils (copyFiles)
import Control.Exception ( bracket_ )
import Control.Monad ( unless )
-import System.Process ( runCommand, runProcess, waitForProcess )
-import System.FilePath ( (</>), (<.>) )
+import System.Process ( rawSystem, runCommand, waitForProcess )
+import System.FilePath ( (</>) )
import System.Directory
-import System.IO ( stderr )
import System.Exit
import System.Time
import System.IO.Error ( isDoesNotExistError )
@@ -38,41 +37,41 @@ main = do
-- | Run test suite.
runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a
-runTestSuite _ _ pkg _ = do
- let isHighlightingKate (Dependency (PackageName "highlighting-kate") _) = True
- isHighlightingKate _ = False
- let highlightingSupport = any isHighlightingKate $ buildDepends pkg
- let testArgs = ["lhs" | highlightingSupport]
- let testCmd = "runhaskell -i.. RunTests.hs " ++ unwords testArgs
- inDirectory "tests" $ runCommand testCmd >>= waitForProcess >>= exitWith
+runTestSuite args _ pkg lbi = do
+ let testDir = buildDir lbi </> "test-pandoc"
+ testDir' <- canonicalizePath testDir
+ let testArgs = concatMap (\arg -> ["-t",arg]) args
+ if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"]
+ then inDirectory "tests" $ rawSystem (testDir' </> "test-pandoc") testArgs >>= exitWith
+ else do
+ putStrLn "Build pandoc with the 'tests' flag to run tests"
+ exitWith $ ExitFailure 3
--- | Build man pages from markdown sources in man/man1/.
+-- | Build man pages from markdown sources in man/
makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
-makeManPages _ flags _ buildInfo =
- mapM_ (makeManPage pandocPath (fromFlag $ buildVerbosity flags)) manpages
- where pandocPath = (buildDir buildInfo) </> "pandoc" </> "pandoc"
+makeManPages _ flags _ _ = do
+ let verbosity = fromFlag $ buildVerbosity flags
+ ds1 <- modifiedDependencies (manDir </> "man1" </> "pandoc.1")
+ ["README", manDir </> "man1" </> "pandoc.1.template"]
+ ds2 <- modifiedDependencies (manDir </> "man1" </> "markdown2pdf.1")
+ [manDir </> "man1" </> "markdown2pdf.1.md"]
+ ds3 <- modifiedDependencies (manDir </> "man5" </> "pandoc_markdown.5")
+ ["README", manDir </> "man5" </> "pandoc_markdown.5.template"]
+ let cmd = "runghc -package-conf=dist/package.conf.inplace MakeManPage.hs"
+ let cmd' = if verbosity == silent
+ then cmd
+ else cmd ++ " --verbose"
+ -- Don't run MakeManPage.hs unless we have to
+ unless (null ds1 && null ds2 && null ds3) $
+ runCommand cmd' >>= waitForProcess >>= exitWith
manpages :: [FilePath]
-manpages = ["pandoc.1", "markdown2pdf.1"]
+manpages = ["man1" </> "pandoc.1"
+ ,"man1" </> "markdown2pdf.1"
+ ,"man5" </> "pandoc_markdown.5"]
manDir :: FilePath
-manDir = "man" </> "man1"
-
--- | Build a man page from markdown source in man/man1.
-makeManPage :: FilePath -> Verbosity -> FilePath -> IO ()
-makeManPage pandoc verbosity manpage = do
- let page = manDir </> manpage
- let source = page <.> "md"
- modifiedDeps <- modifiedDependencies page [source]
- unless (null modifiedDeps) $ do
- ec <- runProcess pandoc ["-s", "-S", "-r", "markdown", "-w", "man",
- "--template=templates/man.template", "-o", page, source]
- Nothing Nothing Nothing Nothing (Just stderr) >>= waitForProcess
- case ec of
- ExitSuccess -> unless (verbosity == silent) $
- putStrLn $ "Created " ++ page
- ExitFailure n -> putStrLn ("Error creating " ++ page ++
- ". Exit code = " ++ show n) >> exitWith ec
+manDir = "man"
installScripts :: PackageDescription -> LocalBuildInfo
-> Verbosity -> CopyDest -> IO ()
@@ -86,7 +85,7 @@ installScripts pkg lbi verbosity copy =
installManpages :: PackageDescription -> LocalBuildInfo
-> Verbosity -> CopyDest -> IO ()
installManpages pkg lbi verbosity copy =
- copyFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy) </> "man1")
+ copyFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy))
(zip (repeat manDir) manpages)
-- | Returns a list of 'dependencies' that have been modified after 'file'.
diff --git a/changelog b/changelog
index ee7227ff1..b3283d297 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,412 @@
+pando (1.8.0.1)
+
+ * Revised Interact.hs so that it works with the CPP macros
+ in the UTF8 module.
+
+ * Revised Setup.hs so that we don't call MakeManPage.hs unless
+ the man pages are out of date.
+
+pandoc (1.8)
+
+ [new features]
+
+ * Support for citations using Andrea Rossato's `citeproc-hs` 0.3.
+ You can now write, for example,
+
+ Water is wet [see @doe99, pp. 33-35; also @smith04, ch. 1].
+
+ and, when you process your document using `pandoc`, specifying
+ a citation style using `--csl` and a bibliography using `--bibliography`,
+ the citation will be replaced by an appropriately formatted
+ citation, and a list of works cited will be added to the end
+ of the document.
+
+ This means that you can switch effortlessly between different citation
+ and bibliography styles, including footnote, numerical, and author-date
+ formats. The bibliography can be in any of the following formats: MODS,
+ BibTeX, BibLaTeX, RIS, EndNote, EndNote XML, ISI, MEDLINE, Copac, or JSON.
+ See the README for further details.
+
+ Citations are supported in the markdown reader, using a special
+ syntax, and in the LaTeX reader, using natbib or biblatex syntax.
+ (Thanks to Nathan Gass for the natbib and biblatex support.)
+
+ * New `textile` reader and writer. Thanks to Paul Rivier for contributing
+ the `textile` reader, an almost complete implementation of the textile
+ syntax used by the ruby [RedCloth library](http://redcloth.org/textile).
+ Resolves Issue #51.
+
+ * New `org` writer, for Emacs Org-mode, contributed by Puneeth Chaganti.
+
+ * New `json` reader and writer, for reading and writing a JSON
+ representation of the native Pandoc AST. These are much faster
+ than the `native` reader and writer, and should be used for
+ serializing Pandoc to text. To convert between the JSON representation
+ and native Pandoc, use `encodeJSON` and `decodeJSON` from
+ `Text.JSON.Generic`.
+
+ * A new `jsonFilter` function in `Text.Pandoc` makes it easy
+ to write scripts that transform a JSON-encoded pandoc document.
+ For example:
+
+ -- removelinks.hs - removes links from document
+ import Text.Pandoc
+ main = interact $ jsonFilter $ bottomUp removeLink
+ where removeLink (Link xs _) = Emph xs
+ removeLink x = x
+
+ To use this to remove links while translating markdown to LaTeX:
+
+ pandoc -t json | runghc removelinks.hs | pandoc -f json -t latex
+
+ * Attributes are now allowed in inline `Code` elements, for example:
+
+ In this code, `ulist ! [theclass "special"] << elts`{.haskell} is...
+
+ The attribute syntax is the same as for delimited code blocks.
+ `Code` inline has an extra argument place for attributes, just like
+ `CodeBlock`. Inline code will be highlighted in HTML output, if pandoc
+ is compiled with highlighting support. Resolves Issue #119.
+
+ * New `RawBlock` and `RawInline` elements (replacing `RawHtml`,
+ `HtmlInline`, and `TeX`) provide lots of flexibility in writing
+ scripts to transform Pandoc documents. Scripts can now change
+ how each element is rendered in each output format.
+
+ * You can now define LaTeX macros in markdown documents, and pandoc
+ will apply them to TeX math. For example,
+
+ \newcommand{\plus}[2]{#1 + #2}
+ $\plus{3}{4}$
+
+ yields `3+4`. Since the macros are applied in the reader, they
+ will work in every output format, not just LaTeX.
+
+ * LaTeX macros can also be used in LaTeX documents (both in math
+ and in non-math contexts).
+
+ * A new `--mathjax` option has been added for displaying
+ math in HTML using MathJax. Resolves issue #259.
+
+ * Footnotes are now supported in the RST reader. (Note, however,
+ that unlike docutils, pandoc ignores the numeral or symbol used in
+ the note; footnotes are put in an auto-numbered ordered list.)
+ Resolves Issue #258.
+
+ * A new `--normalize` option causes pandoc to normalize the AST
+ before writing the document. This means that, for example,
+ `*hi**there*` will be rendered as `<em>hithere</em>`
+ instead of `<em>hi</em><em>there</em>`. This is not the default,
+ because there is a significant performance penalty.
+
+ * A new `--chapters` command-line option causes headers
+ in DocBook, LaTeX, and ConTeXt to start with "chapter" (level one).
+ Resolves Issue #265.
+
+ * In DocBook output, `<chapter>` is now used for top-level
+ headers if the template contains `<book>`. Resolves Issue #265.
+
+ * A new `--listings` option in `pandoc` and `markdown2pdf` causes
+ the LaTeX writer to use the listings package for code blocks.
+ (Thanks to Josef Svennigsson for the pandoc patch, and Etienne
+ Millon for the markdown2pdf patch.)
+
+ * `markdown2pdf` now supports `--data-dir`.
+
+ * URLs in autolinks now have class "url" so they can be styled.
+
+ * Improved prettyprinting in most formats. Lines will be wrapped
+ more evenly and duplicate blank lines avoided.
+
+ * New `--columns` command-line option sets the column width for
+ line wrapping and relative width calculations for tables.
+
+ * Made `--smart` work in HTML, RST, and Textile readers, as well
+ as markdown.
+
+ * Added `--html5` option for HTML5 output.
+
+ * Added support for listings package in LaTeX reader
+ (Puneeth Chaganti).
+
+ * Added support for simple tables in the LaTeX reader.
+
+ * Added support for simple tables in the HTML reader.
+
+ * Significant performance improvements in many readers and writers.
+
+ [API and program changes]
+
+ * Moved `Text.Pandoc.Definition` from the `pandoc` package to a new
+ auxiliary package, `pandoc-types`. This will make it possible for other
+ programs to supply output in Pandoc format, without depending on the whole
+ pandoc package.
+
+ * Added `Attr` field to `Code`.
+
+ * Removed `RawHtml`, `HtmlInline`, and `TeX` elements; added generic
+ `RawBlock` and `RawInline`.
+
+ * Moved generic functions to `Text.Pandoc.Generic`. Deprecated
+ `processWith`, replacing it with two functions, `bottomUp` and `topDown`.
+ Removed previously deprecated functions `processPandoc` and `queryPandoc`.
+
+ * Added `Text.Pandoc.Builder`, for building `Pandoc` structures.
+
+ * `Text.Pandoc` now exports association lists `readers` and `writers`.
+
+ * Added `Text.Pandoc.Readers.Native`, which exports `readNative`.
+ `readNative` can now read full pandoc documents, block lists, blocks,
+ inline lists, or inlines. It will interpret `Str "hi"`
+ as if it were `Pandoc (Meta [] [] []) [Plain [Str "hi"]]`.
+ This should make testing easier.
+
+ * Removed deprecated `-C/--custom-header` option.
+ Use `--template` instead.
+
+ * `--biblio-file` has been replaced by `--bibliography`.
+ `--biblio-format` has been removed; pandoc now guesses the format
+ from the file extension (see README).
+
+ * pandoc will treat an argument as a URI only if it has an
+ `http(s)` scheme. Previously pandoc would treat some
+ Windows pathnames beginning with `C:/` as URIs.
+
+ * The `--sanitize-html` option and the `stateSanitize` field in
+ `ParserState` have been removed. Sanitization is better done in the
+ resulting HTML using `xss-sanitize`, which is based on pandoc's
+ sanitization, but improved.
+
+ * pandoc now adds a newline to the end of its output in fragment
+ mode (= not `--standalone`).
+
+ * Added support for `lang` in `html` tag in the HTML template,
+ so you can do `pandoc -s -V lang=es`, for example.
+
+ * `highlightHtml` in `Text.Pandoc.Highlighting` now takes
+ a boolean argument that selects between "inline" and
+ "block" HTML.
+
+ * `Text.Pandoc.Writers.RTF` now exports `rtfEmbedImage`.
+ Images are embedded in RTF output when possible (png, jpeg).
+ Resolves Issue #275.
+
+ * Added `Text.Pandoc.Pretty`. This is better suited for pandoc than the
+ `pretty` package. Changed all writers that used
+ `Text.PrettyPrint.HughesPJ` to use `Text.Pandoc.Pretty` instead.
+
+ * Rewrote `writeNative` using the new prettyprinting module. It is
+ now much faster. The output has been made more consistent and compressed.
+ `writeNative` is also now sensitive to writerStandalone`, and will simply
+ `print a block list if writerStandalone` is False.
+
+ * Removed `Text.Pandoc.Blocks`. `Text.Pandoc.Pretty` allows you to define
+ blocks and concatenate them, so a separate module is no longer needed.
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `writerColumns`, `writerChapters`, and `writerHtml5` to
+ `WriterOptions`.
+ + Added `normalize`.
+ + Removed unneeded prettyprinting functions:
+ `wrapped`, `wrapIfNeeded`, `wrappedTeX`, `wrapTeXIfNeeded`, `hang'`,
+ `BlockWrapper`, `wrappedBlocksToDoc`.
+ + Made `splitBy` take a test instead of an element.
+ + Added `findDataFile`, refactored `readDataFile`.
+ + Added `stringify`. Rewrote `inlineListToIdentifier` using `stringify`.
+ + Fixed `inlineListToIdentifier` to treat '\160' as ' '.
+
+ * `Text.Pandoc.Readers.HTML`:
+
+ + Removed `rawHtmlBlock`, `anyHtmlBlockTag`, `anyHtmlInlineTag`,
+ `anyHtmlTag`, `anyHtmlEndTag`, `htmlEndTag`, `extractTagType`,
+ `htmlBlockElement`, `htmlComment`
+ + Added `htmlTag`, `htmlInBalanced`, `isInlineTag`, `isBlockTag`,
+ `isTextTag`
+
+ * Moved `smartPunctuation` from `Text.Pandoc.Readers.Markdown`
+ to `Text.Pandoc.Readers.Parsing`, and parameterized it with
+ an inline parser.
+
+ * Ellipses are no longer allowed to contain spaces.
+ Previously we allowed '. . .', ' . . . ', etc. This caused
+ too many complications, and removed author's flexibility in
+ combining ellipses with spaces and periods.
+
+ * Allow linebreaks in URLs (treat as spaces). Also, a string of
+ consecutive spaces or tabs is now parsed as a single space. If you have
+ multiple spaces in your URL, use `%20%20`.
+
+ * `Text.Pandoc.Parsing`:
+
+ + Removed `refsMatch`.
+ + Hid `Key` constructor.
+ + Removed custom `Ord` and `Eq` instances for `Key`.
+ + Added `toKey` and `fromKey` to convert between `Key` and `[Inline]`.
+ + Generalized type on `readWith`.
+
+ * Small change in calculation of relative widths of table columns.
+ If the size of the header > the specified column width, use
+ the header size as 100% for purposes of calculating
+ relative widths of columns.
+
+ * Markdown writer now uses some pandoc-specific features when `--strict`
+ is not specified: `\` newline is used for a hard linebreak instead of
+ two spaces then a newline. And delimited code blocks are used when
+ there are attributes.
+
+ * HTML writer: improved gladTeX output by setting ENV appropriately
+ for display or inline math (Jonathan Daugherty).
+
+ * LaTeX writer: Use `\paragraph`, `\subparagraph` for level 4,5 headers.
+
+ * LaTeX reader:
+
+ + `\label{foo}` and `\ref{foo}` now become `{foo}` instead of `(foo)`.
+ + `\index{}` commands are skipped.
+
+ * Added `fontsize` variable to default LaTeX template.
+ This makes it easy to set the font size using `markdown2pdf`:
+ `markdown2pdf -V fontsize=12pt input.txt`.
+
+ * Fixed problem with strikeout in LaTeX headers when using
+ hyperref, by adding a command to the default LaTeX template
+ that disables `\sout` inside pdf strings. Thanks to Joost Kremers
+ for the fix.
+
+ * The `COLUMNS` environment variable no longer has any effect.
+
+ [under-the-hood improvements]
+
+ * Pandoc now compiles with GHC 7. (This alone leads to a
+ significant performance improvement, 15-20%.)
+
+ * Completely rewrote HTML reader using tagsoup as a lexer. The
+ new reader is faster and more accurate. Unlike the
+ old reader, it does not get bogged down on some input
+ (Issues #277, 255). And it handles namespaces in tags
+ (Issue #274).
+
+ * Replaced `escapeStringAsXML` with a faster version.
+
+ * Rewrote `spaceChar` and some other parsers in Text.Pandoc.Parsing
+ for a significant performance boost.
+
+ * Improved performance of all readers by rewriting parsers.
+
+ * Simplified Text.Pandoc.CharacterReferences by using
+ entity lookup functions from TagSoup.
+
+ * `Text.Pandoc.UTF8` now uses the unicode-aware IO functions
+ from `System.IO` if base >= 4.2. This gives support for
+ windows line endings on windows.
+
+ * Remove duplications in documentation by generating the
+ pandoc man page from README, using `MakeManPage.hs`.
+
+ * README now includes a full description of markdown syntax,
+ including non-pandoc-specific parts. A new `pandoc_markdown`
+ man page is extracted from this, so you can look up markdown
+ syntax by doing `man pandoc_markdown`.
+
+ * Completely revised test framework (with help from Nathan Gass).
+ The new test framework is built when the `tests` Cabal flag is set. It
+ includes the old integration tests, but also some new unit and quickcheck
+ tests. Test output has been much improved, and you can now specify a glob
+ pattern after `cabal test` to indicate which tests should be run;
+ for example `cabal test citations` will run all the citation tests.
+
+ * Added a shell script, `stripansi.sh`, for filtering ANSI control
+ sequences from test output: `cabal test | ./stripansi.sh > test.log`.
+
+ * Added `Interact.hs` to make it easier to use ghci while developing.
+ `Interact.hs` loads `ghci` from the `src` directory, specifying
+ all the options needed to load pandoc modules (including
+ specific package dependencies, which it gets by parsing
+ dist/setup-config).
+
+ * Added `Benchmark.hs`, testing all readers + writers using criterion.
+
+ * Added `stats.sh`, to make it easier to collect and archive
+ benchmark and lines-of-code stats.
+
+ * Added upper bounds to all cabal dependencies.
+
+ * Include man pages in extra-source-files. This allows users to
+ install pandoc from the tarball without needing to build the man
+ pages.
+
+ [bug fixes]
+
+ * Filenames are encoded as UTF8. Resolves Issue #252.
+
+ * Handle curly quotes better in `--smart` mode. Previously, curly quotes
+ were just parsed literally, leading to problems in some output formats.
+ Now they are parsed as `Quoted` inlines, if `--smart` is specified.
+ Resolves Issue #270.
+
+ * Text.Pandoc.Parsing: Fixed bug in grid table parser.
+ Spaces at end of line were not being stripped properly,
+ resulting in unintended LineBreaks.
+
+ * Markdown reader:
+
+ + Allow HTML comments as inline elements in markdown.
+ So, `aaa <!-- comment --> bbb` can be a single paragraph.
+ + Fixed superscripts with links: `^[link](/foo)^` gets
+ recognized as a superscripted link, not an inline note followed by
+ garbage.
+ + Fixed regression, making markdown reference keys case-insensitive again.
+ Resolves Issue #272.
+ + Properly handle abbreviations (like `Mr.`) at the end of a line.
+ + Better handling of intraword underscores, avoiding exponential
+ slowdowns in some cases. Resolves Issue #182.
+ + Fixed bug in alignments in tables with blank rows in the header.
+
+ * RST reader:
+
+ + Field lists now allow spaces in field names, and
+ block content in field values. (Thanks to Lachlan Musicman
+ for pointing out the bug.)
+ + Definition list items are now always `Para` instead of
+ `Plain`, matching behavior of `rst2xml.py`.
+ + In image blocks, the description is parsed properly and
+ used for the alt attribute, not also the title.
+ + Skip blank lines at beginning of file. Resolves
+ Debian #611328.
+
+ * LaTeX reader:
+
+ + Improved parsing of preamble.
+ Previously you'd get unexpected behavior on a document that
+ contained `\begin{document}` in, say, a verbatim block.
+ + Allow spaces between `\begin` or `\end` and `{`.
+ + Support `\L` and `\l`.
+ + Skip comments inside paragraphs.
+
+ * LaTeX writer:
+
+ + Escape strings in `\href{..}`.
+ + In nonsimple tables, put cells in `\parbox`.
+
+ * OpenDocument writer: don't print raw TeX.
+
+ * Markdown writer:
+
+ + Fixed bug in `Image`. URI was getting unescaped twice!
+ + Avoid printing extra blank lines at the end if there are
+ no notes or references.
+
+ * LaTeX and ConTeXt: Escape `[` and `]` as `{[}` and `{]}`.
+ This avoids unwanted interpretation as an optional argument.
+
+ * ConTeXt writer: Fixed problem with inline code. Previously
+ `}` would be rendered `\type{}}`. Now we check the string for '}' and '{'.
+ If it contains neither, use `\type{}`; otherwise use `\mono{}`
+ with an escaped version of the string.
+
+ * `:` now allowed in HTML tags. Resolves Issue #274.
+
pandoc (1.6)
[ John MacFarlane ]
@@ -408,7 +817,8 @@ pandoc (1.5)
+ Removed stLink, link template variable. Reason: we now always
include hyperref in the template.
- * Latex template:
+ * LaTeX template:
+
+ Only show \author if there are some.
+ Always include hyperref package. It is used not just for links but
for toc, section heading bookmarks, footnotes, etc. Also added
diff --git a/default.csl b/default.csl
new file mode 100644
index 000000000..f16f82305
--- /dev/null
+++ b/default.csl
@@ -0,0 +1,369 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" page-range-format="chicago">
+ <info>
+ <title>Chicago Manual of Style (Author-Date format)</title>
+ <id>http://www.zotero.org/styles/chicago-author-date</id>
+ <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>
+ <author>
+ <name>Julian Onions</name>
+ <email>julian.onions@gmail.com</email>
+ </author>
+ <category citation-format="author-date"/>
+ <category field="generic-base"/>
+ <updated>2009-12-04T20:22:16+00:00</updated>
+ <summary>The author-date variant of the Chicago style</summary>
+ <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
+ </info>
+ <macro name="secondary-contributors">
+ <choose>
+ <if match="none" type="chapter">
+ <group delimiter=". ">
+ <choose>
+ <if variable="author">
+ <names variable="editor">
+ <label form="verb-short" prefix=" " suffix=". " text-case="capitalize-first" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ <choose>
+ <if match="any" variable="author editor">
+ <names variable="translator">
+ <label form="verb-short" prefix=" " suffix=". " text-case="capitalize-first" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="container-contributors">
+ <choose>
+ <if type="chapter">
+ <group delimiter=", " prefix=",">
+ <choose>
+ <if variable="author">
+ <names variable="editor">
+ <label form="verb-short" prefix=" " suffix=". " text-case="lowercase" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ <choose>
+ <if match="any" variable="author editor">
+ <names variable="translator">
+ <label form="verb-short" prefix=" " suffix=". " text-case="lowercase" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="anon">
+ <choose>
+ <if match="none" variable="author editor translator">
+ <text form="short" term="anonymous" text-case="capitalize-first" />
+ </if>
+ </choose>
+ </macro>
+ <macro name="editor">
+ <names variable="editor">
+ <name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
+ <label form="short" prefix=", " suffix="." />
+ </names>
+ </macro>
+ <macro name="translator">
+ <names variable="translator">
+ <name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
+ <label form="verb-short" prefix=", " suffix="." />
+ </names>
+ </macro>
+ <macro name="recipient">
+ <choose>
+ <if type="personal_communication">
+ <choose>
+ <if variable="genre">
+ <text text-case="capitalize-first" variable="genre" />
+ </if>
+ <else>
+ <text term="letter" text-case="capitalize-first" />
+ </else>
+ </choose>
+ </if>
+ </choose>
+ <names delimiter=", " variable="recipient">
+ <label form="verb" prefix=" " suffix=" " text-case="lowercase" />
+ <name and="text" delimiter=", " />
+ </names>
+ </macro>
+ <macro name="contributors">
+ <names variable="author">
+ <name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
+ <label form="verb-short" prefix=", " suffix="." text-case="lowercase" />
+ <substitute>
+ <text macro="editor" />
+ <text macro="translator" />
+ </substitute>
+ </names>
+ <text macro="anon" />
+ <text macro="recipient" />
+ </macro>
+ <macro name="contributors-short">
+ <names variable="author">
+ <name and="text" delimiter=", " form="short" />
+ <substitute>
+ <names variable="editor" />
+ <names variable="translator" />
+ </substitute>
+ </names>
+ <text macro="anon" />
+ </macro>
+ <macro name="interviewer">
+ <names delimiter=", " variable="interviewer">
+ <label form="verb" prefix=" " suffix=" " text-case="capitalize-first" />
+ <name and="text" delimiter=", " />
+ </names>
+ </macro>
+ <macro name="archive">
+ <group delimiter=". ">
+ <text text-case="capitalize-first" variable="archive_location" />
+ <text variable="archive" />
+ <text variable="archive-place" />
+ </group>
+ </macro>
+ <macro name="access">
+ <group delimiter=". ">
+ <choose>
+ <if match="any" type="graphic report">
+ <text macro="archive" />
+ </if>
+ <else-if match="none" type="book thesis chapter article-journal article-newspaper article-magazine">
+ <text macro="archive" />
+ </else-if>
+ </choose>
+ <text prefix="doi:" variable="DOI" />
+ <text variable="URL" />
+ </group>
+ </macro>
+ <macro name="title">
+ <choose>
+ <if match="none" variable="title">
+ <choose>
+ <if match="none" type="personal_communication">
+ <text text-case="capitalize-first" variable="genre" />
+ </if>
+ </choose>
+ </if>
+ <else-if type="book">
+ <text font-style="italic" variable="title" />
+ </else-if>
+ <else>
+ <text variable="title" />
+ </else>
+ </choose>
+ </macro>
+ <macro name="edition">
+ <choose>
+ <if match="any" type="book chapter">
+ <choose>
+ <if is-numeric="edition">
+ <group delimiter=" ">
+ <number form="ordinal" variable="edition" />
+ <text form="short" suffix="." term="edition" />
+ </group>
+ </if>
+ <else>
+ <text suffix="." variable="edition" />
+ </else>
+ </choose>
+ </if>
+ </choose>
+ </macro>
+ <macro name="locators">
+ <choose>
+ <if type="article-journal">
+ <text prefix=" " variable="volume" />
+ <text prefix=", no. " variable="issue" />
+ </if>
+ <else-if type="book">
+ <group delimiter=". " prefix=". ">
+ <group>
+ <text form="short" suffix=". " term="volume" text-case="capitalize-first" />
+ <number form="numeric" variable="volume" />
+ </group>
+ <group>
+ <number form="numeric" variable="number-of-volumes" />
+ <text form="short" plural="true" prefix=" " suffix="." term="volume" />
+ </group>
+ </group>
+ </else-if>
+ </choose>
+ </macro>
+ <macro name="locators-chapter">
+ <choose>
+ <if type="chapter">
+ <group prefix=", ">
+ <text suffix=":" variable="volume" />
+ <text variable="page" />
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="locators-article">
+ <choose>
+ <if type="article-newspaper">
+ <group delimiter=", " prefix=", ">
+ <group>
+ <text suffix=" " variable="edition" />
+ <text prefix=" " term="edition" />
+ </group>
+ <group>
+ <text form="short" suffix=". " term="section" />
+ <text variable="section" />
+ </group>
+ </group>
+ </if>
+ <else-if type="article-journal">
+ <text prefix=": " variable="page" />
+ </else-if>
+ </choose>
+ </macro>
+ <macro name="point-locators">
+ <group>
+ <choose>
+ <if locator="page" match="none">
+ <label form="short" suffix=" " variable="locator" />
+ </if>
+ </choose>
+ <text variable="locator" />
+ </group>
+ </macro>
+ <macro name="container-prefix">
+ <text term="in" text-case="capitalize-first" />
+ </macro>
+ <macro name="container-title">
+ <choose>
+ <if type="chapter">
+ <text macro="container-prefix" suffix=" " />
+ </if>
+ </choose>
+ <text font-style="italic" variable="container-title" />
+ </macro>
+ <macro name="publisher">
+ <group delimiter=": ">
+ <text variable="publisher-place" />
+ <text variable="publisher" />
+ </group>
+ </macro>
+ <macro name="date">
+ <date variable="issued">
+ <date-part name="year" />
+ </date>
+ </macro>
+ <macro name="day-month">
+ <date variable="issued">
+ <date-part name="month" />
+ <date-part name="day" prefix=" " />
+ </date>
+ </macro>
+ <macro name="collection-title">
+ <text variable="collection-title" />
+ <text prefix=" " variable="collection-number" />
+ </macro>
+ <macro name="event">
+ <group>
+ <text suffix=" " term="presented at" />
+ <text variable="event" />
+ </group>
+ </macro>
+ <macro name="description">
+ <group delimiter=". ">
+ <text macro="interviewer" />
+ <text text-case="capitalize-first" variable="medium" />
+ </group>
+ <choose>
+ <if match="none" variable="title"> </if>
+ <else-if type="thesis"> </else-if>
+ <else>
+ <text prefix=". " text-case="capitalize-first" variable="genre" />
+ </else>
+ </choose>
+ </macro>
+ <macro name="issue">
+ <choose>
+ <if type="article-journal">
+ <text macro="day-month" prefix=" (" suffix=")" />
+ </if>
+ <else-if type="speech">
+ <group delimiter=", " prefix=" ">
+ <text macro="event" />
+ <text macro="day-month" />
+ <text variable="event-place" />
+ </group>
+ </else-if>
+ <else-if match="any" type="article-newspaper article-magazine">
+ <text macro="day-month" prefix=", " />
+ </else-if>
+ <else>
+ <group delimiter=", " prefix=". ">
+ <choose>
+ <if type="thesis">
+ <text text-case="capitalize-first" variable="genre" />
+ </if>
+ </choose>
+ <text macro="publisher" />
+ <text macro="day-month" />
+ </group>
+ </else>
+ </choose>
+ </macro>
+ <citation
+ disambiguate-add-givenname="true"
+ disambiguate-add-names="true"
+ disambiguate-add-year-suffix="true"
+ et-al-min="4"
+ et-al-subsequent-min="4"
+ et-al-subsequent-use-first="1"
+ et-al-use-first="1">
+ <layout delimiter="; " prefix="(" suffix=")">
+ <group delimiter=", ">
+ <group delimiter=" ">
+ <text macro="contributors-short" />
+ <text macro="date" />
+ </group>
+ <text macro="point-locators" />
+ </group>
+ </layout>
+ </citation>
+ <bibliography
+ entry-spacing="0"
+ et-al-min="11"
+ et-al-use-first="7"
+ hanging-indent="true"
+ subsequent-author-substitute="---">
+ <sort>
+ <key macro="contributors" />
+ <key variable="issued" />
+ <key variable="title" />
+ </sort>
+ <layout suffix=".">
+ <text macro="contributors" suffix=". " />
+ <text macro="date" suffix=". " />
+ <text macro="title" />
+ <text macro="description" />
+ <text macro="secondary-contributors" prefix=". " />
+ <text macro="container-title" prefix=". " />
+ <text macro="container-contributors" />
+ <text macro="locators-chapter" />
+ <text macro="edition" prefix=". " />
+ <text macro="locators" />
+ <text macro="collection-title" prefix=". " />
+ <text macro="issue" />
+ <text macro="locators-article" />
+ <text macro="access" prefix=". " />
+ </layout>
+ </bibliography>
+</style>
diff --git a/man/man1/markdown2pdf.1 b/man/man1/markdown2pdf.1
new file mode 100644
index 000000000..11c0e7ce7
--- /dev/null
+++ b/man/man1/markdown2pdf.1
@@ -0,0 +1,165 @@
+.TH MARKDOWN2PDF 1 "January 29, 2011" "Pandoc User Manuals"
+.SH NAME
+.PP
+markdown2pdf - converts markdown-formatted text to PDF, using pdflatex
+.SH SYNOPSIS
+.PP
+markdown2pdf [\f[I]options\f[]] [\f[I]input-file\f[]]...
+.SH DESCRIPTION
+.PP
+\f[C]markdown2pdf\f[] converts \f[I]input-file\f[] (or text from
+standard input) from markdown-formatted plain text to PDF, using
+\f[C]pandoc\f[] and \f[C]pdflatex\f[].
+If no output filename is specified (using the \f[C]-o\f[] option), the
+name of the output file is derived from the input file; thus, for
+example, if the input file is \f[I]hello.txt\f[], the output file will
+be \f[I]hello.pdf\f[].
+If the input is read from STDIN and no output filename is specified, the
+output file will be named \f[I]stdin.pdf\f[].
+If multiple input files are specified, they will be concatenated before
+conversion, and the name of the output file will be derived from the
+first input file.
+.PP
+Input is assumed to be in the UTF-8 character encoding.
+If your local character encoding is not UTF-8, you should pipe input
+through \f[C]iconv\f[]:
+.IP
+.nf
+\f[C]
+iconv\ -t\ utf-8\ input.txt\ |\ markdown2pdf
+\f[]
+.fi
+.PP
+\f[C]markdown2pdf\f[] assumes that the \f[C]unicode\f[], \f[C]array\f[],
+\f[C]fancyvrb\f[], \f[C]graphicx\f[], and \f[C]ulem\f[] packages are in
+latex\[aq]s search path.
+If these packages are not included in your latex setup, they can be
+obtained from \f[C]http://ctan.org\f[].
+.SH OPTIONS
+.TP
+.B -o \f[I]FILE\f[], --output=\f[I]FILE\f[]
+Write output to \f[I]FILE\f[].
+.RS
+.RE
+.TP
+.B --strict
+Use strict markdown syntax, with no extensions or variants.
+.RS
+.RE
+.TP
+.B --xetex
+Use xelatex instead of pdflatex to create the PDF.
+.RS
+.RE
+.TP
+.B -N, --number-sections
+Number section headings in LaTeX output.
+(Default is not to number them.)
+.RS
+.RE
+.TP
+.B --listings
+Use listings package for LaTeX code blocks
+.RS
+.RE
+.TP
+.B --template=\f[I]FILE\f[]
+Use \f[I]FILE\f[] as a custom template for the generated document.
+Implies \f[C]-s\f[].
+See the section TEMPLATES in \f[C]pandoc\f[](1) for information about
+template syntax.
+Use \f[C]pandoc\ -D\ latex\f[] to print the default LaTeX template.
+.RS
+.RE
+.TP
+.B -V KEY=VAL, --variable=\f[I]KEY:VAL\f[]
+Set the template variable KEY to the value VAL when rendering the
+document in standalone mode.
+Use this to set the font size when using the default LaTeX template:
+\f[C]-V\ fontsize=12pt\f[].
+.RS
+.RE
+.TP
+.B -H \f[I]FILE\f[], --include-in-header=\f[I]FILE\f[]
+Include (LaTeX) contents of \f[I]FILE\f[] at the end of the header.
+Implies \f[C]-s\f[].
+.RS
+.RE
+.TP
+.B -B \f[I]FILE\f[], --include-before-body=\f[I]FILE\f[]
+Include (LaTeX) contents of \f[I]FILE\f[] at the beginning of the
+document body.
+.RS
+.RE
+.TP
+.B -A \f[I]FILE\f[], --include-after-body=\f[I]FILE\f[]
+Include (LaTeX) contents of \f[I]FILE\f[] at the end of the document
+body.
+.RS
+.RE
+.TP
+.B --bibliography=\f[I]FILE\f[]
+Specify bibliography database to be used in resolving citations.
+The database type will be determined from the extension of
+\f[I]FILE\f[], which may be \f[C].xml\f[] (MODS format), \f[C].bib\f[]
+(BibTeX format), or \f[C].json\f[] (citeproc JSON).
+.RS
+.RE
+.TP
+.B --csl=\f[I]FILE\f[]
+Specify CSL style to be used in formatting citations and the
+bibliography.
+If \f[I]FILE\f[] is not found, pandoc will look for it in
+.RS
+.IP
+.nf
+\f[C]
+$HOME/.csl
+\f[]
+.fi
+.PP
+in unix and
+.IP
+.nf
+\f[C]
+C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\csl
+\f[]
+.fi
+.PP
+in Windows.
+If the \f[C]--csl\f[] option is not specified, pandoc will use a default
+style: either \f[C]default.csl\f[] in the user data directory (see
+\f[C]--data-dir\f[]), or, if that is not present, the Chicago
+author-date style.
+.RE
+.TP
+.B --data-dir\f[I]=DIRECTORY\f[]
+Specify the user data directory to search for pandoc data files.
+If this option is not specified, the default user data directory will be
+used:
+.RS
+.IP
+.nf
+\f[C]
+$HOME/.pandoc
+\f[]
+.fi
+.PP
+in unix and
+.IP
+.nf
+\f[C]
+C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\pandoc
+\f[]
+.fi
+.PP
+in Windows.
+A \f[C]reference.odt\f[], \f[C]epub.css\f[], \f[C]templates\f[]
+directory, or \f[C]s5\f[] directory placed in this directory will
+override pandoc\[aq]s normal defaults.
+.RE
+.SH SEE ALSO
+.PP
+\f[C]pandoc\f[](1), \f[C]pdflatex\f[](1)
+.SH AUTHORS
+John MacFarlane, Paulo Tanimoto, and Recai Oktas.
diff --git a/man/man1/markdown2pdf.1.md b/man/man1/markdown2pdf.1.md
index 3947ef8da..efbdc8184 100644
--- a/man/man1/markdown2pdf.1.md
+++ b/man/man1/markdown2pdf.1.md
@@ -1,6 +1,6 @@
% MARKDOWN2PDF(1) Pandoc User Manuals
-% John MacFarlane and Recai Oktas
-% January 8, 2008
+% John MacFarlane, Paulo Tanimoto, and Recai Oktas
+% January 29, 2011
# NAME
@@ -48,6 +48,9 @@ packages are not included in your latex setup, they can be obtained from
-N, \--number-sections
: Number section headings in LaTeX output. (Default is not to number them.)
+\--listings
+: Use listings package for LaTeX code blocks
+
\--template=*FILE*
: Use *FILE* as a custom template for the generated document. Implies
`-s`. See the section TEMPLATES in `pandoc`(1) for information about
@@ -56,10 +59,8 @@ packages are not included in your latex setup, they can be obtained from
-V KEY=VAL, \--variable=*KEY:VAL*
: Set the template variable KEY to the value VAL when rendering the
- document in standalone mode. This is only useful when the
- `--template` option is used to specify a custom template, since
- pandoc automatically sets the variables used in the default
- templates.
+ document in standalone mode. Use this to set the font size when
+ using the default LaTeX template: `-V fontsize=12pt`.
-H *FILE*, \--include-in-header=*FILE*
: Include (LaTeX) contents of *FILE* at the end of the header. Implies
@@ -71,10 +72,46 @@ packages are not included in your latex setup, they can be obtained from
-A *FILE*, \--include-after-body=*FILE*
: Include (LaTeX) contents of *FILE* at the end of the document body.
--C *FILE*, \--custom-header=*FILE*
-: Use contents of *FILE* as the document header. *Note: This option is
- deprecated. Users should transition to using `--template` instead.*
+\--bibliography=*FILE*
+: Specify bibliography database to be used in resolving
+ citations. The database type will be determined from the
+ extension of *FILE*, which may be `.xml` (MODS format),
+ `.bib` (BibTeX format), or `.json` (citeproc JSON).
+
+\--csl=*FILE*
+: Specify [CSL] style to be used in formatting citations and
+ the bibliography. If *FILE* is not found, pandoc will look
+ for it in
+
+ $HOME/.csl
+
+ in unix and
+
+ C:\Documents And Settings\USERNAME\Application Data\csl
+
+ in Windows. If the `--csl` option is not specified, pandoc
+ will use a default style: either `default.csl` in the
+ user data directory (see `--data-dir`), or, if that is
+ not present, the Chicago author-date style.
+
+\--data-dir*=DIRECTORY*
+: Specify the user data directory to search for pandoc data files.
+ If this option is not specified, the default user data directory
+ will be used:
+
+ $HOME/.pandoc
+
+ in unix and
+
+ C:\Documents And Settings\USERNAME\Application Data\pandoc
+
+ in Windows. A `reference.odt`, `epub.css`, `templates` directory,
+ or `s5` directory placed in this directory will override pandoc's
+ normal defaults.
# SEE ALSO
`pandoc`(1), `pdflatex`(1)
+
+[CSL]: CitationStyles.org
+
diff --git a/man/man1/pandoc.1 b/man/man1/pandoc.1
new file mode 100644
index 000000000..a9fcfb08d
--- /dev/null
+++ b/man/man1/pandoc.1
@@ -0,0 +1,905 @@
+.TH PANDOC 1 "January 29, 2011" "Pandoc"
+.SH NAME
+pandoc - general markup converter
+.SH SYNOPSIS
+.PP
+pandoc [\f[I]options\f[]] [\f[I]input-file\f[]]...
+.SH DESCRIPTION
+.PP
+Pandoc is a Haskell library for converting from one markup format to
+another, and a command-line tool that uses this library.
+It can read markdown and (subsets of) Textile, reStructuredText, HTML,
+and LaTeX; and it can write plain text, markdown, reStructuredText,
+HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU
+Texinfo, MediaWiki markup, EPUB, Textile, groff man pages, Emacs
+Org-Mode, and Slidy or S5 HTML slide shows.
+.PP
+Pandoc\[aq]s enhanced version of markdown includes syntax for footnotes,
+tables, flexible ordered lists, definition lists, delimited code blocks,
+superscript, subscript, strikeout, title blocks, automatic tables of
+contents, embedded LaTeX math, citations, and markdown inside HTML block
+elements.
+(These enhancements, described below under Pandoc\[aq]s markdown, can be
+disabled using the \f[C]--strict\f[] option.)
+.PP
+In contrast to most existing tools for converting markdown to HTML,
+which use regex substitutions, Pandoc has a modular design: it consists
+of a set of readers, which parse text in a given format and produce a
+native representation of the document, and a set of writers, which
+convert this native representation into a target format.
+Thus, adding an input or output format requires only adding a reader or
+writer.
+.SS Using Pandoc
+.PP
+If no \f[I]input-file\f[] is specified, input is read from
+\f[I]stdin\f[].
+Otherwise, the \f[I]input-files\f[] are concatenated (with a blank line
+between each) and used as input.
+Output goes to \f[I]stdout\f[] by default (though output to
+\f[I]stdout\f[] is disabled for the \f[C]odt\f[] and \f[C]epub\f[]
+output formats).
+For output to a file, use the \f[C]-o\f[] option:
+.IP
+.nf
+\f[C]
+pandoc\ -o\ output.html\ input.txt
+\f[]
+.fi
+.PP
+Instead of a file, an absolute URI may be given.
+In this case pandoc will fetch the content using HTTP:
+.IP
+.nf
+\f[C]
+pandoc\ -f\ html\ -t\ markdown\ http://www.fsf.org
+\f[]
+.fi
+.PP
+If multiple input files are given, \f[C]pandoc\f[] will concatenate them
+all (with blank lines between them) before parsing.
+.PP
+The format of the input and output can be specified explicitly using
+command-line options.
+The input format can be specified using the \f[C]-r/--read\f[] or
+\f[C]-f/--from\f[] options, the output format using the
+\f[C]-w/--write\f[] or \f[C]-t/--to\f[] options.
+Thus, to convert \f[C]hello.txt\f[] from markdown to LaTeX, you could
+type:
+.IP
+.nf
+\f[C]
+pandoc\ -f\ markdown\ -t\ latex\ hello.txt
+\f[]
+.fi
+.PP
+To convert \f[C]hello.html\f[] from html to markdown:
+.IP
+.nf
+\f[C]
+pandoc\ -f\ html\ -t\ markdown\ hello.html
+\f[]
+.fi
+.PP
+Supported output formats are listed below under the \f[C]-t/--to\f[]
+option.
+Supported input formats are listed below under the \f[C]-f/--from\f[]
+option.
+Note that the \f[C]rst\f[], \f[C]textile\f[], \f[C]latex\f[], and
+\f[C]html\f[] readers are not complete; there are some constructs that
+they do not parse.
+.PP
+If the input or output format is not specified explicitly,
+\f[C]pandoc\f[] will attempt to guess it from the extensions of the
+input and output filenames.
+Thus, for example,
+.IP
+.nf
+\f[C]
+pandoc\ -o\ hello.tex\ hello.txt
+\f[]
+.fi
+.PP
+will convert \f[C]hello.txt\f[] from markdown to LaTeX.
+If no output file is specified (so that output goes to \f[I]stdout\f[]),
+or if the output file\[aq]s extension is unknown, the output format will
+default to HTML.
+If no input file is specified (so that input comes from \f[I]stdin\f[]),
+or if the input files\[aq] extensions are unknown, the input format will
+be assumed to be markdown unless explicitly specified.
+.PP
+Pandoc uses the UTF-8 character encoding for both input and output.
+If your local character encoding is not UTF-8, you should pipe input and
+output through \f[C]iconv\f[]:
+.IP
+.nf
+\f[C]
+iconv\ -t\ utf-8\ input.txt\ |\ pandoc\ |\ iconv\ -f\ utf-8
+\f[]
+.fi
+.SH OPTIONS
+.TP
+.B \f[C]-f\f[] \f[I]FORMAT\f[], \f[C]-r\f[] \f[I]FORMAT\f[],
+\f[C]--from=\f[]\f[I]FORMAT\f[], \f[C]--read=\f[]\f[I]FORMAT\f[]
+Specify input format.
+\f[I]FORMAT\f[] can be \f[C]native\f[] (native Haskell), \f[C]json\f[]
+(JSON version of native AST), \f[C]markdown\f[] (markdown),
+\f[C]textile\f[] (Textile), \f[C]rst\f[] (reStructuredText),
+\f[C]html\f[] (HTML), or \f[C]latex\f[] (LaTeX).
+If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[], or
+\f[C]latex\f[], the input will be treated as literate Haskell source:
+see Literate Haskell support, below.
+.RS
+.RE
+.TP
+.B \f[C]-t\f[] \f[I]FORMAT\f[], \f[C]-w\f[] \f[I]FORMAT\f[],
+\f[C]--to=\f[]\f[I]FORMAT\f[], \f[C]--write=\f[]\f[I]FORMAT\f[]
+Specify output format.
+\f[I]FORMAT\f[] can be \f[C]native\f[] (native Haskell), \f[C]json\f[]
+(JSON version of native AST), \f[C]plain\f[] (plain text),
+\f[C]markdown\f[] (markdown), \f[C]rst\f[] (reStructuredText),
+\f[C]html\f[] (HTML), \f[C]latex\f[] (LaTeX), \f[C]context\f[]
+(ConTeXt), \f[C]man\f[] (groff man), \f[C]mediawiki\f[] (MediaWiki
+markup), \f[C]textile\f[] (Textile), \f[C]org\f[] (Emacs Org-Mode),
+\f[C]texinfo\f[] (GNU Texinfo), \f[C]docbook\f[] (DocBook XML),
+\f[C]opendocument\f[] (OpenDocument XML), \f[C]odt\f[] (OpenOffice text
+document), \f[C]epub\f[] (EPUB book), \f[C]slidy\f[] (Slidy HTML and
+javascript slide show), \f[C]s5\f[] (S5 HTML and javascript slide show),
+or \f[C]rtf\f[] (rich text format).
+Note that \f[C]odt\f[] and \f[C]epub\f[] output will not be directed to
+\f[I]stdout\f[]; an output filename must be specified using the
+\f[C]-o/--output\f[] option.
+If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[],
+\f[C]latex\f[], or \f[C]html\f[], the output will be rendered as
+literate Haskell source: see Literate Haskell support, below.
+.RS
+.RE
+.TP
+.B \f[C]-s\f[], \f[C]--standalone\f[]
+Produce output with an appropriate header and footer (e.g.
+a standalone HTML, LaTeX, or RTF file, not a fragment).
+.RS
+.RE
+.TP
+.B \f[C]-o\f[] \f[I]FILE\f[], \f[C]--output=\f[]\f[I]FILE\f[]
+Write output to \f[I]FILE\f[] instead of \f[I]stdout\f[].
+If \f[I]FILE\f[] is \f[C]-\f[], output will go to \f[I]stdout\f[].
+(Exception: if the output format is \f[C]odt\f[] or \f[C]epub\f[],
+output to stdout is disabled.)
+.RS
+.RE
+.TP
+.B \f[C]-p\f[], \f[C]--preserve-tabs\f[]
+Preserve tabs instead of converting them to spaces (the default).
+.RS
+.RE
+.TP
+.B \f[C]--tab-stop=\f[]\f[I]NUMBER\f[]
+Specify the number of spaces per tab (default is 4).
+.RS
+.RE
+.TP
+.B \f[C]--strict\f[]
+Use strict markdown syntax, with no pandoc extensions or variants.
+When the input format is HTML, this means that constructs that have no
+equivalents in standard markdown (e.g.
+definition lists or strikeout text) will be parsed as raw HTML.
+.RS
+.RE
+.TP
+.B \f[C]--normalize\f[]
+Normalize the document after reading: merge adjacent \f[C]Str\f[] or
+\f[C]Emph\f[] elements, for example, and remove repeated
+\f[C]Space\f[]s.
+.RS
+.RE
+.TP
+.B \f[C]--reference-links\f[]
+Use reference-style links, rather than inline links, in writing markdown
+or reStructuredText.
+By default inline links are used.
+.RS
+.RE
+.TP
+.B \f[C]-R\f[], \f[C]--parse-raw\f[]
+Parse untranslatable HTML codes and LaTeX environments as raw HTML or
+LaTeX, instead of ignoring them.
+Affects only HTML and LaTeX input.
+Raw HTML can be printed in markdown, reStructuredText, HTML, Slidy, and
+S5 output; raw LaTeX can be printed in markdown, reStructuredText,
+LaTeX, and ConTeXt output.
+The default is for the readers to omit untranslatable HTML codes and
+LaTeX environments.
+(The LaTeX reader does pass through untranslatable LaTeX
+\f[I]commands\f[], even if \f[C]-R\f[] is not specified.)
+.RS
+.RE
+.TP
+.B \f[C]-S\f[], \f[C]--smart\f[]
+Produce typographically correct output, converting straight quotes to
+curly quotes, \f[C]---\f[] and \f[C]--\f[] to dashes, ande \f[C]...\f[]
+to ellipses.
+Nonbreaking spaces are inserted after certain abbreviations, such as
+"Mr." (Note: This option is significant only when the input format is
+\f[C]markdown\f[] or \f[C]textile\f[].
+It is selected automatically when the input format is \f[C]textile\f[]
+or the output format is \f[C]latex\f[] or \f[C]context\f[].)
+.RS
+.RE
+.TP
+.B \f[C]-5\f[], \f[C]--html5\f[]
+Produce HTML5 instead of HTML4.
+This option has no effect for writers other than \f[C]html\f[].
+.RS
+.RE
+.TP
+.B \f[C]-m\f[] \f[I]URL\f[], \f[C]--latexmathml=\f[]\f[I]URL\f[]
+Use the LaTeXMathML script to display embedded TeX math in HTML output.
+To insert a link to a local copy of the \f[C]LaTeXMathML.js\f[] script,
+provide a \f[I]URL\f[].
+If no \f[I]URL\f[] is provided, the contents of the script will be
+inserted directly into the HTML header, preserving portability at the
+price of efficiency.
+If you plan to use math on several pages, it is much better to link to a
+copy of the script, so it can be cached.
+.RS
+.RE
+.TP
+.B \f[C]--mathml\f[]
+Convert TeX math to MathML.
+In standalone mode, a small javascript will be inserted that allows the
+MathML to be viewed on some browsers.
+.RS
+.RE
+.TP
+.B \f[C]--jsmath=\f[]\f[I]URL\f[]
+Use jsMath to display embedded TeX math in HTML output.
+The \f[I]URL\f[] should point to the jsMath load script (e.g.
+\f[C]jsMath/easy/load.js\f[]); if provided, it will be linked to in the
+header of standalone HTML documents.
+.RS
+.RE
+.TP
+.B \f[C]--mathjax=\f[]\f[I]URL\f[]
+Use MathJax to display embedded TeX math in HTML output.
+The \f[I]URL\f[] should point to the \f[C]MathJax.js\f[] load script.
+.RS
+.RE
+.TP
+.B \f[C]--gladtex\f[]
+Enclose TeX math in \f[C]<eq>\f[] tags in HTML output.
+These can then be processed by gladTeX to produce links to images of the
+typeset formulas.
+.RS
+.RE
+.TP
+.B \f[C]--mimetex=\f[]\f[I]URL\f[]
+Render TeX math using the mimeTeX CGI script.
+If \f[I]URL\f[] is not specified, it is assumed that the script is at
+\f[C]/cgi-bin/mimetex.cgi\f[].
+.RS
+.RE
+.TP
+.B \f[C]--webtex=\f[]\f[I]URL\f[]
+Render TeX formulas using an external script that converts TeX formulas
+to images.
+The formula will be concatenated with the URL provided.
+If \f[I]URL\f[] is not specified, the Google Chart API will be used.
+.RS
+.RE
+.TP
+.B \f[C]-i\f[], \f[C]--incremental\f[]
+Make list items in Slidy or S5 display incrementally (one by one).
+The default is for lists to be displayed all at once.
+.RS
+.RE
+.TP
+.B \f[C]--offline\f[]
+Include all the CSS and javascript needed for a Slidy or S5 slide show
+in the output, so that the slide show will work even when no internet
+connection is available.
+.RS
+.RE
+.TP
+.B \f[C]--xetex\f[]
+Create LaTeX outut suitable for processing by XeTeX.
+.RS
+.RE
+.TP
+.B \f[C]--chapters\f[]
+Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
+output.
+.RS
+.RE
+.TP
+.B \f[C]-N\f[], \f[C]--number-sections\f[]
+Number section headings in LaTeX, ConTeXt, or HTML output.
+By default, sections are not numbered.
+.RS
+.RE
+.TP
+.B \f[C]--listings\f[]
+Use listings package for LaTeX code blocks
+.RS
+.RE
+.TP
+.B \f[C]--section-divs\f[]
+Wrap sections in \f[C]<div>\f[] tags (or \f[C]<section>\f[] tags in
+HTML5), and attach identifiers to the enclosing \f[C]<div>\f[] (or
+\f[C]<section>\f[]) rather than the header itself.
+See Section identifiers, below.
+.RS
+.RE
+.TP
+.B \f[C]--no-wrap\f[]
+Disable text wrapping in output.
+By default, text is wrapped appropriately for the output format.
+.RS
+.RE
+.TP
+.B \f[C]--columns\f[]=\f[I]NUMBER\f[]
+Specify length of lines in characters (for text wrapping).
+.RS
+.RE
+.TP
+.B \f[C]--email-obfuscation=\f[]\f[I]none|javascript|references\f[]
+Specify a method for obfuscating \f[C]mailto:\f[] links in HTML
+documents.
+\f[I]none\f[] leaves \f[C]mailto:\f[] links as they are.
+\f[I]javascript\f[] obfuscates them using javascript.
+\f[I]references\f[] obfuscates them by printing their letters as decimal
+or hexadecimal character references.
+If \f[C]--strict\f[] is specified, \f[I]references\f[] is used
+regardless of the presence of this option.
+.RS
+.RE
+.TP
+.B \f[C]--id-prefix\f[]=\f[I]STRING\f[]
+Specify a prefix to be added to all automatically generated identifiers
+in HTML output.
+This is useful for preventing duplicate identifiers when generating
+fragments to be included in other pages.
+.RS
+.RE
+.TP
+.B \f[C]--indented-code-classes=\f[]\f[I]CLASSES\f[]
+Specify classes to use for indented code blocks--for example,
+\f[C]perl,numberLines\f[] or \f[C]haskell\f[].
+Multiple classes may be separated by spaces or commas.
+.RS
+.RE
+.TP
+.B \f[C]--toc\f[], \f[C]--table-of-contents\f[]
+Include an automatically generated table of contents (or, in the case of
+\f[C]latex\f[], \f[C]context\f[], and \f[C]rst\f[], an instruction to
+create one) in the output document.
+This option has no effect on \f[C]man\f[], \f[C]docbook\f[],
+\f[C]slidy\f[], or \f[C]s5\f[] output.
+.RS
+.RE
+.TP
+.B \f[C]--base-header-level=\f[]\f[I]NUMBER\f[]
+Specify the base level for headers (defaults to 1).
+.RS
+.RE
+.TP
+.B \f[C]--template=\f[]\f[I]FILE\f[]
+Use \f[I]FILE\f[] as a custom template for the generated document.
+Implies \f[C]--standalone\f[].
+See Templates below for a description of template syntax.
+If this option is not used, a default template appropriate for the
+output format will be used.
+See also \f[C]-D/--print-default-template\f[].
+.RS
+.RE
+.TP
+.B \f[C]-V\f[] \f[I]KEY=VAL\f[], \f[C]--variable=\f[]\f[I]KEY:VAL\f[]
+Set the template variable \f[I]KEY\f[] to the value \f[I]VAL\f[] when
+rendering the document in standalone mode.
+This is only useful when the \f[C]--template\f[] option is used to
+specify a custom template, since pandoc automatically sets the variables
+used in the default templates.
+.RS
+.RE
+.TP
+.B \f[C]-c\f[] \f[I]URL\f[], \f[C]--css=\f[]\f[I]URL\f[]
+Link to a CSS style sheet.
+.RS
+.RE
+.TP
+.B \f[C]-H\f[] \f[I]FILE\f[], \f[C]--include-in-header=\f[]\f[I]FILE\f[]
+Include contents of \f[I]FILE\f[], verbatim, at the end of the header.
+This can be used, for example, to include special CSS or javascript in
+HTML documents.
+This option can be used repeatedly to include multiple files in the
+header.
+They will be included in the order specified.
+Implies \f[C]--standalone\f[].
+.RS
+.RE
+.TP
+.B \f[C]-B\f[] \f[I]FILE\f[],
+\f[C]--include-before-body=\f[]\f[I]FILE\f[]
+Include contents of \f[I]FILE\f[], verbatim, at the beginning of the
+document body (e.g.
+after the \f[C]<body>\f[] tag in HTML, or the \f[C]\\begin{document}\f[]
+command in LaTeX).
+This can be used to include navigation bars or banners in HTML
+documents.
+This option can be used repeatedly to include multiple files.
+They will be included in the order specified.
+Implies \f[C]--standalone\f[].
+.RS
+.RE
+.TP
+.B \f[C]-A\f[] \f[I]FILE\f[],
+\f[C]--include-after-body=\f[]\f[I]FILE\f[]
+Include contents of \f[I]FILE\f[], verbatim, at the end of the document
+body (before the \f[C]</body>\f[] tag in HTML, or the
+\f[C]\\end{document}\f[] command in LaTeX).
+This option can be be used repeatedly to include multiple files.
+They will be included in the order specified.
+Implies \f[C]--standalone\f[].
+.RS
+.RE
+.TP
+.B \f[C]--reference-odt=\f[]\f[I]FILE\f[]
+Use the specified file as a style reference in producing an ODT.
+For best results, the reference ODT should be a modified version of an
+ODT produced using pandoc.
+The contents of the reference ODT are ignored, but its stylesheets are
+used in the new ODT.
+If no reference ODT is specified on the command line, pandoc will look
+for a file \f[C]reference.odt\f[] in the user data directory (see
+\f[C]--data-dir\f[]).
+If this is not found either, sensible defaults will be used.
+.RS
+.RE
+.TP
+.B \f[C]--epub-stylesheet=\f[]\f[I]FILE\f[]
+Use the specified CSS file to style the EPUB.
+If no stylesheet is specified, pandoc will look for a file
+\f[C]epub.css\f[] in the user data directory (see \f[C]--data-dir\f[],
+below).
+If it is not found there, sensible defaults will be used.
+.RS
+.RE
+.TP
+.B \f[C]--epub-metadata=\f[]\f[I]FILE\f[]
+Look in the specified XML file for metadata for the EPUB.
+The file should contain a series of Dublin Core elements, as documented
+at \f[C]http://dublincore.org/documents/dces/\f[].
+For example:
+.RS
+.IP
+.nf
+\f[C]
+\ <dc:rights>Creative\ Commons</dc:rights>
+\ <dc:language>es-AR</dc:language>
+\f[]
+.fi
+.PP
+By default, pandoc will include the following metadata elements:
+\f[C]<dc:title>\f[] (from the document title), \f[C]<dc:creator>\f[]
+(from the document authors), \f[C]<dc:language>\f[] (from the locale),
+and \f[C]<dc:identifier\ id="BookId">\f[] (a randomly generated UUID).
+Any of these may be overridden by elements in the metadata file.
+.RE
+.TP
+.B \f[C]-D\f[] \f[I]FORMAT\f[],
+\f[C]--print-default-template=\f[]\f[I]FORMAT\f[]
+Print the default template for an output \f[I]FORMAT\f[].
+(See \f[C]-t\f[] for a list of possible \f[I]FORMAT\f[]s.)
+.RS
+.RE
+.TP
+.B \f[C]-T\f[] \f[I]STRING\f[], \f[C]--title-prefix=\f[]\f[I]STRING\f[]
+Specify \f[I]STRING\f[] as a prefix at the beginning of the title that
+appears in the HTML header (but not in the title as it appears at the
+beginning of the HTML body).
+Implies \f[C]--standalone\f[].
+.RS
+.RE
+.TP
+.B \f[C]--bibliography=\f[]\f[I]FILE\f[]
+Specify bibliography database to be used in resolving citations.
+The database type will be determined from the extension of
+\f[I]FILE\f[], which may be \f[C].mods\f[] (MODS format), \f[C].bib\f[]
+(BibTeX format), \f[C].bbx\f[] (BibLaTeX format), \f[C].ris\f[] (RIS
+format), \f[C].enl\f[] (EndNote format), \f[C].xml\f[] (EndNote XML
+format), \f[C].wos\f[] (ISI format), \f[C].medline\f[] (MEDLINE format),
+\f[C].copac\f[] (Copac format), or \f[C].json\f[] (citeproc JSON).
+If you want to use multiple bibliographies, just use this option
+repeatedly.
+.RS
+.RE
+.TP
+.B \f[C]--csl=\f[]\f[I]FILE\f[]
+Specify CSL style to be used in formatting citations and the
+bibliography.
+If \f[I]FILE\f[] is not found, pandoc will look for it in
+.RS
+.IP
+.nf
+\f[C]
+$HOME/.csl
+\f[]
+.fi
+.PP
+in unix and
+.IP
+.nf
+\f[C]
+C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\csl
+\f[]
+.fi
+.PP
+in Windows.
+If the \f[C]--csl\f[] option is not specified, pandoc will use a default
+style: either \f[C]default.csl\f[] in the user data directory (see
+\f[C]--data-dir\f[]), or, if that is not present, the Chicago
+author-date style.
+.RE
+.TP
+.B \f[C]--data-dir=\f[]\f[I]DIRECTORY\f[]
+Specify the user data directory to search for pandoc data files.
+If this option is not specified, the default user data directory will be
+used:
+.RS
+.IP
+.nf
+\f[C]
+$HOME/.pandoc
+\f[]
+.fi
+.PP
+in unix and
+.IP
+.nf
+\f[C]
+C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\pandoc
+\f[]
+.fi
+.PP
+in Windows.
+A \f[C]reference.odt\f[], \f[C]epub.css\f[], \f[C]templates\f[]
+directory, or \f[C]s5\f[] directory placed in this directory will
+override pandoc\[aq]s normal defaults.
+.RE
+.TP
+.B \f[C]--dump-args\f[]
+Print information about command-line arguments to \f[I]stdout\f[], then
+exit.
+This option is intended primarily for use in wrapper scripts.
+The first line of output contains the name of the output file specified
+with the \f[C]-o\f[] option, or \f[C]-\f[] (for \f[I]stdout\f[]) if no
+output file was specified.
+The remaining lines contain the command-line arguments, one per line, in
+the order they appear.
+These do not include regular Pandoc options and their arguments, but do
+include any options appearing after a \f[C]--\f[] separator at the end
+of the line.
+.RS
+.RE
+.TP
+.B \f[C]--ignore-args\f[]
+Ignore command-line arguments (for use in wrapper scripts).
+Regular Pandoc options are not ignored.
+Thus, for example,
+.RS
+.IP
+.nf
+\f[C]
+pandoc\ --ignore-args\ -o\ foo.html\ -s\ foo.txt\ --\ -e\ latin1
+\f[]
+.fi
+.PP
+is equivalent to
+.IP
+.nf
+\f[C]
+pandoc\ -o\ foo.html\ -s
+\f[]
+.fi
+.RE
+.TP
+.B \f[C]-v\f[], \f[C]--version\f[]
+Print version.
+.RS
+.RE
+.TP
+.B \f[C]-h\f[], \f[C]--help\f[]
+Show usage message.
+.RS
+.RE
+.SH TEMPLATES
+.PP
+When the \f[C]-s/--standalone\f[] option is used, pandoc uses a template
+to add header and footer material that is needed for a self-standing
+document.
+To see the default template that is used, just type
+.IP
+.nf
+\f[C]
+pandoc\ -D\ FORMAT
+\f[]
+.fi
+.PP
+where \f[C]FORMAT\f[] is the name of the output format.
+A custom template can be specified using the \f[C]--template\f[] option.
+You can also override the system default templates for a given output
+format \f[C]FORMAT\f[] by putting a file
+\f[C]templates/FORMAT.template\f[] in the user data directory (see
+\f[C]--data-dir\f[], above).
+.PP
+Templates may contain \f[I]variables\f[].
+Variable names are sequences of alphanumerics, \f[C]-\f[], and
+\f[C]_\f[], starting with a letter.
+A variable name surrounded by \f[C]$\f[] signs will be replaced by its
+value.
+For example, the string \f[C]$title$\f[] in
+.IP
+.nf
+\f[C]
+<title>$title$</title>
+\f[]
+.fi
+.PP
+will be replaced by the document title.
+.PP
+To write a literal \f[C]$\f[] in a template, use \f[C]$$\f[].
+.PP
+Some variables are set automatically by pandoc.
+These vary somewhat depending on the output format, but include:
+.TP
+.B \f[C]header-includes\f[]
+contents specified by \f[C]-H/--include-in-header\f[] (may have multiple
+values)
+.RS
+.RE
+.TP
+.B \f[C]toc\f[]
+non-null value if \f[C]--toc/--table-of-contents\f[] was specified
+.RS
+.RE
+.TP
+.B \f[C]include-before\f[]
+contents specified by \f[C]-B/--include-before-body\f[] (may have
+multiple values)
+.RS
+.RE
+.TP
+.B \f[C]include-after\f[]
+contents specified by \f[C]-A/--include-after-body\f[] (may have
+multiple values)
+.RS
+.RE
+.TP
+.B \f[C]body\f[]
+body of document
+.RS
+.RE
+.TP
+.B \f[C]title\f[]
+title of document, as specified in title block
+.RS
+.RE
+.TP
+.B \f[C]author\f[]
+author of document, as specified in title block (may have multiple
+values)
+.RS
+.RE
+.TP
+.B \f[C]date\f[]
+date of document, as specified in title block
+.RS
+.RE
+.TP
+.B \f[C]lang\f[]
+language code for HTML documents
+.RS
+.RE
+.PP
+Variables may be set at the command line using the
+\f[C]-V/--variable\f[] option.
+This allows users to include custom variables in their templates.
+.PP
+Templates may contain conditionals.
+The syntax is as follows:
+.IP
+.nf
+\f[C]
+$if(variable)$
+X
+$else$
+Y
+$endif$
+\f[]
+.fi
+.PP
+This will include \f[C]X\f[] in the template if \f[C]variable\f[] has a
+non-null value; otherwise it will include \f[C]Y\f[].
+\f[C]X\f[] and \f[C]Y\f[] are placeholders for any valid template text,
+and may include interpolated variables or other conditionals.
+The \f[C]$else$\f[] section may be omitted.
+.PP
+When variables can have multiple values (for example, \f[C]author\f[] in
+a multi-author document), you can use the \f[C]$for$\f[] keyword:
+.IP
+.nf
+\f[C]
+$for(author)$
+<meta\ name="author"\ content="$author$"\ />
+$endfor$
+\f[]
+.fi
+.PP
+You can optionally specify a separator to be used between consecutive
+items:
+.IP
+.nf
+\f[C]
+$for(author)$$author$$sep$,\ $endfor$
+\f[]
+.fi
+.SH PRODUCING HTML SLIDE SHOWS WITH PANDOC
+.PP
+You can use Pandoc to produce an HTML + javascript slide presentation
+that can be viewed via a web browser.
+There are two ways to do this, using S5 or Slidy.
+.PP
+Here\[aq]s the markdown source for a simple slide show,
+\f[C]eating.txt\f[]:
+.IP
+.nf
+\f[C]
+%\ Eating\ Habits
+%\ John\ Doe
+%\ March\ 22,\ 2005
+
+#\ In\ the\ morning
+
+-\ Eat\ eggs
+-\ Drink\ coffee
+
+#\ In\ the\ evening
+
+-\ Eat\ spaghetti
+-\ Drink\ wine
+
+--------------------------
+
+![picture\ of\ spaghetti](images/spaghetti.jpg)
+\f[]
+.fi
+.PP
+To produce the slide show, simply type
+.IP
+.nf
+\f[C]
+pandoc\ -w\ s5\ -s\ eating.txt\ >\ eating.html
+\f[]
+.fi
+.PP
+for S5, or
+.IP
+.nf
+\f[C]
+pandoc\ -w\ slidy\ -s\ eating.txt\ >\ eating.html
+\f[]
+.fi
+.PP
+for Slidy.
+.PP
+A title page is constructed automatically from the document\[aq]s title
+block.
+Each level-one header and horizontal rule begins a new slide.
+.PP
+The file produced by pandoc with the \f[C]-s/--standalone\f[] option
+embeds a link to javascripts and CSS files, which are assumed to be
+available at the relative path \f[C]ui/default\f[] (for S5) or at the
+Slidy website at \f[C]w3.org\f[] (for Slidy).
+If the \f[C]--offline\f[] option is specified, the scripts and CSS will
+be included directly in the generated file, so that it may be used
+offline.
+.PP
+You can change the style of the slides by putting customized CSS files
+in \f[C]$DATADIR/s5/default\f[] (for S5) or \f[C]$DATADIR/slidy\f[] (for
+Slidy), where \f[C]$DATADIR\f[] is the user data directory (see
+\f[C]--data-dir\f[], above).
+The originals may be found in pandoc\[aq]s system data directory
+(generally \f[C]$CABALDIR/pandoc-VERSION/s5/default\f[]).
+Pandoc will look there for any files it does not find in the user data
+directory.
+.SS Incremental lists
+.PP
+By default, these writers produces lists that display "all at once." If
+you want your lists to display incrementally (one item at a time), use
+the \f[C]-i\f[] option.
+If you want a particular list to depart from the default (that is, to
+display incrementally without the \f[C]-i\f[] option and all at once
+with the \f[C]-i\f[] option), put it in a block quote:
+.IP
+.nf
+\f[C]
+>\ -\ Eat\ spaghetti
+>\ -\ Drink\ wine
+\f[]
+.fi
+.PP
+In this way incremental and nonincremental lists can be mixed in a
+single document.
+.SH LITERATE HASKELL SUPPORT
+.PP
+If you append \f[C]+lhs\f[] to an appropriate input or output format
+(\f[C]markdown\f[], \f[C]rst\f[], or \f[C]latex\f[] for input or output;
+\f[C]html\f[] for output only), pandoc will treat the document as
+literate Haskell source.
+This means that
+.IP \[bu] 2
+In markdown input, "bird track" sections will be parsed as Haskell code
+rather than block quotations.
+Text between \f[C]\\begin{code}\f[] and \f[C]\\end{code}\f[] will also
+be treated as Haskell code.
+.IP \[bu] 2
+In markdown output, code blocks with class \f[C]haskell\f[] will be
+rendered using bird tracks, and block quotations will be indented one
+space, so they will not be treated as Haskell code.
+In addition, headers will be rendered setext-style (with underlines)
+rather than atx-style (with \[aq]#\[aq] characters).
+(This is because ghc treats \[aq]#\[aq] characters in column 1 as
+introducing line numbers.)
+.IP \[bu] 2
+In restructured text input, "bird track" sections will be parsed as
+Haskell code.
+.IP \[bu] 2
+In restructured text output, code blocks with class \f[C]haskell\f[]
+will be rendered using bird tracks.
+.IP \[bu] 2
+In LaTeX input, text in \f[C]code\f[] environments will be parsed as
+Haskell code.
+.IP \[bu] 2
+In LaTeX output, code blocks with class \f[C]haskell\f[] will be
+rendered inside \f[C]code\f[] environments.
+.IP \[bu] 2
+In HTML output, code blocks with class \f[C]haskell\f[] will be rendered
+with class \f[C]literatehaskell\f[] and bird tracks.
+.PP
+Examples:
+.IP
+.nf
+\f[C]
+pandoc\ -f\ markdown+lhs\ -t\ html
+\f[]
+.fi
+.PP
+reads literate Haskell source formatted with markdown conventions and
+writes ordinary HTML (without bird tracks).
+.IP
+.nf
+\f[C]
+pandoc\ -f\ markdown+lhs\ -t\ html+lhs
+\f[]
+.fi
+.PP
+writes HTML with the Haskell code in bird tracks, so it can be copied
+and pasted as literate Haskell source.
+.SH AUTHORS
+.PP
+© 2006-2011 John MacFarlane (jgm at berkeley dot edu).
+Released under the GPL, version 2 or greater.
+This software carries no warranty of any kind.
+(See COPYRIGHT for full copyright and warranty notices.)
+ Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
+Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
+Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
+Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner.
+.SH PANDOC'S MARKDOWN
+For a complete description of pandoc's extensions to standard markdown,
+see \f[C]pandoc_markdown\f[] (5).
+.SH SEE ALSO
+.PP
+\f[C]markdown2pdf\f[] (1), \f[C]pandoc_markdown\f[] (5).
+.PP
+The Pandoc source code and all documentation may be downloaded
+from <http://johnmacfarlane.net/pandoc/>.
diff --git a/man/man1/pandoc.1.md b/man/man1/pandoc.1.md
deleted file mode 100644
index 502b0b98d..000000000
--- a/man/man1/pandoc.1.md
+++ /dev/null
@@ -1,394 +0,0 @@
-% PANDOC(1) Pandoc User Manuals
-% John MacFarlane
-% January 8, 2008
-
-# NAME
-
-pandoc - general markup converter
-
-# SYNOPSIS
-
-pandoc [*options*] [*input-file*]...
-
-# DESCRIPTION
-
-Pandoc converts files from one markup format to another. It can
-read markdown and (subsets of) reStructuredText, HTML, and LaTeX, and
-it can write plain text, markdown, reStructuredText, HTML, LaTeX,
-ConTeXt, Texinfo, groff man, MediaWiki markup, RTF, OpenDocument XML,
-ODT, DocBook XML, EPUB, and Slidy or S5 HTML slide shows.
-
-If no *input-file* is specified, input is read from *stdin*.
-Otherwise, the *input-files* are concatenated (with a blank
-line between each) and used as input. Output goes to *stdout* by
-default (though output to *stdout* is disabled for the `odt` and
-`epub` output formats). For output to a file, use the `-o` option:
-
- pandoc -o output.html input.txt
-
-Instead of a file, an absolute URI may be given. In this case
-pandoc will fetch the content using HTTP:
-
- pandoc -f html -t markdown http://www.fsf.org
-
-The input and output formats may be specified using command-line options
-(see **OPTIONS**, below, for details). If these formats are not
-specified explicitly, Pandoc will attempt to determine them
-from the extensions of the input and output filenames. If input comes
-from *stdin* or from a file with an unknown extension, the input is assumed
-to be markdown. If no output filename is specified using the `-o`
-option, or if a filename is specified but its extension is unknown,
-the output will default to HTML. Thus, for example,
-
- pandoc -o chap1.tex chap1.txt
-
-converts *chap1.txt* from markdown to LaTeX. And
-
- pandoc README
-
-converts *README* from markdown to HTML.
-
-Pandoc's version of markdown is an extended variant of standard
-markdown: the differences are described in the *README* file in
-the user documentation. If standard markdown syntax is desired, the
-`--strict` option may be used.
-
-Pandoc uses the UTF-8 character encoding for both input and output.
-If your local character encoding is not UTF-8, you
-should pipe input and output through `iconv`:
-
- iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
-
-# OPTIONS
-
--f *FORMAT*, -r *FORMAT*, \--from=*FORMAT*, \--read=*FORMAT*
-: Specify input format. *FORMAT* can be
- `native` (native Haskell), `markdown` (markdown or plain text),
- `rst` (reStructuredText), `html` (HTML), or `latex` (LaTeX).
- If `+lhs` is appended to `markdown`, `rst`, or `latex`, the input
- will be treated as literate Haskell source.
-
--t *FORMAT*, -w *FORMAT*, \--to=*FORMAT*, \--write=*FORMAT*
-: Specify output format. *FORMAT* can be `native` (native Haskell),
- `plain` (plain text), `markdown` (markdown), `rst` (reStructuredText),
- `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man),
- `mediawiki` (MediaWiki markup), `texinfo` (GNU Texinfo),
- `docbook` (DocBook XML), `opendocument` (OpenDocument XML),
- `odt` (OpenOffice text document), `epub` (EPUB book),
- `slidy` (Slidy HTML and javascript slide show),
- `s5` (S5 HTML and javascript slide show), or `rtf` (rich text
- format). Note that `odt` and `epub` output will not be directed to
- *stdout*; an output filename must be specified using the `-o/--output`
- option. If `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`,
- the output will be rendered as literate Haskell source.
-
--s, \--standalone
-: Produce output with an appropriate header and footer (e.g. a
- standalone HTML, LaTeX, or RTF file, not a fragment).
-
--o *FILE*, \--output=*FILE*
-: Write output to *FILE* instead of *stdout*. If *FILE* is
- \``-`', output will go to *stdout*.
-
--p, \--preserve-tabs
-: Preserve tabs instead of converting them to spaces.
-
-\--tab-stop=*TABSTOP*
-: Specify tab stop (default is 4).
-
-\--strict
-: Use strict markdown syntax, with no extensions or variants.
-
-\--reference-links
-: Use reference-style links, rather than inline links, in writing markdown
- or reStructuredText.
-
--R, \--parse-raw
-: Parse untranslatable HTML codes and LaTeX environments as raw HTML
- or LaTeX, instead of ignoring them.
-
--S, \--smart
-: Use smart quotes, dashes, and ellipses. (This option is significant
- only when the input format is `markdown`. It is selected automatically
- when the output format is `latex` or `context`.)
-
--m*URL*, \--latexmathml=*URL*
-: Use LaTeXMathML to display embedded TeX math in HTML output.
- To insert a link to a local copy of the `LaTeXMathML.js` script,
- provide a *URL*. If no *URL* is provided, the contents of the
- script will be inserted directly into the HTML header.
-
-\--mathml
-: Convert TeX math to MathML. In standalone mode, a small javascript
- will be inserted that allows the MathML to be viewed on some browsers.
-
-\--jsmath=*URL*
-: Use jsMath to display embedded TeX math in HTML output.
- The *URL* should point to the jsMath load script; if provided,
- it will be linked to in the header of standalone HTML documents.
-
-\--gladtex
-: Enclose TeX math in `<eq>` tags in HTML output. These can then
- be processed by gladTeX to produce links to images of the typeset
- formulas.
-
-\--mimetex=*URL*
-: Render TeX math using the mimeTeX CGI script. If *URL* is not specified,
- it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
-
-\--webtex=*URL*
-: Render TeX math using an external script. The formula will be
- concatenated with the URL provided. If *URL* is not specified, the
- Google Chart API will be used.
-
--i, \--incremental
-: Make list items in Slidy or S5 display incrementally (one by one).
-
-\--offline
-: Include all the CSS and javascript needed for a Slidy or S5 slide
- show in the output, so that the slide show will work even when no
- internet connection is available.
-
-\--xetex
-: Create LaTeX outut suitable for processing by XeTeX.
-
--N, \--number-sections
-: Number section headings in LaTeX, ConTeXt, or HTML output.
- (Default is not to number them.)
-
-\--section-divs
-: Wrap sections in `<div>` tags, and attach identifiers to the
- enclosing `<div>` rather than the header itself.
-
-\--no-wrap
-: Disable text wrapping in output. (Default is to wrap text.)
-
-\--sanitize-html
-: Sanitizes HTML (in markdown or HTML input) using a whitelist.
- Unsafe tags are replaced by HTML comments; unsafe attributes
- are omitted. URIs in links and images are also checked against a
- whitelist of URI schemes.
-
-\--email-obfuscation=*none|javascript|references*
-: Specify a method for obfuscating `mailto:` links in HTML documents.
- *none* leaves `mailto:` links as they are. *javascript* obfuscates
- them using javascript. *references* obfuscates them by printing their
- letters as decimal or hexadecimal character references.
- If `--strict` is specified, *references* is used regardless of the
- presence of this option.
-
-\--id-prefix*=string*
-: Specify a prefix to be added to all automatically generated identifiers
- in HTML output. This is useful for preventing duplicate identifiers
- when generating fragments to be included in other pages.
-
-\--indented-code-classes*=classes*
-: Specify classes to use for indented code blocks--for example,
- `perl,numberLines` or `haskell`. Multiple classes may be separated
- by spaces or commas.
-
-\--toc, \--table-of-contents
-: Include an automatically generated table of contents (HTML, markdown,
- RTF) or an instruction to create one (LaTeX, reStructuredText).
- This option has no effect on man, DocBook, Slidy, or S5 output.
-
-\--base-header-level=*LEVEL*
-: Specify the base level for headers (defaults to 1).
-
-\--template=*FILE*
-: Use *FILE* as a custom template for the generated document. Implies
- `-s`. See TEMPLATES below for a description of template syntax. If
- this option is not used, a default template appropriate for the
- output format will be used. See also `-D/--print-default-template`.
-
--V KEY=VAL, \--variable=*KEY:VAL*
-: Set the template variable KEY to the value VAL when rendering the
- document in standalone mode. This is only useful when the
- `--template` option is used to specify a custom template, since
- pandoc automatically sets the variables used in the default
- templates.
-
--c *CSS*, \--css=*CSS*
-: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
-
--H *FILE*, \--include-in-header=*FILE*
-: Include contents of *FILE* at the end of the header. Implies `-s`.
-
--B *FILE*, \--include-before-body=*FILE*
-: Include contents of *FILE* at the beginning of the document body.
- Implies `-s`.
-
--A *FILE*, \--include-after-body=*FILE*
-: Include contents of *FILE* at the end of the document body.
- Implies `-s`.
-
--C *FILE*, \--custom-header=*FILE*
-: Use contents of *FILE* as the document header. *Note: This option is
- deprecated. Users should transition to using `--template` instead.*
-
-\--reference-odt=*filename*
-: Use the specified file as a style reference in producing an ODT.
- For best results, the reference ODT should be a modified version
- of an ODT produced using pandoc. The contents of the reference ODT
- are ignored, but its stylesheets are used in the new ODT. If no
- reference ODT is specified on the command line, pandoc will look
- for a file `reference.odt` in the user data directory (see
- `--data-dir`). If this is not found either, sensible defaults will be
- used.
-
-\--epub-stylesheet=*filename*
-: Use the specified CSS file to style the EPUB. If no stylesheet
- is specified, pandoc will look for a file `epub.css` in the
- user data directory (see `--data-dir`, below). If it is not
- found there, sensible defaults will be used.
-
-\--epub-metadata=*filename*
-: Look in the specified XML file for metadata for the EPUB.
- The file should contain a series of Dublin Core elements
- (http://dublincore.org/documents/dces/), for example:
-
- <dc:rights>Creative Commons</dc:rights>
- <dc:language>es-AR</dc:language>
-
- By default, pandoc will include the following metadata elements:
- `<dc:title>` (from the document title), `<dc:creator>` (from the
- document authors), `<dc:language>` (from the locale), and
- `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
- these may be overridden by elements in the metadata file.
-
--D *FORMAT*, \--print-default-template=*FORMAT*
-: Print the default template for an output *FORMAT*. (See `-t`
- for a list of possible *FORMAT*s.)
-
--T *STRING*, \--title-prefix=*STRING*
-: Specify *STRING* as a prefix to the HTML window title.
-
-\--data-dir*=DIRECTORY*
-: Specify the user data directory to search for pandoc data files.
- If this option is not specified, the default user data directory
- will be used:
-
- $HOME/.pandoc
-
- in unix and
-
- C:\Documents And Settings\USERNAME\Application Data\pandoc
-
- in Windows. A `reference.odt`, `epub.css`, `templates` directory,
- or `s5` directory placed in this directory will override pandoc's
- normal defaults.
-
-\--dump-args
-: Print information about command-line arguments to *stdout*, then exit.
- The first line of output contains the name of the output file specified
- with the `-o` option, or \``-`' (for *stdout*) if no output file was
- specified. The remaining lines contain the command-line arguments,
- one per line, in the order they appear. These do not include regular
- Pandoc options and their arguments, but do include any options appearing
- after a \``--`' separator at the end of the line.
- This option is intended primarily for use in wrapper scripts.
-
-\--ignore-args
-: Ignore command-line arguments (for use in wrapper scripts).
- Regular Pandoc options are not ignored. Thus, for example,
-
- pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
-
- is equivalent to
-
- pandoc -o foo.html -s
-
--v, \--version
-: Print version.
-
--h, \--help
-: Show usage message.
-
-# TEMPLATES
-
-When the `-s/--standalone` option is used, pandoc uses a template to
-add header and footer material that is needed for a self-standing
-document. To see the default template that is used, just type
-
- pandoc --print-default-template=FORMAT
-
-where `FORMAT` is the name of the output format. A custom template
-can be specified using the `--template` option. You can also override
-the system default templates for a given output format `FORMAT`
-by putting a file `templates/FORMAT.template` in the user data
-directory (see `--data-dir`, below).
-
-Templates may contain *variables*. Variable names are sequences of
-alphanumerics, `-`, and `_`, starting with a letter. A variable name
-surrounded by `$` signs will be replaced by its value. For example,
-the string `$title$` in
-
- <title>$title$</title>
-
-will be replaced by the document title.
-
-To write a literal `$` in a template, use `$$`.
-
-Some variables are set automatically by pandoc. These vary somewhat
-depending on the output format, but include:
-
-`legacy-header`
-: contents specified by `-C/--custom-header`
-`header-includes`
-: contents specified by `-H/--include-in-header` (may have multiple
- values)
-`toc`
-: non-null value if `--toc/--table-of-contents` was specified
-`include-before`
-: contents specified by `-B/--include-before-body` (may have
- multiple values)
-`include-after`
-: contents specified by `-A/--include-after-body` (may have
- multiple values)
-`body`
-: body of document
-`title`
-: title of document, as specified in title block
-`author`
-: author of document, as specified in title block (may have
- multiple values)
-`date`
-: date of document, as specified in title block
-
-Variables may be set at the command line using the `-V/--variable`
-option. This allows users to include custom variables in their
-templates.
-
-Templates may contain conditionals. The syntax is as follows:
-
- $if(variable)$
- X
- $else$
- Y
- $endif$
-
-This will include `X` in the template if `variable` has a non-null
-value; otherwise it will include `Y`. `X` and `Y` are placeholders for
-any valid template text, and may include interpolated variables or other
-conditionals. The `$else$` section may be omitted.
-
-When variables can have multiple values (for example, `author` in
-a multi-author document), you can use the `$for$` keyword:
-
- $for(author)$
- <meta name="author" content="$author$" />
- $endfor$
-
-You can optionally specify a separator to be used between
-consecutive items:
-
- $for(author)$$author$$sep$, $endfor$
-
-# SEE ALSO
-
-`markdown2pdf` (1).
-The *README* file distributed with Pandoc contains full documentation.
-
-The Pandoc source code and all documentation may be downloaded from
-<http://johnmacfarlane.net/pandoc/>.
-
diff --git a/man/man1/pandoc.1.template b/man/man1/pandoc.1.template
new file mode 100644
index 000000000..c9b2b20f8
--- /dev/null
+++ b/man/man1/pandoc.1.template
@@ -0,0 +1,16 @@
+$if(has-tables)$
+.\"t
+$endif$
+.TH PANDOC 1 "$date$" "$title$"
+.SH NAME
+pandoc - general markup converter
+$body$
+.SH PANDOC'S MARKDOWN
+For a complete description of pandoc's extensions to standard markdown,
+see \f[C]pandoc_markdown\f[] (5).
+.SH SEE ALSO
+.PP
+\f[C]markdown2pdf\f[] (1), \f[C]pandoc_markdown\f[] (5).
+.PP
+The Pandoc source code and all documentation may be downloaded
+from <http://johnmacfarlane.net/pandoc/>.
diff --git a/man/man5/pandoc_markdown.5 b/man/man5/pandoc_markdown.5
new file mode 100644
index 000000000..1b5c483c1
--- /dev/null
+++ b/man/man5/pandoc_markdown.5
@@ -0,0 +1,1692 @@
+.\"t
+.TH PANDOC_MARKDOWN 5 "January 29, 2011" "Pandoc"
+.SH NAME
+pandoc_markdown - markdown syntax for pandoc(1)
+.SH DESCRIPTION
+.PP
+Pandoc understands an extended and slightly revised version of John
+Gruber\[aq]s markdown syntax.
+This document explains the syntax, noting differences from standard
+markdown.
+Except where noted, these differences can be suppressed by specifying
+the \f[C]--strict\f[] command-line option.
+.SH PHILOSOPHY
+.PP
+Markdown is designed to be easy to write, and, even more importantly,
+easy to read:
+.RS
+.PP
+A Markdown-formatted document should be publishable as-is, as plain
+text, without looking like it\[aq]s been marked up with tags or
+formatting instructions.
+-- John Gruber
+.RE
+.PP
+This principle has guided pandoc\[aq]s decisions in finding syntax for
+tables, footnotes, and other extensions.
+.PP
+There is, however, one respect in which pandoc\[aq]s aims are different
+from the original aims of markdown.
+Whereas markdown was originally designed with HTML generation in mind,
+pandoc is designed for multiple output formats.
+Thus, while pandoc allows the embedding of raw HTML, it discourages it,
+and provides other, non-HTMLish ways of representing important document
+elements like definition lists, tables, mathematics, and footnotes.
+.SH PARAGRAPHS
+.PP
+A paragraph is one or more lines of text followed by one or more blank
+line.
+Newlines are treated as spaces, so you can reflow your paragraphs as you
+like.
+If you need a hard line break, put two or more spaces at the end of a
+line, or or type a backslash followed by a newline.
+.SH HEADERS
+.PP
+There are two kinds of headers, Setext and atx.
+.SS Setext-style headers
+.PP
+A setext-style header is a line of text "underlined" with a row of
+\f[C]=\f[] signs (for a level one header) of \f[C]-\f[] signs (for a
+level two header):
+.IP
+.nf
+\f[C]
+A\ level-one\ header
+==================
+
+A\ level-two\ header
+------------------
+\f[]
+.fi
+.PP
+The header text can contain inline formatting, such as emphasis (see
+Inline formatting, below).
+.SS Atx-style headers
+.PP
+An Atx-style header consists of one to six \f[C]#\f[] signs and a line
+of text, optionally followed by any number of \f[C]#\f[] signs.
+The number of \f[C]#\f[] signs at the beginning of the line is the
+header level:
+.IP
+.nf
+\f[C]
+##\ A\ level-two\ header
+
+###\ A\ level-three\ header\ ###
+\f[]
+.fi
+.PP
+As with setext-style headers, the header text can contain formatting:
+.IP
+.nf
+\f[C]
+#\ A\ level-one\ header\ with\ a\ [link](/url)\ and\ *emphasis*
+\f[]
+.fi
+.PP
+Standard markdown syntax does not require a blank line before a header.
+Pandoc does require this (except, of course, at the beginning of the
+document).
+The reason for the requirement is that it is all too easy for a
+\f[C]#\f[] to end up at the beginning of a line by accident (perhaps
+through line wrapping).
+Consider, for example:
+.IP
+.nf
+\f[C]
+I\ like\ several\ of\ their\ flavors\ of\ ice\ cream:
+#22,\ for\ example,\ and\ #5.
+\f[]
+.fi
+.SS Header identifiers in HTML
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Each header element in pandoc\[aq]s HTML output is given a unique
+identifier.
+This identifier is based on the text of the header.
+To derive the identifier from the header text,
+.IP \[bu] 2
+Remove all formatting, links, etc.
+.IP \[bu] 2
+Remove all punctuation, except underscores, hyphens, and periods.
+.IP \[bu] 2
+Replace all spaces and newlines with hyphens.
+.IP \[bu] 2
+Convert all alphabetic characters to lowercase.
+.IP \[bu] 2
+Remove everything up to the first letter (identifiers may not begin with
+a number or punctuation mark).
+.IP \[bu] 2
+If nothing is left after this, use the identifier \f[C]section\f[].
+.PP
+Thus, for example,
+.PP
+.TS
+tab(@);
+l l.
+T{
+Header
+T}@T{
+Identifier
+T}
+_
+T{
+Header identifiers in HTML
+T}@T{
+\f[C]header-identifiers-in-html\f[]
+T}
+T{
+\f[I]Dogs\f[]?--in \f[I]my\f[] house?
+T}@T{
+\f[C]dogs--in-my-house\f[]
+T}
+T{
+HTML, S5, or RTF?
+T}@T{
+\f[C]html-s5-or-rtf\f[]
+T}
+T{
+3.
+Applications
+T}@T{
+\f[C]applications\f[]
+T}
+T{
+33
+T}@T{
+\f[C]section\f[]
+T}
+.TE
+.PP
+These rules should, in most cases, allow one to determine the identifier
+from the header text.
+The exception is when several headers have the same text; in this case,
+the first will get an identifier as described above; the second will get
+the same identifier with \f[C]-1\f[] appended; the third with
+\f[C]-2\f[]; and so on.
+.PP
+These identifiers are used to provide link targets in the table of
+contents generated by the \f[C]--toc|--table-of-contents\f[] option.
+They also make it easy to provide links from one section of a document
+to another.
+A link to this section, for example, might look like this:
+.IP
+.nf
+\f[C]
+See\ the\ section\ on
+[header\ identifiers](#header-identifiers-in-html).
+\f[]
+.fi
+.PP
+Note, however, that this method of providing links to sections works
+only in HTML.
+.PP
+If the \f[C]--section-divs\f[] option is specified, then each section
+will be wrapped in a \f[C]div\f[] (or a \f[C]section\f[], if
+\f[C]--html5\f[] was specified), and the identifier will be attached to
+the enclosing \f[C]<div>\f[] (or \f[C]<section>\f[]) tag rather than the
+header itself.
+This allows entire sections to be manipulated using javascript or
+treated differently in CSS.
+.SH BLOCK QUOTATIONS
+.PP
+Markdown uses email conventions for quoting blocks of text.
+A block quotation is one or more paragraphs or other block elements
+(such as lists or headers), with each line preceded by a \f[C]>\f[]
+character and a space.
+(The \f[C]>\f[] need not start at the left margin, but it should not be
+indented more than three spaces.)
+.IP
+.nf
+\f[C]
+>\ This\ is\ a\ block\ quote.\ This
+>\ paragraph\ has\ two\ lines.
+>
+>\ 1.\ This\ is\ a\ list\ inside\ a\ block\ quote.
+>\ 2.\ Second\ item.
+\f[]
+.fi
+.PP
+A "lazy" form, which requires the \f[C]>\f[] character only on the first
+line of each block, is also allowed:
+.IP
+.nf
+\f[C]
+>\ This\ is\ a\ block\ quote.\ This
+paragraph\ has\ two\ lines.
+
+>\ 1.\ This\ is\ a\ list\ inside\ a\ block\ quote.
+2.\ Second\ item.
+\f[]
+.fi
+.PP
+Among the block elements that can be contained in a block quote are
+other block quotes.
+That is, block quotes can be nested:
+.IP
+.nf
+\f[C]
+>\ This\ is\ a\ block\ quote.
+>
+>\ >\ A\ block\ quote\ within\ a\ block\ quote.
+\f[]
+.fi
+.PP
+Standard markdown syntax does not require a blank line before a block
+quote.
+Pandoc does require this (except, of course, at the beginning of the
+document).
+The reason for the requirement is that it is all too easy for a
+\f[C]>\f[] to end up at the beginning of a line by accident (perhaps
+through line wrapping).
+So, unless \f[C]--strict\f[] is used, the following does not produce a
+nested block quote in pandoc:
+.IP
+.nf
+\f[C]
+>\ This\ is\ a\ block\ quote.
+>>\ Nested.
+\f[]
+.fi
+.SH VERBATIM (CODE) BLOCKS
+.SS Indented code blocks
+.PP
+A block of text indented four spaces (or one tab) is treated as verbatim
+text: that is, special characters do not trigger special formatting, and
+all spaces and line breaks are preserved.
+For example,
+.IP
+.nf
+\f[C]
+\ \ \ \ if\ (a\ >\ 3)\ {
+\ \ \ \ \ \ moveShip(5\ *\ gravity,\ DOWN);
+\ \ \ \ }
+\f[]
+.fi
+.PP
+The initial (four space or one tab) indentation is not considered part
+of the verbatim text, and is removed in the output.
+.PP
+Note: blank lines in the verbatim text need not begin with four spaces.
+.SS Delimited code blocks
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+In addition to standard indented code blocks, Pandoc supports
+\f[I]delimited\f[] code blocks.
+These begin with a row of three or more tildes (\f[C]~\f[]) and end with
+a row of tildes that must be at least as long as the starting row.
+Everything between the tilde-lines is treated as code.
+No indentation is necessary:
+.IP
+.nf
+\f[C]
+~~~~~~~
+if\ (a\ >\ 3)\ {
+\ \ moveShip(5\ *\ gravity,\ DOWN);
+}
+~~~~~~~
+\f[]
+.fi
+.PP
+Like regular code blocks, delimited code blocks must be separated from
+surrounding text by blank lines.
+.PP
+If the code itself contains a row of tildes, just use a longer row of
+tildes at the start and end:
+.IP
+.nf
+\f[C]
+~~~~~~~~~~~~~~~~
+~~~~~~~~~~
+code\ including\ tildes
+~~~~~~~~~~
+~~~~~~~~~~~~~~~~
+\f[]
+.fi
+.PP
+Optionally, you may specify the language of the code block using this
+syntax:
+.IP
+.nf
+\f[C]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ {.haskell\ .numberLines}
+qsort\ []\ \ \ \ \ =\ []
+qsort\ (x:xs)\ =\ qsort\ (filter\ (<\ x)\ xs)\ ++\ [x]\ ++
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ qsort\ (filter\ (>=\ x)\ xs)\
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+\f[]
+.fi
+.PP
+Some output formats can use this information to do syntax highlighting.
+Currently, the only output format that uses this information is HTML.
+.PP
+If pandoc has been compiled with syntax highlighting support, then the
+code block above will appear highlighted, with numbered lines.
+(To see which languages are supported, do \f[C]pandoc\ --version\f[].)
+.PP
+If pandoc has not been compiled with syntax highlighting support, the
+code block above will appear as follows:
+.IP
+.nf
+\f[C]
+<pre\ class="haskell">
+\ \ <code>
+\ \ ...
+\ \ </code>
+</pre>
+\f[]
+.fi
+.SH LISTS
+.SS Bullet lists
+.PP
+A bullet list is a list of bulleted list items.
+A bulleted list item begins with a bullet (\f[C]*\f[], \f[C]+\f[], or
+\f[C]-\f[]).
+Here is a simple example:
+.IP
+.nf
+\f[C]
+*\ one
+*\ two
+*\ three
+\f[]
+.fi
+.PP
+This will produce a "compact" list.
+If you want a "loose" list, in which each item is formatted as a
+paragraph, put spaces between the items:
+.IP
+.nf
+\f[C]
+*\ one
+
+*\ two
+
+*\ three
+\f[]
+.fi
+.PP
+The bullets need not be flush with the left margin; they may be indented
+one, two, or three spaces.
+The bullet must be followed by whitespace.
+.PP
+A list item may contain multiple paragraphs and other block-level
+content.
+Subsequent paragraphs must be preceded by a blank line and indented four
+spaces or a tab.
+The list will look better if the first paragraph is aligned with the
+rest:
+.IP
+.nf
+\f[C]
+\ \ *\ First\ paragraph.
+
+\ \ \ \ Continued.
+
+\ \ *\ Second\ paragraph.\ With\ a\ code\ block,\ which\ must\ be\ indented
+\ \ \ \ eight\ spaces:
+
+\ \ \ \ \ \ \ \ {\ code\ }
+\f[]
+.fi
+.PP
+List items may include other lists.
+In this case the preceding blank line is optional.
+The nested list must be indented four spaces or one tab:
+.IP
+.nf
+\f[C]
+*\ fruits
+\ \ \ \ +\ apples
+\ \ \ \ \ \ \ \ -\ macintosh
+\ \ \ \ \ \ \ \ -\ red\ delicious
+\ \ \ \ +\ pears
+\ \ \ \ +\ peaches
+*\ vegetables
+\ \ \ \ +\ brocolli
+\ \ \ \ +\ chard
+\f[]
+.fi
+.PP
+Markdown allows you to write list items "lazily," instead of indenting
+continuation lines.
+However, if there are multiple paragraphs or other blocks in a list
+item, the first line of each must be indented.
+.IP
+.nf
+\f[C]
++\ A\ lazy,\ lazy,\ list
+item.
+
++\ Another\ one;\ this\ looks
+bad\ but\ is\ legal.
+
+\ \ \ \ Second\ paragraph\ of\ second
+list\ item.
+\f[]
+.fi
+.SS Ordered lists
+.PP
+Ordered lists work just like bulleted lists, except that the items begin
+with enumerators rather than bullets.
+.PP
+In standard markdown, enumerators are decimal numbers followed by a
+period and a space.
+The numbers themselves are ignored, so there is no difference between
+this list:
+.IP
+.nf
+\f[C]
+1.\ \ one
+2.\ \ two
+3.\ \ three
+\f[]
+.fi
+.PP
+and this one:
+.IP
+.nf
+\f[C]
+5.\ \ one
+7.\ \ two
+1.\ \ three
+\f[]
+.fi
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Unlike standard markdown, Pandoc allows ordered list items to be marked
+with uppercase and lowercase letters and roman numerals, in addition to
+arabic numerals.
+List markers may be enclosed in parentheses or followed by a single
+right-parentheses or period.
+They must be separated from the text that follows by at least one space,
+and, if the list marker is a capital letter with a period, by at least
+two spaces.[1]
+.PP
+Pandoc also pays attention to the type of list marker used, and to the
+starting number, and both of these are preserved where possible in the
+output format.
+Thus, the following yields a list with numbers followed by a single
+parenthesis, starting with 9, and a sublist with lowercase roman
+numerals:
+.IP
+.nf
+\f[C]
+\ 9)\ \ Ninth
+10)\ \ Tenth
+11)\ \ Eleventh
+\ \ \ \ \ \ \ i.\ subone
+\ \ \ \ \ \ ii.\ subtwo
+\ \ \ \ \ iii.\ subthree
+\f[]
+.fi
+.PP
+Note that Pandoc pays attention only to the \f[I]starting\f[] marker in
+a list.
+So, the following yields a list numbered sequentially starting from 2:
+.IP
+.nf
+\f[C]
+(2)\ Two
+(5)\ Three
+1.\ \ Four
+*\ \ \ Five
+\f[]
+.fi
+.PP
+If default list markers are desired, use \f[C]#.\f[]:
+.IP
+.nf
+\f[C]
+#.\ \ one
+#.\ \ two
+#.\ \ three
+\f[]
+.fi
+.SS Definition lists
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Pandoc supports definition lists, using a syntax inspired by PHP
+Markdown Extra and reStructuredText:[2]
+.IP
+.nf
+\f[C]
+Term\ 1
+
+:\ \ \ Definition\ 1
+
+Term\ 2\ with\ *inline\ markup*
+
+:\ \ \ Definition\ 2
+
+\ \ \ \ \ \ \ \ {\ some\ code,\ part\ of\ Definition\ 2\ }
+
+\ \ \ \ Third\ paragraph\ of\ definition\ 2.
+\f[]
+.fi
+.PP
+Each term must fit on one line, which may optionally be followed by a
+blank line, and must be followed by one or more definitions.
+A definition begins with a colon or tilde, which may be indented one or
+two spaces.
+A term may have multiple definitions, and each definition may consist of
+one or more block elements (paragraph, code block, list, etc.)
+, each indented four spaces or one tab stop.
+.PP
+If you leave space after the definition (as in the example above), the
+blocks of the definitions will be considered paragraphs.
+In some output formats, this will mean greater spacing between
+term/definition pairs.
+For a compact definition list, do not leave space between the definition
+and the next term:
+.IP
+.nf
+\f[C]
+Term\ 1
+\ \ ~\ Definition\ 1
+Term\ 2
+\ \ ~\ Definition\ 2a
+\ \ ~\ Definition\ 2b
+\f[]
+.fi
+.SS Numbered example lists
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+The special list marker \f[C]\@\f[] can be used for sequentially
+numbered examples.
+The first list item with a \f[C]\@\f[] marker will be numbered
+\[aq]1\[aq], the next \[aq]2\[aq], and so on, throughout the document.
+The numbered examples need not occur in a single list; each new list
+using \f[C]\@\f[] will take up where the last stopped.
+So, for example:
+.IP
+.nf
+\f[C]
+(\@)\ \ My\ first\ example\ will\ be\ numbered\ (1).
+(\@)\ \ My\ second\ example\ will\ be\ numbered\ (2).
+
+Explanation\ of\ examples.
+
+(\@)\ \ My\ third\ example\ will\ be\ numbered\ (3).
+\f[]
+.fi
+.PP
+Numbered examples can be labeled and referred to elsewhere in the
+document:
+.IP
+.nf
+\f[C]
+(\@good)\ \ This\ is\ a\ good\ example.
+
+As\ (\@good)\ illustrates,\ ...
+\f[]
+.fi
+.PP
+The label can be any string of alphanumeric characters, underscores, or
+hyphens.
+.SS Compact and loose lists
+.PP
+Pandoc behaves differently from \f[C]Markdown.pl\f[] on some "edge
+cases" involving lists.
+Consider this source:
+.IP
+.nf
+\f[C]
++\ \ \ First
++\ \ \ Second:
+\ -\ \ \ Fee
+\ -\ \ \ Fie
+\ -\ \ \ Foe
+
++\ \ \ Third
+\f[]
+.fi
+.PP
+Pandoc transforms this into a "compact list" (with no \f[C]<p>\f[] tags
+around "First", "Second", or "Third"), while markdown puts \f[C]<p>\f[]
+tags around "Second" and "Third" (but not "First"), because of the blank
+space around "Third".
+Pandoc follows a simple rule: if the text is followed by a blank line,
+it is treated as a paragraph.
+Since "Second" is followed by a list, and not a blank line, it isn\[aq]t
+treated as a paragraph.
+The fact that the list is followed by a blank line is irrelevant.
+(Note: Pandoc works this way even when the \f[C]--strict\f[] option is
+specified.
+This behavior is consistent with the official markdown syntax
+description, even though it is different from that of
+\f[C]Markdown.pl\f[].)
+.SS Ending a list
+.PP
+What if you want to put an indented code block after a list?
+.IP
+.nf
+\f[C]
+-\ \ \ item\ one
+-\ \ \ item\ two
+
+\ \ \ \ {\ my\ code\ block\ }
+\f[]
+.fi
+.PP
+Trouble! Here pandoc (like other markdown implementations) will treat
+\f[C]{\ my\ code\ block\ }\f[] as the second paragraph of item two, and
+not as a code block.
+.PP
+To "cut off" the list after item two, you can insert some non-indented
+content, like an HTML comment, which won\[aq]t produce visible output in
+any format:
+.IP
+.nf
+\f[C]
+-\ \ \ item\ one
+-\ \ \ item\ two
+
+<!--\ end\ of\ list\ -->
+
+\ \ \ \ {\ my\ code\ block\ }
+\f[]
+.fi
+.PP
+You can use the same trick if you want two consecutive lists instead of
+one big list:
+.IP
+.nf
+\f[C]
+1.\ \ one
+2.\ \ two
+3.\ \ three
+
+<!--\ -->
+
+a.\ \ uno
+b.\ \ dos
+c.\ \ tres
+\f[]
+.fi
+.SH HORIZONTAL RULES
+.PP
+A line containing a row of three or more \f[C]*\f[], \f[C]-\f[], or
+\f[C]_\f[] characters (optionally separated by spaces) produces a
+horizontal rule:
+.IP
+.nf
+\f[C]
+*\ \ *\ \ *\ \ *
+
+---------------
+\f[]
+.fi
+.SH TABLES
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Three kinds of tables may be used.
+All three kinds presuppose the use of a fixed-width font, such as
+Courier.
+.PP
+\f[B]Simple tables\f[] look like this:
+.IP
+.nf
+\f[C]
+\ \ Right\ \ \ \ \ Left\ \ \ \ \ Center\ \ \ \ \ Default
+-------\ \ \ \ \ ------\ ----------\ \ \ -------
+\ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ 12
+\ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ 123
+\ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ 1
+
+Table:\ \ Demonstration\ of\ simple\ table\ syntax.
+\f[]
+.fi
+.PP
+The headers and table rows must each fit on one line.
+Column alignments are determined by the position of the header text
+relative to the dashed line below it:[3]
+.IP \[bu] 2
+If the dashed line is flush with the header text on the right side but
+extends beyond it on the left, the column is right-aligned.
+.IP \[bu] 2
+If the dashed line is flush with the header text on the left side but
+extends beyond it on the right, the column is left-aligned.
+.IP \[bu] 2
+If the dashed line extends beyond the header text on both sides, the
+column is centered.
+.IP \[bu] 2
+If the dashed line is flush with the header text on both sides, the
+default alignment is used (in most cases, this will be left).
+.PP
+The table must end with a blank line, or a line of dashes followed by a
+blank line.
+A caption may optionally be provided (as illustrated in the example
+above).
+A caption is a paragraph beginning with the string \f[C]Table:\f[] (or
+just \f[C]:\f[]), which will be stripped off.
+It may appear either before or after the table.
+.PP
+The column headers may be omitted, provided a dashed line is used to end
+the table.
+For example:
+.IP
+.nf
+\f[C]
+-------\ \ \ \ \ ------\ ----------\ \ \ -------
+\ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ \ 12
+\ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ \ 123
+\ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ 1
+-------\ \ \ \ \ ------\ ----------\ \ \ -------
+\f[]
+.fi
+.PP
+When headers are omitted, column alignments are determined on the basis
+of the first line of the table body.
+So, in the tables above, the columns would be right, left, center, and
+right aligned, respectively.
+.PP
+\f[B]Multiline tables\f[] allow headers and table rows to span multiple
+lines of text (but cells that span multiple columns or rows of the table
+are not supported).
+Here is an example:
+.IP
+.nf
+\f[C]
+-------------------------------------------------------------
+\ Centered\ \ \ Default\ \ \ \ \ \ \ \ \ \ \ Right\ Left
+\ \ Header\ \ \ \ Aligned\ \ \ \ \ \ \ \ \ Aligned\ Aligned
+-----------\ -------\ ---------------\ -------------------------
+\ \ \ First\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 12.0\ Example\ of\ a\ row\ that
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spans\ multiple\ lines.
+
+\ \ Second\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 5.0\ Here\[aq]s\ another\ one.\ Note
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ blank\ line\ between
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.
+-------------------------------------------------------------
+
+Table:\ Here\[aq]s\ the\ caption.\ It,\ too,\ may\ span
+multiple\ lines.
+\f[]
+.fi
+.PP
+These work like simple tables, but with the following differences:
+.IP \[bu] 2
+They must begin with a row of dashes, before the header text (unless the
+headers are omitted).
+.IP \[bu] 2
+They must end with a row of dashes, then a blank line.
+.IP \[bu] 2
+The rows must be separated by blank lines.
+.PP
+In multiline tables, the table parser pays attention to the widths of
+the columns, and the writers try to reproduce these relative widths in
+the output.
+So, if you find that one of the columns is too narrow in the output, try
+widening it in the markdown source.
+.PP
+Headers may be omitted in multiline tables as well as simple tables:
+.IP
+.nf
+\f[C]
+-----------\ -------\ ---------------\ -------------------------
+\ \ \ First\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 12.0\ Example\ of\ a\ row\ that
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spans\ multiple\ lines.
+
+\ \ Second\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 5.0\ Here\[aq]s\ another\ one.\ Note
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ blank\ line\ between
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.
+-------------------------------------------------------------
+
+:\ Here\[aq]s\ a\ multiline\ table\ without\ headers.
+\f[]
+.fi
+.PP
+It is possible for a multiline table to have just one row, but the row
+should be followed by a blank line (and then the row of dashes that ends
+the table), or the table may be interpreted as a simple table.
+.PP
+\f[B]Grid tables\f[] look like this:
+.IP
+.nf
+\f[C]
+:\ Sample\ grid\ table.
+
++---------------+---------------+--------------------+
+|\ Fruit\ \ \ \ \ \ \ \ \ |\ Price\ \ \ \ \ \ \ \ \ |\ Advantages\ \ \ \ \ \ \ \ \ |
++===============+===============+====================+
+|\ Bananas\ \ \ \ \ \ \ |\ $1.34\ \ \ \ \ \ \ \ \ |\ -\ built-in\ wrapper\ |
+|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ -\ bright\ color\ \ \ \ \ |
++---------------+---------------+--------------------+
+|\ Oranges\ \ \ \ \ \ \ |\ $2.10\ \ \ \ \ \ \ \ \ |\ -\ cures\ scurvy\ \ \ \ \ |
+|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ -\ tasty\ \ \ \ \ \ \ \ \ \ \ \ |
++---------------+---------------+--------------------+
+\f[]
+.fi
+.PP
+The row of \f[C]=\f[]s separates the header from the table body, and can
+be omitted for a headerless table.
+The cells of grid tables may contain arbitrary block elements (multiple
+paragraphs, code blocks, lists, etc.)
+\&.
+Alignments are not supported, nor are cells that span multiple columns
+or rows.
+Grid tables can be created easily using Emacs table mode.
+.SH TITLE BLOCK
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+If the file begins with a title block
+.IP
+.nf
+\f[C]
+%\ title
+%\ author(s)\ (separated\ by\ semicolons)
+%\ date
+\f[]
+.fi
+.PP
+it will be parsed as bibliographic information, not regular text.
+(It will be used, for example, in the title of standalone LaTeX or HTML
+output.)
+ The block may contain just a title, a title and an author, or all three
+elements.
+If you want to include an author but no title, or a title and a date but
+no author, you need a blank line:
+.IP
+.nf
+\f[C]
+%
+%\ Author
+
+%\ My\ title
+%
+%\ June\ 15,\ 2006
+\f[]
+.fi
+.PP
+The title may occupy multiple lines, but continuation lines must begin
+with leading space, thus:
+.IP
+.nf
+\f[C]
+%\ My\ title
+\ \ on\ multiple\ lines
+\f[]
+.fi
+.PP
+If a document has multiple authors, the authors may be put on separate
+lines with leading space, or separated by semicolons, or both.
+So, all of the following are equivalent:
+.IP
+.nf
+\f[C]
+%\ Author\ One
+\ \ Author\ Two
+
+%\ Author\ One;\ Author\ Two
+
+%\ Author\ One;
+\ \ Author\ Two
+\f[]
+.fi
+.PP
+The date must fit on one line.
+.PP
+All three metadata fields may contain standard inline formatting
+(italics, links, footnotes, etc.)
+\&.
+.PP
+Title blocks will always be parsed, but they will affect the output only
+when the \f[C]--standalone\f[] (\f[C]-s\f[]) option is chosen.
+In HTML output, titles will appear twice: once in the document head --
+this is the title that will appear at the top of the window in a browser
+-- and once at the beginning of the document body.
+The title in the document head can have an optional prefix attached
+(\f[C]--title-prefix\f[] or \f[C]-T\f[] option).
+The title in the body appears as an H1 element with class "title", so it
+can be suppressed or reformatted with CSS.
+If a title prefix is specified with \f[C]-T\f[] and no title block
+appears in the document, the title prefix will be used by itself as the
+HTML title.
+.PP
+The man page writer extracts a title, man page section number, and other
+header and footer information from the title line.
+The title is assumed to be the first word on the title line, which may
+optionally end with a (single-digit) section number in parentheses.
+(There should be no space between the title and the parentheses.)
+ Anything after this is assumed to be additional footer and header text.
+A single pipe character (\f[C]|\f[]) should be used to separate the
+footer text from the header text.
+Thus,
+.IP
+.nf
+\f[C]
+%\ PANDOC(1)
+\f[]
+.fi
+.PP
+will yield a man page with the title \f[C]PANDOC\f[] and section 1.
+.IP
+.nf
+\f[C]
+%\ PANDOC(1)\ Pandoc\ User\ Manuals
+\f[]
+.fi
+.PP
+will also have "Pandoc User Manuals" in the footer.
+.IP
+.nf
+\f[C]
+%\ PANDOC(1)\ Pandoc\ User\ Manuals\ |\ Version\ 4.0
+\f[]
+.fi
+.PP
+will also have "Version 4.0" in the header.
+.SH BACKSLASH ESCAPES
+.PP
+Except inside a code block or inline code, any punctuation or space
+character preceded by a backslash will be treated literally, even if it
+would normally indicate formatting.
+Thus, for example, if one writes
+.IP
+.nf
+\f[C]
+*\\*hello\\**
+\f[]
+.fi
+.PP
+one will get
+.IP
+.nf
+\f[C]
+<em>*hello*</em>
+\f[]
+.fi
+.PP
+instead of
+.IP
+.nf
+\f[C]
+<strong>hello</strong>
+\f[]
+.fi
+.PP
+This rule is easier to remember than standard markdown\[aq]s rule, which
+allows only the following characters to be backslash-escaped:
+.IP
+.nf
+\f[C]
+\\`*_{}[]()>#+-.!
+\f[]
+.fi
+.PP
+(However, if the \f[C]--strict\f[] option is supplied, the standard
+markdown rule will be used.)
+.PP
+A backslash-escaped space is parsed as a nonbreaking space.
+It will appear in TeX output as \f[C]~\f[] and in HTML and XML as
+\f[C]\\&#160;\f[] or \f[C]\\&nbsp;\f[].
+.PP
+A backslash-escaped newline (i.e.
+a backslash occurring at the end of a line) is parsed as a hard line
+break.
+It will appear in TeX output as \f[C]\\\\\f[] and in HTML as
+\f[C]<br\ />\f[].
+This is a nice alternative to markdown\[aq]s "invisible" way of
+indicating hard line breaks using two trailing spaces on a line.
+.PP
+Backslash escapes do not work in verbatim contexts.
+.SH SMART PUNCTUATION
+.PP
+If the \f[C]--smart\f[] option is specified, pandoc will produce
+typographically correct output, converting straight quotes to curly
+quotes, \f[C]---\f[] and \f[C]--\f[] to Em-dashes, and \f[C]...\f[] to
+ellipses.
+Nonbreaking spaces are inserted after certain abbreviations, such as
+"Mr."
+.SH INLINE FORMATTING
+.SS Emphasis
+.PP
+To \f[I]emphasize\f[] some text, surround it with \f[C]*\f[]s or
+\f[C]_\f[], like this:
+.IP
+.nf
+\f[C]
+This\ text\ is\ _emphasized\ with\ underscores_,\ and\ this
+is\ *emphasized\ with\ asterisks*.
+\f[]
+.fi
+.PP
+Double \f[C]*\f[] or \f[C]_\f[] produces \f[B]strong emphasis\f[]:
+.IP
+.nf
+\f[C]
+This\ is\ **strong\ emphasis**\ and\ __with\ underscores__.
+\f[]
+.fi
+.PP
+A \f[C]*\f[] or \f[C]_\f[] character surrounded by spaces, or
+backslash-escaped, will not trigger emphasis:
+.IP
+.nf
+\f[C]
+This\ is\ *\ not\ emphasized\ *,\ and\ \\*neither\ is\ this\\*.
+\f[]
+.fi
+.PP
+Because \f[C]_\f[] is sometimes used inside words and identifiers,
+pandoc does not interpret a \f[C]_\f[] surrounded by alphanumeric
+characters as an emphasis marker.
+If you want to emphasize just part of a word, use \f[C]*\f[]:
+.IP
+.nf
+\f[C]
+feas*ible*,\ not\ feas*able*.
+\f[]
+.fi
+.SS Strikeout
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+To strikeout a section of text with a horizontal line, begin and end it
+with \f[C]~~\f[].
+Thus, for example,
+.IP
+.nf
+\f[C]
+This\ ~~is\ deleted\ text.~~
+\f[]
+.fi
+.SS Superscripts and subscripts
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Superscripts may be written by surrounding the superscripted text by
+\f[C]^\f[] characters; subscripts may be written by surrounding the
+subscripted text by \f[C]~\f[] characters.
+Thus, for example,
+.IP
+.nf
+\f[C]
+H~2~O\ is\ a\ liquid.\ \ 2^10^\ is\ 1024.
+\f[]
+.fi
+.PP
+If the superscripted or subscripted text contains spaces, these spaces
+must be escaped with backslashes.
+(This is to prevent accidental superscripting and subscripting through
+the ordinary use of \f[C]~\f[] and \f[C]^\f[].)
+ Thus, if you want the letter P with \[aq]a cat\[aq] in subscripts, use
+\f[C]P~a\\\ cat~\f[], not \f[C]P~a\ cat~\f[].
+.SS Verbatim
+.PP
+To make a short span of text verbatim, put it inside backticks:
+.IP
+.nf
+\f[C]
+What\ is\ the\ difference\ between\ `>>=`\ and\ `>>`?
+\f[]
+.fi
+.PP
+If the verbatim text includes a backtick, use double backticks:
+.IP
+.nf
+\f[C]
+Here\ is\ a\ literal\ backtick\ ``\ `\ ``.
+\f[]
+.fi
+.PP
+(The spaces after the opening backticks and before the closing backticks
+will be ignored.)
+.PP
+The general rule is that a verbatim span starts with a string of
+consecutive backticks (optionally followed by a space) and ends with a
+string of the same number of backticks (optionally preceded by a space).
+.PP
+Note that backslash-escapes (and other markdown constructs) do not work
+in verbatim contexts:
+.IP
+.nf
+\f[C]
+This\ is\ a\ backslash\ followed\ by\ an\ asterisk:\ `\\*`.
+\f[]
+.fi
+.SH MATH
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Anything between two \f[C]$\f[] characters will be treated as TeX math.
+The opening \f[C]$\f[] must have a character immediately to its right,
+while the closing \f[C]$\f[] must have a character immediately to its
+left.
+Thus, \f[C]$20,000\ and\ $30,000\f[] won\[aq]t parse as math.
+If for some reason you need to enclose text in literal \f[C]$\f[]
+characters, backslash-escape them and they won\[aq]t be treated as math
+delimiters.
+.PP
+TeX math will be printed in all output formats.
+How it is rendered depends on the output format:
+.TP
+.B Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
+It will appear verbatim between \f[C]$\f[] characters.
+.RS
+.RE
+.TP
+.B reStructuredText
+It will be rendered using an interpreted text role \f[C]:math:\f[], as
+described here.
+.RS
+.RE
+.TP
+.B Texinfo
+It will be rendered inside a \f[C]\@math\f[] command.
+.RS
+.RE
+.TP
+.B groff man
+It will be rendered verbatim without \f[C]$\f[]\[aq]s.
+.RS
+.RE
+.TP
+.B MediaWiki
+It will be rendered inside \f[C]<math>\f[] tags.
+.RS
+.RE
+.TP
+.B Textile
+It will be rendered inside \f[C]<span\ class="math">\f[] tags.
+.RS
+.RE
+.TP
+.B RTF, Docbook, OpenDocument, ODT
+It will be rendered, if possible, using unicode characters, and will
+otherwise appear verbatim.
+.RS
+.RE
+.TP
+.B HTML, Slidy, S5, EPUB
+The way math is rendered in HTML will depend on the command-line options
+selected:
+.RS
+.IP "1." 3
+The default is to render TeX math as far as possible using unicode
+characters, as with RTF, Docbook, and OpenDocument output.
+Formulas are put inside a \f[C]span\f[] with \f[C]class="math"\f[], so
+that they may be styled differently from the surrounding text if needed.
+.IP "2." 3
+If the \f[C]--latexmathml\f[] option is used, TeX math will be displayed
+between $ or $$ characters and put in \f[C]<span>\f[] tags with class
+\f[C]LaTeX\f[].
+The LaTeXMathML script will be used to render it as formulas.
+(This trick does not work in all browsers, but it works in Firefox.
+In browsers that do not support LaTeXMathML, TeX math will appear
+verbatim between $ characters.)
+.IP "3." 3
+If the \f[C]--jsmath\f[] option is used, TeX math will be put inside
+\f[C]<span>\f[] tags (for inline math) or \f[C]<div>\f[] tags (for
+display math) with class \f[C]math\f[].
+The jsMath script will be used to render it.
+.IP "4." 3
+If the \f[C]--mimetex\f[] option is used, the mimeTeX CGI script will be
+called to generate images for each TeX formula.
+This should work in all browsers.
+The \f[C]--mimetex\f[] option takes an optional URL as argument.
+If no URL is specified, it will be assumed that the mimeTeX CGI script
+is at \f[C]/cgi-bin/mimetex.cgi\f[].
+.IP "5." 3
+If the \f[C]--gladtex\f[] option is used, TeX formulas will be enclosed
+in \f[C]<eq>\f[] tags in the HTML output.
+The resulting \f[C]htex\f[] file may then be processed by gladTeX, which
+will produce image files for each formula and an \f[C]html\f[] file with
+links to these images.
+So, the procedure is:
+.RS 4
+.IP
+.nf
+\f[C]
+pandoc\ -s\ --gladtex\ myfile.txt\ -o\ myfile.htex
+gladtex\ -d\ myfile-images\ myfile.htex
+#\ produces\ myfile.html\ and\ images\ in\ myfile-images
+\f[]
+.fi
+.RE
+.IP "6." 3
+If the \f[C]--webtex\f[] option is used, TeX formulas will be converted
+to \f[C]<img>\f[] tags that link to an external script that converts
+formulas to images.
+The formula will be URL-encoded and concatenated with the URL provided.
+If no URL is specified, the Google Chart API will be used
+(\f[C]http://chart.apis.google.com/chart?cht=tx&chl=\f[]).
+.RE
+.SH RAW HTML
+.PP
+Markdown allows you to insert raw HTML anywhere in a document (except
+verbatim contexts, where \f[C]<\f[], \f[C]>\f[], and \f[C]&\f[] are
+interpreted literally).
+.PP
+The raw HTML is passed through unchanged in HTML, S5, Slidy, EPUB,
+Markdown, and Textile output, and suppressed in other formats.
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Standard markdown allows you to include HTML "blocks": blocks of HTML
+between balanced tags that are separated from the surrounding text with
+blank lines, and start and end at the left margin.
+Within these blocks, everything is interpreted as HTML, not markdown; so
+(for example), \f[C]*\f[] does not signify emphasis.
+.PP
+Pandoc behaves this way when \f[C]--strict\f[] is specified; but by
+default, pandoc interprets material between HTML block tags as markdown.
+Thus, for example, Pandoc will turn
+.IP
+.nf
+\f[C]
+<table>
+\ <tr>
+\ \ <td>*one*</td>
+\ \ <td>[a\ link](http://google.com)</td>
+\ </tr>
+</table>
+\f[]
+.fi
+.PP
+into
+.IP
+.nf
+\f[C]
+<table>
+\ <tr>
+\ \ <td><em>one</em></td>
+\ \ <td><a\ href="http://google.com">a\ link</a></td>
+\ </tr>
+</table>
+\f[]
+.fi
+.PP
+whereas \f[C]Markdown.pl\f[] will preserve it as is.
+.PP
+There is one exception to this rule: text between \f[C]<script>\f[] and
+\f[C]<style>\f[] tags is not interpreted as markdown.
+.PP
+This departure from standard markdown should make it easier to mix
+markdown with HTML block elements.
+For example, one can surround a block of markdown text with
+\f[C]<div>\f[] tags without preventing it from being interpreted as
+markdown.
+.SH RAW TEX
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
+included in a document.
+Inline TeX commands will be preserved and passed unchanged to the LaTeX
+and ConTeXt writers.
+Thus, for example, you can use LaTeX to include BibTeX citations:
+.IP
+.nf
+\f[C]
+This\ result\ was\ proved\ in\ \\cite{jones.1967}.
+\f[]
+.fi
+.PP
+Note that in LaTeX environments, like
+.IP
+.nf
+\f[C]
+\\begin{tabular}{|l|l|}\\hline
+Age\ &\ Frequency\ \\\\\ \\hline
+18--25\ \ &\ 15\ \\\\
+26--35\ \ &\ 33\ \\\\\
+36--45\ \ &\ 22\ \\\\\ \\hline
+\\end{tabular}
+\f[]
+.fi
+.PP
+the material between the begin and end tags will be interpreted as raw
+LaTeX, not as markdown.
+.PP
+Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
+and ConTeXt.
+.SS Macros
+.PP
+For output formats other than LaTeX, pandoc will parse LaTeX
+\f[C]\\newcommand\f[] and \f[C]\\renewcommand\f[] definitions and apply
+the resulting macros to all LaTeX math.
+So, for example, the following will work in all output formats, not just
+LaTeX:
+.IP
+.nf
+\f[C]
+\\newcommand{\\tuple}[1]{\\langle\ #1\ \\rangle}
+
+$\\tuple{a,\ b,\ c}$
+\f[]
+.fi
+.PP
+In LaTeX output, the \f[C]\\newcommand\f[] definition will simply be
+passed unchanged to the output.
+.SH LINKS
+.PP
+Markdown allows links to be specified in several ways.
+.SS Automatic links
+.PP
+If you enclose a URL or email address in pointy brackets, it will become
+a link:
+.IP
+.nf
+\f[C]
+<http://google.com>
+<sam\@green.eggs.ham>
+\f[]
+.fi
+.SS Inline links
+.PP
+An inline link consists of the link text in square brackets, followed by
+the URL in parentheses.
+(Optionally, the URL can be followed by a link title, in quotes.)
+.IP
+.nf
+\f[C]
+This\ is\ an\ [inline\ link](/url),\ and\ here\[aq]s\ [one\ with
+a\ title](http://fsf.org\ "click\ here\ for\ a\ good\ time!").
+\f[]
+.fi
+.PP
+There can be no space between the bracketed part and the parenthesized
+part.
+The link text can contain formatting (such as emphasis), but the title
+cannot.
+.SS Reference links
+.PP
+An \f[I]explicit\f[] reference link has two parts, the link itself and
+the link definition, which may occur elsewhere in the document (either
+before or after the link).
+.PP
+The link consists of link text in square brackets, followed by a label
+in square brackets.
+(There can be space between the two.)
+ The link definition must begin at the left margin or indented no more
+than three spaces.
+It consists of the bracketed label, followed by a colon and a space,
+followed by the URL, and optionally (after a space) a link title either
+in quotes or in parentheses.
+.PP
+Here are some examples:
+.IP
+.nf
+\f[C]
+[my\ label\ 1]:\ /foo/bar.html\ \ "My\ title,\ optional"
+[my\ label\ 2]:\ /foo
+[my\ label\ 3]:\ http://fsf.org\ (The\ free\ software\ foundation)
+[my\ label\ 4]:\ /bar#special\ \ \[aq]A\ title\ in\ single\ quotes\[aq]
+\f[]
+.fi
+.PP
+The URL may optionally be surrounded by angle brackets:
+.IP
+.nf
+\f[C]
+[my\ label\ 5]:\ <http://foo.bar.baz>
+\f[]
+.fi
+.PP
+The title may go on the next line:
+.IP
+.nf
+\f[C]
+[my\ label\ 3]:\ http://fsf.org
+\ \ "The\ free\ software\ foundation"
+\f[]
+.fi
+.PP
+Note that link labels are not case sensitive.
+So, this will work:
+.IP
+.nf
+\f[C]
+Here\ is\ [my\ link][FOO]
+
+[Foo]:\ /bar/baz
+\f[]
+.fi
+.PP
+In an \f[I]implicit\f[] reference link, the second pair of brackets is
+empty, or omitted entirely:
+.IP
+.nf
+\f[C]
+See\ [my\ website][],\ or\ [my\ website].
+
+[my\ website]:\ http://foo.bar.baz
+\f[]
+.fi
+.SH IMAGES
+.PP
+A link immediately preceded by a \f[C]!\f[] will be treated as an image.
+The link text will be used as the image\[aq]s alt text:
+.IP
+.nf
+\f[C]
+![la\ lune](lalune.jpg\ "Voyage\ to\ the\ moon")
+
+![movie\ reel]
+
+[movie\ reel]:\ movie.gif
+\f[]
+.fi
+.SS Pictures with captions
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+An image occurring by itself in a paragraph will be rendered as a figure
+with a caption.[4] (In LaTeX, a figure environment will be used; in
+HTML, the image will be placed in a \f[C]div\f[] with class
+\f[C]figure\f[], together with a caption in a \f[C]p\f[] with class
+\f[C]caption\f[].)
+ The image\[aq]s alt text will be used as the caption.
+.IP
+.nf
+\f[C]
+![This\ is\ the\ caption](/url/of/image.png)
+\f[]
+.fi
+.PP
+If you just want a regular inline image, just make sure it is not the
+only thing in the paragraph.
+One way to do this is to insert a nonbreaking space after the image:
+.IP
+.nf
+\f[C]
+![This\ image\ won\[aq]t\ be\ a\ figure](/url/of/image.png)\\\
+\f[]
+.fi
+.SH FOOTNOTES
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Pandoc\[aq]s markdown allows footnotes, using the following syntax:
+.IP
+.nf
+\f[C]
+Here\ is\ a\ footnote\ reference,[^1]\ and\ another.[^longnote]
+
+[^1]:\ Here\ is\ the\ footnote.
+
+[^longnote]:\ Here\[aq]s\ one\ with\ multiple\ blocks.
+
+\ \ \ \ Subsequent\ paragraphs\ are\ indented\ to\ show\ that\ they\
+belong\ to\ the\ previous\ footnote.
+
+\ \ \ \ \ \ \ \ {\ some.code\ }
+
+\ \ \ \ The\ whole\ paragraph\ can\ be\ indented,\ or\ just\ the\ first
+\ \ \ \ line.\ \ In\ this\ way,\ multi-paragraph\ footnotes\ work\ like
+\ \ \ \ multi-paragraph\ list\ items.
+
+This\ paragraph\ won\[aq]t\ be\ part\ of\ the\ note,\ because\ it
+isn\[aq]t\ indented.
+\f[]
+.fi
+.PP
+The identifiers in footnote references may not contain spaces, tabs, or
+newlines.
+These identifiers are used only to correlate the footnote reference with
+the note itself; in the output, footnotes will be numbered sequentially.
+.PP
+The footnotes themselves need not be placed at the end of the document.
+They may appear anywhere except inside other block elements (lists,
+block quotes, tables, etc.)
+\&.
+.PP
+Inline footnotes are also allowed (though, unlike regular notes, they
+cannot contain multiple paragraphs).
+The syntax is as follows:
+.IP
+.nf
+\f[C]
+Here\ is\ an\ inline\ note.^[Inlines\ notes\ are\ easier\ to\ write,\ since
+you\ don\[aq]t\ have\ to\ pick\ an\ identifier\ and\ move\ down\ to\ type\ the
+note.]
+\f[]
+.fi
+.PP
+Inline and regular footnotes may be mixed freely.
+.SH CITATIONS
+.PP
+\f[I]Pandoc extension\f[].
+.PP
+Pandoc can automatically generate citations and a bibliography in a
+number of styles (using Andrea Rossato\[aq]s \f[C]hs-citeproc\f[]).
+In order to use this feature, you will need a bibliographic database in
+one of the following formats:
+.PP
+.TS
+tab(@);
+l l.
+T{
+Format
+T}@T{
+File extension
+T}
+_
+T{
+MODS
+T}@T{
+\&.mods
+T}
+T{
+BibTeX
+T}@T{
+\&.bib
+T}
+T{
+BibLaTeX
+T}@T{
+\&.bbx
+T}
+T{
+RIS
+T}@T{
+\&.ris
+T}
+T{
+EndNote
+T}@T{
+\&.enl
+T}
+T{
+EndNote XML
+T}@T{
+\&.xml
+T}
+T{
+ISI
+T}@T{
+\&.wos
+T}
+T{
+MEDLINE
+T}@T{
+\&.medline
+T}
+T{
+Copac
+T}@T{
+\&.copac
+T}
+T{
+JSON citeproc
+T}@T{
+\&.json
+T}
+.TE
+.PP
+You will need to specify the bibliography file using the
+\f[C]--bibliography\f[] command-line option (which may be repeated if
+you have several bibliographies).
+.PP
+By default, pandoc will use a Chicago author-date format for citations
+and references.
+To use another style, you will need to use the \f[C]--csl\f[] option to
+specify a CSL 1.0 style file.
+A primer on creating and modifying CSL styles can be found at
+\f[C]http://citationstyles.org/downloads/primer.html\f[].
+A repository of CSL styles can be found at
+\f[C]https://github.com/citation-style-language/styles\f[].
+.PP
+Citations go inside square brackets and are separated by semicolons.
+Each citation must have a key, composed of \[aq]\@\[aq] + the citation
+identifier from the database, and may optionally have a prefix, a
+locator, and a suffix.
+Here are some examples:
+.IP
+.nf
+\f[C]
+Blah\ blah\ [see\ \@doe99,\ pp.\ 33-35;\ also\ \@smith04,\ ch.\ 1].
+
+Blah\ blah\ [\@doe99,\ pp.\ 33-35,\ 38-39\ and\ *passim*].
+
+Blah\ blah\ [\@smith04;\ \@doe99].
+\f[]
+.fi
+.PP
+A minus sign (\f[C]-\f[]) before the \f[C]\@\f[] will suppress mention
+of the author in the citation.
+This can be useful when the author is already mentioned in the text:
+.IP
+.nf
+\f[C]
+Smith\ says\ blah\ [-\@smith04].
+\f[]
+.fi
+.PP
+You can also write an in-text citation, as follows:
+.IP
+.nf
+\f[C]
+\@smith04\ says\ blah.
+
+\@smith04\ [p.\ 33]\ says\ blah.
+\f[]
+.fi
+.PP
+If the style calls for a list of works cited, it will be placed at the
+end of the document.
+Normally, you will want to end your document with an appropriate header:
+.IP
+.nf
+\f[C]
+last\ paragraph...
+
+#\ References
+\f[]
+.fi
+.PP
+The bibliography will be inserted after this header.
+.SH NOTES
+.SS [1]
+.PP
+The point of this rule is to ensure that normal paragraphs starting with
+people\[aq]s initials, like
+.IP
+.nf
+\f[C]
+B.\ Russell\ was\ an\ English\ philosopher.
+\f[]
+.fi
+.PP
+do not get treated as list items.
+.PP
+This rule will not prevent
+.IP
+.nf
+\f[C]
+(C)\ 2007\ Joe\ Smith
+\f[]
+.fi
+.PP
+from being interpreted as a list item.
+In this case, a backslash escape can be used:
+.IP
+.nf
+\f[C]
+(C\\)\ 2007\ Joe\ Smith
+\f[]
+.fi
+.SS [2]
+.PP
+I have also been influenced by the suggestions of David Wheeler.
+.SS [3]
+.PP
+This scheme is due to Michel Fortin, who proposed it on the Markdown
+discussion list.
+.SS [4]
+.PP
+This feature is not yet implemented for RTF, OpenDocument, or ODT.
+In those formats, you\[aq]ll just get an image in a paragraph by itself,
+with no caption.
+.SH SEE ALSO
+.PP
+\f[C]pandoc\f[] (1).
diff --git a/man/man5/pandoc_markdown.5.template b/man/man5/pandoc_markdown.5.template
new file mode 100644
index 000000000..f775a4683
--- /dev/null
+++ b/man/man5/pandoc_markdown.5.template
@@ -0,0 +1,11 @@
+$if(has-tables)$
+.\"t
+$endif$
+.TH PANDOC_MARKDOWN 5 "$date$" "$title$"
+.SH NAME
+pandoc_markdown - markdown syntax for pandoc(1)
+.SH DESCRIPTION
+$body$
+.SH SEE ALSO
+.PP
+\f[C]pandoc\f[] (1).
diff --git a/pandoc.cabal b/pandoc.cabal
index 60e719d12..9d75c6062 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,6 +1,6 @@
Name: pandoc
-Version: 1.6
-Cabal-Version: >= 1.2
+Version: 1.8.0.1
+Cabal-Version: >= 1.6
Build-Type: Custom
License: GPL
License-File: COPYING
@@ -11,15 +11,16 @@ Bug-Reports: http://code.google.com/p/pandoc/issues/list
Stability: alpha
Homepage: http://johnmacfarlane.net/pandoc
Category: Text
-Tested-With: GHC == 6.12.1
+Tested-With: GHC == 6.12.1, GHC == 6.12.3, GHC == 7.0.1
Synopsis: Conversion between markup formats
Description: Pandoc is a Haskell library for converting from one markup
format to another, and a command-line tool that uses
this library. It can read markdown and (subsets of)
- reStructuredText, HTML, and LaTeX, and it can write
+ reStructuredText, HTML, LaTeX and Textile, and it can write
markdown, reStructuredText, HTML, LaTeX, ConTeXt, Docbook,
- OpenDocument, ODT, RTF, MediaWiki, groff man pages, EPUB,
- and S5 and Slidy HTML slide shows.
+ OpenDocument, ODT, RTF, MediaWiki, Textile, groff man pages,
+ plain text, Emacs Org-Mode, EPUB, and S5 and Slidy HTML
+ slide shows.
.
Pandoc extends standard markdown syntax with footnotes,
embedded LaTeX, definition lists, tables, and other
@@ -43,6 +44,7 @@ Data-Files:
templates/rst.template, templates/plain.template,
templates/mediawiki.template, templates/rtf.template,
templates/s5.template, templates/slidy.template,
+ templates/textile.template, templates/org.template
-- data for ODT writer
reference.odt,
-- stylesheet for EPUB writer
@@ -62,11 +64,23 @@ Data-Files:
-- data for slidy writer
slidy/slidy.min.css,
slidy/slidy.min.js,
+ -- data for citeproc
+ default.csl,
-- documentation
README, INSTALL, COPYRIGHT, BUGS, changelog
Extra-Source-Files:
-- sources for man pages
- man/man1/pandoc.1.md, man/man1/markdown2pdf.1.md,
+ man/man1/markdown2pdf.1.md,
+ -- code to create pandoc.1 man page
+ MakeManPage.hs,
+ man/man1/pandoc.1.template,
+ man/man5/pandoc_markdown.5.template,
+ -- generated man pages (produced post-build)
+ man/man1/markdown2pdf.1,
+ man/man1/pandoc.1,
+ man/man5/pandoc_markdown.5,
+ -- benchmarks
+ Benchmark.hs,
-- tests
tests/bodybg.gif,
tests/html-reader.html,
@@ -74,10 +88,21 @@ Extra-Source-Files:
tests/insert,
tests/lalune.jpg,
tests/movie.jpg,
+ tests/biblio.bib,
+ tests/chicago-author-date.csl,
+ tests/ieee.csl,
+ tests/mhra.csl,
tests/latex-reader.latex,
tests/latex-reader.native,
+ tests/textile-reader.textile,
+ tests/textile-reader.native,
tests/markdown-reader-more.txt,
tests/markdown-reader-more.native,
+ tests/markdown-citations.txt,
+ tests/markdown-citations.chicago-author-date.txt,
+ tests/markdown-citations.mhra.txt,
+ tests/markdown-citations.ieee.txt,
+ tests/textile-reader.textile,
tests/rst-reader.native,
tests/rst-reader.rst,
tests/s5.basic.html,
@@ -93,8 +118,10 @@ Extra-Source-Files:
tests/tables.plain,
tests/tables.markdown,
tests/tables.mediawiki,
+ tests/tables.textile,
tests/tables.native,
tests/tables.opendocument,
+ tests/tables.org,
tests/tables.texinfo,
tests/tables.rst,
tests/tables.rtf,
@@ -110,8 +137,10 @@ Extra-Source-Files:
tests/writer.markdown,
tests/writer.plain,
tests/writer.mediawiki,
+ tests/writer.textile,
tests/writer.native,
tests/writer.opendocument,
+ tests/writer.org,
tests/writer.rst,
tests/writer.rtf,
tests/writer.texinfo,
@@ -124,9 +153,12 @@ Extra-Source-Files:
tests/lhs-test.latex+lhs,
tests/lhs-test.html,
tests/lhs-test.html+lhs,
- tests/lhs-test.fragment.html+lhs,
- tests/RunTests.hs
-Extra-Tmp-Files: man/man1/pandoc.1, man/man1/markdown2pdf.1
+ tests/lhs-test.nohl.html,
+ tests/lhs-test.nohl.html+lhs,
+ tests/lhs-test.fragment.html+lhs
+Extra-Tmp-Files: man/man1/pandoc.1,
+ man/man1/markdown2pdf.1,
+ man/man5/pandoc_markdown.5
Flag threaded
Description: Compile markdown2pdf with -threaded option.
@@ -143,44 +175,57 @@ Flag library
Flag wrappers
Description: Build the wrappers (markdown2pdf).
Default: True
-Flag citeproc
- Description: Compile in support for citeproc-hs bibliographic formatting.
+Flag tests
+ Description: Build test-pandoc.
+ Default: False
+Flag benchmarks
+ Description: Build benchmark-pandoc.
Default: False
Library
-- Note: the following material must be in both Library and Executable stanzas.
-- It needs to be duplicated because of the library & executable flags.
-- BEGIN DUPLICATED SECTION
- Build-Depends: pretty >= 1, containers >= 0.1,
- parsec >= 2.1, xhtml >= 3000.0,
- mtl >= 1.1, network >= 2, filepath >= 1.1,
- process >= 1, directory >= 1,
- bytestring >= 0.9, zip-archive >= 0.1.1.4,
- utf8-string >= 0.3, old-time >= 1,
- HTTP >= 4000.0.5, texmath >= 0.3, xml >= 1.3.5 && < 1.4,
- random, extensible-exceptions
+ Build-Depends: containers >= 0.1 && < 0.5,
+ parsec >= 2.1 && < 3.2,
+ xhtml >= 3000.0 && < 3000.3,
+ mtl >= 1.1 && < 2.1,
+ network >= 2 && < 2.4,
+ filepath >= 1.1 && < 1.3,
+ process >= 1 && < 1.1,
+ directory >= 1 && < 1.2,
+ bytestring >= 0.9 && < 1.0,
+ zip-archive >= 0.1.1.7 && < 0.2,
+ utf8-string >= 0.3 && < 0.4,
+ old-time >= 1 && < 1.1,
+ HTTP >= 4000.0.5 && < 4000.2,
+ texmath >= 0.5 && < 0.6,
+ xml >= 1.3.5 && < 1.4,
+ random >= 1 && < 1.1,
+ extensible-exceptions >= 0.1 && < 0.2,
+ citeproc-hs >= 0.3.1 && < 0.4,
+ pandoc-types == 1.8.*,
+ json >= 0.4 && < 0.5,
+ dlist >= 0.4 && < 0.6,
+ tagsoup >= 0.12 && < 0.13
if impl(ghc >= 6.10)
- Build-depends: base >= 4 && < 5, syb
+ Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
else
Build-depends: base >= 3 && < 4
if flag(highlighting)
- Build-depends: highlighting-kate >= 0.2.7.1
+ Build-depends: highlighting-kate >= 0.2.9 && < 0.3
cpp-options: -D_HIGHLIGHTING
- if flag(citeproc)
- Build-depends: citeproc-hs >= 0.2
- cpp-options: -D_CITEPROC
if impl(ghc >= 6.12)
Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind
else
Ghc-Options: -O2 -Wall
- Ghc-Prof-Options: -auto-all -caf-all
+ Ghc-Prof-Options: -auto-all -caf-all
Extensions: CPP
Hs-Source-Dirs: src
-- END DUPLICATED SECTION
Exposed-Modules: Text.Pandoc,
- Text.Pandoc.Blocks,
- Text.Pandoc.Definition,
+ Text.Pandoc.Pretty,
Text.Pandoc.CharacterReferences,
Text.Pandoc.Shared,
Text.Pandoc.Parsing,
@@ -190,6 +235,8 @@ Library
Text.Pandoc.Readers.Markdown,
Text.Pandoc.Readers.RST,
Text.Pandoc.Readers.TeXMath,
+ Text.Pandoc.Readers.Textile,
+ Text.Pandoc.Readers.Native,
Text.Pandoc.Writers.Native,
Text.Pandoc.Writers.Docbook,
Text.Pandoc.Writers.HTML,
@@ -200,19 +247,20 @@ Library
Text.Pandoc.Writers.Man,
Text.Pandoc.Writers.Markdown,
Text.Pandoc.Writers.RST,
+ Text.Pandoc.Writers.Org,
+ Text.Pandoc.Writers.Textile,
Text.Pandoc.Writers.MediaWiki,
Text.Pandoc.Writers.RTF,
Text.Pandoc.Writers.ODT,
Text.Pandoc.Writers.EPUB,
Text.Pandoc.S5,
Text.Pandoc.Templates
+ Text.Pandoc.Biblio
Other-Modules: Text.Pandoc.XML,
Text.Pandoc.UTF8,
Text.Pandoc.UUID,
Paths_pandoc
- if flag(citeproc)
- Exposed-Modules: Text.Pandoc.Biblio
if flag(library)
Buildable: True
else
@@ -222,38 +270,49 @@ Executable pandoc
-- Note: the following material must be in both Library and Executable stanzas.
-- It needs to be duplicated because of the library & executable flags.
-- BEGIN DUPLICATED SECTION
- Build-Depends: pretty >= 1, containers >= 0.1,
- parsec >= 2.1, xhtml >= 3000.0,
- mtl >= 1.1, network >= 2, filepath >= 1.1,
- process >= 1, directory >= 1,
- bytestring >= 0.9, zip-archive >= 0.1.1.4,
- utf8-string >= 0.3, old-time >= 1,
- HTTP >= 4000.0.5, texmath, xml >= 1.3.5 && < 1.4,
- random, extensible-exceptions
+ Build-Depends: containers >= 0.1 && < 0.5,
+ parsec >= 2.1 && < 3.2,
+ xhtml >= 3000.0 && < 3000.3,
+ mtl >= 1.1 && < 2.1,
+ network >= 2 && < 2.4,
+ filepath >= 1.1 && < 1.3,
+ process >= 1 && < 1.1,
+ directory >= 1 && < 1.2,
+ bytestring >= 0.9 && < 1.0,
+ zip-archive >= 0.1.1.7 && < 0.2,
+ utf8-string >= 0.3 && < 0.4,
+ old-time >= 1 && < 1.1,
+ HTTP >= 4000.0.5 && < 4000.2,
+ texmath >= 0.5 && < 0.6,
+ xml >= 1.3.5 && < 1.4,
+ random >= 1 && < 1.1,
+ extensible-exceptions >= 0.1 && < 0.2,
+ citeproc-hs >= 0.3.1 && < 0.4,
+ pandoc-types == 1.8.*,
+ json >= 0.4 && < 0.5,
+ dlist >= 0.4 && < 0.6,
+ tagsoup >= 0.12 && < 0.13
if impl(ghc >= 6.10)
- Build-depends: base >= 4 && < 5, syb
+ Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
else
Build-depends: base >= 3 && < 4
if flag(highlighting)
- Build-depends: highlighting-kate >= 0.2.7.1
+ Build-depends: highlighting-kate >= 0.2.9 && < 0.3
cpp-options: -D_HIGHLIGHTING
- if flag(citeproc)
- Build-depends: citeproc-hs >= 0.2
- cpp-options: -D_CITEPROC
if impl(ghc >= 6.12)
Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind
else
Ghc-Options: -O2 -Wall
- Ghc-Prof-Options: -auto-all -caf-all
+ Ghc-Prof-Options: -auto-all -caf-all
Extensions: CPP
Hs-Source-Dirs: src
-- END DUPLICATED SECTION
Main-Is: pandoc.hs
if flag(executable) || flag(wrappers)
- Buildable: True
+ Buildable: True
else
- Buildable: False
+ Buildable: False
Executable markdown2pdf
Hs-Source-Dirs: src
@@ -265,7 +324,41 @@ Executable markdown2pdf
Ghc-Prof-Options: -auto-all
Extensions: CPP
if flag(wrappers)
- Buildable: True
+ Buildable: True
else
- Buildable: False
+ Buildable: False
+Executable test-pandoc
+ Hs-Source-Dirs: src
+ Main-Is: test-pandoc.hs
+ if flag(highlighting)
+ cpp-options: -D_HIGHLIGHTING
+ if impl(ghc >= 7)
+ cpp-options: -D_LIT=lit
+ else
+ cpp-options: -D_LIT=$lit
+ if !flag(tests)
+ Buildable: False
+ else
+ if impl(ghc >= 6.12)
+ Ghc-Options: -Wall -fno-warn-unused-do-bind
+ else
+ Ghc-Options: -Wall
+ Extensions: CPP
+ Build-Depends: base >= 4 && < 5, Diff, test-framework >= 0.3 && < 0.4,
+ test-framework-hunit >= 0.2 && < 0.3,
+ test-framework-quickcheck2 >= 0.2.9 && < 0.3,
+ QuickCheck >= 2.4 && < 2.6,
+ HUnit >= 1.2 && < 1.3,
+ template-haskell >= 2.4 && < 2.6,
+ ansi-terminal == 0.5.*
+ Other-Modules: Tests.Old
+ Tests.Helpers
+ Tests.Arbitrary
+ Tests.Shared
+ Tests.Readers.LaTeX
+ Tests.Readers.Markdown
+ Tests.Readers.RST
+ Tests.Writers.Native
+ Tests.Writers.ConTeXt
+ Tests.Writers.HTML
diff --git a/src/Tests/Arbitrary.hs b/src/Tests/Arbitrary.hs
new file mode 100644
index 000000000..978717bef
--- /dev/null
+++ b/src/Tests/Arbitrary.hs
@@ -0,0 +1,181 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+-- provides Arbitrary instance for Pandoc types
+module Tests.Arbitrary ()
+where
+import Test.QuickCheck.Gen
+import Test.QuickCheck.Arbitrary
+import Control.Monad (liftM, liftM2)
+import Text.Pandoc
+import Text.Pandoc.Shared
+import Text.Pandoc.Builder
+
+realString :: Gen String
+realString = resize 8 arbitrary -- elements wordlist
+
+{-
+wordlist :: [String]
+wordlist = ["foo","Bar","baz","\\","/",":","\"","'","féé"]
+-}
+
+instance Arbitrary Inlines where
+ arbitrary = liftM fromList arbitrary
+
+instance Arbitrary Blocks where
+ arbitrary = liftM fromList arbitrary
+
+instance Arbitrary Inline where
+ arbitrary = resize 3 $ arbInline 3
+
+-- restrict to 3 levels of nesting max; otherwise we get
+-- bogged down in indefinitely large structures
+arbInline :: Int -> Gen Inline
+arbInline n = frequency $ [ (60, liftM Str realString)
+ , (60, return Space)
+ , (10, liftM2 Code arbitrary realString)
+ , (5, return EmDash)
+ , (5, return EnDash)
+ , (5, return Apostrophe)
+ , (5, return Ellipses)
+ , (5, elements [ RawInline "html" "<a>*&amp;*</a>"
+ , RawInline "latex" "\\my{command}" ])
+ ] ++ [ x | x <- nesters, n > 1]
+ where nesters = [ (10, liftM Emph $ listOf $ arbInline (n-1))
+ , (10, liftM Strong $ listOf $ arbInline (n-1))
+ , (10, liftM Strikeout $ listOf $ arbInline (n-1))
+ , (10, liftM Superscript $ listOf $ arbInline (n-1))
+ , (10, liftM Subscript $ listOf $ arbInline (n-1))
+ , (10, liftM SmallCaps $ listOf $ arbInline (n-1))
+ , (10, do x1 <- arbitrary
+ x2 <- listOf $ arbInline (n-1)
+ return $ Quoted x1 x2)
+ , (10, do x1 <- arbitrary
+ x2 <- realString
+ return $ Math x1 x2)
+ , (10, do x1 <- listOf $ arbInline (n-1)
+ x3 <- realString
+ x2 <- realString
+ return $ Link x1 (x2,x3))
+ , (10, do x1 <- listOf $ arbInline (n-1)
+ x3 <- realString
+ x2 <- realString
+ return $ Image x1 (x2,x3))
+ , (2, liftM Note $ resize 3 $ listOf1 arbitrary)
+ ]
+
+instance Arbitrary Block where
+ arbitrary = resize 3 $ arbBlock 3
+
+arbBlock :: Int -> Gen Block
+arbBlock n = frequency $ [ (10, liftM Plain arbitrary)
+ , (15, liftM Para arbitrary)
+ , (5, liftM2 CodeBlock arbitrary realString)
+ , (2, elements [ RawBlock "html"
+ "<div>\n*&amp;*\n</div>"
+ , RawBlock "latex"
+ "\\begin[opt]{env}\nhi\n{\\end{env}"
+ ])
+ , (5, do x1 <- choose (1 :: Int, 6)
+ x2 <- arbitrary
+ return (Header x1 x2))
+ , (2, return HorizontalRule)
+ ] ++ [x | x <- nesters, n > 0]
+ where nesters = [ (5, liftM BlockQuote $ listOf $ arbBlock (n-1))
+ , (5, liftM2 OrderedList arbitrary
+ $ (listOf1 $ listOf1 $ arbBlock (n-1)))
+ , (5, liftM BulletList $ (listOf1 $ listOf1 $ arbBlock (n-1)))
+ , (5, do x1 <- listOf $ listOf1 $ listOf1 $ arbBlock (n-1)
+ x2 <- arbitrary
+ return (DefinitionList $ zip x2 x1))
+ , (2, do rs <- choose (1 :: Int, 4)
+ cs <- choose (1 :: Int, 4)
+ x1 <- arbitrary
+ x2 <- vector cs
+ x3 <- vectorOf cs $ elements [0, 0.25]
+ x4 <- vectorOf cs $ listOf $ arbBlock (n-1)
+ x5 <- vectorOf rs $ vectorOf cs
+ $ listOf $ arbBlock (n-1)
+ return (Table x1 x2 x3 x4 x5))
+ ]
+
+instance Arbitrary Pandoc where
+ arbitrary = resize 8 $ liftM normalize
+ $ liftM2 Pandoc arbitrary arbitrary
+
+{-
+instance Arbitrary CitationMode where
+ arbitrary
+ = do x <- choose (0 :: Int, 2)
+ case x of
+ 0 -> return AuthorInText
+ 1 -> return SuppressAuthor
+ 2 -> return NormalCitation
+ _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
+
+instance Arbitrary Citation where
+ arbitrary
+ = do x1 <- liftM (filter (`notElem` ",;]@ \t\n")) arbitrary
+ x2 <- arbitrary
+ x3 <- arbitrary
+ x4 <- arbitrary
+ x5 <- arbitrary
+ x6 <- arbitrary
+ return (Citation x1 x2 x3 x4 x5 x6)
+-}
+
+instance Arbitrary MathType where
+ arbitrary
+ = do x <- choose (0 :: Int, 1)
+ case x of
+ 0 -> return DisplayMath
+ 1 -> return InlineMath
+ _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
+
+instance Arbitrary QuoteType where
+ arbitrary
+ = do x <- choose (0 :: Int, 1)
+ case x of
+ 0 -> return SingleQuote
+ 1 -> return DoubleQuote
+ _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
+
+instance Arbitrary Meta where
+ arbitrary
+ = do x1 <- arbitrary
+ x2 <- liftM (filter (not . null)) arbitrary
+ x3 <- arbitrary
+ return (Meta x1 x2 x3)
+
+instance Arbitrary Alignment where
+ arbitrary
+ = do x <- choose (0 :: Int, 3)
+ case x of
+ 0 -> return AlignLeft
+ 1 -> return AlignRight
+ 2 -> return AlignCenter
+ 3 -> return AlignDefault
+ _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
+
+instance Arbitrary ListNumberStyle where
+ arbitrary
+ = do x <- choose (0 :: Int, 6)
+ case x of
+ 0 -> return DefaultStyle
+ 1 -> return Example
+ 2 -> return Decimal
+ 3 -> return LowerRoman
+ 4 -> return UpperRoman
+ 5 -> return LowerAlpha
+ 6 -> return UpperAlpha
+ _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
+
+instance Arbitrary ListNumberDelim where
+ arbitrary
+ = do x <- choose (0 :: Int, 3)
+ case x of
+ 0 -> return DefaultDelim
+ 1 -> return Period
+ 2 -> return OneParen
+ 3 -> return TwoParens
+ _ -> error "FATAL ERROR: Arbitrary instance, logic bug"
+
diff --git a/src/Tests/Helpers.hs b/src/Tests/Helpers.hs
new file mode 100644
index 000000000..b8d6b83a7
--- /dev/null
+++ b/src/Tests/Helpers.hs
@@ -0,0 +1,116 @@
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, TemplateHaskell #-}
+-- Utility functions for the test suite.
+
+module Tests.Helpers ( lit
+ , file
+ , test
+ , (=?>)
+ , property
+ , ToString(..)
+ , ToPandoc(..)
+ )
+ where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder (Inlines, Blocks, doc, plain)
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.Framework.Providers.QuickCheck2
+import Test.HUnit (assertBool)
+import Text.Pandoc.Shared (normalize, defaultWriterOptions,
+ WriterOptions(..), removeTrailingSpace)
+import Text.Pandoc.Writers.Native (writeNative)
+import Language.Haskell.TH.Quote (QuasiQuoter(..))
+import Language.Haskell.TH.Syntax (Q, runIO)
+import qualified Test.QuickCheck.Property as QP
+import System.Console.ANSI
+import Data.Algorithm.Diff
+
+lit :: QuasiQuoter
+lit = QuasiQuoter {
+ quoteExp = (\a -> let b = rnl a in [|b|]) . filter (/= '\r')
+ , quotePat = error "Cannot use lit as a pattern"
+ }
+ where rnl ('\n':xs) = xs
+ rnl xs = xs
+
+file :: QuasiQuoter
+file = quoteFile lit
+
+-- adapted from TH 2.5 code
+quoteFile :: QuasiQuoter -> QuasiQuoter
+quoteFile (QuasiQuoter { quoteExp = qe, quotePat = qp }) =
+ QuasiQuoter { quoteExp = get qe, quotePat = get qp }
+ where
+ get :: (String -> Q a) -> String -> Q a
+ get old_quoter file_name = do { file_cts <- runIO (readFile file_name)
+ ; old_quoter file_cts }
+
+test :: (ToString a, ToString b, ToString c)
+ => (a -> b) -- ^ function to test
+ -> String -- ^ name of test case
+ -> (a, c) -- ^ (input, expected value)
+ -> Test
+test fn name (input, expected) =
+ testCase name $ assertBool msg (actual' == expected')
+ where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++
+ dashes "expected" ++ nl ++ expected'' ++
+ dashes "got" ++ nl ++ actual'' ++
+ dashes ""
+ nl = "\n"
+ input' = toString input
+ actual' = toString $ fn input
+ expected' = toString expected
+ diff = getDiff (lines expected') (lines actual')
+ expected'' = unlines $ map vividize $ filter (\(d,_) -> d /= S) diff
+ actual'' = unlines $ map vividize $ filter (\(d,_) -> d /= F) diff
+ dashes "" = replicate 72 '-'
+ dashes x = replicate (72 - length x - 5) '-' ++ " " ++ x ++ " ---"
+
+vividize :: (DI,String) -> String
+vividize (B,s) = s
+vividize (_,s) = vivid s
+
+property :: QP.Testable a => TestName -> a -> Test
+property = testProperty
+
+vivid :: String -> String
+vivid s = setSGRCode [SetColor Background Dull Red
+ , SetColor Foreground Vivid White] ++ s
+ ++ setSGRCode [Reset]
+
+infix 6 =?>
+(=?>) :: a -> b -> (a,b)
+x =?> y = (x, y)
+
+class ToString a where
+ toString :: a -> String
+
+instance ToString Pandoc where
+ toString d = writeNative defaultWriterOptions{ writerStandalone = s }
+ $ toPandoc d
+ where s = case d of
+ (Pandoc (Meta [] [] []) _) -> False
+ _ -> True
+
+instance ToString Blocks where
+ toString = writeNative defaultWriterOptions . toPandoc
+
+instance ToString Inlines where
+ toString = removeTrailingSpace . writeNative defaultWriterOptions .
+ toPandoc
+
+instance ToString String where
+ toString = id
+
+class ToPandoc a where
+ toPandoc :: a -> Pandoc
+
+instance ToPandoc Pandoc where
+ toPandoc = normalize
+
+instance ToPandoc Blocks where
+ toPandoc = normalize . doc
+
+instance ToPandoc Inlines where
+ toPandoc = normalize . doc . plain
diff --git a/src/Tests/Old.hs b/src/Tests/Old.hs
new file mode 100644
index 000000000..cb1417ffa
--- /dev/null
+++ b/src/Tests/Old.hs
@@ -0,0 +1,201 @@
+module Tests.Old (tests) where
+
+import Test.Framework (testGroup, Test )
+import Test.Framework.Providers.HUnit
+import Test.HUnit ( assertBool )
+
+import System.IO ( openTempFile, stderr )
+import System.Process ( runProcess, waitForProcess )
+import System.FilePath ( (</>), (<.>) )
+import System.Directory
+import System.Exit
+import Data.Algorithm.Diff
+import Text.Pandoc.Shared ( normalize, defaultWriterOptions )
+import Text.Pandoc.Writers.Native ( writeNative )
+import Text.Pandoc.Readers.Native ( readNative )
+import Text.Pandoc.Highlighting ( languages )
+import Prelude hiding ( readFile )
+import qualified Data.ByteString.Lazy as B
+import Data.ByteString.Lazy.UTF8 (toString)
+import Text.Printf
+
+readFileUTF8 :: FilePath -> IO String
+readFileUTF8 f = B.readFile f >>= return . toString
+
+pandocPath :: FilePath
+pandocPath = ".." </> "dist" </> "build" </> "pandoc" </> "pandoc"
+
+data TestResult = TestPassed
+ | TestError ExitCode
+ | TestFailed String FilePath [(DI, String)]
+ deriving (Eq)
+
+instance Show TestResult where
+ show TestPassed = "PASSED"
+ show (TestError ec) = "ERROR " ++ show ec
+ show (TestFailed cmd file d) = '\n' : dash ++
+ "\n--- " ++ file ++
+ "\n+++ " ++ cmd ++ "\n" ++ showDiff (1,1) d ++
+ dash
+ where dash = replicate 72 '-'
+
+showDiff :: (Int,Int) -> [(DI, String)] -> String
+showDiff _ [] = ""
+showDiff (l,r) ((F, ln) : ds) =
+ printf "+%4d " l ++ ln ++ "\n" ++ showDiff (l+1,r) ds
+showDiff (l,r) ((S, ln) : ds) =
+ printf "-%4d " r ++ ln ++ "\n" ++ showDiff (l,r+1) ds
+showDiff (l,r) ((B, _ ) : ds) =
+ showDiff (l+1,r+1) ds
+
+tests :: [Test]
+tests = [ testGroup "markdown"
+ [ testGroup "writer"
+ $ writerTests "markdown" ++ lhsWriterTests "markdown"
+ , testGroup "reader"
+ [ test "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
+ "testsuite.txt" "testsuite.native"
+ , test "tables" ["-r", "markdown", "-w", "native", "--columns=80"]
+ "tables.txt" "tables.native"
+ , test "more" ["-r", "markdown", "-w", "native", "-S"]
+ "markdown-reader-more.txt" "markdown-reader-more.native"
+ , lhsReaderTest "markdown+lhs"
+ ]
+ , testGroup "citations" markdownCitationTests
+ ]
+ , testGroup "rst"
+ [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
+ , testGroup "reader"
+ [ test "basic" ["-r", "rst", "-w", "native",
+ "-s", "-S", "--columns=80"] "rst-reader.rst" "rst-reader.native"
+ , test "tables" ["-r", "rst", "-w", "native", "--columns=80"]
+ "tables.rst" "tables-rstsubset.native"
+ , lhsReaderTest "rst+lhs"
+ ]
+ ]
+ , testGroup "latex"
+ [ testGroup "writer" (writerTests "latex" ++ lhsWriterTests "latex")
+ , testGroup "reader"
+ [ test "basic" ["-r", "latex", "-w", "native", "-s", "-R"]
+ "latex-reader.latex" "latex-reader.native"
+ , lhsReaderTest "latex+lhs"
+ ]
+ ]
+ , testGroup "html"
+ [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
+ , test "reader" ["-r", "html", "-w", "native", "-s"]
+ "html-reader.html" "html-reader.native"
+ ]
+ , testGroup "s5"
+ [ s5WriterTest "basic" ["-s"] "s5"
+ , s5WriterTest "fancy" ["-s","-m","-i"] "s5"
+ , s5WriterTest "fragment" [] "html"
+ , s5WriterTest "inserts" ["-s", "-H", "insert",
+ "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
+ ]
+ , testGroup "textile"
+ [ testGroup "writer" $ writerTests "textile"
+ , test "reader" ["-r", "textile", "-w", "native", "-s"]
+ "textile-reader.textile" "textile-reader.native"
+ ]
+ , testGroup "native"
+ [ testGroup "writer" $ writerTests "native"
+ , test "reader" ["-r", "native", "-w", "native", "-s"]
+ "testsuite.native" "testsuite.native"
+ ]
+ , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
+ [ "docbook", "opendocument" , "context" , "texinfo"
+ , "man" , "plain" , "mediawiki", "rtf", "org"
+ ]
+ ]
+
+-- makes sure file is fully closed after reading
+readFile' :: FilePath -> IO String
+readFile' f = do s <- readFileUTF8 f
+ return $! (length s `seq` s)
+
+lhsWriterTests :: String -> [Test]
+lhsWriterTests format
+ = [ t "lhs to normal" format
+ , t "lhs to lhs" (format ++ "+lhs")
+ ]
+ where
+ t n f = test n ["--columns=78", "-r", "native", "-s", "-w", f]
+ "lhs-test.native" ("lhs-test" <.> ext f)
+ ext f = if null languages && format == "html"
+ then "nohl" <.> f
+ else f
+
+lhsReaderTest :: String -> Test
+lhsReaderTest format =
+ testWithNormalize normalizer "lhs" ["-r", format, "-w", "native"]
+ ("lhs-test" <.> format) "lhs-test.native"
+ where normalizer = writeNative defaultWriterOptions . normalize . readNative
+
+writerTests :: String -> [Test]
+writerTests format
+ = [ test "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
+ , test "tables" opts "tables.native" ("tables" <.> format)
+ ]
+ where
+ opts = ["-r", "native", "-w", format, "--columns=78"]
+
+s5WriterTest :: String -> [String] -> String -> Test
+s5WriterTest modifier opts format
+ = test (format ++ " writer (" ++ modifier ++ ")")
+ (["-r", "native", "-w", format] ++ opts)
+ "s5.native" ("s5." ++ modifier <.> "html")
+
+markdownCitationTests :: [Test]
+markdownCitationTests
+ = map styleToTest ["chicago-author-date","ieee","mhra"]
+ ++ [test "natbib" wopts "markdown-citations.txt"
+ "markdown-citations.txt"]
+ where
+ ropts = ["-r", "markdown", "-w", "markdown", "--bibliography",
+ "biblio.bib", "--no-wrap"]
+ wopts = ropts ++ ["--natbib"]
+ styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
+ "markdown-citations.txt"
+ ("markdown-citations." ++ style ++ ".txt")
+
+-- | Run a test without normalize function, return True if test passed.
+test :: String -- ^ Title of test
+ -> [String] -- ^ Options to pass to pandoc
+ -> String -- ^ Input filepath
+ -> FilePath -- ^ Norm (for test results) filepath
+ -> Test
+test = testWithNormalize id
+
+-- | Run a test with normalize function, return True if test passed.
+testWithNormalize :: (String -> String) -- ^ Normalize function for output
+ -> String -- ^ Title of test
+ -> [String] -- ^ Options to pass to pandoc
+ -> String -- ^ Input filepath
+ -> FilePath -- ^ Norm (for test results) filepath
+ -> Test
+testWithNormalize normalizer testname opts inp norm = testCase testname $ do
+ (outputPath, hOut) <- openTempFile "" "pandoc-test"
+ let inpPath = inp
+ let normPath = norm
+ let options = ["--data-dir", ".."] ++ [inpPath] ++ opts
+ let cmd = pandocPath ++ " " ++ unwords options
+ ph <- runProcess pandocPath options Nothing
+ (Just [("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut)
+ (Just stderr)
+ ec <- waitForProcess ph
+ result <- if ec == ExitSuccess
+ then do
+ -- filter \r so the tests will work on Windows machines
+ outputContents <- readFile' outputPath >>=
+ return . filter (/='\r') . normalizer
+ normContents <- readFile' normPath >>=
+ return . filter (/='\r') . normalizer
+ if outputContents == normContents
+ then return TestPassed
+ else return
+ $ TestFailed cmd normPath
+ $ getDiff (lines outputContents) (lines normContents)
+ else return $ TestError ec
+ removeFile outputPath
+ assertBool (show result) (result == TestPassed)
diff --git a/src/Tests/Readers/LaTeX.hs b/src/Tests/Readers/LaTeX.hs
new file mode 100644
index 000000000..6d28441f8
--- /dev/null
+++ b/src/Tests/Readers/LaTeX.hs
@@ -0,0 +1,161 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.LaTeX (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+latex :: String -> Pandoc
+latex = readLaTeX defaultParserState
+
+infix 5 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test latex
+
+tests :: [Test]
+tests = [ testGroup "basic"
+ [ "simple" =:
+ "word" =?> para "word"
+ , "space" =:
+ "some text" =?> para ("some text")
+ , "emphasized" =:
+ "\\emph{emphasized}" =?> para (emph "emphasized")
+ ]
+
+ , testGroup "headers"
+ [ "level 1" =:
+ "\\section{header}" =?> header 1 "header"
+ , "level 2" =:
+ "\\subsection{header}" =?> header 2 "header"
+ , "level 3" =:
+ "\\subsubsection{header}" =?> header 3 "header"
+ , "emph" =:
+ "\\section{text \\emph{emph}}" =?>
+ header 1 ("text" +++ space +++ emph "emph")
+ , "link" =:
+ "\\section{text \\href{/url}{link}}" =?>
+ header 1 ("text" +++ space +++ link "/url" "" "link")
+ ]
+
+ , testGroup "space and comments"
+ [ "blank lines + space at beginning" =:
+ "\n \n hi" =?> para "hi"
+ , "blank lines + space + comments" =:
+ "% my comment\n\n \n % another\n\nhi" =?> para "hi"
+ , "comment in paragraph" =:
+ "hi % this is a comment\nthere\n" =?> para "hi there"
+ ]
+
+ , testGroup "citations"
+ [ natbibCitations
+ , biblatexCitations
+ ]
+ ]
+
+baseCitation :: Citation
+baseCitation = Citation{ citationId = "item1"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0 }
+
+natbibCitations :: Test
+natbibCitations = testGroup "natbib"
+ [ "citet" =: "\\citet{item1}"
+ =?> para (cite [baseCitation] empty)
+ , "suffix" =: "\\citet[p.~30]{item1}"
+ =?> para
+ (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] empty)
+ , "suffix long" =: "\\citet[p.~30, with suffix]{item1}"
+ =?> para (cite [baseCitation{ citationSuffix =
+ toList $ text "p.\160\&30, with suffix" }] empty)
+ , "multiple" =: "\\citeauthor{item1} \\citetext{\\citeyear{item1}; \\citeyear[p.~30]{item2}; \\citealp[see also][]{item3}}"
+ =?> para (cite [baseCitation{ citationMode = AuthorInText }
+ ,baseCitation{ citationMode = SuppressAuthor
+ , citationSuffix = [Str "p.\160\&30"]
+ , citationId = "item2" }
+ ,baseCitation{ citationId = "item3"
+ , citationPrefix = [Str "see",Space,Str "also"]
+ , citationMode = NormalCitation }
+ ] empty)
+ , "group" =: "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Str "see"]
+ , citationSuffix = [Str "p.\160\&34",EnDash,Str "35"] }
+ ,baseCitation{ citationMode = NormalCitation
+ , citationId = "item3"
+ , citationPrefix = [Str "also"]
+ , citationSuffix = [Str "chap.",Space,Str "3"] }
+ ] empty)
+ , "suffix and locator" =: "\\citep[pp.~33, 35--37, and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = [Str "pp.\160\&33,",Space,Str "35",EnDash,Str "37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] empty)
+ , "suffix only" =: "\\citep[and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = toList $ text "and nowhere else" }] empty)
+ , "no author" =: "\\citeyearpar{item1}, and now Doe with a locator \\citeyearpar[p.~44]{item2}"
+ =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] empty +++
+ text ", and now Doe with a locator " +++
+ cite [baseCitation{ citationMode = SuppressAuthor
+ , citationSuffix = [Str "p.\160\&44"]
+ , citationId = "item2" }] empty)
+ , "markup" =: "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Emph [Str "see"]]
+ , citationSuffix = [Str "p.",Space,
+ Strong [Str "32"]] }] empty)
+ ]
+
+biblatexCitations :: Test
+biblatexCitations = testGroup "biblatex"
+ [ "textcite" =: "\\textcite{item1}"
+ =?> para (cite [baseCitation] empty)
+ , "suffix" =: "\\textcite[p.~30]{item1}"
+ =?> para
+ (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] empty)
+ , "suffix long" =: "\\textcite[p.~30, with suffix]{item1}"
+ =?> para (cite [baseCitation{ citationSuffix =
+ toList $ text "p.\160\&30, with suffix" }] empty)
+ , "multiple" =: "\\textcites{item1}[p.~30]{item2}[see also][]{item3}"
+ =?> para (cite [baseCitation{ citationMode = AuthorInText }
+ ,baseCitation{ citationMode = NormalCitation
+ , citationSuffix = [Str "p.\160\&30"]
+ , citationId = "item2" }
+ ,baseCitation{ citationId = "item3"
+ , citationPrefix = [Str "see",Space,Str "also"]
+ , citationMode = NormalCitation }
+ ] empty)
+ , "group" =: "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Str "see"]
+ , citationSuffix = [Str "p.\160\&34",EnDash,Str "35"] }
+ ,baseCitation{ citationMode = NormalCitation
+ , citationId = "item3"
+ , citationPrefix = [Str "also"]
+ , citationSuffix = [Str "chap.",Space,Str "3"] }
+ ] empty)
+ , "suffix and locator" =: "\\autocite[pp.~33, 35--37, and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = [Str "pp.\160\&33,",Space,Str "35",EnDash,Str "37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] empty)
+ , "suffix only" =: "\\autocite[and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = toList $ text "and nowhere else" }] empty)
+ , "no author" =: "\\autocite*{item1}, and now Doe with a locator \\autocite*[p.~44]{item2}"
+ =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] empty +++
+ text ", and now Doe with a locator " +++
+ cite [baseCitation{ citationMode = SuppressAuthor
+ , citationSuffix = [Str "p.\160\&44"]
+ , citationId = "item2" }] empty)
+ , "markup" =: "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Emph [Str "see"]]
+ , citationSuffix = [Str "p.",Space,
+ Strong [Str "32"]] }] empty)
+ , "parencite" =: "\\parencite{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation }] empty)
+ ]
diff --git a/src/Tests/Readers/Markdown.hs b/src/Tests/Readers/Markdown.hs
new file mode 100644
index 000000000..722a45bdb
--- /dev/null
+++ b/src/Tests/Readers/Markdown.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Readers.Markdown (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+markdown :: String -> Pandoc
+markdown = readMarkdown defaultParserState{ stateStandalone = True }
+
+infix 5 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test markdown
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "with attribute" =:
+ "`document.write(\"Hello\");`{.javascript}"
+ =?> para
+ (codeWith ("",["javascript"],[]) "document.write(\"Hello\");")
+ , "with attribute space" =:
+ "`*` {.haskell .special x=\"7\"}"
+ =?> para (codeWith ("",["haskell","special"],[("x","7")]) "*")
+ ]
+ ]
diff --git a/src/Tests/Readers/RST.hs b/src/Tests/Readers/RST.hs
new file mode 100644
index 000000000..c0f60ff51
--- /dev/null
+++ b/src/Tests/Readers/RST.hs
@@ -0,0 +1,46 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Readers.RST (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+rst :: String -> Pandoc
+rst = readRST defaultParserState{ stateStandalone = True }
+
+infix 5 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test rst
+
+tests :: [Test]
+tests = [ "field list" =:
+ [_LIT|
+:Hostname: media08
+:IP address: 10.0.0.19
+:Size: 3ru
+:Date: 2001-08-16
+:Version: 1
+:Authors: - Me
+ - Myself
+ - I
+:Indentation: Since the field marker may be quite long, the second
+ and subsequent lines of the field body do not have to line up
+ with the first line, but they must be indented relative to the
+ field name marker, and they must line up with each other.
+:Parameter i: integer
+|] =?> ( setAuthors ["Me","Myself","I"]
+ $ setDate "2001-08-16"
+ $ doc
+ $ definitionList [ (str "Hostname", [para "media08"])
+ , (str "IP address", [para "10.0.0.19"])
+ , (str "Size", [para "3ru"])
+ , (str "Version", [para "1"])
+ , (str "Indentation", [para "Since the field marker may be quite long, the second and subsequent lines of the field body do not have to line up with the first line, but they must be indented relative to the field name marker, and they must line up with each other."])
+ , (str "Parameter i", [para "integer"])
+ ])
+ ]
+
diff --git a/src/Tests/Shared.hs b/src/Tests/Shared.hs
new file mode 100644
index 000000000..c35a158c1
--- /dev/null
+++ b/src/Tests/Shared.hs
@@ -0,0 +1,21 @@
+module Tests.Shared (tests) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared
+import Test.Framework
+import Tests.Helpers
+import Tests.Arbitrary()
+
+tests :: [Test]
+tests = [ testGroup "normalize"
+ [ property "p_normalize_blocks_rt" p_normalize_blocks_rt
+ , property "p_normalize_inlines_rt" p_normalize_inlines_rt
+ ]
+ ]
+
+p_normalize_blocks_rt :: [Block] -> Bool
+p_normalize_blocks_rt bs = normalize bs == normalize (normalize bs)
+
+p_normalize_inlines_rt :: [Inline] -> Bool
+p_normalize_inlines_rt ils = normalize ils == normalize (normalize ils)
+
diff --git a/src/Tests/Writers/ConTeXt.hs b/src/Tests/Writers/ConTeXt.hs
new file mode 100644
index 000000000..704571e95
--- /dev/null
+++ b/src/Tests/Writers/ConTeXt.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Writers.ConTeXt (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+
+context :: (ToString a, ToPandoc a) => a -> String
+context = writeConTeXt defaultWriterOptions . toPandoc
+
+context' :: (ToString a, ToPandoc a) => a -> String
+context' = writeConTeXt defaultWriterOptions{ writerWrapText = False }
+ . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test context "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test context "my test" (X,Y)
+-}
+
+infix 5 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test context
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "with '}'" =: code "}" =?> "\\mono{\\letterclosebrace{}}"
+ , "without '}'" =: code "]" =?> "\\type{]}"
+ , property "code property" $ \s -> null s ||
+ if '{' `elem` s || '}' `elem` s
+ then (context' $ code s) == "\\mono{" ++
+ (context' $ str s) ++ "}"
+ else (context' $ code s) == "\\type{" ++ s ++ "}"
+ ]
+ , testGroup "headers"
+ [ "level 1" =:
+ header 1 "My header" =?> "\\subject{My header}"
+ , property "header 1 property" $ \ils ->
+ context' (header 1 ils) == "\\subject{" ++ context' ils ++ "}"
+ ]
+ , testGroup "bullet lists"
+ [ "nested" =:
+ bulletList [plain (text "top")
+ ,bulletList [plain (text "next")
+ ,bulletList [plain (text "bot")]]]
+ =?> [_LIT|
+\startitemize
+\item
+ top
+\item
+ \startitemize
+ \item
+ next
+ \item
+ \startitemize
+ \item
+ bot
+ \stopitemize
+ \stopitemize
+\stopitemize|]
+ ]
+ ]
+
diff --git a/src/Tests/Writers/HTML.hs b/src/Tests/Writers/HTML.hs
new file mode 100644
index 000000000..e13d0dc87
--- /dev/null
+++ b/src/Tests/Writers/HTML.hs
@@ -0,0 +1,41 @@
+{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
+module Tests.Writers.HTML (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Highlighting (languages) -- null if no hl support
+
+html :: (ToString a, ToPandoc a) => a -> String
+html = writeHtmlString defaultWriterOptions{ writerWrapText = False } . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test html "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test html "my test" (X,Y)
+-}
+
+infix 5 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test html
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "basic" =: code "@&" =?> "<code>@&amp;</code>"
+ , "haskell" =: codeWith ("",["haskell"],[]) ">>="
+ =?> if null languages
+ then "<code class=\"haskell\">&gt;&gt;=</code>"
+ else "<code class=\"sourceCode haskell\"><span class=\"fu\">&gt;&gt;=</span></code>"
+ , "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
+ =?> "<code class=\"nolanguage\">&gt;&gt;=</code>"
+ ]
+ ]
diff --git a/src/Tests/Writers/Native.hs b/src/Tests/Writers/Native.hs
new file mode 100644
index 000000000..234fe938a
--- /dev/null
+++ b/src/Tests/Writers/Native.hs
@@ -0,0 +1,20 @@
+module Tests.Writers.Native (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+
+p_write_rt :: Pandoc -> Bool
+p_write_rt d =
+ read (writeNative defaultWriterOptions{ writerStandalone = True } d) == d
+
+p_write_blocks_rt :: [Block] -> Bool
+p_write_blocks_rt bs =
+ read (writeNative defaultWriterOptions (Pandoc (Meta [] [] []) bs)) == bs
+
+tests :: [Test]
+tests = [ property "p_write_rt" p_write_rt
+ , property "p_write_blocks_rt" p_write_blocks_rt
+ ]
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index ad429bc93..ef8560284 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -57,11 +57,18 @@ module Text.Pandoc
(
-- * Definitions
module Text.Pandoc.Definition
+ -- * Generics
+ , module Text.Pandoc.Generic
+ -- * Lists of readers and writers
+ , readers
+ , writers
-- * Readers: converting /to/ Pandoc format
, readMarkdown
, readRST
, readLaTeX
, readHtml
+ , readTextile
+ , readNative
-- * Parser state used in readers
, ParserState (..)
, defaultParserState
@@ -84,25 +91,34 @@ module Text.Pandoc
, writeOpenDocument
, writeMan
, writeMediaWiki
+ , writeTextile
, writeRTF
, writeODT
, writeEPUB
+ , writeOrg
-- * Writer options used in writers
, WriterOptions (..)
, HTMLSlideVariant (..)
, HTMLMathMethod (..)
+ , CiteMethod (..)
, defaultWriterOptions
-- * Rendering templates and default templates
, module Text.Pandoc.Templates
-- * Version
, pandocVersion
+ -- * Miscellaneous
+ , rtfEmbedImage
+ , jsonFilter
) where
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import Text.Pandoc.Readers.Markdown
import Text.Pandoc.Readers.RST
import Text.Pandoc.Readers.LaTeX
import Text.Pandoc.Readers.HTML
+import Text.Pandoc.Readers.Textile
+import Text.Pandoc.Readers.Native
import Text.Pandoc.Writers.Native
import Text.Pandoc.Writers.Markdown
import Text.Pandoc.Writers.RST
@@ -117,12 +133,69 @@ import Text.Pandoc.Writers.OpenDocument
import Text.Pandoc.Writers.Man
import Text.Pandoc.Writers.RTF
import Text.Pandoc.Writers.MediaWiki
+import Text.Pandoc.Writers.Textile
+import Text.Pandoc.Writers.Org
import Text.Pandoc.Templates
import Text.Pandoc.Parsing
import Text.Pandoc.Shared
import Data.Version (showVersion)
+import Text.JSON.Generic
import Paths_pandoc (version)
-- | Version number of pandoc library.
pandocVersion :: String
pandocVersion = showVersion version
+
+-- | Association list of formats and readers.
+readers :: [(String, ParserState -> String -> Pandoc)]
+readers = [("native" , \_ -> readNative)
+ ,("json" , \_ -> decodeJSON)
+ ,("markdown" , readMarkdown)
+ ,("markdown+lhs" , \st ->
+ readMarkdown st{ stateLiterateHaskell = True})
+ ,("rst" , readRST)
+ ,("rst+lhs" , \st ->
+ readRST st{ stateLiterateHaskell = True})
+ ,("textile" , readTextile) -- TODO : textile+lhs
+ ,("html" , readHtml)
+ ,("latex" , readLaTeX)
+ ,("latex+lhs" , \st ->
+ readLaTeX st{ stateLiterateHaskell = True})
+ ]
+
+-- | Association list of formats and writers (omitting the
+-- binary writers, odt and epub).
+writers :: [ ( String, WriterOptions -> Pandoc -> String ) ]
+writers = [("native" , writeNative)
+ ,("json" , \_ -> encodeJSON)
+ ,("html" , writeHtmlString)
+ ,("html+lhs" , \o ->
+ writeHtmlString o{ writerLiterateHaskell = True })
+ ,("s5" , writeHtmlString)
+ ,("slidy" , writeHtmlString)
+ ,("docbook" , writeDocbook)
+ ,("opendocument" , writeOpenDocument)
+ ,("latex" , writeLaTeX)
+ ,("latex+lhs" , \o ->
+ writeLaTeX o{ writerLiterateHaskell = True })
+ ,("context" , writeConTeXt)
+ ,("texinfo" , writeTexinfo)
+ ,("man" , writeMan)
+ ,("markdown" , writeMarkdown)
+ ,("markdown+lhs" , \o ->
+ writeMarkdown o{ writerLiterateHaskell = True })
+ ,("plain" , writePlain)
+ ,("rst" , writeRST)
+ ,("rst+lhs" , \o ->
+ writeRST o{ writerLiterateHaskell = True })
+ ,("mediawiki" , writeMediaWiki)
+ ,("textile" , writeTextile)
+ ,("rtf" , writeRTF)
+ ,("org" , writeOrg)
+ ]
+
+-- | Converts a transformation on the Pandoc AST into a function
+-- that reads and writes a JSON-encoded string. This is useful
+-- for writing small scripts.
+jsonFilter :: (Pandoc -> Pandoc) -> String -> String
+jsonFilter f = encodeJSON . f . decodeJSON
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs
index 436eadd68..d65c9de1c 100644
--- a/src/Text/Pandoc/Biblio.hs
+++ b/src/Text/Pandoc/Biblio.hs
@@ -19,48 +19,203 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Biblio
- Copyright : Copyright (C) 2008 Andrea Rossato
+ Copyright : Copyright (C) 2008-2010 Andrea Rossato
License : GNU GPL, version 2 or above
- Maintainer : Andrea Rossato <andrea.rossato@ing.unitn.it>
+ Maintainer : Andrea Rossato <andrea.rossato@unitn.it>
Stability : alpha
Portability : portable
-}
module Text.Pandoc.Biblio ( processBiblio ) where
-import Control.Monad ( when )
import Data.List
-import Text.CSL
+import Data.Unique
+import Data.Char ( isDigit, isPunctuation )
+import qualified Data.Map as M
+import Text.CSL hiding ( Cite(..), Citation(..) )
+import qualified Text.CSL as CSL ( Cite(..) )
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
+import Text.Pandoc.Shared (stringify)
+import Text.ParserCombinators.Parsec
+import Control.Monad
-- | Process a 'Pandoc' document by adding citations formatted
-- according to a CSL style, using 'citeproc' from citeproc-hs.
-processBiblio :: String -> [Reference] -> Pandoc -> IO Pandoc
-processBiblio cf r p
+processBiblio :: FilePath -> [Reference] -> Pandoc -> IO Pandoc
+processBiblio cslfile r p
= if null r then return p
else do
- when (null cf) $ error "Missing the needed citation style file"
- csl <- readCSLFile cf
- let groups = queryWith getCite p
- result = citeproc csl r groups
- cits_map = zip groups (citations result)
- biblioList = map (read . renderPandoc' csl) (bibliography result)
- Pandoc m b = processWith (processCite csl cits_map) p
- return $ Pandoc m $ b ++ biblioList
+ csl <- readCSLFile cslfile
+ p' <- bottomUpM setHash p
+ let (nts,grps) = if styleClass csl == "note"
+ then let cits = queryWith getCite p'
+ ncits = map (queryWith getCite) $ queryWith getNote p'
+ needNt = cits \\ concat ncits
+ in (,) needNt $ getNoteCitations needNt p'
+ else (,) [] $ queryWith getCitation p'
+ result = citeproc procOpts csl r (setNearNote csl $
+ map (map toCslCite) grps)
+ cits_map = M.fromList $ zip grps (citations result)
+ biblioList = map (renderPandoc' csl) (bibliography result)
+ Pandoc m b = bottomUp (procInlines $ processCite csl cits_map) p'
+ return . generateNotes nts . Pandoc m $ b ++ biblioList
-- | Substitute 'Cite' elements with formatted citations.
-processCite :: Style -> [([Target],[FormattedOutput])] -> Inline -> Inline
-processCite s cs il
- | Cite t _ <- il = Cite t (process t)
- | otherwise = il
+processCite :: Style -> M.Map [Citation] [FormattedOutput] -> [Inline] -> [Inline]
+processCite _ _ [] = []
+processCite s cs (i:is)
+ | Cite t _ <- i = process t ++ processCite s cs is
+ | otherwise = i : processCite s cs is
where
- process t = case elemIndex t (map fst cs) of
- Just i -> read . renderPandoc s $ snd (cs !! i)
+ addNt t x = if null x then [] else [Cite t $ renderPandoc s x]
+ process t = case M.lookup t cs of
+ Just x -> if isTextualCitation t && x /= []
+ then renderPandoc s [head x] ++
+ if tail x /= []
+ then Space : addNt t (tail x)
+ else []
+ else [Cite t $ renderPandoc s x]
Nothing -> [Str ("Error processing " ++ show t)]
+isTextualCitation :: [Citation] -> Bool
+isTextualCitation (c:_) = citationMode c == AuthorInText
+isTextualCitation _ = False
+
-- | Retrieve all citations from a 'Pandoc' docuument. To be used with
-- 'queryWith'.
-getCite :: Inline -> [[(String,String)]]
-getCite i | Cite t _ <- i = [t]
+getCitation :: Inline -> [[Citation]]
+getCitation i | Cite t _ <- i = [t]
+ | otherwise = []
+
+getNote :: Inline -> [Inline]
+getNote i | Note _ <- i = [i]
+ | otherwise = []
+
+getCite :: Inline -> [Inline]
+getCite i | Cite _ _ <- i = [i]
| otherwise = []
+
+getNoteCitations :: [Inline] -> Pandoc -> [[Citation]]
+getNoteCitations needNote
+ = let mvCite i = if i `elem` needNote then Note [Para [i]] else i
+ setNote = bottomUp mvCite
+ getCits = concat . flip (zipWith $ setCiteNoteNum) [1..] .
+ map (queryWith getCite) . queryWith getNote . setNote
+ in queryWith getCitation . getCits
+
+setHash :: Citation -> IO Citation
+setHash (Citation i p s cm nn _)
+ = hashUnique `fmap` newUnique >>= return . Citation i p s cm nn
+
+generateNotes :: [Inline] -> Pandoc -> Pandoc
+generateNotes needNote = bottomUp (mvCiteInNote needNote)
+
+procInlines :: ([Inline] -> [Inline]) -> Block -> Block
+procInlines f b
+ | Plain inls <- b = Plain $ f inls
+ | Para inls <- b = Para $ f inls
+ | Header i inls <- b = Header i $ f inls
+ | otherwise = b
+
+mvCiteInNote :: [Inline] -> Block -> Block
+mvCiteInNote is = procInlines mvCite
+ where
+ mvCite :: [Inline] -> [Inline]
+ mvCite inls
+ | x:i:xs <- inls, startWithPunct xs
+ , x == Space, i `elem_` is = switch i xs ++ mvCite (tailFirstInlineStr xs)
+ | x:i:xs <- inls
+ , x == Space, i `elem_` is = mvInNote i : mvCite xs
+ | i:xs <- inls, i `elem_` is
+ , startWithPunct xs = switch i xs ++ mvCite (tailFirstInlineStr xs)
+ | i:xs <- inls, Note _ <- i = checkNt i : mvCite xs
+ | i:xs <- inls = i : mvCite xs
+ | otherwise = []
+ elem_ x xs = case x of Cite cs _ -> (Cite cs []) `elem` xs; _ -> False
+ switch i xs = Str (headInline xs) : mvInNote i : []
+ mvInNote i
+ | Cite t o <- i = Note [Para [Cite t $ sanitize o]]
+ | otherwise = Note [Para [i ]]
+ sanitize i
+ | endWithPunct i = toCapital i
+ | otherwise = toCapital (i ++ [Str "."])
+
+ checkPt i
+ | Cite c o : xs <- i
+ , endWithPunct o, startWithPunct xs
+ , endWithPunct o = Cite c (initInline o) : checkPt xs
+ | x:xs <- i = x : checkPt xs
+ | otherwise = []
+ checkNt = bottomUp $ procInlines checkPt
+
+setCiteNoteNum :: [Inline] -> Int -> [Inline]
+setCiteNoteNum ((Cite cs o):xs) n = Cite (setCitationNoteNum n cs) o : setCiteNoteNum xs n
+setCiteNoteNum _ _ = []
+
+setCitationNoteNum :: Int -> [Citation] -> [Citation]
+setCitationNoteNum i = map $ \c -> c { citationNoteNum = i}
+
+toCslCite :: Citation -> CSL.Cite
+toCslCite c
+ = let (l, s) = locatorWords $ citationSuffix c
+ (la,lo) = parseLocator l
+ citMode = case citationMode c of
+ AuthorInText -> (True, False)
+ SuppressAuthor -> (False,True )
+ NormalCitation -> (False,False)
+ s' = case s of
+ [] -> []
+ (Str (y:_) : _) | isPunctuation y -> s
+ _ -> Str "," : Space : s
+ in emptyCite { CSL.citeId = citationId c
+ , CSL.citePrefix = PandocText $ citationPrefix c
+ , CSL.citeSuffix = PandocText $ s'
+ , CSL.citeLabel = la
+ , CSL.citeLocator = lo
+ , CSL.citeNoteNumber = show $ citationNoteNum c
+ , CSL.authorInText = fst citMode
+ , CSL.suppressAuthor = snd citMode
+ , CSL.citeHash = citationHash c
+ }
+
+locatorWords :: [Inline] -> (String, [Inline])
+locatorWords inp =
+ case parse pLocatorWords "suffix" inp of
+ Right r -> r
+ Left _ -> ("",inp)
+
+pLocatorWords :: GenParser Inline st (String, [Inline])
+pLocatorWords = do
+ l <- pLocator
+ s <- getInput -- rest is suffix
+ if length l > 0 && last l == ','
+ then return (init l, Str "," : s)
+ else return (l, s)
+
+pMatch :: (Inline -> Bool) -> GenParser Inline st Inline
+pMatch condition = try $ do
+ t <- anyToken
+ guard $ condition t
+ return t
+
+pSpace :: GenParser Inline st Inline
+pSpace = pMatch (== Space)
+
+pLocator :: GenParser Inline st String
+pLocator = try $ do
+ optional $ pMatch (== Str ",")
+ optional pSpace
+ f <- many1 (notFollowedBy pSpace >> anyToken)
+ gs <- many1 pWordWithDigits
+ return $ stringify f ++ (' ' : unwords gs)
+
+pWordWithDigits :: GenParser Inline st String
+pWordWithDigits = try $ do
+ pSpace
+ r <- many1 (notFollowedBy pSpace >> anyToken)
+ let s = stringify r
+ guard $ any isDigit s
+ return s
+
diff --git a/src/Text/Pandoc/Blocks.hs b/src/Text/Pandoc/Blocks.hs
deleted file mode 100644
index 122931773..000000000
--- a/src/Text/Pandoc/Blocks.hs
+++ /dev/null
@@ -1,146 +0,0 @@
-{-
-Copyright (C) 2007 John MacFarlane <jgm@berkeley.edu>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--}
-
-{- |
- Module : Text.Pandoc.Blocks
- Copyright : Copyright (C) 2007 John MacFarlane
- License : GNU GPL, version 2 or above
-
- Maintainer : John MacFarlane <jgm@berkeley.edu>
- Stability : alpha
- Portability : portable
-
-Functions for the manipulation of fixed-width blocks of text.
-These are used in the construction of plain-text tables.
--}
-
-module Text.Pandoc.Blocks
- (
- TextBlock (..),
- docToBlock,
- blockToDoc,
- widthOfBlock,
- heightOfBlock,
- hcatBlocks,
- hsepBlocks,
- centerAlignBlock,
- leftAlignBlock,
- rightAlignBlock
- )
-where
-import Text.PrettyPrint
-import Data.List ( intersperse )
-
--- | A fixed-width block of text. Parameters are width of block,
--- height of block, and list of lines.
-data TextBlock = TextBlock Int Int [String]
-instance Show TextBlock where
- show x = show $ blockToDoc x
-
--- | Break lines in a list of lines so that none are greater than
--- a given width.
-breakLines :: Int -- ^ Maximum length of lines.
- -> [String] -- ^ List of lines.
- -> [String]
-breakLines _ [] = []
-breakLines width (l:ls) =
- if length l > width
- then (take width l):(breakLines width ((drop width l):ls))
- else l:(breakLines width ls)
-
--- | Convert a @Doc@ element into a @TextBlock@ with a specified width.
-docToBlock :: Int -- ^ Width of text block.
- -> Doc -- ^ @Doc@ to convert.
- -> TextBlock
-docToBlock width doc =
- let rendered = renderStyle (style {lineLength = width,
- ribbonsPerLine = 1}) doc
- lns = breakLines width $ lines rendered
- in TextBlock width (length lns) lns
-
--- | Convert a @TextBlock@ to a @Doc@ element.
-blockToDoc :: TextBlock -> Doc
-blockToDoc (TextBlock _ _ lns) =
- if null lns
- then empty
- else vcat $ map text lns
-
--- | Returns width of a @TextBlock@ (number of columns).
-widthOfBlock :: TextBlock -> Int
-widthOfBlock (TextBlock width _ _) = width
-
--- | Returns height of a @TextBlock@ (number of rows).
-heightOfBlock :: TextBlock -> Int
-heightOfBlock (TextBlock _ height _) = height
-
--- | Pads a string out to a given width using spaces.
-hPad :: Int -- ^ Desired width.
- -> String -- ^ String to pad.
- -> String
-hPad width line =
- let linelen = length line
- in if linelen <= width
- then line ++ replicate (width - linelen) ' '
- else take width line
-
--- | Concatenates a list of @TextBlock@s into a new @TextBlock@ in
--- which they appear side by side.
-hcatBlocks :: [TextBlock] -> TextBlock
-hcatBlocks [] = TextBlock 0 0 []
-hcatBlocks [x] = x -- This is not redundant! We don't want last item hPad'd.
-hcatBlocks ((TextBlock width1 height1 lns1):xs) =
- let (TextBlock width2 height2 lns2) = hcatBlocks xs
- height = max height1 height2
- width = width1 + width2
- lns1' = map (hPad width1) $ lns1 ++ replicate (height - height1) ""
- lns2' = lns2 ++ replicate (height - height2) ""
- lns = zipWith (++) lns1' lns2'
- in TextBlock width height lns
-
--- | Like @hcatBlocks@, but inserts space between the @TextBlock@s.
-hsepBlocks :: [TextBlock] -> TextBlock
-hsepBlocks = hcatBlocks . (intersperse (TextBlock 1 1 [" "]))
-
-isWhitespace :: Char -> Bool
-isWhitespace x = x `elem` " \t"
-
--- | Left-aligns the contents of a @TextBlock@ within the block.
-leftAlignBlock :: TextBlock -> TextBlock
-leftAlignBlock (TextBlock width height lns) =
- TextBlock width height $ map (dropWhile isWhitespace) lns
-
--- | Right-aligns the contents of a @TextBlock@ within the block.
-rightAlignBlock :: TextBlock -> TextBlock
-rightAlignBlock (TextBlock width height lns) =
- let rightAlignLine ln =
- let (spaces, rest) = span isWhitespace $ reverse $ hPad width ln
- in reverse (rest ++ spaces)
- in TextBlock width height $ map rightAlignLine lns
-
--- | Centers the contents of a @TextBlock@ within the block.
-centerAlignBlock :: TextBlock -> TextBlock
-centerAlignBlock (TextBlock width height lns) =
- let centerAlignLine ln =
- let ln' = hPad width ln
- (startSpaces, rest) = span isWhitespace ln'
- endSpaces = takeWhile isWhitespace (reverse ln')
- numSpaces = length (startSpaces ++ endSpaces)
- startSpaces' = replicate (quot numSpaces 2) ' '
- in startSpaces' ++ rest
- in TextBlock width height $ map centerAlignLine lns
-
diff --git a/src/Text/Pandoc/CharacterReferences.hs b/src/Text/Pandoc/CharacterReferences.hs
index 8ac55fc61..8157d94d3 100644
--- a/src/Text/Pandoc/CharacterReferences.hs
+++ b/src/Text/Pandoc/CharacterReferences.hs
@@ -31,9 +31,9 @@ module Text.Pandoc.CharacterReferences (
characterReference,
decodeCharacterReferences,
) where
-import Data.Char ( chr )
import Text.ParserCombinators.Parsec
-import qualified Data.Map as Map
+import Text.HTML.TagSoup.Entity ( lookupNamedEntity, lookupNumericEntity )
+import Data.Maybe ( fromMaybe )
-- | Parse character entity.
characterReference :: GenParser Char st Char
@@ -47,18 +47,21 @@ numRef :: GenParser Char st Char
numRef = do
char '#'
num <- hexNum <|> decNum
- return $ chr $ num
+ return $ fromMaybe '?' $ lookupNumericEntity num
-hexNum :: GenParser Char st Int
-hexNum = oneOf "Xx" >> many1 hexDigit >>= return . read . (\xs -> '0':'x':xs)
+hexNum :: GenParser Char st [Char]
+hexNum = do
+ x <- oneOf "Xx"
+ num <- many1 hexDigit
+ return (x:num)
-decNum :: GenParser Char st Int
-decNum = many1 digit >>= return . read
+decNum :: GenParser Char st [Char]
+decNum = many1 digit
entity :: GenParser Char st Char
entity = do
body <- many1 alphaNum
- return $ Map.findWithDefault '?' body entityTable
+ return $ fromMaybe '?' $ lookupNamedEntity body
-- | Convert entities in a string to characters.
decodeCharacterReferences :: String -> String
@@ -67,261 +70,3 @@ decodeCharacterReferences str =
Left err -> error $ "\nError: " ++ show err
Right result -> result
-entityTable :: Map.Map String Char
-entityTable = Map.fromList entityTableList
-
-entityTableList :: [(String, Char)]
-entityTableList = [
- ("quot", chr 34),
- ("amp", chr 38),
- ("lt", chr 60),
- ("gt", chr 62),
- ("nbsp", chr 160),
- ("iexcl", chr 161),
- ("cent", chr 162),
- ("pound", chr 163),
- ("curren", chr 164),
- ("yen", chr 165),
- ("brvbar", chr 166),
- ("sect", chr 167),
- ("uml", chr 168),
- ("copy", chr 169),
- ("ordf", chr 170),
- ("laquo", chr 171),
- ("not", chr 172),
- ("shy", chr 173),
- ("reg", chr 174),
- ("macr", chr 175),
- ("deg", chr 176),
- ("plusmn", chr 177),
- ("sup2", chr 178),
- ("sup3", chr 179),
- ("acute", chr 180),
- ("micro", chr 181),
- ("para", chr 182),
- ("middot", chr 183),
- ("cedil", chr 184),
- ("sup1", chr 185),
- ("ordm", chr 186),
- ("raquo", chr 187),
- ("frac14", chr 188),
- ("frac12", chr 189),
- ("frac34", chr 190),
- ("iquest", chr 191),
- ("Agrave", chr 192),
- ("Aacute", chr 193),
- ("Acirc", chr 194),
- ("Atilde", chr 195),
- ("Auml", chr 196),
- ("Aring", chr 197),
- ("AElig", chr 198),
- ("Ccedil", chr 199),
- ("Egrave", chr 200),
- ("Eacute", chr 201),
- ("Ecirc", chr 202),
- ("Euml", chr 203),
- ("Igrave", chr 204),
- ("Iacute", chr 205),
- ("Icirc", chr 206),
- ("Iuml", chr 207),
- ("ETH", chr 208),
- ("Ntilde", chr 209),
- ("Ograve", chr 210),
- ("Oacute", chr 211),
- ("Ocirc", chr 212),
- ("Otilde", chr 213),
- ("Ouml", chr 214),
- ("times", chr 215),
- ("Oslash", chr 216),
- ("Ugrave", chr 217),
- ("Uacute", chr 218),
- ("Ucirc", chr 219),
- ("Uuml", chr 220),
- ("Yacute", chr 221),
- ("THORN", chr 222),
- ("szlig", chr 223),
- ("agrave", chr 224),
- ("aacute", chr 225),
- ("acirc", chr 226),
- ("atilde", chr 227),
- ("auml", chr 228),
- ("aring", chr 229),
- ("aelig", chr 230),
- ("ccedil", chr 231),
- ("egrave", chr 232),
- ("eacute", chr 233),
- ("ecirc", chr 234),
- ("euml", chr 235),
- ("igrave", chr 236),
- ("iacute", chr 237),
- ("icirc", chr 238),
- ("iuml", chr 239),
- ("eth", chr 240),
- ("ntilde", chr 241),
- ("ograve", chr 242),
- ("oacute", chr 243),
- ("ocirc", chr 244),
- ("otilde", chr 245),
- ("ouml", chr 246),
- ("divide", chr 247),
- ("oslash", chr 248),
- ("ugrave", chr 249),
- ("uacute", chr 250),
- ("ucirc", chr 251),
- ("uuml", chr 252),
- ("yacute", chr 253),
- ("thorn", chr 254),
- ("yuml", chr 255),
- ("OElig", chr 338),
- ("oelig", chr 339),
- ("Scaron", chr 352),
- ("scaron", chr 353),
- ("Yuml", chr 376),
- ("fnof", chr 402),
- ("circ", chr 710),
- ("tilde", chr 732),
- ("Alpha", chr 913),
- ("Beta", chr 914),
- ("Gamma", chr 915),
- ("Delta", chr 916),
- ("Epsilon", chr 917),
- ("Zeta", chr 918),
- ("Eta", chr 919),
- ("Theta", chr 920),
- ("Iota", chr 921),
- ("Kappa", chr 922),
- ("Lambda", chr 923),
- ("Mu", chr 924),
- ("Nu", chr 925),
- ("Xi", chr 926),
- ("Omicron", chr 927),
- ("Pi", chr 928),
- ("Rho", chr 929),
- ("Sigma", chr 931),
- ("Tau", chr 932),
- ("Upsilon", chr 933),
- ("Phi", chr 934),
- ("Chi", chr 935),
- ("Psi", chr 936),
- ("Omega", chr 937),
- ("alpha", chr 945),
- ("beta", chr 946),
- ("gamma", chr 947),
- ("delta", chr 948),
- ("epsilon", chr 949),
- ("zeta", chr 950),
- ("eta", chr 951),
- ("theta", chr 952),
- ("iota", chr 953),
- ("kappa", chr 954),
- ("lambda", chr 955),
- ("mu", chr 956),
- ("nu", chr 957),
- ("xi", chr 958),
- ("omicron", chr 959),
- ("pi", chr 960),
- ("rho", chr 961),
- ("sigmaf", chr 962),
- ("sigma", chr 963),
- ("tau", chr 964),
- ("upsilon", chr 965),
- ("phi", chr 966),
- ("chi", chr 967),
- ("psi", chr 968),
- ("omega", chr 969),
- ("thetasym", chr 977),
- ("upsih", chr 978),
- ("piv", chr 982),
- ("ensp", chr 8194),
- ("emsp", chr 8195),
- ("thinsp", chr 8201),
- ("zwnj", chr 8204),
- ("zwj", chr 8205),
- ("lrm", chr 8206),
- ("rlm", chr 8207),
- ("ndash", chr 8211),
- ("mdash", chr 8212),
- ("lsquo", chr 8216),
- ("rsquo", chr 8217),
- ("sbquo", chr 8218),
- ("ldquo", chr 8220),
- ("rdquo", chr 8221),
- ("bdquo", chr 8222),
- ("dagger", chr 8224),
- ("Dagger", chr 8225),
- ("bull", chr 8226),
- ("hellip", chr 8230),
- ("permil", chr 8240),
- ("prime", chr 8242),
- ("Prime", chr 8243),
- ("lsaquo", chr 8249),
- ("rsaquo", chr 8250),
- ("oline", chr 8254),
- ("frasl", chr 8260),
- ("euro", chr 8364),
- ("image", chr 8465),
- ("weierp", chr 8472),
- ("real", chr 8476),
- ("trade", chr 8482),
- ("alefsym", chr 8501),
- ("larr", chr 8592),
- ("uarr", chr 8593),
- ("rarr", chr 8594),
- ("darr", chr 8595),
- ("harr", chr 8596),
- ("crarr", chr 8629),
- ("lArr", chr 8656),
- ("uArr", chr 8657),
- ("rArr", chr 8658),
- ("dArr", chr 8659),
- ("hArr", chr 8660),
- ("forall", chr 8704),
- ("part", chr 8706),
- ("exist", chr 8707),
- ("empty", chr 8709),
- ("nabla", chr 8711),
- ("isin", chr 8712),
- ("notin", chr 8713),
- ("ni", chr 8715),
- ("prod", chr 8719),
- ("sum", chr 8721),
- ("minus", chr 8722),
- ("lowast", chr 8727),
- ("radic", chr 8730),
- ("prop", chr 8733),
- ("infin", chr 8734),
- ("ang", chr 8736),
- ("and", chr 8743),
- ("or", chr 8744),
- ("cap", chr 8745),
- ("cup", chr 8746),
- ("int", chr 8747),
- ("there4", chr 8756),
- ("sim", chr 8764),
- ("cong", chr 8773),
- ("asymp", chr 8776),
- ("ne", chr 8800),
- ("equiv", chr 8801),
- ("le", chr 8804),
- ("ge", chr 8805),
- ("sub", chr 8834),
- ("sup", chr 8835),
- ("nsub", chr 8836),
- ("sube", chr 8838),
- ("supe", chr 8839),
- ("oplus", chr 8853),
- ("otimes", chr 8855),
- ("perp", chr 8869),
- ("sdot", chr 8901),
- ("lceil", chr 8968),
- ("rceil", chr 8969),
- ("lfloor", chr 8970),
- ("rfloor", chr 8971),
- ("lang", chr 9001),
- ("rang", chr 9002),
- ("loz", chr 9674),
- ("spades", chr 9824),
- ("clubs", chr 9827),
- ("hearts", chr 9829),
- ("diams", chr 9830)
- ]
diff --git a/src/Text/Pandoc/Definition.hs b/src/Text/Pandoc/Definition.hs
deleted file mode 100644
index fffca3b2e..000000000
--- a/src/Text/Pandoc/Definition.hs
+++ /dev/null
@@ -1,151 +0,0 @@
-{-# OPTIONS_GHC -fglasgow-exts #-} -- for deriving Typeable
-{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--}
-
-{- |
- Module : Text.Pandoc.Definition
- Copyright : Copyright (C) 2006-2010 John MacFarlane
- License : GNU GPL, version 2 or above
-
- Maintainer : John MacFarlane <jgm@berkeley.edu>
- Stability : alpha
- Portability : portable
-
-Definition of 'Pandoc' data structure for format-neutral representation
-of documents.
--}
-module Text.Pandoc.Definition where
-
-import Data.Generics
-
-data Pandoc = Pandoc Meta [Block] deriving (Eq, Ord, Read, Show, Typeable, Data)
-
--- | Bibliographic information for the document: title, authors, date.
-data Meta = Meta { docTitle :: [Inline]
- , docAuthors :: [[Inline]]
- , docDate :: [Inline] }
- deriving (Eq, Ord, Show, Read, Typeable, Data)
-
--- | Alignment of a table column.
-data Alignment = AlignLeft
- | AlignRight
- | AlignCenter
- | AlignDefault deriving (Eq, Ord, Show, Read, Typeable, Data)
-
--- | List attributes.
-type ListAttributes = (Int, ListNumberStyle, ListNumberDelim)
-
--- | Style of list numbers.
-data ListNumberStyle = DefaultStyle
- | Example
- | Decimal
- | LowerRoman
- | UpperRoman
- | LowerAlpha
- | UpperAlpha deriving (Eq, Ord, Show, Read, Typeable, Data)
-
--- | Delimiter of list numbers.
-data ListNumberDelim = DefaultDelim
- | Period
- | OneParen
- | TwoParens deriving (Eq, Ord, Show, Read, Typeable, Data)
-
--- | Attributes: identifier, classes, key-value pairs
-type Attr = (String, [String], [(String, String)])
-
--- | Block element.
-data Block
- = Plain [Inline] -- ^ Plain text, not a paragraph
- | Para [Inline] -- ^ Paragraph
- | CodeBlock Attr String -- ^ Code block (literal) with attributes
- | RawHtml String -- ^ Raw HTML block (literal)
- | BlockQuote [Block] -- ^ Block quote (list of blocks)
- | OrderedList ListAttributes [[Block]] -- ^ Ordered list (attributes
- -- and a list of items, each a list of blocks)
- | BulletList [[Block]] -- ^ Bullet list (list of items, each
- -- a list of blocks)
- | DefinitionList [([Inline],[[Block]])] -- ^ Definition list
- -- Each list item is a pair consisting of a
- -- term (a list of inlines) and one or more
- -- definitions (each a list of blocks)
- | Header Int [Inline] -- ^ Header - level (integer) and text (inlines)
- | HorizontalRule -- ^ Horizontal rule
- | Table [Inline] [Alignment] [Double] [[Block]] [[[Block]]] -- ^ Table,
- -- with caption, column alignments,
- -- relative column widths (0 = default),
- -- column headers (each a list of blocks), and
- -- rows (each a list of lists of blocks)
- | Null -- ^ Nothing
- deriving (Eq, Ord, Read, Show, Typeable, Data)
-
--- | Type of quotation marks to use in Quoted inline.
-data QuoteType = SingleQuote | DoubleQuote deriving (Show, Eq, Ord, Read, Typeable, Data)
-
--- | Link target (URL, title).
-type Target = (String, String)
-
--- | Type of math element (display or inline).
-data MathType = DisplayMath | InlineMath deriving (Show, Eq, Ord, Read, Typeable, Data)
-
--- | Inline elements.
-data Inline
- = Str String -- ^ Text (string)
- | Emph [Inline] -- ^ Emphasized text (list of inlines)
- | Strong [Inline] -- ^ Strongly emphasized text (list of inlines)
- | Strikeout [Inline] -- ^ Strikeout text (list of inlines)
- | Superscript [Inline] -- ^ Superscripted text (list of inlines)
- | Subscript [Inline] -- ^ Subscripted text (list of inlines)
- | SmallCaps [Inline] -- ^ Small caps text (list of inlines)
- | Quoted QuoteType [Inline] -- ^ Quoted text (list of inlines)
- | Cite [Target] [Inline] -- ^ Citation (list of inlines)
- | Code String -- ^ Inline code (literal)
- | Space -- ^ Inter-word space
- | EmDash -- ^ Em dash
- | EnDash -- ^ En dash
- | Apostrophe -- ^ Apostrophe
- | Ellipses -- ^ Ellipses
- | LineBreak -- ^ Hard line break
- | Math MathType String -- ^ TeX math (literal)
- | TeX String -- ^ LaTeX code (literal)
- | HtmlInline String -- ^ HTML code (literal)
- | Link [Inline] Target -- ^ Hyperlink: text (list of inlines), target
- | Image [Inline] Target -- ^ Image: alt text (list of inlines), target
- -- and target
- | Note [Block] -- ^ Footnote or endnote
- deriving (Show, Eq, Ord, Read, Typeable, Data)
-
--- | Applies a transformation on @a@s to matching elements in a @b@.
-processWith :: (Data a, Data b) => (a -> a) -> b -> b
-processWith f = everywhere (mkT f)
-
--- | Like 'processWith', but with monadic transformations.
-processWithM :: (Monad m, Data a, Data b) => (a -> m a) -> b -> m b
-processWithM f = everywhereM (mkM f)
-
--- | Runs a query on matching @a@ elements in a @c@.
-queryWith :: (Data a, Data c) => (a -> [b]) -> c -> [b]
-queryWith f = everything (++) ([] `mkQ` f)
-
-{-# DEPRECATED processPandoc "Use processWith instead" #-}
-processPandoc :: Data a => (a -> a) -> Pandoc -> Pandoc
-processPandoc = processWith
-
-{-# DEPRECATED queryPandoc "Use queryWith instead" #-}
-queryPandoc :: Data a => (a -> [b]) -> Pandoc -> [b]
-queryPandoc = queryWith
-
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs
index f29106262..5ddaf1379 100644
--- a/src/Text/Pandoc/Highlighting.hs
+++ b/src/Text/Pandoc/Highlighting.hs
@@ -37,10 +37,14 @@ import Data.List (find)
import Data.Maybe (fromMaybe)
import Data.Char (toLower)
-highlightHtml :: Attr -> String -> Either String Html
-highlightHtml (_, classes, keyvals) rawCode =
+highlightHtml :: Bool -- ^ True if inline HTML
+ -> Attr -- ^ Attributes of the Code or CodeBlock
+ -> String -- ^ Raw contents of the Code or CodeBlock
+ -> Either String Html -- ^ An error or the formatted Html
+highlightHtml inline (_, classes, keyvals) rawCode =
let firstNum = read $ fromMaybe "1" $ lookup "startFrom" keyvals
fmtOpts = [OptNumberFrom firstNum] ++
+ [OptInline | inline] ++
case find (`elem` ["number","numberLines","number-lines"]) classes of
Nothing -> []
Just _ -> [OptNumberLines]
@@ -65,6 +69,6 @@ languages = []
languagesByExtension :: String -> [String]
languagesByExtension _ = []
-highlightHtml :: Attr -> String -> Either String Html
-highlightHtml _ _ = Left "Pandoc was not compiled with support for highlighting"
+highlightHtml :: Bool -> Attr -> String -> Either String Html
+highlightHtml _ _ _ = Left "Pandoc was not compiled with support for highlighting"
#endif
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 3678fc22a..9ce064f91 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -64,21 +64,27 @@ module Text.Pandoc.Parsing ( (>>~),
QuoteContext (..),
NoteTable,
KeyTable,
- Key (..),
+ Key,
+ toKey,
+ fromKey,
lookupKeySrc,
- refsMatch )
+ smartPunctuation,
+ macro,
+ applyMacros' )
where
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
import Text.ParserCombinators.Parsec
import Text.Pandoc.CharacterReferences ( characterReference )
-import Data.Char ( toLower, toUpper, ord, isAscii )
+import Data.Char ( toLower, toUpper, ord, isAscii, isAlphaNum, isDigit )
import Data.List ( intercalate, transpose )
import Network.URI ( parseURI, URI (..), isAllowedInURI )
-import Control.Monad ( join, liftM )
+import Control.Monad ( join, liftM, guard )
import Text.Pandoc.Shared
import qualified Data.Map as M
+import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
-- | Like >>, but returns the operation on the left.
-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
@@ -114,7 +120,7 @@ oneOfStrings listOfStrings = choice $ map (try . string) listOfStrings
-- | Parses a space or tab.
spaceChar :: CharParser st Char
-spaceChar = char ' ' <|> char '\t'
+spaceChar = satisfy $ \c -> c == ' ' || c == '\t'
-- | Skips zero or more spaces or tabs.
skipSpaces :: GenParser Char st ()
@@ -169,7 +175,8 @@ lineClump = blanklines
charsInBalanced :: Char -> Char -> GenParser Char st String
charsInBalanced open close = try $ do
char open
- raw <- many $ (many1 (noneOf [open, close, '\n']))
+ raw <- many $ (many1 (satisfy $ \c ->
+ c /= open && c /= close && c /= '\n'))
<|> (do res <- charsInBalanced open close
return $ [open] ++ res ++ [close])
<|> try (string "\n" >>~ notFollowedBy' blanklines)
@@ -180,7 +187,7 @@ charsInBalanced open close = try $ do
charsInBalanced' :: Char -> Char -> GenParser Char st String
charsInBalanced' open close = try $ do
char open
- raw <- many $ (many1 (noneOf [open, close]))
+ raw <- many $ (many1 (satisfy $ \c -> c /= open && c /= close))
<|> (do res <- charsInBalanced' open close
return $ [open] ++ res ++ [close])
char close
@@ -201,7 +208,7 @@ romanNumeral upperCase = do
let romanDigits = if upperCase
then uppercaseRomanDigits
else lowercaseRomanDigits
- lookAhead $ oneOf romanDigits
+ lookAhead $ oneOf romanDigits
let [one, five, ten, fifty, hundred, fivehundred, thousand] =
map char romanDigits
thousands <- many thousand >>= (return . (1000 *) . length)
@@ -227,7 +234,8 @@ romanNumeral upperCase = do
-- Parsers for email addresses and URIs
emailChar :: GenParser Char st Char
-emailChar = alphaNum <|> oneOf "-+_."
+emailChar = alphaNum <|>
+ satisfy (\c -> c == '-' || c == '+' || c == '_' || c == '.')
domainChar :: GenParser Char st Char
domainChar = alphaNum <|> char '-'
@@ -283,7 +291,7 @@ nullBlock :: GenParser Char st Block
nullBlock = anyChar >> return Null
-- | Fail if reader is in strict markdown syntax mode.
-failIfStrict :: GenParser Char ParserState ()
+failIfStrict :: GenParser a ParserState ()
failIfStrict = do
state <- getState
if stateStrict state then fail "strict mode" else return ()
@@ -327,7 +335,7 @@ decimal = do
exampleNum :: GenParser Char ParserState (ListNumberStyle, Int)
exampleNum = do
char '@'
- lab <- many (alphaNum <|> oneOf "_-")
+ lab <- many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))
st <- getState
let num = stateNextExample st
let newlabels = if null lab
@@ -450,8 +458,9 @@ widthsFromIndices :: Int -- Number of columns on terminal
-> [Int] -- Indices
-> [Double] -- Fractional relative sizes of columns
widthsFromIndices _ [] = []
-widthsFromIndices numColumns indices =
- let lengths' = zipWith (-) indices (0:indices)
+widthsFromIndices numColumns' indices =
+ let numColumns = max numColumns' (if null indices then 0 else last indices)
+ lengths' = zipWith (-) indices (0:indices)
lengths = reverse $
case reverse lengths' of
[] -> []
@@ -481,8 +490,8 @@ gridTableWith block tableCaption headless =
tableWith (gridTableHeader headless block) (gridTableRow block) (gridTableSep '-') gridTableFooter tableCaption
gridTableSplitLine :: [Int] -> String -> [String]
-gridTableSplitLine indices line =
- map removeFinalBar $ tail $ splitByIndices (init indices) line
+gridTableSplitLine indices line = map removeFinalBar $ tail $
+ splitByIndices (init indices) $ removeTrailingSpace line
gridPart :: Char -> GenParser Char st (Int, Int)
gridPart ch = do
@@ -494,8 +503,8 @@ gridDashedLines :: Char -> GenParser Char st [(Int,Int)]
gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline
removeFinalBar :: String -> String
-removeFinalBar = reverse . dropWhile (=='|') . dropWhile (`elem` " \t") .
- reverse
+removeFinalBar =
+ reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse
-- | Separator between rows of grid table.
gridTableSep :: Char -> GenParser Char ParserState Char
@@ -532,7 +541,7 @@ gridTableRawLine :: [Int] -> GenParser Char ParserState [String]
gridTableRawLine indices = do
char '|'
line <- many1Till anyChar newline
- return (gridTableSplitLine indices $ removeTrailingSpace line)
+ return (gridTableSplitLine indices line)
-- | Parse row of grid table.
gridTableRow :: GenParser Char ParserState Block
@@ -562,9 +571,9 @@ gridTableFooter = blanklines
---
-- | Parse a string with a given parser and state.
-readWith :: GenParser Char ParserState a -- ^ parser
+readWith :: GenParser t ParserState a -- ^ parser
-> ParserState -- ^ initial state
- -> String -- ^ input string
+ -> [t] -- ^ input
-> a
readWith parser state input =
case runParser parser state "source" input of
@@ -583,11 +592,8 @@ data ParserState = ParserState
{ stateParseRaw :: Bool, -- ^ Parse raw HTML and LaTeX?
stateParserContext :: ParserContext, -- ^ Inside list?
stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?
- stateSanitizeHTML :: Bool, -- ^ Sanitize HTML?
stateKeys :: KeyTable, -- ^ List of reference keys
-#ifdef _CITEPROC
stateCitations :: [String], -- ^ List of available citations
-#endif
stateNotes :: NoteTable, -- ^ List of notes
stateTabStop :: Int, -- ^ Tab stop
stateStandalone :: Bool, -- ^ Parse bibliographic info?
@@ -602,7 +608,9 @@ data ParserState = ParserState
stateIndentedCodeClasses :: [String], -- ^ Classes to use for indented code blocks
stateNextExample :: Int, -- ^ Number of next example
stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
- stateHasChapters :: Bool -- ^ True if \chapter encountered
+ stateHasChapters :: Bool, -- ^ True if \chapter encountered
+ stateApplyMacros :: Bool, -- ^ Apply LaTeX macros?
+ stateMacros :: [Macro] -- ^ List of macros defined so far
}
deriving Show
@@ -611,11 +619,8 @@ defaultParserState =
ParserState { stateParseRaw = False,
stateParserContext = NullState,
stateQuoteContext = NoQuote,
- stateSanitizeHTML = False,
stateKeys = M.empty,
-#ifdef _CITEPROC
stateCitations = [],
-#endif
stateNotes = [],
stateTabStop = 4,
stateStandalone = False,
@@ -630,7 +635,9 @@ defaultParserState =
stateIndentedCodeClasses = [],
stateNextExample = 1,
stateExamples = M.empty,
- stateHasChapters = False }
+ stateHasChapters = False,
+ stateApplyMacros = True,
+ stateMacros = []}
data HeaderType
= SingleHeader Char -- ^ Single line of characters underneath
@@ -650,13 +657,20 @@ data QuoteContext
type NoteTable = [(String, String)]
-newtype Key = Key [Inline] deriving (Show, Read)
+newtype Key = Key [Inline] deriving (Show, Read, Eq, Ord)
-instance Eq Key where
- Key a == Key b = refsMatch a b
+toKey :: [Inline] -> Key
+toKey = Key . bottomUp lowercase
+ where lowercase :: Inline -> Inline
+ lowercase (Str xs) = Str (map toLower xs)
+ lowercase (Math t xs) = Math t (map toLower xs)
+ lowercase (Code attr xs) = Code attr (map toLower xs)
+ lowercase (RawInline f xs) = RawInline f (map toLower xs)
+ lowercase LineBreak = Space
+ lowercase x = x
-instance Ord Key where
- compare (Key a) (Key b) = if a == b then EQ else compare a b
+fromKey :: Key -> [Inline]
+fromKey (Key xs) = xs
type KeyTable = M.Map Key Target
@@ -668,33 +682,130 @@ lookupKeySrc table key = case M.lookup key table of
Nothing -> Nothing
Just src -> Just src
--- | Returns @True@ if keys match (case insensitive).
-refsMatch :: [Inline] -> [Inline] -> Bool
-refsMatch ((Str x):restx) ((Str y):resty) =
- ((map toLower x) == (map toLower y)) && refsMatch restx resty
-refsMatch ((Emph x):restx) ((Emph y):resty) =
- refsMatch x y && refsMatch restx resty
-refsMatch ((Strong x):restx) ((Strong y):resty) =
- refsMatch x y && refsMatch restx resty
-refsMatch ((Strikeout x):restx) ((Strikeout y):resty) =
- refsMatch x y && refsMatch restx resty
-refsMatch ((Superscript x):restx) ((Superscript y):resty) =
- refsMatch x y && refsMatch restx resty
-refsMatch ((Subscript x):restx) ((Subscript y):resty) =
- refsMatch x y && refsMatch restx resty
-refsMatch ((SmallCaps x):restx) ((SmallCaps y):resty) =
- refsMatch x y && refsMatch restx resty
-refsMatch ((Quoted t x):restx) ((Quoted u y):resty) =
- t == u && refsMatch x y && refsMatch restx resty
-refsMatch ((Code x):restx) ((Code y):resty) =
- ((map toLower x) == (map toLower y)) && refsMatch restx resty
-refsMatch ((Math t x):restx) ((Math u y):resty) =
- ((map toLower x) == (map toLower y)) && t == u && refsMatch restx resty
-refsMatch ((TeX x):restx) ((TeX y):resty) =
- ((map toLower x) == (map toLower y)) && refsMatch restx resty
-refsMatch ((HtmlInline x):restx) ((HtmlInline y):resty) =
- ((map toLower x) == (map toLower y)) && refsMatch restx resty
-refsMatch (x:restx) (y:resty) = (x == y) && refsMatch restx resty
-refsMatch [] x = null x
-refsMatch x [] = null x
+-- | Fail unless we're in "smart typography" mode.
+failUnlessSmart :: GenParser tok ParserState ()
+failUnlessSmart = getState >>= guard . stateSmart
+
+smartPunctuation :: GenParser Char ParserState Inline
+ -> GenParser Char ParserState Inline
+smartPunctuation inlineParser = do
+ failUnlessSmart
+ choice [ quoted inlineParser, apostrophe, dash, ellipses ]
+
+apostrophe :: GenParser Char ParserState Inline
+apostrophe = (char '\'' <|> char '\8217') >> return Apostrophe
+
+quoted :: GenParser Char ParserState Inline
+ -> GenParser Char ParserState Inline
+quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
+
+withQuoteContext :: QuoteContext
+ -> (GenParser Char ParserState Inline)
+ -> GenParser Char ParserState Inline
+withQuoteContext context parser = do
+ oldState <- getState
+ let oldQuoteContext = stateQuoteContext oldState
+ setState oldState { stateQuoteContext = context }
+ result <- parser
+ newState <- getState
+ setState newState { stateQuoteContext = oldQuoteContext }
+ return result
+
+singleQuoted :: GenParser Char ParserState Inline
+ -> GenParser Char ParserState Inline
+singleQuoted inlineParser = try $ do
+ singleQuoteStart
+ withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
+ return . Quoted SingleQuote . normalizeSpaces
+
+doubleQuoted :: GenParser Char ParserState Inline
+ -> GenParser Char ParserState Inline
+doubleQuoted inlineParser = try $ do
+ doubleQuoteStart
+ withQuoteContext InDoubleQuote $ do
+ contents <- manyTill inlineParser doubleQuoteEnd
+ return . Quoted DoubleQuote . normalizeSpaces $ contents
+
+failIfInQuoteContext :: QuoteContext -> GenParser tok ParserState ()
+failIfInQuoteContext context = do
+ st <- getState
+ if stateQuoteContext st == context
+ then fail "already inside quotes"
+ else return ()
+
+charOrRef :: [Char] -> GenParser Char st Char
+charOrRef cs =
+ oneOf cs <|> try (do c <- characterReference
+ guard (c `elem` cs)
+ return c)
+
+singleQuoteStart :: GenParser Char ParserState ()
+singleQuoteStart = do
+ failIfInQuoteContext InSingleQuote
+ try $ do charOrRef "'\8216"
+ notFollowedBy (oneOf ")!],.;:-? \t\n")
+ notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >>
+ satisfy (not . isAlphaNum)))
+ -- possess/contraction
+ return ()
+
+singleQuoteEnd :: GenParser Char st ()
+singleQuoteEnd = try $ do
+ charOrRef "'\8217"
+ notFollowedBy alphaNum
+
+doubleQuoteStart :: GenParser Char ParserState ()
+doubleQuoteStart = do
+ failIfInQuoteContext InDoubleQuote
+ try $ do charOrRef "\"\8220"
+ notFollowedBy (satisfy (\c -> c == ' ' || c == '\t' || c == '\n'))
+
+doubleQuoteEnd :: GenParser Char st ()
+doubleQuoteEnd = do
+ charOrRef "\"\8221"
+ return ()
+
+ellipses :: GenParser Char st Inline
+ellipses = do
+ try (charOrRef "…") <|> try (string "..." >> return '…')
+ return Ellipses
+
+dash :: GenParser Char st Inline
+dash = enDash <|> emDash
+
+enDash :: GenParser Char st Inline
+enDash = do
+ try (charOrRef "–") <|>
+ try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
+ return EnDash
+
+emDash :: GenParser Char st Inline
+emDash = do
+ try (charOrRef "—") <|> (try $ string "--" >> optional (char '-') >> return '—')
+ return EmDash
+
+--
+-- Macros
+--
+
+-- | Parse a \newcommand or \renewcommand macro definition.
+macro :: GenParser Char ParserState Block
+macro = do
+ getState >>= guard . stateApplyMacros
+ inp <- getInput
+ case parseMacroDefinitions inp of
+ ([], _) -> pzero
+ (ms, rest) -> do count (length inp - length rest) anyChar
+ updateState $ \st ->
+ st { stateMacros = ms ++ stateMacros st }
+ return Null
+
+-- | Apply current macros to string.
+applyMacros' :: String -> GenParser Char ParserState String
+applyMacros' target = do
+ apply <- liftM stateApplyMacros getState
+ if apply
+ then do macros <- liftM stateMacros getState
+ return $ applyMacros macros target
+ else return target
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
new file mode 100644
index 000000000..54d65af6f
--- /dev/null
+++ b/src/Text/Pandoc/Pretty.hs
@@ -0,0 +1,429 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-
+Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111(-1)307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Pretty
+ Copyright : Copyright (C) 2010 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+A prettyprinting library for the production of text documents,
+including wrapped text, indentated blocks, and tables.
+-}
+
+module Text.Pandoc.Pretty (
+ Doc
+ , render
+ , cr
+ , blankline
+ , space
+ , text
+ , char
+ , prefixed
+ , flush
+ , nest
+ , hang
+ , nowrap
+ , offset
+ , height
+ , lblock
+ , cblock
+ , rblock
+ , (<>)
+ , (<+>)
+ , ($$)
+ , ($+$)
+ , isEmpty
+ , empty
+ , cat
+ , hcat
+ , hsep
+ , vcat
+ , vsep
+ , inside
+ , braces
+ , brackets
+ , parens
+ , quotes
+ , doubleQuotes
+ )
+
+where
+import Data.DList (DList, fromList, toList, cons, singleton)
+import Data.List (intercalate)
+import Data.Monoid
+import Data.String
+import Control.Monad.State
+import Data.Char (isSpace)
+
+data Monoid a =>
+ RenderState a = RenderState{
+ output :: [a] -- ^ In reverse order
+ , prefix :: String
+ , usePrefix :: Bool
+ , lineLength :: Maybe Int -- ^ 'Nothing' means no wrapping
+ , column :: Int
+ , newlines :: Int -- ^ Number of preceding newlines
+ }
+
+type DocState a = State (RenderState a) ()
+
+data D = Text Int String
+ | Block Int [String]
+ | Prefixed String Doc
+ | Flush Doc
+ | BreakingSpace
+ | CarriageReturn
+ | NewLine
+ | BlankLine
+ deriving (Show)
+
+newtype Doc = Doc { unDoc :: DList D }
+ deriving (Monoid)
+
+instance Show Doc where
+ show = render Nothing
+
+instance IsString Doc where
+ fromString = text
+
+-- | True if the document is empty.
+isEmpty :: Doc -> Bool
+isEmpty = null . toList . unDoc
+
+-- | The empty document.
+empty :: Doc
+empty = mempty
+
+-- | @a <> b@ is the result of concatenating @a@ with @b@.
+(<>) :: Doc -> Doc -> Doc
+(<>) = mappend
+
+-- | Concatenate a list of 'Doc's.
+cat :: [Doc] -> Doc
+cat = mconcat
+
+-- | Same as 'cat'.
+hcat :: [Doc] -> Doc
+hcat = mconcat
+
+-- | Concatenate a list of 'Doc's, putting breakable spaces
+-- between them.
+(<+>) :: Doc -> Doc -> Doc
+(<+>) x y = if isEmpty x
+ then y
+ else if isEmpty y
+ then x
+ else x <> space <> y
+
+-- | Same as 'cat', but putting breakable spaces between the
+-- 'Doc's.
+hsep :: [Doc] -> Doc
+hsep = foldr (<+>) empty
+
+-- | @a $$ b@ puts @a@ above @b@.
+($$) :: Doc -> Doc -> Doc
+($$) x y = if isEmpty x
+ then y
+ else if isEmpty y
+ then x
+ else x <> cr <> y
+
+-- | @a $$ b@ puts @a@ above @b@, with a blank line between.
+($+$) :: Doc -> Doc -> Doc
+($+$) x y = if isEmpty x
+ then y
+ else if isEmpty y
+ then x
+ else x <> blankline <> y
+
+-- | List version of '$$'.
+vcat :: [Doc] -> Doc
+vcat = foldr ($$) empty
+
+-- | List version of '$+$'.
+vsep :: [Doc] -> Doc
+vsep = foldr ($+$) empty
+
+outp :: (IsString a, Monoid a)
+ => Int -> String -> DocState a
+outp off s | off <= 0 = do
+ st' <- get
+ let rawpref = prefix st'
+ when (column st' == 0 && usePrefix st' && not (null rawpref)) $ do
+ let pref = reverse $ dropWhile isSpace $ reverse rawpref
+ modify $ \st -> st{ output = fromString pref : output st
+ , column = column st + length pref }
+ when (off < 0) $ do
+ modify $ \st -> st { output = fromString s : output st
+ , column = 0
+ , newlines = newlines st + 1 }
+outp off s = do
+ st' <- get
+ let pref = prefix st'
+ when (column st' == 0 && usePrefix st' && not (null pref)) $ do
+ modify $ \st -> st{ output = fromString pref : output st
+ , column = column st + length pref }
+ modify $ \st -> st{ output = fromString s : output st
+ , column = column st + off
+ , newlines = 0 }
+
+-- | Renders a 'Doc'. @render (Just n)@ will use
+-- a line length of @n@ to reflow text on breakable spaces.
+-- @render Nothing@ will not reflow text.
+render :: (Monoid a, IsString a)
+ => Maybe Int -> Doc -> a
+render linelen doc = fromString . mconcat . reverse . output $
+ execState (renderDoc doc) startingState
+ where startingState = RenderState{
+ output = mempty
+ , prefix = ""
+ , usePrefix = True
+ , lineLength = linelen
+ , column = 0
+ , newlines = 2 }
+
+renderDoc :: (IsString a, Monoid a)
+ => Doc -> DocState a
+renderDoc = renderList . toList . unDoc
+
+renderList :: (IsString a, Monoid a)
+ => [D] -> DocState a
+renderList [] = return ()
+renderList (Text off s : xs) = do
+ outp off s
+ renderList xs
+
+renderList (Prefixed pref d : xs) = do
+ st <- get
+ let oldPref = prefix st
+ put st{ prefix = prefix st ++ pref }
+ renderDoc d
+ modify $ \s -> s{ prefix = oldPref }
+ renderList xs
+
+renderList (Flush d : xs) = do
+ st <- get
+ let oldUsePrefix = usePrefix st
+ put st{ usePrefix = False }
+ renderDoc d
+ modify $ \s -> s{ usePrefix = oldUsePrefix }
+ renderList xs
+
+renderList (BlankLine : xs) = do
+ st <- get
+ case output st of
+ _ | newlines st > 1 || null xs -> return ()
+ _ | column st == 0 -> do
+ outp (-1) "\n"
+ _ -> do
+ outp (-1) "\n"
+ outp (-1) "\n"
+ renderList xs
+
+renderList (CarriageReturn : xs) = do
+ st <- get
+ if newlines st > 0 || null xs
+ then renderList xs
+ else do
+ outp (-1) "\n"
+ renderList xs
+
+renderList (NewLine : xs) = do
+ outp (-1) "\n"
+ renderList xs
+
+renderList (BreakingSpace : CarriageReturn : xs) = renderList (CarriageReturn:xs)
+renderList (BreakingSpace : NewLine : xs) = renderList (NewLine:xs)
+renderList (BreakingSpace : BlankLine : xs) = renderList (BlankLine:xs)
+renderList (BreakingSpace : BreakingSpace : xs) = renderList (BreakingSpace:xs)
+renderList (BreakingSpace : xs) = do
+ let isText (Text _ _) = True
+ isText (Block _ _) = True
+ isText _ = False
+ let isBreakingSpace BreakingSpace = True
+ isBreakingSpace _ = False
+ let xs' = dropWhile isBreakingSpace xs
+ let next = takeWhile isText xs'
+ st <- get
+ let off = sum $ map offsetOf next
+ case lineLength st of
+ Just l | column st + 1 + off > l -> do
+ outp (-1) "\n"
+ renderList xs'
+ _ -> do
+ outp 1 " "
+ renderList xs'
+
+renderList (b1@Block{} : b2@Block{} : xs) =
+ renderList (mergeBlocks False b1 b2 : xs)
+
+renderList (b1@Block{} : BreakingSpace : b2@Block{} : xs) =
+ renderList (mergeBlocks True b1 b2 : xs)
+
+renderList (Block width lns : xs) = do
+ st <- get
+ let oldPref = prefix st
+ case column st - length oldPref of
+ n | n > 0 -> modify $ \s -> s{ prefix = oldPref ++ replicate n ' ' }
+ _ -> return ()
+ renderDoc $ blockToDoc width lns
+ modify $ \s -> s{ prefix = oldPref }
+ renderList xs
+
+mergeBlocks :: Bool -> D -> D -> D
+mergeBlocks addSpace (Block w1 lns1) (Block w2 lns2) =
+ Block (w1 + w2 + if addSpace then 1 else 0) $
+ zipWith (\l1 l2 -> pad w1 l1 ++ l2) (lns1 ++ empties) (map sp lns2 ++ empties)
+ where empties = replicate (abs $ length lns1 - length lns2) ""
+ pad n s = s ++ replicate (n - length s) ' '
+ sp "" = ""
+ sp xs = if addSpace then (' ' : xs) else xs
+mergeBlocks _ _ _ = error "mergeBlocks tried on non-Block!"
+
+blockToDoc :: Int -> [String] -> Doc
+blockToDoc _ lns = text $ intercalate "\n" lns
+
+offsetOf :: D -> Int
+offsetOf (Text o _) = o
+offsetOf (Block w _) = w
+offsetOf BreakingSpace = 1
+offsetOf _ = 0
+
+-- | A literal string.
+text :: String -> Doc
+text = Doc . toChunks
+ where toChunks :: String -> DList D
+ toChunks [] = mempty
+ toChunks s = case break (=='\n') s of
+ ([], _:ys) -> NewLine `cons` toChunks ys
+ (xs, _:ys) -> Text (length xs) xs `cons`
+ NewLine `cons` toChunks ys
+ (xs, []) -> singleton $ Text (length xs) xs
+
+-- | A character.
+char :: Char -> Doc
+char c = text [c]
+
+-- | A breaking (reflowable) space.
+space :: Doc
+space = Doc $ singleton BreakingSpace
+
+-- | A carriage return. Does nothing if we're at the beginning of
+-- a line; otherwise inserts a newline.
+cr :: Doc
+cr = Doc $ singleton CarriageReturn
+
+-- | Inserts a blank line unless one exists already.
+-- (@blankline <> blankline@ has the same effect as @blankline@.
+-- If you want multiple blank lines, use @text "\\n\\n"@.
+blankline :: Doc
+blankline = Doc $ singleton BlankLine
+
+-- | Uses the specified string as a prefix for every line of
+-- the inside document (except the first, if not at the beginning
+-- of the line).
+prefixed :: String -> Doc -> Doc
+prefixed pref doc = Doc $ singleton $ Prefixed pref doc
+
+-- | Makes a 'Doc' flush against the left margin.
+flush :: Doc -> Doc
+flush doc = Doc $ singleton $ Flush doc
+
+-- | Indents a 'Doc' by the specified number of spaces.
+nest :: Int -> Doc -> Doc
+nest ind = prefixed (replicate ind ' ')
+
+-- | A hanging indent. @hang ind start doc@ prints @start@,
+-- then @doc@, leaving an indent of @ind@ spaces on every
+-- line but the first.
+hang :: Int -> Doc -> Doc -> Doc
+hang ind start doc = start <> nest ind doc
+
+-- | Makes a 'Doc' non-reflowable.
+nowrap :: Doc -> Doc
+nowrap doc = Doc $ fromList $ map replaceSpace $ toList $ unDoc doc
+ where replaceSpace BreakingSpace = Text 1 " "
+ replaceSpace x = x
+
+-- | Returns the width of a 'Doc'.
+offset :: Doc -> Int
+offset d = case map length . lines . render Nothing $ d of
+ [] -> 0
+ os -> maximum os
+
+block :: (String -> String) -> Int -> Doc -> Doc
+block filler width = Doc . singleton . Block width .
+ map filler . chop width . render (Just width)
+
+-- | @lblock n d@ is a block of width @n@ characters, with
+-- text derived from @d@ and aligned to the left.
+lblock :: Int -> Doc -> Doc
+lblock = block id
+
+-- | Like 'lblock' but aligned to the right.
+rblock :: Int -> Doc -> Doc
+rblock w = block (\s -> replicate (w - length s) ' ' ++ s) w
+
+-- | Like 'lblock' but aligned centered.
+cblock :: Int -> Doc -> Doc
+cblock w = block (\s -> replicate ((w - length s) `div` 2) ' ' ++ s) w
+
+-- | Returns the height of a block or other 'Doc'.
+height :: Doc -> Int
+height = length . lines . render Nothing
+
+chop :: Int -> String -> [String]
+chop _ [] = []
+chop n cs = case break (=='\n') cs of
+ (xs, ys) -> if len <= n
+ then case ys of
+ [] -> [xs]
+ (_:[]) -> [xs, ""]
+ (_:zs) -> xs : chop n zs
+ else take n xs : chop n (drop n xs ++ ys)
+ where len = length xs
+
+-- | Encloses a 'Doc' inside a start and end 'Doc'.
+inside :: Doc -> Doc -> Doc -> Doc
+inside start end contents =
+ start <> contents <> end
+
+-- | Puts a 'Doc' in curly braces.
+braces :: Doc -> Doc
+braces = inside (char '{') (char '}')
+
+-- | Puts a 'Doc' in square brackets.
+brackets :: Doc -> Doc
+brackets = inside (char '[') (char ']')
+
+-- | Puts a 'Doc' in parentheses.
+parens :: Doc -> Doc
+parens = inside (char '(') (char ')')
+
+-- | Wraps a 'Doc' in single quotes.
+quotes :: Doc -> Doc
+quotes = inside (char '\'') (char '\'')
+
+-- | Wraps a 'Doc' in double quotes.
+doubleQuotes :: Doc -> Doc
+doubleQuotes = inside (char '"') (char '"')
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index f47309d3f..18e3113d3 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -27,43 +27,397 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of HTML to 'Pandoc' document.
-}
-module Text.Pandoc.Readers.HTML (
- readHtml,
- rawHtmlInline,
- rawHtmlBlock,
- anyHtmlBlockTag,
- anyHtmlInlineTag,
- anyHtmlTag,
- anyHtmlEndTag,
- htmlEndTag,
- extractTagType,
- htmlBlockElement,
- htmlComment,
- unsanitaryURI
+module Text.Pandoc.Readers.HTML ( readHtml
+ , htmlTag
+ , htmlInBalanced
+ , isInlineTag
+ , isBlockTag
+ , isTextTag
+ , isCommentTag
) where
import Text.ParserCombinators.Parsec
+import Text.ParserCombinators.Parsec.Pos
+import Text.HTML.TagSoup
+import Text.HTML.TagSoup.Match
import Text.Pandoc.Definition
+import Text.Pandoc.Builder (text, toList)
import Text.Pandoc.Shared
import Text.Pandoc.Parsing
-import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
-import Data.Maybe ( fromMaybe )
-import Data.List ( isPrefixOf, isSuffixOf, intercalate )
-import Data.Char ( toLower, isAlphaNum )
-import Network.URI ( parseURIReference, URI (..) )
-import Control.Monad ( liftM, when )
+import Data.Maybe ( fromMaybe, isJust )
+import Data.List ( intercalate )
+import Data.Char ( isSpace, isDigit )
+import Control.Monad ( liftM, guard )
-- | Convert HTML-formatted string to 'Pandoc' document.
readHtml :: ParserState -- ^ Parser state
-> String -- ^ String to parse (assumes @'\n'@ line endings)
-> Pandoc
-readHtml = readWith parseHtml
+readHtml st inp = Pandoc meta blocks
+ where blocks = readWith parseBody st rest
+ tags = canonicalizeTags $
+ parseTagsOptions parseOptions{ optTagPosition = True } inp
+ hasHeader = any (~== TagOpen "head" []) tags
+ (meta, rest) = if hasHeader
+ then parseHeader tags
+ else (Meta [] [] [], tags)
+
+type TagParser = GenParser (Tag String) ParserState
+
+-- TODO - fix this - not every header has a title tag
+parseHeader :: [Tag String] -> (Meta, [Tag String])
+parseHeader tags = (Meta{docTitle = tit'', docAuthors = [], docDate = []}, rest)
+ where (tit,_) = break (~== TagClose "title") $ drop 1 $
+ dropWhile (\t -> not $ t ~== TagOpen "title" []) tags
+ tit' = concatMap fromTagText $ filter isTagText tit
+ tit'' = normalizeSpaces $ toList $ text tit'
+ rest = drop 1 $ dropWhile (\t -> not $ t ~== TagClose "head" ||
+ t ~== TagOpen "body" []) tags
+
+parseBody :: TagParser [Block]
+parseBody = liftM concat $ manyTill block eof
+
+block :: TagParser [Block]
+block = choice
+ [ pPara
+ , pHeader
+ , pBlockQuote
+ , pCodeBlock
+ , pList
+ , pHrule
+ , pSimpleTable
+ , pPlain
+ , pRawHtmlBlock
+ ]
+
+renderTags' :: [Tag String] -> String
+renderTags' = renderTagsOptions
+ renderOptions{ optMinimize = (`elem` ["hr","br","img"]) }
+
+pList :: TagParser [Block]
+pList = pBulletList <|> pOrderedList <|> pDefinitionList
+
+pBulletList :: TagParser [Block]
+pBulletList = try $ do
+ pSatisfy (~== TagOpen "ul" [])
+ let nonItem = pSatisfy (\t ->
+ not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
+ not (t ~== TagClose "ul"))
+ -- note: if they have an <ol> or <ul> not in scope of a <li>,
+ -- treat it as a list item, though it's not valid xhtml...
+ skipMany nonItem
+ items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ul")
+ return [BulletList items]
+
+pOrderedList :: TagParser [Block]
+pOrderedList = try $ do
+ TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
+ st <- getState
+ let (start, style) = if stateStrict st
+ then (1, DefaultStyle)
+ else (sta', sty')
+ where sta = fromMaybe "1" $
+ lookup "start" attribs
+ sta' = if all isDigit sta
+ then read sta
+ else 1
+ sty = fromMaybe (fromMaybe "" $
+ lookup "style" attribs) $
+ lookup "class" attribs
+ sty' = case sty of
+ "lower-roman" -> LowerRoman
+ "upper-roman" -> UpperRoman
+ "lower-alpha" -> LowerAlpha
+ "upper-alpha" -> UpperAlpha
+ "decimal" -> Decimal
+ _ -> DefaultStyle
+ let nonItem = pSatisfy (\t ->
+ not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
+ not (t ~== TagClose "ol"))
+ -- note: if they have an <ol> or <ul> not in scope of a <li>,
+ -- treat it as a list item, though it's not valid xhtml...
+ skipMany nonItem
+ items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ol")
+ return [OrderedList (start, style, DefaultDelim) items]
+
+pDefinitionList :: TagParser [Block]
+pDefinitionList = try $ do
+ pSatisfy (~== TagOpen "dl" [])
+ items <- manyTill pDefListItem (pCloses "dl")
+ return [DefinitionList items]
+
+pDefListItem :: TagParser ([Inline],[[Block]])
+pDefListItem = try $ do
+ let nonItem = pSatisfy (\t -> not (t ~== TagOpen "dt" []) &&
+ not (t ~== TagOpen "dd" []) && not (t ~== TagClose "dl"))
+ terms <- many1 (try $ skipMany nonItem >> pInTags "dt" inline)
+ defs <- many1 (try $ skipMany nonItem >> pInTags "dd" block)
+ skipMany nonItem
+ let term = intercalate [LineBreak] terms
+ return (term, defs)
+
+pRawTag :: TagParser String
+pRawTag = do
+ tag <- pAnyTag
+ let ignorable x = x `elem` ["html","head","body"]
+ if tagOpen ignorable (const True) tag || tagClose ignorable tag
+ then return []
+ else return $ renderTags' [tag]
+
+pRawHtmlBlock :: TagParser [Block]
+pRawHtmlBlock = do
+ raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag
+ state <- getState
+ if stateParseRaw state && not (null raw)
+ then return [RawBlock "html" raw]
+ else return []
+
+pHtmlBlock :: String -> TagParser String
+pHtmlBlock t = try $ do
+ open <- pSatisfy (~== TagOpen t [])
+ contents <- manyTill pAnyTag (pSatisfy (~== TagClose t))
+ return $ renderTags' $ [open] ++ contents ++ [TagClose t]
+
+pHeader :: TagParser [Block]
+pHeader = try $ do
+ TagOpen tagtype attr <- pSatisfy $
+ tagOpen (`elem` ["h1","h2","h3","h4","h5","h6"])
+ (const True)
+ let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
+ let level = read (drop 1 tagtype)
+ contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof)
+ return $ if bodyTitle
+ then [] -- skip a representation of the title in the body
+ else [Header level $ normalizeSpaces contents]
+
+pHrule :: TagParser [Block]
+pHrule = do
+ pSelfClosing (=="hr") (const True)
+ return [HorizontalRule]
+
+pSimpleTable :: TagParser [Block]
+pSimpleTable = try $ do
+ TagOpen _ _ <- pSatisfy (~== TagOpen "table" [])
+ skipMany pBlank
+ head' <- option [] $ pInTags "th" pTd
+ rows <- many1 $ try $
+ skipMany pBlank >> pInTags "tr" pTd
+ skipMany pBlank
+ TagClose _ <- pSatisfy (~== TagClose "table")
+ let cols = maximum $ map length rows
+ let aligns = replicate cols AlignLeft
+ let widths = replicate cols 0
+ return [Table [] aligns widths head' rows]
+
+pTd :: TagParser [TableCell]
+pTd = try $ do
+ skipMany pBlank
+ res <- pInTags "td" pPlain
+ skipMany pBlank
+ return [res]
+
+pBlockQuote :: TagParser [Block]
+pBlockQuote = do
+ contents <- pInTags "blockquote" block
+ return [BlockQuote contents]
+
+pPlain :: TagParser [Block]
+pPlain = do
+ contents <- liftM (normalizeSpaces . concat) $ many1 inline
+ if null contents
+ then return []
+ else return [Plain contents]
+
+pPara :: TagParser [Block]
+pPara = do
+ contents <- pInTags "p" inline
+ return [Para $ normalizeSpaces contents]
+
+pCodeBlock :: TagParser [Block]
+pCodeBlock = try $ do
+ TagOpen _ attr <- pSatisfy (~== TagOpen "pre" [])
+ contents <- manyTill pAnyTag (pCloses "pre" <|> eof)
+ let rawText = concatMap fromTagText $ filter isTagText contents
+ -- drop leading newline if any
+ let result' = case rawText of
+ '\n':xs -> xs
+ _ -> rawText
+ -- drop trailing newline if any
+ let result = case reverse result' of
+ '\n':_ -> init result'
+ _ -> result'
+ let attribsId = fromMaybe "" $ lookup "id" attr
+ let attribsClasses = words $ fromMaybe "" $ lookup "class" attr
+ let attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr
+ st <- getState
+ let attribs = if stateStrict st
+ then ("",[],[])
+ else (attribsId, attribsClasses, attribsKV)
+ return [CodeBlock attribs result]
+
+inline :: TagParser [Inline]
+inline = choice
+ [ pTagText
+ , pEmph
+ , pStrong
+ , pSuperscript
+ , pSubscript
+ , pStrikeout
+ , pLineBreak
+ , pLink
+ , pImage
+ , pCode
+ , pRawHtmlInline
+ ]
+
+pLocation :: TagParser ()
+pLocation = do
+ (TagPosition r c) <- pSat isTagPosition
+ setPosition $ newPos "input" r c
+
+pSat :: (Tag String -> Bool) -> TagParser (Tag String)
+pSat f = do
+ pos <- getPosition
+ token show (const pos) (\x -> if f x then Just x else Nothing)
+
+pSatisfy :: (Tag String -> Bool) -> TagParser (Tag String)
+pSatisfy f = try $ optional pLocation >> pSat f
+
+pAnyTag :: TagParser (Tag String)
+pAnyTag = pSatisfy (const True)
+
+pSelfClosing :: (String -> Bool) -> ([Attribute String] -> Bool)
+ -> TagParser (Tag String)
+pSelfClosing f g = do
+ open <- pSatisfy (tagOpen f g)
+ optional $ pSatisfy (tagClose f)
+ return open
+
+pEmph :: TagParser [Inline]
+pEmph = pInlinesInTags "em" Emph <|> pInlinesInTags "i" Emph
+
+pStrong :: TagParser [Inline]
+pStrong = pInlinesInTags "strong" Strong <|> pInlinesInTags "b" Strong
+
+pSuperscript :: TagParser [Inline]
+pSuperscript = failIfStrict >> pInlinesInTags "sup" Superscript
+
+pSubscript :: TagParser [Inline]
+pSubscript = failIfStrict >> pInlinesInTags "sub" Subscript
+
+pStrikeout :: TagParser [Inline]
+pStrikeout = do
+ failIfStrict
+ pInlinesInTags "s" Strikeout <|>
+ pInlinesInTags "strike" Strikeout <|>
+ pInlinesInTags "del" Strikeout <|>
+ try (do pSatisfy (~== TagOpen "span" [("class","strikeout")])
+ contents <- liftM concat $ manyTill inline (pCloses "span")
+ return [Strikeout contents])
+
+pLineBreak :: TagParser [Inline]
+pLineBreak = do
+ pSelfClosing (=="br") (const True)
+ return [LineBreak]
+
+pLink :: TagParser [Inline]
+pLink = try $ do
+ tag <- pSatisfy (tagOpenLit "a" (isJust . lookup "href"))
+ let url = fromAttrib "href" tag
+ let title = fromAttrib "title" tag
+ lab <- liftM concat $ manyTill inline (pCloses "a")
+ return [Link (normalizeSpaces lab) (escapeURI url, title)]
+
+pImage :: TagParser [Inline]
+pImage = do
+ tag <- pSelfClosing (=="img") (isJust . lookup "src")
+ let url = fromAttrib "src" tag
+ let title = fromAttrib "title" tag
+ let alt = fromAttrib "alt" tag
+ return [Image (toList $ text alt) (escapeURI url, title)]
+
+pCode :: TagParser [Inline]
+pCode = try $ do
+ (TagOpen open attr) <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)
+ result <- manyTill pAnyTag (pCloses open)
+ let ident = fromMaybe "" $ lookup "id" attr
+ let classes = words $ fromMaybe [] $ lookup "class" attr
+ let rest = filter (\(x,_) -> x /= "id" && x /= "class") attr
+ return [Code (ident,classes,rest)
+ $ intercalate " " $ lines $ innerText result]
+
+pRawHtmlInline :: TagParser [Inline]
+pRawHtmlInline = do
+ result <- pSatisfy (tagComment (const True)) <|> pSatisfy isInlineTag
+ state <- getState
+ if stateParseRaw state
+ then return [RawInline "html" $ renderTags' [result]]
+ else return []
+
+pInlinesInTags :: String -> ([Inline] -> Inline)
+ -> TagParser [Inline]
+pInlinesInTags tagtype f = do
+ contents <- pInTags tagtype inline
+ return [f contents]
+
+pInTags :: String -> TagParser [a]
+ -> TagParser [a]
+pInTags tagtype parser = try $ do
+ pSatisfy (~== TagOpen tagtype [])
+ liftM concat $ manyTill parser (pCloses tagtype <|> eof)
+
+pCloses :: String -> TagParser ()
+pCloses tagtype = try $ do
+ t <- lookAhead $ pSatisfy $ \tag -> isTagClose tag || isTagOpen tag
+ case t of
+ (TagClose t') | t' == tagtype -> pAnyTag >> return ()
+ (TagOpen t' _) | t' `closes` tagtype -> return ()
+ (TagClose "ul") | tagtype == "li" -> return ()
+ (TagClose "ol") | tagtype == "li" -> return ()
+ (TagClose "dl") | tagtype == "li" -> return ()
+ _ -> pzero
+
+pTagText :: TagParser [Inline]
+pTagText = try $ do
+ (TagText str) <- pSatisfy isTagText
+ st <- getState
+ case runParser (many pTagContents) st "text" str of
+ Left _ -> fail $ "Could not parse `" ++ str ++ "'"
+ Right result -> return result
+
+pBlank :: TagParser ()
+pBlank = try $ do
+ (TagText str) <- pSatisfy isTagText
+ guard $ all isSpace str
+
+pTagContents :: GenParser Char ParserState Inline
+pTagContents = pStr <|> pSpace <|> smartPunctuation pTagContents <|> pSymbol
+
+pStr :: GenParser Char ParserState Inline
+pStr = liftM Str $ many1 $ satisfy $ \c -> not (isSpace c) && not (isSpecial c)
+
+isSpecial :: Char -> Bool
+isSpecial '"' = True
+isSpecial '\'' = True
+isSpecial '.' = True
+isSpecial '-' = True
+isSpecial '\8216' = True
+isSpecial '\8217' = True
+isSpecial '\8220' = True
+isSpecial '\8221' = True
+isSpecial _ = False
+
+pSymbol :: GenParser Char ParserState Inline
+pSymbol = satisfy isSpecial >>= return . Str . (:[])
+
+pSpace :: GenParser Char ParserState Inline
+pSpace = many1 (satisfy isSpace) >> return Space
--
-- Constants
--
-eitherBlockOrInline :: [[Char]]
+eitherBlockOrInline :: [String]
eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",
"map", "area", "object"]
@@ -76,57 +430,41 @@ inlineHtmlTags = ["a", "abbr", "acronym", "b", "basefont", "bdo", "big",
"textarea", "tt", "u", "var"]
-}
-blockHtmlTags :: [[Char]]
+blockHtmlTags :: [String]
blockHtmlTags = ["address", "blockquote", "body", "center", "dir", "div",
"dl", "fieldset", "form", "h1", "h2", "h3", "h4",
- "h5", "h6", "head", "hr", "html", "isindex", "menu", "noframes",
- "noscript", "ol", "p", "pre", "table", "ul", "dd",
+ "h5", "h6", "head", "hr", "html", "isindex", "menu",
+ "noframes", "noscript", "ol", "p", "pre", "table", "ul", "dd",
"dt", "frameset", "li", "tbody", "td", "tfoot",
"th", "thead", "tr", "script", "style"]
-sanitaryTags :: [[Char]]
-sanitaryTags = ["a", "abbr", "acronym", "address", "area", "b", "big",
- "blockquote", "br", "button", "caption", "center",
- "cite", "code", "col", "colgroup", "dd", "del", "dfn",
- "dir", "div", "dl", "dt", "em", "fieldset", "font",
- "form", "h1", "h2", "h3", "h4", "h5", "h6", "hr",
- "i", "img", "input", "ins", "kbd", "label", "legend",
- "li", "map", "menu", "ol", "optgroup", "option", "p",
- "pre", "q", "s", "samp", "select", "small", "span",
- "strike", "strong", "sub", "sup", "table", "tbody",
- "td", "textarea", "tfoot", "th", "thead", "tr", "tt",
- "u", "ul", "var"]
-
-sanitaryAttributes :: [[Char]]
-sanitaryAttributes = ["abbr", "accept", "accept-charset",
- "accesskey", "action", "align", "alt", "axis",
- "border", "cellpadding", "cellspacing", "char",
- "charoff", "charset", "checked", "cite", "class",
- "clear", "cols", "colspan", "color", "compact",
- "coords", "datetime", "dir", "disabled",
- "enctype", "for", "frame", "headers", "height",
- "href", "hreflang", "hspace", "id", "ismap",
- "label", "lang", "longdesc", "maxlength", "media",
- "method", "multiple", "name", "nohref", "noshade",
- "nowrap", "prompt", "readonly", "rel", "rev",
- "rows", "rowspan", "rules", "scope", "selected",
- "shape", "size", "span", "src", "start",
- "summary", "tabindex", "target", "title", "type",
- "usemap", "valign", "value", "vspace", "width"]
+isInlineTag :: Tag String -> Bool
+isInlineTag t = tagOpen (`notElem` blockHtmlTags) (const True) t ||
+ tagClose (`notElem` blockHtmlTags) t ||
+ tagComment (const True) t
+
+isBlockTag :: Tag String -> Bool
+isBlockTag t = tagOpen (`elem` blocktags) (const True) t ||
+ tagClose (`elem` blocktags) t ||
+ tagComment (const True) t
+ where blocktags = blockHtmlTags ++ eitherBlockOrInline
+
+isTextTag :: Tag String -> Bool
+isTextTag = tagText (const True)
+
+isCommentTag :: Tag String -> Bool
+isCommentTag = tagComment (const True)
-- taken from HXT and extended
closes :: String -> String -> Bool
-"EOF" `closes` _ = True
_ `closes` "body" = False
_ `closes` "html" = False
"a" `closes` "a" = True
"li" `closes` "li" = True
"th" `closes` t | t `elem` ["th","td"] = True
-"td" `closes` t | t `elem` ["th","td"] = True
"tr" `closes` t | t `elem` ["th","td","tr"] = True
"dt" `closes` t | t `elem` ["dt","dd"] = True
-"dd" `closes` t | t `elem` ["dt","dd"] = True
"hr" `closes` "p" = True
"p" `closes` "p" = True
"meta" `closes` "meta" = True
@@ -148,627 +486,34 @@ t1 `closes` t2 |
t2 `notElem` (blockHtmlTags ++ eitherBlockOrInline) = True
_ `closes` _ = False
---
--- HTML utility functions
---
-
--- | Returns @True@ if sanitization is specified and the specified tag is
--- not on the sanitized tag list.
-unsanitaryTag :: [Char]
- -> GenParser tok ParserState Bool
-unsanitaryTag tag = do
- st <- getState
- return $ stateSanitizeHTML st && tag `notElem` sanitaryTags
-
--- | returns @True@ if sanitization is specified and the specified attribute
--- is not on the sanitized attribute list.
-unsanitaryAttribute :: ([Char], String, t)
- -> GenParser tok ParserState Bool
-unsanitaryAttribute (attr, val, _) = do
- st <- getState
- return $ stateSanitizeHTML st &&
- (attr `notElem` sanitaryAttributes ||
- (attr `elem` ["href","src"] && unsanitaryURI val))
-
--- | Returns @True@ if the specified URI is potentially a security risk.
-unsanitaryURI :: String -> Bool
-unsanitaryURI u =
- let safeURISchemes = [ "", "http:", "https:", "ftp:", "mailto:", "file:",
- "telnet:", "gopher:", "aaa:", "aaas:", "acap:", "cap:", "cid:",
- "crid:", "dav:", "dict:", "dns:", "fax:", "go:", "h323:", "im:",
- "imap:", "ldap:", "mid:", "news:", "nfs:", "nntp:", "pop:",
- "pres:", "sip:", "sips:", "snmp:", "tel:", "urn:", "wais:",
- "xmpp:", "z39.50r:", "z39.50s:", "aim:", "callto:", "cvs:",
- "ed2k:", "feed:", "fish:", "gg:", "irc:", "ircs:", "lastfm:",
- "ldaps:", "magnet:", "mms:", "msnim:", "notes:", "rsync:",
- "secondlife:", "skype:", "ssh:", "sftp:", "smb:", "sms:",
- "snews:", "webcal:", "ymsgr:"]
- in case parseURIReference (escapeURI u) of
- Just p -> (map toLower $ uriScheme p) `notElem` safeURISchemes
- Nothing -> True
-
--- | Read blocks until end tag.
-blocksTilEnd :: String -> GenParser Char ParserState [Block]
-blocksTilEnd tag = do
- blocks <- manyTill (block >>~ spaces) (htmlEndTag tag)
- return $ filter (/= Null) blocks
-
--- | Read inlines until end tag.
-inlinesTilEnd :: String -> GenParser Char ParserState [Inline]
-inlinesTilEnd tag = manyTill inline (htmlEndTag tag)
-
--- | Parse blocks between open and close tag.
-blocksIn :: String -> GenParser Char ParserState [Block]
-blocksIn tag = try $ htmlOpenTag tag >> spaces >> blocksTilEnd tag
-
--- | Parse inlines between open and close tag.
-inlinesIn :: String -> GenParser Char ParserState [Inline]
-inlinesIn tag = try $ htmlOpenTag tag >> spaces >> inlinesTilEnd tag
-
--- | Extract type from a tag: e.g. @br@ from @\<br\>@
-extractTagType :: String -> String
-extractTagType ('<':rest) =
- let isSpaceOrSlash c = c `elem` "/ \n\t" in
- map toLower $ takeWhile isAlphaNum $ dropWhile isSpaceOrSlash rest
-extractTagType _ = ""
-
--- Parse any HTML tag (opening or self-closing) and return tag type
-anyOpener :: GenParser Char ParserState [Char]
-anyOpener = try $ do
- char '<'
- spaces
- tag <- many1 alphaNum
- skipMany htmlAttribute
- spaces
- option "" (string "/")
- spaces
- char '>'
- return $ map toLower tag
-
--- | Parse any HTML tag (opening or self-closing) and return text of tag
-anyHtmlTag :: GenParser Char ParserState [Char]
-anyHtmlTag = try $ do
- char '<'
- spaces
- tag <- many1 alphaNum
- attribs <- many htmlAttribute
- spaces
- ender <- option "" (string "/")
- let ender' = if null ender then "" else " /"
- spaces
- char '>'
- let result = "<" ++ tag ++
- concatMap (\(_, _, raw) -> (' ':raw)) attribs ++ ender' ++ ">"
- unsanitary <- unsanitaryTag tag
- if unsanitary
- then return $ "<!-- unsafe HTML removed -->"
- else return result
-
-anyHtmlEndTag :: GenParser Char ParserState [Char]
-anyHtmlEndTag = try $ do
- char '<'
- spaces
- char '/'
- spaces
- tag <- many1 alphaNum
- spaces
- char '>'
- let result = "</" ++ tag ++ ">"
- unsanitary <- unsanitaryTag tag
- if unsanitary
- then return $ "<!-- unsafe HTML removed -->"
- else return result
-
-htmlTag :: Bool
- -> String
- -> GenParser Char ParserState (String, [(String, String)])
-htmlTag selfClosing tag = try $ do
- char '<'
- spaces
- stringAnyCase tag
- attribs <- many htmlAttribute
- spaces
- -- note: we want to handle both HTML and XHTML,
- -- so we don't require the /
- when selfClosing $ optional $ char '/' >> spaces
- char '>'
- return (tag, (map (\(name, content, _) -> (name, content)) attribs))
-
-htmlOpenTag :: String
- -> GenParser Char ParserState (String, [(String, String)])
-htmlOpenTag = htmlTag False
-
-htmlCloseTag :: String
- -> GenParser Char ParserState (String, [(String, String)])
-htmlCloseTag = htmlTag False . ('/':)
-
-htmlSelfClosingTag :: String
- -> GenParser Char ParserState (String, [(String, String)])
-htmlSelfClosingTag = htmlTag True
-
--- parses a quoted html attribute value
-quoted :: Char -> GenParser Char st (String, String)
-quoted quoteChar = do
- result <- between (char quoteChar) (char quoteChar)
- (many (noneOf [quoteChar]))
- return (result, [quoteChar])
-
-nullAttribute :: ([Char], [Char], [Char])
-nullAttribute = ("", "", "")
-
-htmlAttribute :: GenParser Char ParserState ([Char], [Char], [Char])
-htmlAttribute = do
- attr <- htmlRegularAttribute <|> htmlMinimizedAttribute
- unsanitary <- unsanitaryAttribute attr
- if unsanitary
- then return nullAttribute
- else return attr
-
--- minimized boolean attribute
-htmlMinimizedAttribute :: GenParser Char st ([Char], [Char], [Char])
-htmlMinimizedAttribute = try $ do
- many1 space
- name <- many1 (choice [letter, oneOf ".-_:"])
- return (name, name, name)
-
-htmlRegularAttribute :: GenParser Char st ([Char], [Char], [Char])
-htmlRegularAttribute = try $ do
- many1 space
- name <- many1 (choice [letter, oneOf ".-_:"])
- spaces
- char '='
- spaces
- (content, quoteStr) <- choice [ (quoted '\''),
- (quoted '"'),
- (do
- a <- many (noneOf " \t\n\r\"'<>")
- return (a,"")) ]
- return (name, content,
- (name ++ "=" ++ quoteStr ++ content ++ quoteStr))
-
--- | Parse an end tag of type 'tag'
-htmlEndTag :: [Char] -> GenParser Char ParserState [Char]
-htmlEndTag tag = try $ do
- closedByNext <- lookAhead $ option False $ liftM (`closes` tag) $
- anyOpener <|> (eof >> return "EOF")
- if closedByNext
- then return ""
- else do char '<'
- spaces
- char '/'
- spaces
- stringAnyCase tag
- spaces
- char '>'
- return $ "</" ++ tag ++ ">"
-
--- | Returns @True@ if the tag is (or can be) a block tag.
-isBlock :: String -> Bool
-isBlock tag = (extractTagType tag) `elem` (blockHtmlTags ++ eitherBlockOrInline)
-
-anyHtmlBlockTag :: GenParser Char ParserState [Char]
-anyHtmlBlockTag = try $ do
- tag <- anyHtmlTag <|> anyHtmlEndTag
- if isBlock tag then return tag else fail "not a block tag"
-
-anyHtmlInlineTag :: GenParser Char ParserState [Char]
-anyHtmlInlineTag = try $ do
- tag <- anyHtmlTag <|> anyHtmlEndTag
- if not (isBlock tag) then return tag else fail "not an inline tag"
-
--- | Parses material between script tags.
--- Scripts must be treated differently, because they can contain '<>' etc.
-htmlScript :: GenParser Char ParserState [Char]
-htmlScript = try $ do
- lookAhead $ htmlOpenTag "script"
- open <- anyHtmlTag
- rest <- liftM concat $ manyTill scriptChunk (htmlEndTag "script")
- st <- getState
- if stateSanitizeHTML st && not ("script" `elem` sanitaryTags)
- then return "<!-- unsafe HTML removed -->"
- else return $ open ++ rest ++ "</script>"
-
-scriptChunk :: GenParser Char ParserState [Char]
-scriptChunk = jsComment <|> jsString <|> jsChars
- where jsComment = jsEndlineComment <|> jsMultilineComment
- jsString = jsSingleQuoteString <|> jsDoubleQuoteString
- jsChars = many1 (noneOf "<\"'*/") <|> count 1 anyChar
- jsEndlineComment = try $ do
- string "//"
- res <- manyTill anyChar newline
- return ("//" ++ res)
- jsMultilineComment = try $ do
- string "/*"
- res <- manyTill anyChar (try $ string "*/")
- return ("/*" ++ res ++ "*/")
- jsSingleQuoteString = stringwith '\''
- jsDoubleQuoteString = stringwith '"'
- charWithEsc escapable = try $
- (try $ char '\\' >> oneOf ('\\':escapable) >>= \x -> return ['\\',x])
- <|> count 1 anyChar
- stringwith c = try $ do
- char c
- res <- liftM concat $ manyTill (charWithEsc [c]) (char c)
- return (c : (res ++ [c]))
-
--- | Parses material between style tags.
--- Style tags must be treated differently, because they can contain CSS
-htmlStyle :: GenParser Char ParserState [Char]
-htmlStyle = try $ do
- lookAhead $ htmlOpenTag "style"
- open <- anyHtmlTag
- rest <- manyTill anyChar (htmlEndTag "style")
- st <- getState
- if stateSanitizeHTML st && not ("style" `elem` sanitaryTags)
- then return "<!-- unsafe HTML removed -->"
- else return $ open ++ rest ++ "</style>"
-
-htmlBlockElement :: GenParser Char ParserState [Char]
-htmlBlockElement = choice [ htmlScript, htmlStyle, htmlComment, xmlDec, definition ]
-
-rawHtmlBlock :: GenParser Char ParserState Block
-rawHtmlBlock = try $ do
- body <- htmlBlockElement <|> rawVerbatimBlock <|> anyHtmlBlockTag
- state <- getState
- if stateParseRaw state then return (RawHtml body) else return Null
-
--- This is a block whose contents should be passed through verbatim, not interpreted.
-rawVerbatimBlock :: GenParser Char ParserState [Char]
-rawVerbatimBlock = try $ do
- start <- anyHtmlBlockTag
- let tagtype = extractTagType start
- if tagtype `elem` ["pre"]
- then do
- contents <- many (notFollowedBy' (htmlEndTag tagtype) >> anyChar)
- end <- htmlEndTag tagtype
- return $ start ++ contents ++ end
- else fail "Not a verbatim block"
-
--- We don't want to parse </body> or </html> as raw HTML, since these
--- are handled in parseHtml.
-rawHtmlBlock' :: GenParser Char ParserState Block
-rawHtmlBlock' = do notFollowedBy' (htmlCloseTag "body" <|>
- htmlCloseTag "html")
- rawHtmlBlock
-
--- | Parses an HTML comment.
-htmlComment :: GenParser Char st [Char]
-htmlComment = try $ do
- string "<!--"
- comment <- many $ noneOf "-"
- <|> try (char '-' >>~ notFollowedBy (try (char '-' >> char '>')))
- string "-->"
- return $ "<!--" ++ comment ++ "-->"
-
---
--- parsing documents
---
-
-xmlDec :: GenParser Char st [Char]
-xmlDec = try $ do
- string "<?"
- rest <- manyTill anyChar (char '>')
- return $ "<?" ++ rest ++ ">"
-
-definition :: GenParser Char st [Char]
-definition = try $ do
- string "<!"
- rest <- manyTill anyChar (char '>')
- return $ "<!" ++ rest ++ ">"
-
-nonTitleNonHead :: GenParser Char ParserState Char
-nonTitleNonHead = try $ do
- notFollowedBy $ (htmlOpenTag "title" >> return ' ') <|>
- (htmlEndTag "head" >> return ' ')
- (rawHtmlBlock >> return ' ') <|> anyChar
-
-parseTitle :: GenParser Char ParserState [Inline]
-parseTitle = try $ do
- (tag, _) <- htmlOpenTag "title"
- contents <- inlinesTilEnd tag
- spaces
- return contents
-
--- parse header and return meta-information (for now, just title)
-parseHead :: GenParser Char ParserState Meta
-parseHead = try $ do
- htmlOpenTag "head"
- spaces
- skipMany nonTitleNonHead
- contents <- option [] parseTitle
- skipMany nonTitleNonHead
- htmlEndTag "head"
- return $ Meta contents [] []
-
--- h1 class="title" representation of title in body
-bodyTitle :: GenParser Char ParserState [Inline]
-bodyTitle = try $ do
- (_, attribs) <- htmlOpenTag "h1"
- case (extractAttribute "class" attribs) of
- Just "title" -> return ""
- _ -> fail "not title"
- inlinesTilEnd "h1"
-
-endOfDoc :: GenParser Char ParserState ()
-endOfDoc = try $ do
- spaces
- optional (htmlEndTag "body")
- spaces
- optional (htmlEndTag "html" >> many anyChar) -- ignore stuff after </html>
- eof
-
-parseHtml :: GenParser Char ParserState Pandoc
-parseHtml = do
- sepEndBy (choice [xmlDec, definition, htmlComment]) spaces
- spaces
- optional $ htmlOpenTag "html"
- spaces
- meta <- option (Meta [] [] []) parseHead
- spaces
- optional $ htmlOpenTag "body"
- spaces
- optional bodyTitle -- skip title in body, because it's represented in meta
- blocks <- parseBlocks
- endOfDoc
- return $ Pandoc meta blocks
-
---
--- parsing blocks
---
-
-parseBlocks :: GenParser Char ParserState [Block]
-parseBlocks = spaces >> sepEndBy block spaces >>= (return . filter (/= Null))
-
-block :: GenParser Char ParserState Block
-block = choice [ codeBlock
- , header
- , hrule
- , list
- , blockQuote
- , para
- , plain
- , rawHtmlBlock'
- , notFollowedBy' endOfDoc >> char '<' >> return Null
- ] <?> "block"
-
---
--- header blocks
---
-
-header :: GenParser Char ParserState Block
-header = choice (map headerLevel (enumFromTo 1 5)) <?> "header"
-
-headerLevel :: Int -> GenParser Char ParserState Block
-headerLevel n = try $ do
- let level = "h" ++ show n
- htmlOpenTag level
- contents <- inlinesTilEnd level
- return $ Header n (normalizeSpaces contents)
-
---
--- hrule block
---
-
-hrule :: GenParser Char ParserState Block
-hrule = try $ do
- (_, attribs) <- htmlSelfClosingTag "hr"
- state <- getState
- if not (null attribs) && stateParseRaw state
- then unexpected "attributes in hr" -- parse as raw in this case
- else return HorizontalRule
-
---
--- code blocks
---
-
--- Note: HTML tags in code blocks (e.g. for syntax highlighting) are
--- skipped, because they are not portable to output formats other than HTML.
-codeBlock :: GenParser Char ParserState Block
-codeBlock = try $ do
- htmlOpenTag "pre"
- result <- manyTill
- (many1 (satisfy (/= '<')) <|>
- ((anyHtmlTag <|> anyHtmlEndTag) >> return ""))
- (htmlEndTag "pre")
- let result' = concat result
- -- drop leading newline if any
- let result'' = if "\n" `isPrefixOf` result'
- then drop 1 result'
- else result'
- -- drop trailing newline if any
- let result''' = if "\n" `isSuffixOf` result''
- then init result''
- else result''
- return $ CodeBlock ("",[],[]) $ decodeCharacterReferences result'''
-
---
--- block quotes
---
-
-blockQuote :: GenParser Char ParserState Block
-blockQuote = try $ htmlOpenTag "blockquote" >> spaces >>
- blocksTilEnd "blockquote" >>= (return . BlockQuote)
-
---
--- list blocks
---
-
-list :: GenParser Char ParserState Block
-list = choice [ bulletList, orderedList, definitionList ] <?> "list"
-
-orderedList :: GenParser Char ParserState Block
-orderedList = try $ do
- (_, attribs) <- htmlOpenTag "ol"
- (start, style) <- option (1, DefaultStyle) $
- do failIfStrict
- let sta = fromMaybe "1" $
- lookup "start" attribs
- let sty = fromMaybe (fromMaybe "" $
- lookup "style" attribs) $
- lookup "class" attribs
- let sty' = case sty of
- "lower-roman" -> LowerRoman
- "upper-roman" -> UpperRoman
- "lower-alpha" -> LowerAlpha
- "upper-alpha" -> UpperAlpha
- "decimal" -> Decimal
- _ -> DefaultStyle
- return (read sta, sty')
- spaces
- -- note: if they have an <ol> or <ul> not in scope of a <li>,
- -- treat it as a list item, though it's not valid xhtml...
- items <- sepEndBy1 (blocksIn "li" <|> liftM (:[]) list) spaces
- htmlEndTag "ol"
- return $ OrderedList (start, style, DefaultDelim) items
-
-bulletList :: GenParser Char ParserState Block
-bulletList = try $ do
- htmlOpenTag "ul"
- spaces
- -- note: if they have an <ol> or <ul> not in scope of a <li>,
- -- treat it as a list item, though it's not valid xhtml...
- items <- sepEndBy1 (blocksIn "li" <|> liftM (:[]) list) spaces
- htmlEndTag "ul"
- return $ BulletList items
-
-definitionList :: GenParser Char ParserState Block
-definitionList = try $ do
- failIfStrict -- def lists not part of standard markdown
- htmlOpenTag "dl"
- spaces
- items <- sepEndBy1 definitionListItem spaces
- htmlEndTag "dl"
- return $ DefinitionList items
-
-definitionListItem :: GenParser Char ParserState ([Inline], [[Block]])
-definitionListItem = try $ do
- terms <- sepEndBy1 (inlinesIn "dt") spaces
- defs <- sepEndBy1 (blocksIn "dd") spaces
- let term = intercalate [LineBreak] terms
- return (term, defs)
-
---
--- paragraph block
---
-
-para :: GenParser Char ParserState Block
-para = try $ htmlOpenTag "p" >> inlinesTilEnd "p" >>=
- return . Para . normalizeSpaces
-
---
--- plain block
---
-
-plain :: GenParser Char ParserState Block
-plain = many1 inline >>= return . Plain . normalizeSpaces
-
---
--- inline
---
-
-inline :: GenParser Char ParserState Inline
-inline = choice [ charRef
- , strong
- , emph
- , superscript
- , subscript
- , strikeout
- , spanStrikeout
- , code
- , str
- , linebreak
- , whitespace
- , link
- , image
- , rawHtmlInline
- , char '&' >> return (Str "&") -- common HTML error
- ] <?> "inline"
-
-code :: GenParser Char ParserState Inline
-code = try $ do
- result <- (htmlOpenTag "code" >> manyTill anyChar (htmlEndTag "code"))
- <|> (htmlOpenTag "tt" >> manyTill anyChar (htmlEndTag "tt"))
- -- remove internal line breaks, leading and trailing space,
- -- and decode character references
- return $ Code $ decodeCharacterReferences $ removeLeadingTrailingSpace $
- intercalate " " $ lines result
-
-rawHtmlInline :: GenParser Char ParserState Inline
-rawHtmlInline = do
- result <- anyHtmlInlineTag <|> htmlComment
- state <- getState
- if stateParseRaw state then return (HtmlInline result) else return (Str "")
-
-betweenTags :: [Char] -> GenParser Char ParserState [Inline]
-betweenTags tag = try $ htmlOpenTag tag >> inlinesTilEnd tag >>=
- return . normalizeSpaces
-
-emph :: GenParser Char ParserState Inline
-emph = (betweenTags "em" <|> betweenTags "i") >>= return . Emph
-
-strong :: GenParser Char ParserState Inline
-strong = (betweenTags "b" <|> betweenTags "strong") >>= return . Strong
-
-superscript :: GenParser Char ParserState Inline
-superscript = failIfStrict >> betweenTags "sup" >>= return . Superscript
-
-subscript :: GenParser Char ParserState Inline
-subscript = failIfStrict >> betweenTags "sub" >>= return . Subscript
-
-strikeout :: GenParser Char ParserState Inline
-strikeout = failIfStrict >> (betweenTags "s" <|> betweenTags "strike") >>=
- return . Strikeout
-
-spanStrikeout :: GenParser Char ParserState Inline
-spanStrikeout = try $ do
- failIfStrict -- strict markdown has no strikeout, so treat as raw HTML
- (_, attributes) <- htmlOpenTag "span"
- result <- case (extractAttribute "class" attributes) of
- Just "strikeout" -> inlinesTilEnd "span"
- _ -> fail "not a strikeout"
- return $ Strikeout result
-
-whitespace :: GenParser Char st Inline
-whitespace = many1 space >> return Space
-
--- hard line break
-linebreak :: GenParser Char ParserState Inline
-linebreak = htmlSelfClosingTag "br" >> optional newline >> return LineBreak
-
-str :: GenParser Char st Inline
-str = many1 (noneOf "< \t\n&") >>= return . Str
-
---
--- links and images
---
-
--- extract contents of attribute (attribute names are case-insensitive)
-extractAttribute :: [Char] -> [([Char], String)] -> Maybe String
-extractAttribute _ [] = Nothing
-extractAttribute name ((attrName, contents):rest) =
- let name' = map toLower name
- attrName' = map toLower attrName
- in if attrName' == name'
- then Just (decodeCharacterReferences contents)
- else extractAttribute name rest
-
-link :: GenParser Char ParserState Inline
-link = try $ do
- (_, attributes) <- htmlOpenTag "a"
- url <- case (extractAttribute "href" attributes) of
- Just url -> return url
- Nothing -> fail "no href"
- let title = fromMaybe "" $ extractAttribute "title" attributes
- lab <- inlinesTilEnd "a"
- return $ Link (normalizeSpaces lab) (escapeURI url, title)
-
-image :: GenParser Char ParserState Inline
-image = try $ do
- (_, attributes) <- htmlSelfClosingTag "img"
- url <- case (extractAttribute "src" attributes) of
- Just url -> return url
- Nothing -> fail "no src"
- let title = fromMaybe "" $ extractAttribute "title" attributes
- let alt = fromMaybe "" (extractAttribute "alt" attributes)
- return $ Image [Str alt] (escapeURI url, title)
-
+--- parsers for use in markdown, textile readers
+
+-- | Matches a stretch of HTML in balanced tags.
+htmlInBalanced :: (Tag String -> Bool) -> GenParser Char ParserState String
+htmlInBalanced f = try $ do
+ (TagOpen t _, tag) <- htmlTag f
+ guard $ '/' `notElem` tag -- not a self-closing tag
+ let nonTagChunk = many1 $ satisfy (/= '<')
+ let stopper = htmlTag (~== TagClose t)
+ let anytag = liftM snd $ htmlTag (const True)
+ contents <- many $ notFollowedBy' stopper >>
+ (nonTagChunk <|> htmlInBalanced (const True) <|> anytag)
+ endtag <- liftM snd stopper
+ return $ tag ++ concat contents ++ endtag
+
+-- | Matches a tag meeting a certain condition.
+htmlTag :: (Tag String -> Bool) -> GenParser Char ParserState (Tag String, String)
+htmlTag f = try $ do
+ lookAhead (char '<')
+ (next : _) <- getInput >>= return . canonicalizeTags . parseTags
+ guard $ f next
+ -- advance the parser
+ case next of
+ TagComment s -> do
+ count (length s + 4) anyChar
+ skipMany (satisfy (/='>'))
+ char '>'
+ return (next, "<!--" ++ s ++ "-->")
+ _ -> do
+ rendered <- manyTill anyChar (char '>')
+ return (next, rendered ++ ">")
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 406809dfc..dca745b56 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -38,9 +38,9 @@ import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Pandoc.Parsing
import Data.Maybe ( fromMaybe )
-import Data.Char ( chr )
-import Data.List ( isPrefixOf, isSuffixOf )
-import Control.Monad ( when )
+import Data.Char ( chr, toUpper )
+import Data.List ( intercalate, isPrefixOf, isSuffixOf )
+import Control.Monad
-- | Parse LaTeX from string and return 'Pandoc' document.
readLaTeX :: ParserState -- ^ Parser state, including options for parser
@@ -50,7 +50,7 @@ readLaTeX = readWith parseLaTeX
-- characters with special meaning
specialChars :: [Char]
-specialChars = "\\`$%^&_~#{}\n \t|<>'\"-"
+specialChars = "\\`$%^&_~#{}[]\n \t|<>'\"-"
--
-- utility functions
@@ -64,7 +64,7 @@ bracketedText openB closeB = do
-- | Returns an option or argument of a LaTeX command.
optOrArg :: GenParser Char st [Char]
-optOrArg = bracketedText '{' '}' <|> bracketedText '[' ']'
+optOrArg = try $ spaces >> (bracketedText '{' '}' <|> bracketedText '[' ']')
-- | True if the string begins with '{'.
isArg :: [Char] -> Bool
@@ -86,14 +86,22 @@ command = do
begin :: [Char] -> GenParser Char st [Char]
begin name = try $ do
- string $ "\\begin{" ++ name ++ "}"
+ string "\\begin"
+ spaces
+ char '{'
+ string name
+ char '}'
optional commandArgs
spaces
return name
end :: [Char] -> GenParser Char st [Char]
end name = try $ do
- string $ "\\end{" ++ name ++ "}"
+ string "\\end"
+ spaces
+ char '{'
+ string name
+ char '}'
return name
-- | Returns a list of block elements containing the contents of an
@@ -103,7 +111,9 @@ environment name = try $ begin name >> spaces >> manyTill block (end name) >>~ s
anyEnvironment :: GenParser Char ParserState Block
anyEnvironment = try $ do
- string "\\begin{"
+ string "\\begin"
+ spaces
+ char '{'
name <- many letter
star <- option "" (string "*") -- some environments have starred variants
char '}'
@@ -119,22 +129,17 @@ anyEnvironment = try $ do
-- | Process LaTeX preamble, extracting metadata.
processLaTeXPreamble :: GenParser Char ParserState ()
-processLaTeXPreamble = try $ manyTill
- (choice [bibliographic, comment, unknownCommand, nullBlock])
- (try (string "\\begin{document}")) >>
- spaces
+processLaTeXPreamble = do
+ try $ string "\\documentclass"
+ skipMany $ bibliographic <|> macro <|> commentBlock <|> skipChar
-- | Parse LaTeX and return 'Pandoc'.
parseLaTeX :: GenParser Char ParserState Pandoc
parseLaTeX = do
- optional processLaTeXPreamble -- preamble might not be present (fragment)
- spaces
- blocks <- parseBlocks
spaces
- optional $ try (string "\\end{document}" >> many anyChar)
- -- might not be present (fragment)
- spaces
- eof
+ skipMany $ comment >> spaces
+ blocks <- try (processLaTeXPreamble >> environment "document")
+ <|> (many block >>~ (spaces >> eof))
state <- getState
let blocks' = filter (/= Null) blocks
let title' = stateTitle state
@@ -155,13 +160,16 @@ block = choice [ hrule
, header
, list
, blockQuote
- , comment
+ , simpleTable
+ , commentBlock
+ , macro
, bibliographic
, para
, itemBlock
, unknownEnvironment
, ignore
- , unknownCommand ] <?> "block"
+ , unknownCommand
+ ] <?> "block"
--
-- header blocks
@@ -208,20 +216,77 @@ hrule :: GenParser Char st Block
hrule = oneOfStrings [ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n\n",
"\\newpage" ] >> spaces >> return HorizontalRule
+-- tables
+
+simpleTable :: GenParser Char ParserState Block
+simpleTable = try $ do
+ string "\\begin"
+ spaces
+ string "{tabular}"
+ spaces
+ aligns <- parseAligns
+ let cols = length aligns
+ optional hline
+ header' <- option [] $ parseTableHeader cols
+ rows <- many (parseTableRow cols >>~ optional hline)
+ spaces
+ end "tabular"
+ spaces
+ let header'' = if null header'
+ then replicate cols []
+ else header'
+ return $ Table [] aligns (replicate cols 0) header'' rows
+
+hline :: GenParser Char st ()
+hline = try $ spaces >> string "\\hline" >> return ()
+
+parseAligns :: GenParser Char ParserState [Alignment]
+parseAligns = try $ do
+ char '{'
+ optional $ char '|'
+ let cAlign = char 'c' >> return AlignCenter
+ let lAlign = char 'l' >> return AlignLeft
+ let rAlign = char 'r' >> return AlignRight
+ let alignChar = cAlign <|> lAlign <|> rAlign
+ aligns' <- sepEndBy alignChar (optional $ char '|')
+ char '}'
+ spaces
+ return aligns'
+
+parseTableHeader :: Int -- ^ number of columns
+ -> GenParser Char ParserState [TableCell]
+parseTableHeader cols = try $ do
+ cells' <- parseTableRow cols
+ hline
+ return cells'
+
+parseTableRow :: Int -- ^ number of columns
+ -> GenParser Char ParserState [TableCell]
+parseTableRow cols = try $ do
+ let tableCellInline = notFollowedBy (char '&' <|>
+ (try $ char '\\' >> char '\\')) >> inline
+ cells' <- sepBy (spaces >> liftM ((:[]) . Plain . normalizeSpaces)
+ (many tableCellInline)) (char '&')
+ guard $ length cells' == cols
+ spaces
+ (try $ string "\\\\" >> spaces) <|>
+ (lookAhead (end "tabular") >> return ())
+ return cells'
+
--
-- code blocks
--
codeBlock :: GenParser Char ParserState Block
-codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> lhsCodeBlock
+codeBlock = codeBlockWith "verbatim" <|> codeBlockWith "Verbatim" <|> codeBlockWith "lstlisting" <|> lhsCodeBlock
-- Note: Verbatim is from fancyvrb.
codeBlockWith :: String -> GenParser Char st Block
codeBlockWith env = try $ do
- string ("\\begin{" ++ env ++ "}") -- don't use begin function because it
- -- gobbles whitespace
- optional blanklines -- we want to gobble blank lines, but not
- -- leading space
+ string "\\begin"
+ spaces -- don't use begin function because it
+ string $ "{" ++ env ++ "}" -- gobbles whitespace; we want to gobble
+ optional blanklines -- blank lines, but not leading space
contents <- manyTill anyChar (try (string $ "\\end{" ++ env ++ "}"))
spaces
let classes = if env == "code" then ["haskell"] else []
@@ -265,7 +330,10 @@ listItem = try $ do
orderedList :: GenParser Char ParserState Block
orderedList = try $ do
- string "\\begin{enumerate}"
+ string "\\begin"
+ spaces
+ string "{enumerate}"
+ spaces
(_, style, delim) <- option (1, DefaultStyle, DefaultDelim) $
try $ do failIfStrict
char '['
@@ -293,7 +361,6 @@ orderedList = try $ do
bulletList :: GenParser Char ParserState Block
bulletList = try $ do
begin "itemize"
- spaces
items <- many listItem
end "itemize"
spaces
@@ -302,7 +369,6 @@ bulletList = try $ do
definitionList :: GenParser Char ParserState Block
definitionList = try $ do
begin "description"
- spaces
items <- many listItem
end "description"
spaces
@@ -342,7 +408,7 @@ authors :: GenParser Char ParserState Block
authors = try $ do
string "\\author{"
raw <- many1 (notFollowedBy (char '}') >> inline)
- let authors' = map normalizeSpaces $ splitBy LineBreak raw
+ let authors' = map normalizeSpaces $ splitBy (== LineBreak) raw
char '}'
spaces
updateState (\s -> s { stateAuthors = authors' })
@@ -382,13 +448,15 @@ rawLaTeXEnvironment :: GenParser Char st Block
rawLaTeXEnvironment = do
contents <- rawLaTeXEnvironment'
spaces
- return $ Para [TeX contents]
+ return $ RawBlock "latex" contents
-- | Parse any LaTeX environment and return a string containing
-- the whole literal environment as raw TeX.
rawLaTeXEnvironment' :: GenParser Char st String
rawLaTeXEnvironment' = try $ do
- string "\\begin{"
+ string "\\begin"
+ spaces
+ char '{'
name <- many1 letter
star <- option "" (string "*") -- for starred variants
let name' = name ++ star
@@ -418,31 +486,49 @@ ignore = try $ do
spaces
return Null
+demacro :: (String, String, [String]) -> GenParser Char ParserState Inline
+demacro (n,st,args) = try $ do
+ let raw = "\\" ++ n ++ st ++ concat args
+ s' <- applyMacros' raw
+ if raw == s'
+ then return $ RawInline "latex" raw
+ else do
+ inp <- getInput
+ setInput $ s' ++ inp
+ return $ Str ""
+
unknownCommand :: GenParser Char ParserState Block
unknownCommand = try $ do
- notFollowedBy' $ choice $ map end ["itemize", "enumerate", "description",
- "document"]
+ spaces
+ notFollowedBy' $ oneOfStrings ["\\begin","\\end","\\item"]
state <- getState
when (stateParserContext state == ListItemState) $
notFollowedBy' (string "\\item")
if stateParseRaw state
- then do
- (name, star, args) <- command
- spaces
- return $ Plain [TeX ("\\" ++ name ++ star ++ concat args)]
+ then command >>= demacro >>= return . Plain . (:[])
else do
(name, _, args) <- command
spaces
- if name `elem` commandsToIgnore
- then return Null
- else return $ Plain [Str $ concat args]
+ unless (name `elem` commandsToIgnore) $ do
+ -- put arguments back in input to be parsed
+ inp <- getInput
+ setInput $ intercalate " " args ++ inp
+ return Null
commandsToIgnore :: [String]
-commandsToIgnore = ["special","pdfannot","pdfstringdef"]
+commandsToIgnore = ["special","pdfannot","pdfstringdef", "index","bibliography"]
+
+skipChar :: GenParser Char ParserState Block
+skipChar = do
+ satisfy (/='\\') <|>
+ (notFollowedBy' (try $
+ string "\\begin" >> spaces >> string "{document}") >>
+ anyChar)
+ spaces
+ return Null
--- latex comment
-comment :: GenParser Char st Block
-comment = try $ char '%' >> manyTill anyChar newline >> spaces >> return Null
+commentBlock :: GenParser Char st Block
+commentBlock = many1 (comment >> spaces) >> return Null
--
-- inline
@@ -464,8 +550,6 @@ inline = choice [ str
, strikeout
, superscript
, subscript
- , ref
- , lab
, code
, url
, link
@@ -474,12 +558,20 @@ inline = choice [ str
, linebreak
, accentedChar
, nonbreakingSpace
+ , cite
, specialChar
+ , ensureMath
, rawLaTeXInline'
, escapedChar
, unescapedChar
+ , comment
] <?> "inline"
+
+-- latex comment
+comment :: GenParser Char st Inline
+comment = try $ char '%' >> manyTill anyChar newline >> spaces >> return (Str "")
+
accentedChar :: GenParser Char st Inline
accentedChar = normalAccentedChar <|> specialAccentedChar
@@ -512,7 +604,7 @@ accentTable =
('u', [('`', 249), ('\'', 250), ('^', 251), ('"', 252)]) ]
specialAccentedChar :: GenParser Char st Inline
-specialAccentedChar = choice [ ccedil, aring, iuml, szlig, aelig,
+specialAccentedChar = choice [ ccedil, aring, iuml, szlig, aelig, lslash,
oslash, pound, euro, copyright, sect ]
ccedil :: GenParser Char st Inline
@@ -543,6 +635,13 @@ oslash = try $ do
let num = if letter' == 'o' then 248 else 216
return $ Str [chr num]
+lslash :: GenParser Char st Inline
+lslash = try $ do
+ cmd <- oneOfStrings ["{\\L}","{\\l}","\\L ","\\l "]
+ return $ if 'l' `elem` cmd
+ then Str "\x142"
+ else Str "\x141"
+
aelig :: GenParser Char st Inline
aelig = try $ do
char '\\'
@@ -569,7 +668,7 @@ escapedChar = do
-- nonescaped special characters
unescapedChar :: GenParser Char st Inline
-unescapedChar = oneOf "`$^&_#{}|<>" >>= return . (\c -> Str [c])
+unescapedChar = oneOf "`$^&_#{}[]|<>" >>= return . (\c -> Str [c])
specialChar :: GenParser Char st Inline
specialChar = choice [ spacer, interwordSpace,
@@ -604,27 +703,34 @@ doubleQuote :: GenParser Char st Inline
doubleQuote = char '"' >> return (Str "\"")
code :: GenParser Char ParserState Inline
-code = code1 <|> code2 <|> lhsInlineCode
+code = code1 <|> code2 <|> code3 <|> lhsInlineCode
code1 :: GenParser Char st Inline
code1 = try $ do
string "\\verb"
marker <- anyChar
result <- manyTill anyChar (char marker)
- return $ Code $ removeLeadingTrailingSpace result
+ return $ Code nullAttr $ removeLeadingTrailingSpace result
code2 :: GenParser Char st Inline
code2 = try $ do
string "\\texttt{"
result <- manyTill (noneOf "\\\n~$%^&{}") (char '}')
- return $ Code result
+ return $ Code nullAttr result
+
+code3 :: GenParser Char st Inline
+code3 = try $ do
+ string "\\lstinline"
+ marker <- anyChar
+ result <- manyTill anyChar (char marker)
+ return $ Code nullAttr $ removeLeadingTrailingSpace result
lhsInlineCode :: GenParser Char ParserState Inline
lhsInlineCode = try $ do
failUnlessLHS
char '|'
result <- manyTill (noneOf "|\n") (char '|')
- return $ Code result
+ return $ Code ("",["haskell"],[]) result
emph :: GenParser Char ParserState Inline
emph = try $ oneOfStrings [ "\\emph{", "\\textit{" ] >>
@@ -683,15 +789,6 @@ emDash = try (string "---") >> return EmDash
hyphen :: GenParser Char st Inline
hyphen = char '-' >> return (Str "-")
-lab :: GenParser Char st Inline
-lab = try $ do
- string "\\label{"
- result <- manyTill anyChar (char '}')
- return $ Str $ "(" ++ result ++ ")"
-
-ref :: GenParser Char st Inline
-ref = try (string "\\ref{") >> manyTill anyChar (char '}') >>= return . Str
-
strong :: GenParser Char ParserState Inline
strong = try (string "\\textbf{") >> manyTill inline (char '}') >>=
return . Strong
@@ -714,13 +811,13 @@ endline :: GenParser Char st Inline
endline = try $ newline >> notFollowedBy blankline >> return Space
-- math
-math :: GenParser Char st Inline
-math = (math3 >>= return . Math DisplayMath)
- <|> (math1 >>= return . Math InlineMath)
- <|> (math2 >>= return . Math InlineMath)
- <|> (math4 >>= return . Math DisplayMath)
- <|> (math5 >>= return . Math DisplayMath)
- <|> (math6 >>= return . Math DisplayMath)
+math :: GenParser Char ParserState Inline
+math = (math3 >>= applyMacros' >>= return . Math DisplayMath)
+ <|> (math1 >>= applyMacros' >>= return . Math InlineMath)
+ <|> (math2 >>= applyMacros' >>= return . Math InlineMath)
+ <|> (math4 >>= applyMacros' >>= return . Math DisplayMath)
+ <|> (math5 >>= applyMacros' >>= return . Math DisplayMath)
+ <|> (math6 >>= applyMacros' >>= return . Math DisplayMath)
<?> "math"
math1 :: GenParser Char st String
@@ -737,7 +834,6 @@ math4 = try $ do
name <- begin "displaymath" <|> begin "equation" <|> begin "equation*" <|>
begin "gather" <|> begin "gather*" <|> begin "gathered" <|>
begin "multline" <|> begin "multline*"
- spaces
manyTill anyChar (end name)
math5 :: GenParser Char st String
@@ -748,10 +844,15 @@ math6 = try $ do
name <- begin "eqnarray" <|> begin "eqnarray*" <|> begin "align" <|>
begin "align*" <|> begin "alignat" <|> begin "alignat*" <|>
begin "split" <|> begin "aligned" <|> begin "alignedat"
- spaces
res <- manyTill anyChar (end name)
return $ filter (/= '&') res -- remove alignment codes
+ensureMath :: GenParser Char st Inline
+ensureMath = try $ do
+ (n, _, args) <- command
+ guard $ n == "ensuremath" && not (null args)
+ return $ Math InlineMath $ tail $ init $ head args
+
--
-- links and images
--
@@ -760,7 +861,7 @@ url :: GenParser Char ParserState Inline
url = try $ do
string "\\url"
url' <- charsInBalanced '{' '}'
- return $ Link [Code url'] (escapeURI url', "")
+ return $ Link [Code ("",["url"],[]) url'] (escapeURI url', "")
link :: GenParser Char ParserState Inline
link = try $ do
@@ -793,6 +894,103 @@ footnote = try $ do
setInput rest
return $ Note blocks
+-- | citations
+cite :: GenParser Char ParserState Inline
+cite = simpleCite <|> complexNatbibCites
+
+simpleCiteArgs :: GenParser Char ParserState [Citation]
+simpleCiteArgs = try $ do
+ first <- optionMaybe $ (char '[') >> manyTill inline (char ']')
+ second <- optionMaybe $ (char '[') >> manyTill inline (char ']')
+ char '{'
+ keys <- many1Till citationLabel (char '}')
+ let (pre, suf) = case (first , second ) of
+ (Just s , Nothing) -> ([], s )
+ (Just s , Just t ) -> (s , t )
+ _ -> ([], [])
+ conv k = Citation { citationId = k
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = NormalCitation
+ , citationHash = 0
+ , citationNoteNum = 0
+ }
+ return $ addPrefix pre $ addSuffix suf $ map conv keys
+
+
+simpleCite :: GenParser Char ParserState Inline
+simpleCite = try $ do
+ char '\\'
+ let biblatex = [a ++ "cite" | a <- ["auto", "foot", "paren", "super", ""]]
+ ++ ["footcitetext"]
+ normal = ["cite" ++ a ++ b | a <- ["al", ""], b <- ["p", "p*", ""]]
+ ++ biblatex
+ supress = ["citeyearpar", "citeyear", "autocite*", "cite*", "parencite*"]
+ intext = ["textcite"] ++ ["cite" ++ a ++ b | a <- ["al", ""], b <- ["t", "t*"]]
+ mintext = ["textcites"]
+ mnormal = map (++ "s") biblatex
+ cmdend = notFollowedBy (letter <|> char '*')
+ capit [] = []
+ capit (x:xs) = toUpper x : xs
+ addUpper xs = xs ++ map capit xs
+ toparser l t = try $ oneOfStrings (addUpper l) >> cmdend >> return t
+ (mode, multi) <- toparser normal (NormalCitation, False)
+ <|> toparser supress (SuppressAuthor, False)
+ <|> toparser intext (AuthorInText , False)
+ <|> toparser mnormal (NormalCitation, True )
+ <|> toparser mintext (AuthorInText , True )
+ cits <- if multi then
+ many1 simpleCiteArgs
+ else
+ simpleCiteArgs >>= \c -> return [c]
+ let (c:cs) = concat cits
+ cits' = case mode of
+ AuthorInText -> c {citationMode = mode} : cs
+ _ -> map (\a -> a {citationMode = mode}) (c:cs)
+ return $ Cite cits' []
+
+complexNatbibCites :: GenParser Char ParserState Inline
+complexNatbibCites = complexNatbibTextual <|> complexNatbibParenthetical
+
+complexNatbibTextual :: GenParser Char ParserState Inline
+complexNatbibTextual = try $ do
+ string "\\citeauthor{"
+ manyTill (noneOf "}") (char '}')
+ skipSpaces
+ Cite (c:cs) _ <- complexNatbibParenthetical
+ return $ Cite (c {citationMode = AuthorInText} : cs) []
+
+
+complexNatbibParenthetical :: GenParser Char ParserState Inline
+complexNatbibParenthetical = try $ do
+ string "\\citetext{"
+ cits <- many1Till parseOne (char '}')
+ return $ Cite (concat cits) []
+ where
+ parseOne = do
+ skipSpaces
+ pref <- many (notFollowedBy (oneOf "\\}") >> inline)
+ (Cite cites _) <- simpleCite
+ suff <- many (notFollowedBy (oneOf "\\};") >> inline)
+ skipSpaces
+ optional $ char ';'
+ return $ addPrefix pref $ addSuffix suff $ cites
+
+addPrefix :: [Inline] -> [Citation] -> [Citation]
+addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks
+addPrefix _ _ = []
+
+addSuffix :: [Inline] -> [Citation] -> [Citation]
+addSuffix s ks@(_:_) = let k = last ks
+ in init ks ++ [k {citationSuffix = citationSuffix k ++ s}]
+addSuffix _ _ = []
+
+citationLabel :: GenParser Char ParserState String
+citationLabel = do
+ res <- many1 $ noneOf ",}"
+ optional $ char ','
+ return $ removeLeadingTrailingSpace res
+
-- | Parse any LaTeX inline command and return it in a raw TeX inline element.
rawLaTeXInline' :: GenParser Char ParserState Inline
rawLaTeXInline' = do
@@ -805,12 +1003,11 @@ rawLaTeXInline :: GenParser Char ParserState Inline
rawLaTeXInline = try $ do
state <- getState
if stateParseRaw state
- then do
- (name, star, args) <- command
- return $ TeX ("\\" ++ name ++ star ++ concat args)
+ then command >>= demacro
else do
- (name, _, args) <- command
- spaces
- if name `elem` commandsToIgnore
- then return $ Str ""
- else return $ Str (concat args)
+ (name,st,args) <- command
+ x <- demacro (name,st,args)
+ unless (x == Str "" || name `elem` commandsToIgnore) $ do
+ inp <- getInput
+ setInput $ intercalate " " args ++ inp
+ return $ Str ""
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 33fb3d8e6..58d2158bf 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -27,26 +27,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of markdown-formatted plain text to 'Pandoc' document.
-}
-module Text.Pandoc.Readers.Markdown (
- readMarkdown
- ) where
+module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
-import Data.List ( transpose, isSuffixOf, sortBy, findIndex, intercalate )
+import Data.List ( transpose, sortBy, findIndex, intercalate )
import qualified Data.Map as M
import Data.Ord ( comparing )
import Data.Char ( isAlphaNum )
import Data.Maybe
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import Text.Pandoc.Shared
import Text.Pandoc.Parsing
import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXEnvironment' )
-import Text.Pandoc.Readers.HTML ( rawHtmlBlock, anyHtmlBlockTag,
- anyHtmlInlineTag, anyHtmlTag,
- anyHtmlEndTag, htmlEndTag, extractTagType,
- htmlBlockElement, htmlComment, unsanitaryURI )
+import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag,
+ isTextTag, isCommentTag )
import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
import Text.ParserCombinators.Parsec
-import Control.Monad (when, liftM, unless)
+import Control.Monad (when, liftM, guard)
+import Text.HTML.TagSoup
+import Text.HTML.TagSoup.Match (tagOpen)
-- | Read markdown from an input string and return a Pandoc document.
readMarkdown :: ParserState -- ^ Parser state, including options for parser
@@ -58,18 +57,26 @@ readMarkdown state s = (readWith parseMarkdown) state (s ++ "\n\n")
-- Constants and data structure definitions
--
-bulletListMarkers :: [Char]
-bulletListMarkers = "*+-"
+isBulletListMarker :: Char -> Bool
+isBulletListMarker '*' = True
+isBulletListMarker '+' = True
+isBulletListMarker '-' = True
+isBulletListMarker _ = False
-hruleChars :: [Char]
-hruleChars = "*-_"
+isHruleChar :: Char -> Bool
+isHruleChar '*' = True
+isHruleChar '-' = True
+isHruleChar '_' = True
+isHruleChar _ = False
setextHChars :: [Char]
setextHChars = "=-"
--- treat these as potentially non-text when parsing inline:
-specialChars :: [Char]
-specialChars = "\\[]*_~`<>$!^-.&@'\";"
+isBlank :: Char -> Bool
+isBlank ' ' = True
+isBlank '\t' = True
+isBlank '\n' = True
+isBlank _ = False
--
-- auxiliary functions
@@ -106,12 +113,6 @@ failUnlessBeginningOfLine = do
pos <- getPosition
if sourceColumn pos == 1 then return () else fail "not beginning of line"
--- | Fail unless we're in "smart typography" mode.
-failUnlessSmart :: GenParser tok ParserState ()
-failUnlessSmart = do
- state <- getState
- if stateSmart state then return () else pzero
-
-- | Parse a sequence of inline elements between square brackets,
-- including inlines between balanced pairs of square brackets.
inlinesInBalancedBrackets :: GenParser Char ParserState Inline
@@ -119,7 +120,7 @@ inlinesInBalancedBrackets :: GenParser Char ParserState Inline
inlinesInBalancedBrackets parser = try $ do
char '['
result <- manyTill ( (do lookAhead $ try $ do (Str res) <- parser
- unless (res == "[") pzero
+ guard (res == "[")
bal <- inlinesInBalancedBrackets parser
return $ [Str "["] ++ bal ++ [Str "]"])
<|> (count 1 parser))
@@ -143,7 +144,8 @@ authorsLine :: GenParser Char ParserState [[Inline]]
authorsLine = try $ do
char '%'
skipSpaces
- authors <- sepEndBy (many (notFollowedBy (oneOf ";\n") >> inline))
+ authors <- sepEndBy (many (notFollowedBy (satisfy $ \c ->
+ c == ';' || c == '\n') >> inline))
(char ';' <|>
try (newline >> notFollowedBy blankline >> spaceChar))
newline
@@ -196,7 +198,7 @@ parseMarkdown = do
handleExampleRef z = z
if M.null examples
then return doc
- else return $ processWith handleExampleRef doc
+ else return $ bottomUp handleExampleRef doc
--
-- initial pass for references and notes
@@ -209,16 +211,24 @@ referenceKey = try $ do
lab <- reference
char ':'
skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')
- let sourceURL excludes = many $
- optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' referenceTitle >> char ' '))
- src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n"
+ let nl = char '\n' >> notFollowedBy blankline >> return ' '
+ let sourceURL = liftM unwords $ many $ try $ do
+ notFollowedBy' referenceTitle
+ skipMany spaceChar
+ optional nl
+ skipMany spaceChar
+ notFollowedBy' reference
+ many1 (satisfy $ not . isBlank)
+ let betweenAngles = try $ char '<' >>
+ manyTill (noneOf ">\n" <|> nl) (char '>')
+ src <- try betweenAngles <|> sourceURL
tit <- option "" referenceTitle
blanklines
endPos <- getPosition
let target = (escapeURI $ removeTrailingSpace src, tit)
st <- getState
let oldkeys = stateKeys st
- updateState $ \s -> s { stateKeys = M.insert (Key lab) target oldkeys }
+ updateState $ \s -> s { stateKeys = M.insert (toKey lab) target oldkeys }
-- return blanks so line count isn't affected
return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
@@ -232,12 +242,12 @@ referenceTitle = try $ do
return $ decodeCharacterReferences tit
noteMarker :: GenParser Char ParserState [Char]
-noteMarker = skipNonindentSpaces >> string "[^" >> manyTill (noneOf " \t\n") (char ']')
+noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
rawLine :: GenParser Char ParserState [Char]
rawLine = do
notFollowedBy blankline
- notFollowedBy' noteMarker
+ notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
contents <- many1 nonEndline
end <- option "" (newline >> optional indentSpaces >> return "\n")
return $ contents ++ end
@@ -248,6 +258,7 @@ rawLines = many1 rawLine >>= return . concat
noteBlock :: GenParser Char ParserState [Char]
noteBlock = try $ do
startPos <- getPosition
+ skipNonindentSpaces
ref <- noteMarker
char ':'
optional blankline
@@ -284,6 +295,7 @@ block = do
, plain
, nullBlock ]
else [ codeBlockDelimited
+ , macro
, header
, table
, codeBlockIndented
@@ -293,6 +305,7 @@ block = do
, bulletList
, orderedList
, definitionList
+ , rawTeXBlock
, para
, rawHtmlBlocks
, plain
@@ -318,6 +331,9 @@ atxClosing = try $ skipMany (char '#') >> blanklines
setextHeader :: GenParser Char ParserState Block
setextHeader = try $ do
+ -- This lookahead prevents us from wasting time parsing Inlines
+ -- unless necessary -- it gives a significant performance boost.
+ lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline
text <- many1Till inline newline
underlineChar <- oneOf setextHChars
many (char underlineChar)
@@ -332,7 +348,7 @@ setextHeader = try $ do
hrule :: GenParser Char st Block
hrule = try $ do
skipSpaces
- start <- oneOf hruleChars
+ start <- satisfy isHruleChar
count 2 (skipSpaces >> char start)
skipMany (spaceChar <|> char start)
newline
@@ -371,6 +387,7 @@ attributes = try $ do
attribute :: GenParser Char st ([Char], [[Char]], [([Char], [Char])])
attribute = identifierAttr <|> classAttr <|> keyValAttr
+
identifier :: GenParser Char st [Char]
identifier = do
first <- letter
@@ -394,7 +411,7 @@ keyValAttr = try $ do
key <- identifier
char '='
char '"'
- val <- manyTill (noneOf "\n") (char '"')
+ val <- manyTill (satisfy (/='\n')) (char '"')
return ("",[],[(key,val)])
codeBlockDelimited :: GenParser Char st Block
@@ -489,7 +506,7 @@ bulletListStart = try $ do
optional newline -- if preceded by a Plain block in a list context
skipNonindentSpaces
notFollowedBy' hrule -- because hrules start out just like lists
- oneOf bulletListMarkers
+ satisfy isBulletListMarker
spaceChar
skipSpaces
@@ -524,7 +541,7 @@ listLine = try $ do
notFollowedBy' (do indentSpaces
many (spaceChar)
listStart)
- chunks <- manyTill (htmlComment <|> count 1 anyChar) newline
+ chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline
return $ concat chunks ++ "\n"
-- parse raw text for one list item, excluding start marker and continuations
@@ -644,23 +661,21 @@ definitionList = do
--
isHtmlOrBlank :: Inline -> Bool
-isHtmlOrBlank (HtmlInline _) = True
-isHtmlOrBlank (Space) = True
-isHtmlOrBlank (LineBreak) = True
-isHtmlOrBlank _ = False
+isHtmlOrBlank (RawInline "html" _) = True
+isHtmlOrBlank (Space) = True
+isHtmlOrBlank (LineBreak) = True
+isHtmlOrBlank _ = False
para :: GenParser Char ParserState Block
para = try $ do
- result <- many1 inline
- if all isHtmlOrBlank result
- then fail "treat as raw HTML"
- else return ()
- newline
- blanklines <|> do st <- getState
- if stateStrict st
- then lookAhead (blockQuote <|> header) >> return ""
- else pzero
- return $ Para $ normalizeSpaces result
+ result <- liftM normalizeSpaces $ many1 inline
+ guard $ not . all isHtmlOrBlank $ result
+ option (Plain result) $ try $ do
+ newline
+ blanklines <|>
+ (getState >>= guard . stateStrict >>
+ lookAhead (blockQuote <|> header) >> return "")
+ return $ Para result
plain :: GenParser Char ParserState Block
plain = many1 inline >>~ spaces >>= return . Plain . normalizeSpaces
@@ -670,7 +685,7 @@ plain = many1 inline >>~ spaces >>= return . Plain . normalizeSpaces
--
htmlElement :: GenParser Char ParserState [Char]
-htmlElement = strictHtmlBlock <|> htmlBlockElement <?> "html element"
+htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag)
htmlBlock :: GenParser Char ParserState Block
htmlBlock = try $ do
@@ -678,27 +693,33 @@ htmlBlock = try $ do
first <- htmlElement
finalSpace <- many spaceChar
finalNewlines <- many newline
- return $ RawHtml $ first ++ finalSpace ++ finalNewlines
-
--- True if tag is self-closing
-isSelfClosing :: [Char] -> Bool
-isSelfClosing tag =
- isSuffixOf "/>" $ filter (not . (`elem` " \n\t")) tag
+ return $ RawBlock "html" $ first ++ finalSpace ++ finalNewlines
strictHtmlBlock :: GenParser Char ParserState [Char]
-strictHtmlBlock = try $ do
- tag <- anyHtmlBlockTag
- let tag' = extractTagType tag
- if isSelfClosing tag || tag' == "hr"
- then return tag
- else do contents <- many (notFollowedBy' (htmlEndTag tag') >>
- (htmlElement <|> (count 1 anyChar)))
- end <- htmlEndTag tag'
- return $ tag ++ concat contents ++ end
+strictHtmlBlock = do
+ failUnlessBeginningOfLine
+ htmlInBalanced (not . isInlineTag)
+
+rawVerbatimBlock :: GenParser Char ParserState String
+rawVerbatimBlock = try $ do
+ (TagOpen tag _, open) <- htmlTag (tagOpen (\t ->
+ t == "pre" || t == "style" || t == "script")
+ (const True))
+ contents <- manyTill anyChar (htmlTag (~== TagClose tag))
+ return $ open ++ contents ++ renderTags [TagClose tag]
+
+rawTeXBlock :: GenParser Char ParserState Block
+rawTeXBlock = do
+ failIfStrict
+ result <- liftM (RawBlock "latex") rawLaTeXEnvironment'
+ <|> liftM (RawBlock "context") rawConTeXtEnvironment'
+ spaces
+ return result
rawHtmlBlocks :: GenParser Char ParserState Block
rawHtmlBlocks = do
- htmlBlocks <- many1 $ do (RawHtml blk) <- rawHtmlBlock
+ htmlBlocks <- many1 $ do blk <- rawVerbatimBlock <|>
+ liftM snd (htmlTag isBlockTag)
sps <- do sp1 <- many spaceChar
sp2 <- option "" (blankline >> return "\n")
sp3 <- many spaceChar
@@ -710,7 +731,7 @@ rawHtmlBlocks = do
return $ blk ++ sps
let combined = concat htmlBlocks
let combined' = if last combined == '\n' then init combined else combined
- return $ RawHtml combined'
+ return $ RawBlock "html" combined'
--
-- Tables
@@ -848,10 +869,11 @@ alignType :: [String]
-> Alignment
alignType [] _ = AlignDefault
alignType strLst len =
- let s = head $ sortBy (comparing length) $
- map removeTrailingSpace strLst
- leftSpace = if null s then False else (s !! 0) `elem` " \t"
- rightSpace = length s < len || (s !! (len - 1)) `elem` " \t"
+ let nonempties = filter (not . null) $ map removeTrailingSpace strLst
+ (leftSpace, rightSpace) =
+ case sortBy (comparing length) nonempties of
+ (x:_) -> (head x `elem` " \t", length x < len)
+ [] -> (False, False)
in case (leftSpace, rightSpace) of
(True, False) -> AlignRight
(False, True) -> AlignLeft
@@ -875,31 +897,29 @@ inline :: GenParser Char ParserState Inline
inline = choice inlineParsers <?> "inline"
inlineParsers :: [GenParser Char ParserState Inline]
-inlineParsers = [ str
- , smartPunctuation
- , whitespace
+inlineParsers = [ whitespace
+ , str
, endline
, code
- , charRef
, (fourOrMore '*' <|> fourOrMore '_')
, strong
, emph
, note
- , inlineNote
, link
-#ifdef _CITEPROC
- , inlineCitation
-#endif
+ , cite
, image
, math
, strikeout
, superscript
, subscript
+ , inlineNote -- after superscript because of ^[link](/foo)^
, autoLink
- , rawHtmlInline'
+ , rawHtmlInline
, rawLaTeXInline'
, escapedChar
, exampleRef
+ , smartPunctuation inline
+ , charRef
, symbol
, ltSign ]
@@ -913,12 +933,12 @@ failIfLink (Link _ _) = pzero
failIfLink elt = return elt
escapedChar :: GenParser Char ParserState Inline
-escapedChar = do
+escapedChar = try $ do
char '\\'
state <- getState
- result <- option '\\' $ if stateStrict state
- then oneOf "\\`*_{}[]()>#+-.!~"
- else satisfy (not . isAlphaNum)
+ result <- if stateStrict state
+ then oneOf "\\`*_{}[]()>#+-.!~"
+ else satisfy (not . isAlphaNum)
return $ case result of
' ' -> Str "\160" -- "\ " is a nonbreaking space
'\n' -> LineBreak -- "\[newline]" is a linebreak
@@ -932,9 +952,6 @@ ltSign = do
else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html
return $ Str ['<']
-specialCharsMinusLt :: [Char]
-specialCharsMinusLt = filter (/= '<') specialChars
-
exampleRef :: GenParser Char ParserState Inline
exampleRef = try $ do
char '@'
@@ -945,7 +962,11 @@ exampleRef = try $ do
symbol :: GenParser Char ParserState Inline
symbol = do
- result <- oneOf specialCharsMinusLt
+ result <- noneOf "<\\\n\t "
+ <|> try (do lookAhead $ char '\\'
+ notFollowedBy' $ rawLaTeXEnvironment'
+ <|> rawConTeXtEnvironment'
+ char '\\')
return $ Str [result]
-- parses inline code, between n `s and n `s
@@ -957,7 +978,8 @@ code = try $ do
(char '\n' >> notFollowedBy' blankline >> return " "))
(try (skipSpaces >> count (length starts) (char '`') >>
notFollowedBy (char '`')))
- return $ Code $ removeLeadingTrailingSpace $ concat result
+ attr <- option ([],[],[]) (try $ optional whitespace >> attributes)
+ return $ Code attr $ removeLeadingTrailingSpace $ concat result
mathWord :: GenParser Char st [Char]
mathWord = liftM concat $ many1 mathChunk
@@ -966,11 +988,11 @@ mathChunk :: GenParser Char st [Char]
mathChunk = do char '\\'
c <- anyChar
return ['\\',c]
- <|> many1 (noneOf " \t\n\\$")
+ <|> many1 (satisfy $ \c -> not (isBlank c || c == '\\' || c == '$'))
math :: GenParser Char ParserState Inline
-math = (mathDisplay >>= return . Math DisplayMath)
- <|> (mathInline >>= return . Math InlineMath)
+math = (mathDisplay >>= applyMacros' >>= return . Math DisplayMath)
+ <|> (mathInline >>= applyMacros' >>= return . Math InlineMath)
mathDisplay :: GenParser Char ParserState String
mathDisplay = try $ do
@@ -1019,85 +1041,6 @@ subscript = failIfStrict >> enclosed (char '~') (char '~')
(notFollowedBy spaceChar >> inline) >>= -- may not contain Space
return . Subscript
-smartPunctuation :: GenParser Char ParserState Inline
-smartPunctuation = failUnlessSmart >>
- choice [ quoted, apostrophe, dash, ellipses ]
-
-apostrophe :: GenParser Char ParserState Inline
-apostrophe = (char '\'' <|> char '\8217') >> return Apostrophe
-
-quoted :: GenParser Char ParserState Inline
-quoted = doubleQuoted <|> singleQuoted
-
-withQuoteContext :: QuoteContext
- -> (GenParser Char ParserState Inline)
- -> GenParser Char ParserState Inline
-withQuoteContext context parser = do
- oldState <- getState
- let oldQuoteContext = stateQuoteContext oldState
- setState oldState { stateQuoteContext = context }
- result <- parser
- newState <- getState
- setState newState { stateQuoteContext = oldQuoteContext }
- return result
-
-singleQuoted :: GenParser Char ParserState Inline
-singleQuoted = try $ do
- singleQuoteStart
- withQuoteContext InSingleQuote $ many1Till inline singleQuoteEnd >>=
- return . Quoted SingleQuote . normalizeSpaces
-
-doubleQuoted :: GenParser Char ParserState Inline
-doubleQuoted = try $ do
- doubleQuoteStart
- withQuoteContext InDoubleQuote $ many1Till inline doubleQuoteEnd >>=
- return . Quoted DoubleQuote . normalizeSpaces
-
-failIfInQuoteContext :: QuoteContext -> GenParser tok ParserState ()
-failIfInQuoteContext context = do
- st <- getState
- if stateQuoteContext st == context
- then fail "already inside quotes"
- else return ()
-
-singleQuoteStart :: GenParser Char ParserState Char
-singleQuoteStart = do
- failIfInQuoteContext InSingleQuote
- try $ do char '\''
- notFollowedBy (oneOf ")!],.;:-? \t\n")
- notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >>
- satisfy (not . isAlphaNum)))
- -- possess/contraction
- return '\''
-
-singleQuoteEnd :: GenParser Char st Char
-singleQuoteEnd = try $ do
- char '\''
- notFollowedBy alphaNum
- return '\''
-
-doubleQuoteStart :: GenParser Char ParserState Char
-doubleQuoteStart = do
- failIfInQuoteContext InDoubleQuote
- try $ do char '"'
- notFollowedBy (oneOf " \t\n")
- return '"'
-
-doubleQuoteEnd :: GenParser Char st Char
-doubleQuoteEnd = char '"'
-
-ellipses :: GenParser Char st Inline
-ellipses = oneOfStrings ["...", " . . . ", ". . .", " . . ."] >> return Ellipses
-
-dash :: GenParser Char st Inline
-dash = enDash <|> emDash
-
-enDash :: GenParser Char st Inline
-enDash = try $ char '-' >> notFollowedBy (noneOf "0123456789") >> return EnDash
-
-emDash :: GenParser Char st Inline
-emDash = oneOfStrings ["---", "--"] >> return EmDash
-
whitespace :: GenParser Char ParserState Inline
whitespace = spaceChar >>
( (spaceChar >> skipMany spaceChar >> option Space (endline >> return LineBreak))
@@ -1106,20 +1049,19 @@ whitespace = spaceChar >>
nonEndline :: GenParser Char st Char
nonEndline = satisfy (/='\n')
-strChar :: GenParser Char st Char
-strChar = noneOf (specialChars ++ " \t\n")
-
str :: GenParser Char ParserState Inline
str = do
- result <- many1 strChar
+ a <- alphaNum
+ as <- many $ alphaNum <|> (try $ char '_' >>~ lookAhead alphaNum)
+ let result = a:as
state <- getState
let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
if stateSmart state
then case likelyAbbrev result of
[] -> return $ Str result
xs -> choice (map (\x ->
- try (string x >> char ' ' >>
- notFollowedBy spaceChar >>
+ try (string x >> oneOf " \n" >>
+ lookAhead alphaNum >>
return (Str $ result ++ spacesToNbr x ++ "\160"))) xs)
<|> (return $ Str result)
else return $ Str result
@@ -1142,15 +1084,13 @@ endline = try $ do
newline
notFollowedBy blankline
st <- getState
- if stateStrict st
- then do notFollowedBy emailBlockQuoteStart
- notFollowedBy (char '#') -- atx header
- else return ()
+ when (stateStrict st) $ do
+ notFollowedBy emailBlockQuoteStart
+ notFollowedBy (char '#') -- atx header
-- parse potential list-starts differently if in a list:
- if stateParserContext st == ListItemState
- then notFollowedBy' (bulletListStart <|>
- (anyOrderedListStart >> return ()))
- else return ()
+ when (stateParserContext st == ListItemState) $ do
+ notFollowedBy' bulletListStart
+ notFollowedBy' anyOrderedListStart
return Space
--
@@ -1175,9 +1115,16 @@ source =
source' :: GenParser Char st (String, [Char])
source' = do
skipSpaces
- let sourceURL excludes = many $
- optional (char '\\') >> (noneOf (' ':excludes) <|> (notFollowedBy' linkTitle >> char ' '))
- src <- try (char '<' >> sourceURL ">\t\n" >>~ char '>') <|> sourceURL "\t\n"
+ let nl = char '\n' >>~ notFollowedBy blankline
+ let sourceURL = liftM unwords $ many $ try $ do
+ notFollowedBy' linkTitle
+ skipMany spaceChar
+ optional nl
+ skipMany spaceChar
+ many1 (satisfy $ not . isBlank)
+ let betweenAngles = try $ char '<' >>
+ manyTill (noneOf ">\n" <|> nl) (char '>')
+ src <- try betweenAngles <|> sourceURL
tit <- option "" linkTitle
skipSpaces
eof
@@ -1196,10 +1143,7 @@ link :: GenParser Char ParserState Inline
link = try $ do
lab <- reference
(src, tit) <- source <|> referenceLink lab
- sanitize <- getState >>= return . stateSanitizeHTML
- if sanitize && unsanitaryURI src
- then fail "Unsanitary URI"
- else return $ Link lab (src, tit)
+ return $ Link lab (src, tit)
-- a link like [this][ref] or [this][] or [this]
referenceLink :: [Inline]
@@ -1209,7 +1153,7 @@ referenceLink lab = do
optional (newline >> skipSpaces) >> reference))
let ref' = if null ref then lab else ref
state <- getState
- case lookupKeySrc (stateKeys state) (Key ref') of
+ case lookupKeySrc (stateKeys state) (toKey ref') of
Nothing -> fail "no corresponding key"
Just target -> return target
@@ -1219,12 +1163,9 @@ autoLink = try $ do
(orig, src) <- uri <|> emailAddress
char '>'
st <- getState
- let sanitize = stateSanitizeHTML st
- if sanitize && unsanitaryURI src
- then fail "Unsanitary URI"
- else return $ if stateStrict st
- then Link [Str orig] (src, "")
- else Link [Code orig] (src, "")
+ return $ if stateStrict st
+ then Link [Str orig] (src, "")
+ else Link [Code ("",["url"],[]) orig] (src, "")
image :: GenParser Char ParserState Inline
image = try $ do
@@ -1250,11 +1191,13 @@ inlineNote = try $ do
return $ Note [Para contents]
rawLaTeXInline' :: GenParser Char ParserState Inline
-rawLaTeXInline' = do
+rawLaTeXInline' = try $ do
failIfStrict
- (rawConTeXtEnvironment' >>= return . TeX)
- <|> (rawLaTeXEnvironment' >>= return . TeX)
- <|> rawLaTeXInline
+ lookAhead $ char '\\'
+ notFollowedBy' $ rawLaTeXEnvironment'
+ <|> rawConTeXtEnvironment'
+ RawInline _ s <- rawLaTeXInline
+ return $ RawInline "tex" s -- "tex" because it might be context or latex
rawConTeXtEnvironment' :: GenParser Char st String
rawConTeXtEnvironment' = try $ do
@@ -1272,46 +1215,98 @@ inBrackets parser = do
char ']'
return $ "[" ++ contents ++ "]"
-rawHtmlInline' :: GenParser Char ParserState Inline
-rawHtmlInline' = do
+rawHtmlInline :: GenParser Char ParserState Inline
+rawHtmlInline = do
st <- getState
- result <- if stateStrict st
- then choice [htmlBlockElement, anyHtmlTag, anyHtmlEndTag]
- else anyHtmlInlineTag
- return $ HtmlInline result
-
-#ifdef _CITEPROC
-inlineCitation :: GenParser Char ParserState Inline
-inlineCitation = try $ do
+ (_,result) <- if stateStrict st
+ then htmlTag (not . isTextTag)
+ else htmlTag isInlineTag
+ return $ RawInline "html" result
+
+-- Citations
+
+cite :: GenParser Char ParserState Inline
+cite = do
failIfStrict
- cit <- citeMarker
- let citations = readWith parseCitation defaultParserState cit
- mr <- mapM chkCit citations
- if catMaybes mr /= []
- then return $ Cite citations []
- else fail "no citation found"
-
-chkCit :: Target -> GenParser Char ParserState (Maybe Target)
-chkCit t = do
+ citations <- textualCite <|> normalCite
+ return $ Cite citations []
+
+spnl :: GenParser Char st ()
+spnl = try $ do
+ skipSpaces
+ optional newline
+ skipSpaces
+ notFollowedBy (char '\n')
+
+textualCite :: GenParser Char ParserState [Citation]
+textualCite = try $ do
+ (_, key) <- citeKey
+ let first = Citation{ citationId = key
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ rest <- option [] $ try $ spnl >> normalCite
+ if null rest
+ then option [first] $ bareloc first
+ else return $ first : rest
+
+bareloc :: Citation -> GenParser Char ParserState [Citation]
+bareloc c = try $ do
+ spnl
+ char '['
+ suff <- suffix
+ rest <- option [] $ try $ char ';' >> citeList
+ spnl
+ char ']'
+ return $ c{ citationSuffix = suff } : rest
+
+normalCite :: GenParser Char ParserState [Citation]
+normalCite = try $ do
+ char '['
+ spnl
+ citations <- citeList
+ spnl
+ char ']'
+ return citations
+
+citeKey :: GenParser Char ParserState (Bool, String)
+citeKey = try $ do
+ suppress_author <- option False (char '-' >> return True)
+ char '@'
+ first <- letter
+ rest <- many $ (noneOf ",;]@ \t\n")
+ let key = first:rest
st <- getState
- case lookupKeySrc (stateKeys st) (Key [Str $ fst t]) of
- Just _ -> fail "This is a link"
- Nothing -> if elem (fst t) $ stateCitations st
- then return $ Just t
- else return $ Nothing
-
-citeMarker :: GenParser Char ParserState String
-citeMarker = char '[' >> manyTill ( noneOf "\n" <|> (newline >>~ notFollowedBy blankline) ) (char ']')
-
-parseCitation :: GenParser Char ParserState [(String,String)]
-parseCitation = try $ sepBy (parseLabel) (oneOf ";")
-
-parseLabel :: GenParser Char ParserState (String,String)
-parseLabel = try $ do
- res <- sepBy (skipSpaces >> optional newline >> skipSpaces >> many1 (noneOf "@;")) (oneOf "@")
- case res of
- [lab,loc] -> return (lab, loc)
- [lab] -> return (lab, "" )
- _ -> return ("" , "" )
-
-#endif
+ guard $ key `elem` stateCitations st
+ return (suppress_author, key)
+
+suffix :: GenParser Char ParserState [Inline]
+suffix = try $ do
+ spnl
+ liftM normalizeSpaces $ many $ notFollowedBy (oneOf ";]") >> inline
+
+prefix :: GenParser Char ParserState [Inline]
+prefix = liftM normalizeSpaces $
+ manyTill inline (char ']' <|> liftM (const ']') (lookAhead citeKey))
+
+citeList :: GenParser Char ParserState [Citation]
+citeList = sepBy1 citation (try $ char ';' >> spnl)
+
+citation :: GenParser Char ParserState Citation
+citation = try $ do
+ pref <- prefix
+ (suppress_author, key) <- citeKey
+ suff <- suffix
+ return $ Citation{ citationId = key
+ , citationPrefix = pref
+ , citationSuffix = suff
+ , citationMode = if suppress_author
+ then SuppressAuthor
+ else NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+
diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs
new file mode 100644
index 000000000..2c6fcc6e6
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Native.hs
@@ -0,0 +1,81 @@
+{-
+Copyright (C) 2011 John MacFarlane <jgm@berkeley.edu>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Native
+ Copyright : Copyright (C) 2011 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of a string representation of a pandoc type (@Pandoc@,
+@[Block]@, @Block@, @[Inline]@, or @Inline@) to a @Pandoc@ document.
+-}
+module Text.Pandoc.Readers.Native ( readNative ) where
+
+import Text.Pandoc.Definition
+
+nullMeta :: Meta
+nullMeta = Meta{ docTitle = []
+ , docAuthors = []
+ , docDate = []
+ }
+
+-- | Read native formatted text and return a Pandoc document.
+-- The input may be a full pandoc document, a block list, a block,
+-- an inline list, or an inline. Thus, for example,
+--
+-- > Str "hi"
+--
+-- will be treated as if it were
+--
+-- > Pandoc (Meta [] [] []) [Plain [Str "hi"]]
+--
+readNative :: String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> Pandoc
+readNative s =
+ case reads s of
+ (d,_):_ -> d
+ [] -> Pandoc nullMeta $ readBlocks s
+
+readBlocks :: String -> [Block]
+readBlocks s =
+ case reads s of
+ (d,_):_ -> d
+ [] -> [readBlock s]
+
+readBlock :: String -> Block
+readBlock s =
+ case reads s of
+ (d,_):_ -> d
+ [] -> Plain $ readInlines s
+
+readInlines :: String -> [Inline]
+readInlines s =
+ case reads s of
+ (d,_):_ -> d
+ [] -> [readInline s]
+
+readInline :: String -> Inline
+readInline s =
+ case reads s of
+ (d,_):_ -> d
+ [] -> error "Cannot parse document"
+
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 13afe5053..32fae5ee7 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -34,10 +34,11 @@ import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Pandoc.Parsing
import Text.ParserCombinators.Parsec
-import Control.Monad ( when, unless )
-import Data.List ( findIndex, intercalate, transpose, sort )
+import Control.Monad ( when )
+import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy )
import qualified Data.Map as M
import Text.Printf ( printf )
+import Data.Maybe ( catMaybes )
-- | Parse reStructuredText string and return Pandoc document.
readRST :: ParserState -- ^ Parser state, including options for parser
@@ -57,7 +58,7 @@ underlineChars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
-- treat these as potentially non-text when parsing inline:
specialChars :: [Char]
-specialChars = "\\`|*_<>$:[-"
+specialChars = "\\`|*_<>$:[-.\"'\8216\8217\8220\8221"
--
-- parsing documents
@@ -90,12 +91,17 @@ titleTransform blocks = (blocks, [])
parseRST :: GenParser Char ParserState Pandoc
parseRST = do
+ optional blanklines -- skip blank lines at beginning of file
startPos <- getPosition
- -- go through once just to get list of reference keys
+ -- go through once just to get list of reference keys and notes
-- docMinusKeys is the raw document with blanks where the keys were...
- docMinusKeys <- manyTill (referenceKey <|> lineClump) eof >>= return . concat
+ docMinusKeys <- manyTill (referenceKey <|> noteBlock <|> lineClump) eof >>=
+ return . concat
setInput docMinusKeys
setPosition startPos
+ st' <- getState
+ let reversedNotes = stateNotes st'
+ updateState $ \s -> s { stateNotes = reverse reversedNotes }
-- now parse it for real...
blocks <- parseBlocks
let blocks' = filter (/= Null) blocks
@@ -117,10 +123,9 @@ parseBlocks = manyTill block eof
block :: GenParser Char ParserState Block
block = choice [ codeBlock
- , rawHtmlBlock
- , rawLaTeXBlock
- , fieldList
+ , rawBlock
, blockQuote
+ , fieldList
, imageBlock
, customCodeBlock
, unknownDirective
@@ -138,46 +143,54 @@ block = choice [ codeBlock
-- field list
--
-fieldListItem :: String -> GenParser Char st ([Char], [Char])
-fieldListItem indent = try $ do
+rawFieldListItem :: String -> GenParser Char ParserState (String, String)
+rawFieldListItem indent = try $ do
string indent
char ':'
- name <- many1 alphaNum
+ name <- many1 $ alphaNum <|> spaceChar
string ": "
skipSpaces
first <- manyTill anyChar newline
- rest <- option "" $ try $ lookAhead (string indent >> oneOf " \t") >>
- indentedBlock
- return (name, intercalate " " (first:(lines rest)))
+ rest <- option "" $ try $ do lookAhead (string indent >> spaceChar)
+ indentedBlock
+ let raw = first ++ "\n" ++ rest ++ "\n"
+ return (name, raw)
+
+fieldListItem :: String
+ -> GenParser Char ParserState (Maybe ([Inline], [[Block]]))
+fieldListItem indent = try $ do
+ (name, raw) <- rawFieldListItem indent
+ let term = [Str name]
+ contents <- parseFromString (many block) raw
+ case (name, contents) of
+ ("Author", x) -> do
+ updateState $ \st ->
+ st{ stateAuthors = stateAuthors st ++ [extractContents x] }
+ return Nothing
+ ("Authors", [BulletList auths]) -> do
+ updateState $ \st -> st{ stateAuthors = map extractContents auths }
+ return Nothing
+ ("Date", x) -> do
+ updateState $ \st -> st{ stateDate = extractContents x }
+ return Nothing
+ ("Title", x) -> do
+ updateState $ \st -> st{ stateTitle = extractContents x }
+ return Nothing
+ _ -> return $ Just (term, [contents])
+
+extractContents :: [Block] -> [Inline]
+extractContents [Plain auth] = auth
+extractContents [Para auth] = auth
+extractContents _ = []
fieldList :: GenParser Char ParserState Block
fieldList = try $ do
- indent <- lookAhead $ many (oneOf " \t")
+ indent <- lookAhead $ many spaceChar
items <- many1 $ fieldListItem indent
blanklines
- let authors = case lookup "Authors" items of
- Just auth -> [auth]
- Nothing -> map snd (filter (\(x,_) -> x == "Author") items)
- unless (null authors) $ do
- authors' <- mapM (parseFromString (many inline)) authors
- updateState $ \st -> st {stateAuthors = map normalizeSpaces authors'}
- case (lookup "Date" items) of
- Just dat -> do
- dat' <- parseFromString (many inline) dat
- updateState $ \st -> st{ stateDate = normalizeSpaces dat' }
- Nothing -> return ()
- case (lookup "Title" items) of
- Just tit -> parseFromString (many inline) tit >>=
- \t -> updateState $ \st -> st {stateTitle = t}
- Nothing -> return ()
- let remaining = filter (\(x,_) -> (x /= "Authors") && (x /= "Author") &&
- (x /= "Date") && (x /= "Title")) items
- if null remaining
- then return Null
- else do terms <- mapM (return . (:[]) . Str . fst) remaining
- defs <- mapM (parseFromString (many block) . snd)
- remaining
- return $ DefinitionList $ zip terms $ map (:[]) defs
+ if null items
+ then return Null
+ else return $ DefinitionList $ catMaybes items
--
-- line block
@@ -186,7 +199,7 @@ fieldList = try $ do
lineBlockLine :: GenParser Char ParserState [Inline]
lineBlockLine = try $ do
string "| "
- white <- many (oneOf " \t")
+ white <- many spaceChar
line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ')
optional endline
return $ normalizeSpaces $ (if null white then [] else [Str white]) ++ line
@@ -231,15 +244,16 @@ plain = many1 inline >>= return . Plain . normalizeSpaces
-- image block
--
-imageBlock :: GenParser Char st Block
+imageBlock :: GenParser Char ParserState Block
imageBlock = try $ do
string ".. image:: "
src <- manyTill anyChar newline
- fields <- option [] $ do indent <- lookAhead $ many (oneOf " /t")
- many1 $ fieldListItem indent
+ fields <- try $ do indent <- lookAhead $ many (oneOf " /t")
+ many $ rawFieldListItem indent
optional blanklines
case lookup "alt" fields of
- Just alt -> return $ Plain [Image [Str alt] (src, alt)]
+ Just alt -> return $ Plain [Image [Str $ removeTrailingSpace alt]
+ (src, "")]
Nothing -> return $ Plain [Image [Str "image"] (src, "")]
--
-- header blocks
@@ -314,20 +328,19 @@ hrule = try $ do
indentedLine :: String -> GenParser Char st [Char]
indentedLine indents = try $ do
string indents
- result <- manyTill anyChar newline
- return $ result ++ "\n"
+ manyTill anyChar newline
-- two or more indented lines, possibly separated by blank lines.
-- any amount of indentation will work.
indentedBlock :: GenParser Char st [Char]
-indentedBlock = do
- indents <- lookAhead $ many1 (oneOf " \t")
+indentedBlock = try $ do
+ indents <- lookAhead $ many1 spaceChar
lns <- many $ choice $ [ indentedLine indents,
try $ do b <- blanklines
l <- indentedLine indents
return (b ++ l) ]
- optional blanklines
- return $ concat lns
+ optional blanklines
+ return $ unlines lns
codeBlock :: GenParser Char st Block
codeBlock = try $ do
@@ -365,23 +378,16 @@ birdTrackLine = do
manyTill anyChar newline
--
--- raw html
+-- raw html/latex/etc
--
-rawHtmlBlock :: GenParser Char st Block
-rawHtmlBlock = try $ string ".. raw:: html" >> blanklines >>
- indentedBlock >>= return . RawHtml
-
---
--- raw latex
---
-
-rawLaTeXBlock :: GenParser Char st Block
-rawLaTeXBlock = try $ do
- string ".. raw:: latex"
+rawBlock :: GenParser Char st Block
+rawBlock = try $ do
+ string ".. raw:: "
+ lang <- many1 (letter <|> digit)
blanklines
result <- indentedBlock
- return $ Para [(TeX result)]
+ return $ RawBlock lang result
--
-- block quotes
@@ -408,7 +414,7 @@ definitionListItem = try $ do
term <- many1Till inline endline
raw <- indentedBlock
-- parse the extracted block, which may contain various block elements:
- contents <- parseFromString parseBlocks $ raw ++ "\n\n"
+ contents <- parseFromString parseBlocks $ raw ++ "\n"
return (normalizeSpaces term, [contents])
definitionList :: GenParser Char ParserState Block
@@ -505,9 +511,35 @@ unknownDirective = try $ do
string ".."
notFollowedBy (noneOf " \t\n")
manyTill anyChar newline
- many $ blanklines <|> (oneOf " \t" >> manyTill anyChar newline)
+ many $ blanklines <|> (spaceChar >> manyTill anyChar newline)
return Null
+---
+--- note block
+---
+
+noteBlock :: GenParser Char ParserState [Char]
+noteBlock = try $ do
+ startPos <- getPosition
+ string ".."
+ spaceChar >> skipMany spaceChar
+ ref <- noteMarker
+ spaceChar >> skipMany spaceChar
+ first <- anyLine
+ blanks <- option "" blanklines
+ rest <- option "" indentedBlock
+ endPos <- getPosition
+ let raw = first ++ "\n" ++ blanks ++ rest ++ "\n"
+ let newnote = (ref, raw)
+ st <- getState
+ let oldnotes = stateNotes st
+ updateState $ \s -> s { stateNotes = newnote : oldnotes }
+ -- return blanks so line count isn't affected
+ return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
+
+noteMarker :: GenParser Char ParserState [Char]
+noteMarker = char '[' >> (many1 digit <|> count 1 (oneOf "#*")) >>~ char ']'
+
--
-- reference key
--
@@ -565,14 +597,14 @@ imageKey = try $ do
skipSpaces
string "image::"
src <- targetURI
- return (Key (normalizeSpaces ref), (src, ""))
+ return (toKey (normalizeSpaces ref), (src, ""))
anonymousKey :: GenParser Char st (Key, Target)
anonymousKey = try $ do
oneOfStrings [".. __:", "__"]
src <- targetURI
pos <- getPosition
- return (Key [Str $ "_" ++ printf "%09d" (sourceLine pos)], (src, ""))
+ return (toKey [Str $ "_" ++ printf "%09d" (sourceLine pos)], (src, ""))
regularKey :: GenParser Char ParserState (Key, Target)
regularKey = try $ do
@@ -580,7 +612,7 @@ regularKey = try $ do
ref <- referenceName
char ':'
src <- targetURI
- return (Key (normalizeSpaces ref), (src, ""))
+ return (toKey (normalizeSpaces ref), (src, ""))
--
-- tables
@@ -679,17 +711,19 @@ table = gridTable False <|> simpleTable False <|>
--
inline :: GenParser Char ParserState Inline
-inline = choice [ link
+inline = choice [ whitespace
+ , link
, str
- , whitespace
, endline
, strong
, emph
, code
, image
- , hyphens
, superscript
, subscript
+ , note
+ , smartPunctuation inline
+ , hyphens
, escapedChar
, symbol ] <?> "inline"
@@ -713,7 +747,8 @@ code :: GenParser Char ParserState Inline
code = try $ do
string "``"
result <- manyTill anyChar (try (string "``"))
- return $ Code $ removeLeadingTrailingSpace $ intercalate " " $ lines result
+ return $ Code nullAttr
+ $ removeLeadingTrailingSpace $ intercalate " " $ lines result
emph :: GenParser Char ParserState Inline
emph = enclosed (char '*') (char '*') inline >>=
@@ -779,9 +814,10 @@ referenceLink = try $ do
label' <- (quotedReferenceName <|> simpleReferenceName) >>~ char '_'
state <- getState
let keyTable = stateKeys state
- let isAnonKey (Key [Str ('_':_)]) = True
- isAnonKey _ = False
- key <- option (Key label') $
+ let isAnonKey x = case fromKey x of
+ [Str ('_':_)] -> True
+ _ -> False
+ key <- option (toKey label') $
do char '_'
let anonKeys = sort $ filter isAnonKey $ M.keys keyTable
if null anonKeys
@@ -814,7 +850,24 @@ image = try $ do
ref <- manyTill inline (char '|')
state <- getState
let keyTable = stateKeys state
- (src,tit) <- case lookupKeySrc keyTable (Key ref) of
+ (src,tit) <- case lookupKeySrc keyTable (toKey ref) of
Nothing -> fail "no corresponding key"
Just target -> return target
return $ Image (normalizeSpaces ref) (src, tit)
+
+note :: GenParser Char ParserState Inline
+note = try $ do
+ ref <- noteMarker
+ char '_'
+ state <- getState
+ let notes = stateNotes state
+ case lookup ref notes of
+ Nothing -> fail "note not found"
+ Just raw -> do
+ contents <- parseFromString parseBlocks raw
+ when (ref == "*" || ref == "#") $ do -- auto-numbered
+ -- delete the note so the next auto-numbered note
+ -- doesn't get the same contents:
+ let newnotes = deleteFirstsBy (==) notes [(ref,raw)]
+ updateState $ \st -> st{ stateNotes = newnotes }
+ return $ Note contents
diff --git a/src/Text/Pandoc/Readers/TeXMath.hs b/src/Text/Pandoc/Readers/TeXMath.hs
index b0c6e86d4..b9a46e8ff 100644
--- a/src/Text/Pandoc/Readers/TeXMath.hs
+++ b/src/Text/Pandoc/Readers/TeXMath.hs
@@ -27,12 +27,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of TeX math to a list of 'Pandoc' inline elements.
-}
-module Text.Pandoc.Readers.TeXMath (
- readTeXMath
- ) where
+module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where
-import Text.ParserCombinators.Parsec
import Text.Pandoc.Definition
+import Text.TeXMath.Types
import Text.TeXMath.Parser
-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
@@ -40,16 +38,17 @@ import Text.TeXMath.Parser
-- can't be converted.
readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings)
-> [Inline]
-readTeXMath inp = case readTeXMath' inp of
- Nothing -> [Str ("$" ++ inp ++ "$")]
- Just res -> res
+readTeXMath inp = case texMathToPandoc inp of
+ Left _ -> [Str ("$" ++ inp ++ "$")]
+ Right res -> res
--- | Like 'readTeXMath', but without the default.
-readTeXMath' :: String -- ^ String to parse (assumes @'\n'@ line endings)
- -> Maybe [Inline]
-readTeXMath' inp = case parse formula "formula" inp of
- Left _ -> Just [Str inp]
- Right exps -> expsToInlines exps
+texMathToPandoc :: String -> Either String [Inline]
+texMathToPandoc inp = inp `seq`
+ case parseFormula inp of
+ Left err -> Left err
+ Right exps -> case expsToInlines exps of
+ Nothing -> Left "Formula too complex for [Inline]"
+ Just r -> Right r
expsToInlines :: [Exp] -> Maybe [Inline]
expsToInlines xs = do
@@ -89,6 +88,26 @@ expToInlines (ESubsup x y z) = do
expToInlines (EDown x y) = expToInlines (ESub x y)
expToInlines (EUp x y) = expToInlines (ESuper x y)
expToInlines (EDownup x y z) = expToInlines (ESubsup x y z)
-expToInlines (EText _ x) = Just [Emph [Str x]]
+expToInlines (EText "normal" x) = Just [Str x]
+expToInlines (EText "bold" x) = Just [Strong [Str x]]
+expToInlines (EText "monospace" x) = Just [Code nullAttr x]
+expToInlines (EText "italic" x) = Just [Emph [Str x]]
+expToInlines (EText _ x) = Just [Str x]
+expToInlines (EOver (EGrouped [EIdentifier [c]]) (ESymbol Accent [accent])) =
+ case accent of
+ '\x203E' -> Just [Emph [Str [c,'\x0304']]] -- bar
+ '\x00B4' -> Just [Emph [Str [c,'\x0301']]] -- acute
+ '\x0060' -> Just [Emph [Str [c,'\x0300']]] -- grave
+ '\x02D8' -> Just [Emph [Str [c,'\x0306']]] -- breve
+ '\x02C7' -> Just [Emph [Str [c,'\x030C']]] -- check
+ '.' -> Just [Emph [Str [c,'\x0307']]] -- dot
+ '\x00B0' -> Just [Emph [Str [c,'\x030A']]] -- ring
+ '\x20D7' -> Just [Emph [Str [c,'\x20D7']]] -- arrow right
+ '\x20D6' -> Just [Emph [Str [c,'\x20D6']]] -- arrow left
+ '\x005E' -> Just [Emph [Str [c,'\x0302']]] -- hat
+ '\x0302' -> Just [Emph [Str [c,'\x0302']]] -- hat
+ '~' -> Just [Emph [Str [c,'\x0303']]] -- tilde
+ _ -> Nothing
expToInlines _ = Nothing
+
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
new file mode 100644
index 000000000..19357b343
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -0,0 +1,523 @@
+{-
+Copyright (C) 2010 Paul Rivier <paul*rivier#demotera*com> | tr '*#' '.@'
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Textile
+ Copyright : Copyright (C) 2010-2011 Paul Rivier and John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Paul Rivier <paul*rivier#demotera*com>
+ Stability : alpha
+ Portability : portable
+
+Conversion from Textile to 'Pandoc' document, based on the spec
+available at http://redcloth.org/textile.
+
+Implemented and parsed:
+ - Paragraphs
+ - Code blocks
+ - Lists
+ - blockquote
+ - Inlines : strong, emph, cite, code, deleted, superscript,
+ subscript, links
+ - footnotes
+
+Implemented but discarded:
+ - HTML-specific and CSS-specific attributes
+
+Left to be implemented:
+ - dimension sign
+ - all caps
+ - continued blocks (ex bq..)
+
+TODO : refactor common patterns across readers :
+ - autolink
+ - smartPunctuation
+ - more ...
+
+-}
+
+
+module Text.Pandoc.Readers.Textile ( readTextile) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared
+import Text.Pandoc.Parsing
+import Text.Pandoc.Readers.HTML ( htmlTag, isInlineTag, isBlockTag )
+import Text.ParserCombinators.Parsec
+import Text.HTML.TagSoup.Match
+import Data.Char ( digitToInt, isLetter )
+import Control.Monad ( guard, liftM )
+
+-- | Parse a Textile text and return a Pandoc document.
+readTextile :: ParserState -- ^ Parser state, including options for parser
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> Pandoc
+readTextile state s = (readWith parseTextile) state (s ++ "\n\n")
+
+
+--
+-- Constants and data structure definitions
+--
+
+-- | Special chars border strings parsing
+specialChars :: [Char]
+specialChars = "\\[]<>*#_@~-+^&,.;:!?|\"'%()"
+
+-- | Generate a Pandoc ADT from a textile document
+parseTextile :: GenParser Char ParserState Pandoc
+parseTextile = do
+ -- textile allows raw HTML and does smart punctuation by default
+ updateState (\state -> state { stateParseRaw = True, stateSmart = True })
+ many blankline
+ startPos <- getPosition
+ -- go through once just to get list of reference keys and notes
+ -- docMinusKeys is the raw document with blanks where the keys/notes were...
+ let firstPassParser = noteBlock <|> lineClump
+ manyTill firstPassParser eof >>= setInput . concat
+ setPosition startPos
+ st' <- getState
+ let reversedNotes = stateNotes st'
+ updateState $ \s -> s { stateNotes = reverse reversedNotes }
+ -- now parse it for real...
+ blocks <- parseBlocks
+ return $ Pandoc (Meta [] [] []) blocks -- FIXME
+
+noteMarker :: GenParser Char ParserState [Char]
+noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.')
+
+noteBlock :: GenParser Char ParserState [Char]
+noteBlock = try $ do
+ startPos <- getPosition
+ ref <- noteMarker
+ optional blankline
+ contents <- liftM unlines $ many1Till anyLine (blanklines <|> noteBlock)
+ endPos <- getPosition
+ let newnote = (ref, contents ++ "\n")
+ st <- getState
+ let oldnotes = stateNotes st
+ updateState $ \s -> s { stateNotes = newnote : oldnotes }
+ -- return blanks so line count isn't affected
+ return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
+
+-- | Parse document blocks
+parseBlocks :: GenParser Char ParserState [Block]
+parseBlocks = manyTill block eof
+
+-- | Block parsers list tried in definition order
+blockParsers :: [GenParser Char ParserState Block]
+blockParsers = [ codeBlock
+ , header
+ , blockQuote
+ , hrule
+ , anyList
+ , rawHtmlBlock
+ , maybeExplicitBlock "table" table
+ , maybeExplicitBlock "p" para
+ , nullBlock ]
+
+-- | Any block in the order of definition of blockParsers
+block :: GenParser Char ParserState Block
+block = choice blockParsers <?> "block"
+
+codeBlock :: GenParser Char ParserState Block
+codeBlock = codeBlockBc <|> codeBlockPre
+
+codeBlockBc :: GenParser Char ParserState Block
+codeBlockBc = try $ do
+ string "bc. "
+ contents <- manyTill anyLine blanklines
+ return $ CodeBlock ("",[],[]) $ unlines contents
+
+-- | Code Blocks in Textile are between <pre> and </pre>
+codeBlockPre :: GenParser Char ParserState Block
+codeBlockPre = try $ do
+ htmlTag (tagOpen (=="pre") null)
+ result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak)
+ -- drop leading newline if any
+ let result'' = case result' of
+ '\n':xs -> xs
+ _ -> result'
+ -- drop trailing newline if any
+ let result''' = case reverse result'' of
+ '\n':_ -> init result''
+ _ -> result''
+ return $ CodeBlock ("",[],[]) result'''
+
+-- | Header of the form "hN. content" with N in 1..6
+header :: GenParser Char ParserState Block
+header = try $ do
+ char 'h'
+ level <- oneOf "123456" >>= return . digitToInt
+ optional attributes
+ char '.'
+ whitespace
+ name <- manyTill inline blockBreak
+ return $ Header level (normalizeSpaces name)
+
+-- | Blockquote of the form "bq. content"
+blockQuote :: GenParser Char ParserState Block
+blockQuote = try $ do
+ string "bq"
+ optional attributes
+ char '.'
+ whitespace
+ para >>= return . BlockQuote . (:[])
+
+-- Horizontal rule
+
+hrule :: GenParser Char st Block
+hrule = try $ do
+ skipSpaces
+ start <- oneOf "-*"
+ count 2 (skipSpaces >> char start)
+ skipMany (spaceChar <|> char start)
+ newline
+ optional blanklines
+ return HorizontalRule
+
+-- Lists handling
+
+-- | Can be a bullet list or an ordered list. This implementation is
+-- strict in the nesting, sublist must start at exactly "parent depth
+-- plus one"
+anyList :: GenParser Char ParserState Block
+anyList = try $ do
+ l <- anyListAtDepth 1
+ blanklines
+ return l
+
+-- | This allow one type of list to be nested into an other type,
+-- provided correct nesting
+anyListAtDepth :: Int -> GenParser Char ParserState Block
+anyListAtDepth depth = choice [ bulletListAtDepth depth,
+ orderedListAtDepth depth,
+ definitionList ]
+
+-- | Bullet List of given depth, depth being the number of leading '*'
+bulletListAtDepth :: Int -> GenParser Char ParserState Block
+bulletListAtDepth depth = try $ do
+ items <- many1 (bulletListItemAtDepth depth)
+ return (BulletList items)
+
+-- | Bullet List Item of given depth, depth being the number of
+-- leading '*'
+bulletListItemAtDepth :: Int -> GenParser Char ParserState [Block]
+bulletListItemAtDepth depth = try $ do
+ count depth (char '*')
+ optional attributes
+ whitespace
+ p <- inlines >>= return . Plain
+ sublist <- option [] (anyListAtDepth (depth + 1) >>= return . (:[]))
+ return (p:sublist)
+
+-- | Ordered List of given depth, depth being the number of
+-- leading '#'
+orderedListAtDepth :: Int -> GenParser Char ParserState Block
+orderedListAtDepth depth = try $ do
+ items <- many1 (orderedListItemAtDepth depth)
+ return (OrderedList (1, DefaultStyle, DefaultDelim) items)
+
+-- | Ordered List Item of given depth, depth being the number of
+-- leading '#'
+orderedListItemAtDepth :: Int -> GenParser Char ParserState [Block]
+orderedListItemAtDepth depth = try $ do
+ count depth (char '#')
+ optional attributes
+ whitespace
+ p <- inlines >>= return . Plain
+ sublist <- option [] (anyListAtDepth (depth + 1) >>= return . (:[]))
+ return (p:sublist)
+
+-- | A definition list is a set of consecutive definition items
+definitionList :: GenParser Char ParserState Block
+definitionList = try $ do
+ items <- many1 definitionListItem
+ return $ DefinitionList items
+
+-- | A definition list item in textile begins with '- ', followed by
+-- the term defined, then spaces and ":=". The definition follows, on
+-- the same single line, or spaned on multiple line, after a line
+-- break.
+definitionListItem :: GenParser Char ParserState ([Inline], [[Block]])
+definitionListItem = try $ do
+ string "- "
+ term <- many1Till inline (try (whitespace >> string ":="))
+ def <- inlineDef <|> multilineDef
+ return (term, def)
+ where inlineDef :: GenParser Char ParserState [[Block]]
+ inlineDef = liftM (\d -> [[Plain d]]) $ try (whitespace >> inlines)
+ multilineDef :: GenParser Char ParserState [[Block]]
+ multilineDef = try $ do
+ optional whitespace >> newline
+ s <- many1Till anyChar (try (string "=:" >> newline))
+ -- this ++ "\n\n" does not look very good
+ ds <- parseFromString parseBlocks (s ++ "\n\n")
+ return [ds]
+
+-- | This terminates a block such as a paragraph. Because of raw html
+-- blocks support, we have to lookAhead for a rawHtmlBlock.
+blockBreak :: GenParser Char ParserState ()
+blockBreak = try (newline >> blanklines >> return ()) <|>
+ (lookAhead rawHtmlBlock >> return ())
+
+-- | A raw Html Block, optionally followed by blanklines
+rawHtmlBlock :: GenParser Char ParserState Block
+rawHtmlBlock = try $ do
+ (_,b) <- htmlTag isBlockTag
+ optional blanklines
+ return $ RawBlock "html" b
+
+-- | In textile, paragraphs are separated by blank lines.
+para :: GenParser Char ParserState Block
+para = try $ do
+ content <- manyTill inline blockBreak
+ return $ Para $ normalizeSpaces content
+
+
+-- Tables
+
+-- | A table cell spans until a pipe |
+tableCell :: GenParser Char ParserState TableCell
+tableCell = do
+ c <- many1 (noneOf "|\n")
+ content <- parseFromString (many1 inline) c
+ return $ [ Plain $ normalizeSpaces content ]
+
+-- | A table row is made of many table cells
+tableRow :: GenParser Char ParserState [TableCell]
+tableRow = try $ do
+ char '|'
+ cells <- endBy1 tableCell (char '|')
+ newline
+ return cells
+
+-- | Many table rows
+tableRows :: GenParser Char ParserState [[TableCell]]
+tableRows = many1 tableRow
+
+-- | Table headers are made of cells separated by a tag "|_."
+tableHeaders :: GenParser Char ParserState [TableCell]
+tableHeaders = try $ do
+ let separator = (try $ string "|_.")
+ separator
+ headers <- sepBy1 tableCell separator
+ char '|'
+ newline
+ return headers
+
+-- | A table with an optional header. Current implementation can
+-- handle tables with and without header, but will parse cells
+-- alignment attributes as content.
+table :: GenParser Char ParserState Block
+table = try $ do
+ headers <- option [] tableHeaders
+ rows <- tableRows
+ blanklines
+ let nbOfCols = max (length headers) (length $ head rows)
+ return $ Table []
+ (replicate nbOfCols AlignDefault)
+ (replicate nbOfCols 0.0)
+ headers
+ rows
+
+
+-- | Blocks like 'p' and 'table' do not need explicit block tag.
+-- However, they can be used to set HTML/CSS attributes when needed.
+maybeExplicitBlock :: String -- ^ block tag name
+ -> GenParser Char ParserState Block -- ^ implicit block
+ -> GenParser Char ParserState Block
+maybeExplicitBlock name blk = try $ do
+ optional $ try $ string name >> optional attributes >> char '.' >>
+ ((try whitespace) <|> endline)
+ blk
+
+
+
+----------
+-- Inlines
+----------
+
+
+-- | Any inline element
+inline :: GenParser Char ParserState Inline
+inline = choice inlineParsers <?> "inline"
+
+-- | List of consecutive inlines before a newline
+inlines :: GenParser Char ParserState [Inline]
+inlines = manyTill inline newline
+
+-- | Inline parsers tried in order
+inlineParsers :: [GenParser Char ParserState Inline]
+inlineParsers = [ autoLink
+ , str
+ , whitespace
+ , endline
+ , code
+ , htmlSpan
+ , rawHtmlInline
+ , note
+ , simpleInline (string "??") (Cite [])
+ , simpleInline (string "**") Strong
+ , simpleInline (string "__") Emph
+ , simpleInline (char '*') Strong
+ , simpleInline (char '_') Emph
+ , simpleInline (char '-') Strikeout
+ , simpleInline (char '^') Superscript
+ , simpleInline (char '~') Subscript
+ , link
+ , image
+ , mark
+ , smartPunctuation inline
+ , symbol
+ ]
+
+-- | Trademark, registered, copyright
+mark :: GenParser Char st Inline
+mark = try $ char '(' >> (try tm <|> try reg <|> copy)
+
+reg :: GenParser Char st Inline
+reg = do
+ oneOf "Rr"
+ char ')'
+ return $ Str "\174"
+
+tm :: GenParser Char st Inline
+tm = do
+ oneOf "Tt"
+ oneOf "Mm"
+ char ')'
+ return $ Str "\8482"
+
+copy :: GenParser Char st Inline
+copy = do
+ oneOf "Cc"
+ char ')'
+ return $ Str "\169"
+
+note :: GenParser Char ParserState Inline
+note = try $ do
+ char '['
+ ref <- many1 digit
+ char ']'
+ state <- getState
+ let notes = stateNotes state
+ case lookup ref notes of
+ Nothing -> fail "note not found"
+ Just raw -> liftM Note $ parseFromString parseBlocks raw
+
+-- | Any string
+str :: GenParser Char ParserState Inline
+str = do
+ xs <- many1 (noneOf (specialChars ++ "\t\n "))
+ optional $ try $ do
+ lookAhead (char '(')
+ notFollowedBy' mark
+ getInput >>= setInput . (' ':) -- add space before acronym explanation
+ -- parse a following hyphen if followed by a letter
+ -- (this prevents unwanted interpretation as starting a strikeout section)
+ result <- option xs $ try $ do
+ char '-'
+ next <- lookAhead letter
+ guard $ isLetter (last xs) || isLetter next
+ return $ xs ++ "-"
+ return $ Str result
+
+-- | Textile allows HTML span infos, we discard them
+htmlSpan :: GenParser Char ParserState Inline
+htmlSpan = try $ do
+ char '%'
+ _ <- attributes
+ content <- manyTill anyChar (char '%')
+ return $ Str content
+
+-- | Some number of space chars
+whitespace :: GenParser Char ParserState Inline
+whitespace = many1 spaceChar >> return Space <?> "whitespace"
+
+-- | In Textile, an isolated endline character is a line break
+endline :: GenParser Char ParserState Inline
+endline = try $ do
+ newline >> notFollowedBy blankline
+ return LineBreak
+
+rawHtmlInline :: GenParser Char ParserState Inline
+rawHtmlInline = liftM (RawInline "html" . snd)
+ $ htmlTag isInlineTag
+
+-- | Textile standard link syntax is "label":target
+link :: GenParser Char ParserState Inline
+link = try $ do
+ name <- surrounded (char '"') inline
+ char ':'
+ url <- manyTill (anyChar) (lookAhead $ (space <|> try (oneOf ".;," >> (space <|> newline))))
+ return $ Link name (url, "")
+
+-- | Detect plain links to http or email.
+autoLink :: GenParser Char ParserState Inline
+autoLink = do
+ (orig, src) <- (try uri <|> try emailAddress)
+ return $ Link [Str orig] (src, "")
+
+-- | image embedding
+image :: GenParser Char ParserState Inline
+image = try $ do
+ char '!' >> notFollowedBy space
+ src <- manyTill anyChar (lookAhead $ oneOf "!(")
+ alt <- option "" (try $ (char '(' >> manyTill anyChar (char ')')))
+ char '!'
+ return $ Image [Str alt] (src, alt)
+
+-- | Any special symbol defined in specialChars
+symbol :: GenParser Char ParserState Inline
+symbol = do
+ result <- oneOf specialChars
+ return $ Str [result]
+
+-- | Inline code
+code :: GenParser Char ParserState Inline
+code = code1 <|> code2
+
+code1 :: GenParser Char ParserState Inline
+code1 = surrounded (char '@') anyChar >>= return . Code nullAttr
+
+code2 :: GenParser Char ParserState Inline
+code2 = do
+ htmlTag (tagOpen (=="tt") null)
+ result' <- manyTill anyChar (try $ htmlTag $ tagClose (=="tt"))
+ return $ Code nullAttr result'
+
+-- | Html / CSS attributes
+attributes :: GenParser Char ParserState String
+attributes = choice [ enclosed (char '(') (char ')') anyChar,
+ enclosed (char '{') (char '}') anyChar,
+ enclosed (char '[') (char ']') anyChar]
+
+-- | Parses material surrounded by a parser.
+surrounded :: GenParser Char st t -- ^ surrounding parser
+ -> GenParser Char st a -- ^ content parser (to be used repeatedly)
+ -> GenParser Char st [a]
+surrounded border = enclosed border border
+
+-- | Inlines are most of the time of the same form
+simpleInline :: GenParser Char ParserState t -- ^ surrounding parser
+ -> ([Inline] -> Inline) -- ^ Inline constructor
+ -> GenParser Char ParserState Inline -- ^ content parser (to be used repeatedly)
+simpleInline border construct = surrounded border (inlineWithAttribute) >>=
+ return . construct . normalizeSpaces
+ where inlineWithAttribute = (try $ optional attributes) >> inline
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 633708046..b1d5de63f 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -46,17 +46,11 @@ module Text.Pandoc.Shared (
escapeURI,
unescapeURI,
tabFilter,
- -- * Prettyprinting
- wrapped,
- wrapIfNeeded,
- wrappedTeX,
- wrapTeXIfNeeded,
- BlockWrapper (..),
- wrappedBlocksToDoc,
- hang',
-- * Pandoc block and inline list processing
orderedListMarkers,
normalizeSpaces,
+ normalize,
+ stringify,
compactify,
Element (..),
hierarchicalize,
@@ -65,19 +59,20 @@ module Text.Pandoc.Shared (
headerShift,
-- * Writer options
HTMLMathMethod (..),
+ CiteMethod (..),
ObfuscationMethod (..),
HTMLSlideVariant (..),
WriterOptions (..),
defaultWriterOptions,
-- * File handling
inDirectory,
+ findDataFile,
readDataFile
) where
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import qualified Text.Pandoc.UTF8 as UTF8 (readFile)
-import Text.PrettyPrint.HughesPJ ( Doc, fsep, ($$), (<>), empty, isEmpty, text, nest )
-import qualified Text.PrettyPrint.HughesPJ as PP
import Data.Char ( toLower, isLower, isUpper, isAlpha, isAscii,
isLetter, isDigit )
import Data.List ( find, isPrefixOf, intercalate )
@@ -94,12 +89,12 @@ import Paths_pandoc (getDataFileName)
--
-- | Split list by groups of one or more sep.
-splitBy :: (Eq a) => a -> [a] -> [[a]]
+splitBy :: (a -> Bool) -> [a] -> [[a]]
splitBy _ [] = []
-splitBy sep lst =
- let (first, rest) = break (== sep) lst
- rest' = dropWhile (== sep) rest
- in first:(splitBy sep rest')
+splitBy isSep lst =
+ let (first, rest) = break isSep lst
+ rest' = dropWhile isSep rest
+ in first:(splitBy isSep rest')
-- | Split list into chunks divided at specified indices.
splitByIndices :: [Int] -> [a] -> [[a]]
@@ -218,83 +213,6 @@ tabFilter tabStop =
in go tabStop
--
--- Prettyprinting
---
-
--- | Wrap inlines to line length.
-wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
-wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>=
- return . fsep
-
--- | Wrap inlines if the text wrap option is selected.
-wrapIfNeeded :: Monad m => WriterOptions -> ([Inline] -> m Doc) ->
- [Inline] -> m Doc
-wrapIfNeeded opts = if writerWrapText opts
- then wrapped
- else ($)
-
--- auxiliary function for wrappedTeX
-isNote :: Inline -> Bool
-isNote (Note _) = True
-isNote _ = False
-
--- | Wrap inlines to line length, treating footnotes in a way that
--- makes sense in LaTeX and ConTeXt.
-wrappedTeX :: Monad m
- => Bool
- -> ([Inline] -> m Doc)
- -> [Inline]
- -> m Doc
-wrappedTeX includePercent listWriter sect = do
- let (firstpart, rest) = break isNote sect
- firstpartWrapped <- wrapped listWriter firstpart
- if null rest
- then return firstpartWrapped
- else do let (note:rest') = rest
- let (rest1, rest2) = break (== Space) rest'
- -- rest1 is whatever comes between the note and a Space.
- -- if the note is followed directly by a Space, rest1 is null.
- -- rest1 is printed after the note but before the line break,
- -- to avoid spurious blank space the note and immediately
- -- following punctuation.
- rest1Out <- if null rest1
- then return empty
- else listWriter rest1
- rest2Wrapped <- if null rest2
- then return empty
- else wrappedTeX includePercent listWriter (tail rest2)
- noteText <- listWriter [note]
- return $ (firstpartWrapped <> if includePercent then PP.char '%' else empty) $$
- (noteText <> rest1Out) $$
- rest2Wrapped
-
--- | Wrap inlines if the text wrap option is selected, specialized
--- for LaTeX and ConTeXt.
-wrapTeXIfNeeded :: Monad m
- => WriterOptions
- -> Bool
- -> ([Inline] -> m Doc)
- -> [Inline]
- -> m Doc
-wrapTeXIfNeeded opts includePercent = if writerWrapText opts
- then wrappedTeX includePercent
- else ($)
-
--- | Indicates whether block should be surrounded by blank lines (@Pad@) or not (@Reg@).
-data BlockWrapper = Pad Doc | Reg Doc
-
--- | Converts a list of wrapped blocks to a Doc, with appropriate spaces around blocks.
-wrappedBlocksToDoc :: [BlockWrapper] -> Doc
-wrappedBlocksToDoc = foldr addBlock empty
- where addBlock (Pad d) accum | isEmpty accum = d
- addBlock (Pad d) accum = d $$ text "" $$ accum
- addBlock (Reg d) accum = d $$ accum
-
--- | A version of hang that works like the version in pretty-1.0.0.0
-hang' :: Doc -> Int -> Doc -> Doc
-hang' d1 n d2 = d1 $$ (nest n d2)
-
---
-- Pandoc block and inline list processing
--
@@ -324,20 +242,96 @@ orderedListMarkers (start, numstyle, numdelim) =
-- @Space@ elements, collapse double @Space@s into singles, and
-- remove empty Str elements.
normalizeSpaces :: [Inline] -> [Inline]
-normalizeSpaces [] = []
-normalizeSpaces list =
- let removeDoubles [] = []
- removeDoubles (Space:Space:rest) = removeDoubles (Space:rest)
- removeDoubles (Space:(Str ""):Space:rest) = removeDoubles (Space:rest)
- removeDoubles ((Str ""):rest) = removeDoubles rest
- removeDoubles (x:rest) = x:(removeDoubles rest)
- removeLeading (Space:xs) = removeLeading xs
- removeLeading x = x
- removeTrailing [] = []
- removeTrailing lst = if (last lst == Space)
- then init lst
- else lst
- in removeLeading $ removeTrailing $ removeDoubles list
+normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
+ where isSpaceOrEmpty Space = True
+ isSpaceOrEmpty (Str "") = True
+ isSpaceOrEmpty _ = False
+ cleanup [] = []
+ cleanup (Space:rest) = let rest' = dropWhile isSpaceOrEmpty rest
+ in case rest' of
+ [] -> []
+ _ -> Space : cleanup rest'
+ cleanup ((Str ""):rest) = cleanup rest
+ cleanup (x:rest) = x : cleanup rest
+
+-- | Normalize @Pandoc@ document, consolidating doubled 'Space's,
+-- combining adjacent 'Str's and 'Emph's, remove 'Null's and
+-- empty elements, etc.
+normalize :: (Eq a, Data a) => a -> a
+normalize = topDown removeEmptyBlocks .
+ topDown consolidateInlines .
+ bottomUp removeEmptyInlines
+
+removeEmptyBlocks :: [Block] -> [Block]
+removeEmptyBlocks (Null : xs) = removeEmptyBlocks xs
+removeEmptyBlocks (BulletList [] : xs) = removeEmptyBlocks xs
+removeEmptyBlocks (OrderedList _ [] : xs) = removeEmptyBlocks xs
+removeEmptyBlocks (DefinitionList [] : xs) = removeEmptyBlocks xs
+removeEmptyBlocks (RawBlock _ [] : xs) = removeEmptyBlocks xs
+removeEmptyBlocks (x:xs) = x : removeEmptyBlocks xs
+removeEmptyBlocks [] = []
+
+removeEmptyInlines :: [Inline] -> [Inline]
+removeEmptyInlines (Emph [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (Strong [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (Subscript [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (Superscript [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (SmallCaps [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (Strikeout [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (RawInline _ [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (Code _ [] : zs) = removeEmptyInlines zs
+removeEmptyInlines (Str "" : zs) = removeEmptyInlines zs
+removeEmptyInlines (x : xs) = x : removeEmptyInlines xs
+removeEmptyInlines [] = []
+
+consolidateInlines :: [Inline] -> [Inline]
+consolidateInlines (Str x : ys) =
+ case concat (x : map fromStr strs) of
+ "" -> consolidateInlines rest
+ n -> Str n : consolidateInlines rest
+ where
+ (strs, rest) = span isStr ys
+ isStr (Str _) = True
+ isStr _ = False
+ fromStr (Str z) = z
+ fromStr _ = error "consolidateInlines - fromStr - not a Str"
+consolidateInlines (Space : ys) = Space : rest
+ where isSpace Space = True
+ isSpace _ = False
+ rest = consolidateInlines $ dropWhile isSpace ys
+consolidateInlines (Emph xs : Emph ys : zs) = consolidateInlines $
+ Emph (xs ++ ys) : zs
+consolidateInlines (Strong xs : Strong ys : zs) = consolidateInlines $
+ Strong (xs ++ ys) : zs
+consolidateInlines (Subscript xs : Subscript ys : zs) = consolidateInlines $
+ Subscript (xs ++ ys) : zs
+consolidateInlines (Superscript xs : Superscript ys : zs) = consolidateInlines $
+ Superscript (xs ++ ys) : zs
+consolidateInlines (SmallCaps xs : SmallCaps ys : zs) = consolidateInlines $
+ SmallCaps (xs ++ ys) : zs
+consolidateInlines (Strikeout xs : Strikeout ys : zs) = consolidateInlines $
+ Strikeout (xs ++ ys) : zs
+consolidateInlines (RawInline f x : RawInline f' y : zs) | f == f' =
+ consolidateInlines $ RawInline f (x ++ y) : zs
+consolidateInlines (Code a1 x : Code a2 y : zs) | a1 == a2 =
+ consolidateInlines $ Code a1 (x ++ y) : zs
+consolidateInlines (x : xs) = x : consolidateInlines xs
+consolidateInlines [] = []
+
+-- | Convert list of inlines to a string with formatting removed.
+stringify :: [Inline] -> String
+stringify = queryWith go
+ where go :: Inline -> [Char]
+ go Space = " "
+ go (Str x) = x
+ go (Code _ x) = x
+ go (Math _ x) = x
+ go EmDash = "--"
+ go EnDash = "-"
+ go Apostrophe = "'"
+ go Ellipses = "..."
+ go LineBreak = " "
+ go _ = ""
-- | Change final list item from @Para@ to @Plain@ if the list contains
-- no other @Para@ blocks.
@@ -370,32 +364,12 @@ data Element = Blk Block
-- letters, digits, and the characters _-.
inlineListToIdentifier :: [Inline] -> String
inlineListToIdentifier =
- dropWhile (not . isAlpha) . intercalate "-" . words . map toLower .
- filter (\c -> isLetter c || isDigit c || c `elem` "_-. ") .
- concatMap extractText
- where extractText x = case x of
- Str s -> s
- Emph lst -> concatMap extractText lst
- Strikeout lst -> concatMap extractText lst
- Superscript lst -> concatMap extractText lst
- SmallCaps lst -> concatMap extractText lst
- Subscript lst -> concatMap extractText lst
- Strong lst -> concatMap extractText lst
- Quoted _ lst -> concatMap extractText lst
- Cite _ lst -> concatMap extractText lst
- Code s -> s
- Space -> " "
- EmDash -> "---"
- EnDash -> "--"
- Apostrophe -> ""
- Ellipses -> "..."
- LineBreak -> " "
- Math _ s -> s
- TeX _ -> ""
- HtmlInline _ -> ""
- Link lst _ -> concatMap extractText lst
- Image lst _ -> concatMap extractText lst
- Note _ -> ""
+ dropWhile (not . isAlpha) . intercalate "-" . words .
+ map (nbspToSp . toLower) .
+ filter (\c -> isLetter c || isDigit c || c `elem` "_-. ") .
+ stringify
+ where nbspToSp '\160' = ' '
+ nbspToSp x = x
-- | Convert list of Pandoc blocks into (hierarchical) list of Elements
hierarchicalize :: [Block] -> [Element]
@@ -444,7 +418,7 @@ isHeaderBlock _ = False
-- | Shift header levels up or down.
headerShift :: Int -> Pandoc -> Pandoc
-headerShift n = processWith shift
+headerShift n = bottomUp shift
where shift :: Block -> Block
shift (Header level inner) = Header (level + n) inner
shift x = x
@@ -459,8 +433,14 @@ data HTMLMathMethod = PlainMath
| GladTeX
| WebTeX String -- url of TeX->image script.
| MathML (Maybe String) -- url of MathMLinHTML.js
+ | MathJax String -- url of MathJax.js
deriving (Show, Read, Eq)
+data CiteMethod = Citeproc -- use citeproc to render them
+ | Natbib -- output natbib cite commands
+ | Biblatex -- output biblatex cite commands
+ deriving (Show, Read, Eq)
+
-- | Methods for obfuscating email addresses in HTML.
data ObfuscationMethod = NoObfuscation
| ReferenceObfuscation
@@ -491,11 +471,17 @@ data WriterOptions = WriterOptions
, writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
, writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
, writerWrapText :: Bool -- ^ Wrap text to line length
+ , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
, writerLiterateHaskell :: Bool -- ^ Write as literate haskell
, writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
, writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
, writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file
, writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
+ , writerCiteMethod :: CiteMethod -- ^ How to print cites
+ , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
+ , writerHtml5 :: Bool -- ^ Produce HTML5
+ , writerChapters :: Bool -- ^ Use "chapter" for top-level sects
+ , writerListings :: Bool -- ^ Use listings package for code
} deriving Show
-- | Default writer options.
@@ -517,11 +503,17 @@ defaultWriterOptions =
, writerStrictMarkdown = False
, writerReferenceLinks = False
, writerWrapText = True
+ , writerColumns = 72
, writerLiterateHaskell = False
, writerEmailObfuscation = JavascriptObfuscation
, writerIdentifierPrefix = ""
, writerSourceDirectory = "."
, writerUserDataDir = Nothing
+ , writerCiteMethod = Citeproc
+ , writerBiblioFiles = []
+ , writerHtml5 = False
+ , writerChapters = False
+ , writerListings = False
}
--
@@ -537,11 +529,17 @@ inDirectory path action = do
setCurrentDirectory oldDir
return result
+-- | Get file path for data file, either from specified user data directory,
+-- or, if not found there, from Cabal data directory.
+findDataFile :: Maybe FilePath -> FilePath -> IO FilePath
+findDataFile Nothing f = getDataFileName f
+findDataFile (Just u) f = do
+ ex <- doesFileExist (u </> f)
+ if ex
+ then return (u </> f)
+ else getDataFileName f
+
-- | Read file from specified user data directory or, if not found there, from
-- Cabal data directory.
readDataFile :: Maybe FilePath -> FilePath -> IO String
-readDataFile userDir fname =
- case userDir of
- Nothing -> getDataFileName fname >>= UTF8.readFile
- Just u -> catch (UTF8.readFile $ u </> fname)
- (\_ -> getDataFileName fname >>= UTF8.readFile)
+readDataFile userDir fname = findDataFile userDir fname >>= UTF8.readFile
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index c8ddc3abf..b03e8c73f 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -72,7 +72,6 @@ import Text.ParserCombinators.Parsec
import Control.Monad (liftM, when, forM)
import System.FilePath
import Data.List (intercalate, intersperse)
-import Text.PrettyPrint (text, Doc)
import Text.XHtml (primHtml, Html)
import Data.ByteString.Lazy.UTF8 (ByteString, fromString)
import Text.Pandoc.Shared (readDataFile)
@@ -112,9 +111,6 @@ instance TemplateTarget ByteString where
instance TemplateTarget Html where
toTarget = primHtml
-instance TemplateTarget Doc where
- toTarget = text
-
-- | Renders a template
renderTemplate :: TemplateTarget a
=> [(String,String)] -- ^ Assoc. list of values for variables
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
index 96d6e6218..a77f92cdc 100644
--- a/src/Text/Pandoc/UTF8.hs
+++ b/src/Text/Pandoc/UTF8.hs
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Stability : alpha
Portability : portable
-UTF-8 aware string IO functions that will work with GHC 6.10 or 6.12.
+UTF-8 aware string IO functions that will work with GHC 6.10, 6.12, or 7.
-}
module Text.Pandoc.UTF8 ( readFile
, writeFile
@@ -34,15 +34,54 @@ module Text.Pandoc.UTF8 ( readFile
, putStrLn
, hPutStr
, hPutStrLn
+ , hGetContents
)
where
+
+#if MIN_VERSION_base(4,2,0)
+
+import System.IO hiding (readFile, writeFile, getContents,
+ putStr, putStrLn, hPutStr, hPutStrLn, hGetContents)
+import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn )
+import qualified System.IO as IO
+
+readFile :: FilePath -> IO String
+readFile f = do
+ h <- openFile f ReadMode
+ hGetContents h
+
+writeFile :: FilePath -> String -> IO ()
+writeFile f s = withFile f WriteMode $ \h -> hPutStr h s
+
+getContents :: IO String
+getContents = hGetContents stdin
+
+putStr :: String -> IO ()
+putStr s = hPutStr stdout s
+
+putStrLn :: String -> IO ()
+putStrLn s = hPutStrLn stdout s
+
+hPutStr :: Handle -> String -> IO ()
+hPutStr h s = hSetEncoding h utf8 >> IO.hPutStr h s
+
+hPutStrLn :: Handle -> String -> IO ()
+hPutStrLn h s = hSetEncoding h utf8 >> IO.hPutStrLn h s
+
+hGetContents :: Handle -> IO String
+hGetContents h = hSetEncoding h utf8_bom >> IO.hGetContents h
+
+#else
+
import qualified Data.ByteString as B
+import Codec.Binary.UTF8.String (encodeString)
import Data.ByteString.UTF8 (toString, fromString)
import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
import System.IO (Handle)
import Control.Monad (liftM)
+
bom :: B.ByteString
bom = B.pack [0xEF, 0xBB, 0xBF]
@@ -51,14 +90,17 @@ stripBOM s | bom `B.isPrefixOf` s = B.drop 3 s
stripBOM s = s
readFile :: FilePath -> IO String
-readFile = liftM (toString . stripBOM) . B.readFile
+readFile = liftM (toString . stripBOM) . B.readFile . encodeString
writeFile :: FilePath -> String -> IO ()
-writeFile f = B.writeFile f . fromString
+writeFile f = B.writeFile (encodeString f) . fromString
getContents :: IO String
getContents = liftM (toString . stripBOM) B.getContents
+hGetContents :: Handle -> IO String
+hGetContents h = liftM (toString . stripBOM) (B.hGetContents h)
+
putStr :: String -> IO ()
putStr = B.putStr . fromString
@@ -70,3 +112,5 @@ hPutStr h = B.hPutStr h . fromString
hPutStrLn :: Handle -> String -> IO ()
hPutStrLn h s = hPutStr h (s ++ "\n")
+
+#endif
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 395bc2d30..0f6e00a3b 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>
@@ -31,9 +32,9 @@ module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Printf ( printf )
-import Data.List ( isSuffixOf, intercalate, intersperse )
+import Data.List ( intercalate )
import Control.Monad.State
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Text.Pandoc.Pretty
import Text.Pandoc.Templates ( renderTemplate )
data WriterState =
@@ -56,15 +57,18 @@ writeConTeXt options document =
pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState String
pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do
+ let colwidth = if writerWrapText options
+ then Just $ writerColumns options
+ else Nothing
titletext <- if null title
then return ""
- else liftM render $ inlineListToConTeXt title
- authorstext <- mapM (liftM render . inlineListToConTeXt) authors
+ else liftM (render colwidth) $ inlineListToConTeXt title
+ authorstext <- mapM (liftM (render colwidth) . inlineListToConTeXt) authors
datetext <- if null date
then return ""
- else liftM render $ inlineListToConTeXt date
- body <- blockListToConTeXt blocks
- let main = render $ body $$ text ""
+ else liftM (render colwidth) $ inlineListToConTeXt date
+ body <- blockListToConTeXt blocks
+ let main = render colwidth $ body
let context = writerVariables options ++
[ ("toc", if writerTableOfContents options then "yes" else "")
, ("body", main)
@@ -92,6 +96,8 @@ escapeCharForConTeXt ch =
'#' -> "\\#"
'<' -> "\\letterless{}"
'>' -> "\\lettermore{}"
+ '[' -> "{[}"
+ ']' -> "{]}"
'_' -> "\\letterunderscore{}"
'\160' -> "~"
x -> [x]
@@ -102,32 +108,27 @@ stringToConTeXt = concatMap escapeCharForConTeXt
-- | Convert Pandoc block element to ConTeXt.
blockToConTeXt :: Block
- -> State WriterState BlockWrapper
-blockToConTeXt Null = return $ Reg empty
-blockToConTeXt (Plain lst) = do
- st <- get
- let options = stOptions st
- contents <- wrapTeXIfNeeded options False inlineListToConTeXt lst
- return $ Reg contents
+ -> State WriterState Doc
+blockToConTeXt Null = return empty
+blockToConTeXt (Plain lst) = inlineListToConTeXt lst
blockToConTeXt (Para [Image txt (src,_)]) = do
capt <- inlineListToConTeXt txt
- return $ Pad $ text "\\placefigure[here,nonumber]{" <> capt <>
- text "}{\\externalfigure[" <> text src <> text "]}"
+ return $ blankline $$ "\\placefigure[here,nonumber]" <> braces capt <>
+ braces ("\\externalfigure" <> brackets (text src)) <> blankline
blockToConTeXt (Para lst) = do
- st <- get
- let options = stOptions st
- contents <- wrapTeXIfNeeded options False inlineListToConTeXt lst
- return $ Pad contents
+ contents <- inlineListToConTeXt lst
+ return $ contents <> blankline
blockToConTeXt (BlockQuote lst) = do
contents <- blockListToConTeXt lst
- return $ Pad $ text "\\startblockquote" $$ contents $$ text "\\stopblockquote"
-blockToConTeXt (CodeBlock _ str) =
- return $ Reg $ text $ "\\starttyping\n" ++ str ++ "\n\\stoptyping\n"
- -- \n because \stoptyping can't have anything after it, inc. }
-blockToConTeXt (RawHtml _) = return $ Reg empty
-blockToConTeXt (BulletList lst) = do
+ return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline
+blockToConTeXt (CodeBlock _ str) =
+ return $ "\\starttyping" <> cr <> flush (text str) <> cr <> "\\stoptyping" $$ blankline
+ -- blankline because \stoptyping can't have anything after it, inc. '}'
+blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline
+blockToConTeXt (RawBlock _ _ ) = return empty
+blockToConTeXt (BulletList lst) = do
contents <- mapM listItemToConTeXt lst
- return $ Pad $ text "\\startitemize" $$ vcat contents $$ text "\\stopitemize"
+ return $ "\\startitemize" $$ vcat contents $$ text "\\stopitemize" <> blankline
blockToConTeXt (OrderedList (start, style', delim) lst) = do
st <- get
let level = stOrderedListLevel st
@@ -159,20 +160,23 @@ blockToConTeXt (OrderedList (start, style', delim) lst) = do
LowerAlpha -> "[a]"
UpperAlpha -> "[A]"
let specs = style'' ++ specs2
- return $ Pad $ text ("\\startitemize" ++ specs) $$ vcat contents $$
- text "\\stopitemize"
+ return $ "\\startitemize" <> text specs $$ vcat contents $$
+ "\\stopitemize" <> blankline
blockToConTeXt (DefinitionList lst) =
- mapM defListItemToConTeXt lst >>= return . Pad . wrappedBlocksToDoc
-blockToConTeXt HorizontalRule = return $ Pad $ text "\\thinrule"
+ liftM vcat $ mapM defListItemToConTeXt lst
+blockToConTeXt HorizontalRule = return $ "\\thinrule" <> blankline
blockToConTeXt (Header level lst) = do
contents <- inlineListToConTeXt lst
st <- get
let opts = stOptions st
let base = if writerNumberSections opts then "section" else "subject"
- return $ Pad $ if level >= 1 && level <= 5
- then char '\\' <> text (concat (replicate (level - 1) "sub")) <>
- text base <> char '{' <> contents <> char '}'
- else contents
+ let level' = if writerChapters opts then level - 1 else level
+ return $ if level' >= 1 && level' <= 5
+ then char '\\' <> text (concat (replicate (level' - 1) "sub")) <>
+ text base <> char '{' <> contents <> char '}' <> blankline
+ else if level' == 0
+ then "\\chapter{" <> contents <> "}"
+ else contents <> blankline
blockToConTeXt (Table caption aligns widths heads rows) = do
let colDescriptor colWidth alignment = (case alignment of
AlignLeft -> 'l'
@@ -186,81 +190,87 @@ blockToConTeXt (Table caption aligns widths heads rows) = do
zipWith colDescriptor widths aligns)
headers <- if all null heads
then return empty
- else liftM ($$ text "\\HL") $ tableRowToConTeXt heads
+ else liftM ($$ "\\HL") $ tableRowToConTeXt heads
captionText <- inlineListToConTeXt caption
let captionText' = if null caption then text "none" else captionText
rows' <- mapM tableRowToConTeXt rows
- return $ Pad $ text "\\placetable[here]{" <> captionText' <> char '}' $$
- text "\\starttable[" <> text colDescriptors <> char ']' $$
- text "\\HL" $$ headers $$
- vcat rows' $$ text "\\HL\n\\stoptable"
+ return $ "\\placetable[here]" <> braces captionText' $$
+ "\\starttable" <> brackets (text colDescriptors) $$
+ "\\HL" $$ headers $$
+ vcat rows' $$ "\\HL" $$ "\\stoptable" <> blankline
tableRowToConTeXt :: [[Block]] -> State WriterState Doc
tableRowToConTeXt cols = do
cols' <- mapM blockListToConTeXt cols
- return $ (vcat (map (text "\\NC " <>) cols')) $$
- text "\\NC\\AR"
+ return $ (vcat (map ("\\NC " <>) cols')) $$ "\\NC\\AR"
listItemToConTeXt :: [Block] -> State WriterState Doc
listItemToConTeXt list = blockListToConTeXt list >>=
- return . (text "\\item" $$) . (nest 2)
+ return . ("\\item" $$) . (nest 2)
-defListItemToConTeXt :: ([Inline], [[Block]]) -> State WriterState BlockWrapper
+defListItemToConTeXt :: ([Inline], [[Block]]) -> State WriterState Doc
defListItemToConTeXt (term, defs) = do
term' <- inlineListToConTeXt term
- def' <- liftM (vcat . intersperse (text "")) $ mapM blockListToConTeXt defs
- return $ Pad $ text "\\startdescr{" <> term' <> char '}' $$ def' $$ text "\\stopdescr"
+ def' <- liftM vsep $ mapM blockListToConTeXt defs
+ return $ "\\startdescr" <> braces term' $$ nest 2 def' $$
+ "\\stopdescr" <> blankline
-- | Convert list of block elements to ConTeXt.
blockListToConTeXt :: [Block] -> State WriterState Doc
-blockListToConTeXt lst = mapM blockToConTeXt lst >>= return . wrappedBlocksToDoc
+blockListToConTeXt lst = liftM vcat $ mapM blockToConTeXt lst
-- | Convert list of inline elements to ConTeXt.
inlineListToConTeXt :: [Inline] -- ^ Inlines to convert
-> State WriterState Doc
-inlineListToConTeXt lst = mapM inlineToConTeXt lst >>= return . hcat
+inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt lst
-- | Convert inline element to ConTeXt
inlineToConTeXt :: Inline -- ^ Inline to convert
-> State WriterState Doc
inlineToConTeXt (Emph lst) = do
contents <- inlineListToConTeXt lst
- return $ text "{\\em " <> contents <> char '}'
+ return $ braces $ "\\em " <> contents
inlineToConTeXt (Strong lst) = do
contents <- inlineListToConTeXt lst
- return $ text "{\\bf " <> contents <> char '}'
+ return $ braces $ "\\bf " <> contents
inlineToConTeXt (Strikeout lst) = do
contents <- inlineListToConTeXt lst
- return $ text "\\overstrikes{" <> contents <> char '}'
+ return $ "\\overstrikes" <> braces contents
inlineToConTeXt (Superscript lst) = do
contents <- inlineListToConTeXt lst
- return $ text "\\high{" <> contents <> char '}'
+ return $ "\\high" <> braces contents
inlineToConTeXt (Subscript lst) = do
contents <- inlineListToConTeXt lst
- return $ text "\\low{" <> contents <> char '}'
+ return $ "\\low" <> braces contents
inlineToConTeXt (SmallCaps lst) = do
contents <- inlineListToConTeXt lst
- return $ text "{\\sc " <> contents <> char '}'
-inlineToConTeXt (Code str) = return $ text $ "\\type{" ++ str ++ "}"
+ return $ braces $ "\\sc " <> contents
+inlineToConTeXt (Code _ str) | not ('{' `elem` str || '}' `elem` str) =
+ return $ "\\type" <> braces (text str)
+inlineToConTeXt (Code _ str) =
+ return $ "\\mono" <> braces (text $ stringToConTeXt str)
inlineToConTeXt (Quoted SingleQuote lst) = do
contents <- inlineListToConTeXt lst
- return $ text "\\quote{" <> contents <> char '}'
+ return $ "\\quote" <> braces contents
inlineToConTeXt (Quoted DoubleQuote lst) = do
contents <- inlineListToConTeXt lst
- return $ text "\\quotation{" <> contents <> char '}'
+ return $ "\\quotation" <> braces contents
inlineToConTeXt (Cite _ lst) = inlineListToConTeXt lst
inlineToConTeXt Apostrophe = return $ char '\''
-inlineToConTeXt EmDash = return $ text "---"
-inlineToConTeXt EnDash = return $ text "--"
-inlineToConTeXt Ellipses = return $ text "\\ldots{}"
+inlineToConTeXt EmDash = return "---"
+inlineToConTeXt EnDash = return "--"
+inlineToConTeXt Ellipses = return "\\ldots{}"
inlineToConTeXt (Str str) = return $ text $ stringToConTeXt str
-inlineToConTeXt (Math InlineMath str) = return $ char '$' <> text str <> char '$'
-inlineToConTeXt (Math DisplayMath str) = return $ text "\\startformula " <> text str <> text " \\stopformula"
-inlineToConTeXt (TeX str) = return $ text str
-inlineToConTeXt (HtmlInline _) = return empty
-inlineToConTeXt (LineBreak) = return $ text "\\crlf\n"
-inlineToConTeXt Space = return $ char ' '
-inlineToConTeXt (Link [Code str] (src, tit)) = -- since ConTeXt has its own
+inlineToConTeXt (Math InlineMath str) =
+ return $ char '$' <> text str <> char '$'
+inlineToConTeXt (Math DisplayMath str) =
+ return $ text "\\startformula " <> text str <> text " \\stopformula"
+inlineToConTeXt (RawInline "context" str) = return $ text str
+inlineToConTeXt (RawInline "tex" str) = return $ text str
+inlineToConTeXt (RawInline _ _) = return empty
+inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr
+inlineToConTeXt Space = return space
+inlineToConTeXt (Link [Code _ str] (src, tit)) = -- since ConTeXt has its own
inlineToConTeXt (Link [Str str] (src, tit)) -- way of printing links...
inlineToConTeXt (Link txt (src, _)) = do
st <- get
@@ -268,15 +278,12 @@ inlineToConTeXt (Link txt (src, _)) = do
put $ st {stNextRef = next + 1}
let ref = show next
label <- inlineListToConTeXt txt
- return $ text "\\useURL[" <> text ref <> text "][" <> text src <>
- text "][][" <> label <> text "]\\from[" <> text ref <> char ']'
+ return $ "\\useURL" <> brackets (text ref) <> brackets (text src) <>
+ brackets empty <> brackets label <>
+ "\\from" <> brackets (text ref)
inlineToConTeXt (Image _ (src, _)) = do
- return $ text "{\\externalfigure[" <> text src <> text "]}"
+ return $ braces $ "\\externalfigure" <> brackets (text src)
inlineToConTeXt (Note contents) = do
contents' <- blockListToConTeXt contents
- let rawnote = stripTrailingNewlines $ render contents'
- -- note: a \n before } is needed when note ends with a \stoptyping
- let optNewline = "\\stoptyping" `isSuffixOf` rawnote
- return $ text "\\footnote{" <>
- text rawnote <> (if optNewline then char '\n' else empty) <> char '}'
-
+ return $ text "\\footnote{" <>
+ nest 2 contents' <> char '}'
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
index 5223259eb..9d09d46e3 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -33,15 +33,15 @@ import Text.Pandoc.XML
import Text.Pandoc.Shared
import Text.Pandoc.Templates (renderTemplate)
import Text.Pandoc.Readers.TeXMath
-import Data.List ( isPrefixOf, intercalate )
+import Data.List ( isPrefixOf, intercalate, isSuffixOf )
import Data.Char ( toLower )
-import Text.PrettyPrint.HughesPJ hiding ( Str )
import Text.Pandoc.Highlighting (languages, languagesByExtension)
+import Text.Pandoc.Pretty
-- | Convert list of authors to a docbook <author> section
authorToDocbook :: WriterOptions -> [Inline] -> Doc
authorToDocbook opts name' =
- let name = render $ inlinesToDocbook opts name'
+ let name = render Nothing $ inlinesToDocbook opts name'
in if ',' `elem` name
then -- last name first
let (lastname, rest) = break (==',') name
@@ -61,16 +61,24 @@ authorToDocbook opts name' =
-- | Convert Pandoc document to string in Docbook format.
writeDocbook :: WriterOptions -> Pandoc -> String
writeDocbook opts (Pandoc (Meta tit auths dat) blocks) =
- let title = wrap opts tit
+ let title = inlinesToDocbook opts tit
authors = map (authorToDocbook opts) auths
date = inlinesToDocbook opts dat
elements = hierarchicalize blocks
- main = render $ vcat (map (elementToDocbook opts) elements)
+ colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ render' = render colwidth
+ opts' = if "</book>" `isSuffixOf`
+ (removeTrailingSpace $ writerTemplate opts)
+ then opts{ writerChapters = True }
+ else opts
+ main = render' $ vcat (map (elementToDocbook opts') elements)
context = writerVariables opts ++
[ ("body", main)
- , ("title", render title)
- , ("date", render date) ] ++
- [ ("author", render a) | a <- authors ]
+ , ("title", render' title)
+ , ("date", render' date) ] ++
+ [ ("author", render' a) | a <- authors ]
in if writerStandalone opts
then renderTemplate context $ writerTemplate opts
else main
@@ -83,9 +91,12 @@ elementToDocbook opts (Sec _ _num id' title elements) =
let elements' = if null elements
then [Blk (Para [])]
else elements
- in inTags True "section" [("id",id')] $
- inTagsSimple "title" (wrap opts title) $$
- vcat (map (elementToDocbook opts) elements')
+ tag = if writerChapters opts
+ then "chapter"
+ else "section"
+ in inTags True tag [("id",id')] $
+ inTagsSimple "title" (inlinesToDocbook opts title) $$
+ vcat (map (elementToDocbook opts{ writerChapters = False }) elements')
-- | Convert a list of Pandoc blocks to Docbook.
blocksToDocbook :: WriterOptions -> [Block] -> Doc
@@ -123,7 +134,7 @@ listItemToDocbook opts item =
blockToDocbook :: WriterOptions -> Block -> Doc
blockToDocbook _ Null = empty
blockToDocbook _ (Header _ _) = empty -- should not occur after hierarchicalize
-blockToDocbook opts (Plain lst) = wrap opts lst
+blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst
blockToDocbook opts (Para [Image txt (src,_)]) =
let capt = inlinesToDocbook opts txt
in inTagsIndented "figure" $
@@ -132,12 +143,13 @@ blockToDocbook opts (Para [Image txt (src,_)]) =
(inTagsIndented "imageobject"
(selfClosingTag "imagedata" [("fileref",src)])) $$
inTagsSimple "textobject" (inTagsSimple "phrase" capt))
-blockToDocbook opts (Para lst) = inTagsIndented "para" $ wrap opts lst
+blockToDocbook opts (Para lst) =
+ inTagsIndented "para" $ inlinesToDocbook opts lst
blockToDocbook opts (BlockQuote blocks) =
inTagsIndented "blockquote" $ blocksToDocbook opts blocks
blockToDocbook _ (CodeBlock (_,classes,_) str) =
- text ("<screen" ++ lang ++ ">\n") <>
- text (escapeStringForXML str) <> text "\n</screen>"
+ text ("<screen" ++ lang ++ ">") <> cr <>
+ flush (text (escapeStringForXML str) <> cr <> text "</screen>")
where lang = if null langs
then ""
else " language=\"" ++ escapeStringForXML (head langs) ++
@@ -167,7 +179,10 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
in inTags True "orderedlist" attribs items
blockToDocbook opts (DefinitionList lst) =
inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
-blockToDocbook _ (RawHtml str) = text str -- raw XML block
+blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block
+-- we allow html for compatibility with earlier versions of pandoc
+blockToDocbook _ (RawBlock "html" str) = text str -- raw XML block
+blockToDocbook _ (RawBlock _ _) = empty
blockToDocbook _ HorizontalRule = empty -- not semantic
blockToDocbook opts (Table caption aligns widths headers rows) =
let alignStrings = map alignmentToString aligns
@@ -214,12 +229,6 @@ tableItemToDocbook opts tag align item =
let attrib = [("align", align)]
in inTags True tag attrib $ vcat $ map (blockToDocbook opts) item
--- | Take list of inline elements and return wrapped doc.
-wrap :: WriterOptions -> [Inline] -> Doc
-wrap opts lst = if writerWrapText opts
- then fsep $ map (inlinesToDocbook opts) (splitBy Space lst)
- else inlinesToDocbook opts lst
-
-- | Convert a list of inline elements to Docbook.
inlinesToDocbook :: WriterOptions -> [Inline] -> Doc
inlinesToDocbook opts lst = hcat $ map (inlineToDocbook opts) lst
@@ -249,22 +258,21 @@ inlineToDocbook _ Apostrophe = char '\''
inlineToDocbook _ Ellipses = text "…"
inlineToDocbook _ EmDash = text "—"
inlineToDocbook _ EnDash = text "–"
-inlineToDocbook _ (Code str) =
+inlineToDocbook _ (Code _ str) =
inTagsSimple "literal" $ text (escapeStringForXML str)
inlineToDocbook opts (Math _ str) = inlinesToDocbook opts $ readTeXMath str
-inlineToDocbook _ (TeX _) = empty
-inlineToDocbook _ (HtmlInline _) = empty
-inlineToDocbook _ LineBreak = text $ "<literallayout></literallayout>"
-inlineToDocbook _ Space = char ' '
+inlineToDocbook _ (RawInline _ _) = empty
+inlineToDocbook _ LineBreak = inTagsSimple "literallayout" empty
+inlineToDocbook _ Space = space
inlineToDocbook opts (Link txt (src, _)) =
if isPrefixOf "mailto:" src
then let src' = drop 7 src
emailLink = inTagsSimple "email" $ text $
escapeStringForXML $ src'
- in if txt == [Code src']
- then emailLink
- else inlinesToDocbook opts txt <+> char '(' <> emailLink <>
- char ')'
+ in case txt of
+ [Code _ s] | s == src' -> emailLink
+ _ -> inlinesToDocbook opts txt <+>
+ char '(' <> emailLink <> char ')'
else (if isPrefixOf "#" src
then inTags False "link" [("linkend", drop 1 src)]
else inTags False "ulink" [("url", src)]) $
@@ -275,6 +283,6 @@ inlineToDocbook _ (Image _ (src, tit)) =
else inTagsIndented "objectinfo" $
inTagsIndented "title" (text $ escapeStringForXML tit)
in inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $
- titleDoc $$ selfClosingTag "imagedata" [("fileref", src)]
+ titleDoc $$ selfClosingTag "imagedata" [("fileref", src)]
inlineToDocbook opts (Note contents) =
inTagsIndented "footnote" $ blocksToDocbook opts contents
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index deaa2fe33..33b8aa76a 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -39,6 +39,7 @@ import Codec.Archive.Zip
import System.Time
import Text.Pandoc.Shared hiding ( Element )
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import Control.Monad (liftM)
import Text.XML.Light hiding (ppTopElement)
import Text.Pandoc.UUID
@@ -69,7 +70,7 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
-- handle pictures
picsRef <- newIORef []
- Pandoc _ blocks <- liftM (processWith transformBlock) $ processWithM
+ Pandoc _ blocks <- liftM (bottomUp transformBlock) $ bottomUpM
(transformInlines (writerHTMLMathMethod opts) sourceDir picsRef) doc
pics <- readIORef picsRef
let readPicEntry (oldsrc, newsrc) = readEntry [] oldsrc >>= \e ->
@@ -232,13 +233,13 @@ transformInlines (MathML _) _ _ (x@(Math _ _) : xs) = do
mathml ++ "</ops:case><ops:default>" ++ fallback ++ "</ops:default>" ++
"</ops:switch>"
result = if "<math" `isPrefixOf` mathml then inOps else mathml
- return $ HtmlInline result : xs
-transformInlines _ _ _ (HtmlInline _ : xs) = return $ Str "" : xs
+ return $ RawInline "html" result : xs
+transformInlines _ _ _ (RawInline _ _ : xs) = return $ Str "" : xs
transformInlines _ _ _ (Link lab (_,_) : xs) = return $ lab ++ xs
transformInlines _ _ _ xs = return xs
transformBlock :: Block -> Block
-transformBlock (RawHtml _) = Null
+transformBlock (RawBlock _ _) = Null
transformBlock x = x
(!) :: Node t => (t -> Element) -> [(String, String)] -> t -> Element
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index d2a400c5c..ef14b6809 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -105,8 +105,8 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
toc <- if writerTableOfContents opts
then tableOfContents opts sects
else return Nothing
- let startSlide = RawHtml "<div class=\"slide\">\n"
- endSlide = RawHtml "</div>\n"
+ let startSlide = RawBlock "html" "<div class=\"slide\">\n"
+ endSlide = RawBlock "html" "</div>\n"
let cutUp (HorizontalRule : Header 1 ys : xs) = cutUp (Header 1 ys : xs)
cutUp (HorizontalRule : xs) = [endSlide, startSlide] ++ cutUp xs
cutUp (Header 1 ys : xs) = [endSlide, startSlide] ++
@@ -134,6 +134,8 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
MathML (Just url) ->
script !
[src url, thetype "text/javascript"] $ noHtml
+ MathJax url ->
+ script ! [src url, thetype "text/javascript"] $ noHtml
JsMath (Just url) ->
script !
[src url, thetype "text/javascript"] $ noHtml
@@ -168,6 +170,7 @@ inTemplate opts tit auths date toc body' newvars =
, ("pagetitle", topTitle')
, ("title", renderHtmlFragment tit)
, ("date", date') ] ++
+ [ ("html5","true") | writerHtml5 opts ] ++
(case toc of
Just t -> [ ("toc", renderHtmlFragment t)]
Nothing -> []) ++
@@ -187,7 +190,12 @@ tableOfContents opts sects = do
let tocList = catMaybes contents
return $ if null tocList
then Nothing
- else Just $ thediv ! [prefixedId opts' "TOC"] $ unordList tocList
+ else Just $
+ if writerHtml5 opts
+ then tag "nav" ! [prefixedId opts' "TOC"] $
+ unordList tocList
+ else thediv ! [prefixedId opts' "TOC"] $
+ unordList tocList
-- | Convert section number to string
showSecNum :: [Int] -> String
@@ -224,7 +232,10 @@ elementToHtml opts (Sec level num id' title' elements) = do
return $ if slides -- S5 gets confused by the extra divs around sections
then toHtmlFromList stuff
else if writerSectionDivs opts
- then thediv ! [prefixedId opts id'] << stuff
+ then if writerHtml5 opts
+ then tag "section" ! [prefixedId opts id']
+ << stuff
+ else thediv ! [prefixedId opts id'] << stuff
else toHtmlFromList stuff
-- | Convert list of Note blocks to a footnote <div>.
@@ -287,6 +298,12 @@ obfuscateChar char =
obfuscateString :: String -> String
obfuscateString = concatMap obfuscateChar . decodeCharacterReferences
+attrsToHtml :: WriterOptions -> Attr -> [HtmlAttr]
+attrsToHtml opts (id',classes',keyvals) =
+ [theclass (unwords classes') | not (null classes')] ++
+ [prefixedId opts id' | not (null id')] ++
+ map (\(x,y) -> strAttr x y) keyvals
+
-- | Convert Pandoc block element to HTML.
blockToHtml :: WriterOptions -> Block -> State WriterState Html
blockToHtml _ Null = return $ noHtml
@@ -294,22 +311,24 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
blockToHtml opts (Para [Image txt (s,tit)]) = do
img <- inlineToHtml opts (Image txt (s,tit))
capt <- inlineListToHtml opts txt
- return $ thediv ! [theclass "figure"] <<
- [img, paragraph ! [theclass "caption"] << capt]
+ return $ if writerHtml5 opts
+ then tag "figure" <<
+ [img, tag "figcaption" << capt]
+ else thediv ! [theclass "figure"] <<
+ [img, paragraph ! [theclass "caption"] << capt]
blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph)
-blockToHtml _ (RawHtml str) = return $ primHtml str
+blockToHtml _ (RawBlock "html" str) = return $ primHtml str
+blockToHtml _ (RawBlock _ _) = return noHtml
blockToHtml _ (HorizontalRule) = return $ hr
blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
let classes' = if writerLiterateHaskell opts
then classes
else filter (/= "literate") classes
- case highlightHtml (id',classes',keyvals) rawCode of
+ case highlightHtml False (id',classes',keyvals) rawCode of
Left _ -> -- change leading newlines into <br /> tags, because some
-- browsers ignore leading newlines in pre blocks
let (leadingBreaks, rawCode') = span (=='\n') rawCode
- attrs = [theclass (unwords classes') | not (null classes')] ++
- [prefixedId opts id' | not (null id')] ++
- map (\(x,y) -> strAttr x y) keyvals
+ attrs = attrsToHtml opts (id', classes', keyvals)
addBird = if "literate" `elem` classes'
then unlines . map ("> " ++) . lines
else unlines . lines
@@ -366,7 +385,17 @@ blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
then [start startnum]
else []) ++
(if numstyle /= DefaultStyle
- then [thestyle $ "list-style-type: " ++ numstyle' ++ ";"]
+ then if writerHtml5 opts
+ then [strAttr "type" $
+ case numstyle of
+ Decimal -> "1"
+ LowerAlpha -> "a"
+ UpperAlpha -> "A"
+ LowerRoman -> "i"
+ UpperRoman -> "I"
+ _ -> "1"]
+ else [thestyle $ "list-style-type: " ++
+ numstyle']
else [])
return $ ordList ! attribs $ contents
blockToHtml opts (DefinitionList lst) = do
@@ -379,28 +408,30 @@ blockToHtml opts (DefinitionList lst) = do
else []
return $ dlist ! attribs << concat contents
blockToHtml opts (Table capt aligns widths headers rows') = do
- let alignStrings = map alignmentToString aligns
captionDoc <- if null capt
then return noHtml
else inlineListToHtml opts capt >>= return . caption
let percent w = show (truncate (100*w) :: Integer) ++ "%"
+ let widthAttrs w = if writerHtml5 opts
+ then [thestyle $ "width: " ++ percent w]
+ else [width $ percent w]
let coltags = if all (== 0.0) widths
then noHtml
else concatHtml $ map
- (\w -> col ! [width $ percent w] $ noHtml) widths
+ (\w -> col ! (widthAttrs w) $ noHtml) widths
head' <- if all null headers
then return noHtml
- else liftM (thead <<) $ tableRowToHtml opts alignStrings 0 headers
+ else liftM (thead <<) $ tableRowToHtml opts aligns 0 headers
body' <- liftM (tbody <<) $
- zipWithM (tableRowToHtml opts alignStrings) [1..] rows'
+ zipWithM (tableRowToHtml opts aligns) [1..] rows'
return $ table $ captionDoc +++ coltags +++ head' +++ body'
tableRowToHtml :: WriterOptions
- -> [String]
+ -> [Alignment]
-> Int
-> [[Block]]
-> State WriterState Html
-tableRowToHtml opts alignStrings rownum cols' = do
+tableRowToHtml opts aligns rownum cols' = do
let mkcell = if rownum == 0 then th else td
let rowclass = case rownum of
0 -> "header"
@@ -408,7 +439,7 @@ tableRowToHtml opts alignStrings rownum cols' = do
_ -> "even"
cols'' <- sequence $ zipWith
(\alignment item -> tableItemToHtml opts mkcell alignment item)
- alignStrings cols'
+ aligns cols'
return $ tr ! [theclass rowclass] $ toHtmlFromList cols''
alignmentToString :: Alignment -> [Char]
@@ -420,12 +451,15 @@ alignmentToString alignment = case alignment of
tableItemToHtml :: WriterOptions
-> (Html -> Html)
- -> [Char]
+ -> Alignment
-> [Block]
-> State WriterState Html
tableItemToHtml opts tag' align' item = do
contents <- blockListToHtml opts item
- return $ tag' ! [align align'] $ contents
+ let alignAttrs = if writerHtml5 opts
+ then [thestyle $ "align: " ++ alignmentToString align']
+ else [align $ alignmentToString align']
+ return $ tag' ! alignAttrs $ contents
blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html
blockListToHtml opts lst =
@@ -449,7 +483,11 @@ inlineToHtml opts inline =
(Apostrophe) -> return $ stringToHtml "’"
(Emph lst) -> inlineListToHtml opts lst >>= return . emphasize
(Strong lst) -> inlineListToHtml opts lst >>= return . strong
- (Code str) -> return $ thecode << str
+ (Code attr str) -> case highlightHtml True attr str of
+ Left _ -> return
+ $ thecode ! (attrsToHtml opts attr)
+ $ stringToHtml str
+ Right h -> return h
(Strikeout lst) -> inlineListToHtml opts lst >>=
return . (thespan ! [thestyle "text-decoration: line-through;"])
(SmallCaps lst) -> inlineListToHtml opts lst >>=
@@ -464,8 +502,7 @@ inlineToHtml opts inline =
stringToHtml "”")
in do contents <- inlineListToHtml opts lst
return $ leftQuote +++ contents +++ rightQuote
- (Math t str) ->
- modify (\st -> st {stMath = True}) >>
+ (Math t str) -> modify (\st -> st {stMath = True}) >>
(case writerHTMLMathMethod opts of
LaTeXMathML _ ->
-- putting LaTeXMathML in container with class "LaTeX" prevents
@@ -487,7 +524,9 @@ inlineToHtml opts inline =
InlineMath -> m
DisplayMath -> br +++ m +++ br
GladTeX ->
- return $ primHtml $ "<EQ>" ++ str ++ "</EQ>"
+ return $ case t of
+ InlineMath -> primHtml $ "<EQ ENV=\"math\">" ++ str ++ "</EQ>"
+ DisplayMath -> primHtml $ "<EQ ENV=\"displaymath\">" ++ str ++ "</EQ>"
MathML _ -> do
let dt = if t == InlineMath
then DisplayInline
@@ -500,18 +539,23 @@ inlineToHtml opts inline =
Left _ -> inlineListToHtml opts
(readTeXMath str) >>= return .
(thespan ! [theclass "math"])
+ MathJax _ -> return $ primHtml $
+ case t of
+ InlineMath -> "\\(" ++ str ++ "\\)"
+ DisplayMath -> "\\[" ++ str ++ "\\]"
PlainMath -> do
x <- inlineListToHtml opts (readTeXMath str)
let m = thespan ! [theclass "math"] $ x
return $ case t of
InlineMath -> m
DisplayMath -> br +++ m +++ br )
- (TeX str) -> case writerHTMLMathMethod opts of
- LaTeXMathML _ -> do modify (\st -> st {stMath = True})
- return $ primHtml str
- _ -> return noHtml
- (HtmlInline str) -> return $ primHtml str
- (Link [Code str] (s,_)) | "mailto:" `isPrefixOf` s ->
+ (RawInline "latex" str) -> case writerHTMLMathMethod opts of
+ LaTeXMathML _ -> do modify (\st -> st {stMath = True})
+ return $ primHtml str
+ _ -> return noHtml
+ (RawInline "html" str) -> return $ primHtml str
+ (RawInline _ _) -> return noHtml
+ (Link [Code _ str] (s,_)) | "mailto:" `isPrefixOf` s ->
return $ obfuscateLink opts str s
(Link txt (s,_)) | "mailto:" `isPrefixOf` s -> do
linkText <- inlineListToHtml opts txt
@@ -551,7 +595,7 @@ blockListToNote :: WriterOptions -> String -> [Block] -> State WriterState Html
blockListToNote opts ref blocks =
-- If last block is Para or Plain, include the backlink at the end of
-- that block. Otherwise, insert a new Plain block with the backlink.
- let backlink = [HtmlInline $ " <a href=\"#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref ++
+ let backlink = [RawInline "html" $ " <a href=\"#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref ++
"\" class=\"footnoteBackLink\"" ++
" title=\"Jump back to footnote " ++ ref ++ "\">↩</a>"]
blocks' = if null blocks
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 720c00ac8..28a1e7174 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
@@ -29,13 +30,15 @@ Conversion of 'Pandoc' format into LaTeX.
-}
module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import Text.Pandoc.Shared
import Text.Pandoc.Templates
import Text.Printf ( printf )
-import Data.List ( (\\), isSuffixOf, isPrefixOf, intersperse )
-import Data.Char ( toLower )
+import Data.List ( (\\), isSuffixOf, isPrefixOf, intercalate, intersperse )
+import Data.Char ( toLower, isPunctuation )
import Control.Monad.State
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Text.Pandoc.Pretty
+import System.FilePath (dropExtension)
data WriterState =
WriterState { stInNote :: Bool -- @True@ if we're in a note
@@ -60,7 +63,7 @@ writeLaTeX options document =
stVerbInNote = False, stEnumerate = False,
stTable = False, stStrikeout = False, stSubscript = False,
stUrl = False, stGraphics = False,
- stLHS = False, stBook = False }
+ stLHS = False, stBook = writerChapters options }
pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
@@ -70,13 +73,34 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
"{report}" `isSuffixOf` x)
when (any usesBookClass (lines template)) $
modify $ \s -> s{stBook = True}
- titletext <- liftM render $ inlineListToLaTeX title
- authorsText <- mapM (liftM render . inlineListToLaTeX) authors
- dateText <- liftM render $ inlineListToLaTeX date
- body <- blockListToLaTeX blocks
- let main = render body
+ opts <- liftM stOptions get
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ titletext <- liftM (render colwidth) $ inlineListToLaTeX title
+ authorsText <- mapM (liftM (render colwidth) . inlineListToLaTeX) authors
+ dateText <- liftM (render colwidth) $ inlineListToLaTeX date
+ let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then
+ (blocks, [])
+ else case last blocks of
+ Header 1 il -> (init blocks, il)
+ _ -> (blocks, [])
+ body <- blockListToLaTeX blocks'
+ biblioTitle <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
+ let main = render colwidth body
st <- get
- let context = writerVariables options ++
+ let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
+ citecontext = case writerCiteMethod options of
+ Natbib -> [ ("biblio-files", biblioFiles)
+ , ("biblio-title", biblioTitle)
+ , ("natbib", "yes")
+ ]
+ Biblatex -> [ ("biblio-files", biblioFiles)
+ , ("biblio-title", biblioTitle)
+ , ("biblatex", "yes")
+ ]
+ _ -> []
+ context = writerVariables options ++
[ ("toc", if writerTableOfContents options then "yes" else "")
, ("body", main)
, ("title", titletext)
@@ -91,7 +115,10 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
[ ("url", "yes") | stUrl st ] ++
[ ("numbersections", "yes") | writerNumberSections options ] ++
[ ("lhs", "yes") | stLHS st ] ++
- [ ("graphics", "yes") | stGraphics st ]
+ [ ("graphics", "yes") | stGraphics st ] ++
+ [ ("book-class", "yes") | stBook st] ++
+ [ ("listings", "yes") | writerListings options ] ++
+ citecontext
return $ if writerStandalone options
then renderTemplate context template
else main
@@ -107,7 +134,13 @@ stringToLaTeX = escapeStringUsing latexEscapes
, ('|', "\\textbar{}")
, ('<', "\\textless{}")
, ('>', "\\textgreater{}")
+ , ('[', "{[}") -- to avoid interpretation as
+ , (']', "{]}") -- optional arguments
, ('\160', "~")
+ , ('\x2018', "`")
+ , ('\x2019', "'")
+ , ('\x201C', "``")
+ , ('\x201D', "''")
]
-- | Puts contents into LaTeX command.
@@ -118,49 +151,73 @@ inCmd cmd contents = char '\\' <> text cmd <> braces contents
-- (because it's illegal to have verbatim inside some command arguments)
deVerb :: [Inline] -> [Inline]
deVerb [] = []
-deVerb ((Code str):rest) =
- (TeX $ "\\texttt{" ++ stringToLaTeX str ++ "}"):(deVerb rest)
+deVerb ((Code _ str):rest) =
+ (RawInline "latex" $ "\\texttt{" ++ stringToLaTeX str ++ "}"):(deVerb rest)
deVerb (other:rest) = other:(deVerb rest)
-- | Convert Pandoc block element to LaTeX.
blockToLaTeX :: Block -- ^ Block to convert
-> State WriterState Doc
blockToLaTeX Null = return empty
-blockToLaTeX (Plain lst) = do
- st <- get
- let opts = stOptions st
- wrapTeXIfNeeded opts True inlineListToLaTeX lst
+blockToLaTeX (Plain lst) = inlineListToLaTeX lst
blockToLaTeX (Para [Image txt (src,tit)]) = do
capt <- inlineListToLaTeX txt
img <- inlineToLaTeX (Image txt (src,tit))
- return $ text "\\begin{figure}[htb]" $$ text "\\centering" $$ img $$
- (text "\\caption{" <> capt <> char '}') $$ text "\\end{figure}\n"
+ return $ "\\begin{figure}[htb]" $$ "\\centering" $$ img $$
+ ("\\caption{" <> capt <> char '}') $$ "\\end{figure}" $$ blankline
blockToLaTeX (Para lst) = do
- st <- get
- let opts = stOptions st
- result <- wrapTeXIfNeeded opts True inlineListToLaTeX lst
- return $ result <> char '\n'
+ result <- inlineListToLaTeX lst
+ return $ result <> blankline
blockToLaTeX (BlockQuote lst) = do
contents <- blockListToLaTeX lst
- return $ text "\\begin{quote}" $$ contents $$ text "\\end{quote}"
-blockToLaTeX (CodeBlock (_,classes,_) str) = do
+ return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
+blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
st <- get
env <- if writerLiterateHaskell (stOptions st) && "haskell" `elem` classes &&
"literate" `elem` classes
then do
modify $ \s -> s{ stLHS = True }
return "code"
- else if stInNote st
- then do
- modify $ \s -> s{ stVerbInNote = True }
- return "Verbatim"
- else return "verbatim"
- return $ text ("\\begin{" ++ env ++ "}\n") <> text str <>
- text ("\n\\end{" ++ env ++ "}")
-blockToLaTeX (RawHtml _) = return empty
+ else if writerListings (stOptions st)
+ then return "lstlisting"
+ else if stInNote st
+ then do
+ modify $ \s -> s{ stVerbInNote = True }
+ return "Verbatim"
+ else return "verbatim"
+ let params = if writerListings (stOptions st)
+ then take 1
+ [ "language=" ++ lang | lang <- classes
+ , lang `elem` ["ABAP","IDL","Plasm","ACSL","inform"
+ ,"POV","Ada","Java","Prolog","Algol"
+ ,"JVMIS","Promela","Ant","ksh","Python"
+ ,"Assembler","Lisp","R","Awk","Logo"
+ ,"Reduce","bash","make","Rexx","Basic"
+ ,"Mathematica","RSL","C","Matlab","Ruby"
+ ,"C++","Mercury","S","Caml","MetaPost"
+ ,"SAS","Clean","Miranda","Scilab","Cobol"
+ ,"Mizar","sh","Comal","ML","SHELXL","csh"
+ ,"Modula-2","Simula","Delphi","MuPAD"
+ ,"SQL","Eiffel","NASTRAN","tcl","Elan"
+ ,"Oberon-2","TeX","erlang","OCL"
+ ,"VBScript","Euphoria","Octave","Verilog"
+ ,"Fortran","Oz","VHDL","GCL","Pascal"
+ ,"VRML","Gnuplot","Perl","XML","Haskell"
+ ,"PHP","XSLT","HTML","PL/I"]
+ ] ++
+ [ key ++ "=" ++ attr | (key,attr) <- keyvalAttr ]
+ else []
+ printParams
+ | null params = empty
+ | otherwise = "[" <> hsep (intersperse "," (map text params)) <>
+ "]"
+ return $ "\\begin{" <> text env <> "}" <> printParams $$ flush (text str) $$
+ "\\end{" <> text env <> "}" $$ cr -- final cr needed because of footnotes
+blockToLaTeX (RawBlock "latex" x) = return $ text x <> blankline
+blockToLaTeX (RawBlock _ _) = return empty
blockToLaTeX (BulletList lst) = do
items <- mapM listItemToLaTeX lst
- return $ text "\\begin{itemize}" $$ vcat items $$ text "\\end{itemize}"
+ return $ "\\begin{itemize}" $$ vcat items $$ "\\end{itemize}"
blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
st <- get
let oldlevel = stOLLevel st
@@ -179,20 +236,19 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
map toLower (toRomanNumeral oldlevel) ++
"}{" ++ show (start - 1) ++ "}"
else empty
- return $ text "\\begin{enumerate}" <> exemplar $$ resetcounter $$
- vcat items $$ text "\\end{enumerate}"
+ return $ "\\begin{enumerate}" <> exemplar $$ resetcounter $$
+ vcat items $$ "\\end{enumerate}"
blockToLaTeX (DefinitionList lst) = do
items <- mapM defListItemToLaTeX lst
- return $ text "\\begin{description}" $$ vcat items $$
- text "\\end{description}"
-blockToLaTeX HorizontalRule = return $ text $
- "\\begin{center}\\rule{3in}{0.4pt}\\end{center}\n"
+ return $ "\\begin{description}" $$ vcat items $$ "\\end{description}"
+blockToLaTeX HorizontalRule = return $
+ "\\begin{center}\\rule{3in}{0.4pt}\\end{center}" $$ blankline
blockToLaTeX (Header level lst) = do
let lst' = deVerb lst
txt <- inlineListToLaTeX lst'
let noNote (Note _) = Str ""
noNote x = x
- let lstNoNotes = processWith noNote lst'
+ let lstNoNotes = bottomUp noNote lst'
-- footnotes in sections don't work unless you specify an optional
-- argument: \section[mysec]{mysec\footnote{blah}}
optional <- if lstNoNotes == lst'
@@ -202,30 +258,31 @@ blockToLaTeX (Header level lst) = do
return $ char '[' <> res <> char ']'
let stuffing = optional <> char '{' <> txt <> char '}'
book <- liftM stBook get
- return $ case (book, level) of
- (True, 1) -> text "\\chapter" <> stuffing <> char '\n'
- (True, 2) -> text "\\section" <> stuffing <> char '\n'
- (True, 3) -> text "\\subsection" <> stuffing <> char '\n'
- (True, 4) -> text "\\subsubsection" <> stuffing <> char '\n'
- (False, 1) -> text "\\section" <> stuffing <> char '\n'
- (False, 2) -> text "\\subsection" <> stuffing <> char '\n'
- (False, 3) -> text "\\subsubsection" <> stuffing <> char '\n'
- _ -> txt <> char '\n'
+ let level' = if book then level - 1 else level
+ let headerWith x y = text x <> y $$ blankline
+ return $ case level' of
+ 0 -> headerWith "\\chapter" stuffing
+ 1 -> headerWith "\\section" stuffing
+ 2 -> headerWith "\\subsection" stuffing
+ 3 -> headerWith "\\subsubsection" stuffing
+ 4 -> headerWith "\\paragraph" stuffing
+ 5 -> headerWith "\\subparagraph" stuffing
+ _ -> txt $$ blankline
blockToLaTeX (Table caption aligns widths heads rows) = do
headers <- if all null heads
then return empty
- else liftM ($$ text "\\hline") $ tableRowToLaTeX heads
+ else liftM ($$ "\\hline") $ (tableRowToLaTeX widths) heads
captionText <- inlineListToLaTeX caption
- rows' <- mapM tableRowToLaTeX rows
+ rows' <- mapM (tableRowToLaTeX widths) rows
let colDescriptors = concat $ zipWith toColDescriptor widths aligns
let tableBody = text ("\\begin{tabular}{" ++ colDescriptors ++ "}") $$
- headers $$ vcat rows' $$ text "\\end{tabular}"
- let centered txt = text "\\begin{center}" $$ txt $$ text "\\end{center}"
+ headers $$ vcat rows' $$ "\\end{tabular}"
+ let centered txt = "\\begin{center}" $$ txt $$ "\\end{center}"
modify $ \s -> s{ stTable = True }
return $ if isEmpty captionText
- then centered tableBody <> char '\n'
- else text "\\begin{table}[h]" $$ centered tableBody $$
- inCmd "caption" captionText $$ text "\\end{table}\n"
+ then centered tableBody $$ blankline
+ else "\\begin{table}[h]" $$ centered tableBody $$
+ inCmd "caption" captionText $$ "\\end{table}" $$ blankline
toColDescriptor :: Double -> Alignment -> String
toColDescriptor 0 align =
@@ -240,16 +297,19 @@ toColDescriptor width align = ">{\\PBS" ++
AlignRight -> "\\raggedleft"
AlignCenter -> "\\centering"
AlignDefault -> "\\raggedright") ++
- "\\hspace{0pt}}p{" ++ printf "%.2f" width ++
- "\\columnwidth}"
+ "\\hspace{0pt}}p{" ++ printf "%.2f" width ++ "\\columnwidth}"
blockListToLaTeX :: [Block] -> State WriterState Doc
blockListToLaTeX lst = mapM blockToLaTeX lst >>= return . vcat
-tableRowToLaTeX :: [[Block]] -> State WriterState Doc
-tableRowToLaTeX cols = mapM blockListToLaTeX cols >>=
- return . ($$ text "\\\\") . foldl (\row item -> row $$
- (if isEmpty row then text "" else text " & ") <> item) empty
+tableRowToLaTeX :: [Double] -> [[Block]] -> State WriterState Doc
+tableRowToLaTeX widths cols = do
+ renderedCells <- mapM blockListToLaTeX cols
+ let toCell 0 c = c
+ toCell w c = "\\parbox{" <> text (printf "%.2f" w) <>
+ "\\columnwidth}{" <> c <> cr <> "}"
+ let cells = zipWith toCell widths renderedCells
+ return $ (hcat $ intersperse (" & ") cells) <> "\\\\"
listItemToLaTeX :: [Block] -> State WriterState Doc
listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
@@ -258,8 +318,8 @@ listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
defListItemToLaTeX (term, defs) = do
term' <- inlineListToLaTeX $ deVerb term
- def' <- liftM (vcat . intersperse (text "")) $ mapM blockListToLaTeX defs
- return $ text "\\item[" <> term' <> text "]" $$ def'
+ def' <- liftM vsep $ mapM blockListToLaTeX defs
+ return $ "\\item" <> brackets term' $$ def'
-- | Convert list of inline elements to LaTeX.
inlineListToLaTeX :: [Inline] -- ^ Inlines to convert
@@ -292,60 +352,161 @@ inlineToLaTeX (Subscript lst) = do
return $ inCmd "textsubscr" contents
inlineToLaTeX (SmallCaps lst) =
inlineListToLaTeX (deVerb lst) >>= return . inCmd "textsc"
-inlineToLaTeX (Cite _ lst) =
- inlineListToLaTeX lst
-inlineToLaTeX (Code str) = do
+inlineToLaTeX (Cite cits lst) = do
+ st <- get
+ let opts = stOptions st
+ case writerCiteMethod opts of
+ Natbib -> citationsToNatbib cits
+ Biblatex -> citationsToBiblatex cits
+ _ -> inlineListToLaTeX lst
+
+inlineToLaTeX (Code _ str) = do
st <- get
when (stInNote st) $ modify $ \s -> s{ stVerbInNote = True }
let chr = ((enumFromTo '!' '~') \\ str) !! 0
- return $ text $ "\\verb" ++ [chr] ++ str ++ [chr]
+ if writerListings (stOptions st)
+ then return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr]
+ else return $ text $ "\\verb" ++ [chr] ++ str ++ [chr]
inlineToLaTeX (Quoted SingleQuote lst) = do
contents <- inlineListToLaTeX lst
let s1 = if (not (null lst)) && (isQuoted (head lst))
- then text "\\,"
- else empty
+ then "\\,"
+ else empty
let s2 = if (not (null lst)) && (isQuoted (last lst))
- then text "\\,"
+ then "\\,"
else empty
return $ char '`' <> s1 <> contents <> s2 <> char '\''
inlineToLaTeX (Quoted DoubleQuote lst) = do
contents <- inlineListToLaTeX lst
let s1 = if (not (null lst)) && (isQuoted (head lst))
- then text "\\,"
- else empty
+ then "\\,"
+ else empty
let s2 = if (not (null lst)) && (isQuoted (last lst))
- then text "\\,"
+ then "\\,"
else empty
- return $ text "``" <> s1 <> contents <> s2 <> text "''"
+ return $ "``" <> s1 <> contents <> s2 <> "''"
inlineToLaTeX Apostrophe = return $ char '\''
-inlineToLaTeX EmDash = return $ text "---"
-inlineToLaTeX EnDash = return $ text "--"
-inlineToLaTeX Ellipses = return $ text "\\ldots{}"
+inlineToLaTeX EmDash = return "---"
+inlineToLaTeX EnDash = return "--"
+inlineToLaTeX Ellipses = return "\\ldots{}"
inlineToLaTeX (Str str) = return $ text $ stringToLaTeX str
inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'
-inlineToLaTeX (Math DisplayMath str) = return $ text "\\[" <> text str <> text "\\]"
-inlineToLaTeX (TeX str) = return $ text str
-inlineToLaTeX (HtmlInline _) = return empty
-inlineToLaTeX (LineBreak) = return $ text "\\\\"
-inlineToLaTeX Space = return $ char ' '
+inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"
+inlineToLaTeX (RawInline "latex" str) = return $ text str
+inlineToLaTeX (RawInline "tex" str) = return $ text str
+inlineToLaTeX (RawInline _ _) = return empty
+inlineToLaTeX (LineBreak) = return "\\\\"
+inlineToLaTeX Space = return space
inlineToLaTeX (Link txt (src, _)) =
case txt of
- [Code x] | x == src -> -- autolink
+ [Code _ x] | x == src -> -- autolink
do modify $ \s -> s{ stUrl = True }
return $ text $ "\\url{" ++ x ++ "}"
_ -> do contents <- inlineListToLaTeX $ deVerb txt
- return $ text ("\\href{" ++ src ++ "}{") <> contents <>
- char '}'
+ return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <>
+ contents <> char '}'
inlineToLaTeX (Image _ (source, _)) = do
modify $ \s -> s{ stGraphics = True }
- return $ text $ "\\includegraphics{" ++ source ++ "}"
+ return $ "\\includegraphics" <> braces (text source)
inlineToLaTeX (Note contents) = do
- st <- get
- put (st {stInNote = True})
+ modify (\s -> s{stInNote = True})
contents' <- blockListToLaTeX contents
modify (\s -> s {stInNote = False})
- let rawnote = stripTrailingNewlines $ render contents'
-- note: a \n before } is needed when note ends with a Verbatim environment
- let optNewline = "\\end{Verbatim}" `isSuffixOf` rawnote
- return $ text "\\footnote{" <>
- text rawnote <> (if optNewline then char '\n' else empty) <> char '}'
+ return $ "\\footnote" <> braces (nest 2 contents')
+
+
+citationsToNatbib :: [Citation] -> State WriterState Doc
+citationsToNatbib (one:[])
+ = citeCommand c p s k
+ where
+ Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ , citationMode = m
+ }
+ = one
+ c = case m of
+ AuthorInText -> "citet"
+ SuppressAuthor -> "citeyearpar"
+ NormalCitation -> "citep"
+
+citationsToNatbib cits
+ | noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits
+ = citeCommand "citep" p s ks
+ where
+ noPrefix = and . map (null . citationPrefix)
+ noSuffix = and . map (null . citationSuffix)
+ ismode m = and . map (((==) m) . citationMode)
+ p = citationPrefix $ head $ cits
+ s = citationSuffix $ last $ cits
+ ks = intercalate ", " $ map citationId cits
+
+citationsToNatbib (c:cs) | citationMode c == AuthorInText = do
+ author <- citeCommand "citeauthor" [] [] (citationId c)
+ cits <- citationsToNatbib (c { citationMode = SuppressAuthor } : cs)
+ return $ author <+> cits
+
+citationsToNatbib cits = do
+ cits' <- mapM convertOne cits
+ return $ text "\\citetext{" <> foldl combineTwo empty cits' <> text "}"
+ where
+ combineTwo a b | isEmpty a = b
+ | otherwise = a <> text "; " <> b
+ convertOne Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ , citationMode = m
+ }
+ = case m of
+ AuthorInText -> citeCommand "citealt" p s k
+ SuppressAuthor -> citeCommand "citeyear" p s k
+ NormalCitation -> citeCommand "citealp" p s k
+
+citeCommand :: String -> [Inline] -> [Inline] -> String -> State WriterState Doc
+citeCommand c p s k = do
+ args <- citeArguments p s k
+ return $ text ("\\" ++ c) <> args
+
+citeArguments :: [Inline] -> [Inline] -> String -> State WriterState Doc
+citeArguments p s k = do
+ let s' = case s of
+ (Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r
+ (Str (x:xs) : r) | isPunctuation x -> Str xs : r
+ _ -> s
+ pdoc <- inlineListToLaTeX p
+ sdoc <- inlineListToLaTeX s'
+ let optargs = case (isEmpty pdoc, isEmpty sdoc) of
+ (True, True ) -> empty
+ (True, False) -> brackets sdoc
+ (_ , _ ) -> brackets pdoc <> brackets sdoc
+ return $ optargs <> braces (text k)
+
+citationsToBiblatex :: [Citation] -> State WriterState Doc
+citationsToBiblatex (one:[])
+ = citeCommand cmd p s k
+ where
+ Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ , citationMode = m
+ } = one
+ cmd = case m of
+ SuppressAuthor -> "autocite*"
+ AuthorInText -> "textcite"
+ NormalCitation -> "autocite"
+
+citationsToBiblatex (c:cs) = do
+ args <- mapM convertOne (c:cs)
+ return $ text cmd <> foldl (<>) empty args
+ where
+ cmd = case citationMode c of
+ AuthorInText -> "\\textcites"
+ _ -> "\\autocites"
+ convertOne Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ }
+ = citeArguments p s k
+
+citationsToBiblatex _ = return empty
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index a46a18893..78b9274d6 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -35,7 +35,7 @@ import Text.Pandoc.Shared
import Text.Pandoc.Readers.TeXMath
import Text.Printf ( printf )
import Data.List ( isPrefixOf, intersperse, intercalate )
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Text.Pandoc.Pretty
import Control.Monad.State
type Notes = [[Block]]
@@ -52,27 +52,31 @@ pandocToMan opts (Pandoc (Meta title authors date) blocks) = do
titleText <- inlineListToMan opts title
authors' <- mapM (inlineListToMan opts) authors
date' <- inlineListToMan opts date
- let (cmdName, rest) = break (== ' ') $ render titleText
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ let render' = render colwidth
+ let (cmdName, rest) = break (== ' ') $ render' titleText
let (title', section) = case reverse cmdName of
(')':d:'(':xs) | d `elem` ['0'..'9'] ->
(text (reverse xs), char d)
- xs -> (text (reverse xs), doubleQuotes empty)
+ xs -> (text (reverse xs), doubleQuotes empty)
let description = hsep $
map (doubleQuotes . text . removeLeadingTrailingSpace) $
- splitBy '|' rest
+ splitBy (== '|') rest
body <- blockListToMan opts blocks
notes <- liftM stNotes get
notes' <- notesToMan opts (reverse notes)
- let main = render $ body $$ notes' $$ text ""
+ let main = render' $ body $$ notes' $$ text ""
hasTables <- liftM stHasTables get
let context = writerVariables opts ++
[ ("body", main)
- , ("title", render title')
- , ("section", render section)
- , ("date", render date')
- , ("description", render description) ] ++
+ , ("title", render' title')
+ , ("section", render' section)
+ , ("date", render' date')
+ , ("description", render' description) ] ++
[ ("has-tables", "yes") | hasTables ] ++
- [ ("author", render a) | a <- authors' ]
+ [ ("author", render' a) | a <- authors' ]
if writerStandalone opts
then return $ renderTemplate context $ writerTemplate opts
else return main
@@ -89,7 +93,7 @@ notesToMan opts notes =
noteToMan :: WriterOptions -> Int -> [Block] -> State WriterState Doc
noteToMan opts num note = do
contents <- blockListToMan opts note
- let marker = text "\n.SS [" <> text (show num) <> char ']'
+ let marker = cr <> text ".SS " <> brackets (text (show num))
return $ marker $$ contents
-- | Association list of characters to escape.
@@ -136,14 +140,14 @@ blockToMan :: WriterOptions -- ^ Options
-> State WriterState Doc
blockToMan _ Null = return empty
blockToMan opts (Plain inlines) =
- liftM vcat $ mapM (wrapIfNeeded opts (inlineListToMan opts)) $
- splitSentences inlines
+ liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines
blockToMan opts (Para inlines) = do
- contents <- liftM vcat $ mapM (wrapIfNeeded opts (inlineListToMan opts)) $
+ contents <- liftM vcat $ mapM (inlineListToMan opts) $
splitSentences inlines
return $ text ".PP" $$ contents
-blockToMan _ (RawHtml _) = return empty
-blockToMan _ HorizontalRule = return $ text $ ".PP\n * * * * *"
+blockToMan _ (RawBlock "man" str) = return $ text str
+blockToMan _ (RawBlock _ _) = return empty
+blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *"
blockToMan opts (Header level inlines) = do
contents <- inlineListToMan opts inlines
let heading = case level of
@@ -256,7 +260,7 @@ definitionListItemToMan opts (label, defs) = do
mapM (\item -> blockToMan opts item) rest
first' <- blockToMan opts first
return $ first' $$ text ".RS" $$ rest' $$ text ".RE"
- return $ text ".TP\n.B " <> labelText $+$ contents
+ return $ text ".TP" $$ text ".B " <> labelText $$ contents
-- | Convert list of Pandoc block elements to man.
blockListToMan :: WriterOptions -- ^ Options
@@ -303,23 +307,25 @@ inlineToMan _ EmDash = return $ text "\\[em]"
inlineToMan _ EnDash = return $ text "\\[en]"
inlineToMan _ Apostrophe = return $ char '\''
inlineToMan _ Ellipses = return $ text "\\&..."
-inlineToMan _ (Code str) =
+inlineToMan _ (Code _ str) =
return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]"
inlineToMan _ (Str str) = return $ text $ escapeString str
inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str
inlineToMan opts (Math DisplayMath str) = do
contents <- inlineListToMan opts $ readTeXMath str
- return $ text ".RS" $$ contents $$ text ".RE"
-inlineToMan _ (TeX _) = return empty
-inlineToMan _ (HtmlInline _) = return empty
-inlineToMan _ (LineBreak) = return $ text "\n.PD 0\n.P\n.PD\n"
-inlineToMan _ Space = return $ char ' '
+ return $ cr <> text ".RS" $$ contents $$ text ".RE"
+inlineToMan _ (RawInline "man" str) = return $ text str
+inlineToMan _ (RawInline _ _) = return empty
+inlineToMan _ (LineBreak) = return $
+ cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr
+inlineToMan _ Space = return space
inlineToMan opts (Link txt (src, _)) = do
linktext <- inlineListToMan opts txt
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
- return $ if txt == [Code srcSuffix]
- then char '<' <> text srcSuffix <> char '>'
- else linktext <> text " (" <> text src <> char ')'
+ return $ case txt of
+ [Code _ s]
+ | s == srcSuffix -> char '<' <> text srcSuffix <> char '>'
+ _ -> linktext <> text " (" <> text src <> char ')'
inlineToMan opts (Image alternate (source, tit)) = do
let txt = if (null alternate) || (alternate == [Str ""]) ||
(alternate == [Str source]) -- to prevent autolinks
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 1b612006b..5e12c4aca 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
@@ -31,13 +32,13 @@ Markdown: <http://daringfireball.net/projects/markdown/>
-}
module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import Text.Pandoc.Templates (renderTemplate)
import Text.Pandoc.Shared
-import Text.Pandoc.Parsing
-import Text.Pandoc.Blocks
+import Text.Pandoc.Parsing hiding (blankline)
import Text.ParserCombinators.Parsec ( runParser, GenParser )
import Data.List ( group, isPrefixOf, find, intersperse, transpose )
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Text.Pandoc.Pretty
import Control.Monad.State
type Notes = [[Block]]
@@ -57,28 +58,28 @@ writeMarkdown opts document =
-- pictures, or inline formatting).
writePlain :: WriterOptions -> Pandoc -> String
writePlain opts document =
- evalState (pandocToMarkdown opts document') WriterState{ stNotes = []
- , stRefs = []
- , stPlain = True }
+ evalState (pandocToMarkdown opts{writerStrictMarkdown = True}
+ document') WriterState{ stNotes = []
+ , stRefs = []
+ , stPlain = True }
where document' = plainify document
plainify :: Pandoc -> Pandoc
-plainify = processWith go
- where go :: [Inline] -> [Inline]
- go (Emph xs : ys) = go xs ++ go ys
- go (Strong xs : ys) = go xs ++ go ys
- go (Strikeout xs : ys) = go xs ++ go ys
- go (Superscript xs : ys) = go xs ++ go ys
- go (Subscript xs : ys) = go xs ++ go ys
- go (SmallCaps xs : ys) = go xs ++ go ys
- go (Code s : ys) = Str s : go ys
- go (Math _ s : ys) = Str s : go ys
- go (TeX _ : ys) = Str "" : go ys
- go (HtmlInline _ : ys) = Str "" : go ys
- go (Link xs _ : ys) = go xs ++ go ys
- go (Image _ _ : ys) = go ys
- go (x : ys) = x : go ys
- go [] = []
+plainify = bottomUp go
+ where go :: Inline -> Inline
+ go (Emph xs) = SmallCaps xs
+ go (Strong xs) = SmallCaps xs
+ go (Strikeout xs) = SmallCaps xs
+ go (Superscript xs) = SmallCaps xs
+ go (Subscript xs) = SmallCaps xs
+ go (SmallCaps xs) = SmallCaps xs
+ go (Code _ s) = Str s
+ go (Math _ s) = Str s
+ go (RawInline _ _) = Str ""
+ go (Link xs _) = SmallCaps xs
+ go (Image xs _) = SmallCaps $ [Str "["] ++ xs ++ [Str "]"]
+ go (Cite _ cits) = SmallCaps cits
+ go x = x
-- | Return markdown representation of document.
pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String
@@ -96,15 +97,20 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
notes' <- notesToMarkdown opts (reverse $ stNotes st)
st' <- get -- note that the notes may contain refs
refs' <- refsToMarkdown opts (reverse $ stRefs st')
- let main = render $ foldl ($+$) empty $ [body, notes', refs']
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ let main = render colwidth $ body <>
+ (if isEmpty notes' then empty else blankline <> notes') <>
+ (if isEmpty refs' then empty else blankline <> refs')
let context = writerVariables opts ++
- [ ("toc", render toc)
+ [ ("toc", render colwidth toc)
, ("body", main)
- , ("title", render title')
- , ("date", render date')
+ , ("title", render colwidth title')
+ , ("date", render colwidth date')
] ++
[ ("titleblock", "yes") | titleblock ] ++
- [ ("author", render a) | a <- authors' ]
+ [ ("author", render colwidth a) | a <- authors' ]
if writerStandalone opts
then return $ renderTemplate context $ writerTemplate opts
else return main
@@ -112,29 +118,36 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
-- | Return markdown representation of reference key table.
refsToMarkdown :: WriterOptions -> Refs -> State WriterState Doc
refsToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat
-
+
-- | Return markdown representation of a reference key.
keyToMarkdown :: WriterOptions
-> ([Inline], (String, String))
-> State WriterState Doc
keyToMarkdown opts (label, (src, tit)) = do
label' <- inlineListToMarkdown opts label
- let tit' = if null tit then empty else text $ " \"" ++ tit ++ "\""
- return $ text " " <> char '[' <> label' <> char ']' <> text ": " <>
- text src <> tit'
+ let tit' = if null tit
+ then empty
+ else space <> "\"" <> text tit <> "\""
+ return $ nest 2 $ hang 2
+ ("[" <> label' <> "]:" <> space) (text src <> tit')
-- | Return markdown representation of notes.
notesToMarkdown :: WriterOptions -> [[Block]] -> State WriterState Doc
notesToMarkdown opts notes =
- mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>=
- return . vcat
+ mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>=
+ return . vsep
-- | Return markdown representation of a note.
noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc
noteToMarkdown opts num blocks = do
contents <- blockListToMarkdown opts blocks
- let marker = text "[^" <> text (show num) <> text "]:"
- return $ hang' marker (writerTabStop opts) contents
+ let num' = text $ show num
+ let marker = text "[^" <> num' <> text "]:"
+ let markerSize = 4 + offset num'
+ let spacer = case writerTabStop opts - markerSize of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ return $ hang (writerTabStop opts) (marker <> spacer) contents
-- | Escape special characters for Markdown.
escapeString :: String -> String
@@ -158,6 +171,22 @@ elementToListItem (Sec _ _ _ headerText subsecs) = [Plain headerText] ++
then []
else [BulletList $ map elementToListItem subsecs]
+attrsToMarkdown :: Attr -> Doc
+attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]
+ where attribId = case attribs of
+ ([],_,_) -> empty
+ (i,_,_) -> "#" <> text i
+ attribClasses = case attribs of
+ (_,[],_) -> empty
+ (_,cs,_) -> hsep $
+ map (text . ('.':))
+ cs
+ attribKeys = case attribs of
+ (_,_,[]) -> empty
+ (_,_,ks) -> hsep $
+ map (\(k,v) -> text k
+ <> "=\"" <> text v <> "\"") ks
+
-- | Ordered list start parser for use in Para below.
olMarker :: GenParser Char ParserState Char
olMarker = do (start, style', delim) <- anyOrderedListMarker
@@ -169,134 +198,139 @@ olMarker = do (start, style', delim) <- anyOrderedListMarker
-- | True if string begins with an ordered list marker
beginsWithOrderedListMarker :: String -> Bool
-beginsWithOrderedListMarker str =
- case runParser olMarker defaultParserState "para start" str of
- Left _ -> False
+beginsWithOrderedListMarker str =
+ case runParser olMarker defaultParserState "para start" (take 10 str) of
+ Left _ -> False
Right _ -> True
-wrappedMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
-wrappedMarkdown opts inlines = do
- let chunks = splitBy LineBreak inlines
- let chunks' = if null chunks
- then []
- else (map (++ [Str " "]) $ init chunks) ++ [last chunks]
- lns <- mapM (wrapIfNeeded opts (inlineListToMarkdown opts)) chunks'
- return $ vcat lns
-
-- | Convert Pandoc block element to markdown.
blockToMarkdown :: WriterOptions -- ^ Options
-> Block -- ^ Block element
-> State WriterState Doc
blockToMarkdown _ Null = return empty
-blockToMarkdown opts (Plain inlines) =
- wrappedMarkdown opts inlines
+blockToMarkdown opts (Plain inlines) = do
+ contents <- inlineListToMarkdown opts inlines
+ return $ contents <> cr
blockToMarkdown opts (Para inlines) = do
- contents <- wrappedMarkdown opts inlines
+ contents <- inlineListToMarkdown opts inlines
-- escape if para starts with ordered list marker
- let esc = if (not (writerStrictMarkdown opts)) &&
- beginsWithOrderedListMarker (render contents)
- then char '\\'
- else empty
- return $ esc <> contents <> text "\n"
-blockToMarkdown _ (RawHtml str) = do
st <- get
- if stPlain st
- then return empty
- else return $ text str
-blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n"
+ let esc = if (not (writerStrictMarkdown opts)) &&
+ not (stPlain st) &&
+ beginsWithOrderedListMarker (render Nothing contents)
+ then text "\\"
+ else empty
+ return $ esc <> contents <> blankline
+blockToMarkdown _ (RawBlock f str)
+ | f == "html" || f == "latex" || f == "tex" || f == "markdown" = do
+ st <- get
+ if stPlain st
+ then return empty
+ else return $ text str <> text "\n"
+blockToMarkdown _ (RawBlock _ _) = return empty
+blockToMarkdown _ HorizontalRule =
+ return $ blankline <> text "* * * * *" <> blankline
blockToMarkdown opts (Header level inlines) = do
contents <- inlineListToMarkdown opts inlines
st <- get
-- use setext style headers if in literate haskell mode.
-- ghc interprets '#' characters in column 1 as line number specifiers.
if writerLiterateHaskell opts || stPlain st
- then let len = length $ render contents
- in return $ contents <> text "\n" <>
- case level of
- 1 -> text $ replicate len '=' ++ "\n"
- 2 -> text $ replicate len '-' ++ "\n"
- _ -> empty
- else return $ text ((replicate level '#') ++ " ") <> contents <> text "\n"
-blockToMarkdown opts (CodeBlock (_,classes,_) str) | "haskell" `elem` classes &&
- "literate" `elem` classes &&
- writerLiterateHaskell opts =
- return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n"
-blockToMarkdown opts (CodeBlock _ str) = return $
- (nest (writerTabStop opts) $ vcat $ map text (lines str)) <> text "\n"
+ then let len = offset contents
+ in return $ contents <> cr <>
+ (case level of
+ 1 -> text $ replicate len '='
+ 2 -> text $ replicate len '-'
+ _ -> empty) <> blankline
+ else return $
+ text ((replicate level '#') ++ " ") <> contents <> blankline
+blockToMarkdown opts (CodeBlock (_,classes,_) str)
+ | "haskell" `elem` classes && "literate" `elem` classes &&
+ writerLiterateHaskell opts =
+ return $ prefixed "> " (text str) <> blankline
+blockToMarkdown opts (CodeBlock attribs str) = return $
+ if writerStrictMarkdown opts || attribs == nullAttr
+ then nest (writerTabStop opts) (text str) <> blankline
+ else -- use delimited code block
+ flush (tildes <> space <> attrs <> cr <> text str <>
+ cr <> tildes) <> blankline
+ where tildes = text "~~~~"
+ attrs = attrsToMarkdown attribs
blockToMarkdown opts (BlockQuote blocks) = do
st <- get
-- if we're writing literate haskell, put a space before the bird tracks
-- so they won't be interpreted as lhs...
let leader = if writerLiterateHaskell opts
- then text . (" > " ++)
+ then " > "
else if stPlain st
- then text . (" " ++)
- else text . ("> " ++)
+ then " "
+ else "> "
contents <- blockListToMarkdown opts blocks
- return $ (vcat $ map leader $ lines $ render contents) <>
- text "\n"
+ return $ (prefixed leader contents) <> blankline
blockToMarkdown opts (Table caption aligns widths headers rows) = do
caption' <- inlineListToMarkdown opts caption
let caption'' = if null caption
then empty
- else text "" $+$ (text ": " <> caption')
+ else blankline <> ": " <> caption' <> blankline
headers' <- mapM (blockListToMarkdown opts) headers
let alignHeader alignment = case alignment of
- AlignLeft -> leftAlignBlock
- AlignCenter -> centerAlignBlock
- AlignRight -> rightAlignBlock
- AlignDefault -> leftAlignBlock
+ AlignLeft -> lblock
+ AlignCenter -> cblock
+ AlignRight -> rblock
+ AlignDefault -> lblock
rawRows <- mapM (mapM (blockListToMarkdown opts)) rows
let isSimple = all (==0) widths
- let numChars = maximum . map (length . render)
+ let numChars = maximum . map offset
let widthsInChars =
if isSimple
then map ((+2) . numChars) $ transpose (headers' : rawRows)
- else map (floor . (78 *)) widths
- let makeRow = hsepBlocks . (zipWith alignHeader aligns) .
- (zipWith docToBlock widthsInChars)
+ else map (floor . (fromIntegral (writerColumns opts) *)) widths
+ let makeRow = hcat . intersperse (lblock 1 (text " ")) .
+ (zipWith3 alignHeader aligns widthsInChars)
let rows' = map makeRow rawRows
let head' = makeRow headers'
- let maxRowHeight = maximum $ map heightOfBlock (head':rows')
- let underline = hsep $
- map (\width -> text $ replicate width '-') widthsInChars
+ let maxRowHeight = maximum $ map height (head':rows')
+ let underline = cat $ intersperse (text " ") $
+ map (\width -> text (replicate width '-')) widthsInChars
let border = if maxRowHeight > 1
- then text $ replicate (sum widthsInChars + (length widthsInChars - 1)) '-'
+ then text (replicate (sum widthsInChars +
+ length widthsInChars - 1) '-')
else if all null headers
then underline
else empty
let head'' = if all null headers
then empty
- else border $+$ blockToDoc head'
- let spacer = if maxRowHeight > 1
- then text ""
- else empty
- let body = vcat $ intersperse spacer $ map blockToDoc rows'
+ else border <> cr <> head'
+ let body = if maxRowHeight > 1
+ then vsep rows'
+ else vcat rows'
let bottom = if all null headers
then underline
else border
- return $ (nest 2 $ head'' $+$ underline $+$ body $+$
- bottom $+$ caption'') <> text "\n"
+ return $ nest 2 $ head'' $$ underline $$ body $$
+ bottom $$ blankline $$ caption'' $$ blankline
blockToMarkdown opts (BulletList items) = do
contents <- mapM (bulletListItemToMarkdown opts) items
- return $ (vcat contents) <> text "\n"
+ return $ cat contents <> blankline
blockToMarkdown opts (OrderedList attribs items) = do
let markers = orderedListMarkers attribs
let markers' = map (\m -> if length m < 3
then m ++ replicate (3 - length m) ' '
- else m) markers
+ else m) markers
contents <- mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $
- zip markers' items
- return $ (vcat contents) <> text "\n"
+ zip markers' items
+ return $ cat contents <> blankline
blockToMarkdown opts (DefinitionList items) = do
contents <- mapM (definitionListItemToMarkdown opts) items
- return $ (vcat contents) <> text "\n"
+ return $ cat contents <> blankline
-- | Convert bullet list item (list of blocks) to markdown.
bulletListItemToMarkdown :: WriterOptions -> [Block] -> State WriterState Doc
bulletListItemToMarkdown opts items = do
contents <- blockListToMarkdown opts items
- return $ hang' (text "- ") (writerTabStop opts) contents
+ let sps = replicate (writerTabStop opts - 2) ' '
+ let start = text ('-' : ' ' : sps)
+ return $ hang (writerTabStop opts) start $ contents <> cr
-- | Convert ordered list item (a list of blocks) to markdown.
orderedListItemToMarkdown :: WriterOptions -- ^ options
@@ -305,8 +339,11 @@ orderedListItemToMarkdown :: WriterOptions -- ^ options
-> State WriterState Doc
orderedListItemToMarkdown opts marker items = do
contents <- blockListToMarkdown opts items
- return $ hsep [nest (min (3 - length marker) 0) (text marker),
- nest (writerTabStop opts) contents]
+ let sps = case length marker - writerTabStop opts of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ let start = text marker <> sps
+ return $ hang (writerTabStop opts) start $ contents <> cr
-- | Convert definition list item (label, list of blocks) to markdown.
definitionListItemToMarkdown :: WriterOptions
@@ -316,17 +353,20 @@ definitionListItemToMarkdown opts (label, defs) = do
labelText <- inlineListToMarkdown opts label
let tabStop = writerTabStop opts
st <- get
- let leader = if stPlain st then empty else text " ~"
- contents <- liftM vcat $
- mapM (liftM ((leader $$) . nest tabStop . vcat) . mapM (blockToMarkdown opts)) defs
- return $ labelText $+$ contents
+ let leader = if stPlain st then " " else " ~"
+ let sps = case writerTabStop opts - 3 of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ defs' <- mapM (mapM (blockToMarkdown opts)) defs
+ let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'
+ return $ labelText <> cr <> contents <> cr
-- | Convert list of Pandoc block elements to markdown.
blockListToMarkdown :: WriterOptions -- ^ Options
-> [Block] -- ^ List of block elements
-> State WriterState Doc
blockListToMarkdown opts blocks =
- mapM (blockToMarkdown opts) blocks >>= return . vcat
+ mapM (blockToMarkdown opts) blocks >>= return . cat
-- | Get reference for target; if none exists, create unique one and return.
-- Prefer label if possible; otherwise, generate a unique key.
@@ -349,86 +389,132 @@ getReference label (src, tit) = do
-- | Convert list of Pandoc inline elements to markdown.
inlineListToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
inlineListToMarkdown opts lst =
- mapM (inlineToMarkdown opts) lst >>= return . hcat
+ mapM (inlineToMarkdown opts) lst >>= return . cat
+
+escapeSpaces :: Inline -> Inline
+escapeSpaces (Str s) = Str $ substitute " " "\\ " s
+escapeSpaces Space = Str "\\ "
+escapeSpaces x = x
-- | Convert Pandoc inline element to markdown.
inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc
inlineToMarkdown opts (Emph lst) = do
contents <- inlineListToMarkdown opts lst
- return $ char '*' <> contents <> char '*'
+ return $ "*" <> contents <> "*"
inlineToMarkdown opts (Strong lst) = do
contents <- inlineListToMarkdown opts lst
- return $ text "**" <> contents <> text "**"
+ return $ "**" <> contents <> "**"
inlineToMarkdown opts (Strikeout lst) = do
contents <- inlineListToMarkdown opts lst
- return $ text "~~" <> contents <> text "~~"
+ return $ "~~" <> contents <> "~~"
inlineToMarkdown opts (Superscript lst) = do
- contents <- inlineListToMarkdown opts lst
- let contents' = text $ substitute " " "\\ " $ render contents
- return $ char '^' <> contents' <> char '^'
+ let lst' = bottomUp escapeSpaces lst
+ contents <- inlineListToMarkdown opts lst'
+ return $ "^" <> contents <> "^"
inlineToMarkdown opts (Subscript lst) = do
- contents <- inlineListToMarkdown opts lst
- let contents' = text $ substitute " " "\\ " $ render contents
- return $ char '~' <> contents' <> char '~'
+ let lst' = bottomUp escapeSpaces lst
+ contents <- inlineListToMarkdown opts lst'
+ return $ "~" <> contents <> "~"
inlineToMarkdown opts (SmallCaps lst) = inlineListToMarkdown opts lst
inlineToMarkdown opts (Quoted SingleQuote lst) = do
contents <- inlineListToMarkdown opts lst
- return $ char '‘' <> contents <> char '’'
+ return $ "‘" <> contents <> "’"
inlineToMarkdown opts (Quoted DoubleQuote lst) = do
contents <- inlineListToMarkdown opts lst
- return $ char '“' <> contents <> char '”'
-inlineToMarkdown _ EmDash = return $ char '\8212'
-inlineToMarkdown _ EnDash = return $ char '\8211'
-inlineToMarkdown _ Apostrophe = return $ char '\8217'
-inlineToMarkdown _ Ellipses = return $ char '\8230'
-inlineToMarkdown _ (Code str) =
+ return $ "“" <> contents <> "”"
+inlineToMarkdown _ EmDash = return "\8212"
+inlineToMarkdown _ EnDash = return "\8211"
+inlineToMarkdown _ Apostrophe = return "\8217"
+inlineToMarkdown _ Ellipses = return "\8230"
+inlineToMarkdown opts (Code attr str) =
let tickGroups = filter (\s -> '`' `elem` s) $ group str
longest = if null tickGroups
then 0
else maximum $ map length tickGroups
marker = replicate (longest + 1) '`'
- spacer = if (longest == 0) then "" else " " in
- return $ text (marker ++ spacer ++ str ++ spacer ++ marker)
+ spacer = if (longest == 0) then "" else " "
+ attrs = if writerStrictMarkdown opts || attr == nullAttr
+ then empty
+ else attrsToMarkdown attr
+ in return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs
inlineToMarkdown _ (Str str) = do
st <- get
if stPlain st
then return $ text str
else return $ text $ escapeString str
-inlineToMarkdown _ (Math InlineMath str) = return $ char '$' <> text str <> char '$'
-inlineToMarkdown _ (Math DisplayMath str) = return $ text "$$" <> text str <> text "$$"
-inlineToMarkdown _ (TeX str) = return $ text str
-inlineToMarkdown _ (HtmlInline str) = return $ text str
-inlineToMarkdown _ (LineBreak) = return $ text " \n"
-inlineToMarkdown _ Space = return $ char ' '
-inlineToMarkdown opts (Cite _ cits) = inlineListToMarkdown opts cits
+inlineToMarkdown _ (Math InlineMath str) =
+ return $ "$" <> text str <> "$"
+inlineToMarkdown _ (Math DisplayMath str) =
+ return $ "$$" <> text str <> "$$"
+inlineToMarkdown _ (RawInline f str)
+ | f == "html" || f == "latex" || f == "tex" || f == "markdown" =
+ return $ text str
+inlineToMarkdown _ (RawInline _ _) = return empty
+inlineToMarkdown opts (LineBreak) = return $
+ if writerStrictMarkdown opts
+ then " " <> cr
+ else "\\" <> cr
+inlineToMarkdown _ Space = return space
+inlineToMarkdown opts (Cite (c:cs) lst)
+ | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst
+ | citationMode c == AuthorInText = do
+ suffs <- inlineListToMarkdown opts $ citationSuffix c
+ rest <- mapM convertOne cs
+ let inbr = suffs <+> joincits rest
+ br = if isEmpty inbr then empty else char '[' <> inbr <> char ']'
+ return $ text ("@" ++ citationId c) <+> br
+ | otherwise = do
+ cits <- mapM convertOne (c:cs)
+ return $ text "[" <> joincits cits <> text "]"
+ where
+ joincits = hcat . intersperse (text "; ") . filter (not . isEmpty)
+ convertOne Citation { citationId = k
+ , citationPrefix = pinlines
+ , citationSuffix = sinlines
+ , citationMode = m }
+ = do
+ pdoc <- inlineListToMarkdown opts pinlines
+ sdoc <- inlineListToMarkdown opts sinlines
+ let k' = text (modekey m ++ "@" ++ k)
+ r = case sinlines of
+ Str (y:_):_ | y `elem` ",;]@" -> k' <> sdoc
+ _ -> k' <+> sdoc
+ return $ pdoc <+> r
+ modekey SuppressAuthor = "-"
+ modekey _ = ""
+inlineToMarkdown _ (Cite _ _) = return $ text ""
inlineToMarkdown opts (Link txt (src', tit)) = do
linktext <- inlineListToMarkdown opts txt
- let linktitle = if null tit then empty else text $ " \"" ++ tit ++ "\""
+ let linktitle = if null tit
+ then empty
+ else text $ " \"" ++ tit ++ "\""
let src = unescapeURI src'
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
let useRefLinks = writerReferenceLinks opts
- let useAuto = null tit && txt == [Code srcSuffix]
+ let useAuto = case (tit,txt) of
+ ("", [Code _ s]) | s == srcSuffix -> True
+ _ -> False
ref <- if useRefLinks then getReference txt (src, tit) else return []
reftext <- inlineListToMarkdown opts ref
return $ if useAuto
- then char '<' <> text srcSuffix <> char '>'
+ then "<" <> text srcSuffix <> ">"
else if useRefLinks
- then let first = char '[' <> linktext <> char ']'
+ then let first = "[" <> linktext <> "]"
second = if txt == ref
- then text "[]"
- else char '[' <> reftext <> char ']'
+ then "[]"
+ else "[" <> reftext <> "]"
in first <> second
- else char '[' <> linktext <> char ']' <>
- char '(' <> text src <> linktitle <> char ')'
+ else "[" <> linktext <> "](" <>
+ text src <> linktitle <> ")"
inlineToMarkdown opts (Image alternate (source, tit)) = do
let txt = if (null alternate) || (alternate == [Str ""]) ||
(alternate == [Str source]) -- to prevent autolinks
then [Str "image"]
else alternate
- linkPart <- inlineToMarkdown opts (Link txt (unescapeURI source, tit))
- return $ char '!' <> linkPart
+ linkPart <- inlineToMarkdown opts (Link txt (source, tit))
+ return $ "!" <> linkPart
inlineToMarkdown _ (Note contents) = do
modify (\st -> st{ stNotes = contents : stNotes st })
st <- get
let ref = show $ (length $ stNotes st)
- return $ text "[^" <> text ref <> char ']'
+ return $ "[^" <> text ref <> "]"
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
index e8cb33caf..a7c7fc482 100644
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -96,7 +96,9 @@ blockToMediaWiki opts (Para inlines) = do
then "<p>" ++ contents ++ "</p>"
else contents ++ if null listLevel then "\n" else ""
-blockToMediaWiki _ (RawHtml str) = return str
+blockToMediaWiki _ (RawBlock "mediawiki" str) = return str
+blockToMediaWiki _ (RawBlock "html" str) = return str
+blockToMediaWiki _ (RawBlock _ _) = return ""
blockToMediaWiki _ HorizontalRule = return "\n-----\n"
@@ -360,7 +362,7 @@ inlineToMediaWiki _ Apostrophe = return "&rsquo;"
inlineToMediaWiki _ Ellipses = return "&hellip;"
-inlineToMediaWiki _ (Code str) =
+inlineToMediaWiki _ (Code _ str) =
return $ "<tt>" ++ (escapeString str) ++ "</tt>"
inlineToMediaWiki _ (Str str) = return $ escapeString str
@@ -368,9 +370,9 @@ inlineToMediaWiki _ (Str str) = return $ escapeString str
inlineToMediaWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
-- note: str should NOT be escaped
-inlineToMediaWiki _ (TeX _) = return ""
-
-inlineToMediaWiki _ (HtmlInline str) = return str
+inlineToMediaWiki _ (RawInline "mediawiki" str) = return str
+inlineToMediaWiki _ (RawInline "html" str) = return str
+inlineToMediaWiki _ (RawInline _ _) = return ""
inlineToMediaWiki _ (LineBreak) = return "<br />\n"
@@ -378,12 +380,12 @@ inlineToMediaWiki _ Space = return " "
inlineToMediaWiki opts (Link txt (src, _)) = do
label <- inlineListToMediaWiki opts txt
- if txt == [Code src] -- autolink
- then return src
- else if isURI src
- then return $ "[" ++ src ++ " " ++ label ++ "]"
- else return $ "[[" ++ src' ++ "|" ++ label ++ "]]"
- where src' = case src of
+ case txt of
+ [Code _ s] | s == src -> return src
+ _ -> if isURI src
+ then return $ "[" ++ src ++ " " ++ label ++ "]"
+ else return $ "[[" ++ src' ++ "|" ++ label ++ "]]"
+ where src' = case src of
'/':xs -> xs -- with leading / it's a
_ -> src -- link to a help page
inlineToMediaWiki opts (Image alt (source, tit)) = do
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs
index 3b5ea7481..d2b56cd17 100644
--- a/src/Text/Pandoc/Writers/Native.hs
+++ b/src/Text/Pandoc/Writers/Native.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
@@ -25,62 +26,53 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Stability : alpha
Portability : portable
-Utility functions and definitions used by the various Pandoc modules.
+Conversion of a 'Pandoc' document to a string representation.
+
+Note: If @writerStandalone@ is @False@, only the document body
+is represented; otherwise, the full 'Pandoc' document, including the
+metadata.
-}
module Text.Pandoc.Writers.Native ( writeNative )
where
-import Text.Pandoc.Shared ( WriterOptions )
-import Data.List ( intercalate )
+import Text.Pandoc.Shared ( WriterOptions(..) )
+import Data.List ( intersperse )
import Text.Pandoc.Definition
+import Text.Pandoc.Pretty
--- | Indent string as a block.
-indentBy :: Int -- ^ Number of spaces to indent the block
- -> Int -- ^ Number of spaces (rel to block) to indent first line
- -> String -- ^ Contents of block to indent
- -> String
-indentBy _ _ [] = ""
-indentBy num first str =
- let (firstLine:restLines) = lines str
- firstLineIndent = num + first
- in (replicate firstLineIndent ' ') ++ firstLine ++ "\n" ++
- (intercalate "\n" $ map ((replicate num ' ') ++ ) restLines)
-
--- | Prettyprint list of Pandoc blocks elements.
-prettyBlockList :: Int -- ^ Number of spaces to indent list of blocks
- -> [Block] -- ^ List of blocks
- -> String
-prettyBlockList indent [] = indentBy indent 0 "[]"
-prettyBlockList indent blocks = indentBy indent (-2) $ "[ " ++
- (intercalate "\n, " (map prettyBlock blocks)) ++ " ]"
+prettyList :: [Doc] -> Doc
+prettyList ds =
+ "[" <> (cat $ intersperse (cr <> ",") $ map (nest 1) ds) <> "]"
-- | Prettyprint Pandoc block element.
-prettyBlock :: Block -> String
-prettyBlock (BlockQuote blocks) = "BlockQuote\n " ++
- (prettyBlockList 2 blocks)
+prettyBlock :: Block -> Doc
+prettyBlock (BlockQuote blocks) =
+ "BlockQuote" $$ prettyList (map prettyBlock blocks)
prettyBlock (OrderedList attribs blockLists) =
- "OrderedList " ++ show attribs ++ "\n" ++ indentBy 2 0 ("[ " ++
- (intercalate ", " $ map (\blocks -> prettyBlockList 2 blocks)
- blockLists)) ++ " ]"
-prettyBlock (BulletList blockLists) = "BulletList\n" ++
- indentBy 2 0 ("[ " ++ (intercalate ", "
- (map (\blocks -> prettyBlockList 2 blocks) blockLists))) ++ " ]"
-prettyBlock (DefinitionList items) = "DefinitionList\n" ++
- indentBy 2 0 ("[ " ++ (intercalate "\n, "
- (map (\(term, defs) -> "(" ++ show term ++ ",\n" ++
- indentBy 3 0 ("[ " ++ (intercalate ", "
- (map (\blocks -> prettyBlockList 2 blocks) defs)) ++ "]") ++
- ")") items))) ++ " ]"
+ "OrderedList" <> space <> text (show attribs) $$
+ (prettyList $ map (prettyList . map prettyBlock) blockLists)
+prettyBlock (BulletList blockLists) =
+ "BulletList" $$
+ (prettyList $ map (prettyList . map prettyBlock) blockLists)
+prettyBlock (DefinitionList items) = "DefinitionList" $$
+ (prettyList $ map deflistitem items)
+ where deflistitem (term, defs) = "(" <> text (show term) <> "," <> cr <>
+ nest 1 (prettyList $ map (prettyList . map prettyBlock) defs) <> ")"
prettyBlock (Table caption aligns widths header rows) =
- "Table " ++ show caption ++ " " ++ show aligns ++ " " ++
- show widths ++ "\n" ++ prettyRow header ++ " [\n" ++
- (intercalate ",\n" (map prettyRow rows)) ++ " ]"
- where prettyRow cols = indentBy 2 0 ("[ " ++ (intercalate ", "
- (map (\blocks -> prettyBlockList 2 blocks)
- cols))) ++ " ]"
-prettyBlock block = show block
+ "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <>
+ text (show widths) $$
+ prettyRow header $$
+ prettyList (map prettyRow rows)
+ where prettyRow cols = prettyList (map (prettyList . map prettyBlock) cols)
+prettyBlock block = text $ show block
-- | Prettyprint Pandoc document.
writeNative :: WriterOptions -> Pandoc -> String
-writeNative _ (Pandoc meta blocks) = "Pandoc " ++ "(" ++ show meta ++
- ")\n" ++ (prettyBlockList 0 blocks) ++ "\n"
-
+writeNative opts (Pandoc meta blocks) =
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ withHead = if writerStandalone opts
+ then \bs -> text ("Pandoc " ++ "(" ++ show meta ++ ")") $$
+ bs $$ cr
+ else id
+ in render colwidth $ withHead $ prettyList $ map prettyBlock blocks
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
index 5aa0fd310..cf1be8755 100644
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -37,6 +37,7 @@ import System.Time
import Paths_pandoc ( getDataFileName )
import Text.Pandoc.Shared ( WriterOptions(..) )
import Text.Pandoc.Definition
+import Text.Pandoc.Generic
import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument )
import System.Directory
import Control.Monad (liftM)
@@ -63,8 +64,8 @@ writeODT mbRefOdt opts doc = do
-- handle pictures
picEntriesRef <- newIORef ([] :: [Entry])
let sourceDir = writerSourceDirectory opts
- doc' <- processWithM (transformPic sourceDir picEntriesRef) doc
- let newContents = writeOpenDocument opts doc'
+ doc' <- bottomUpM (transformPic sourceDir picEntriesRef) doc
+ let newContents = writeOpenDocument opts{writerWrapText = False} doc'
(TOD epochtime _) <- getClockTime
let contentEntry = toEntry "content.xml" epochtime $ fromString newContents
picEntries <- readIORef picEntriesRef
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 4e3979c07..b9444aac7 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -35,7 +35,7 @@ import Text.Pandoc.Shared
import Text.Pandoc.XML
import Text.Pandoc.Templates (renderTemplate)
import Text.Pandoc.Readers.TeXMath
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Text.Pandoc.Pretty
import Text.Printf ( printf )
import Control.Applicative ( (<$>) )
import Control.Arrow ( (***), (>>>) )
@@ -112,7 +112,9 @@ setInDefinitionList :: Bool -> State WriterState ()
setInDefinitionList b = modify $ \s -> s { stInDefinition = b }
inParagraphTags :: Doc -> Doc
-inParagraphTags = inTags False "text:p" [("text:style-name", "Text_20_body")]
+inParagraphTags d | isEmpty d = empty
+inParagraphTags d =
+ inTags False "text:p" [("text:style-name", "Text_20_body")] d
inParagraphTagsWithStyle :: String -> Doc -> Doc
inParagraphTagsWithStyle sty = inTags False "text:p" [("text:style-name", sty)]
@@ -167,7 +169,11 @@ writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
date'' <- inlinesToOpenDocument opts date
doc'' <- blocksToOpenDocument opts blocks
return (doc'', title'', authors'', date'')
- body' = render doc
+ colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ render' = render colwidth
+ body' = render' doc
styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
listStyle (n,l) = inTags True "text:list-style"
[("style:name", "L" ++ show n)] (vcat l)
@@ -176,10 +182,10 @@ writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
reverse $ styles ++ listStyles
context = writerVariables opts ++
[ ("body", body')
- , ("automatic-styles", render automaticStyles)
- , ("title", render title')
- , ("date", render date') ] ++
- [ ("author", render a) | a <- authors' ]
+ , ("automatic-styles", render' automaticStyles)
+ , ("title", render' title')
+ , ("date", render' date') ] ++
+ [ ("author", render' a) | a <- authors' ]
in if writerStandalone opts
then renderTemplate context $ writerTemplate opts
else body'
@@ -273,7 +279,7 @@ blockToOpenDocument o bs
| Header i b <- bs = inHeaderTags i <$> inlinesToOpenDocument o b
| BlockQuote b <- bs = mkBlockQuote b
| CodeBlock _ s <- bs = preformatted s
- | RawHtml _ <- bs = return empty
+ | RawBlock _ _ <- bs = return empty
| DefinitionList b <- bs = defList b
| BulletList b <- bs = bulletListToOpenDocument o b
| OrderedList a b <- bs = orderedList a b
@@ -286,7 +292,7 @@ blockToOpenDocument o bs
r <- vcat <$> mapM (deflistItemToOpenDocument o) b
setInDefinitionList False
return r
- preformatted s = vcat <$> mapM (inPreformattedTags . escapeStringForXML) (lines s)
+ preformatted s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (lines s)
mkBlockQuote b = do increaseIndent
i <- paraStyle "Quotations" []
inBlockQuote o i (map plainToPara b)
@@ -346,7 +352,7 @@ inlineToOpenDocument o ils
| EmDash <- ils = inTextStyle $ text "&#8212;"
| EnDash <- ils = inTextStyle $ text "&#8211;"
| Apostrophe <- ils = inTextStyle $ text "&#8217;"
- | Space <- ils = inTextStyle $ char ' '
+ | Space <- ils = inTextStyle space
| LineBreak <- ils = return $ selfClosingTag "text:line-break" []
| Str s <- ils = inTextStyle $ handleSpaces $ escapeStringForXML s
| Emph l <- ils = withTextStyle Italic $ inlinesToOpenDocument o l
@@ -356,11 +362,12 @@ inlineToOpenDocument o ils
| Subscript l <- ils = withTextStyle Sub $ inlinesToOpenDocument o l
| SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l
| Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l
- | Code s <- ils = preformatted s
+ | Code _ s <- ils = preformatted s
| Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s)
| Cite _ l <- ils = inlinesToOpenDocument o l
- | TeX s <- ils = preformatted s
- | HtmlInline s <- ils = preformatted s
+ | RawInline "opendocument" s <- ils = preformatted s
+ | RawInline "html" s <- ils = preformatted s -- for backwards compat.
+ | RawInline _ _ <- ils = return empty
| Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l
| Image _ (s,_) <- ils = return $ mkImg s
| Note l <- ils = mkNote l
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
new file mode 100644
index 000000000..f7f314428
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -0,0 +1,284 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2006-2010 Puneeth Chaganti <punchagan@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Writers.Org
+ Copyright : Copyright (C) 2010 Puneeth Chaganti
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Puneeth Chaganti <punchagan@gmail.com>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to Emacs Org-Mode.
+
+Org-Mode: <http://orgmode.org>
+-}
+module Text.Pandoc.Writers.Org ( writeOrg) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared
+import Text.Pandoc.Pretty
+import Text.Pandoc.Templates (renderTemplate)
+import Data.List ( intersect, intersperse, transpose )
+import Control.Monad.State
+import Control.Applicative ( (<$>) )
+
+data WriterState =
+ WriterState { stNotes :: [[Block]]
+ , stLinks :: Bool
+ , stImages :: Bool
+ , stHasMath :: Bool
+ , stOptions :: WriterOptions
+ }
+
+-- | Convert Pandoc to Org.
+writeOrg :: WriterOptions -> Pandoc -> String
+writeOrg opts document =
+ let st = WriterState { stNotes = [], stLinks = False,
+ stImages = False, stHasMath = False,
+ stOptions = opts }
+ in evalState (pandocToOrg document) st
+
+-- | Return Org representation of document.
+pandocToOrg :: Pandoc -> State WriterState String
+pandocToOrg (Pandoc (Meta tit auth dat) blocks) = do
+ opts <- liftM stOptions get
+ title <- titleToOrg tit
+ authors <- mapM inlineListToOrg auth
+ date <- inlineListToOrg dat
+ body <- blockListToOrg blocks
+ notes <- liftM (reverse . stNotes) get >>= notesToOrg
+ -- note that the notes may contain refs, so we do them first
+ hasMath <- liftM stHasMath get
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ let main = render colwidth $ foldl ($+$) empty $ [body, notes]
+ let context = writerVariables opts ++
+ [ ("body", main)
+ , ("title", render Nothing title)
+ , ("date", render Nothing date) ] ++
+ [ ("math", "yes") | hasMath ] ++
+ [ ("author", render Nothing a) | a <- authors ]
+ if writerStandalone opts
+ then return $ renderTemplate context $ writerTemplate opts
+ else return main
+
+-- | Return Org representation of notes.
+notesToOrg :: [[Block]] -> State WriterState Doc
+notesToOrg notes =
+ mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>=
+ return . vsep
+
+-- | Return Org representation of a note.
+noteToOrg :: Int -> [Block] -> State WriterState Doc
+noteToOrg num note = do
+ contents <- blockListToOrg note
+ let marker = "[" ++ show num ++ "] "
+ return $ hang (length marker) (text marker) contents
+
+-- | Escape special characters for Org.
+escapeString :: String -> String
+escapeString = escapeStringUsing (backslashEscapes "^_")
+
+titleToOrg :: [Inline] -> State WriterState Doc
+titleToOrg [] = return empty
+titleToOrg lst = do
+ contents <- inlineListToOrg lst
+ return $ "#+TITLE: " <> contents
+
+-- | Convert Pandoc block element to Org.
+blockToOrg :: Block -- ^ Block element
+ -> State WriterState Doc
+blockToOrg Null = return empty
+blockToOrg (Plain inlines) = inlineListToOrg inlines
+blockToOrg (Para [Image txt (src,tit)]) = do
+ capt <- inlineListToOrg txt
+ img <- inlineToOrg (Image txt (src,tit))
+ return $ "#+CAPTION: " <> capt <> blankline <> img
+blockToOrg (Para inlines) = do
+ contents <- inlineListToOrg inlines
+ return $ contents <> blankline
+blockToOrg (RawBlock "html" str) =
+ return $ blankline $$ "#+BEGIN_HTML" $$
+ nest 2 (text str) $$ "#+END_HTML" $$ blankline
+blockToOrg (RawBlock f str) | f == "org" || f == "latex" || f == "tex" =
+ return $ text str
+blockToOrg (RawBlock _ _) = return empty
+blockToOrg HorizontalRule = return $ blankline $$ "--------------" $$ blankline
+blockToOrg (Header level inlines) = do
+ contents <- inlineListToOrg inlines
+ let headerStr = text $ if level > 999 then " " else replicate level '*'
+ return $ headerStr <> " " <> contents <> blankline
+blockToOrg (CodeBlock (_,classes,_) str) = do
+ opts <- stOptions <$> get
+ let tabstop = writerTabStop opts
+ let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa",
+ "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex",
+ "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave",
+ "oz", "perl", "plantuml", "python", "R", "ruby", "sass",
+ "scheme", "screen", "sh", "sql", "sqlite"]
+ let (beg, end) = if null at
+ then ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE")
+ else ("#+BEGIN_SRC" ++ head at, "#+END_SRC")
+ return $ text beg $$ nest tabstop (text str) $$ text end $$ blankline
+blockToOrg (BlockQuote blocks) = do
+ contents <- blockListToOrg blocks
+ return $ blankline $$ "#+BEGIN_QUOTE" $$
+ nest 2 contents $$ "#+END_QUOTE" $$ blankline
+blockToOrg (Table caption' _ _ headers rows) = do
+ caption'' <- inlineListToOrg caption'
+ let caption = if null caption'
+ then empty
+ else ("#+CAPTION: " <> caption'')
+ headers' <- mapM blockListToOrg headers
+ rawRows <- mapM (mapM blockListToOrg) rows
+ let numChars = maximum . map offset
+ -- FIXME: width is not being used.
+ let widthsInChars =
+ map ((+2) . numChars) $ transpose (headers' : rawRows)
+ -- FIXME: Org doesn't allow blocks with height more than 1.
+ let hpipeBlocks blocks = hcat [beg, middle, end]
+ where h = maximum (map height blocks)
+ sep' = lblock 3 $ vcat (map text $ replicate h " | ")
+ beg = lblock 2 $ vcat (map text $ replicate h "| ")
+ end = lblock 2 $ vcat (map text $ replicate h " |")
+ middle = hcat $ intersperse sep' blocks
+ let makeRow = hpipeBlocks . zipWith lblock widthsInChars
+ let head' = makeRow headers'
+ rows' <- mapM (\row -> do cols <- mapM blockListToOrg row
+ return $ makeRow cols) rows
+ let border ch = char '|' <> char ch <>
+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
+ map (\l -> text $ replicate l ch) widthsInChars) <>
+ char ch <> char '|'
+ let body = vcat rows'
+ let head'' = if all null headers
+ then empty
+ else head' $$ border '-'
+ return $ head'' $$ body $$ caption $$ blankline
+blockToOrg (BulletList items) = do
+ contents <- mapM bulletListItemToOrg items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $+$ vcat contents $$ blankline
+blockToOrg (OrderedList (start, _, delim) items) = do
+ let delim' = case delim of
+ TwoParens -> OneParen
+ x -> x
+ let markers = take (length items) $ orderedListMarkers
+ (start, Decimal, delim')
+ let maxMarkerLength = maximum $ map length markers
+ let markers' = map (\m -> let s = maxMarkerLength - length m
+ in m ++ replicate s ' ') markers
+ contents <- mapM (\(item, num) -> orderedListItemToOrg item num) $
+ zip markers' items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $$ vcat contents $$ blankline
+blockToOrg (DefinitionList items) = do
+ contents <- mapM definitionListItemToOrg items
+ return $ vcat contents $$ blankline
+
+-- | Convert bullet list item (list of blocks) to Org.
+bulletListItemToOrg :: [Block] -> State WriterState Doc
+bulletListItemToOrg items = do
+ contents <- blockListToOrg items
+ return $ hang 3 "- " (contents <> cr)
+
+-- | Convert ordered list item (a list of blocks) to Org.
+orderedListItemToOrg :: String -- ^ marker for list item
+ -> [Block] -- ^ list item (list of blocks)
+ -> State WriterState Doc
+orderedListItemToOrg marker items = do
+ contents <- blockListToOrg items
+ return $ hang (length marker + 1) (text marker <> space) (contents <> cr)
+
+-- | Convert defintion list item (label, list of blocks) to Org.
+definitionListItemToOrg :: ([Inline], [[Block]]) -> State WriterState Doc
+definitionListItemToOrg (label, defs) = do
+ label' <- inlineListToOrg label
+ contents <- liftM vcat $ mapM blockListToOrg defs
+ return $ hang 3 "- " $ label' <> " :: " <> (contents <> cr)
+
+-- | Convert list of Pandoc block elements to Org.
+blockListToOrg :: [Block] -- ^ List of block elements
+ -> State WriterState Doc
+blockListToOrg blocks = mapM blockToOrg blocks >>= return . vcat
+
+-- | Convert list of Pandoc inline elements to Org.
+inlineListToOrg :: [Inline] -> State WriterState Doc
+inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat
+
+-- | Convert Pandoc inline element to Org.
+inlineToOrg :: Inline -> State WriterState Doc
+inlineToOrg (Emph lst) = do
+ contents <- inlineListToOrg lst
+ return $ "/" <> contents <> "/"
+inlineToOrg (Strong lst) = do
+ contents <- inlineListToOrg lst
+ return $ "*" <> contents <> "*"
+inlineToOrg (Strikeout lst) = do
+ contents <- inlineListToOrg lst
+ return $ "+" <> contents <> "+"
+inlineToOrg (Superscript lst) = do
+ contents <- inlineListToOrg lst
+ return $ "^{" <> contents <> "}"
+inlineToOrg (Subscript lst) = do
+ contents <- inlineListToOrg lst
+ return $ "_{" <> contents <> "}"
+inlineToOrg (SmallCaps lst) = inlineListToOrg lst
+inlineToOrg (Quoted SingleQuote lst) = do
+ contents <- inlineListToOrg lst
+ return $ "'" <> contents <> "'"
+inlineToOrg (Quoted DoubleQuote lst) = do
+ contents <- inlineListToOrg lst
+ return $ "\"" <> contents <> "\""
+inlineToOrg (Cite _ lst) = inlineListToOrg lst
+inlineToOrg EmDash = return "---"
+inlineToOrg EnDash = return "--"
+inlineToOrg Apostrophe = return "'"
+inlineToOrg Ellipses = return "..."
+inlineToOrg (Code _ str) = return $ "=" <> text str <> "="
+inlineToOrg (Str str) = return $ text $ escapeString str
+inlineToOrg (Math t str) = do
+ modify $ \st -> st{ stHasMath = True }
+ return $ if t == InlineMath
+ then "$" <> text str <> "$"
+ else "$$" <> text str <> "$$"
+inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str
+inlineToOrg (RawInline _ _) = return empty
+inlineToOrg (LineBreak) = return cr -- there's no line break in Org
+inlineToOrg Space = return space
+inlineToOrg (Link txt (src, _)) = do
+ case txt of
+ [Code _ x] | x == src -> -- autolink
+ do modify $ \s -> s{ stLinks = True }
+ return $ "[[" <> text x <> "]]"
+ _ -> do contents <- inlineListToOrg txt
+ modify $ \s -> s{ stLinks = True }
+ return $ "[[" <> text src <> "][" <> contents <> "]]"
+inlineToOrg (Image _ (source', _)) = do
+ let source = unescapeURI source'
+ modify $ \s -> s{ stImages = True }
+ return $ "[[" <> text source <> "]]"
+inlineToOrg (Note contents) = do
+ -- add to notes in state
+ notes <- get >>= (return . stNotes)
+ modify $ \st -> st { stNotes = contents:notes }
+ let ref = show $ (length notes) + 1
+ return $ " [" <> text ref <> "]"
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index e79f97b33..d4adaa929 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
@@ -32,10 +33,9 @@ reStructuredText: <http://docutils.sourceforge.net/rst.html>
module Text.Pandoc.Writers.RST ( writeRST) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
-import Text.Pandoc.Blocks
import Text.Pandoc.Templates (renderTemplate)
-import Data.List ( isPrefixOf, isSuffixOf, intersperse, transpose )
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Data.List ( isPrefixOf, intersperse, transpose )
+import Text.Pandoc.Pretty
import Control.Monad.State
import Control.Applicative ( (<$>) )
@@ -70,13 +70,16 @@ pandocToRST (Pandoc (Meta tit auth dat) blocks) = do
refs <- liftM (reverse . stLinks) get >>= refsToRST
pics <- liftM (reverse . stImages) get >>= pictRefsToRST
hasMath <- liftM stHasMath get
- let main = render $ foldl ($+$) empty $ [body, notes, refs, pics]
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ let main = render colwidth $ foldl ($+$) empty $ [body, notes, refs, pics]
let context = writerVariables opts ++
[ ("body", main)
- , ("title", render title)
- , ("date", render date) ] ++
+ , ("title", render Nothing title)
+ , ("date", render colwidth date) ] ++
[ ("math", "yes") | hasMath ] ++
- [ ("author", render a) | a <- authors ]
+ [ ("author", render colwidth a) | a <- authors ]
if writerStandalone opts
then return $ renderTemplate context $ writerTemplate opts
else return main
@@ -84,49 +87,40 @@ pandocToRST (Pandoc (Meta tit auth dat) blocks) = do
-- | Return RST representation of reference key table.
refsToRST :: Refs -> State WriterState Doc
refsToRST refs = mapM keyToRST refs >>= return . vcat
-
+
-- | Return RST representation of a reference key.
keyToRST :: ([Inline], (String, String))
-> State WriterState Doc
keyToRST (label, (src, _)) = do
label' <- inlineListToRST label
- let label'' = if ':' `elem` (render label')
+ let label'' = if ':' `elem` (render Nothing label')
then char '`' <> label' <> char '`'
else label'
- return $ text ".. _" <> label'' <> text ": " <> text src
+ return $ ".. _" <> label'' <> ": " <> text src
-- | Return RST representation of notes.
notesToRST :: [[Block]] -> State WriterState Doc
notesToRST notes =
- mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>=
- return . vcat
+ mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>=
+ return . vsep
-- | Return RST representation of a note.
noteToRST :: Int -> [Block] -> State WriterState Doc
noteToRST num note = do
contents <- blockListToRST note
- let marker = text ".. [" <> text (show num) <> text "]"
+ let marker = ".. [" <> text (show num) <> "]"
return $ marker $$ nest 3 contents
-- | Return RST representation of picture reference table.
pictRefsToRST :: Refs -> State WriterState Doc
pictRefsToRST refs = mapM pictToRST refs >>= return . vcat
-
+
-- | Return RST representation of a picture substitution reference.
pictToRST :: ([Inline], (String, String))
-> State WriterState Doc
pictToRST (label, (src, _)) = do
label' <- inlineListToRST label
- return $ text ".. " <> char '|' <> label' <> char '|' <> text " image:: " <>
- text src
-
--- | Take list of inline elements and return wrapped doc.
-wrappedRST :: WriterOptions -> [Inline] -> State WriterState Doc
-wrappedRST opts inlines = do
- lineBreakDoc <- inlineToRST LineBreak
- chunks <- mapM (wrapIfNeeded opts inlineListToRST)
- (splitBy LineBreak inlines)
- return $ vcat $ intersperse lineBreakDoc chunks
+ return $ ".. |" <> label' <> "| image:: " <> text src
-- | Escape special characters for RST.
escapeString :: String -> String
@@ -136,69 +130,66 @@ titleToRST :: [Inline] -> State WriterState Doc
titleToRST [] = return empty
titleToRST lst = do
contents <- inlineListToRST lst
- let titleLength = length $ render contents
+ let titleLength = length $ (render Nothing contents :: String)
let border = text (replicate titleLength '=')
- return $ border $+$ contents $+$ border
+ return $ border $$ contents $$ border
-- | Convert Pandoc block element to RST.
blockToRST :: Block -- ^ Block element
-> State WriterState Doc
blockToRST Null = return empty
-blockToRST (Plain inlines) = do
- opts <- get >>= (return . stOptions)
- wrappedRST opts inlines
+blockToRST (Plain inlines) = inlineListToRST inlines
blockToRST (Para [Image txt (src,tit)]) = do
capt <- inlineListToRST txt
- let fig = text "figure:: " <> text src
- let align = text ":align: center"
- let alt = text ":alt: " <> if null tit then capt else text tit
- return $ (text ".. " <> (fig $$ align $$ alt $$ text "" $$ capt)) $$ text ""
+ let fig = "figure:: " <> text src
+ let align = ":align: center"
+ let alt = ":alt: " <> if null tit then capt else text tit
+ return $ hang 3 ".. " $ fig $$ align $$ alt $+$ capt $$ blankline
blockToRST (Para inlines) = do
- opts <- get >>= (return . stOptions)
- contents <- wrappedRST opts inlines
- return $ contents <> text "\n"
-blockToRST (RawHtml str) =
- let str' = if "\n" `isSuffixOf` str then str ++ "\n" else str ++ "\n\n" in
- return $ (text "\n.. raw:: html\n") $$ (nest 3 $ vcat $ map text (lines str'))
-blockToRST HorizontalRule = return $ text "--------------\n"
+ contents <- inlineListToRST inlines
+ return $ contents <> blankline
+blockToRST (RawBlock f str) =
+ return $ blankline <> ".. raw:: " <> text f $+$
+ (nest 3 $ text str) $$ blankline
+blockToRST HorizontalRule =
+ return $ blankline $$ "--------------" $$ blankline
blockToRST (Header level inlines) = do
contents <- inlineListToRST inlines
- let headerLength = length $ render contents
let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1)
- let border = text $ replicate headerLength headerChar
- return $ contents $+$ border <> text "\n"
+ let border = text $ replicate (offset contents) headerChar
+ return $ contents $$ border $$ blankline
blockToRST (CodeBlock (_,classes,_) str) = do
opts <- stOptions <$> get
let tabstop = writerTabStop opts
if "haskell" `elem` classes && "literate" `elem` classes &&
writerLiterateHaskell opts
- then return $ (vcat $ map (text "> " <>) $ map text (lines str)) <> text "\n"
- else return $ (text "::\n") $+$
- (nest tabstop $ vcat $ map text (lines str)) <> text "\n"
+ then return $ prefixed "> " (text str) $$ blankline
+ else return $ "::" $+$ nest tabstop (text str) $$ blankline
blockToRST (BlockQuote blocks) = do
tabstop <- get >>= (return . writerTabStop . stOptions)
contents <- blockListToRST blocks
- return $ (nest tabstop contents) <> text "\n"
+ return $ (nest tabstop contents) <> blankline
blockToRST (Table caption _ widths headers rows) = do
caption' <- inlineListToRST caption
let caption'' = if null caption
then empty
- else text "" $+$ (text "Table: " <> caption')
+ else blankline <> text "Table: " <> caption'
headers' <- mapM blockListToRST headers
rawRows <- mapM (mapM blockListToRST) rows
let isSimple = all (==0) widths && all (all (\bs -> length bs == 1)) rows
- let numChars = maximum . map (length . render)
+ let numChars = maximum . map offset
+ opts <- get >>= return . stOptions
let widthsInChars =
if isSimple
then map ((+2) . numChars) $ transpose (headers' : rawRows)
- else map (floor . (78 *)) widths
- let hpipeBlocks blocks = hcatBlocks [beg, middle, end]
- where height = maximum (map heightOfBlock blocks)
- sep' = TextBlock 3 height (replicate height " | ")
- beg = TextBlock 2 height (replicate height "| ")
- end = TextBlock 2 height (replicate height " |")
- middle = hcatBlocks $ intersperse sep' blocks
- let makeRow = hpipeBlocks . zipWith docToBlock widthsInChars
+ else map (floor . (fromIntegral (writerColumns opts) *)) widths
+ let hpipeBlocks blocks = hcat [beg, middle, end]
+ where h = maximum (map height blocks)
+ sep' = lblock 3 $ vcat (map text $ replicate h " | ")
+ beg = lblock 2 $ vcat (map text $ replicate h "| ")
+ end = lblock 2 $ vcat (map text $ replicate h " |")
+ middle = hcat $ intersperse sep' blocks
+ let makeRow = hpipeBlocks . zipWith lblock widthsInChars
let head' = makeRow headers'
rows' <- mapM (\row -> do cols <- mapM blockListToRST row
return $ makeRow cols) rows
@@ -206,15 +197,15 @@ blockToRST (Table caption _ widths headers rows) = do
(hcat $ intersperse (char ch <> char '+' <> char ch) $
map (\l -> text $ replicate l ch) widthsInChars) <>
char ch <> char '+'
- let body = vcat $ intersperse (border '-') $ map blockToDoc rows'
+ let body = vcat $ intersperse (border '-') rows'
let head'' = if all null headers
then empty
- else blockToDoc head' $+$ border '='
- return $ border '-' $+$ head'' $+$ body $+$ border '-' $$ caption'' $$ text ""
+ else head' $$ border '='
+ return $ border '-' $$ head'' $$ body $$ border '-' $$ caption'' $$ blankline
blockToRST (BulletList items) = do
contents <- mapM bulletListItemToRST items
-- ensure that sublists have preceding blank line
- return $ text "" $+$ vcat contents <> text "\n"
+ return $ blankline $$ vcat contents $$ blankline
blockToRST (OrderedList (start, style', delim) items) = do
let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
then take (length items) $ repeat "#."
@@ -224,18 +215,19 @@ blockToRST (OrderedList (start, style', delim) items) = do
let markers' = map (\m -> let s = maxMarkerLength - length m
in m ++ replicate s ' ') markers
contents <- mapM (\(item, num) -> orderedListItemToRST item num) $
- zip markers' items
+ zip markers' items
-- ensure that sublists have preceding blank line
- return $ text "" $+$ vcat contents <> text "\n"
+ return $ blankline $$ vcat contents $$ blankline
blockToRST (DefinitionList items) = do
contents <- mapM definitionListItemToRST items
- return $ (vcat contents) <> text "\n"
+ -- ensure that sublists have preceding blank line
+ return $ blankline $$ vcat contents $$ blankline
-- | Convert bullet list item (list of blocks) to RST.
bulletListItemToRST :: [Block] -> State WriterState Doc
bulletListItemToRST items = do
contents <- blockListToRST items
- return $ (text "- ") <> contents
+ return $ hang 3 "- " $ contents <> cr
-- | Convert ordered list item (a list of blocks) to RST.
orderedListItemToRST :: String -- ^ marker for list item
@@ -243,7 +235,8 @@ orderedListItemToRST :: String -- ^ marker for list item
-> State WriterState Doc
orderedListItemToRST marker items = do
contents <- blockListToRST items
- return $ (text marker <> char ' ') <> contents
+ let marker' = marker ++ " "
+ return $ hang (length marker') (text marker') $ contents <> cr
-- | Convert defintion list item (label, list of blocks) to RST.
definitionListItemToRST :: ([Inline], [[Block]]) -> State WriterState Doc
@@ -251,7 +244,7 @@ definitionListItemToRST (label, defs) = do
label' <- inlineListToRST label
contents <- liftM vcat $ mapM blockListToRST defs
tabstop <- get >>= (return . writerTabStop . stOptions)
- return $ label' $+$ nest tabstop contents
+ return $ label' $$ nest tabstop (contents <> cr)
-- | Convert list of Pandoc block elements to RST.
blockListToRST :: [Block] -- ^ List of block elements
@@ -266,65 +259,63 @@ inlineListToRST lst = mapM inlineToRST lst >>= return . hcat
inlineToRST :: Inline -> State WriterState Doc
inlineToRST (Emph lst) = do
contents <- inlineListToRST lst
- return $ char '*' <> contents <> char '*'
+ return $ "*" <> contents <> "*"
inlineToRST (Strong lst) = do
contents <- inlineListToRST lst
- return $ text "**" <> contents <> text "**"
+ return $ "**" <> contents <> "**"
inlineToRST (Strikeout lst) = do
contents <- inlineListToRST lst
- return $ text "[STRIKEOUT:" <> contents <> char ']'
+ return $ "[STRIKEOUT:" <> contents <> "]"
inlineToRST (Superscript lst) = do
contents <- inlineListToRST lst
- return $ text "\\ :sup:`" <> contents <> text "`\\ "
+ return $ "\\ :sup:`" <> contents <> "`\\ "
inlineToRST (Subscript lst) = do
contents <- inlineListToRST lst
- return $ text "\\ :sub:`" <> contents <> text "`\\ "
+ return $ "\\ :sub:`" <> contents <> "`\\ "
inlineToRST (SmallCaps lst) = inlineListToRST lst
inlineToRST (Quoted SingleQuote lst) = do
contents <- inlineListToRST lst
- return $ char '‘' <> contents <> char '’'
+ return $ "‘" <> contents <> "’"
inlineToRST (Quoted DoubleQuote lst) = do
contents <- inlineListToRST lst
- return $ char '“' <> contents <> char '”'
+ return $ "“" <> contents <> "”"
inlineToRST (Cite _ lst) =
inlineListToRST lst
inlineToRST EmDash = return $ char '\8212'
inlineToRST EnDash = return $ char '\8211'
inlineToRST Apostrophe = return $ char '\8217'
inlineToRST Ellipses = return $ char '\8230'
-inlineToRST (Code str) = return $ text $ "``" ++ str ++ "``"
+inlineToRST (Code _ str) = return $ "``" <> text str <> "``"
inlineToRST (Str str) = return $ text $ escapeString str
inlineToRST (Math t str) = do
modify $ \st -> st{ stHasMath = True }
return $ if t == InlineMath
- then text $ ":math:`$" ++ str ++ "$`"
- else text $ ":math:`$$" ++ str ++ "$$`"
-inlineToRST (TeX _) = return empty
-inlineToRST (HtmlInline _) = return empty
-inlineToRST (LineBreak) = do
- return $ empty -- there's no line break in RST
-inlineToRST Space = return $ char ' '
-inlineToRST (Link [Code str] (src, _)) | src == str ||
- src == "mailto:" ++ str = do
+ then ":math:`$" <> text str <> "$`"
+ else ":math:`$$" <> text str <> "$$`"
+inlineToRST (RawInline _ _) = return empty
+inlineToRST (LineBreak) = return cr -- there's no line break in RST
+inlineToRST Space = return space
+inlineToRST (Link [Code _ str] (src, _)) | src == str ||
+ src == "mailto:" ++ str = do
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
return $ text $ unescapeURI srcSuffix
inlineToRST (Link txt (src', tit)) = do
let src = unescapeURI src'
- useReferenceLinks <- get >>= (return . writerReferenceLinks . stOptions)
+ useReferenceLinks <- get >>= return . writerReferenceLinks . stOptions
linktext <- inlineListToRST $ normalizeSpaces txt
if useReferenceLinks
- then do refs <- get >>= (return . stLinks)
+ then do refs <- get >>= return . stLinks
let refs' = if (txt, (src, tit)) `elem` refs
then refs
else (txt, (src, tit)):refs
modify $ \st -> st { stLinks = refs' }
- return $ char '`' <> linktext <> text "`_"
- else return $ char '`' <> linktext <> text " <" <> text src <> text ">`_"
+ return $ "`" <> linktext <> "`_"
+ else return $ "`" <> linktext <> " <" <> text src <> ">`_"
inlineToRST (Image alternate (source', tit)) = do
let source = unescapeURI source'
- pics <- get >>= (return . stImages)
+ pics <- get >>= return . stImages
let labelsUsed = map fst pics
- let txt = if null alternate || alternate == [Str ""] ||
+ let txt = if null alternate || alternate == [Str ""] ||
alternate `elem` labelsUsed
then [Str $ "image" ++ show (length pics)]
else alternate
@@ -333,10 +324,10 @@ inlineToRST (Image alternate (source', tit)) = do
else (txt, (source, tit)):pics
modify $ \st -> st { stImages = pics' }
label <- inlineListToRST txt
- return $ char '|' <> label <> char '|'
+ return $ "|" <> label <> "|"
inlineToRST (Note contents) = do
-- add to notes in state
- notes <- get >>= (return . stNotes)
+ notes <- get >>= return . stNotes
modify $ \st -> st { stNotes = contents:notes }
let ref = show $ (length notes) + 1
- return $ text " [" <> text ref <> text "]_"
+ return $ " [" <> text ref <> "]_"
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index ae71e1307..605e4162b 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -27,13 +27,34 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of 'Pandoc' documents to RTF (rich text format).
-}
-module Text.Pandoc.Writers.RTF ( writeRTF ) where
+module Text.Pandoc.Writers.RTF ( writeRTF, rtfEmbedImage ) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Pandoc.Readers.TeXMath
import Text.Pandoc.Templates (renderTemplate)
import Data.List ( isSuffixOf, intercalate )
-import Data.Char ( ord, isDigit )
+import Data.Char ( ord, isDigit, toLower )
+import System.FilePath ( takeExtension )
+import qualified Data.ByteString as B
+import Text.Printf ( printf )
+
+-- | Convert Image inlines into a raw RTF embedded image, read from a file.
+-- If file not found or filetype not jpeg or png, leave the inline unchanged.
+rtfEmbedImage :: Inline -> IO Inline
+rtfEmbedImage x@(Image _ (src,_))
+ | map toLower (takeExtension src) `elem` [".jpg",".jpeg",".png"] = do
+ imgdata <- catch (B.readFile src) (\_ -> return B.empty)
+ let bytes = map (printf "%02x") $ B.unpack imgdata
+ let filetype = case map toLower (takeExtension src) of
+ ".jpg" -> "\\jpegblip"
+ ".jpeg" -> "\\jpegblip"
+ ".png" -> "\\pngblip"
+ _ -> error "Unknown file type"
+ let raw = "{\\pict" ++ filetype ++ " " ++ concat bytes ++ "}"
+ return $ if B.null imgdata
+ then x
+ else RawInline "rtf" raw
+rtfEmbedImage x = return x
-- | Convert Pandoc to a string in rich text format.
writeRTF :: WriterOptions -> Pandoc -> String
@@ -159,7 +180,8 @@ blockToRTF indent alignment (BlockQuote lst) =
concatMap (blockToRTF (indent + indentIncrement) alignment) lst
blockToRTF indent _ (CodeBlock _ str) =
rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
-blockToRTF _ _ (RawHtml _) = ""
+blockToRTF _ _ (RawBlock "rtf" str) = str
+blockToRTF _ _ (RawBlock _ _) = ""
blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
@@ -264,12 +286,12 @@ inlineToRTF Apostrophe = "\\u8217'"
inlineToRTF Ellipses = "\\u8230?"
inlineToRTF EmDash = "\\u8212-"
inlineToRTF EnDash = "\\u8211-"
-inlineToRTF (Code str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
+inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
inlineToRTF (Str str) = stringToRTF str
inlineToRTF (Math _ str) = inlineListToRTF $ readTeXMath str
inlineToRTF (Cite _ lst) = inlineListToRTF lst
-inlineToRTF (TeX _) = ""
-inlineToRTF (HtmlInline _) = ""
+inlineToRTF (RawInline "rtf" str) = str
+inlineToRTF (RawInline _ _) = ""
inlineToRTF (LineBreak) = "\\line "
inlineToRTF Space = " "
inlineToRTF (Link text (src, _)) =
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
index 65e053827..c8638cdd7 100644
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -31,13 +31,12 @@ module Text.Pandoc.Writers.Texinfo ( writeTexinfo ) where
import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Pandoc.Templates (renderTemplate)
-import Text.Pandoc.Readers.TeXMath
import Text.Printf ( printf )
-import Data.List ( isSuffixOf, transpose, maximumBy )
+import Data.List ( transpose, maximumBy )
import Data.Ord ( comparing )
import Data.Char ( chr, ord )
import Control.Monad.State
-import Text.PrettyPrint.HughesPJ hiding ( Str )
+import Text.Pandoc.Pretty
data WriterState =
WriterState { stStrikeout :: Bool -- document contains strikeout
@@ -69,17 +68,20 @@ pandocToTexinfo options (Pandoc (Meta title authors date) blocks) = do
let titlePage = not $ all null $ title : date : authors
main <- blockListToTexinfo blocks
st <- get
- let body = render main
+ let colwidth = if writerWrapText options
+ then Just $ writerColumns options
+ else Nothing
+ let body = render colwidth main
let context = writerVariables options ++
[ ("body", body)
- , ("title", render titleText)
- , ("date", render dateText) ] ++
+ , ("title", render colwidth titleText)
+ , ("date", render colwidth dateText) ] ++
[ ("toc", "yes") | writerTableOfContents options ] ++
[ ("titlepage", "yes") | titlePage ] ++
[ ("subscript", "yes") | stSubscript st ] ++
[ ("superscript", "yes") | stSuperscript st ] ++
[ ("strikeout", "yes") | stStrikeout st ] ++
- [ ("author", render a) | a <- authorsText ]
+ [ ("author", render colwidth a) | a <- authorsText ]
if writerStandalone options
then return $ renderTemplate context $ writerTemplate options
else return body
@@ -124,22 +126,25 @@ blockToTexinfo (BlockQuote lst) = do
blockToTexinfo (CodeBlock _ str) = do
return $ text "@verbatim" $$
- vcat (map text (lines str)) $$
- text "@end verbatim\n"
+ flush (text str) $$
+ text "@end verbatim" <> blankline
-blockToTexinfo (RawHtml _) = return empty
+blockToTexinfo (RawBlock "texinfo" str) = return $ text str
+blockToTexinfo (RawBlock "latex" str) =
+ return $ text "@tex" $$ text str $$ text "@end tex"
+blockToTexinfo (RawBlock _ _) = return empty
blockToTexinfo (BulletList lst) = do
items <- mapM listItemToTexinfo lst
return $ text "@itemize" $$
vcat items $$
- text "@end itemize\n"
+ text "@end itemize" <> blankline
blockToTexinfo (OrderedList (start, numstyle, _) lst) = do
items <- mapM listItemToTexinfo lst
return $ text "@enumerate " <> exemplar $$
vcat items $$
- text "@end enumerate\n"
+ text "@end enumerate" <> blankline
where
exemplar = case numstyle of
DefaultStyle -> decimal
@@ -159,7 +164,7 @@ blockToTexinfo (DefinitionList lst) = do
items <- mapM defListItemToTexinfo lst
return $ text "@table @asis" $$
vcat items $$
- text "@end table\n"
+ text "@end table" <> blankline
blockToTexinfo HorizontalRule =
-- XXX can't get the equivalent from LaTeX.hs to work
@@ -175,13 +180,13 @@ blockToTexinfo (Header 0 lst) = do
then return $ text "Top"
else inlineListToTexinfo lst
return $ text "@node Top" $$
- text "@top " <> txt <> char '\n'
+ text "@top " <> txt <> blankline
blockToTexinfo (Header level lst) = do
node <- inlineListForNode lst
txt <- inlineListToTexinfo lst
return $ if (level > 0) && (level <= 4)
- then text "\n@node " <> node <> char '\n' <>
+ then blankline <> text "@node " <> node <> cr <>
text (seccmd level) <> txt
else txt
where
@@ -200,18 +205,18 @@ blockToTexinfo (Table caption aligns widths heads rows) = do
colDescriptors <-
if all (== 0) widths
then do -- use longest entry instead of column widths
- cols <- mapM (mapM (liftM (render . hcat) . mapM blockToTexinfo)) $
- transpose $ heads : rows
+ cols <- mapM (mapM (liftM (render Nothing . hcat) . mapM blockToTexinfo)) $
+ transpose $ heads : rows
return $ concatMap ((\x -> "{"++x++"} ") . maximumBy (comparing length)) cols
else return $ "@columnfractions " ++ concatMap (printf "%.2f ") widths
let tableBody = text ("@multitable " ++ colDescriptors) $$
headers $$
vcat rowsText $$
- text "@end multitable"
+ text "@end multitable"
return $ if isEmpty captionText
- then tableBody <> char '\n'
+ then tableBody <> blankline
else text "@float" $$
- tableBody $$
+ tableBody $$
inCmd "caption" captionText $$
text "@end float"
@@ -253,7 +258,7 @@ alignedBlock _ col = blockListToTexinfo col
-- | Convert Pandoc block elements to Texinfo.
blockListToTexinfo :: [Block]
-> State WriterState Doc
-blockListToTexinfo [] = return $ empty
+blockListToTexinfo [] = return empty
blockListToTexinfo (x:xs) = do
x' <- blockToTexinfo x
case x of
@@ -276,7 +281,7 @@ blockListToTexinfo (x:xs) = do
xs' <- blockListToTexinfo xs
case xs of
((CodeBlock _ _):_) -> return $ x' $$ xs'
- _ -> return $ x' $$ text "" $$ xs'
+ _ -> return $ x' $+$ xs'
_ -> do
xs' <- blockListToTexinfo xs
return $ x' $$ xs'
@@ -307,15 +312,23 @@ makeMenuLine _ = error "makeMenuLine called with non-Header block"
listItemToTexinfo :: [Block]
-> State WriterState Doc
-listItemToTexinfo lst = blockListToTexinfo lst >>=
- return . (text "@item" $$)
+listItemToTexinfo lst = do
+ contents <- blockListToTexinfo lst
+ let spacer = case reverse lst of
+ (Para{}:_) -> blankline
+ _ -> empty
+ return $ text "@item" $$ contents <> spacer
defListItemToTexinfo :: ([Inline], [[Block]])
-> State WriterState Doc
defListItemToTexinfo (term, defs) = do
term' <- inlineListToTexinfo term
- def' <- liftM vcat $ mapM blockListToTexinfo defs
- return $ text "@item " <> term' <> text "\n" $$ def'
+ let defToTexinfo bs = do d <- blockListToTexinfo bs
+ case reverse bs of
+ (Para{}:_) -> return $ d <> blankline
+ _ -> return d
+ defs' <- mapM defToTexinfo defs
+ return $ text "@item " <> term' $+$ vcat defs'
-- | Convert list of inline elements to Texinfo.
inlineListToTexinfo :: [Inline] -- ^ Inlines to convert
@@ -325,31 +338,7 @@ inlineListToTexinfo lst = mapM inlineToTexinfo lst >>= return . hcat
-- | Convert list of inline elements to Texinfo acceptable for a node name.
inlineListForNode :: [Inline] -- ^ Inlines to convert
-> State WriterState Doc
-inlineListForNode lst = mapM inlineForNode lst >>= return . hcat
-
-inlineForNode :: Inline -> State WriterState Doc
-inlineForNode (Str str) = return $ text $ filter (not.disallowedInNode) str
-inlineForNode (Emph lst) = inlineListForNode lst
-inlineForNode (Strong lst) = inlineListForNode lst
-inlineForNode (Strikeout lst) = inlineListForNode lst
-inlineForNode (Superscript lst) = inlineListForNode lst
-inlineForNode (Subscript lst) = inlineListForNode lst
-inlineForNode (SmallCaps lst) = inlineListForNode lst
-inlineForNode (Quoted _ lst) = inlineListForNode lst
-inlineForNode (Cite _ lst) = inlineListForNode lst
-inlineForNode (Code str) = inlineForNode (Str str)
-inlineForNode Space = return $ char ' '
-inlineForNode EmDash = return $ text "---"
-inlineForNode EnDash = return $ text "--"
-inlineForNode Apostrophe = return $ char '\''
-inlineForNode Ellipses = return $ text "..."
-inlineForNode LineBreak = return empty
-inlineForNode (Math _ str) = inlineListForNode $ readTeXMath str
-inlineForNode (TeX _) = return empty
-inlineForNode (HtmlInline _) = return empty
-inlineForNode (Link lst _) = inlineListForNode lst
-inlineForNode (Image lst _) = inlineListForNode lst
-inlineForNode (Note _) = return empty
+inlineListForNode = return . text . filter (not . disallowedInNode) . stringify
-- periods, commas, colons, and parentheses are disallowed in node names
disallowedInNode :: Char -> Bool
@@ -383,7 +372,7 @@ inlineToTexinfo (Subscript lst) = do
inlineToTexinfo (SmallCaps lst) =
inlineListToTexinfo lst >>= return . inCmd "sc"
-inlineToTexinfo (Code str) = do
+inlineToTexinfo (Code _ str) = do
return $ text $ "@code{" ++ stringToTexinfo str ++ "}"
inlineToTexinfo (Quoted SingleQuote lst) = do
@@ -402,14 +391,16 @@ inlineToTexinfo EnDash = return $ text "--"
inlineToTexinfo Ellipses = return $ text "@dots{}"
inlineToTexinfo (Str str) = return $ text (stringToTexinfo str)
inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str
-inlineToTexinfo (TeX str) = return $ text "@tex" $$ text str $$ text "@end tex"
-inlineToTexinfo (HtmlInline _) = return empty
+inlineToTexinfo (RawInline f str) | f == "latex" || f == "tex" =
+ return $ text "@tex" $$ text str $$ text "@end tex"
+inlineToTexinfo (RawInline "texinfo" str) = return $ text str
+inlineToTexinfo (RawInline _ _) = return empty
inlineToTexinfo (LineBreak) = return $ text "@*"
inlineToTexinfo Space = return $ char ' '
inlineToTexinfo (Link txt (src, _)) = do
case txt of
- [Code x] | x == src -> -- autolink
+ [Code _ x] | x == src -> -- autolink
do return $ text $ "@url{" ++ x ++ "}"
_ -> do contents <- inlineListToTexinfo txt
let src1 = stringToTexinfo src
@@ -429,9 +420,4 @@ inlineToTexinfo (Image alternate (source, _)) = do
inlineToTexinfo (Note contents) = do
contents' <- blockListToTexinfo contents
- let rawnote = stripTrailingNewlines $ render contents'
- let optNewline = "@end verbatim" `isSuffixOf` rawnote
- return $ text "@footnote{" <>
- text rawnote <>
- (if optNewline then char '\n' else empty) <>
- char '}'
+ return $ text "@footnote" <> braces contents'
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
new file mode 100644
index 000000000..6614ec28e
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -0,0 +1,422 @@
+{-
+Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Writers.Textile
+ Copyright : Copyright (C) 2010 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to Textile markup.
+
+Textile: <http://thresholdstate.com/articles/4312/the-textile-reference-manual>
+-}
+module Text.Pandoc.Writers.Textile ( writeTextile ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared
+import Text.Pandoc.Templates (renderTemplate)
+import Text.Pandoc.XML ( escapeStringForXML )
+import Data.List ( intercalate )
+import Control.Monad.State
+import Data.Char ( isSpace )
+
+data WriterState = WriterState {
+ stNotes :: [String] -- Footnotes
+ , stListLevel :: [Char] -- String at beginning of list items, e.g. "**"
+ , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list
+ }
+
+-- | Convert Pandoc to Textile.
+writeTextile :: WriterOptions -> Pandoc -> String
+writeTextile opts document =
+ evalState (pandocToTextile opts document)
+ (WriterState { stNotes = [], stListLevel = [], stUseTags = False })
+
+-- | Return Textile representation of document.
+pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String
+pandocToTextile opts (Pandoc _ blocks) = do
+ body <- blockListToTextile opts blocks
+ notes <- liftM (unlines . reverse . stNotes) get
+ let main = body ++ if null notes then "" else ("\n\n" ++ notes)
+ let context = writerVariables opts ++ [ ("body", main) ]
+ if writerStandalone opts
+ then return $ renderTemplate context $ writerTemplate opts
+ else return main
+
+withUseTags :: State WriterState a -> State WriterState a
+withUseTags action = do
+ oldUseTags <- liftM stUseTags get
+ modify $ \s -> s { stUseTags = True }
+ result <- action
+ modify $ \s -> s { stUseTags = oldUseTags }
+ return result
+
+-- | Escape one character as needed for Textile.
+escapeCharForTextile :: Char -> String
+escapeCharForTextile x = case x of
+ '&' -> "&amp;"
+ '<' -> "&lt;"
+ '>' -> "&gt;"
+ '"' -> "&quot;"
+ '*' -> "&#42;"
+ '_' -> "&#95;"
+ '@' -> "&#64;"
+ '|' -> "&#124;"
+ c -> [c]
+
+-- | Escape string as needed for Textile.
+escapeStringForTextile :: String -> String
+escapeStringForTextile = concatMap escapeCharForTextile
+
+-- | Convert Pandoc block element to Textile.
+blockToTextile :: WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> State WriterState String
+
+blockToTextile _ Null = return ""
+
+blockToTextile opts (Plain inlines) =
+ inlineListToTextile opts inlines
+
+blockToTextile opts (Para [Image txt (src,tit)]) = do
+ capt <- blockToTextile opts (Para txt)
+ im <- inlineToTextile opts (Image txt (src,tit))
+ return $ im ++ "\n" ++ capt
+
+blockToTextile opts (Para inlines) = do
+ useTags <- liftM stUseTags get
+ listLevel <- liftM stListLevel get
+ contents <- inlineListToTextile opts inlines
+ return $ if useTags
+ then "<p>" ++ contents ++ "</p>"
+ else contents ++ if null listLevel then "\n" else ""
+
+blockToTextile _ (RawBlock f str) =
+ if f == "html" || f == "textile"
+ then return str
+ else return ""
+
+blockToTextile _ HorizontalRule = return "<hr />\n"
+
+blockToTextile opts (Header level inlines) = do
+ contents <- inlineListToTextile opts inlines
+ let prefix = 'h' : (show level ++ ". ")
+ return $ prefix ++ contents ++ "\n"
+
+blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =
+ return $ "<pre" ++ classes' ++ ">\n" ++ escapeStringForXML str ++
+ "\n</pre>\n"
+ where classes' = if null classes
+ then ""
+ else " class=\"" ++ unwords classes ++ "\""
+
+blockToTextile _ (CodeBlock (_,classes,_) str) =
+ return $ "bc" ++ classes' ++ ". " ++ str ++ "\n\n"
+ where classes' = if null classes
+ then ""
+ else "(" ++ unwords classes ++ ")"
+
+blockToTextile opts (BlockQuote bs@[Para _]) = do
+ contents <- blockListToTextile opts bs
+ return $ "bq. " ++ contents ++ "\n\n"
+
+blockToTextile opts (BlockQuote blocks) = do
+ contents <- blockListToTextile opts blocks
+ return $ "<blockquote>\n\n" ++ contents ++ "\n</blockquote>\n"
+
+blockToTextile opts (Table [] aligns widths headers rows') |
+ all (==0) widths && all (`elem` [AlignLeft,AlignDefault]) aligns = do
+ hs <- mapM (liftM (("_. " ++) . stripTrailingNewlines) . blockListToTextile opts) headers
+ let cellsToRow cells = "|" ++ intercalate "|" cells ++ "|"
+ let header = if all null headers then "" else cellsToRow hs
+ let rowToCells = mapM (liftM stripTrailingNewlines . blockListToTextile opts)
+ bs <- mapM rowToCells rows'
+ let body = unlines $ map cellsToRow bs
+ return $ header ++ "\n" ++ body ++ "\n"
+
+blockToTextile opts (Table capt aligns widths headers rows') = do
+ let alignStrings = map alignmentToString aligns
+ captionDoc <- if null capt
+ then return ""
+ else do
+ c <- inlineListToTextile opts capt
+ return $ "<caption>" ++ c ++ "</caption>\n"
+ let percent w = show (truncate (100*w) :: Integer) ++ "%"
+ let coltags = if all (== 0.0) widths
+ then ""
+ else unlines $ map
+ (\w -> "<col width=\"" ++ percent w ++ "\" />") widths
+ head' <- if all null headers
+ then return ""
+ else do
+ hs <- tableRowToTextile opts alignStrings 0 headers
+ return $ "<thead>\n" ++ hs ++ "\n</thead>\n"
+ body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows'
+ return $ "<table>\n" ++ captionDoc ++ coltags ++ head' ++
+ "<tbody>\n" ++ unlines body' ++ "</tbody>\n</table>\n"
+
+blockToTextile opts x@(BulletList items) = do
+ oldUseTags <- liftM stUseTags get
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- withUseTags $ mapM (listItemToTextile opts) items
+ return $ "<ul>\n" ++ vcat contents ++ "\n</ul>\n"
+ else do
+ modify $ \s -> s { stListLevel = stListLevel s ++ "*" }
+ level <- get >>= return . length . stListLevel
+ contents <- mapM (listItemToTextile opts) items
+ modify $ \s -> s { stListLevel = init (stListLevel s) }
+ return $ vcat contents ++ (if level > 1 then "" else "\n")
+
+blockToTextile opts x@(OrderedList attribs items) = do
+ oldUseTags <- liftM stUseTags get
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- withUseTags $ mapM (listItemToTextile opts) items
+ return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++
+ "\n</ol>\n"
+ else do
+ modify $ \s -> s { stListLevel = stListLevel s ++ "#" }
+ level <- get >>= return . length . stListLevel
+ contents <- mapM (listItemToTextile opts) items
+ modify $ \s -> s { stListLevel = init (stListLevel s) }
+ return $ vcat contents ++ (if level > 1 then "" else "\n")
+
+blockToTextile opts (DefinitionList items) = do
+ contents <- withUseTags $ mapM (definitionListItemToTextile opts) items
+ return $ "<dl>\n" ++ vcat contents ++ "\n</dl>\n"
+
+-- Auxiliary functions for lists:
+
+-- | Convert ordered list attributes to HTML attribute string
+listAttribsToString :: ListAttributes -> String
+listAttribsToString (startnum, numstyle, _) =
+ let numstyle' = camelCaseToHyphenated $ show numstyle
+ in (if startnum /= 1
+ then " start=\"" ++ show startnum ++ "\""
+ else "") ++
+ (if numstyle /= DefaultStyle
+ then " style=\"list-style-type: " ++ numstyle' ++ ";\""
+ else "")
+
+-- | Convert bullet or ordered list item (list of blocks) to Textile.
+listItemToTextile :: WriterOptions -> [Block] -> State WriterState String
+listItemToTextile opts items = do
+ contents <- blockListToTextile opts items
+ useTags <- get >>= return . stUseTags
+ if useTags
+ then return $ "<li>" ++ contents ++ "</li>"
+ else do
+ marker <- get >>= return . stListLevel
+ return $ marker ++ " " ++ contents
+
+-- | Convert definition list item (label, list of blocks) to Textile.
+definitionListItemToTextile :: WriterOptions
+ -> ([Inline],[[Block]])
+ -> State WriterState String
+definitionListItemToTextile opts (label, items) = do
+ labelText <- inlineListToTextile opts label
+ contents <- mapM (blockListToTextile opts) items
+ return $ "<dt>" ++ labelText ++ "</dt>\n" ++
+ (intercalate "\n" $ map (\d -> "<dd>" ++ d ++ "</dd>") contents)
+
+-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
+isSimpleList :: Block -> Bool
+isSimpleList x =
+ case x of
+ BulletList items -> all isSimpleListItem items
+ OrderedList (num, sty, _) items -> all isSimpleListItem items &&
+ num == 1 && sty `elem` [DefaultStyle, Decimal]
+ _ -> False
+
+-- | True if list item can be handled with the simple wiki syntax. False if
+-- HTML tags will be needed.
+isSimpleListItem :: [Block] -> Bool
+isSimpleListItem [] = True
+isSimpleListItem [x] =
+ case x of
+ Plain _ -> True
+ Para _ -> True
+ BulletList _ -> isSimpleList x
+ OrderedList _ _ -> isSimpleList x
+ _ -> False
+isSimpleListItem [x, y] | isPlainOrPara x =
+ case y of
+ BulletList _ -> isSimpleList y
+ OrderedList _ _ -> isSimpleList y
+ _ -> False
+isSimpleListItem _ = False
+
+isPlainOrPara :: Block -> Bool
+isPlainOrPara (Plain _) = True
+isPlainOrPara (Para _) = True
+isPlainOrPara _ = False
+
+-- | Concatenates strings with line breaks between them.
+vcat :: [String] -> String
+vcat = intercalate "\n"
+
+-- Auxiliary functions for tables. (TODO: these are common to HTML, MediaWiki,
+-- and Textile writers, and should be abstracted out.)
+
+tableRowToTextile :: WriterOptions
+ -> [String]
+ -> Int
+ -> [[Block]]
+ -> State WriterState String
+tableRowToTextile opts alignStrings rownum cols' = do
+ let celltype = if rownum == 0 then "th" else "td"
+ let rowclass = case rownum of
+ 0 -> "header"
+ x | x `rem` 2 == 1 -> "odd"
+ _ -> "even"
+ cols'' <- sequence $ zipWith
+ (\alignment item -> tableItemToTextile opts celltype alignment item)
+ alignStrings cols'
+ return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"
+
+alignmentToString :: Alignment -> [Char]
+alignmentToString alignment = case alignment of
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> "left"
+
+tableItemToTextile :: WriterOptions
+ -> String
+ -> String
+ -> [Block]
+ -> State WriterState String
+tableItemToTextile opts celltype align' item = do
+ let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++
+ x ++ "</" ++ celltype ++ ">"
+ contents <- blockListToTextile opts item
+ return $ mkcell contents
+
+-- | Convert list of Pandoc block elements to Textile.
+blockListToTextile :: WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> State WriterState String
+blockListToTextile opts blocks =
+ mapM (blockToTextile opts) blocks >>= return . vcat
+
+-- | Convert list of Pandoc inline elements to Textile.
+inlineListToTextile :: WriterOptions -> [Inline] -> State WriterState String
+inlineListToTextile opts lst =
+ mapM (inlineToTextile opts) lst >>= return . concat
+
+-- | Convert Pandoc inline element to Textile.
+inlineToTextile :: WriterOptions -> Inline -> State WriterState String
+
+inlineToTextile opts (Emph lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '_' `elem` contents
+ then "<em>" ++ contents ++ "</em>"
+ else "_" ++ contents ++ "_"
+
+inlineToTextile opts (Strong lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '*' `elem` contents
+ then "<strong>" ++ contents ++ "</strong>"
+ else "*" ++ contents ++ "*"
+
+inlineToTextile opts (Strikeout lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '-' `elem` contents
+ then "<del>" ++ contents ++ "</del>"
+ else "-" ++ contents ++ "-"
+
+inlineToTextile opts (Superscript lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '^' `elem` contents
+ then "<sup>" ++ contents ++ "</sup>"
+ else "[^" ++ contents ++ "^]"
+
+inlineToTextile opts (Subscript lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '~' `elem` contents
+ then "<sub>" ++ contents ++ "</sub>"
+ else "[~" ++ contents ++ "~]"
+
+inlineToTextile opts (SmallCaps lst) = inlineListToTextile opts lst
+
+inlineToTextile opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ "'" ++ contents ++ "'"
+
+inlineToTextile opts (Quoted DoubleQuote lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ "\"" ++ contents ++ "\""
+
+inlineToTextile opts (Cite _ lst) = inlineListToTextile opts lst
+
+inlineToTextile _ EmDash = return " -- "
+
+inlineToTextile _ EnDash = return " - "
+
+inlineToTextile _ Apostrophe = return "'"
+
+inlineToTextile _ Ellipses = return "..."
+
+inlineToTextile _ (Code _ str) =
+ return $ if '@' `elem` str
+ then "<tt>" ++ escapeStringForXML str ++ "</tt>"
+ else "@" ++ str ++ "@"
+
+inlineToTextile _ (Str str) = return $ escapeStringForTextile str
+
+inlineToTextile _ (Math _ str) =
+ return $ "<span class=\"math\">" ++ escapeStringForXML str ++ "</math>"
+
+inlineToTextile _ (RawInline f str) =
+ if f == "html" || f == "textile"
+ then return str
+ else return ""
+
+inlineToTextile _ (LineBreak) = return "\n"
+
+inlineToTextile _ Space = return " "
+
+inlineToTextile opts (Link txt (src, _)) = do
+ label <- case txt of
+ [Code _ s] -> return s
+ _ -> inlineListToTextile opts txt
+ return $ "\"" ++ label ++ "\":" ++ src
+
+inlineToTextile opts (Image alt (source, tit)) = do
+ alt' <- inlineListToTextile opts alt
+ let txt = if null tit
+ then if null alt'
+ then ""
+ else "(" ++ alt' ++ ")"
+ else "(" ++ tit ++ ")"
+ return $ "!" ++ source ++ txt ++ "!"
+
+inlineToTextile opts (Note contents) = do
+ curNotes <- liftM stNotes get
+ let newnum = length curNotes + 1
+ contents' <- blockListToTextile opts contents
+ let thisnote = "fn" ++ show newnum ++ ". " ++ contents' ++ "\n"
+ modify $ \s -> s { stNotes = thisnote : curNotes }
+ return $ "[" ++ show newnum ++ "]"
+ -- note - may not work for notes with multiple blocks
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs
index 0c48b48df..e21525018 100644
--- a/src/Text/Pandoc/XML.hs
+++ b/src/Text/Pandoc/XML.hs
@@ -34,7 +34,8 @@ module Text.Pandoc.XML ( stripTags,
selfClosingTag,
inTagsSimple,
inTagsIndented ) where
-import Text.PrettyPrint.HughesPJ
+
+import Text.Pandoc.Pretty
-- | Remove everything between <...>
stripTags :: String -> String
@@ -55,23 +56,15 @@ escapeCharForXML x = case x of
'"' -> "&quot;"
c -> [c]
--- | True if the character needs to be escaped.
-needsEscaping :: Char -> Bool
-needsEscaping c = c `elem` "&<>\""
-
-- | Escape string as needed for XML. Entity references are not preserved.
escapeStringForXML :: String -> String
-escapeStringForXML "" = ""
-escapeStringForXML str =
- case break needsEscaping str of
- (okay, "") -> okay
- (okay, (c:cs)) -> okay ++ escapeCharForXML c ++ escapeStringForXML cs
+escapeStringForXML = concatMap escapeCharForXML
-- | Return a text object with a string of formatted XML attributes.
attributeList :: [(String, String)] -> Doc
-attributeList = text . concatMap
- (\(a, b) -> " " ++ escapeStringForXML a ++ "=\"" ++
- escapeStringForXML b ++ "\"")
+attributeList = hcat . map
+ (\(a, b) -> text (' ' : escapeStringForXML a ++ "=\"" ++
+ escapeStringForXML b ++ "\""))
-- | Put the supplied contents between start and end tags of tagType,
-- with specified attributes and (if specified) indentation.
diff --git a/src/markdown2pdf.hs b/src/markdown2pdf.hs
index cc6a034c0..4070001f1 100644
--- a/src/markdown2pdf.hs
+++ b/src/markdown2pdf.hs
@@ -155,7 +155,7 @@ main = bracket
"--include-before-body","--include-after-body",
"--custom-header","--output",
"--template", "--variable",
- "--csl", "--biblio", "--biblio-format"]
+ "--csl", "--bibliography", "--data-dir", "--listings"]
let isOpt ('-':_) = True
isOpt _ = False
let opts = filter isOpt args
diff --git a/src/pandoc.hs b/src/pandoc.hs
index ef38c0332..c0f457449 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -32,29 +32,27 @@ module Main where
import Text.Pandoc
import Text.Pandoc.S5 (s5HeaderIncludes)
import Text.Pandoc.Shared ( tabFilter, ObfuscationMethod (..), readDataFile,
- headerShift )
+ headerShift, findDataFile, normalize )
#ifdef _HIGHLIGHTING
import Text.Pandoc.Highlighting ( languages )
#endif
-import System.Environment ( getArgs, getProgName, getEnvironment )
+import System.Environment ( getArgs, getProgName )
import System.Exit ( exitWith, ExitCode (..) )
import System.FilePath
import System.Console.GetOpt
-import Data.Char ( toLower, isDigit )
-import Data.List ( intercalate, isSuffixOf )
-import System.Directory ( getAppUserDataDirectory )
+import Data.Char ( toLower )
+import Data.List ( intercalate, isSuffixOf, isPrefixOf )
+import System.Directory ( getAppUserDataDirectory, doesFileExist )
import System.IO ( stdout, stderr )
import qualified Text.Pandoc.UTF8 as UTF8
-#ifdef _CITEPROC
import Text.CSL
import Text.Pandoc.Biblio
-#endif
import Control.Monad (when, unless, liftM)
import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
-import Network.URI (parseURI, isURI)
+import Network.URI (parseURI, isURI, URI(..))
import qualified Data.ByteString.Lazy as B
-import Data.ByteString.Lazy.UTF8 (toString, fromString)
-import Codec.Binary.UTF8.String (decodeString)
+import Data.ByteString.Lazy.UTF8 (toString )
+import Codec.Binary.UTF8.String (decodeString, encodeString)
copyrightMessage :: String
copyrightMessage = "\nCopyright (C) 2006-2010 John MacFarlane\n" ++
@@ -64,9 +62,7 @@ copyrightMessage = "\nCopyright (C) 2006-2010 John MacFarlane\n" ++
compileInfo :: String
compileInfo =
-#ifdef _CITEPROC
"\nCompiled with citeproc support." ++
-#endif
#ifdef _HIGHLIGHTING
"\nCompiled with syntax highlighting support for:\n" ++
wrapWords 78 languages ++
@@ -84,47 +80,6 @@ wrapWords c = wrap' c c where
then ",\n" ++ x ++ wrap' cols (cols - length x) xs
else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs
--- | Association list of formats and readers.
-readers :: [(String, ParserState -> String -> Pandoc)]
-readers = [("native" , readPandoc)
- ,("markdown" , readMarkdown)
- ,("markdown+lhs" , readMarkdown)
- ,("rst" , readRST)
- ,("rst+lhs" , readRST)
- ,("html" , readHtml)
- ,("latex" , readLaTeX)
- ,("latex+lhs" , readLaTeX)
- ]
-
--- | Reader for native Pandoc format.
-readPandoc :: ParserState -> String -> Pandoc
-readPandoc _ = read
-
--- | Association list of formats and writers.
-writers :: [ ( String, WriterOptions -> Pandoc -> String ) ]
-writers = [("native" , writeNative)
- ,("html" , writeHtmlString)
- ,("html+lhs" , writeHtmlString)
- ,("s5" , writeHtmlString)
- ,("slidy" , writeHtmlString)
- ,("docbook" , writeDocbook)
- ,("opendocument" , writeOpenDocument)
- ,("odt" , \_ _ -> "")
- ,("epub" , \_ _ -> "")
- ,("latex" , writeLaTeX)
- ,("latex+lhs" , writeLaTeX)
- ,("context" , writeConTeXt)
- ,("texinfo" , writeTexinfo)
- ,("man" , writeMan)
- ,("markdown" , writeMarkdown)
- ,("markdown+lhs" , writeMarkdown)
- ,("plain" , writePlain)
- ,("rst" , writeRST)
- ,("rst+lhs" , writeRST)
- ,("mediawiki" , writeMediaWiki)
- ,("rtf" , writeRTF)
- ]
-
isNonTextOutput :: String -> Bool
isNonTextOutput = (`elem` ["odt","epub"])
@@ -147,6 +102,8 @@ data Opt = Opt
, optOffline :: Bool -- ^ Make slideshow accessible offline
, optXeTeX :: Bool -- ^ Format latex for xetex
, optSmart :: Bool -- ^ Use smart typography
+ , optHtml5 :: Bool -- ^ Produce HTML5 in HTML
+ , optChapters :: Bool -- ^ Use chapter for top-level sects
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
, optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
, optEPUBStylesheet :: Maybe String -- ^ EPUB stylesheet
@@ -156,17 +113,16 @@ data Opt = Opt
, optStrict :: Bool -- ^ Use strict markdown syntax
, optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
, optWrapText :: Bool -- ^ Wrap text
- , optSanitizeHTML :: Bool -- ^ Sanitize HTML
+ , optColumns :: Int -- ^ Line length in characters
, optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
, optEmailObfuscation :: ObfuscationMethod
, optIdentifierPrefix :: String
, optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
, optDataDir :: Maybe FilePath
-#ifdef _CITEPROC
- , optBiblioFile :: String
- , optBiblioFormat :: String
- , optCslFile :: String
-#endif
+ , optCiteMethod :: CiteMethod -- ^ Method to output cites
+ , optBibliography :: [String]
+ , optCslFile :: FilePath
+ , optListings :: Bool -- ^ Use listings package for code blocks
}
-- | Defaults for command-line options.
@@ -189,6 +145,8 @@ defaultOpts = Opt
, optOffline = False
, optXeTeX = False
, optSmart = False
+ , optHtml5 = False
+ , optChapters = False
, optHTMLMathMethod = PlainMath
, optReferenceODT = Nothing
, optEPUBStylesheet = Nothing
@@ -198,17 +156,16 @@ defaultOpts = Opt
, optStrict = False
, optReferenceLinks = False
, optWrapText = True
- , optSanitizeHTML = False
+ , optColumns = 72
, optPlugins = []
, optEmailObfuscation = JavascriptObfuscation
, optIdentifierPrefix = ""
, optIndentedCodeClasses = []
, optDataDir = Nothing
-#ifdef _CITEPROC
- , optBiblioFile = []
- , optBiblioFormat = []
- , optCslFile = []
-#endif
+ , optCiteMethod = Citeproc
+ , optBibliography = []
+ , optCslFile = ""
+ , optListings = False
}
-- | A list of functions, each transforming the options data structure
@@ -219,13 +176,13 @@ options =
(ReqArg
(\arg opt -> return opt { optReader = map toLower arg })
"FORMAT")
- "" -- ("(" ++ (intercalate ", " $ map fst readers) ++ ")")
+ ""
, Option "tw" ["to","write"]
(ReqArg
(\arg opt -> return opt { optWriter = map toLower arg })
"FORMAT")
- "" -- ("(" ++ (intercalate ", " $ map fst writers) ++ ")")
+ ""
, Option "s" ["standalone"]
(NoArg
@@ -245,8 +202,14 @@ options =
, Option "" ["tab-stop"]
(ReqArg
- (\arg opt -> return opt { optTabStop = (read arg) } )
- "TABSTOP")
+ (\arg opt ->
+ case reads arg of
+ [(t,"")] | t > 0 -> return opt { optTabStop = t }
+ _ -> do
+ UTF8.hPutStrLn stderr $
+ "tab-stop must be a number greater than 0"
+ exitWith $ ExitFailure 31)
+ "NUMBER")
"" -- "Tab stop (default 4)"
, Option "" ["strict"]
@@ -254,6 +217,12 @@ options =
(\opt -> return opt { optStrict = True } ))
"" -- "Disable markdown syntax extensions"
+ , Option "" ["normalize"]
+ (NoArg
+ (\opt -> return opt { optTransforms =
+ normalize : optTransforms opt } ))
+ "" -- "Normalize the Pandoc AST"
+
, Option "" ["reference-links"]
(NoArg
(\opt -> return opt { optReferenceLinks = True } ))
@@ -269,6 +238,11 @@ options =
(\opt -> return opt { optSmart = True }))
"" -- "Use smart quotes, dashes, and ellipses"
+ , Option "5" ["html5"]
+ (NoArg
+ (\opt -> return opt { optHtml5 = True }))
+ "" -- "Produce HTML5 in HTML output"
+
, Option "m" ["latexmathml", "asciimathml"]
(OptArg
(\arg opt ->
@@ -309,6 +283,12 @@ options =
"URL")
"" -- "Use jsMath for HTML math"
+ , Option "" ["mathjax"]
+ (ReqArg
+ (\arg opt -> return opt { optHTMLMathMethod = MathJax arg})
+ "URL")
+ "" -- "Use MathJax for HTML math"
+
, Option "" ["gladtex"]
(NoArg
(\opt -> return opt { optHTMLMathMethod = GladTeX }))
@@ -330,11 +310,21 @@ options =
(\opt -> return opt { optXeTeX = True }))
"" -- "Format latex for processing by XeTeX"
+ , Option "" ["chapters"]
+ (NoArg
+ (\opt -> return opt { optChapters = True }))
+ "" -- "Use chapter for top-level sections in LaTeX, DocBook"
+
, Option "N" ["number-sections"]
(NoArg
(\opt -> return opt { optNumberSections = True }))
"" -- "Number sections in LaTeX"
+ , Option "" ["listings"]
+ (NoArg
+ (\opt -> return opt { optListings = True }))
+ "" -- "Use listings package for LaTeX code blocks"
+
, Option "" ["section-divs"]
(NoArg
(\opt -> return opt { optSectionDivs = True }))
@@ -345,10 +335,17 @@ options =
(\opt -> return opt { optWrapText = False }))
"" -- "Do not wrap text in output"
- , Option "" ["sanitize-html"]
- (NoArg
- (\opt -> return opt { optSanitizeHTML = True }))
- "" -- "Sanitize HTML"
+ , Option "" ["columns"]
+ (ReqArg
+ (\arg opt ->
+ case reads arg of
+ [(t,"")] | t > 0 -> return opt { optColumns = t }
+ _ -> do
+ UTF8.hPutStrLn stderr $
+ "columns must be a number greater than 0"
+ exitWith $ ExitFailure 33)
+ "NUMBER")
+ "" -- "Length of line in characters"
, Option "" ["email-obfuscation"]
(ReqArg
@@ -383,17 +380,18 @@ options =
, Option "" ["base-header-level"]
(ReqArg
- (\arg opt -> do
- if all isDigit arg && (read arg :: Int) >= 1
- then do
- let oldTransforms = optTransforms opt
- let shift = read arg - 1
- return opt{ optTransforms =
- headerShift shift : oldTransforms }
- else do
- UTF8.hPutStrLn stderr $ "base-header-level must be a number >= 1"
- exitWith $ ExitFailure 19)
- "LEVEL")
+ (\arg opt ->
+ case reads arg of
+ [(t,"")] | t > 0 -> do
+ let oldTransforms = optTransforms opt
+ let shift = t - 1
+ return opt{ optTransforms =
+ headerShift shift : oldTransforms }
+ _ -> do
+ UTF8.hPutStrLn stderr $
+ "base-header-level must be a number > 0"
+ exitWith $ ExitFailure 19)
+ "NUMBER")
"" -- "Headers base level"
, Option "" ["template"]
@@ -415,7 +413,7 @@ options =
_ -> do
UTF8.hPutStrLn stderr $ "Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)"
exitWith $ ExitFailure 17)
- "FILENAME")
+ "KEY:VALUE")
"" -- "Use custom template"
, Option "c" ["css"]
@@ -461,16 +459,6 @@ options =
"FILENAME")
"" -- "File to include after document body"
- , Option "C" ["custom-header"]
- (ReqArg
- (\arg opt -> do
- text <- UTF8.readFile arg
- let newVars = ("legacy-header", text) : optVariables opt
- return opt { optVariables = newVars
- , optStandalone = True })
- "FILENAME")
- "" -- "File to use for custom header (implies -s)"
-
, Option "T" ["title-prefix"]
(ReqArg
(\arg opt -> do
@@ -513,23 +501,29 @@ options =
exitWith ExitSuccess)
"FORMAT")
"" -- "Print default template for FORMAT"
-#ifdef _CITEPROC
- , Option "" ["biblio"]
+
+ , Option "" ["bibliography"]
(ReqArg
- (\arg opt -> return opt { optBiblioFile = arg} )
+ (\arg opt -> return opt { optBibliography = (optBibliography opt) ++ [arg] })
"FILENAME")
""
- , Option "" ["biblio-format"]
- (ReqArg
- (\arg opt -> return opt { optBiblioFormat = arg} )
- "STRING")
- ""
+
, Option "" ["csl"]
(ReqArg
- (\arg opt -> return opt { optCslFile = arg} )
+ (\arg opt -> return opt { optCslFile = arg })
"FILENAME")
""
-#endif
+
+ , Option "" ["natbib"]
+ (NoArg
+ (\opt -> return opt { optCiteMethod = Natbib }))
+ "" -- "Use natbib cite commands in LaTeX output"
+
+ , Option "" ["biblatex"]
+ (NoArg
+ (\opt -> return opt { optCiteMethod = Biblatex }))
+ "" -- "Use biblatex cite commands in LaTeX output"
+
, Option "" ["data-dir"]
(ReqArg
(\arg opt -> return opt { optDataDir = Just arg })
@@ -569,7 +563,7 @@ usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
usageMessage programName = usageInfo
(programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
(intercalate ", " $ map fst readers) ++ "\nOutput formats: " ++
- (intercalate ", " $ map fst writers) ++ "\nOptions:")
+ (intercalate ", " $ map fst writers ++ ["odt","epub"]) ++ "\nOptions:")
-- Determine default reader based on source file extensions
defaultReaderName :: String -> [FilePath] -> String
@@ -584,7 +578,9 @@ defaultReaderName fallback (x:xs) =
".ltx" -> "latex"
".rst" -> "rst"
".lhs" -> "markdown+lhs"
+ ".textile" -> "textile"
".native" -> "native"
+ ".json" -> "json"
_ -> defaultReaderName fallback xs
-- Returns True if extension of first source is .lhs
@@ -607,16 +603,19 @@ defaultWriterName x =
".rst" -> "rst"
".s5" -> "s5"
".native" -> "native"
+ ".json" -> "json"
".txt" -> "markdown"
".text" -> "markdown"
".md" -> "markdown"
".markdown" -> "markdown"
+ ".textile" -> "textile"
".lhs" -> "markdown+lhs"
".texi" -> "texinfo"
".texinfo" -> "texinfo"
".db" -> "docbook"
".odt" -> "odt"
".epub" -> "epub"
+ ".org" -> "org"
['.',y] | y `elem` ['1'..'9'] -> "man"
_ -> "html"
@@ -663,6 +662,8 @@ main = do
, optOffline = offline
, optXeTeX = xetex
, optSmart = smart
+ , optHtml5 = html5
+ , optChapters = chapters
, optHTMLMathMethod = mathMethod
, optReferenceODT = referenceODT
, optEPUBStylesheet = epubStylesheet
@@ -672,16 +673,15 @@ main = do
, optStrict = strict
, optReferenceLinks = referenceLinks
, optWrapText = wrap
- , optSanitizeHTML = sanitize
+ , optColumns = columns
, optEmailObfuscation = obfuscationMethod
, optIdentifierPrefix = idPrefix
, optIndentedCodeClasses = codeBlockClasses
, optDataDir = mbDataDir
-#ifdef _CITEPROC
- , optBiblioFile = biblioFile
- , optBiblioFormat = biblioFormat
- , optCslFile = cslFile
-#endif
+ , optBibliography = reffiles
+ , optCslFile = cslfile
+ , optCiteMethod = citeMethod
+ , optListings = listings
} = opts
when dumpArgs $
@@ -689,13 +689,6 @@ main = do
mapM_ (\arg -> UTF8.hPutStrLn stdout arg) args
exitWith ExitSuccess
- -- warn about deprecated options
- case lookup "legacy-header" variables of
- Just _ -> UTF8.hPutStrLn stderr $
- "Warning: The -C/--custom-header is deprecated.\n" ++
- "Please transition to using --template instead."
- Nothing -> return ()
-
let sources = if ignoreArgs then [] else args
datadir <- case mbDataDir of
@@ -720,30 +713,13 @@ main = do
Just r -> return r
Nothing -> error ("Unknown reader: " ++ readerName')
- let writer = case lookup writerName' writers of
- Just _ | writerName' == "epub" -> writeEPUB epubStylesheet
- Just _ | writerName' == "odt" -> writeODT referenceODT
- Just r -> \o ->
- return . fromString . r o
- Nothing -> error $ "Unknown writer: " ++
- writerName'
-
templ <- getDefaultTemplate datadir writerName'
let defaultTemplate = case templ of
Right t -> t
Left e -> error (show e)
- environment <- getEnvironment
- let columns = case lookup "COLUMNS" environment of
- Just cols -> read cols
- Nothing -> stateColumns defaultParserState
-
let standalone' = standalone || isNonTextOutput writerName'
-#ifdef _CITEPROC
- refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat
-#endif
-
variables' <- case (writerName', standalone', offline) of
("s5", True, True) -> do
inc <- s5HeaderIncludes datadir
@@ -766,6 +742,11 @@ main = do
return $ ("mathml-script", s) : variables'
_ -> return variables'
+ refs <- mapM (\f -> catch (readBiblioFile f) $ \e -> do
+ UTF8.hPutStrLn stderr $ "Error reading bibliography `" ++ f ++ "'"
+ UTF8.hPutStrLn stderr $ show e
+ exitWith (ExitFailure 23)) reffiles >>= \rs -> return $ concat rs
+
let sourceDir = if null sources
then "."
else takeDirectory (head sources)
@@ -778,18 +759,16 @@ main = do
let startParserState =
defaultParserState { stateParseRaw = parseRaw,
stateTabStop = tabStop,
- stateSanitizeHTML = sanitize,
stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
lhsExtension sources,
stateStandalone = standalone',
-#ifdef _CITEPROC
- stateCitations = map citeKey refs,
-#endif
+ stateCitations = map refId refs,
stateSmart = smart || writerName' `elem`
- ["latex", "context", "man"],
+ ["latex", "context", "latex+lhs", "man"],
stateColumns = columns,
stateStrict = strict,
- stateIndentedCodeClasses = codeBlockClasses }
+ stateIndentedCodeClasses = codeBlockClasses,
+ stateApplyMacros = writerName' `notElem` ["latex", "latex+lhs"] }
let writerOptions = WriterOptions { writerStandalone = standalone',
writerTemplate = if null template
@@ -804,12 +783,15 @@ main = do
writerSlideVariant = slideVariant,
writerIncremental = incremental,
writerXeTeX = xetex,
+ writerCiteMethod = citeMethod,
+ writerBiblioFiles = reffiles,
writerIgnoreNotes = False,
writerNumberSections = numberSections,
writerSectionDivs = sectionDivs,
writerStrictMarkdown = strict,
writerReferenceLinks = referenceLinks,
writerWrapText = wrap,
+ writerColumns = columns,
writerLiterateHaskell = "+lhs" `isSuffixOf` writerName' ||
lhsExtension [outputFile],
writerEmailObfuscation = if strict
@@ -817,7 +799,11 @@ main = do
else obfuscationMethod,
writerIdentifierPrefix = idPrefix,
writerSourceDirectory = sourceDir,
- writerUserDataDir = datadir }
+ writerUserDataDir = datadir,
+ writerHtml5 = html5 &&
+ "html" `isPrefixOf` writerName',
+ writerChapters = chapters,
+ writerListings = listings }
when (isNonTextOutput writerName' && outputFile == "-") $
do UTF8.hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++
@@ -828,8 +814,9 @@ main = do
readSources srcs = mapM readSource srcs
readSource "-" = UTF8.getContents
readSource src = case parseURI src of
- Just u -> readURI u
- Nothing -> UTF8.readFile src
+ Just u | uriScheme u `elem` ["http:","https:"] ->
+ readURI u
+ _ -> UTF8.readFile src
readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
return . toString -- treat all as UTF8
@@ -837,17 +824,39 @@ main = do
doc <- fmap (reader startParserState . convertTabs . intercalate "\n") (readSources sources)
- let doc' = foldr ($) doc transforms
-
- doc'' <- do
-#ifdef _CITEPROC
- processBiblio cslFile refs doc'
-#else
- return doc'
-#endif
-
- writerOutput <- writer writerOptions doc''
-
- if outputFile == "-"
- then B.putStr writerOutput
- else B.writeFile outputFile writerOutput
+ let doc0 = foldr ($) doc transforms
+
+ doc1 <- if writerName' == "rtf"
+ then bottomUpM rtfEmbedImage doc0
+ else return doc0
+
+ doc2 <- do
+ if citeMethod == Citeproc && not (null refs)
+ then do
+ csldir <- getAppUserDataDirectory "csl"
+ cslfile' <- if null cslfile
+ then findDataFile datadir "default.csl"
+ else do
+ ex <- doesFileExist cslfile
+ if ex
+ then return cslfile
+ else findDataFile datadir $
+ replaceDirectory
+ (replaceExtension cslfile "csl")
+ csldir
+ processBiblio cslfile' refs doc1
+ else return doc1
+
+ case lookup writerName' writers of
+ Nothing | writerName' == "epub" ->
+ writeEPUB epubStylesheet writerOptions doc2
+ >>= B.writeFile (encodeString outputFile)
+ Nothing | writerName' == "odt" ->
+ writeODT referenceODT writerOptions doc2
+ >>= B.writeFile (encodeString outputFile)
+ Just r -> writerFn outputFile result
+ where writerFn "-" = UTF8.putStr
+ writerFn f = UTF8.writeFile f
+ result = r writerOptions doc2 ++
+ ['\n' | not standalone']
+ Nothing -> error $ "Unknown writer: " ++ writerName'
diff --git a/src/test-pandoc.hs b/src/test-pandoc.hs
new file mode 100644
index 000000000..2b6c2bb49
--- /dev/null
+++ b/src/test-pandoc.hs
@@ -0,0 +1,32 @@
+{-# OPTIONS_GHC -Wall #-}
+
+module Main where
+
+import Test.Framework
+
+import qualified Tests.Old
+import qualified Tests.Readers.LaTeX
+import qualified Tests.Readers.Markdown
+import qualified Tests.Readers.RST
+import qualified Tests.Writers.ConTeXt
+import qualified Tests.Writers.HTML
+import qualified Tests.Writers.Native
+import qualified Tests.Shared
+
+tests :: [Test]
+tests = [ testGroup "Old" Tests.Old.tests
+ , testGroup "Shared" Tests.Shared.tests
+ , testGroup "Writers"
+ [ testGroup "Native" Tests.Writers.Native.tests
+ , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
+ , testGroup "HTML" Tests.Writers.HTML.tests
+ ]
+ , testGroup "Readers"
+ [ testGroup "LaTeX" Tests.Readers.LaTeX.tests
+ , testGroup "Markdown" Tests.Readers.Markdown.tests
+ , testGroup "RST" Tests.Readers.RST.tests
+ ]
+ ]
+
+main :: IO ()
+main = defaultMain tests
diff --git a/templates/context.template b/templates/context.template
index 6d7e842a2..4269d06a1 100644
--- a/templates/context.template
+++ b/templates/context.template
@@ -1,6 +1,3 @@
-$if(legacy-header)$
-$legacy-header$
-$else$
\enableregime[utf] % use UTF-8
\setupcolors[state=start]
@@ -52,7 +49,6 @@ after={\blank[medium]},
]
\protect
-$endif$
$for(header-includes)$
$header-includes$
$endfor$
diff --git a/templates/docbook.template b/templates/docbook.template
index cd9ec59ca..66dfbef8d 100644
--- a/templates/docbook.template
+++ b/templates/docbook.template
@@ -1,10 +1,6 @@
-$if(legacy-header)$
-$legacy-header$
-$else$
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
-$endif$
<article>
<articleinfo>
<title>$title$</title>
diff --git a/templates/html.template b/templates/html.template
index bd1864ff0..3f8b76fed 100644
--- a/templates/html.template
+++ b/templates/html.template
@@ -1,8 +1,16 @@
+$if(html5)$
+<!DOCTYPE html>
+<html$if(lang)$ lang="$lang$"$endif$>
+$else$
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$>
+$endif$
<head>
- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
+$if(html5)$
+ <meta charset="utf-8" />
+$else$
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+$endif$
<meta name="generator" content="pandoc" />
$for(author)$
<meta name="author" content="$author$" />
@@ -10,17 +18,26 @@ $endfor$
$if(date)$
<meta name="date" content="$date$" />
$endif$
+ <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
+$if(html5)$
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+$endif$
$if(highlighting-css)$
<style type="text/css">
$highlighting-css$
</style>
$endif$
$for(css)$
- <link rel="stylesheet" href="$css$" type="text/css" />
+ <link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/>
$endfor$
$if(math)$
+$if(html5)$
+$else$
$math$
$endif$
+$endif$
$for(header-includes)$
$header-includes$
$endfor$
@@ -30,7 +47,13 @@ $for(include-before)$
$include-before$
$endfor$
$if(title)$
+$if(html5)$
+<header>
+$endif$
<h1 class="title">$title$</h1>
+$if(html5)$
+</header>
+$endif$
$endif$
$if(toc)$
$toc$
diff --git a/templates/latex.template b/templates/latex.template
index 4eb92e2c1..40de32109 100644
--- a/templates/latex.template
+++ b/templates/latex.template
@@ -1,7 +1,4 @@
-$if(legacy-header)$
-$legacy-header$
-$else$
-\documentclass{article}
+\documentclass$if(fontsize)$[$fontsize$]$endif${article}
\usepackage{amssymb,amsmath}
$if(xetex)$
\usepackage{ifxetex}
@@ -16,11 +13,20 @@ $else$
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
$endif$
+$if(natbib)$
+\usepackage{natbib}
+\bibliographystyle{plainnat}
+$endif$
+$if(biblatex)$
+\usepackage{biblatex}
+$if(biblio-files)$
+\bibliography{$biblio-files$}
+$endif$
+$endif$
$if(lhs)$
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
-$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
@@ -41,6 +47,8 @@ $if(tables)$
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
+% avoid problems with \sout in headers with hyperref:
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
$if(subscript)$
\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
@@ -60,9 +68,12 @@ $if(graphics)$
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
$endif$
-\usepackage[breaklinks=true,unicode=true]{hyperref}
+\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
+$if(listings)$
+\usepackage{listings}
+$endif$
$if(numbersections)$
$else$
\setcounter{secnumdepth}{0}
@@ -98,6 +109,21 @@ $if(toc)$
$endif$
$body$
+$if(biblio-files)$
+$if(natbib)$
+$if(biblio-title)$
+$if(book-class)$
+\renewcommand\bibname{$biblio-title$}
+$else$
+\renewcommand\refname{$biblio-title$}
+$endif$
+$endif$
+\bibliography{$biblio-files$}
+$endif$
+$endif$
+$if(biblatex)$
+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
+$endif$
$for(include-after)$
$include-after$
diff --git a/templates/mediawiki.template b/templates/mediawiki.template
index 673e2fc8d..5d210fa7d 100644
--- a/templates/mediawiki.template
+++ b/templates/mediawiki.template
@@ -1,6 +1,3 @@
-$if(legacy-header)$
-$legacy-header$
-$endif$
$for(include-before)$
$include-before$
diff --git a/templates/org.template b/templates/org.template
new file mode 100644
index 000000000..eaaa17533
--- /dev/null
+++ b/templates/org.template
@@ -0,0 +1,24 @@
+$if(title)$
+$title$
+
+$endif$
+$if(author)$
+#+AUTHOR: $for(author)$$author$$sep$; $endfor$
+$endif$
+$if(date)$
+#+DATE: $date$
+
+$endif$
+$for(header-includes)$
+$header-includes$
+
+$endfor$
+$for(include-before)$
+$include-before$
+
+$endfor$
+$body$
+$for(include-after)$
+
+$include-after$
+$endfor$
diff --git a/templates/rtf.template b/templates/rtf.template
index c5493cd34..833e19844 100644
--- a/templates/rtf.template
+++ b/templates/rtf.template
@@ -1,10 +1,6 @@
-$if(legacy-header)$
-$legacy-header$
-$else$
{\rtf1\ansi\deff0{\fonttbl{\f0 \fswiss Helvetica;}{\f1 Courier;}}
{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}
\widowctrl\hyphauto
-$endif$
$for(header-includes)$
$header-includes$
$endfor$
diff --git a/templates/s5.template b/templates/s5.template
index 480c1e435..c1f727f6e 100644
--- a/templates/s5.template
+++ b/templates/s5.template
@@ -1,7 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
$for(author)$
@@ -10,6 +9,7 @@ $endfor$
$if(date)$
<meta name="date" content="$date$" />
$endif$
+ <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
diff --git a/templates/slidy.template b/templates/slidy.template
index f625c36e2..9cfdb8f5e 100644
--- a/templates/slidy.template
+++ b/templates/slidy.template
@@ -3,7 +3,6 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
- <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
$for(author)$
@@ -13,6 +12,7 @@ $if(date)$
<meta name="date" content="$date$" />
$endif$
$if(highlighting-css)$
+ <title>$if(title-prefix)$$title-prefix$ - $endif$$if(pagetitle)$$pagetitle$$endif$</title>
<style type="text/css">
$highlighting-css$
</style>
diff --git a/templates/texinfo.template b/templates/texinfo.template
index 58948a068..9c1d8e178 100644
--- a/templates/texinfo.template
+++ b/templates/texinfo.template
@@ -1,9 +1,5 @@
-$if(legacy-header)$
-$legacy-header$
-$else$
\input texinfo
@documentencoding utf-8
-$endif$
$for(header-includes)$
$header-includes$
$endfor$
diff --git a/templates/textile.template b/templates/textile.template
new file mode 100644
index 000000000..69bd05b56
--- /dev/null
+++ b/templates/textile.template
@@ -0,0 +1,9 @@
+$for(include-before)$
+$include-before$
+
+$endfor$
+$body$
+$for(include-after)$
+
+$include-after$
+$endfor$
diff --git a/tests/RunTests.hs b/tests/RunTests.hs
deleted file mode 100644
index 1715400fd..000000000
--- a/tests/RunTests.hs
+++ /dev/null
@@ -1,181 +0,0 @@
-{-# OPTIONS_GHC -Wall #-}
--- RunTests.hs - run test suite for pandoc
--- This script is designed to be run from the tests directory.
--- It assumes the pandoc executable is in dist/build/pandoc.
---
--- runhaskell -i.. RunTests.hs [lhs]
---
--- If the lhs argument is provided, tests for lhs support will be
--- run. These presuppose that pandoc has been compiled with the
--- -fhighlighting flag, so these tests are not run by default.
---
--- This program assumes that the Diff package has been installed:
--- cabal install Diff
-
-module Main where
-import System.IO ( openTempFile, stderr, stdout, hFlush )
-import System.Process ( runProcess, waitForProcess )
-import System.FilePath ( (</>), (<.>) )
-import System.Directory
-import System.Environment
-import System.Exit
-import Text.Printf
-import Data.Algorithm.Diff
-import Prelude hiding ( readFile )
-import qualified Data.ByteString.Lazy as B
-import Data.ByteString.Lazy.UTF8 (toString, fromString)
-
-readFileUTF8 :: FilePath -> IO String
-readFileUTF8 f = B.readFile f >>= return . toString
-
-pandocPath :: FilePath
-pandocPath = ".." </> "dist" </> "build" </> "pandoc" </> "pandoc"
-
-data TestResult = TestPassed
- | TestError ExitCode
- | TestFailed [(DI, String)]
- deriving (Eq)
-
-instance Show TestResult where
- show TestPassed = "PASSED"
- show (TestError ec) = "ERROR " ++ show ec
- show (TestFailed d) = "FAILED\n" ++ showDiff d
-
-showDiff :: [(DI, String)] -> String
-showDiff [] = ""
-showDiff ((F, ln) : ds) = "|TEST| " ++ ln ++ "\n" ++ showDiff ds
-showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds
-showDiff ((B, _ ) : ds) = showDiff ds
-
-writerFormats :: [String]
-writerFormats = [ "native"
- , "html"
- , "docbook"
- , "opendocument"
- , "latex"
- , "context"
- , "texinfo"
- , "man"
- , "plain"
- , "markdown"
- , "rst"
- , "mediawiki"
- , "rtf"
- ]
-
-lhsWriterFormats :: [String]
-lhsWriterFormats = [ "markdown"
- , "markdown+lhs"
- , "rst"
- , "rst+lhs"
- , "latex"
- , "latex+lhs"
- , "html"
- , "html+lhs"
- ]
-
-lhsReaderFormats :: [String]
-lhsReaderFormats = [ "markdown+lhs"
- , "rst+lhs"
- , "latex+lhs"
- ]
-
-main :: IO ()
-main = do
- args <- getArgs
- let runLhsTests = "lhs" `elem` args
- r1s <- mapM runWriterTest writerFormats
- r2 <- runS5WriterTest "basic" ["-s"] "s5"
- r3 <- runS5WriterTest "fancy" ["-s","-m","-i"] "s5"
- r4 <- runS5WriterTest "fragment" [] "html"
- r5 <- runS5WriterTest "inserts" ["-s", "-H", "insert",
- "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
- r6 <- runTest "markdown reader" ["-r", "markdown", "-w", "native", "-s", "-S"]
- "testsuite.txt" "testsuite.native"
- r7 <- runTest "markdown reader (tables)" ["-r", "markdown", "-w", "native"]
- "tables.txt" "tables.native"
- r7a <- runTest "markdown reader (more)" ["-r", "markdown", "-w", "native"]
- "markdown-reader-more.txt" "markdown-reader-more.native"
- r8 <- runTest "rst reader" ["-r", "rst", "-w", "native", "-s", "-S"]
- "rst-reader.rst" "rst-reader.native"
- r8a <- runTest "rst reader (tables)" ["-r", "rst", "-w", "native"]
- "tables.rst" "tables-rstsubset.native"
- r9 <- runTest "html reader" ["-r", "html", "-w", "native", "-s"]
- "html-reader.html" "html-reader.native"
- r10 <- runTest "latex reader" ["-r", "latex", "-w", "native", "-s", "-R"]
- "latex-reader.latex" "latex-reader.native"
- r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"]
- "testsuite.native" "testsuite.native"
- r12s <- if runLhsTests
- then mapM runLhsWriterTest lhsWriterFormats
- else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return []
- r13s <- if runLhsTests
- then mapM runLhsReaderTest lhsReaderFormats
- else putStrLn "Skipping lhs reader tests because they presuppose highlighting support" >> return []
- let results = r1s ++
- [ r2, r3, r4, r5 -- S5
- , r6, r7, r7a -- markdown reader
- , r8, r8a -- rst
- , r9 -- html
- , r10 -- latex
- , r11 -- native
- ] ++ r12s ++ r13s
- if all id results
- then do
- putStrLn "\nAll tests passed."
- exitWith ExitSuccess
- else do
- let failures = length $ filter not results
- putStrLn $ "\n" ++ show failures ++ " tests failed."
- exitWith (ExitFailure failures)
-
--- makes sure file is fully closed after reading
-readFile' :: FilePath -> IO String
-readFile' f = do s <- readFileUTF8 f
- return $! (length s `seq` s)
-
-runLhsWriterTest :: String -> IO Bool
-runLhsWriterTest format =
- runTest ("(lhs) " ++ format ++ " writer") ["-r", "native", "-s", "-w", format] "lhs-test.native" ("lhs-test" <.> format)
-
-runLhsReaderTest :: String -> IO Bool
-runLhsReaderTest format =
- runTest ("(lhs) " ++ format ++ " reader") ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
-
-runWriterTest :: String -> IO Bool
-runWriterTest format = do
- r1 <- runTest (format ++ " writer") ["-r", "native", "-s", "-w", format] "testsuite.native" ("writer" <.> format)
- r2 <- runTest (format ++ " writer (tables)") ["-r", "native", "-w", format] "tables.native" ("tables" <.> format)
- return (r1 && r2)
-
-runS5WriterTest :: String -> [String] -> String -> IO Bool
-runS5WriterTest modifier opts format = runTest (format ++ " writer (" ++ modifier ++ ")")
- (["-r", "native", "-w", format] ++ opts) "s5.native" ("s5." ++ modifier <.> "html")
-
--- | Run a test, return True if test passed.
-runTest :: String -- ^ Title of test
- -> [String] -- ^ Options to pass to pandoc
- -> String -- ^ Input filepath
- -> FilePath -- ^ Norm (for test results) filepath
- -> IO Bool
-runTest testname opts inp norm = do
- putStr $ printf "%-28s ---> " testname
- (outputPath, hOut) <- openTempFile "" "pandoc-test"
- let inpPath = inp
- let normPath = norm
- hFlush stdout
- -- Note: COLUMNS must be set for markdown table reader
- ph <- runProcess pandocPath (opts ++ [inpPath] ++ ["--data-dir", ".."]) Nothing (Just [("COLUMNS", "80")]) Nothing (Just hOut) (Just stderr)
- ec <- waitForProcess ph
- result <- if ec == ExitSuccess
- then do
- -- filter \r so the tests will work on Windows machines
- outputContents <- readFile' outputPath >>= return . filter (/='\r')
- normContents <- readFile' normPath >>= return . filter (/='\r')
- if outputContents == normContents
- then return TestPassed
- else return $ TestFailed $ getDiff (lines outputContents) (lines normContents)
- else return $ TestError ec
- removeFile outputPath
- B.putStrLn (fromString $ show result)
- return (result == TestPassed)
diff --git a/tests/biblio.bib b/tests/biblio.bib
new file mode 100644
index 000000000..755d535a8
--- /dev/null
+++ b/tests/biblio.bib
@@ -0,0 +1,26 @@
+@Book{item1,
+author="John Doe",
+title="First Book",
+year="2005",
+address="Cambridge",
+publisher="Cambridge University Press"
+}
+
+@Article{item2,
+author="John Doe",
+title="Article",
+year="2006",
+journal="Journal of Generic Studies",
+volume="6",
+pages="33-34"
+}
+
+@InCollection{item3,
+author="John Doe and Jenny Roe",
+title="Why Water Is Wet",
+booktitle="Third Book",
+editor="Sam Smith",
+publisher="Oxford University Press",
+address="Oxford",
+year="2007"
+}
diff --git a/tests/chicago-author-date.csl b/tests/chicago-author-date.csl
new file mode 100644
index 000000000..f16f82305
--- /dev/null
+++ b/tests/chicago-author-date.csl
@@ -0,0 +1,369 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" page-range-format="chicago">
+ <info>
+ <title>Chicago Manual of Style (Author-Date format)</title>
+ <id>http://www.zotero.org/styles/chicago-author-date</id>
+ <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>
+ <author>
+ <name>Julian Onions</name>
+ <email>julian.onions@gmail.com</email>
+ </author>
+ <category citation-format="author-date"/>
+ <category field="generic-base"/>
+ <updated>2009-12-04T20:22:16+00:00</updated>
+ <summary>The author-date variant of the Chicago style</summary>
+ <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
+ </info>
+ <macro name="secondary-contributors">
+ <choose>
+ <if match="none" type="chapter">
+ <group delimiter=". ">
+ <choose>
+ <if variable="author">
+ <names variable="editor">
+ <label form="verb-short" prefix=" " suffix=". " text-case="capitalize-first" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ <choose>
+ <if match="any" variable="author editor">
+ <names variable="translator">
+ <label form="verb-short" prefix=" " suffix=". " text-case="capitalize-first" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="container-contributors">
+ <choose>
+ <if type="chapter">
+ <group delimiter=", " prefix=",">
+ <choose>
+ <if variable="author">
+ <names variable="editor">
+ <label form="verb-short" prefix=" " suffix=". " text-case="lowercase" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ <choose>
+ <if match="any" variable="author editor">
+ <names variable="translator">
+ <label form="verb-short" prefix=" " suffix=". " text-case="lowercase" />
+ <name and="text" delimiter=", " />
+ </names>
+ </if>
+ </choose>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="anon">
+ <choose>
+ <if match="none" variable="author editor translator">
+ <text form="short" term="anonymous" text-case="capitalize-first" />
+ </if>
+ </choose>
+ </macro>
+ <macro name="editor">
+ <names variable="editor">
+ <name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
+ <label form="short" prefix=", " suffix="." />
+ </names>
+ </macro>
+ <macro name="translator">
+ <names variable="translator">
+ <name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
+ <label form="verb-short" prefix=", " suffix="." />
+ </names>
+ </macro>
+ <macro name="recipient">
+ <choose>
+ <if type="personal_communication">
+ <choose>
+ <if variable="genre">
+ <text text-case="capitalize-first" variable="genre" />
+ </if>
+ <else>
+ <text term="letter" text-case="capitalize-first" />
+ </else>
+ </choose>
+ </if>
+ </choose>
+ <names delimiter=", " variable="recipient">
+ <label form="verb" prefix=" " suffix=" " text-case="lowercase" />
+ <name and="text" delimiter=", " />
+ </names>
+ </macro>
+ <macro name="contributors">
+ <names variable="author">
+ <name and="text" delimiter=", " delimiter-precedes-last="always" name-as-sort-order="first" sort-separator=", " />
+ <label form="verb-short" prefix=", " suffix="." text-case="lowercase" />
+ <substitute>
+ <text macro="editor" />
+ <text macro="translator" />
+ </substitute>
+ </names>
+ <text macro="anon" />
+ <text macro="recipient" />
+ </macro>
+ <macro name="contributors-short">
+ <names variable="author">
+ <name and="text" delimiter=", " form="short" />
+ <substitute>
+ <names variable="editor" />
+ <names variable="translator" />
+ </substitute>
+ </names>
+ <text macro="anon" />
+ </macro>
+ <macro name="interviewer">
+ <names delimiter=", " variable="interviewer">
+ <label form="verb" prefix=" " suffix=" " text-case="capitalize-first" />
+ <name and="text" delimiter=", " />
+ </names>
+ </macro>
+ <macro name="archive">
+ <group delimiter=". ">
+ <text text-case="capitalize-first" variable="archive_location" />
+ <text variable="archive" />
+ <text variable="archive-place" />
+ </group>
+ </macro>
+ <macro name="access">
+ <group delimiter=". ">
+ <choose>
+ <if match="any" type="graphic report">
+ <text macro="archive" />
+ </if>
+ <else-if match="none" type="book thesis chapter article-journal article-newspaper article-magazine">
+ <text macro="archive" />
+ </else-if>
+ </choose>
+ <text prefix="doi:" variable="DOI" />
+ <text variable="URL" />
+ </group>
+ </macro>
+ <macro name="title">
+ <choose>
+ <if match="none" variable="title">
+ <choose>
+ <if match="none" type="personal_communication">
+ <text text-case="capitalize-first" variable="genre" />
+ </if>
+ </choose>
+ </if>
+ <else-if type="book">
+ <text font-style="italic" variable="title" />
+ </else-if>
+ <else>
+ <text variable="title" />
+ </else>
+ </choose>
+ </macro>
+ <macro name="edition">
+ <choose>
+ <if match="any" type="book chapter">
+ <choose>
+ <if is-numeric="edition">
+ <group delimiter=" ">
+ <number form="ordinal" variable="edition" />
+ <text form="short" suffix="." term="edition" />
+ </group>
+ </if>
+ <else>
+ <text suffix="." variable="edition" />
+ </else>
+ </choose>
+ </if>
+ </choose>
+ </macro>
+ <macro name="locators">
+ <choose>
+ <if type="article-journal">
+ <text prefix=" " variable="volume" />
+ <text prefix=", no. " variable="issue" />
+ </if>
+ <else-if type="book">
+ <group delimiter=". " prefix=". ">
+ <group>
+ <text form="short" suffix=". " term="volume" text-case="capitalize-first" />
+ <number form="numeric" variable="volume" />
+ </group>
+ <group>
+ <number form="numeric" variable="number-of-volumes" />
+ <text form="short" plural="true" prefix=" " suffix="." term="volume" />
+ </group>
+ </group>
+ </else-if>
+ </choose>
+ </macro>
+ <macro name="locators-chapter">
+ <choose>
+ <if type="chapter">
+ <group prefix=", ">
+ <text suffix=":" variable="volume" />
+ <text variable="page" />
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="locators-article">
+ <choose>
+ <if type="article-newspaper">
+ <group delimiter=", " prefix=", ">
+ <group>
+ <text suffix=" " variable="edition" />
+ <text prefix=" " term="edition" />
+ </group>
+ <group>
+ <text form="short" suffix=". " term="section" />
+ <text variable="section" />
+ </group>
+ </group>
+ </if>
+ <else-if type="article-journal">
+ <text prefix=": " variable="page" />
+ </else-if>
+ </choose>
+ </macro>
+ <macro name="point-locators">
+ <group>
+ <choose>
+ <if locator="page" match="none">
+ <label form="short" suffix=" " variable="locator" />
+ </if>
+ </choose>
+ <text variable="locator" />
+ </group>
+ </macro>
+ <macro name="container-prefix">
+ <text term="in" text-case="capitalize-first" />
+ </macro>
+ <macro name="container-title">
+ <choose>
+ <if type="chapter">
+ <text macro="container-prefix" suffix=" " />
+ </if>
+ </choose>
+ <text font-style="italic" variable="container-title" />
+ </macro>
+ <macro name="publisher">
+ <group delimiter=": ">
+ <text variable="publisher-place" />
+ <text variable="publisher" />
+ </group>
+ </macro>
+ <macro name="date">
+ <date variable="issued">
+ <date-part name="year" />
+ </date>
+ </macro>
+ <macro name="day-month">
+ <date variable="issued">
+ <date-part name="month" />
+ <date-part name="day" prefix=" " />
+ </date>
+ </macro>
+ <macro name="collection-title">
+ <text variable="collection-title" />
+ <text prefix=" " variable="collection-number" />
+ </macro>
+ <macro name="event">
+ <group>
+ <text suffix=" " term="presented at" />
+ <text variable="event" />
+ </group>
+ </macro>
+ <macro name="description">
+ <group delimiter=". ">
+ <text macro="interviewer" />
+ <text text-case="capitalize-first" variable="medium" />
+ </group>
+ <choose>
+ <if match="none" variable="title"> </if>
+ <else-if type="thesis"> </else-if>
+ <else>
+ <text prefix=". " text-case="capitalize-first" variable="genre" />
+ </else>
+ </choose>
+ </macro>
+ <macro name="issue">
+ <choose>
+ <if type="article-journal">
+ <text macro="day-month" prefix=" (" suffix=")" />
+ </if>
+ <else-if type="speech">
+ <group delimiter=", " prefix=" ">
+ <text macro="event" />
+ <text macro="day-month" />
+ <text variable="event-place" />
+ </group>
+ </else-if>
+ <else-if match="any" type="article-newspaper article-magazine">
+ <text macro="day-month" prefix=", " />
+ </else-if>
+ <else>
+ <group delimiter=", " prefix=". ">
+ <choose>
+ <if type="thesis">
+ <text text-case="capitalize-first" variable="genre" />
+ </if>
+ </choose>
+ <text macro="publisher" />
+ <text macro="day-month" />
+ </group>
+ </else>
+ </choose>
+ </macro>
+ <citation
+ disambiguate-add-givenname="true"
+ disambiguate-add-names="true"
+ disambiguate-add-year-suffix="true"
+ et-al-min="4"
+ et-al-subsequent-min="4"
+ et-al-subsequent-use-first="1"
+ et-al-use-first="1">
+ <layout delimiter="; " prefix="(" suffix=")">
+ <group delimiter=", ">
+ <group delimiter=" ">
+ <text macro="contributors-short" />
+ <text macro="date" />
+ </group>
+ <text macro="point-locators" />
+ </group>
+ </layout>
+ </citation>
+ <bibliography
+ entry-spacing="0"
+ et-al-min="11"
+ et-al-use-first="7"
+ hanging-indent="true"
+ subsequent-author-substitute="---">
+ <sort>
+ <key macro="contributors" />
+ <key variable="issued" />
+ <key variable="title" />
+ </sort>
+ <layout suffix=".">
+ <text macro="contributors" suffix=". " />
+ <text macro="date" suffix=". " />
+ <text macro="title" />
+ <text macro="description" />
+ <text macro="secondary-contributors" prefix=". " />
+ <text macro="container-title" prefix=". " />
+ <text macro="container-contributors" />
+ <text macro="locators-chapter" />
+ <text macro="edition" prefix=". " />
+ <text macro="locators" />
+ <text macro="collection-title" prefix=". " />
+ <text macro="issue" />
+ <text macro="locators-article" />
+ <text macro="access" prefix=". " />
+ </layout>
+ </bibliography>
+</style>
diff --git a/tests/html-reader.html b/tests/html-reader.html
index da6c075b3..a51ee3307 100644
--- a/tests/html-reader.html
+++ b/tests/html-reader.html
@@ -340,7 +340,7 @@ foo<p>This should just be an HTML comment:</p>
<p>So is <strong><em>this</em></strong> word.</p>
<p><strong><em>This is strong and em.</em></strong></p>
<p>So is <strong><em>this</em></strong> word.</p>
-<p>This is code: <code>></code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html></code>.</p>
+<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
<hr />
<h1>Smart quotes, ellipses, dashes</h1>
<p>"Hello," said the spider. "'Shelob' is my name."</p>
@@ -442,8 +442,8 @@ Email link (nobody [at] nowhere.net)<p><a href="">Empty</a>.</p>
An e-mail address: nobody [at] nowhere.net<blockquote>
<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
</blockquote>
-<p>Auto-links should not occur here: <code>&lt;http://example.com/></code></p>
-<pre><code>or here: &lt;http://example.com/>
+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
+<pre><code>or here: &lt;http://example.com/&gt;
</code></pre>
<hr />
<h1>Images</h1>
diff --git a/tests/html-reader.native b/tests/html-reader.native
index ee419d3ac..c7ba26568 100644
--- a/tests/html-reader.native
+++ b/tests/html-reader.native
@@ -1,346 +1,339 @@
Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [], docDate = []})
-[ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber's",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
-, HorizontalRule
-, Header 1 [Str "Headers"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
-, Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 4 [Str "Level",Space,Str "4"]
-, Header 5 [Str "Level",Space,Str "5"]
-, Header 1 [Str "Level",Space,Str "1"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 3 [Str "Level",Space,Str "3"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, Header 2 [Str "Level",Space,Str "2"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, HorizontalRule
-, Header 1 [Str "Paragraphs"]
-, Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
-, Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
-, Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
-, Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Space,Str "here."]
-, HorizontalRule
-, Header 1 [Str "Block",Space,Str "Quotes"]
-, Para [Str "E-mail",Space,Str "style:"]
-, BlockQuote
- [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."] ]
-
-, BlockQuote
- [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
- , Para [Str "A",Space,Str "list:"]
- , OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "item",Space,Str "one"] ]
- , [ Plain [Str "item",Space,Str "two"] ] ]
- , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
- , BlockQuote
- [ Para [Str "nested"] ]
-
- , BlockQuote
- [ Para [Str "nested"] ]
- ]
-, Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]
-, Para [Str "Box-style:"]
-, BlockQuote
- [ Para [Str "Example:"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" ]
-, BlockQuote
- [ OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "do",Space,Str "laundry"] ]
- , [ Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ]
-, Para [Str "Here's",Space,Str "a",Space,Str "nested",Space,Str "one:"]
-, BlockQuote
- [ Para [Str "Joe",Space,Str "said:"]
- , BlockQuote
- [ Para [Str "Don't",Space,Str "quote",Space,Str "me."] ]
- ]
-, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
-, HorizontalRule
-, Header 1 [Str "Code",Space,Str "Blocks"]
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
-, Para [Str "And:"]
-, CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
-, HorizontalRule
-, Header 1 [Str "Lists"]
-, Header 2 [Str "Unordered"]
-, Para [Str "Asterisks",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "asterisk",Space,Str "1"] ]
- , [ Plain [Str "asterisk",Space,Str "2"] ]
- , [ Plain [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Asterisks",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "asterisk",Space,Str "1"] ]
- , [ Para [Str "asterisk",Space,Str "2"] ]
- , [ Para [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "Plus",Space,Str "1"] ]
- , [ Plain [Str "Plus",Space,Str "2"] ]
- , [ Plain [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Plus",Space,Str "1"] ]
- , [ Para [Str "Plus",Space,Str "2"] ]
- , [ Para [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "Minus",Space,Str "1"] ]
- , [ Plain [Str "Minus",Space,Str "2"] ]
- , [ Plain [Str "Minus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Minus",Space,Str "1"] ]
- , [ Para [Str "Minus",Space,Str "2"] ]
- , [ Para [Str "Minus",Space,Str "3"] ] ]
-, Header 2 [Str "Ordered"]
-, Para [Str "Tight:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second"] ]
- , [ Plain [Str "Third"] ] ]
-, Para [Str "and:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "One"] ]
- , [ Plain [Str "Two"] ]
- , [ Plain [Str "Three"] ] ]
-, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second"] ]
- , [ Para [Str "Third"] ] ]
-, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Para [Str "One"] ]
- , [ Para [Str "Two"] ]
- , [ Para [Str "Three"] ] ]
-, Para [Str "Multiple",Space,Str "paragraphs:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
- , Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog's",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ]
- , [ Para [Str "Item",Space,Str "3."] ] ]
-, Header 2 [Str "Nested"]
-, BulletList
- [ [ Plain [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"] ]
- ] ] ] ] ]
-, Para [Str "Here's",Space,Str "another:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second:"]
- , BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ], [ Plain [Str "Third"] ] ]
-, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second:"]
- , BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ]
-, Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
-, BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
- , BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
-, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
-, OrderedList (2,Decimal,DefaultDelim)
- [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
- , [ Para [Str "and",Space,Str "now",Space,Str "3"]
- , Para [Str "with",Space,Str "a",Space,Str "continuation"]
- , OrderedList (4,LowerRoman,DefaultDelim)
- [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
- , [ Plain [Str "more",Space,Str "items"]
- , OrderedList (1,UpperAlpha,DefaultDelim)
- [ [ Plain [Str "a",Space,Str "subsublist"] ]
- , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
-, Para [Str "Nesting:"]
-, OrderedList (1,UpperAlpha,DefaultDelim)
- [ [ Plain [Str "Upper",Space,Str "Alpha"]
- , OrderedList (1,UpperRoman,DefaultDelim)
- [ [ Plain [Str "Upper",Space,Str "Roman."]
- , OrderedList (6,Decimal,DefaultDelim)
- [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
- , OrderedList (3,LowerAlpha,DefaultDelim)
- [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
- ] ] ] ] ] ] ]
-, Para [Str "Autonumbering:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Autonumber."] ]
- , [ Plain [Str "More."]
- , OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Nested."] ]
- ] ] ]
-, HorizontalRule
-, Header 2 [Str "Definition"]
-, DefinitionList
- [ ([Str "Violin"],
- [ [ Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument."] ]
- , [ Plain [Str "Torture",Space,Str "device."] ]
- ])
- , ([Str "Cello",LineBreak,Str "Violoncello"],
- [ [ Plain [Str "Low-voiced",Space,Str "stringed",Space,Str "instrument."] ]
- ]) ]
-, HorizontalRule
-, Header 1 [Str "HTML",Space,Str "Blocks"]
-, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
-, Plain [Str "foo"]
-, Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
-, Plain [Str "foobar"]
-, Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
-, Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
-, Para [Str "Here's",Space,Str "a",Space,Str "simple",Space,Str "block:"]
-, Plain [Str "foo"]
-, Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
-, CodeBlock ("",[],[]) "<div>\n foo\n</div>"
-, Para [Str "As",Space,Str "should",Space,Str "this:"]
-, CodeBlock ("",[],[]) "<div>foo</div>"
-, Para [Str "Now,",Space,Str "nested:"]
-, Plain [Str "foo"]
-, Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
-, Para [Str "Multiline:"]
-, Para [Str "Code",Space,Str "block:"]
-, CodeBlock ("",[],[]) "<!-- Comment -->"
-, Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "<hr />"
-, Para [Str "Hr's:"]
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, HorizontalRule
-, Header 1 [Str "Inline",Space,Str "Markup"]
-, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
-, Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
-, Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
-, Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ">",Str ",",Space,Code "$",Str ",",Space,Code "\\",Str ",",Space,Code "\\$",Str ",",Space,Code "<html>",Str "."]
-, HorizontalRule
-, Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
-, Para [Str "\"Hello,\"",Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Str "\"'Shelob'",Space,Str "is",Space,Str "my",Space,Str "name.\""]
-, Para [Str "'A',",Space,Str "'B',",Space,Str "and",Space,Str "'C'",Space,Str "are",Space,Str "letters."]
-, Para [Str "'Oak,'",Space,Str "'elm,'",Space,Str "and",Space,Str "'beech'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Str "'pine.'"]
-, Para [Str "'He",Space,Str "said,",Space,Str "\"I",Space,Str "want",Space,Str "to",Space,Str "go.\"'",Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70's?"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"."]
-, Para [Str "Some",Space,Str "dashes:",Space,Str "one---two",Space,Str "---",Space,Str "three--four",Space,Str "--",Space,Str "five."]
-, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5-7,",Space,Str "255-66,",Space,Str "1987-1999."]
-, Para [Str "Ellipses...and.",Space,Str ".",Space,Str ".and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."]
-, HorizontalRule
-, Header 1 [Str "LaTeX"]
-, BulletList
- [ [ Plain [Str "\\cite[22-23]{smith.1899}"] ]
- , [ Plain [Str "\\doublespacing"] ]
- , [ Plain [Str "$2+2=4$"] ]
- , [ Plain [Str "$x",Space,Str "\\in",Space,Str "y$"] ]
- , [ Plain [Str "$\\alpha",Space,Str "\\wedge",Space,Str "\\omega$"] ]
- , [ Plain [Str "$223$"] ]
- , [ Plain [Str "$p$-Tree"] ]
- , [ Plain [Str "$\\frac{d}{dx}f(x)=\\lim_{h\\to",Space,Str "0}\\frac{f(x+h)-f(x)}{h}$"] ]
- , [ Plain [Str "Here's",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Str "$\\alpha",Space,Str "+",Space,Str "\\omega",Space,Str "\\times",Space,Str "x^2$."] ] ]
-, Para [Str "These",Space,Str "shouldn't",Space,Str "be",Space,Str "math:"]
-, BulletList
- [ [ Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code "$e = mc^2$",Str "."] ]
- , [ Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Str "\"lot\"",Space,Str "is",Space,Str "emphasized.)"] ]
- , [ Plain [Str "Escaped",Space,Code "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."] ] ]
-, Para [Str "Here's",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
-, Para [Str "\\begin{tabular}{|l|l|}\\hline",Space,Str "Animal",Space,Str "&",Space,Str "Number",Space,Str "\\\\",Space,Str "\\hline",Space,Str "Dog",Space,Str "&",Space,Str "2",Space,Str "\\\\",Space,Str "Cat",Space,Str "&",Space,Str "1",Space,Str "\\\\",Space,Str "\\hline",Space,Str "\\end{tabular}"]
-, HorizontalRule
-, Header 1 [Str "Special",Space,Str "Characters"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
-, BulletList
- [ [ Plain [Str "I",Space,Str "hat:",Space,Str "\206"] ]
- , [ Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"] ]
- , [ Plain [Str "section:",Space,Str "\167"] ]
- , [ Plain [Str "set",Space,Str "membership:",Space,Str "\8712"] ]
- , [ Plain [Str "copyright:",Space,Str "\169"] ] ]
-, Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
-, Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
-, Para [Str "This",Space,Str "&",Space,Str "that."]
-, Para [Str "4",Space,Str "<",Space,Str "5."]
-, Para [Str "6",Space,Str ">",Space,Str "5."]
-, Para [Str "Backslash:",Space,Str "\\"]
-, Para [Str "Backtick:",Space,Str "`"]
-, Para [Str "Asterisk:",Space,Str "*"]
-, Para [Str "Underscore:",Space,Str "_"]
-, Para [Str "Left",Space,Str "brace:",Space,Str "{"]
-, Para [Str "Right",Space,Str "brace:",Space,Str "}"]
-, Para [Str "Left",Space,Str "bracket:",Space,Str "["]
-, Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
-, Para [Str "Left",Space,Str "paren:",Space,Str "("]
-, Para [Str "Right",Space,Str "paren:",Space,Str ")"]
-, Para [Str "Greater-than:",Space,Str ">"]
-, Para [Str "Hash:",Space,Str "#"]
-, Para [Str "Period:",Space,Str "."]
-, Para [Str "Bang:",Space,Str "!"]
-, Para [Str "Plus:",Space,Str "+"]
-, Para [Str "Minus:",Space,Str "-"]
-, HorizontalRule
-, Header 1 [Str "Links"]
-, Header 2 [Str "Explicit"]
-, Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
-, Plain [Str "Email",Space,Str "link",Space,Str "(nobody",Space,Str "[at]",Space,Str "nowhere.net)"]
-, Para [Link [Str "Empty"] ("",""),Str "."]
-, Header 2 [Str "Reference"]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "With",Space,Link [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
-, Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
-, Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
-, Para [Str "This",Space,Str "should",Space,Str "[not]",Space,Str "be",Space,Str "a",Space,Str "link."]
-, CodeBlock ("",[],[]) "[not]: /url"
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
-, Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
-, Header 2 [Str "With",Space,Str "ampersands"]
-, Para [Str "Here's",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
-, Para [Str "Here's",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]
-, Para [Str "Here's",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
-, Para [Str "Here's",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
-, Header 2 [Str "Autolinks"]
-, Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example.com/?foo=1",Str "&",Str "bar=2"] ("http://example.com/?foo=1&bar=2","")]
-, BulletList
- [ [ Plain [Str "In",Space,Str "a",Space,Str "list?"] ]
- , [ Plain [Link [Str "http://example.com/"] ("http://example.com/","")] ]
- , [ Plain [Str "It",Space,Str "should."] ] ]
-, Plain [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Str "nobody",Space,Str "[at]",Space,Str "nowhere.net"]
-, BlockQuote
- [ Para [Str "Blockquoted:",Space,Link [Str "http://example.com/"] ("http://example.com/","")] ]
-
-, Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code "<http://example.com/>"]
-, CodeBlock ("",[],[]) "or here: <http://example.com/>"
-, HorizontalRule
-, Header 1 [Str "Images"]
-, Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
-, Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
-, HorizontalRule
-, Header 1 [Str "Footnotes"]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Link [Str "(1)"] ("#note_1",""),Str ",",Space,Str "and",Space,Str "another",Link [Str "(longnote)"] ("#note_longnote",""),Str ".",Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space^(my",Space,Str "note)."]
-, Para [Link [Str "(1)"] ("#ref_1",""),Space,Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "in",Space,Str "the",Space,Str "document,",Space,Str "not",Space,Str "just",Space,Str "at",Space,Str "the",Space,Str "end."]
-, Para [Link [Str "(longnote)"] ("#ref_longnote",""),Space,Str "Here's",Space,Str "the",Space,Str "other",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."]
-, Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)."]
-, CodeBlock ("",[],[]) " { <code> }"
-, Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "use",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "every",Space,Str "line,",Space,Str "as",Space,Str "with",Space,Str "blockquotes,",Space,Str "but",Space,Str "all",Space,Str "that",Space,Str "you",Space,Str "need",Space,Str "is",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "the",Space,Str "block",Space,Str "and",Space,Str "any",Space,Str "preceding",Space,Str "blank",Space,Str "lines."] ]
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Str "'",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+,HorizontalRule
+,Header 1 [Str "Headers"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 [Str "Level",Space,Str "4"]
+,Header 5 [Str "Level",Space,Str "5"]
+,Header 1 [Str "Level",Space,Str "1"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 [Str "Paragraphs"]
+,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
+,Para [Str "Here",Str "'",Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Space,Str "here",Str "."]
+,HorizontalRule
+,Header 1 [Str "Block",Space,Str "Quotes"]
+,Para [Str "E",Str "-",Str "mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]
+,Para [Str "Box",Str "-",Str "style:"]
+,BlockQuote
+ [Para [Str "Example:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"]
+,BlockQuote
+ [OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "do",Space,Str "laundry"]]
+ ,[Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]]
+,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
+,BlockQuote
+ [Para [Str "Joe",Space,Str "said:"]
+ ,BlockQuote
+ [Para [Str "Don",Str "'",Str "t",Space,Str "quote",Space,Str "me",Str "."]]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
+,HorizontalRule
+,Header 1 [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 [Str "Lists"]
+,Header 2 [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
+ ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Str "'",Str "s",Space,Str "back",Str "."]]
+ ,[Para [Str "Item",Space,Str "2",Str "."]]
+ ,[Para [Str "Item",Space,Str "3",Str "."]]]
+,Header 2 [Str "Nested"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here",Str "'",Str "s",Space,Str "another:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,DefaultDelim)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,DefaultDelim)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,DefaultDelim)
+ [[Plain [Str "Upper",Space,Str "Roman",Str "."]
+ ,OrderedList (6,Decimal,DefaultDelim)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,DefaultDelim)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber",Str "."]]
+ ,[Plain [Str "More",Str "."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested",Str "."]]]]]
+,HorizontalRule
+,Header 2 [Str "Definition"]
+,DefinitionList
+ [([Str "Violin"],
+ [[Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument",Str "."]]
+ ,[Plain [Str "Torture",Space,Str "device",Str "."]]])
+ ,([Str "Cello",LineBreak,Str "Violoncello"],
+ [[Plain [Str "Low",Str "-",Str "voiced",Space,Str "stringed",Space,Str "instrument",Str "."]]])]
+,HorizontalRule
+,Header 1 [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
+,Plain [Str "foo"]
+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
+,Plain [Str "foobar"]
+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
+,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
+,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
+,Plain [Str "foo"]
+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this:"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now,",Space,Str "nested:"]
+,Plain [Str "foo"]
+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
+,Para [Str "Multiline:"]
+,Para [Str "Code",Space,Str "block:"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr",Str "'",Str "s:"]
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,Header 1 [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,HorizontalRule
+,Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Str "\"",Str "Hello,",Str "\"",Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Str "\"",Str "'",Str "Shelob",Str "'",Space,Str "is",Space,Str "my",Space,Str "name",Str ".",Str "\""]
+,Para [Str "'",Str "A",Str "'",Str ",",Space,Str "'",Str "B",Str "'",Str ",",Space,Str "and",Space,Str "'",Str "C",Str "'",Space,Str "are",Space,Str "letters",Str "."]
+,Para [Str "'",Str "Oak,",Str "'",Space,Str "'",Str "elm,",Str "'",Space,Str "and",Space,Str "'",Str "beech",Str "'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Str "'",Str "pine",Str ".",Str "'"]
+,Para [Str "'",Str "He",Space,Str "said,",Space,Str "\"",Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str ".",Str "\"",Str "'",Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Str "'",Str "s?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code ("",[],[]) "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"",Str "."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one",Str "-",Str "-",Str "-",Str "two",Space,Str "-",Str "-",Str "-",Space,Str "three",Str "-",Str "-",Str "four",Space,Str "-",Str "-",Space,Str "five",Str "."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",Str "-",Str "7,",Space,Str "255",Str "-",Str "66,",Space,Str "1987",Str "-",Str "1999",Str "."]
+,Para [Str "Ellipses",Str ".",Str ".",Str ".",Str "and",Str ".",Space,Str ".",Space,Str ".",Str "and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."]
+,HorizontalRule
+,Header 1 [Str "LaTeX"]
+,BulletList
+ [[Plain [Str "\\cite[22",Str "-",Str "23]{smith",Str ".",Str "1899}"]]
+ ,[Plain [Str "\\doublespacing"]]
+ ,[Plain [Str "$2+2=4$"]]
+ ,[Plain [Str "$x",Space,Str "\\in",Space,Str "y$"]]
+ ,[Plain [Str "$\\alpha",Space,Str "\\wedge",Space,Str "\\omega$"]]
+ ,[Plain [Str "$223$"]]
+ ,[Plain [Str "$p$",Str "-",Str "Tree"]]
+ ,[Plain [Str "$\\frac{d}{dx}f(x)=\\lim_{h\\to",Space,Str "0}\\frac{f(x+h)",Str "-",Str "f(x)}{h}$"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Str "$\\alpha",Space,Str "+",Space,Str "\\omega",Space,Str "\\times",Space,Str "x^2$",Str "."]]]
+,Para [Str "These",Space,Str "shouldn",Str "'",Str "t",Space,Str "be",Space,Str "math:"]
+,BulletList
+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$34,000",Str ".",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Str "\"",Str "lot",Str "\"",Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$",Str "."]]]
+,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+,Para [Str "\\begin{tabular}{|l|l|}\\hline",Space,Str "Animal",Space,Str "&",Space,Str "Number",Space,Str "\\\\",Space,Str "\\hline",Space,Str "Dog",Space,Str "&",Space,Str "2",Space,Str "\\\\",Space,Str "Cat",Space,Str "&",Space,Str "1",Space,Str "\\\\",Space,Str "\\hline",Space,Str "\\end{tabular}"]
+,HorizontalRule
+,Header 1 [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Plain [Str "section:",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Plain [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]
+,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
+,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
+,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater",Str "-",Str "than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,HorizontalRule
+,Header 1 [Str "Links"]
+,Header 2 [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
+,Plain [Str "Email",Space,Str "link",Space,Str "(nobody",Space,Str "[at]",Space,Str "nowhere",Str ".",Str "net)"]
+,Para [Link [Str "Empty"] ("",""),Str "."]
+,Header 2 [Str "Reference"]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
+,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
+,Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
+,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
+,Header 2 [Str "With",Space,Str "ampersands"]
+,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/","AT&T"),Str "."]
+,Para [Str "Here",Str "'",Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Str "'",Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example",Str ".",Str "com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Plain [Link [Str "http://example",Str ".",Str "com/"] ("http://example.com/","")]]
+ ,[Plain [Str "It",Space,Str "should",Str "."]]]
+,Plain [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Str "nobody",Space,Str "[at]",Space,Str "nowhere",Str ".",Str "net"]
+,BlockQuote
+ [Para [Str "Blockquoted:",Space,Link [Str "http://example",Str ".",Str "com/"] ("http://example.com/","")]]
+,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 [Str "Images"]
+,Para [Str "From",Space,Str "\"",Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune",Str "\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
+,HorizontalRule
+,Header 1 [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Link [Str "(1)"] ("#note_1",""),Str ",",Space,Str "and",Space,Str "another",Link [Str "(longnote)"] ("#note_longnote",""),Str ".",Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space^(my",Space,Str "note)",Str "."]
+,Para [Link [Str "(1)"] ("#ref_1",""),Space,Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "in",Space,Str "the",Space,Str "document,",Space,Str "not",Space,Str "just",Space,Str "at",Space,Str "the",Space,Str "end",Str "."]
+,Para [Link [Str "(longnote)"] ("#ref_longnote",""),Space,Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "other",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."]
+,Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)",Str "."]
+,CodeBlock ("",[],[]) " { <code> }"
+,Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "use",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "every",Space,Str "line,",Space,Str "as",Space,Str "with",Space,Str "blockquotes,",Space,Str "but",Space,Str "all",Space,Str "that",Space,Str "you",Space,Str "need",Space,Str "is",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "the",Space,Str "block",Space,Str "and",Space,Str "any",Space,Str "preceding",Space,Str "blank",Space,Str "lines",Str "."]]
diff --git a/tests/ieee.csl b/tests/ieee.csl
new file mode 100644
index 000000000..af57495c8
--- /dev/null
+++ b/tests/ieee.csl
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="numeric" version="1.0">
+ <info>
+ <title>IEEE</title>
+ <id>http://www.zotero.org/styles/ieee</id>
+ <link href="http://www.zotero.org/styles/ieee" rel="self"/>
+ <author>
+ <name>Michael Berkowitz</name>
+ <email>mberkowi@gmu.edu</email>
+ </author>
+ <contributor>
+ <name>Julian Onions</name>
+ <email>julian.onions@gmail.com</email>
+ </contributor>
+ <contributor>
+ <name>Rintze Zelle</name>
+ <uri>http://forums.zotero.org/account/831/</uri>
+ </contributor>
+ <category field="engineering"/>
+ <category field="generic-base"/>
+ <category citation-format="numeric"/>
+ <updated>2010-02-06T06:35:40+00:00</updated>
+ <link href="http://www.ieee.org/portal/cms_docs_iportals/iportals/publications/authors/transjnl/stylemanual.pdf" rel="documentation"/>
+ </info>
+ <macro name="author">
+ <names variable="author">
+ <name initialize-with="." delimiter=", " and="text"/>
+ <label form="short" prefix=", " text-case="capitalize-first" suffix="." strip-periods="true"/>
+ <substitute>
+ <names variable="editor"/>
+ <names variable="translator"/>
+ </substitute>
+ </names>
+ </macro>
+ <macro name="editor">
+ <names variable="editor">
+ <name initialize-with="." delimiter=", " and="text" name-as-sort-order="all"/>
+ <label form="short" prefix=", " text-case="capitalize-first" suffix="." strip-periods="true"/>
+ </names>
+ </macro>
+ <macro name="title">
+ <choose>
+ <if type="bill book graphic legal_case motion_picture report song" match="any">
+ <text variable="title" font-style="italic"/>
+ </if>
+ <else>
+ <text variable="title" quotes="true"/>
+ </else>
+ </choose>
+ </macro>
+ <macro name="publisher">
+ <text variable="publisher-place" suffix=": "/>
+ <text variable="publisher" suffix=", "/>
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ </macro>
+ <macro name="access">
+ <text variable="URL"/>
+ </macro>
+ <macro name="page">
+ <group>
+ <label variable="page" form="short" suffix=". " strip-periods="true"/>
+ <text variable="page"/>
+ </group>
+ </macro>
+ <citation et-al-min="3" et-al-use-first="1" collapse="citation-number">
+ <sort>
+ <key variable="citation-number"/>
+ </sort>
+ <layout delimiter=",">
+ <text variable="citation-number" prefix="[" suffix="]"/>
+ </layout>
+ </citation>
+ <bibliography entry-spacing="0" second-field-align="flush">
+ <layout suffix=".">
+ <text variable="citation-number" prefix="[" suffix="]"/>
+ <text macro="author" prefix=" " suffix=", "/>
+ <choose>
+ <if type="bill book graphic legal_case motion_picture report song" match="any">
+ <group delimiter=", ">
+ <text macro="title"/>
+ <text macro="publisher"/>
+ </group>
+ </if>
+ <else-if type="chapter paper-conference" match="any">
+ <group delimiter=", ">
+ <text macro="title"/>
+ <text variable="container-title" font-style="italic"/>
+ <text macro="editor"/>
+ <text macro="publisher"/>
+ <text macro="page"/>
+ </group>
+ </else-if>
+ <else-if type="patent">
+ <text macro="title" suffix=", "/>
+ <text variable="number" prefix="U.S. Patent "/>
+ <date variable="issued" prefix=", ">
+ <date-part name="month" suffix=" "/>
+ <date-part name="day" suffix=", "/>
+ <date-part name="year"/>
+ </date>
+ </else-if>
+ <else-if type="thesis">
+ <group delimiter=", ">
+ <text macro="title"/>
+ <text variable="genre"/>
+ <text variable="publisher"/>
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ </group>
+ </else-if>
+ <else>
+ <group delimiter=", ">
+ <text macro="title"/>
+ <text variable="container-title" font-style="italic"/>
+ <text variable="volume" prefix="vol. "/>
+ <date variable="issued">
+ <date-part name="month" form="short" suffix=". " strip-periods="true"/>
+ <date-part name="year"/>
+ </date>
+ <text macro="page"/>
+ </group>
+ </else>
+ </choose>
+ </layout>
+ </bibliography>
+</style> \ No newline at end of file
diff --git a/tests/latex-reader.latex b/tests/latex-reader.latex
index 589a83e82..135ee57bb 100644
--- a/tests/latex-reader.latex
+++ b/tests/latex-reader.latex
@@ -7,6 +7,8 @@
\newcommand{\textsubscript}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
\usepackage[breaklinks=true,unicode=true]{hyperref}
\usepackage[normalem]{ulem}
+% avoid problems with \sout in headers with hyperref:
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
\usepackage{enumerate}
\usepackage{fancyvrb}
\usepackage{graphicx}
@@ -71,7 +73,7 @@ E-mail style:
This is a block quote. It is pretty short.
\end{quote}
-\begin{quote}
+\begin {quote}
Code in a block quote:
\begin{verbatim}
diff --git a/tests/latex-reader.native b/tests/latex-reader.native
index 921bf9d77..a5e14dd8f 100644
--- a/tests/latex-reader.native
+++ b/tests/latex-reader.native
@@ -1,377 +1,366 @@
Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]})
-[ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
-, HorizontalRule
-, Header 1 [Str "Headers"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
-, Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Para [Str "Level",Space,Str "4"]
-, Para [Str "Level",Space,Str "5"]
-, Header 1 [Str "Level",Space,Str "1"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 3 [Str "Level",Space,Str "3"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, Header 2 [Str "Level",Space,Str "2"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, HorizontalRule
-, Header 1 [Str "Paragraphs"]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
-, Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
-, Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
-, HorizontalRule
-, Header 1 [Str "Block",Space,Str "Quotes"]
-, Para [Str "E",Str "-",Str "mail",Space,Str "style:"]
-, BlockQuote
- [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."] ]
-
-, BlockQuote
- [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
- , Para [Str "A",Space,Str "list:"]
- , OrderedList (1,Decimal,Period)
- [ [ Para [Str "item",Space,Str "one"] ]
- , [ Para [Str "item",Space,Str "two"] ] ]
- , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
- , BlockQuote
- [ Para [Str "nested"] ]
-
- , BlockQuote
- [ Para [Str "nested"] ]
- ]
-, Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]
-, Para [Str "Box",Str "-",Str "style:"]
-, BlockQuote
- [ Para [Str "Example:"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}" ]
-, BlockQuote
- [ OrderedList (1,Decimal,Period)
- [ [ Para [Str "do",Space,Str "laundry"] ]
- , [ Para [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"] ] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
-, BlockQuote
- [ Para [Str "Joe",Space,Str "said:"]
- , BlockQuote
- [ Para [Str "Don",Apostrophe,Str "t",Space,Str "quote",Space,Str "me."] ]
- ]
-, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
-, HorizontalRule
-, Header 1 [Str "Code",Space,Str "Blocks"]
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
-, Para [Str "And:"]
-, CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
-, HorizontalRule
-, Header 1 [Str "Lists"]
-, Header 2 [Str "Unordered"]
-, Para [Str "Asterisks",Space,Str "tight:"]
-, BulletList
- [ [ Para [Str "asterisk",Space,Str "1"] ]
- , [ Para [Str "asterisk",Space,Str "2"] ]
- , [ Para [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Asterisks",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "asterisk",Space,Str "1"] ]
- , [ Para [Str "asterisk",Space,Str "2"] ]
- , [ Para [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "tight:"]
-, BulletList
- [ [ Para [Str "Plus",Space,Str "1"] ]
- , [ Para [Str "Plus",Space,Str "2"] ]
- , [ Para [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Plus",Space,Str "1"] ]
- , [ Para [Str "Plus",Space,Str "2"] ]
- , [ Para [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "tight:"]
-, BulletList
- [ [ Para [Str "Minus",Space,Str "1"] ]
- , [ Para [Str "Minus",Space,Str "2"] ]
- , [ Para [Str "Minus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Minus",Space,Str "1"] ]
- , [ Para [Str "Minus",Space,Str "2"] ]
- , [ Para [Str "Minus",Space,Str "3"] ] ]
-, Header 2 [Str "Ordered"]
-, Para [Str "Tight:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second"] ]
- , [ Para [Str "Third"] ] ]
-, Para [Str "and:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "One"] ]
- , [ Para [Str "Two"] ]
- , [ Para [Str "Three"] ] ]
-, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second"] ]
- , [ Para [Str "Third"] ] ]
-, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "One"] ]
- , [ Para [Str "Two"] ]
- , [ Para [Str "Three"] ] ]
-, Para [Str "Multiple",Space,Str "paragraphs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
- , Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ]
- , [ Para [Str "Item",Space,Str "3."] ] ]
-, Header 2 [Str "Nested"]
-, BulletList
- [ [ Para [Str "Tab"]
- , BulletList
- [ [ Para [Str "Tab"]
- , BulletList
- [ [ Para [Str "Tab"] ]
- ] ] ] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second:"]
- , BulletList
- [ [ Para [Str "Fee"] ]
- , [ Para [Str "Fie"] ]
- , [ Para [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ]
-, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second:"]
- , BulletList
- [ [ Para [Str "Fee"] ]
- , [ Para [Str "Fie"] ]
- , [ Para [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ]
-, Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
-, BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
- , BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
-, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
-, OrderedList (2,Decimal,TwoParens)
- [ [ Para [Str "begins",Space,Str "with",Space,Str "2"] ]
- , [ Para [Str "and",Space,Str "now",Space,Str "3"]
- , Para [Str "with",Space,Str "a",Space,Str "continuation"]
- , OrderedList (4,LowerRoman,Period)
- [ [ Para [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
- , [ Para [Str "more",Space,Str "items"]
- , OrderedList (1,UpperAlpha,TwoParens)
- [ [ Para [Str "a",Space,Str "subsublist"] ]
- , [ Para [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
-, Para [Str "Nesting:"]
-, OrderedList (1,UpperAlpha,Period)
- [ [ Para [Str "Upper",Space,Str "Alpha"]
- , OrderedList (1,UpperRoman,Period)
- [ [ Para [Str "Upper",Space,Str "Roman."]
- , OrderedList (6,Decimal,TwoParens)
- [ [ Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
- , OrderedList (3,LowerAlpha,OneParen)
- [ [ Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
- ] ] ] ] ] ] ]
-, Para [Str "Autonumbering:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Para [Str "Autonumber."] ]
- , [ Para [Str "More."]
- , OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Para [Str "Nested."] ]
- ] ] ]
-, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
-, Para [Str "M.A.",Space,Str "2007"]
-, Para [Str "B.",Space,Str "Williams"]
-, HorizontalRule
-, Header 1 [Str "Definition",Space,Str "Lists"]
-, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Para [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Para [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Loose:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Para [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
-, DefinitionList
- [ ([Emph [Str "apple"]],
- [ [ Para [Str "red",Space,Str "fruit"]
- , Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"] ]])
- , ([Emph [Str "orange"]],
- [ [ Para [Str "orange",Space,Str "fruit"]
- , CodeBlock ("",[],[]) "{ orange code block }"
- , BlockQuote
- [ Para [Str "orange",Space,Str "block",Space,Str "quote"] ]
- ]]) ]
-, Header 1 [Str "HTML",Space,Str "Blocks"]
-, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
-, Para [Str "foo",Space,Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
-, Para [Str "foo",Space,Str "bar",Space,Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
-, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"],Space,Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
-, Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
-, CodeBlock ("",[],[]) "<div>\n foo\n</div>"
-, Para [Str "As",Space,Str "should",Space,Str "this:"]
-, CodeBlock ("",[],[]) "<div>foo</div>"
-, Para [Str "Now,",Space,Str "nested:"]
-, Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
-, Para [Str "Multiline:"]
-, Para [Str "Code",Space,Str "block:"]
-, CodeBlock ("",[],[]) "<!-- Comment -->"
-, Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "<hr />"
-, Para [Str "Hr",Apostrophe,Str "s:"]
-, HorizontalRule
-, Header 1 [Str "Inline",Space,Str "Markup"]
-, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
-, Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
-, Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
-, Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ">",Str ",",Space,Code "$",Str ",",Space,Code "\\",Str ",",Space,Code "\\$",Str ",",Space,Code "<html>",Str "."]
-, Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
-, Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str "."]
-, Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
-, Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d."]
-, HorizontalRule
-, Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
-, Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]
-, Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
-, Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]
-, Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Apostrophe,Str "s?"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
-, Para [Str "Some",Space,Str "dashes:",Space,Str "one",EmDash,Str "two",EmDash,Str "three",EmDash,Str "four",EmDash,Str "five."]
-, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999."]
-, Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."]
-, HorizontalRule
-, Header 1 [Str "LaTeX"]
-, BulletList
- [ [ Para [TeX "\\cite[22-23]{smith.1899}"] ]
- , [ Para [TeX "\\doublespacing"] ]
- , [ Para [Math InlineMath "2+2=4"] ]
- , [ Para [Math InlineMath "x \\in y"] ]
- , [ Para [Math InlineMath "\\alpha \\wedge \\omega"] ]
- , [ Para [Math InlineMath "223"] ]
- , [ Para [Math InlineMath "p",Str "-",Str "Tree"] ]
- , [ Para [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"] ]
- , [ Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."] ] ]
-, Para [Str "These",Space,Str "shouldn",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"]
-, BulletList
- [ [ Para [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code "$e = mc^2$",Str "."] ]
- , [ Para [Str "$",Str "22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$",Str "34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"] ]
- , [ Para [Str "Escaped",Space,Code "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
-, Para [TeX "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"]
-, HorizontalRule
-, Header 1 [Str "Special",Space,Str "Characters"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
-, BulletList
- [ [ Para [Str "I",Space,Str "hat:",Space,Str "\206"] ]
- , [ Para [Str "o",Space,Str "umlaut:",Space,Str "\246"] ]
- , [ Para [Str "section:",Space,Str "\167"] ]
- , [ Para [Str "set",Space,Str "membership:",Space,Str "\8712"] ]
- , [ Para [Str "copyright:",Space,Str "\169"] ] ]
-, Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
-, Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
-, Para [Str "This",Space,Str "&",Space,Str "that."]
-, Para [Str "4",Space,Str "<",Space,Str "5."]
-, Para [Str "6",Space,Str ">",Space,Str "5."]
-, Para [Str "Backslash:",Space,Str "\\"]
-, Para [Str "Backtick:",Space,Str "`"]
-, Para [Str "Asterisk:",Space,Str "*"]
-, Para [Str "Underscore:",Space,Str "_"]
-, Para [Str "Left",Space,Str "brace:",Space,Str "{"]
-, Para [Str "Right",Space,Str "brace:",Space,Str "}"]
-, Para [Str "Left",Space,Str "bracket:",Space,Str "["]
-, Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
-, Para [Str "Left",Space,Str "paren:",Space,Str "("]
-, Para [Str "Right",Space,Str "paren:",Space,Str ")"]
-, Para [Str "Greater",Str "-",Str "than:",Space,Str ">"]
-, Para [Str "Hash:",Space,Str "#"]
-, Para [Str "Period:",Space,Str "."]
-, Para [Str "Bang:",Space,Str "!"]
-, Para [Str "Plus:",Space,Str "+"]
-, Para [Str "Minus:",Space,Str "-"]
-, HorizontalRule
-, Header 1 [Str "Links"]
-, Header 2 [Str "Explicit"]
-, Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
-, Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]
-, Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
-, Para [Link [Str "Empty"] ("",""),Str "."]
-, Header 2 [Str "Reference"]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "With",Space,Link [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
-, Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
-, Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
-, Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."]
-, CodeBlock ("",[],[]) "[not]: /url"
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "biz"] ("/url/",""),Str "."]
-, Header 2 [Str "With",Space,Str "ampersands"]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
-, Header 2 [Str "Autolinks"]
-, Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Code "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
-, BulletList
- [ [ Para [Str "In",Space,Str "a",Space,Str "list?"] ]
- , [ Para [Link [Code "http://example.com/"] ("http://example.com/","")] ]
- , [ Para [Str "It",Space,Str "should."] ] ]
-, Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Link [Code "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
-, BlockQuote
- [ Para [Str "Blockquoted:",Space,Link [Code "http://example.com/"] ("http://example.com/","")] ]
-
-, Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code "<http://example.com/>"]
-, CodeBlock ("",[],[]) "or here: <http://example.com/>"
-, HorizontalRule
-, Header 1 [Str "Images"]
-, Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
-, Para [Image [Str "image"] ("lalune.jpg","")]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "image"] ("movie.jpg",""),Space,Str "icon."]
-, HorizontalRule
-, Header 1 [Str "Footnotes"]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here",Apostrophe,Str "s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[",Str "^",Str "my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
-, BlockQuote
- [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]] ]
-
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]] ]
- ]
-, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."] ]
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,HorizontalRule
+,Header 1 [Str "Headers"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Para [Str "Level",Space,Str "4"]
+,Para [Str "Level",Space,Str "5"]
+,Header 1 [Str "Level",Space,Str "1"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 [Str "Paragraphs"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
+,HorizontalRule
+,Header 1 [Str "Block",Space,Str "Quotes"]
+,Para [Str "E",Str "-",Str "mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,Decimal,Period)
+ [[Para [Str "item",Space,Str "one"]]
+ ,[Para [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]
+,Para [Str "Box",Str "-",Str "style:"]
+,BlockQuote
+ [Para [Str "Example:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"]
+,BlockQuote
+ [OrderedList (1,Decimal,Period)
+ [[Para [Str "do",Space,Str "laundry"]]
+ ,[Para [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
+,BlockQuote
+ [Para [Str "Joe",Space,Str "said:"]
+ ,BlockQuote
+ [Para [Str "Don",Apostrophe,Str "t",Space,Str "quote",Space,Str "me."]]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,HorizontalRule
+,Header 1 [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 [Str "Lists"]
+,Header 2 [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
+,Header 2 [Str "Nested"]
+,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]]]]]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Para [Str "Fee"]]
+ ,[Para [Str "Fie"]]
+ ,[Para [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Para [Str "Fee"]]
+ ,[Para [Str "Fie"]]
+ ,[Para [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Para [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Para [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Para [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Para [Str "a",Space,Str "subsublist"]]
+ ,[Para [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Para [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Para [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "Autonumber."]]
+ ,[Para [Str "More."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "Nested."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
+,Para [Str "M.A.",Space,Str "2007"]
+,Para [Str "B.",Space,Str "Williams"]
+,HorizontalRule
+,Header 1 [Str "Definition",Space,Str "Lists"]
+,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Header 1 [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
+,Para [Str "foo",Space,Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
+,Para [Str "foo",Space,Str "bar",Space,Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Space,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"],Space,Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
+,Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this:"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now,",Space,Str "nested:"]
+,Para [Str "foo",Space,Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
+,Para [Str "Multiline:"]
+,Para [Str "Code",Space,Str "block:"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr",Apostrophe,Str "s:"]
+,HorizontalRule
+,Header 1 [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str "."]
+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d."]
+,HorizontalRule
+,Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]
+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
+,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]
+,Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Apostrophe,Str "s?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one",EmDash,Str "two",EmDash,Str "three",EmDash,Str "four",EmDash,Str "five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999."]
+,Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."]
+,HorizontalRule
+,Header 1 [Str "LaTeX"]
+,BulletList
+ [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22",Str "-",Str "23"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] []]]
+ ,[Para [RawInline "latex" "\\doublespacing"]]
+ ,[Para [Math InlineMath "2+2=4"]]
+ ,[Para [Math InlineMath "x \\in y"]]
+ ,[Para [Math InlineMath "\\alpha \\wedge \\omega"]]
+ ,[Para [Math InlineMath "223"]]
+ ,[Para [Math InlineMath "p",Str "-",Str "Tree"]]
+ ,[Para [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]
+ ,[Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]
+,Para [Str "These",Space,Str "shouldn",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"]
+,BulletList
+ [[Para [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Para [Str "$",Str "22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$",Str "34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]]
+ ,[Para [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+,Table [] [AlignLeft,AlignLeft] [0.0,0.0]
+ [[Plain [Str "Animal"]]
+ ,[Plain [Str "Number"]]]
+ [[[Plain [Str "Dog"]]
+ ,[Plain [Str "2"]]]
+ ,[[Plain [Str "Cat"]]
+ ,[Plain [Str "1"]]]]
+,HorizontalRule
+,Header 1 [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Para [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Para [Str "section:",Space,Str "\167"]]
+ ,[Para [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Para [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater",Str "-",Str "than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,HorizontalRule
+,Header 1 [Str "Links"]
+,Header 2 [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
+,Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]
+,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Link [Str "Empty"] ("",""),Str "."]
+,Header 2 [Str "Reference"]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]
+,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
+,Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "biz"] ("/url/",""),Str "."]
+,Header 2 [Str "With",Space,Str "ampersands"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Code ("",["url"],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Para [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Para [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]
+ ,[Para [Str "It",Space,Str "should."]]]
+,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Link [Code ("",[],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted:",Space,Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image [Str "image"] ("lalune.jpg","")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "image"] ("movie.jpg",""),Space,Str "icon."]
+,HorizontalRule
+,Header 1 [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here",Apostrophe,Str "s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]]
diff --git a/tests/lhs-test.fragment.html+lhs b/tests/lhs-test.fragment.html+lhs
index 74180d5c1..7757bc634 100644
--- a/tests/lhs-test.fragment.html+lhs
+++ b/tests/lhs-test.fragment.html+lhs
@@ -6,9 +6,21 @@
> is an arrow that takes a pair of values and combines them to return a single value:</p
><pre class="sourceCode haskell"
><code
- >&gt; unsplit :: (<span class="dt"
+ >&gt; <span class="ot"
+ >unsplit </span
+ ><span class="ot"
+ >::</span
+ > (<span class="dt"
>Arrow</span
- > a) =&gt; (b -&gt; c -&gt; d) -&gt; a (b, c) d<br
+ > a) <span class="ot"
+ >=&gt;</span
+ > (b <span class="ot"
+ >-&gt;</span
+ > c <span class="ot"
+ >-&gt;</span
+ > d) <span class="ot"
+ >-&gt;</span
+ > a (b, c) d<br
/>&gt; unsplit <span class="fu"
>=</span
> arr <span class="fu"
@@ -18,8 +30,7 @@
> <br
/>&gt; <span class="co"
>-- arr (\op (x,y) -&gt; x `op` y) </span
- ><br
- /></code
+ ></code
></pre
><p
><code
@@ -36,4 +47,4 @@
><p
>foo bar</p
></blockquote
-> \ No newline at end of file
+>
diff --git a/tests/lhs-test.html b/tests/lhs-test.html
index 1cfcb199a..0e5587a83 100644
--- a/tests/lhs-test.html
+++ b/tests/lhs-test.html
@@ -1,27 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
+ <title></title>
<style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
-pre.sourceCode span.kw { color: #007020; font-weight: bold; }
-pre.sourceCode span.dt { color: #902000; }
-pre.sourceCode span.dv { color: #40a070; }
-pre.sourceCode span.bn { color: #40a070; }
-pre.sourceCode span.fl { color: #40a070; }
-pre.sourceCode span.ch { color: #4070a0; }
-pre.sourceCode span.st { color: #4070a0; }
-pre.sourceCode span.co { color: #60a0b0; font-style: italic; }
-pre.sourceCode span.ot { color: #007020; }
-pre.sourceCode span.al { color: red; font-weight: bold; }
-pre.sourceCode span.fu { color: #06287e; }
-pre.sourceCode span.re { }
-pre.sourceCode span.er { color: red; font-weight: bold; }
+code.sourceCode span.kw { color: #007020; font-weight: bold; }
+code.sourceCode span.dt { color: #902000; }
+code.sourceCode span.dv { color: #40a070; }
+code.sourceCode span.bn { color: #40a070; }
+code.sourceCode span.fl { color: #40a070; }
+code.sourceCode span.ch { color: #4070a0; }
+code.sourceCode span.st { color: #4070a0; }
+code.sourceCode span.co { color: #60a0b0; font-style: italic; }
+code.sourceCode span.ot { color: #007020; }
+code.sourceCode span.al { color: red; font-weight: bold; }
+code.sourceCode span.fu { color: #06287e; }
+code.sourceCode span.re { }
+code.sourceCode span.er { color: red; font-weight: bold; }
</style>
</head>
<body>
@@ -31,11 +31,23 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
><code
>unsplit</code
> is an arrow that takes a pair of values and combines them to return a single value:</p
-><pre class="sourceCode haskell"
-><code
- >unsplit :: (<span class="dt"
+><pre class="sourceCode"
+><code class="sourceCode haskell"
+ ><span class="ot"
+ >unsplit </span
+ ><span class="ot"
+ >::</span
+ > (<span class="dt"
>Arrow</span
- > a) =&gt; (b -&gt; c -&gt; d) -&gt; a (b, c) d<br
+ > a) <span class="ot"
+ >=&gt;</span
+ > (b <span class="ot"
+ >-&gt;</span
+ > c <span class="ot"
+ >-&gt;</span
+ > d) <span class="ot"
+ >-&gt;</span
+ > a (b, c) d<br
/>unsplit <span class="fu"
>=</span
> arr <span class="fu"
@@ -45,8 +57,7 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
> <br
/> <span class="co"
>-- arr (\op (x,y) -&gt; x `op` y) </span
- ><br
- /></code
+ ></code
></pre
><p
><code
diff --git a/tests/lhs-test.html+lhs b/tests/lhs-test.html+lhs
index a33bf83ce..8a4b82e0a 100644
--- a/tests/lhs-test.html+lhs
+++ b/tests/lhs-test.html+lhs
@@ -1,27 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
+ <title></title>
<style type="text/css">
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
-pre.sourceCode span.kw { color: #007020; font-weight: bold; }
-pre.sourceCode span.dt { color: #902000; }
-pre.sourceCode span.dv { color: #40a070; }
-pre.sourceCode span.bn { color: #40a070; }
-pre.sourceCode span.fl { color: #40a070; }
-pre.sourceCode span.ch { color: #4070a0; }
-pre.sourceCode span.st { color: #4070a0; }
-pre.sourceCode span.co { color: #60a0b0; font-style: italic; }
-pre.sourceCode span.ot { color: #007020; }
-pre.sourceCode span.al { color: red; font-weight: bold; }
-pre.sourceCode span.fu { color: #06287e; }
-pre.sourceCode span.re { }
-pre.sourceCode span.er { color: red; font-weight: bold; }
+code.sourceCode span.kw { color: #007020; font-weight: bold; }
+code.sourceCode span.dt { color: #902000; }
+code.sourceCode span.dv { color: #40a070; }
+code.sourceCode span.bn { color: #40a070; }
+code.sourceCode span.fl { color: #40a070; }
+code.sourceCode span.ch { color: #4070a0; }
+code.sourceCode span.st { color: #4070a0; }
+code.sourceCode span.co { color: #60a0b0; font-style: italic; }
+code.sourceCode span.ot { color: #007020; }
+code.sourceCode span.al { color: red; font-weight: bold; }
+code.sourceCode span.fu { color: #06287e; }
+code.sourceCode span.re { }
+code.sourceCode span.er { color: red; font-weight: bold; }
</style>
</head>
<body>
@@ -31,11 +31,23 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
><code
>unsplit</code
> is an arrow that takes a pair of values and combines them to return a single value:</p
-><pre class="sourceCode haskell"
-><code
- >&gt; unsplit :: (<span class="dt"
+><pre class="sourceCode"
+><code class="sourceCode haskell"
+ >&gt; <span class="ot"
+ >unsplit </span
+ ><span class="ot"
+ >::</span
+ > (<span class="dt"
>Arrow</span
- > a) =&gt; (b -&gt; c -&gt; d) -&gt; a (b, c) d<br
+ > a) <span class="ot"
+ >=&gt;</span
+ > (b <span class="ot"
+ >-&gt;</span
+ > c <span class="ot"
+ >-&gt;</span
+ > d) <span class="ot"
+ >-&gt;</span
+ > a (b, c) d<br
/>&gt; unsplit <span class="fu"
>=</span
> arr <span class="fu"
@@ -45,8 +57,7 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
> <br
/>&gt; <span class="co"
>-- arr (\op (x,y) -&gt; x `op` y) </span
- ><br
- /></code
+ ></code
></pre
><p
><code
diff --git a/tests/lhs-test.latex b/tests/lhs-test.latex
index 331f429ef..d34c21090 100644
--- a/tests/lhs-test.latex
+++ b/tests/lhs-test.latex
@@ -2,7 +2,7 @@
\usepackage{amssymb,amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
-\usepackage[breaklinks=true,unicode=true]{hyperref}
+\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setcounter{secnumdepth}{0}
@@ -12,17 +12,17 @@
\section{lhs test}
-\verb!unsplit! is an arrow that takes a pair of values and combines
-them to return a single value:
+\verb!unsplit! is an arrow that takes a pair of values and combines them to
+return a single value:
\begin{verbatim}
unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
unsplit = arr . uncurry
-- arr (\op (x,y) -> x `op` y)
\end{verbatim}
-\verb!(***)! combines two arrows into a new arrow by running the
-two arrows on a pair of values (one arrow on the first item of the
-pair and one arrow on the second item of the pair).
+\verb!(***)! combines two arrows into a new arrow by running the two arrows on
+a pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
\begin{verbatim}
f *** g = first f >>> second g
diff --git a/tests/lhs-test.latex+lhs b/tests/lhs-test.latex+lhs
index a6270afcf..29237f820 100644
--- a/tests/lhs-test.latex+lhs
+++ b/tests/lhs-test.latex+lhs
@@ -4,7 +4,7 @@
\usepackage[utf8x]{inputenc}
\usepackage{listings}
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
-\usepackage[breaklinks=true,unicode=true]{hyperref}
+\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setcounter{secnumdepth}{0}
@@ -14,17 +14,17 @@
\section{lhs test}
-\verb!unsplit! is an arrow that takes a pair of values and combines
-them to return a single value:
+\verb!unsplit! is an arrow that takes a pair of values and combines them to
+return a single value:
\begin{code}
unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
unsplit = arr . uncurry
-- arr (\op (x,y) -> x `op` y)
\end{code}
-\verb!(***)! combines two arrows into a new arrow by running the
-two arrows on a pair of values (one arrow on the first item of the
-pair and one arrow on the second item of the pair).
+\verb!(***)! combines two arrows into a new arrow by running the two arrows on
+a pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
\begin{verbatim}
f *** g = first f >>> second g
diff --git a/tests/lhs-test.markdown b/tests/lhs-test.markdown
index 834d642d8..1d6cfcfb7 100644
--- a/tests/lhs-test.markdown
+++ b/tests/lhs-test.markdown
@@ -1,15 +1,17 @@
# lhs test
-`unsplit` is an arrow that takes a pair of values and combines them
-to return a single value:
+`unsplit` is an arrow that takes a pair of values and combines them to return
+a single value:
- unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
- unsplit = arr . uncurry
- -- arr (\op (x,y) -> x `op` y)
+~~~~ {.sourceCode .literate .haskell}
+unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
+unsplit = arr . uncurry
+ -- arr (\op (x,y) -> x `op` y)
+~~~~
-`(***)` combines two arrows into a new arrow by running the two
-arrows on a pair of values (one arrow on the first item of the pair
-and one arrow on the second item of the pair).
+`(***)` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
f *** g = first f >>> second g
diff --git a/tests/lhs-test.markdown+lhs b/tests/lhs-test.markdown+lhs
index 187fa630f..e6f0088c5 100644
--- a/tests/lhs-test.markdown+lhs
+++ b/tests/lhs-test.markdown+lhs
@@ -1,16 +1,16 @@
lhs test
========
-`unsplit` is an arrow that takes a pair of values and combines them
-to return a single value:
+`unsplit` is an arrow that takes a pair of values and combines them to return
+a single value:
> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
> unsplit = arr . uncurry
> -- arr (\op (x,y) -> x `op` y)
-`(***)` combines two arrows into a new arrow by running the two
-arrows on a pair of values (one arrow on the first item of the pair
-and one arrow on the second item of the pair).
+`(***)` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
f *** g = first f >>> second g
diff --git a/tests/lhs-test.native b/tests/lhs-test.native
index 94150f069..4b5a3e112 100644
--- a/tests/lhs-test.native
+++ b/tests/lhs-test.native
@@ -1,10 +1,8 @@
-Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
-[ Header 1 [Str "lhs",Space,Str "test"]
-, Para [Code "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]
-, CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry \n -- arr (\\op (x,y) -> x `op` y) "
-, Para [Code "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)",Str "."]
-, CodeBlock ("",[],[]) "f *** g = first f >>> second g"
-, Para [Str "Block",Space,Str "quote:"]
-, BlockQuote
- [ Para [Str "foo",Space,Str "bar"] ]
- ]
+[Header 1 [Str "lhs",Space,Str "test"]
+,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value",Str ":"]
+,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry \n -- arr (\\op (x,y) -> x `op` y) "
+,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)",Str "."]
+,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
+,Para [Str "Block",Space,Str "quote",Str ":"]
+,BlockQuote
+ [Para [Str "foo",Space,Str "bar"]]]
diff --git a/tests/lhs-test.nohl.html b/tests/lhs-test.nohl.html
new file mode 100644
index 000000000..cb03679f3
--- /dev/null
+++ b/tests/lhs-test.nohl.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="generator" content="pandoc" />
+ <title></title>
+</head>
+<body>
+<h1 id="lhs-test"
+>lhs test</h1
+><p
+><code
+ >unsplit</code
+ > is an arrow that takes a pair of values and combines them to return a single value:</p
+><pre class="sourceCode haskell"
+><code
+ >unsplit :: (Arrow a) =&gt; (b -&gt; c -&gt; d) -&gt; a (b, c) d
+unsplit = arr . uncurry
+ -- arr (\op (x,y) -&gt; x `op` y)
+</code
+ ></pre
+><p
+><code
+ >(***)</code
+ > combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p
+><pre
+><code
+ >f *** g = first f &gt;&gt;&gt; second g
+</code
+ ></pre
+><p
+>Block quote:</p
+><blockquote
+><p
+ >foo bar</p
+ ></blockquote
+>
+</body>
+</html>
diff --git a/tests/lhs-test.nohl.html+lhs b/tests/lhs-test.nohl.html+lhs
new file mode 100644
index 000000000..8b972a044
--- /dev/null
+++ b/tests/lhs-test.nohl.html+lhs
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="generator" content="pandoc" />
+ <title></title>
+</head>
+<body>
+<h1 id="lhs-test"
+>lhs test</h1
+><p
+><code
+ >unsplit</code
+ > is an arrow that takes a pair of values and combines them to return a single value:</p
+><pre class="sourceCode literate haskell"
+><code
+ >&gt; unsplit :: (Arrow a) =&gt; (b -&gt; c -&gt; d) -&gt; a (b, c) d
+&gt; unsplit = arr . uncurry
+&gt; -- arr (\op (x,y) -&gt; x `op` y)
+</code
+ ></pre
+><p
+><code
+ >(***)</code
+ > combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p
+><pre
+><code
+ >f *** g = first f &gt;&gt;&gt; second g
+</code
+ ></pre
+><p
+>Block quote:</p
+><blockquote
+><p
+ >foo bar</p
+ ></blockquote
+>
+</body>
+</html>
diff --git a/tests/lhs-test.rst b/tests/lhs-test.rst
index 67f7b3984..37ad099af 100644
--- a/tests/lhs-test.rst
+++ b/tests/lhs-test.rst
@@ -1,8 +1,8 @@
lhs test
========
-``unsplit`` is an arrow that takes a pair of values and combines
-them to return a single value:
+``unsplit`` is an arrow that takes a pair of values and combines them to
+return a single value:
::
@@ -10,9 +10,9 @@ them to return a single value:
unsplit = arr . uncurry
-- arr (\op (x,y) -> x `op` y)
-``(***)`` combines two arrows into a new arrow by running the two
-arrows on a pair of values (one arrow on the first item of the pair
-and one arrow on the second item of the pair).
+``(***)`` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
::
@@ -21,4 +21,3 @@ and one arrow on the second item of the pair).
Block quote:
foo bar
-
diff --git a/tests/lhs-test.rst+lhs b/tests/lhs-test.rst+lhs
index 22d54e85e..6b6ffb860 100644
--- a/tests/lhs-test.rst+lhs
+++ b/tests/lhs-test.rst+lhs
@@ -1,16 +1,16 @@
lhs test
========
-``unsplit`` is an arrow that takes a pair of values and combines
-them to return a single value:
+``unsplit`` is an arrow that takes a pair of values and combines them to
+return a single value:
> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
> unsplit = arr . uncurry
> -- arr (\op (x,y) -> x `op` y)
-``(***)`` combines two arrows into a new arrow by running the two
-arrows on a pair of values (one arrow on the first item of the pair
-and one arrow on the second item of the pair).
+``(***)`` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
::
@@ -19,4 +19,3 @@ and one arrow on the second item of the pair).
Block quote:
foo bar
-
diff --git a/tests/markdown-citations.chicago-author-date.txt b/tests/markdown-citations.chicago-author-date.txt
new file mode 100644
index 000000000..11d84dadc
--- /dev/null
+++ b/tests/markdown-citations.chicago-author-date.txt
@@ -0,0 +1,43 @@
+# Pandoc with citeproc-hs
+
+- [@nonexistent]
+
+- @nonexistent
+
+- Doe (2005) says blah.
+
+- Doe (2005, 30) says blah.
+
+- Doe (2005, 30, with suffix) says blah.
+
+- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.
+
+- In a note.[^1]
+
+- A citation group (see Doe 2005, 34–35; also Doe and Roe 2007, chap. 3).
+
+- Another one (see Doe 2005, 34–35).
+
+- And another one in a note.[^2]
+
+- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else).
+
+- Citation with suffix only (Doe 2005, and nowhere else).
+
+- Now some modifiers.[^3]
+
+- With some markup (*see* Doe 2005, 32).
+
+# References
+
+Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press.
+
+---. 2006. Article. *Journal of Generic Studies* 6: 33–34.
+
+Doe, John, and Jenny Roe. 2007. Why Water Is Wet. In *Third Book*, ed. Sam Smith. Oxford: Oxford University Press.
+
+[^1]: A citation without locators (Doe and Roe 2007).
+
+[^2]: Some citations (see Doe 2006, chap. 3; Doe and Roe 2007; Doe 2005).
+
+[^3]: Like a citation without author: (2005), and now Doe with a locator (2006, 44).
diff --git a/tests/markdown-citations.ieee.txt b/tests/markdown-citations.ieee.txt
new file mode 100644
index 000000000..0fd9335ad
--- /dev/null
+++ b/tests/markdown-citations.ieee.txt
@@ -0,0 +1,43 @@
+# Pandoc with citeproc-hs
+
+- [@nonexistent]
+
+- @nonexistent
+
+- Reference [1] says blah.
+
+- Reference [1] says blah.
+
+- Reference [1] says blah.
+
+- Reference [1] says blah.
+
+- In a note.[^1]
+
+- A citation group [1],[3].
+
+- Another one [1].
+
+- And another one in a note.[^2]
+
+- Citation with a suffix and locator [1].
+
+- Citation with suffix only [1].
+
+- Now some modifiers.[^3]
+
+- With some markup [1].
+
+# References
+
+[1] J. Doe, *First Book*, Cambridge: Cambridge University Press, 2005.
+
+[2] J. Doe, “Article,” *Journal of Generic Studies*, vol. 6, 2006, pp. 33-34.
+
+[3] J. Doe and J. Roe, “Why Water Is Wet,” *Third Book*, Smith, S., Ed., Oxford: Oxford University Press, 2007.
+
+[^1]: A citation without locators [3].
+
+[^2]: Some citations [1]-[3].
+
+[^3]: Like a citation without author: [1], and now Doe with a locator [2].
diff --git a/tests/markdown-citations.mhra.txt b/tests/markdown-citations.mhra.txt
new file mode 100644
index 000000000..56eb147a3
--- /dev/null
+++ b/tests/markdown-citations.mhra.txt
@@ -0,0 +1,61 @@
+# Pandoc with citeproc-hs
+
+- [@nonexistent]
+
+- @nonexistent
+
+- John Doe[^1] says blah.
+
+- Doe[^2] says blah.
+
+- Doe[^3] says blah.
+
+- Doe[^4] says blah.
+
+- In a note.[^5]
+
+- A citation group.[^6]
+
+- Another one.[^7]
+
+- And another one in a note.[^8]
+
+- Citation with a suffix and locator.[^9]
+
+- Citation with suffix only.[^10]
+
+- Now some modifiers.[^11]
+
+- With some markup.[^12]
+
+# References
+
+Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34.
+
+---, *First Book* (Cambridge: Cambridge University Press, 2005).
+
+Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smith (Oxford: Oxford University Press, 2007).
+
+[^1]: *First Book* (Cambridge: Cambridge University Press, 2005).
+
+[^2]: First Book, p. 30.
+
+[^3]: First Book, p. 30, with suffix.
+
+[^4]: First Book; ‘Article’, *Journal of Generic Studies*, 6 (2006), 33-34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed by Sam Smith (Oxford: Oxford University Press, 2007).
+
+[^5]: A citation without locators Doe and Roe.
+
+[^6]: See Doe, First Book, pp. 34-35; also Doe and Roe, chap. 3.
+
+[^7]: See Doe, First Book, pp. 34-35.
+
+[^8]: Some citations see Doe, Article, 33-34 (chap. 3); Doe and Roe; Doe, First Book.
+
+[^9]: Doe, First Book, pp. 33, 35-37, and nowhere else.
+
+[^10]: Doe, First Book, and nowhere else.
+
+[^11]: Like a citation without author: First Book, and now Doe with a locator Article, 33-34 (p. 44).
+
+[^12]: *See* Doe, First Book, p. 32.
diff --git a/tests/markdown-citations.txt b/tests/markdown-citations.txt
new file mode 100644
index 000000000..e2864d365
--- /dev/null
+++ b/tests/markdown-citations.txt
@@ -0,0 +1,37 @@
+# Pandoc with citeproc-hs
+
+- [@nonexistent]
+
+- @nonexistent
+
+- @item1 says blah.
+
+- @item1 [p. 30] says blah.
+
+- @item1 [p. 30, with suffix] says blah.
+
+- @item1 [-@item2 p. 30; see also @item3] says blah.
+
+- In a note.[^1]
+
+- A citation group [see @item1 p. 34-35; also @item3 chap. 3].
+
+- Another one [see @item1 p. 34-35].
+
+- And another one in a note.[^2]
+
+- Citation with a suffix and locator [@item1 pp. 33, 35-37, and nowhere else].
+
+- Citation with suffix only [@item1 and nowhere else].
+
+- Now some modifiers.[^3]
+
+- With some markup [*see* @item1 p. **32**].
+
+# References
+
+[^1]: A citation without locators [@item3].
+
+[^2]: Some citations [see @item2 chap. 3; @item3; @item1].
+
+[^3]: Like a citation without author: [-@item1], and now Doe with a locator [-@item2 p. 44].
diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native
index 104baeaa6..e5e079e9f 100644
--- a/tests/markdown-reader-more.native
+++ b/tests/markdown-reader-more.native
@@ -1,42 +1,50 @@
-Pandoc (Meta {docTitle = [Str "Title",Space,Str "spanning",Space,Str "multiple",Space,Str "lines"], docAuthors = [[Str "Author",Space,Str "One"],[Str "Author",Space,Str "Two"],[Str "Author",Space,Str "Three"],[Str "Author",Space,Str "Four"]], docDate = []})
-[ Header 1 [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"]
-, Header 2 [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"]
-, Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")]
-, Header 2 [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"]
-, Para [TeX "\\placeformula",Space,TeX "\\startformula\n L_{1} = L_{2}\n \\stopformula"]
-, Para [TeX "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"]
-, Header 2 [Str "URLs",Space,Str "with",Space,Str "spaces"]
-, Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20%20and%20%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")]
-, Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]
-, Header 2 [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"]
-, HorizontalRule
-, HorizontalRule
-, Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]
-, Plain [HtmlInline "<a>",HtmlInline "</a>"]
-, Header 3 [Str "my",Space,Str "header"]
-, Header 2 [Str "$",Space,Str "in",Space,Str "math"]
-, Para [Math InlineMath "\\$2 + \\$3"]
-, Header 2 [Str "Commented",Str "-",Str "out",Space,Str "list",Space,Str "item"]
-, BulletList
- [ [ Plain [Str "one"]
- , RawHtml "<!--\n- two\n-->" ], [ Plain [Str "three"] ] ]
-, Header 2 [Str "Backslash",Space,Str "newline"]
-, Para [Str "hi",LineBreak,Str "there"]
-, Header 2 [Str "Code",Space,Str "spans"]
-, Para [Code "hi\\"]
-, Para [Code "hi there"]
-, Para [Code "hi````there"]
-, Para [Str "`",Str "hi"]
-, Para [Str "there",Str "`"]
-, Header 2 [Str "Multilingual",Space,Str "URLs"]
-, Para [Link [Code "http://\27979.com?\27979=\27979"] ("http://%E6%B5%8B.com?%E6%B5%8B=%E6%B5%8B","")]
-, Para [Link [Str "foo"] ("/bar/%E6%B5%8B?x=%E6%B5%8B","title")]
-, Para [Link [Code "\27979@foo.\27979.baz"] ("mailto:%E6%B5%8B@foo.%E6%B5%8B.baz","")]
-, Header 2 [Str "Numbered",Space,Str "examples"]
-, OrderedList (1,Example,TwoParens)
- [ [ Plain [Str "First",Space,Str "example",Str "."] ]
- , [ Plain [Str "Second",Space,Str "example",Str "."] ] ]
-, Para [Str "Explanation",Space,Str "of",Space,Str "examples",Space,Str "(",Str "2",Str ")",Space,Str "and",Space,Str "(",Str "3",Str ")",Str "."]
-, OrderedList (3,Example,TwoParens)
- [ [ Plain [Str "Third",Space,Str "example",Str "."] ]
- ] ]
+[Header 1 [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"]
+,Header 2 [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"]
+,Para [Link [Str "foo"] ("/url",""),Space,Str "and",Space,Link [Str "bar"] ("/url","title")]
+,Header 2 [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"]
+,Plain [RawInline "tex" "\\placeformula"]
+,RawBlock "context" "\\startformula\n L_{1} = L_{2}\n \\stopformula"
+,RawBlock "context" "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
+,Header 2 [Str "URLs",Space,Str "with",Space,Str "spaces"]
+,Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")]
+,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]
+,Header 2 [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"]
+,HorizontalRule
+,HorizontalRule
+,Header 2 [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]
+,Plain [RawInline "html" "<a>",RawInline "html" "</a>"]
+,Header 3 [Str "my",Space,Str "header"]
+,Header 2 [Str "$",Space,Str "in",Space,Str "math"]
+,Para [Math InlineMath "\\$2 + \\$3"]
+,Header 2 [Str "Commented",Str "-",Str "out",Space,Str "list",Space,Str "item"]
+,BulletList
+ [[Plain [Str "one",Space,RawInline "html" "<!--\n- two\n-->"]]
+ ,[Plain [Str "three"]]]
+,Header 2 [Str "Backslash",Space,Str "newline"]
+,Para [Str "hi",LineBreak,Str "there"]
+,Header 2 [Str "Code",Space,Str "spans"]
+,Para [Code ("",[],[]) "hi\\"]
+,Para [Code ("",[],[]) "hi there"]
+,Para [Code ("",[],[]) "hi````there"]
+,Para [Str "`",Str "hi"]
+,Para [Str "there",Str "`"]
+,Header 2 [Str "Multilingual",Space,Str "URLs"]
+,Para [Link [Code ("",["url"],[]) "http://\27979.com?\27979=\27979"] ("http://%E6%B5%8B.com?%E6%B5%8B=%E6%B5%8B","")]
+,Para [Link [Str "foo"] ("/bar/%E6%B5%8B?x=%E6%B5%8B","title")]
+,Para [Link [Code ("",["url"],[]) "\27979@foo.\27979.baz"] ("mailto:%E6%B5%8B@foo.%E6%B5%8B.baz","")]
+,Header 2 [Str "Numbered",Space,Str "examples"]
+,OrderedList (1,Example,TwoParens)
+ [[Plain [Str "First",Space,Str "example",Str "."]]
+ ,[Plain [Str "Second",Space,Str "example",Str "."]]]
+,Para [Str "Explanation",Space,Str "of",Space,Str "examples",Space,Str "(",Str "2",Str ")",Space,Str "and",Space,Str "(",Str "3",Str ")",Str "."]
+,OrderedList (3,Example,TwoParens)
+ [[Plain [Str "Third",Space,Str "example",Str "."]]]
+,Header 2 [Str "Macros"]
+,Para [Math InlineMath "\\langle x,y \\rangle"]
+,Header 2 [Str "Case",Str "-",Str "insensitive",Space,Str "references"]
+,Para [Link [Str "Fum"] ("/fum","")]
+,Para [Link [Str "FUM"] ("/fum","")]
+,Para [Link [Str "bat"] ("/bat","")]
+,Header 2 [Str "Curly",Space,Str "smart",Space,Str "quotes"]
+,Para [Quoted DoubleQuote [Str "Hi"]]
+,Para [Quoted SingleQuote [Str "Hi"]]]
diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt
index 29e210088..258002b8a 100644
--- a/tests/markdown-reader-more.txt
+++ b/tests/markdown-reader-more.txt
@@ -31,7 +31,8 @@
## URLs with spaces
[foo](/bar and baz)
-[foo](/bar and baz )
+[foo](/bar
+ and baz )
[foo]( /bar and baz )
[foo](bar baz "title" )
@@ -100,3 +101,25 @@ Explanation of examples (@foo) and (@bar).
(@bar) Third example.
+## Macros
+
+\newcommand{\tuple}[1]{\langle #1 \rangle}
+
+$\tuple{x,y}$
+
+## Case-insensitive references
+
+[Fum]
+
+[FUM]
+
+[bat]
+
+[fum]: /fum
+[BAT]: /bat
+
+## Curly smart quotes
+
+“Hi”
+
+‘Hi’
diff --git a/tests/mhra.csl b/tests/mhra.csl
new file mode 100644
index 000000000..4749cdcd7
--- /dev/null
+++ b/tests/mhra.csl
@@ -0,0 +1,390 @@
+<?xml version="1.0" encoding="utf-8"?>
+<style xmlns="http://purl.org/net/xbiblio/csl" class="note" version="1.0">
+ <info>
+ <title>Modern Humanities Research Association (Note with Bibliography)</title>
+ <id>http://www.zotero.org/styles/mhra</id>
+ <link href="http://www.zotero.org/styles/mhra" rel="self"/>
+ <link href="http://www.mhra.org.uk/Publications/Books/StyleGuide/download.shtml" rel="documentation"/>
+ <author>
+ <name>Rintze Zelle</name>
+ <uri>http://forums.zotero.org/account/831/</uri>
+ </author>
+ <contributor>
+ <name>Sebastian Karcher</name>
+ </contributor>
+ <summary>MHRA format with full notes and bibliography</summary>
+ <category field="generic-base"/>
+ <category citation-format="note"/>
+ <updated>2009-12-15T12:42:52+00:00</updated>
+ </info>
+ <locale xml:lang="en">
+ <terms>
+ <term name="et-al">and others</term>
+ <term name="editor" form="verb-short">ed. by</term>
+ <term name="edition" form="short">edn</term>
+ <term name="translator" form="verb-short">trans. by</term>
+ </terms>
+ </locale>
+ <macro name="author">
+ <names variable="author">
+ <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
+ <label form="short" prefix=", " suffix="." strip-periods="true"/>
+ <substitute>
+ <names variable="editor"/>
+ <names variable="translator"/>
+ <text macro="title-note"/>
+ </substitute>
+ </names>
+ </macro>
+ <macro name="contributors-note">
+ <names variable="author">
+ <name and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never"/>
+ </names>
+ <text macro="recipient-note"/>
+ </macro>
+ <macro name="title-note">
+ <choose>
+ <if type="bill book graphic legal_case motion_picture report song" match="any">
+ <text variable="title" font-style="italic"/>
+ </if>
+ <else>
+ <text variable="title" prefix="‘" suffix="’"/>
+ </else>
+ </choose>
+ </macro>
+ <macro name="editor-translator">
+ <group delimiter=", ">
+ <names variable="editor" delimiter=", ">
+ <label form="verb-short" text-case="lowercase" suffix=" " strip-periods="true"/>
+ <name and="text" delimiter=", " delimiter-precedes-last="never"/>
+ </names>
+ <choose>
+ <if variable="author editor" match="any">
+ <names variable="translator" delimiter=", ">
+ <label form="verb-short" text-case="lowercase" suffix=" " strip-periods="true"/>
+ <name and="text" delimiter=", " delimiter-precedes-last="never"/>
+ </names>
+ </if>
+ </choose>
+ </group>
+ </macro>
+ <macro name="collection-title">
+ <text variable="collection-title"/>
+ <text variable="collection-number" prefix=", "/>
+ </macro>
+ <macro name="locators-note">
+ <choose>
+ <if type="article-journal">
+ <text variable="volume"/>
+ </if>
+ <else-if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
+ <group delimiter=", ">
+ <text macro="edition-note"/>
+ <group>
+ <number variable="number-of-volumes" form="numeric"/>
+ <text term="volume" form="short" prefix=" " plural="true" strip-periods="true"/>
+ </group>
+ </group>
+ </else-if>
+ </choose>
+ </macro>
+ <macro name="volume">
+ <choose>
+ <if type="article-journal">
+ <text variable="volume"/>
+ </if>
+ <else-if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
+ <group delimiter=", ">
+ <text macro="edition-note"/>
+ <group>
+ <number variable="number-of-volumes" form="numeric"/>
+ <text term="volume" form="short" prefix=" " plural="true" strip-periods="true"/>
+ </group>
+ </group>
+ </else-if>
+ </choose>
+ </macro>
+ <macro name="issue-note">
+ <choose>
+ <if type="article-journal">
+ <choose>
+ <if variable="volume">
+ <text macro="issued" prefix=" (" suffix=")"/>
+ </if>
+ <else>
+ <text macro="issued" prefix=", "/>
+ </else>
+ </choose>
+ </if>
+ <else-if variable="publisher-place publisher" match="any">
+ <group prefix=" (" suffix=")" delimiter=", ">
+ <group delimiter=" ">
+ <choose>
+ <if variable="title" match="none"/>
+ <else-if type="thesis speech" match="any">
+ <text variable="genre" prefix="unpublished "/>
+ </else-if>
+ </choose>
+ <text macro="event"/>
+ </group>
+ <text macro="publisher"/>
+ <text macro="issued"/>
+ </group>
+ </else-if>
+ <else>
+ <text macro="issued" prefix=", "/>
+ </else>
+ </choose>
+ </macro>
+ <macro name="locators-specific-note">
+ <choose>
+ <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
+ <choose>
+ <if is-numeric="volume">
+ <number variable="volume" form="roman" font-variant="small-caps"/>
+ </if>
+ </choose>
+ </if>
+ </choose>
+ </macro>
+ <macro name="container-title-note">
+ <choose>
+ <if type="chapter paper-conference" match="any">
+ <text term="in" text-case="lowercase" suffix=" "/>
+ </if>
+ </choose>
+ <text variable="container-title" font-style="italic"/>
+ </macro>
+ <macro name="edition-note">
+ <choose>
+ <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
+ <choose>
+ <if is-numeric="edition">
+ <group delimiter=" ">
+ <number variable="edition" form="ordinal"/>
+ <text term="edition" form="short" strip-periods="true"/>
+ </group>
+ </if>
+ <else>
+ <text variable="edition"/>
+ </else>
+ </choose>
+ </if>
+ </choose>
+ </macro>
+ <macro name="editor-note">
+ <names variable="editor">
+ <name and="text" sort-separator=", " delimiter=", "/>
+ <label form="short" prefix=", " suffix="." strip-periods="true"/>
+ </names>
+ </macro>
+ <macro name="translator-note">
+ <names variable="translator">
+ <name and="text" sort-separator=", " delimiter=", "/>
+ <label form="verb-short" prefix=", " suffix="." strip-periods="true"/>
+ </names>
+ </macro>
+ <macro name="recipient-note">
+ <names variable="recipient" delimiter=", ">
+ <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
+ <name and="text" delimiter=", "/>
+ </names>
+ </macro>
+ <macro name="recipient-short">
+ <names variable="recipient">
+ <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
+ <name form="short" and="text" delimiter=", "/>
+ </names>
+ </macro>
+ <macro name="contributors-short">
+ <names variable="author">
+ <name form="short" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never"/>
+ <substitute>
+ <names variable="editor"/>
+ <names variable="translator"/>
+ </substitute>
+ </names>
+ <text macro="recipient-short"/>
+ </macro>
+ <macro name="interviewer-note">
+ <names variable="interviewer" delimiter=", ">
+ <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
+ <name and="text" delimiter=", "/>
+ </names>
+ </macro>
+ <macro name="locators-newspaper">
+ <choose>
+ <if type="article-newspaper">
+ <group delimiter=", ">
+ <group>
+ <text variable="edition" suffix=" "/>
+ <text term="edition" prefix=" "/>
+ </group>
+ <group>
+ <text term="section" suffix=" "/>
+ <text variable="section"/>
+ </group>
+ </group>
+ </if>
+ </choose>
+ </macro>
+ <macro name="event">
+ <group>
+ <text term="presented at" suffix=" "/>
+ <text variable="event"/>
+ </group>
+ </macro>
+ <macro name="publisher">
+ <group delimiter=": ">
+ <text variable="publisher-place"/>
+ <text variable="publisher"/>
+ </group>
+ </macro>
+ <macro name="issued">
+ <choose>
+ <if type="graphic report article-newspaper" match="any">
+ <date variable="issued">
+ <date-part name="day" suffix=" "/>
+ <date-part name="month" suffix=" "/>
+ <date-part name="year"/>
+ </date>
+ </if>
+ <else-if type="bill book graphic legal_case motion_picture report song thesis chapter paper-conference" match="any">
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ </else-if>
+ <else>
+ <date variable="issued">
+ <date-part name="year"/>
+ </date>
+ </else>
+ </choose>
+ </macro>
+ <macro name="pages">
+ <choose>
+ <if type="article-journal">
+ <text variable="page" prefix=", "/>
+ </if>
+ <else>
+ <choose>
+ <if variable="volume">
+ <text variable="page" prefix=", "/>
+ </if>
+ <else>
+ <label variable="page" form="short" prefix=", " suffix=" "/>
+ <text variable="page"/>
+ </else>
+ </choose>
+ </else>
+ </choose>
+ </macro>
+ <macro name="point-locators">
+ <text macro="pages"/>
+ <choose>
+ <if variable="page">
+ <group prefix=" (" suffix=")">
+ <label variable="locator" form="short" suffix=" "/>
+ <text variable="locator"/>
+ </group>
+ </if>
+ <else>
+ <label variable="locator" form="short" prefix=", " suffix=" "/>
+ <text variable="locator"/>
+ </else>
+ </choose>
+ </macro>
+ <macro name="archive-note">
+ <group delimiter=", ">
+ <text variable="archive_location"/>
+ <text variable="archive"/>
+ <text variable="archive-place"/>
+ </group>
+ </macro>
+ <macro name="access-note">
+ <group delimiter=", ">
+ <choose>
+ <if type="graphic report" match="any">
+ <text macro="archive-note" prefix=", "/>
+ </if>
+ <else-if type="bill book graphic legal_case motion_picture report song article-journal article-magazine article-newspaper thesis chapter paper-conference" match="none">
+ <text macro="archive-note" prefix=", "/>
+ </else-if>
+ </choose>
+ </group>
+ <choose>
+ <if variable="DOI">
+ <text variable="DOI" prefix=" &lt;doi:" suffix="&gt;"/>
+ </if>
+ <else>
+ <text variable="URL" prefix=" &lt;" suffix="&gt;"/>
+ <choose>
+ <if variable="accessed">
+ <group prefix=" [" suffix="]">
+ <text term="accessed" text-case="lowercase"/>
+ <date variable="accessed">
+ <date-part name="day" prefix=" "/>
+ <date-part name="month" prefix=" "/>
+ <date-part name="year" prefix=" "/>
+ </date>
+ </group>
+ </if>
+ </choose>
+ </else>
+ </choose>
+ </macro>
+ <citation et-al-min="4" et-al-use-first="1" et-al-subsequent-min="4" et-al-subsequent-use-first="1" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="by-cite">
+ <layout prefix="" suffix="." delimiter="; ">
+ <choose>
+ <if position="subsequent">
+ <group delimiter=", ">
+ <text macro="contributors-short"/>
+ <choose>
+ <if disambiguate="true">
+ <text variable="title" form="short"/>
+ </if>
+ </choose>
+ </group>
+ <text macro="locators-specific-note" prefix=", "/>
+ <text macro="point-locators"/>
+ </if>
+ <else>
+ <group delimiter=", ">
+ <text macro="contributors-note"/>
+ <text macro="title-note"/>
+ <text macro="container-title-note"/>
+ <text macro="editor-translator"/>
+ <text macro="collection-title"/>
+ <text macro="locators-note"/>
+ </group>
+ <text macro="issue-note"/>
+ <text macro="locators-specific-note" prefix=", "/>
+ <text macro="locators-newspaper" prefix=", "/>
+ <text macro="point-locators"/>
+ <text macro="access-note"/>
+ </else>
+ </choose>
+ </layout>
+ </citation>
+ <bibliography hanging-indent="true" et-al-min="6" et-al-use-first="6" subsequent-author-substitute="---">
+ <sort>
+ <key macro="author"/>
+ <key variable="title"/>
+ </sort>
+ <layout suffix=".">
+ <group delimiter=", ">
+ <text macro="author"/>
+ <text macro="title-note"/>
+ <text macro="container-title-note"/>
+ <text macro="editor-translator"/>
+ <text macro="collection-title"/>
+ <text macro="volume"/>
+ </group>
+ <text macro="issue-note"/>
+ <text macro="locators-specific-note" prefix=", "/>
+ <text macro="locators-newspaper" prefix=", "/>
+ <text macro="pages"/>
+ <text macro="access-note"/>
+ </layout>
+ </bibliography>
+</style> \ No newline at end of file
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index b79d35bd9..a88d499b0 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -1,311 +1,308 @@
Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite",Str ":",Space,Str "Subtitle"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]})
-[ DefinitionList
- [ ([Str "Revision"],
- [ [ Plain [Str "3"] ]
- ]) ]
-, Header 1 [Str "Level",Space,Str "one",Space,Str "header"]
-, Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber's",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
-, Header 2 [Str "Level",Space,Str "two",Space,Str "header"]
-, Header 3 [Str "Level",Space,Str "three"]
-, Header 4 [Str "Level",Space,Str "four",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 5 [Str "Level",Space,Str "five"]
-, Header 1 [Str "Paragraphs"]
-, Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
-, Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
-, Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
-, Para [Str "Horizontal",Space,Str "rule",Str ":"]
-, HorizontalRule
-, Para [Str "Another",Str ":"]
-, HorizontalRule
-, Header 1 [Str "Block",Space,Str "Quotes"]
-, Para [Str "Here's",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
-, BlockQuote
- [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."] ]
-
-, Para [Str "Here's",Space,Str "another,",Space,Str "differently",Space,Str "indented",Str ":"]
-, BlockQuote
- [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It's",Space,Str "indented",Space,Str "with",Space,Str "a",Space,Str "tab."]
- , Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
- , Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
- , OrderedList (1,Decimal,Period)
- [ [ Plain [Str "item",Space,Str "one"] ]
- , [ Plain [Str "item",Space,Str "two"] ] ]
- , Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]
- , BlockQuote
- [ Para [Str "nested"]
- , BlockQuote
- [ Para [Str "nested"] ]
- ] ]
-, Header 1 [Str "Code",Space,Str "Blocks"]
-, Para [Str "Code",Str ":"]
-, CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}"
-, CodeBlock ("",[],[]) "this code block is indented by one tab"
-, Para [Str "And",Str ":"]
-, CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
-, Para [Str "And",Str ":"]
-, CodeBlock ("",["sourceCode","python"],[]) "def my_function(x):\n return x + 1"
-, Header 1 [Str "Lists"]
-, Header 2 [Str "Unordered"]
-, Para [Str "Asterisks",Space,Str "tight",Str ":"]
-, BulletList
- [ [ Plain [Str "asterisk",Space,Str "1"] ]
- , [ Plain [Str "asterisk",Space,Str "2"] ]
- , [ Plain [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Asterisks",Space,Str "loose",Str ":"]
-, BulletList
- [ [ Para [Str "asterisk",Space,Str "1"] ]
- , [ Para [Str "asterisk",Space,Str "2"] ]
- , [ Para [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "tight",Str ":"]
-, BulletList
- [ [ Plain [Str "Plus",Space,Str "1"] ]
- , [ Plain [Str "Plus",Space,Str "2"] ]
- , [ Plain [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "loose",Str ":"]
-, BulletList
- [ [ Para [Str "Plus",Space,Str "1"] ]
- , [ Para [Str "Plus",Space,Str "2"] ]
- , [ Para [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "tight",Str ":"]
-, BulletList
- [ [ Plain [Str "Minus",Space,Str "1"] ]
- , [ Plain [Str "Minus",Space,Str "2"] ]
- , [ Plain [Str "Minus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "loose",Str ":"]
-, BulletList
- [ [ Para [Str "Minus",Space,Str "1"] ]
- , [ Para [Str "Minus",Space,Str "2"] ]
- , [ Para [Str "Minus",Space,Str "3"] ] ]
-, Header 2 [Str "Ordered"]
-, Para [Str "Tight",Str ":"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second"] ]
- , [ Plain [Str "Third"] ] ]
-, Para [Str "and",Str ":"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "One"] ]
- , [ Plain [Str "Two"] ]
- , [ Plain [Str "Three"] ] ]
-, Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second"] ]
- , [ Para [Str "Third"] ] ]
-, Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "One"] ]
- , [ Para [Str "Two"] ]
- , [ Para [Str "Three"] ] ]
-, Para [Str "Multiple",Space,Str "paragraphs",Str ":"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
- , Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog's",Space,Str "back."] ], [ Para [Str "Item",Space,Str "2."] ]
- , [ Para [Str "Item",Space,Str "3."] ] ]
-, Para [Str "Nested",Str ":"]
-, BulletList
- [ [ Para [Str "Tab"]
- , BulletList
- [ [ Para [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"] ]
- ] ] ] ] ]
-, Para [Str "Here's",Space,Str "another",Str ":"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second",Str ":"]
- , BlockQuote
- [ BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ] ], [ Para [Str "Third"] ] ]
-, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
-, OrderedList (2,Decimal,TwoParens)
- [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
- , [ Para [Str "and",Space,Str "now",Space,Str "3"]
- , Para [Str "with",Space,Str "a",Space,Str "continuation"]
- , OrderedList (4,LowerRoman,Period)
- [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
- , [ Para [Str "more",Space,Str "items"]
- , OrderedList (1,UpperAlpha,TwoParens)
- [ [ Plain [Str "a",Space,Str "subsublist"] ]
- , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
-, Para [Str "Nesting",Str ":"]
-, OrderedList (1,UpperAlpha,Period)
- [ [ Para [Str "Upper",Space,Str "Alpha"]
- , OrderedList (1,UpperRoman,Period)
- [ [ Para [Str "Upper",Space,Str "Roman."]
- , OrderedList (6,Decimal,TwoParens)
- [ [ Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
- , OrderedList (3,LowerAlpha,OneParen)
- [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
- ] ] ] ] ] ] ]
-, Para [Str "Autonumbering",Str ":"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Autonumber."] ]
- , [ Para [Str "More."]
- , OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Nested."] ]
- ] ] ]
-, Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start",Str ":"]
-, OrderedList (4,LowerAlpha,TwoParens)
- [ [ Plain [Str "item",Space,Str "1"] ]
- , [ Plain [Str "item",Space,Str "2"] ] ]
-, Header 2 [Str "Definition"]
-, DefinitionList
- [ ([Str "term",Space,Str "1"],
- [ [ Para [Str "Definition",Space,Str "1."] ]
- ])
- , ([Str "term",Space,Str "2"],
- [ [ Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "1."]
- , Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2."] ]])
- , ([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]],
- [ [ Para [Str "Definition",Space,Str "3."] ]
- ]) ]
-, Header 1 [Str "Field",Space,Str "Lists"]
-, DefinitionList
- [ ([Str "address"],
- [ [ Plain [Str "61",Space,Str "Main",Space,Str "St."] ]
- ])
- , ([Str "city"],
- [ [ Plain [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"] ]
- ])
- , ([Str "phone"],
- [ [ Plain [Str "123",Str "-",Str "4567"] ]
- ]) ]
-, DefinitionList
- [ ([Str "address"],
- [ [ Plain [Str "61",Space,Str "Main",Space,Str "St."] ]
- ])
- , ([Str "city"],
- [ [ Plain [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"] ]
- ])
- , ([Str "phone"],
- [ [ Plain [Str "123",Str "-",Str "4567"] ]
- ]) ]
-, Header 1 [Str "HTML",Space,Str "Blocks"]
-, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]
-, RawHtml "<div>foo</div>\n"
-, Para [Str "Now,",Space,Str "nested",Str ":"]
-, RawHtml "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>\n"
-, Header 1 [Str "LaTeX",Space,Str "Block"]
-, Para [TeX "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}\n"]
-, Header 1 [Str "Inline",Space,Str "Markup"]
-, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]
-, Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ">",Str ",",Space,Code "$",Str ",",Space,Code "\\",Str ",",Space,Code "\\$",Str ",",Space,Code "<html>",Str "."]
-, Para [Str "This",Space,Str "is",Subscript [Str "subscripted"],Space,Str "and",Space,Str "this",Space,Str "is",Space,Superscript [Str "superscripted"],Str "."]
-, Header 1 [Str "Special",Space,Str "Characters"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]
-, BulletList
- [ [ Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"] ]
- , [ Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"] ]
- , [ Plain [Str "section",Str ":",Space,Str "\167"] ]
- , [ Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"] ]
- , [ Plain [Str "copyright",Str ":",Space,Str "\169"] ] ]
-, Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
-, Para [Str "This",Space,Str "&",Space,Str "that."]
-, Para [Str "4",Space,Str "<",Space,Str "5."]
-, Para [Str "6",Space,Str ">",Space,Str "5."]
-, Para [Str "Backslash",Str ":",Space,Str "\\"]
-, Para [Str "Backtick",Str ":",Space,Str "`"]
-, Para [Str "Asterisk",Str ":",Space,Str "*"]
-, Para [Str "Underscore",Str ":",Space,Str "_"]
-, Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]
-, Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]
-, Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]
-, Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]
-, Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]
-, Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]
-, Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]
-, Para [Str "Hash",Str ":",Space,Str "#"]
-, Para [Str "Period",Str ":",Space,Str "."]
-, Para [Str "Bang",Str ":",Space,Str "!"]
-, Para [Str "Plus",Str ":",Space,Str "+"]
-, Para [Str "Minus",Str ":",Space,Str "-"]
-, Header 1 [Str "Links"]
-, Para [Str "Explicit",Str ":",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
-, Para [Str "Two",Space,Str "anonymous",Space,Str "links",Str ":",Space,Link [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link [Str "the",Space,Str "second"] ("/url2/","")]
-, Para [Str "Reference",Space,Str "links",Str ":",Space,Link [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link [Str "link1"] ("/url1/",""),Space,Str "again."]
-, Para [Str "Here's",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
-, Para [Str "Here's",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT&T"] ("/url/",""),Str "."]
-, Para [Str "Autolinks",Str ":",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2",""),Space,Str "and",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net",""),Str "."]
-, Para [Str "But",Space,Str "not",Space,Str "here",Str ":"]
-, CodeBlock ("",[],[]) "http://example.com/"
-, Header 1 [Str "Images"]
-, Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902)",Str ":"]
-, Plain [Image [Str "image"] ("lalune.jpg","")]
-, Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","Voyage dans la Lune")]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
-, Header 1 [Str "Comments"]
-, Para [Str "First",Space,Str "paragraph"]
-, Para [Str "Another",Space,Str "paragraph"]
-, Para [Str "A",Space,Str "third",Space,Str "paragraph"]
-, Header 1 [Str "Line",Space,Str "blocks"]
-, Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str " ",Str "or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str " ",Str "when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str " ",Str "due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
-, Para [Str "Continuation",Space,Str "line",LineBreak,Str " ",Str "and",Space,Str "another"]
-, Header 1 [Str "Simple",Space,Str "Tables"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
- [ [ Plain [Str "col",Space,Str "1"] ]
- , [ Plain [Str "col",Space,Str "2"] ]
- , [ Plain [Str "col",Space,Str "3"] ] ] [
- [ [ Plain [Str "r1",Space,Str "a"] ]
- , [ Plain [Str "b"] ]
- , [ Plain [Str "c"] ] ],
- [ [ Plain [Str "r2",Space,Str "d"] ]
- , [ Plain [Str "e"] ]
- , [ Plain [Str "f"] ] ] ]
-, Para [Str "Headless"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
- [ []
- , []
- , [] ] [
- [ [ Plain [Str "r1",Space,Str "a"] ]
- , [ Plain [Str "b"] ]
- , [ Plain [Str "c"] ] ],
- [ [ Plain [Str "r2",Space,Str "d"] ]
- , [ Plain [Str "e"] ]
- , [ Plain [Str "f"] ] ] ]
-, Header 1 [Str "Grid",Space,Str "Tables"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
- [ [ Plain [Str "col",Space,Str "1"] ]
- , [ Plain [Str "col",Space,Str "2"] ]
- , [ Plain [Str "col",Space,Str "3"] ] ] [
- [ [ Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"] ]
- , [ Plain [Str "b",Space,Str "b",Space,Str "2"] ]
- , [ Plain [Str "c",Space,Str "c",Space,Str "2"] ] ],
- [ [ Plain [Str "r2",Space,Str "d"] ]
- , [ Plain [Str "e"] ]
- , [ Plain [Str "f"] ] ] ]
-, Para [Str "Headless"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
- [ []
- , []
- , [] ] [
- [ [ Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"] ]
- , [ Plain [Str "b",Space,Str "b",Space,Str "2"] ]
- , [ Plain [Str "c",Space,Str "c",Space,Str "2"] ] ],
- [ [ Plain [Str "r2",Space,Str "d"] ]
- , [ Plain [Str "e"] ]
- , [ Plain [Str "f"] ] ] ]
-, Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
- [ []
- , []
- , [] ] [
- [ [ Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"] ]
- , [ Plain [Str "b",Space,Str "b",Space,Str "2"] ]
- , [ Plain [Str "c",Space,Str "c",Space,Str "2"] ] ],
- [ [ Plain [Str "r2",Space,Str "d"] ]
- , [ Plain [Str "e"] ]
- , [ Plain [Str "f"] ] ] ]
-, Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
- [ []
- , []
- , [] ] [
- [ [ Para [Str "r1",Space,Str "a"]
- , Para [Str "r1",Space,Str "bis"] ], [ BulletList
- [ [ Plain [Str "b"] ]
- , [ Plain [Str "b",Space,Str "2"] ]
- , [ Plain [Str "b",Space,Str "2"] ] ] ], [ Plain [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"] ] ] ] ]
+[DefinitionList
+ [([Str "Revision"],
+ [[Para [Str "3"]]])]
+,Header 1 [Str "Level",Space,Str "one",Space,Str "header"]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+,Header 2 [Str "Level",Space,Str "two",Space,Str "header"]
+,Header 3 [Str "Level",Space,Str "three"]
+,Header 4 [Str "Level",Space,Str "four",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 5 [Str "Level",Space,Str "five"]
+,Header 1 [Str "Paragraphs"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
+,Para [Str "Horizontal",Space,Str "rule",Str ":"]
+,HorizontalRule
+,Para [Str "Another",Str ":"]
+,HorizontalRule
+,Header 1 [Str "Block",Space,Str "Quotes"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "another,",Space,Str "differently",Space,Str "indented",Str ":"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Apostrophe,Str "s",Space,Str "indented",Space,Str "with",Space,Str "a",Space,Str "tab",Str "."]
+ ,Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]
+ ,BlockQuote
+ [Para [Str "nested"]
+ ,BlockQuote
+ [Para [Str "nested"]]]]
+,Header 1 [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code",Str ":"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}"
+,CodeBlock ("",[],[]) "this code block is indented by one tab"
+,Para [Str "And",Str ":"]
+,CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,Para [Str "And",Str ":"]
+,CodeBlock ("",["sourceCode","python"],[]) "def my_function(x):\n return x + 1"
+,Header 1 [Str "Lists"]
+,Header 2 [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 [Str "Ordered"]
+,Para [Str "Tight",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
+ ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."]]
+ ,[Para [Str "Item",Space,Str "2",Str "."]]
+ ,[Para [Str "Item",Space,Str "3",Str "."]]]
+,Para [Str "Nested",Str ":"]
+,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "another",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second",Str ":"]
+ ,BlockQuote
+ [BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Para [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting",Str ":"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Para [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Para [Str "Upper",Space,Str "Roman",Str "."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering",Str ":"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber",Str "."]]
+ ,[Para [Str "More",Str "."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested",Str "."]]]]]
+,Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start",Str ":"]
+,OrderedList (4,LowerAlpha,TwoParens)
+ [[Plain [Str "item",Space,Str "1"]]
+ ,[Plain [Str "item",Space,Str "2"]]]
+,Header 2 [Str "Definition"]
+,DefinitionList
+ [([Str "term",Space,Str "1"],
+ [[Para [Str "Definition",Space,Str "1",Str "."]]])
+ ,([Str "term",Space,Str "2"],
+ [[Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "1",Str "."]
+ ,Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2",Str "."]]])
+ ,([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]],
+ [[Para [Str "Definition",Space,Str "3",Str "."]]])]
+,Header 1 [Str "Field",Space,Str "Lists"]
+,BlockQuote
+ [DefinitionList
+ [([Str "address"],
+ [[Para [Str "61",Space,Str "Main",Space,Str "St",Str "."]]])
+ ,([Str "city"],
+ [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]])
+ ,([Str "phone"],
+ [[Para [Str "123",EnDash,Str "4567"]]])]]
+,DefinitionList
+ [([Str "address"],
+ [[Para [Str "61",Space,Str "Main",Space,Str "St",Str "."]]])
+ ,([Str "city"],
+ [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]])
+ ,([Str "phone"],
+ [[Para [Str "123",EnDash,Str "4567"]]])]
+,Header 1 [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]
+,RawBlock "html" "<div>foo</div>\n"
+,Para [Str "Now,",Space,Str "nested",Str ":"]
+,RawBlock "html" "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>\n"
+,Header 1 [Str "LaTeX",Space,Str "Block"]
+,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}\n"
+,Header 1 [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Str "This",Space,Str "is",Subscript [Str "subscripted"],Space,Str "and",Space,Str "this",Space,Str "is",Space,Superscript [Str "superscripted"],Str "."]
+,Header 1 [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"]]
+ ,[Plain [Str "section",Str ":",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"]]
+ ,[Plain [Str "copyright",Str ":",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
+,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
+,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
+,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
+,Para [Str "Backslash",Str ":",Space,Str "\\"]
+,Para [Str "Backtick",Str ":",Space,Str "`"]
+,Para [Str "Asterisk",Str ":",Space,Str "*"]
+,Para [Str "Underscore",Str ":",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]
+,Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]
+,Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]
+,Para [Str "Hash",Str ":",Space,Str "#"]
+,Para [Str "Period",Str ":",Space,Str "."]
+,Para [Str "Bang",Str ":",Space,Str "!"]
+,Para [Str "Plus",Str ":",Space,Str "+"]
+,Para [Str "Minus",Str ":",Space,Str "-"]
+,Header 1 [Str "Links"]
+,Para [Str "Explicit",Str ":",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
+,Para [Str "Two",Space,Str "anonymous",Space,Str "links",Str ":",Space,Link [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link [Str "the",Space,Str "second"] ("/url2/","")]
+,Para [Str "Reference",Space,Str "links",Str ":",Space,Link [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link [Str "link1"] ("/url1/",""),Space,Str "again",Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT&T"] ("/url/",""),Str "."]
+,Para [Str "Autolinks",Str ":",Space,Link [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2",""),Space,Str "and",Space,Link [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net",""),Str "."]
+,Para [Str "But",Space,Str "not",Space,Str "here",Str ":"]
+,CodeBlock ("",[],[]) "http://example.com/"
+,Header 1 [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902)",Str ":"]
+,Plain [Image [Str "image"] ("lalune.jpg","")]
+,Plain [Image [Str "Voyage dans la Lune"] ("lalune.jpg","")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
+,Header 1 [Str "Comments"]
+,Para [Str "First",Space,Str "paragraph"]
+,Para [Str "Another",Space,Str "paragraph"]
+,Para [Str "A",Space,Str "third",Space,Str "paragraph"]
+,Header 1 [Str "Line",Space,Str "blocks"]
+,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str " ",Str "or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str " ",Str "when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str " ",Str "due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
+,Para [Str "Continuation",Space,Str "line",LineBreak,Str " ",Str "and",Space,Str "another"]
+,Header 1 [Str "Simple",Space,Str "Tables"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "col",Space,Str "1"]]
+ ,[Plain [Str "col",Space,Str "2"]]
+ ,[Plain [Str "col",Space,Str "3"]]]
+ [[[Plain [Str "r1",Space,Str "a"]]
+ ,[Plain [Str "b"]]
+ ,[Plain [Str "c"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Headless"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "r1",Space,Str "a"]]
+ ,[Plain [Str "b"]]
+ ,[Plain [Str "c"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Header 1 [Str "Grid",Space,Str "Tables"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[Plain [Str "col",Space,Str "1"]]
+ ,[Plain [Str "col",Space,Str "2"]]
+ ,[Plain [Str "col",Space,Str "3"]]]
+ [[[Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]]
+ ,[Plain [Str "b",Space,Str "b",Space,Str "2"]]
+ ,[Plain [Str "c",Space,Str "c",Space,Str "2"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Headless"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]]
+ ,[Plain [Str "b",Space,Str "b",Space,Str "2"]]
+ ,[Plain [Str "c",Space,Str "c",Space,Str "2"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "r1",Space,Str "a",Space,Str "r1",Space,Str "bis"]]
+ ,[Plain [Str "b",Space,Str "b",Space,Str "2"]]
+ ,[Plain [Str "c",Space,Str "c",Space,Str "2"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[]
+ ,[]
+ ,[]]
+ [[[Para [Str "r1",Space,Str "a"]
+ ,Para [Str "r1",Space,Str "bis"]]
+ ,[BulletList
+ [[Plain [Str "b"]]
+ ,[Plain [Str "b",Space,Str "2"]]
+ ,[Plain [Str "b",Space,Str "2"]]]]
+ ,[Plain [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]]
+,Header 1 [Str "Footnotes"]
+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "one",Space,Str "line",Str "."]]]
+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "continuation",Space,Str "line",Str "."]]]
+,Para [Note [Para [Str "Note",Space,Str "with"],Para [Str "continuation",Space,Str "block",Str "."]]]
+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "continuation",Space,Str "line"],Para [Str "and",Space,Str "a",Space,Str "second",Space,Str "para",Str "."]]]
+,Para [Str "Not",Space,Str "in",Space,Str "note",Str "."]]
diff --git a/tests/rst-reader.rst b/tests/rst-reader.rst
index 8c4b7d726..519f0080c 100644
--- a/tests/rst-reader.rst
+++ b/tests/rst-reader.rst
@@ -508,3 +508,31 @@ Multiple blocks in a cell
| | - b 2 | c 2 |
| r1 bis | - b 2 | c 2 |
+------------------+-----------+------------+
+
+Footnotes
+=========
+
+[1]_
+
+[#]_
+
+[#]_
+
+[*]_
+
+.. [1] Note with one line.
+
+.. [#] Note with
+ continuation line.
+
+.. [#] Note with
+
+ continuation block.
+
+.. [*] Note with
+ continuation line
+
+ and a second para.
+
+Not in note.
+
diff --git a/tests/s5.basic.html b/tests/s5.basic.html
index 825d05868..64971417a 100644
--- a/tests/s5.basic.html
+++ b/tests/s5.basic.html
@@ -1,12 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>My S5 Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Sam Smith" />
<meta name="author" content="Jen Jones" />
<meta name="date" content="July 15, 2006" />
+ <title>My S5 Document</title>
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
diff --git a/tests/s5.fancy.html b/tests/s5.fancy.html
index f4f2e7815..200990b6a 100644
--- a/tests/s5.fancy.html
+++ b/tests/s5.fancy.html
@@ -1,12 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>My S5 Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Sam Smith" />
<meta name="author" content="Jen Jones" />
<meta name="date" content="July 15, 2006" />
+ <title>My S5 Document</title>
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
diff --git a/tests/s5.fragment.html b/tests/s5.fragment.html
index cc111566a..9845e1409 100644
--- a/tests/s5.fragment.html
+++ b/tests/s5.fragment.html
@@ -14,4 +14,4 @@
>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span
></li
></ul
-> \ No newline at end of file
+>
diff --git a/tests/s5.inserts.html b/tests/s5.inserts.html
index 90014f2e6..3010ef758 100644
--- a/tests/s5.inserts.html
+++ b/tests/s5.inserts.html
@@ -1,12 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>My S5 Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Sam Smith" />
<meta name="author" content="Jen Jones" />
<meta name="date" content="July 15, 2006" />
+ <title>My S5 Document</title>
<link rel="stylesheet" href="main.css" type="text/css" />
STUFF INSERTED
</head>
diff --git a/tests/s5.native b/tests/s5.native
index c6175478d..020ee4079 100644
--- a/tests/s5.native
+++ b/tests/s5.native
@@ -1,9 +1,8 @@
Pandoc (Meta {docTitle = [Str "My",Space,Str "S5",Space,Str "Document"], docAuthors = [[Str "Sam",Space,Str "Smith"],[Str "Jen",Space,Str "Jones"]], docDate = [Str "July",Space,Str "15,",Space,Str "2006"]})
-[ Header 1 [Str "First",Space,Str "slide"]
-, BulletList
- [ [ Plain [Str "first",Space,Str "bullet"] ]
- , [ Plain [Str "second",Space,Str "bullet"] ] ]
-, Header 1 [Str "Math"]
-, BulletList
- [ [ Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"] ]
- ] ]
+[Header 1 [Str "First",Space,Str "slide"]
+,BulletList
+ [[Plain [Str "first",Space,Str "bullet"]]
+ ,[Plain [Str "second",Space,Str "bullet"]]]
+,Header 1 [Str "Math"]
+,BulletList
+ [[Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]]]
diff --git a/tests/tables-rstsubset.native b/tests/tables-rstsubset.native
index 7941772b5..ef89fea29 100644
--- a/tests/tables-rstsubset.native
+++ b/tests/tables-rstsubset.native
@@ -1,118 +1,117 @@
-Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
-[ Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
- [ [ Plain [Str "Right"] ]
- , [ Plain [Str "Left"] ]
- , [ Plain [Str "Center"] ]
- , [ Plain [Str "Default"] ] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Table",Str ":",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."]
-, Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
- [ [ Plain [Str "Right"] ]
- , [ Plain [Str "Left"] ]
- , [ Plain [Str "Center"] ]
- , [ Plain [Str "Default"] ] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
- [ [ Plain [Str "Right"] ]
- , [ Plain [Str "Left"] ]
- , [ Plain [Str "Center"] ]
- , [ Plain [Str "Default"] ] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Table",Str ":",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."]
-, Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
- [ [ Plain [Str "Centered",Space,Str "Header"] ]
- , [ Plain [Str "Left",Space,Str "Aligned"] ]
- , [ Plain [Str "Right",Space,Str "Aligned"] ]
- , [ Plain [Str "Default",Space,Str "aligned"] ] ] [
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "12.0"] ]
- , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."] ] ],
- [ [ Plain [Str "Second"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "5.0"] ]
- , [ Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."] ] ] ]
-, Para [Str "Table",Str ":",Space,Str "Here's",Space,Str "the",Space,Str "caption.",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines."]
-, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
- [ [ Plain [Str "Centered",Space,Str "Header"] ]
- , [ Plain [Str "Left",Space,Str "Aligned"] ]
- , [ Plain [Str "Right",Space,Str "Aligned"] ]
- , [ Plain [Str "Default",Space,Str "aligned"] ] ] [
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "12.0"] ]
- , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."] ] ],
- [ [ Plain [Str "Second"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "5.0"] ]
- , [ Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."] ] ] ]
-, Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1]
- [ []
- , []
- , []
- , [] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
-, Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
- [ []
- , []
- , []
- , [] ] [
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "12.0"] ]
- , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."] ] ],
- [ [ Plain [Str "Second"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "5.0"] ]
- , [ Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."] ] ] ] ]
+[Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Table",Str ":",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."]
+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Table",Str ":",Space,Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."]
+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12",Str ".",Str "0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5",Str ".",Str "0"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]
+,Para [Str "Table",Str ":",Space,Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12",Str ".",Str "0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5",Str ".",Str "0"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]
+,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,0.1,0.1,0.1]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12",Str ".",Str "0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5",Str ".",Str "0"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]]
diff --git a/tests/tables.docbook b/tests/tables.docbook
index a24964600..6483a97c0 100644
--- a/tests/tables.docbook
+++ b/tests/tables.docbook
@@ -399,4 +399,4 @@
</td>
</tr>
</tbody>
-</informaltable> \ No newline at end of file
+</informaltable>
diff --git a/tests/tables.html b/tests/tables.html
index 93944828c..e4dd6be58 100644
--- a/tests/tables.html
+++ b/tests/tables.html
@@ -298,4 +298,4 @@
></tr
></tbody
></table
-> \ No newline at end of file
+>
diff --git a/tests/tables.latex b/tests/tables.latex
index 5dac8e2a0..89bcf9d9f 100644
--- a/tests/tables.latex
+++ b/tests/tables.latex
@@ -3,27 +3,11 @@ Simple table with caption:
\begin{table}[h]
\begin{center}
\begin{tabular}{rlcl}
-Right
- & Left
- & Center
- & Default
-\\
+Right & Left & Center & Default\\
\hline
-12
- & 12
- & 12
- & 12
-\\
-123
- & 123
- & 123
- & 123
-\\
-1
- & 1
- & 1
- & 1
-\\
+12 & 12 & 12 & 12\\
+123 & 123 & 123 & 123\\
+1 & 1 & 1 & 1\\
\end{tabular}
\end{center}
\caption{Demonstration of simple table syntax.}
@@ -33,27 +17,11 @@ Simple table without caption:
\begin{center}
\begin{tabular}{rlcl}
-Right
- & Left
- & Center
- & Default
-\\
+Right & Left & Center & Default\\
\hline
-12
- & 12
- & 12
- & 12
-\\
-123
- & 123
- & 123
- & 123
-\\
-1
- & 1
- & 1
- & 1
-\\
+12 & 12 & 12 & 12\\
+123 & 123 & 123 & 123\\
+1 & 1 & 1 & 1\\
\end{tabular}
\end{center}
@@ -62,27 +30,11 @@ Simple table indented two spaces:
\begin{table}[h]
\begin{center}
\begin{tabular}{rlcl}
-Right
- & Left
- & Center
- & Default
-\\
+Right & Left & Center & Default\\
\hline
-12
- & 12
- & 12
- & 12
-\\
-123
- & 123
- & 123
- & 123
-\\
-1
- & 1
- & 1
- & 1
-\\
+12 & 12 & 12 & 12\\
+123 & 123 & 123 & 123\\
+1 & 1 & 1 & 1\\
\end{tabular}
\end{center}
\caption{Demonstration of simple table syntax.}
@@ -93,22 +45,23 @@ Multiline table with caption:
\begin{table}[h]
\begin{center}
\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\columnwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\columnwidth}}
-Centered Header
- & Left Aligned
- & Right Aligned
- & Default aligned
-\\
+\parbox{0.15\columnwidth}{Centered Header
+} & \parbox{0.14\columnwidth}{Left Aligned
+} & \parbox{0.16\columnwidth}{Right Aligned
+} & \parbox{0.34\columnwidth}{Default aligned
+}\\
\hline
-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.
-\\
+\parbox{0.15\columnwidth}{First
+} & \parbox{0.14\columnwidth}{row
+} & \parbox{0.16\columnwidth}{12.0
+} & \parbox{0.34\columnwidth}{Example of a row that spans multiple lines.
+}\\
+\parbox{0.15\columnwidth}{Second
+} & \parbox{0.14\columnwidth}{row
+} & \parbox{0.16\columnwidth}{5.0
+} & \parbox{0.34\columnwidth}{Here's another one. Note the blank line between
+rows.
+}\\
\end{tabular}
\end{center}
\caption{Here's the caption. It may span multiple lines.}
@@ -118,22 +71,23 @@ Multiline table without caption:
\begin{center}
\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\columnwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\columnwidth}}
-Centered Header
- & Left Aligned
- & Right Aligned
- & Default aligned
-\\
+\parbox{0.15\columnwidth}{Centered Header
+} & \parbox{0.14\columnwidth}{Left Aligned
+} & \parbox{0.16\columnwidth}{Right Aligned
+} & \parbox{0.34\columnwidth}{Default aligned
+}\\
\hline
-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.
-\\
+\parbox{0.15\columnwidth}{First
+} & \parbox{0.14\columnwidth}{row
+} & \parbox{0.16\columnwidth}{12.0
+} & \parbox{0.34\columnwidth}{Example of a row that spans multiple lines.
+}\\
+\parbox{0.15\columnwidth}{Second
+} & \parbox{0.14\columnwidth}{row
+} & \parbox{0.16\columnwidth}{5.0
+} & \parbox{0.34\columnwidth}{Here's another one. Note the blank line between
+rows.
+}\\
\end{tabular}
\end{center}
@@ -141,21 +95,9 @@ Table without column headers:
\begin{center}
\begin{tabular}{rlcr}
-12
- & 12
- & 12
- & 12
-\\
-123
- & 123
- & 123
- & 123
-\\
-1
- & 1
- & 1
- & 1
-\\
+12 & 12 & 12 & 12\\
+123 & 123 & 123 & 123\\
+1 & 1 & 1 & 1\\
\end{tabular}
\end{center}
@@ -163,15 +105,17 @@ Multiline table without column headers:
\begin{center}
\begin{tabular}{>{\PBS\centering\hspace{0pt}}p{0.15\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.14\columnwidth}>{\PBS\raggedleft\hspace{0pt}}p{0.16\columnwidth}>{\PBS\raggedright\hspace{0pt}}p{0.34\columnwidth}}
-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.
-\\
+\parbox{0.15\columnwidth}{First
+} & \parbox{0.14\columnwidth}{row
+} & \parbox{0.16\columnwidth}{12.0
+} & \parbox{0.34\columnwidth}{Example of a row that spans multiple lines.
+}\\
+\parbox{0.15\columnwidth}{Second
+} & \parbox{0.14\columnwidth}{row
+} & \parbox{0.16\columnwidth}{5.0
+} & \parbox{0.34\columnwidth}{Here's another one. Note the blank line between
+rows.
+}\\
\end{tabular}
\end{center}
+
diff --git a/tests/tables.markdown b/tests/tables.markdown
index 95bcc667e..4b5754cf9 100644
--- a/tests/tables.markdown
+++ b/tests/tables.markdown
@@ -5,7 +5,7 @@ Simple table with caption:
12 12 12 12
123 123 123 123
1 1 1 1
-
+
: Demonstration of simple table syntax.
Simple table without caption:
@@ -23,34 +23,34 @@ Simple table indented two spaces:
12 12 12 12
123 123 123 123
1 1 1 1
-
+
: Demonstration of simple table syntax.
Multiline table with caption:
--------------------------------------------------------------
Centered Left Right Default aligned
- Header Aligned Aligned
+ Header Aligned 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.
--------------------------------------------------------------
-
+
: Here's the caption. It may span multiple lines.
Multiline table without caption:
--------------------------------------------------------------
Centered Left Right Default aligned
- Header Aligned Aligned
+ Header Aligned 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.
@@ -69,8 +69,10 @@ Multiline table without column headers:
----------- ---------- ------------ --------------------------
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.
----------- ---------- ------------ --------------------------
+
+
diff --git a/tests/tables.mediawiki b/tests/tables.mediawiki
index d0e5c7b9e..4836ecd79 100644
--- a/tests/tables.mediawiki
+++ b/tests/tables.mediawiki
@@ -209,3 +209,4 @@ Multiline table without column headers:
</tr>
</tbody>
</table>
+
diff --git a/tests/tables.native b/tests/tables.native
index 8592831fe..1d714d730 100644
--- a/tests/tables.native
+++ b/tests/tables.native
@@ -1,115 +1,114 @@
-Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
-[ Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"]
-, Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
- [ [ Plain [Str "Right"] ]
- , [ Plain [Str "Left"] ]
- , [ Plain [Str "Center"] ]
- , [ Plain [Str "Default"] ] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]
-, Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
- [ [ Plain [Str "Right"] ]
- , [ Plain [Str "Left"] ]
- , [ Plain [Str "Center"] ]
- , [ Plain [Str "Default"] ] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"]
-, Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
- [ [ Plain [Str "Right"] ]
- , [ Plain [Str "Left"] ]
- , [ Plain [Str "Center"] ]
- , [ Plain [Str "Default"] ] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"]
-, Table [Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]
- [ [ Plain [Str "Centered",Space,Str "Header"] ]
- , [ Plain [Str "Left",Space,Str "Aligned"] ]
- , [ Plain [Str "Right",Space,Str "Aligned"] ]
- , [ Plain [Str "Default",Space,Str "aligned"] ] ] [
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "12",Str ".",Str "0"] ]
- , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."] ] ],
- [ [ Plain [Str "Second"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "5",Str ".",Str "0"] ]
- , [ Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."] ] ] ]
-, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"]
-, Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]
- [ [ Plain [Str "Centered",Space,Str "Header"] ]
- , [ Plain [Str "Left",Space,Str "Aligned"] ]
- , [ Plain [Str "Right",Space,Str "Aligned"] ]
- , [ Plain [Str "Default",Space,Str "aligned"] ] ] [
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "12",Str ".",Str "0"] ]
- , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."] ] ],
- [ [ Plain [Str "Second"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "5",Str ".",Str "0"] ]
- , [ Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."] ] ] ]
-, Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers:"]
-, Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0]
- [ []
- , []
- , []
- , [] ] [
- [ [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ]
- , [ Plain [Str "12"] ] ],
- [ [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ]
- , [ Plain [Str "123"] ] ],
- [ [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ]
- , [ Plain [Str "1"] ] ] ]
-, Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers:"]
-, Table [] [AlignCenter,AlignLeft,AlignRight,AlignDefault] [0.15,0.1375,0.1625,0.3375]
- [ []
- , []
- , []
- , [] ] [
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "12",Str ".",Str "0"] ]
- , [ Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."] ] ],
- [ [ Plain [Str "Second"] ]
- , [ Plain [Str "row"] ]
- , [ Plain [Str "5",Str ".",Str "0"] ]
- , [ Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."] ] ] ] ]
+[Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]
+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]
+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces",Str ":"]
+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax",Str "."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption",Str ":"]
+,Table [Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "caption",Str ".",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines",Str "."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12",Str ".",Str "0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5",Str ".",Str "0"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption",Str ":"]
+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12",Str ".",Str "0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5",Str ".",Str "0"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]
+,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers",Str ":"]
+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignDefault] [0.15,0.1375,0.1625,0.3375]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12",Str ".",Str "0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines",Str "."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5",Str ".",Str "0"]]
+ ,[Plain [Str "Here",Str "'",Str "s",Space,Str "another",Space,Str "one",Str ".",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows",Str "."]]]]]
diff --git a/tests/tables.opendocument b/tests/tables.opendocument
index c071e526d..e103dee12 100644
--- a/tests/tables.opendocument
+++ b/tests/tables.opendocument
@@ -63,7 +63,8 @@
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="Caption">Demonstration of simple table syntax.</text:p>
+<text:p text:style-name="Caption">Demonstration of simple table
+syntax.</text:p>
<text:p text:style-name="Text_20_body">Simple table without caption:</text:p>
<table:table table:name="Table2" table:style-name="Table2">
<table:table-column table:style-name="Table2.A" />
@@ -129,7 +130,8 @@
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="Text_20_body">Simple table indented two spaces:</text:p>
+<text:p text:style-name="Text_20_body">Simple table indented two
+spaces:</text:p>
<table:table table:name="Table3" table:style-name="Table3">
<table:table-column table:style-name="Table3.A" />
<table:table-column table:style-name="Table3.B" />
@@ -194,7 +196,8 @@
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="Caption">Demonstration of simple table syntax.</text:p>
+<text:p text:style-name="Caption">Demonstration of simple table
+syntax.</text:p>
<text:p text:style-name="Text_20_body">Multiline table with caption:</text:p>
<table:table table:name="Table4" table:style-name="Table4">
<table:table-column table:style-name="Table4.A" />
@@ -228,7 +231,8 @@
<text:p text:style-name="P16">12.0</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table4.A1" office:value-type="string">
- <text:p text:style-name="Table_20_Contents">Example of a row that spans multiple lines.</text:p>
+ <text:p text:style-name="Table_20_Contents">Example of a row that spans
+ multiple lines.</text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -242,12 +246,15 @@
<text:p text:style-name="P16">5.0</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table4.A1" office:value-type="string">
- <text:p text:style-name="Table_20_Contents">Here's another one. Note the blank line between rows.</text:p>
+ <text:p text:style-name="Table_20_Contents">Here's another one. Note the
+ blank line between rows.</text:p>
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="Caption">Here's the caption. It may span multiple lines.</text:p>
-<text:p text:style-name="Text_20_body">Multiline table without caption:</text:p>
+<text:p text:style-name="Caption">Here's the caption. It may span multiple
+lines.</text:p>
+<text:p text:style-name="Text_20_body">Multiline table without
+caption:</text:p>
<table:table table:name="Table5" table:style-name="Table5">
<table:table-column table:style-name="Table5.A" />
<table:table-column table:style-name="Table5.B" />
@@ -280,7 +287,8 @@
<text:p text:style-name="P20">12.0</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table5.A1" office:value-type="string">
- <text:p text:style-name="Table_20_Contents">Example of a row that spans multiple lines.</text:p>
+ <text:p text:style-name="Table_20_Contents">Example of a row that spans
+ multiple lines.</text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -294,7 +302,8 @@
<text:p text:style-name="P20">5.0</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table5.A1" office:value-type="string">
- <text:p text:style-name="Table_20_Contents">Here's another one. Note the blank line between rows.</text:p>
+ <text:p text:style-name="Table_20_Contents">Here's another one. Note the
+ blank line between rows.</text:p>
</table:table-cell>
</table:table-row>
</table:table>
@@ -347,7 +356,8 @@
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="Text_20_body">Multiline table without column headers:</text:p>
+<text:p text:style-name="Text_20_body">Multiline table without column
+headers:</text:p>
<table:table table:name="Table7" table:style-name="Table7">
<table:table-column table:style-name="Table7.A" />
<table:table-column table:style-name="Table7.B" />
@@ -364,7 +374,8 @@
<text:p text:style-name="P30">12.0</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table7.A1" office:value-type="string">
- <text:p text:style-name="Table_20_Contents">Example of a row that spans multiple lines.</text:p>
+ <text:p text:style-name="Table_20_Contents">Example of a row that spans
+ multiple lines.</text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -378,7 +389,8 @@
<text:p text:style-name="P30">5.0</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table7.A1" office:value-type="string">
- <text:p text:style-name="Table_20_Contents">Here's another one. Note the blank line between rows.</text:p>
+ <text:p text:style-name="Table_20_Contents">Here's another one. Note the
+ blank line between rows.</text:p>
</table:table-cell>
</table:table-row>
-</table:table> \ No newline at end of file
+</table:table>
diff --git a/tests/tables.org b/tests/tables.org
new file mode 100644
index 000000000..8d9100d07
--- /dev/null
+++ b/tests/tables.org
@@ -0,0 +1,52 @@
+Simple table with caption:
+
+| Right | Left | Center | Default |
+|---------+--------+----------+-----------|
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+#+CAPTION: Demonstration of simple table syntax.
+
+Simple table without caption:
+
+| Right | Left | Center | Default |
+|---------+--------+----------+-----------|
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+
+Simple table indented two spaces:
+
+| Right | Left | Center | Default |
+|---------+--------+----------+-----------|
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+#+CAPTION: Demonstration of simple table syntax.
+
+Multiline table with caption:
+
+| Centered Header | Left Aligned | Right Aligned | Default 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. |
+#+CAPTION: Here's the caption. It may span multiple lines.
+
+Multiline table without caption:
+
+| Centered Header | Left Aligned | Right Aligned | Default 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. |
+
+Table without column headers:
+
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+
+Multiline table without column headers:
+
+| 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. |
+
diff --git a/tests/tables.plain b/tests/tables.plain
index 95bcc667e..4b5754cf9 100644
--- a/tests/tables.plain
+++ b/tests/tables.plain
@@ -5,7 +5,7 @@ Simple table with caption:
12 12 12 12
123 123 123 123
1 1 1 1
-
+
: Demonstration of simple table syntax.
Simple table without caption:
@@ -23,34 +23,34 @@ Simple table indented two spaces:
12 12 12 12
123 123 123 123
1 1 1 1
-
+
: Demonstration of simple table syntax.
Multiline table with caption:
--------------------------------------------------------------
Centered Left Right Default aligned
- Header Aligned Aligned
+ Header Aligned 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.
--------------------------------------------------------------
-
+
: Here's the caption. It may span multiple lines.
Multiline table without caption:
--------------------------------------------------------------
Centered Left Right Default aligned
- Header Aligned Aligned
+ Header Aligned 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.
@@ -69,8 +69,10 @@ Multiline table without column headers:
----------- ---------- ------------ --------------------------
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.
----------- ---------- ------------ --------------------------
+
+
diff --git a/tests/tables.rst b/tests/tables.rst
index 25d5932ea..e77f69d97 100644
--- a/tests/tables.rst
+++ b/tests/tables.rst
@@ -88,3 +88,4 @@ Multiline table without column headers:
| | | | the blank line between |
| | | | rows. |
+-------------+------------+--------------+----------------------------+
+
diff --git a/tests/tables.rtf b/tests/tables.rtf
index 011724967..e7c1e9f60 100644
--- a/tests/tables.rtf
+++ b/tests/tables.rtf
@@ -357,3 +357,4 @@
}
\intbl\row}
{\pard \ql \f0 \sa180 \li0 \fi0 \par}
+
diff --git a/tests/tables.textile b/tests/tables.textile
new file mode 100644
index 000000000..4836ecd79
--- /dev/null
+++ b/tests/tables.textile
@@ -0,0 +1,212 @@
+Simple table with caption:
+
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th align="left">Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="left">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="left">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="left">1</td>
+</tr>
+</tbody>
+</table>
+
+Simple table without caption:
+
+<table>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th align="left">Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="left">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="left">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="left">1</td>
+</tr>
+</tbody>
+</table>
+
+Simple table indented two spaces:
+
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th align="left">Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="left">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="left">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="left">1</td>
+</tr>
+</tbody>
+</table>
+
+Multiline table with caption:
+
+<table>
+<caption>Here's the caption. It may span multiple lines.</caption>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+<thead>
+<tr class="header">
+<th align="center">Centered Header</th>
+<th align="left">Left Aligned</th>
+<th align="right">Right Aligned</th>
+<th align="left">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here's another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+
+Multiline table without caption:
+
+<table>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+<thead>
+<tr class="header">
+<th align="center">Centered Header</th>
+<th align="left">Left Aligned</th>
+<th align="right">Right Aligned</th>
+<th align="left">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here's another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+
+Table without column headers:
+
+<table>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="right">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="right">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="right">1</td>
+</tr>
+</tbody>
+</table>
+
+Multiline table without column headers:
+
+<table>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here's another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+
diff --git a/tests/testsuite.native b/tests/testsuite.native
index ced38537c..879cb24fc 100644
--- a/tests/testsuite.native
+++ b/tests/testsuite.native
@@ -1,417 +1,396 @@
-Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]})
-[ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
-, HorizontalRule
-, Header 1 [Str "Headers"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
-, Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 4 [Str "Level",Space,Str "4"]
-, Header 5 [Str "Level",Space,Str "5"]
-, Header 1 [Str "Level",Space,Str "1"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 3 [Str "Level",Space,Str "3"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, Header 2 [Str "Level",Space,Str "2"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, HorizontalRule
-, Header 1 [Str "Paragraphs"]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
-, Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
-, Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here",Str "."]
-, HorizontalRule
-, Header 1 [Str "Block",Space,Str "Quotes"]
-, Para [Str "E",Str "-",Str "mail",Space,Str "style:"]
-, BlockQuote
- [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."] ]
-
-, BlockQuote
- [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
- , Para [Str "A",Space,Str "list:"]
- , OrderedList (1,Decimal,Period)
- [ [ Plain [Str "item",Space,Str "one"] ]
- , [ Plain [Str "item",Space,Str "two"] ] ]
- , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
- , BlockQuote
- [ Para [Str "nested"] ]
-
- , BlockQuote
- [ Para [Str "nested"] ]
- ]
-, Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]
-, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
-, HorizontalRule
-, Header 1 [Str "Code",Space,Str "Blocks"]
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
-, Para [Str "And:"]
-, CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
-, HorizontalRule
-, Header 1 [Str "Lists"]
-, Header 2 [Str "Unordered"]
-, Para [Str "Asterisks",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "asterisk",Space,Str "1"] ]
- , [ Plain [Str "asterisk",Space,Str "2"] ]
- , [ Plain [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Asterisks",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "asterisk",Space,Str "1"] ]
- , [ Para [Str "asterisk",Space,Str "2"] ]
- , [ Para [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "Plus",Space,Str "1"] ]
- , [ Plain [Str "Plus",Space,Str "2"] ]
- , [ Plain [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Plus",Space,Str "1"] ]
- , [ Para [Str "Plus",Space,Str "2"] ]
- , [ Para [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "Minus",Space,Str "1"] ]
- , [ Plain [Str "Minus",Space,Str "2"] ]
- , [ Plain [Str "Minus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Minus",Space,Str "1"] ]
- , [ Para [Str "Minus",Space,Str "2"] ]
- , [ Para [Str "Minus",Space,Str "3"] ] ]
-, Header 2 [Str "Ordered"]
-, Para [Str "Tight:"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second"] ]
- , [ Plain [Str "Third"] ] ]
-, Para [Str "and:"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "One"] ]
- , [ Plain [Str "Two"] ]
- , [ Plain [Str "Three"] ] ]
-, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second"] ]
- , [ Para [Str "Third"] ] ]
-, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "One"] ]
- , [ Para [Str "Two"] ]
- , [ Para [Str "Three"] ] ]
-, Para [Str "Multiple",Space,Str "paragraphs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
- , Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."] ], [ Para [Str "Item",Space,Str "2",Str "."] ]
- , [ Para [Str "Item",Space,Str "3",Str "."] ] ]
-, Header 2 [Str "Nested"]
-, BulletList
- [ [ Plain [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"] ]
- ] ] ] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second:"]
- , BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ], [ Plain [Str "Third"] ] ]
-, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second:"]
- , BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ]
-, Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
-, BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
- , BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
-, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
-, OrderedList (2,Decimal,TwoParens)
- [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
- , [ Para [Str "and",Space,Str "now",Space,Str "3"]
- , Para [Str "with",Space,Str "a",Space,Str "continuation"]
- , OrderedList (4,LowerRoman,Period)
- [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
- , [ Plain [Str "more",Space,Str "items"]
- , OrderedList (1,UpperAlpha,TwoParens)
- [ [ Plain [Str "a",Space,Str "subsublist"] ]
- , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
-, Para [Str "Nesting:"]
-, OrderedList (1,UpperAlpha,Period)
- [ [ Plain [Str "Upper",Space,Str "Alpha"]
- , OrderedList (1,UpperRoman,Period)
- [ [ Plain [Str "Upper",Space,Str "Roman",Str "."]
- , OrderedList (6,Decimal,TwoParens)
- [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
- , OrderedList (3,LowerAlpha,OneParen)
- [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
- ] ] ] ] ] ] ]
-, Para [Str "Autonumbering:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Autonumber",Str "."] ]
- , [ Plain [Str "More",Str "."]
- , OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Nested",Str "."] ]
- ] ] ]
-, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
-, Para [Str "M.A.\160",Str "2007"]
-, Para [Str "B",Str ".",Space,Str "Williams"]
-, HorizontalRule
-, Header 1 [Str "Definition",Space,Str "Lists"]
-, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Plain [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Plain [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Plain [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Plain [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Plain [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Plain [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Loose:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Para [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
-, DefinitionList
- [ ([Emph [Str "apple"]],
- [ [ Para [Str "red",Space,Str "fruit"]
- , Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"] ]])
- , ([Emph [Str "orange"]],
- [ [ Para [Str "orange",Space,Str "fruit"]
- , CodeBlock ("",[],[]) "{ orange code block }"
- , BlockQuote
- [ Para [Str "orange",Space,Str "block",Space,Str "quote"] ]
- ]]) ]
-, Para [Str "Multiple",Space,Str "definitions,",Space,Str "tight:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Plain [Str "red",Space,Str "fruit"] ]
- , [ Plain [Str "computer"] ]
- ])
- , ([Str "orange"],
- [ [ Plain [Str "orange",Space,Str "fruit"] ]
- , [ Plain [Str "bank"] ]
- ]) ]
-, Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- , [ Para [Str "computer"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- , [ Para [Str "bank"] ]
- ]) ]
-, Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- , [ Para [Str "computer"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"]
- , OrderedList (1,Decimal,Period)
- [ [ Plain [Str "sublist"] ]
- , [ Plain [Str "sublist"] ] ] ]]) ]
-, Header 1 [Str "HTML",Space,Str "Blocks"]
-, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
-, RawHtml "<div>"
-, Plain [Str "foo"]
-, RawHtml "</div>\n"
-, Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
-, RawHtml "<div>\n<div>\n<div>"
-, Plain [Str "foo"]
-, RawHtml "</div>\n</div>\n<div>"
-, Plain [Str "bar"]
-, RawHtml "</div>\n</div>\n"
-, Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
-, RawHtml "<table>\n<tr>\n<td>"
-, Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
-, RawHtml "</td>\n<td>"
-, Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
-, RawHtml "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
-, RawHtml "<div>\n "
-, Plain [Str "foo"]
-, RawHtml "</div>\n"
-, Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
-, CodeBlock ("",[],[]) "<div>\n foo\n</div>"
-, Para [Str "As",Space,Str "should",Space,Str "this:"]
-, CodeBlock ("",[],[]) "<div>foo</div>"
-, Para [Str "Now,",Space,Str "nested:"]
-, RawHtml "<div>\n <div>\n <div>\n "
-, Plain [Str "foo"]
-, RawHtml "</div>\n </div>\n</div>\n"
-, Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
-, RawHtml "<!-- Comment -->\n"
-, Para [Str "Multiline:"]
-, RawHtml "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
-, Para [Str "Code",Space,Str "block:"]
-, CodeBlock ("",[],[]) "<!-- Comment -->"
-, Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
-, RawHtml "<!-- foo --> \n"
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "<hr />"
-, Para [Str "Hr",Apostrophe,Str "s:"]
-, RawHtml "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
-, HorizontalRule
-, Header 1 [Str "Inline",Space,Str "Markup"]
-, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
-, Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
-, Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
-, Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ">",Str ",",Space,Code "$",Str ",",Space,Code "\\",Str ",",Space,Code "\\$",Str ",",Space,Code "<html>",Str "."]
-, Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
-, Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Str "\160",Str "there"],Str "."]
-, Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many",Str "\160",Str "of",Str "\160",Str "them"],Str "O",Str "."]
-, Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."]
-, HorizontalRule
-, Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
-, Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name",Str "."]]
-, Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters",Str "."]
-, Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]]
-, Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str "."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Apostrophe,Str "s?"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
-, Para [Str "Some",Space,Str "dashes:",Space,Str "one",EmDash,Str "two",Space,EmDash,Space,Str "three",EmDash,Str "four",Space,EmDash,Space,Str "five",Str "."]
-, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999",Str "."]
-, Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."]
-, HorizontalRule
-, Header 1 [Str "LaTeX"]
-, BulletList
- [ [ Plain [TeX "\\cite[22-23]{smith.1899}"] ]
- , [ Plain [Math InlineMath "2+2=4"] ]
- , [ Plain [Math InlineMath "x \\in y"] ]
- , [ Plain [Math InlineMath "\\alpha \\wedge \\omega"] ]
- , [ Plain [Math InlineMath "223"] ]
- , [ Plain [Math InlineMath "p",Str "-",Str "Tree"] ]
- , [ Plain [Str "Here",Apostrophe,Str "s",Space,Str "some",Space,Str "display",Space,Str "math:",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"] ]
- , [ Plain [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."] ] ]
-, Para [Str "These",Space,Str "shouldn",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"]
-, BulletList
- [ [ Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code "$e = mc^2$",Str "."] ]
- , [ Plain [Str "$",Str "22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$",Str "34,000",Str ".",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized",Str ".",Str ")"] ]
- , [ Plain [Str "Shoes",Space,Str "(",Str "$",Str "20)",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5)",Str "."] ]
- , [ Plain [Str "Escaped",Space,Code "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
-, Para [TeX "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"]
-, HorizontalRule
-, Header 1 [Str "Special",Space,Str "Characters"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
-, BulletList
- [ [ Plain [Str "I",Space,Str "hat:",Space,Str "\206"] ]
- , [ Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"] ]
- , [ Plain [Str "section:",Space,Str "\167"] ]
- , [ Plain [Str "set",Space,Str "membership:",Space,Str "\8712"] ]
- , [ Plain [Str "copyright:",Space,Str "\169"] ] ]
-, Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
-, Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]
-, Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
-, Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
-, Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
-, Para [Str "Backslash:",Space,Str "\\"]
-, Para [Str "Backtick:",Space,Str "`"]
-, Para [Str "Asterisk:",Space,Str "*"]
-, Para [Str "Underscore:",Space,Str "_"]
-, Para [Str "Left",Space,Str "brace:",Space,Str "{"]
-, Para [Str "Right",Space,Str "brace:",Space,Str "}"]
-, Para [Str "Left",Space,Str "bracket:",Space,Str "["]
-, Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
-, Para [Str "Left",Space,Str "paren:",Space,Str "("]
-, Para [Str "Right",Space,Str "paren:",Space,Str ")"]
-, Para [Str "Greater",Str "-",Str "than:",Space,Str ">"]
-, Para [Str "Hash:",Space,Str "#"]
-, Para [Str "Period:",Space,Str "."]
-, Para [Str "Bang:",Space,Str "!"]
-, Para [Str "Plus:",Space,Str "+"]
-, Para [Str "Minus:",Space,Str "-"]
-, HorizontalRule
-, Header 1 [Str "Links"]
-, Header 2 [Str "Explicit"]
-, Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
-, Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]
-, Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
-, Para [Link [Str "Empty"] ("",""),Str "."]
-, Header 2 [Str "Reference"]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]
-, Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
-, Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
-, Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
-, CodeBlock ("",[],[]) "[not]: /url"
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
-, Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
-, Header 2 [Str "With",Space,Str "ampersands"]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
-, Header 2 [Str "Autolinks"]
-, Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Code "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
-, BulletList
- [ [ Plain [Str "In",Space,Str "a",Space,Str "list?"] ]
- , [ Plain [Link [Code "http://example.com/"] ("http://example.com/","")] ]
- , [ Plain [Str "It",Space,Str "should",Str "."] ] ]
-, Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Link [Code "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
-, BlockQuote
- [ Para [Str "Blockquoted:",Space,Link [Code "http://example.com/"] ("http://example.com/","")] ]
-
-, Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code "<http://example.com/>"]
-, CodeBlock ("",[],[]) "or here: <http://example.com/>"
-, HorizontalRule
-, Header 1 [Str "Images"]
-, Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
-, Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
-, HorizontalRule
-, Header 1 [Str "Footnotes"]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference",Str ".",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document",Str "."]],Space,Str "and",Space,Str "another",Str ".",Note [Para [Str "Here",Apostrophe,Str "s",Space,Str "the",Space,Str "long",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)",Str "."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block",Str "."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space",Str ".",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note",Str ".",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type",Str ".",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]
-, BlockQuote
- [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]] ]
-
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]] ]
- ]
-, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."] ]
+Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17",Str ",",Space,Str "2006"]})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+,HorizontalRule
+,Header 1 [Str "Headers"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 [Str "Level",Space,Str "4"]
+,Header 5 [Str "Level",Space,Str "5"]
+,Header 1 [Str "Level",Space,Str "1"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 [Str "Paragraphs"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here",Str "."]
+,HorizontalRule
+,Header 1 [Str "Block",Space,Str "Quotes"]
+,Para [Str "E",Str "-",Str "mail",Space,Str "style",Str ":"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list",Str ":"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
+,HorizontalRule
+,Header 1 [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code",Str ":"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And",Str ":"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 [Str "Lists"]
+,Header 2 [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 [Str "Ordered"]
+,Para [Str "Tight",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1",Str ",",Space,Str "graf",Space,Str "one",Str "."]
+ ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."]]
+ ,[Para [Str "Item",Space,Str "2",Str "."]]
+ ,[Para [Str "Item",Space,Str "3",Str "."]]]
+,Header 2 [Str "Nested"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "another",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second",Str ":"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second",Str ":"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals",Str ",",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting",Str ":"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Plain [Str "Upper",Space,Str "Roman",Str "."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering",Str ":"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber",Str "."]]
+ ,[Plain [Str "More",Str "."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested",Str "."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item",Str ":"]
+,Para [Str "M.A.\160",Str "2007"]
+,Para [Str "B",Str ".",Space,Str "Williams"]
+,HorizontalRule
+,Header 1 [Str "Definition",Space,Str "Lists"]
+,Para [Str "Tight",Space,Str "using",Space,Str "spaces",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Tight",Space,Str "using",Space,Str "tabs",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Loose",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics",Str ":"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds",Str ",",Space,Str "crisp",Str ",",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "tight",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]
+ ,[Plain [Str "computer"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]
+ ,[Plain [Str "bank"]]])]
+,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "loose",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]
+ ,[Para [Str "bank"]]])]
+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term",Str ",",Space,Str "indented",Space,Str "marker",Str ",",Space,Str "alternate",Space,Str "markers",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "sublist"]]
+ ,[Plain [Str "sublist"]]]]])]
+,Header 1 [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]
+,RawBlock "html" "<div>"
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n"
+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation",Str ":"]
+,RawBlock "html" "<div>\n<div>\n<div>"
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n</div>\n<div>"
+,Plain [Str "bar"]
+,RawBlock "html" "</div>\n</div>\n"
+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table",Str ":"]
+,RawBlock "html" "<table>\n<tr>\n<td>"
+,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
+,RawBlock "html" "</td>\n<td>"
+,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
+,RawBlock "html" "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block",Str ":"]
+,RawBlock "html" "<div>\n "
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n"
+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block",Str ",",Space,Str "though",Str ":"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this",Str ":"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now",Str ",",Space,Str "nested",Str ":"]
+,RawBlock "html" "<div>\n <div>\n <div>\n "
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n </div>\n</div>\n"
+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment",Str ":"]
+,RawBlock "html" "<!-- Comment -->\n"
+,Para [Str "Multiline",Str ":"]
+,RawBlock "html" "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
+,Para [Str "Code",Space,Str "block",Str ":"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment",Str ",",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line",Str ":"]
+,RawBlock "html" "<!-- foo --> \n"
+,Para [Str "Code",Str ":"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr",Apostrophe,Str "s",Str ":"]
+,RawBlock "html" "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
+,HorizontalRule
+,Header 1 [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Str "\160",Str "there"],Str "."]
+,Para [Str "Subscripts",Str ":",Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Str "\160",Str "of",Str "\160",Str "them"],Str "O",Str "."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts",Str ",",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces",Str ":",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d",Str ",",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."]
+,HorizontalRule
+,Header 1 [Str "Smart",Space,Str "quotes",Str ",",Space,Str "ellipses",Str ",",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello",Str ","],Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name",Str "."]]
+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters",Str "."]
+,Para [Quoted SingleQuote [Str "Oak",Str ","],Space,Quoted SingleQuote [Str "elm",Str ","],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]]
+,Para [Quoted SingleQuote [Str "He",Space,Str "said",Str ",",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str "."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Apostrophe,Str "s",Str "?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
+,Para [Str "Some",Space,Str "dashes",Str ":",Space,Str "one",EmDash,Str "two",Space,EmDash,Space,Str "three",EmDash,Str "four",Space,EmDash,Space,Str "five",Str "."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers",Str ":",Space,Str "5",EnDash,Str "7",Str ",",Space,Str "255",EnDash,Str "66",Str ",",Space,Str "1987",EnDash,Str "1999",Str "."]
+,Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."]
+,HorizontalRule
+,Header 1 [Str "LaTeX"]
+,BulletList
+ [[Plain [RawInline "tex" "\\cite[22-23]{smith.1899}"]]
+ ,[Plain [Math InlineMath "2+2=4"]]
+ ,[Plain [Math InlineMath "x \\in y"]]
+ ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]]
+ ,[Plain [Math InlineMath "223"]]
+ ,[Plain [Math InlineMath "p",Str "-",Str "Tree"]]
+ ,[Plain [Str "Here",Apostrophe,Str "s",Space,Str "some",Space,Str "display",Space,Str "math",Str ":",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]
+ ,[Plain [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it",Str ":",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]
+,Para [Str "These",Space,Str "shouldn",Apostrophe,Str "t",Space,Str "be",Space,Str "math",Str ":"]
+,BulletList
+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation",Str ",",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Plain [Str "$",Str "22",Str ",",Str "000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$",Str "34",Str ",",Str "000",Str ".",Space,Str "(",Str "It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]]
+ ,[Plain [Str "Shoes",Space,Str "(",Str "$",Str "20",Str ")",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5",Str ")",Str "."]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table",Str ":"]
+,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,HorizontalRule
+,Header 1 [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"]]
+ ,[Plain [Str "section",Str ":",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"]]
+ ,[Plain [Str "copyright",Str ":",Space,Str "\169"]]]
+,Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
+,Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]
+,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
+,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
+,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
+,Para [Str "Backslash",Str ":",Space,Str "\\"]
+,Para [Str "Backtick",Str ":",Space,Str "`"]
+,Para [Str "Asterisk",Str ":",Space,Str "*"]
+,Para [Str "Underscore",Str ":",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]
+,Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]
+,Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]
+,Para [Str "Hash",Str ":",Space,Str "#"]
+,Para [Str "Period",Str ":",Space,Str "."]
+,Para [Str "Bang",Str ":",Space,Str "!"]
+,Para [Str "Plus",Str ":",Space,Str "+"]
+,Para [Str "Minus",Str ":",Space,Str "-"]
+,HorizontalRule
+,Header 1 [Str "Links"]
+,Header 2 [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
+,Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]
+,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Link [Str "Empty"] ("",""),Str "."]
+,Header 2 [Str "Reference"]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]
+,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
+,Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
+,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
+,Header 2 [Str "With",Space,Str "ampersands"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Plain [Str "In",Space,Str "a",Space,Str "list",Str "?"]]
+ ,[Plain [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]
+ ,[Plain [Str "It",Space,Str "should",Str "."]]]
+,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address",Str ":",Space,Link [Code ("",["url"],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here",Str ":",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(",Str "1902",Str ")",Str ":"]
+,Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
+,HorizontalRule
+,Header 1 [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference",Str ".",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document",Str "."]],Space,Str "and",Space,Str "another",Str ".",Note [Para [Str "Here",Apostrophe,Str "s",Space,Str "the",Space,Str "long",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(",Str "as",Space,Str "with",Space,Str "list",Space,Str "items",Str ")",Str "."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want",Str ",",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line",Str ",",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block",Str "."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space",Str ".",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note",Str ".",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type",Str ".",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]]]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note",Str ",",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."]]
diff --git a/tests/testsuite.txt b/tests/testsuite.txt
index 7f6e89449..ccee0764a 100644
--- a/tests/testsuite.txt
+++ b/tests/testsuite.txt
@@ -431,21 +431,21 @@ Hr's:
<hr>
-<hr/>
+<hr />
<hr />
<hr>
-<hr/>
+<hr />
<hr />
<hr class="foo" id="bar" />
-<hr class="foo" id="bar"/>
+<hr class="foo" id="bar" />
-<hr class="foo" id="bar" >
+<hr class="foo" id="bar">
-----
@@ -496,7 +496,7 @@ Some dashes: one---two --- three--four -- five.
Dashes between numbers: 5-7, 255-66, 1987-1999.
-Ellipses...and. . .and . . . .
+Ellipses...and...and....
-----
@@ -631,7 +631,6 @@ Indented [thrice][].
This should [not][] be a link.
[once]: /url
-
[twice]: /url
[thrice]: /url
diff --git a/tests/textile-reader.native b/tests/textile-reader.native
new file mode 100644
index 000000000..8c276d194
--- /dev/null
+++ b/tests/textile-reader.native
@@ -0,0 +1,148 @@
+Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Space,Str "Textile",Space,Str "Reader",Str ".",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+,HorizontalRule
+,Header 1 [Str "Headers"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embeded",Space,Str "link"] ("http://www.example.com","")]
+,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Strong [Str "emphasis"]]
+,Header 4 [Str "Level",Space,Str "4"]
+,Header 5 [Str "Level",Space,Str "5"]
+,Header 6 [Str "Level",Space,Str "6"]
+,Header 1 [Str "Paragraphs"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
+,Para [Str "Line",Space,Str "breaks",Space,Str "are",Space,Str "preserved",Space,Str "in",Space,Str "textile",Str ",",Space,Str "so",Space,Str "you",Space,Str "can",Space,Str "not",Space,Str "wrap",Space,Str "your",Space,Str "very",LineBreak,Str "long",Space,Str "paragraph",Space,Str "with",Space,Str "your",Space,Str "favourite",Space,Str "text",Space,Str "editor",Space,Str "and",Space,Str "have",Space,Str "it",Space,Str "rendered",LineBreak,Str "with",Space,Str "no",Space,Str "break",Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str "."]
+,BulletList
+ [[Plain [Str "criminey",Str "."]]]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "paragraph",Space,Str "break",Space,Str "between",Space,Str "here"]
+,Para [Str "and",Space,Str "here",Str "."]
+,Para [Str "pandoc",Space,Str "converts",Space,Str "textile",Str "."]
+,Header 1 [Str "Block",Space,Str "Quotes"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "famous",Space,Str "quote",Space,Str "from",Space,Str "somebody",Str ".",Space,Str "He",Space,Str "had",Space,Str "a",Space,Str "lot",Space,Str "of",Space,Str "things",Space,Str "to",LineBreak,Str "say",Str ",",Space,Str "so",Space,Str "the",Space,Str "text",Space,Str "is",Space,Str "really",Space,Str "really",Space,Str "long",Space,Str "and",Space,Str "spans",Space,Str "on",Space,Str "multiple",Space,Str "lines",Str "."]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
+,Header 1 [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code",Str ":"]
+,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab"
+,Para [Str "And",Str ":"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\\n"
+,Para [Str "Inline",Space,Str "code",Str ":",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."]
+,Header 1 [Str "Lists"]
+,Header 2 [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Header 2 [Str "Ordered"]
+,Para [Str "Tight",Str ":"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Header 2 [Str "Nested"]
+,BulletList
+ [[Plain [Str "ui",Space,Str "1"]
+ ,BulletList
+ [[Plain [Str "ui",Space,Str "1",Str ".",Str "1"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "oi",Space,Str "1",Str ".",Str "1",Str ".",Str "1"]]
+ ,[Plain [Str "oi",Space,Str "1",Str ".",Str "1",Str ".",Str "2"]]]]
+ ,[Plain [Str "ui",Space,Str "1",Str ".",Str "2"]]]]
+ ,[Plain [Str "ui",Space,Str "2"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "oi",Space,Str "2",Str ".",Str "1"]
+ ,BulletList
+ [[Plain [Str "ui",Space,Str "2",Str ".",Str "1",Str ".",Str "1"]]
+ ,[Plain [Str "ui",Space,Str "2",Str ".",Str "1",Str ".",Str "2"]]]]]]]
+,Header 2 [Str "Definition",Space,Str "List"]
+,DefinitionList
+ [([Str "coffee"],
+ [[Plain [Str "Hot",Space,Str "and",Space,Str "black"]]])
+ ,([Str "tea"],
+ [[Plain [Str "Also",Space,Str "hot",Str ",",Space,Str "but",Space,Str "a",Space,Str "little",Space,Str "less",Space,Str "black"]]])
+ ,([Str "milk"],
+ [[Para [Str "Nourishing",Space,Str "beverage",Space,Str "for",Space,Str "baby",Space,Str "cows",Str "."]
+ ,Para [Str "Cold",Space,Str "drink",Space,Str "that",Space,Str "goes",Space,Str "great",Space,Str "with",Space,Str "cookies",Str "."]]])
+ ,([Str "beer"],
+ [[Plain [Str "fresh",Space,Str "and",Space,Str "bitter"]]])]
+,Header 1 [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str ".",LineBreak,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str ".",LineBreak,Str "A",Space,Link [Strong [Str "strong",Space,Str "link"]] ("http://www.foobar.com",""),Str "."]
+,Para [Emph [Strong [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]],LineBreak,Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Space,Str "and",Space,Emph [Strong [Str "that",Space,Str "one"]],Str ".",LineBreak,Strikeout [Str "This",Space,Str "is",Space,Str "strikeout",Space,Str "and",Space,Strong [Str "strong"]]]
+,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Strong [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str ".",LineBreak,Str "Subscripts",Str ":",Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O",Str "."]
+,Para [Str "Dashes",Space,Str ":",Space,Str "How",Space,Str "cool",Space,EmDash,Space,Str "automatic",Space,Str "dashes",Str "."]
+,Para [Str "Elipses",Space,Str ":",Space,Str "He",Space,Str "thought",Space,Str "and",Space,Str "thought",Space,Ellipses,Space,Str "and",Space,Str "then",Space,Str "thought",Space,Str "some",Space,Str "more",Str "."]
+,Para [Str "Quotes",Space,Str "and",Space,Str "apostrophes",Space,Str ":",Space,Quoted DoubleQuote [Str "I",Apostrophe,Str "d",Space,Str "like",Space,Str "to",Space,Str "thank",Space,Str "you"],Space,Str "for",Space,Str "example",Str "."]
+,Header 1 [Str "Links"]
+,Header 2 [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link [Str "url"] ("http://www.url.com","")]
+,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link [Str "http://www.example.com"] ("http://www.example.com",""),Space,Str "and",Space,Link [Str "foobar@example.com"] ("mailto:foobar@example.com",""),Str "."]
+,Header 1 [Str "Tables"]
+,Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"]
+,Header 2 [Str "Without",Space,Str "headers"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "name"]]
+ ,[Plain [Str "age"]]
+ ,[Plain [Str "sex"]]]
+ ,[[Plain [Str "joan"]]
+ ,[Plain [Str "24"]]
+ ,[Plain [Str "f"]]]
+ ,[[Plain [Str "archie"]]
+ ,[Plain [Str "29"]]
+ ,[Plain [Str "m"]]]
+ ,[[Plain [Str "bella"]]
+ ,[Plain [Str "45"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Ellipses]
+,Header 2 [Str "With",Space,Str "headers"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "name"]]
+ ,[Plain [Str "age"]]
+ ,[Plain [Str "sex"]]]
+ [[[Plain [Str "joan"]]
+ ,[Plain [Str "24"]]
+ ,[Plain [Str "f"]]]
+ ,[[Plain [Str "archie"]]
+ ,[Plain [Str "29"]]
+ ,[Plain [Str "m"]]]
+ ,[[Plain [Str "bella"]]
+ ,[Plain [Str "45"]]
+ ,[Plain [Str "f"]]]]
+,Header 1 [Str "Images"]
+,Para [Str "Textile",Space,Str "inline",Space,Str "image",Space,Str "syntax",Str ",",Space,Str "like",Space,LineBreak,Str "here",Space,Image [Str "this is the alt text"] ("this_is_an_image.png","this is the alt text"),LineBreak,Str "and",Space,Str "here",Space,Image [Str ""] ("this_is_an_image.png",""),Str "."]
+,Header 1 [Str "Attributes"]
+,Header 2 [Str "HTML",Space,Str "and",Space,Str "CSS",Space,Str "attributes",Space,Str "are",Space,Str "ignored"]
+,Para [Str "as",Space,Str "well",Space,Str "as",Space,Strong [Str "inline",Space,Str "attributes"],Space,Str "of",Space,Str " all kind"]
+,Para [Str "and",Space,Str "paragraph",Space,Str "attributes",Str ",",Space,Str "and",Space,Str "table",Space,Str "attributes",Str "."]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "name"]]
+ ,[Plain [Str "age"]]
+ ,[Plain [Str "sex"]]]
+ ,[[Plain [Str "joan"]]
+ ,[Plain [Str "24"]]
+ ,[Plain [Str "f"]]]]
+,Header 1 [Str "Raw",Space,Str "HTML"]
+,Para [Str "However",Str ",",Space,RawInline "html" "<strong>",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline "html" "</strong>",Space,Str "are",Space,Str "accepted",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"]
+,RawBlock "html" "<div class=\"foobar\">"
+,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold",LineBreak]
+,RawBlock "html" "</div>"
+,Para [Str "Html",Space,Str "blocks",Space,Str "can",Space,Str "be"]
+,RawBlock "html" "<div>"
+,Para [Str "inlined"]
+,RawBlock "html" "</div>"
+,Para [Str "as",Space,Str "well",Str "."]
+,BulletList
+ [[Plain [Str "this",Space,Str "<",Str "div",Str ">",Space,Str "won",Apostrophe,Str "t",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,Str "<",Str "/div",Str ">"]]
+ ,[Plain [Str "but",Space,Str "this",Space,RawInline "html" "<strong>",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline "html" "</strong>"]]]
+,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"]
+,Header 1 [Str "Acronyms",Space,Str "and",Space,Str "marks"]
+,Para [Str "PBS",Space,Str "(",Str "Public",Space,Str "Broadcasting",Space,Str "System",Str ")"]
+,Para [Str "Hi",Str "\8482"]
+,Para [Str "Hi",Space,Str "\8482"]
+,Para [Str "\174",Space,Str "Hi",Str "\174"]
+,Para [Str "Hi",Str "\169",Str "2008",Space,Str "\169",Space,Str "2008"]
+,Header 1 [Str "Footnotes"]
+,Para [Str "A",Space,Str "note",Str ".",Note [Para [Str "The",Space,Str "note",LineBreak,Str "is",Space,Str "here",Str "!"]]]]
diff --git a/tests/textile-reader.textile b/tests/textile-reader.textile
new file mode 100644
index 000000000..9c9980307
--- /dev/null
+++ b/tests/textile-reader.textile
@@ -0,0 +1,216 @@
+This is a set of tests for pandoc Textile Reader. Part of it comes
+from John Gruber's markdown test suite.
+
+-----
+
+h1. Headers
+
+h2. Level 2 with an "embeded link":http://www.example.com
+
+h3. Level 3 with *emphasis*
+
+h4. Level 4
+
+h5. Level 5
+
+h6. Level 6
+
+
+h1. Paragraphs
+
+Here's a regular paragraph.
+
+Line breaks are preserved in textile, so you can not wrap your very
+long paragraph with your favourite text editor and have it rendered
+with no break.
+
+
+Here's one with a bullet.
+
+* criminey.
+
+There should be a paragraph break between here
+
+and here.
+
+pandoc converts textile.
+
+h1. Block Quotes
+
+bq. This is a famous quote from somebody. He had a lot of things to
+say, so the text is really really long and spans on multiple lines.
+
+And a following paragraph.
+
+h1. Code Blocks
+
+Code:
+
+<pre>
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+</pre>
+
+And:
+
+<pre>
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+</pre>
+
+bc. Code block with .bc
+ continued
+ @</\
+
+Inline code: @<tt>@, <tt>@</tt>.
+
+h1. Lists
+
+h2. Unordered
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+h2. Ordered
+
+Tight:
+
+# First
+# Second
+# Third
+
+h2. Nested
+
+* ui 1
+** ui 1.1
+### oi 1.1.1
+### oi 1.1.2
+** ui 1.2
+* ui 2
+## oi 2.1
+*** ui 2.1.1
+*** ui 2.1.2
+
+h2. Definition List
+
+- coffee := Hot and black
+- tea := Also hot, but a little less black
+- milk :=
+Nourishing beverage for baby cows.
+
+Cold drink that goes great with cookies.=:
+- beer := fresh and bitter
+
+
+h1. Inline Markup
+
+This is _emphasized_, and so __is this__.
+This is *strong*, and so **is this**.
+A "*strong link*":http://www.foobar.com.
+
+_*This is strong and em.*_
+So is *_this_* word and __**that one**__.
+-This is strikeout and *strong*-
+
+Superscripts: a^bc^d a^*hello*^ a^hello there^.
+Subscripts: H~2~O, H~23~O, H~many of them~O.
+
+Dashes : How cool -- automatic dashes.
+
+Elipses : He thought and thought ... and then thought some more.
+
+Quotes and apostrophes : "I'd like to thank you" for example.
+
+
+h1. Links
+
+h2. Explicit
+
+Just a "url":http://www.url.com
+
+"Email link":mailto:nobody@nowhere.net
+
+Automatic linking to http://www.example.com and foobar@example.com.
+
+h1. Tables
+
+Textile allows tables with and without headers :
+
+h2. Without headers
+
+| name | age | sex |
+| joan | 24 | f |
+| archie | 29 | m |
+| bella | 45 | f |
+
+and some text following ...
+
+h2. With headers
+
+|_. name |_. age |_. sex |
+| joan | 24 | f |
+| archie | 29 | m |
+| bella | 45 | f |
+
+
+
+h1. Images
+
+Textile inline image syntax, like
+here !this_is_an_image.png(this is the alt text)!
+and here !this_is_an_image.png!.
+
+h1. Attributes
+
+h2{color:red}. HTML and CSS attributes are ignored
+
+as well as *(foo)inline attributes* of %{color:red} all kind%
+
+p{color:green}. and paragraph attributes, and table attributes.
+
+table{foo:bar}.
+| name | age | sex |
+| joan | 24 | f |
+
+h1. Raw HTML
+
+However, <strong> raw HTML inlines </strong> are accepted, as well as :
+
+<div class="foobar">
+ any *Raw HTML Block* with bold
+</div>
+
+Html blocks can be <div>inlined</div> as well.
+
+* this <div> won't produce raw html blocks </div>
+* but this <strong> will produce inline html </strong>
+
+Can you prove that 2 < 3 ?
+
+h1. Acronyms and marks
+
+PBS(Public Broadcasting System)
+
+Hi(tm)
+
+Hi (TM)
+
+(r) Hi(r)
+
+Hi(c)2008 (C) 2008
+
+h1. Footnotes
+
+A note.[1]
+
+fn1. The note
+is here!
diff --git a/tests/writer.context b/tests/writer.context
index 2c53fde5c..f9fb03cef 100644
--- a/tests/writer.context
+++ b/tests/writer.context
@@ -61,8 +61,8 @@ after={\blank[medium]},
\blank[3*medium]
\stopalignment
-This is a set of tests for pandoc. Most of them are adapted from
-John Gruber's markdown test suite.
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
\thinrule
@@ -94,9 +94,9 @@ with no blank line
Here's a regular paragraph.
-In Markdown 1.0.0 and earlier. Version 8. This line turns into a
-list item. Because a hard-wrapped line in the middle of a paragraph
-looked like a list item.
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
Here's one with a bullet. * criminey.
@@ -293,9 +293,8 @@ Multiple paragraphs:
\startitemize[n][stopper=.]
\item
Item 1, graf one.
-
- Item 1. graf two. The quick brown fox jumped over the lazy dog's
- back.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
\item
Item 2.
\item
@@ -343,7 +342,7 @@ Same thing but with paragraphs:
First
\item
Second:
-
+
\startitemize
\item
Fee
@@ -363,7 +362,7 @@ Same thing but with paragraphs:
this is a list item indented with tabs
\item
this is a list item indented with spaces
-
+
\startitemize
\item
this is an example list item indented with tabs
@@ -379,9 +378,9 @@ Same thing but with paragraphs:
begins with 2
\item
and now 3
-
+
with a continuation
-
+
\startitemize[r][start=4,stopper=.,width=2.0em]
\item
sublist with roman numerals, starting with 4
@@ -441,110 +440,110 @@ B. Williams
Tight using spaces:
\startdescr{apple}
-red fruit
+ red fruit
\stopdescr
\startdescr{orange}
-orange fruit
+ orange fruit
\stopdescr
\startdescr{banana}
-yellow fruit
+ yellow fruit
\stopdescr
Tight using tabs:
\startdescr{apple}
-red fruit
+ red fruit
\stopdescr
\startdescr{orange}
-orange fruit
+ orange fruit
\stopdescr
\startdescr{banana}
-yellow fruit
+ yellow fruit
\stopdescr
Loose:
\startdescr{apple}
-red fruit
+ red fruit
\stopdescr
\startdescr{orange}
-orange fruit
+ orange fruit
\stopdescr
\startdescr{banana}
-yellow fruit
+ yellow fruit
\stopdescr
Multiple blocks with italics:
\startdescr{{\em apple}}
-red fruit
+ red fruit
-contains seeds, crisp, pleasant to taste
+ contains seeds, crisp, pleasant to taste
\stopdescr
\startdescr{{\em orange}}
-orange fruit
+ orange fruit
-\starttyping
+ \starttyping
{ orange code block }
-\stoptyping
+ \stoptyping
-\startblockquote
-orange block quote
-\stopblockquote
+ \startblockquote
+ orange block quote
+ \stopblockquote
\stopdescr
Multiple definitions, tight:
\startdescr{apple}
-red fruit
+ red fruit
-computer
+ computer
\stopdescr
\startdescr{orange}
-orange fruit
+ orange fruit
-bank
+ bank
\stopdescr
Multiple definitions, loose:
\startdescr{apple}
-red fruit
+ red fruit
-computer
+ computer
\stopdescr
\startdescr{orange}
-orange fruit
+ orange fruit
-bank
+ bank
\stopdescr
Blank line after term, indented marker, alternate markers:
\startdescr{apple}
-red fruit
+ red fruit
-computer
+ computer
\stopdescr
\startdescr{orange}
-orange fruit
+ orange fruit
-\startitemize[n][stopper=.]
-\item
- sublist
-\item
- sublist
-\stopitemize
+ \startitemize[n][stopper=.]
+ \item
+ sublist
+ \item
+ sublist
+ \stopitemize
\stopdescr
\subject{HTML Blocks}
@@ -618,8 +617,7 @@ So is {\bf {\em this}} word.
So is {\bf {\em this}} word.
-This is code: \type{>}, \type{$}, \type{\}, \type{\$},
-\type{<html>}.
+This is code: \type{>}, \type{$}, \type{\}, \type{\$}, \type{<html>}.
\overstrikes{This is {\em strikeout}.}
@@ -627,27 +625,25 @@ Superscripts: a\high{bc}d a\high{{\em hello}} a\high{hello~there}.
Subscripts: H\low{2}O, H\low{23}O, H\low{many~of~them}O.
-These should not be superscripts or subscripts, because of the
-unescaped spaces: a\letterhat{}b c\letterhat{}d, a\lettertilde{}b
-c\lettertilde{}d.
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\letterhat{}b c\letterhat{}d, a\lettertilde{}b c\lettertilde{}d.
\thinrule
\subject{Smart quotes, ellipses, dashes}
-\quotation{Hello,} said the spider.
-\quotation{\quote{Shelob} is my name.}
+\quotation{Hello,} said the spider. \quotation{\quote{Shelob} is my name.}
\quote{A}, \quote{B}, and \quote{C} are letters.
-\quote{Oak,} \quote{elm,} and \quote{beech} are names of trees. So
-is \quote{pine.}
+\quote{Oak,} \quote{elm,} and \quote{beech} are names of trees. So is
+\quote{pine.}
-\quote{He said, \quotation{I want to go.}} Were you alive in the
-70's?
+\quote{He said, \quotation{I want to go.}} Were you alive in the 70's?
Here is some quoted \quote{\type{code}} and a
-\quotation{\useURL[3][http://example.com/?foo=1&bar=2][][quoted link]\from[3]}.
+\quotation{\useURL[3][http://example.com/?foo=1&bar=2][][quoted
+link]\from[3]}.
Some dashes: one---two --- three---four --- five.
@@ -676,8 +672,7 @@ Ellipses\ldots{}and\ldots{}and\ldots{}.
Here's some display math:
\startformula \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h} \stopformula
\item
- Here's one that has a line break in it:
- $\alpha + \omega \times x^2$.
+ Here's one that has a line break in it: $\alpha + \omega \times x^2$.
\stopitemize
These shouldn't be math:
@@ -696,12 +691,6 @@ These shouldn't be math:
Here's a LaTeX table:
-\begin{tabular}{|l|l|}\hline
-Animal & Number \\ \hline
-Dog & 2 \\
-Cat & 1 \\ \hline
-\end{tabular}
-
\thinrule
\subject{Special Characters}
@@ -743,9 +732,9 @@ Left brace: \letteropenbrace{}
Right brace: \letterclosebrace{}
-Left bracket: [
+Left bracket: {[}
-Right bracket: ]
+Right bracket: {]}
Left paren: (
@@ -795,7 +784,7 @@ Foo \useURL[14][/url/][][bar]\from[14].
Foo \useURL[15][/url/][][bar]\from[15].
-With \useURL[16][/url/][][embedded [brackets]]\from[16].
+With \useURL[16][/url/][][embedded {[}brackets{]}]\from[16].
\useURL[17][/url/][][b]\from[17] by itself should be a link.
@@ -805,7 +794,7 @@ Indented \useURL[19][/url][][twice]\from[19].
Indented \useURL[20][/url][][thrice]\from[20].
-This should [not][] be a link.
+This should {[}not{]}{[}{]} be a link.
\starttyping
[not]: /url
@@ -817,16 +806,16 @@ Foo \useURL[22][/url/][][biz]\from[22].
\subsubject{With ampersands}
-Here's a
-\useURL[23][http://example.com/?foo=1&bar=2][][link with an ampersand in the URL]\from[23].
+Here's a \useURL[23][http://example.com/?foo=1&bar=2][][link with an ampersand
+in the URL]\from[23].
Here's a link with an amersand in the link text:
\useURL[24][http://att.com/][][AT\&T]\from[24].
Here's an \useURL[25][/script?foo=1&bar=2][][inline link]\from[25].
-Here's an
-\useURL[26][/script?foo=1&bar=2][][inline link in pointy braces]\from[26].
+Here's an \useURL[26][/script?foo=1&bar=2][][inline link in pointy
+braces]\from[26].
\subsubject{Autolinks}
@@ -846,8 +835,7 @@ An e-mail address:
\useURL[29][mailto:nobody@nowhere.net][][nobody@nowhere.net]\from[29]
\startblockquote
-Blockquoted:
-\useURL[30][http://example.com/][][http://example.com/]\from[30]
+Blockquoted: \useURL[30][http://example.com/][][http://example.com/]\from[30]
\stopblockquote
Auto-links should not occur here: \type{<http://example.com/>}
@@ -870,39 +858,34 @@ Here is a movie {\externalfigure[movie.jpg]} icon.
\subject{Footnotes}
-Here is a footnote reference,
-\footnote{Here is the footnote. It can go anywhere after the footnote
-reference. It need not be placed at the end of the document.}
-and another.
-\footnote{Here's the long note. This one contains multiple blocks.
+Here is a footnote reference,\footnote{Here is the footnote. It can go
+ anywhere after the footnote reference. It need not be placed at the end of
+ the document.} and another.\footnote{Here's the long note. This one contains
+ multiple blocks.
-Subsequent blocks are indented to show that they belong to the
-footnote (as with list items).
+ Subsequent blocks are indented to show that they belong to the footnote (as
+ with list items).
-\starttyping
+ \starttyping
{ <code> }
-\stoptyping
+ \stoptyping
-If you want, you can indent every line, but you can also be lazy
-and just indent the first line of each block.}
-This should {\em not} be a footnote reference, because it contains
-a space.[\letterhat{}my note] Here is an inline note.
-\footnote{This is {\em easier} to type. Inline notes may contain
-\useURL[31][http://google.com][][links]\from[31] and \type{]}
-verbatim characters, as well as [bracketed text].}
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.} This should {\em not} be a footnote
+reference, because it contains a space.{[}\letterhat{}my note{]} Here is an
+inline note.\footnote{This is {\em easier} to type. Inline notes may contain
+ \useURL[31][http://google.com][][links]\from[31] and \type{]} verbatim
+ characters, as well as {[}bracketed text{]}.}
\startblockquote
-Notes can go in quotes.
-\footnote{In quote.}
+Notes can go in quotes.\footnote{In quote.}
\stopblockquote
\startitemize[n][stopper=.]
\item
- And in list items.
- \footnote{In list.}
+ And in list items.\footnote{In list.}
\stopitemize
-This paragraph should not be part of the note, as it is not
-indented.
+This paragraph should not be part of the note, as it is not indented.
\stoptext
diff --git a/tests/writer.docbook b/tests/writer.docbook
index c17513cf9..e7e948288 100644
--- a/tests/writer.docbook
+++ b/tests/writer.docbook
@@ -15,14 +15,13 @@
<date>July 17, 2006</date>
</articleinfo>
<para>
- This is a set of tests for pandoc. Most of them are adapted from
- John Gruber's markdown test suite.
+ This is a set of tests for pandoc. Most of them are adapted from John
+ Gruber's markdown test suite.
</para>
<section id="headers">
<title>Headers</title>
<section id="level-2-with-an-embedded-link">
- <title>Level 2 with an
- <ulink url="/url">embedded link</ulink></title>
+ <title>Level 2 with an <ulink url="/url">embedded link</ulink></title>
<section id="level-3-with-emphasis">
<title>Level 3 with <emphasis>emphasis</emphasis></title>
<section id="level-4">
@@ -60,16 +59,15 @@
Here's a regular paragraph.
</para>
<para>
- In Markdown 1.0.0 and earlier. Version 8. This line turns into a
- list item. Because a hard-wrapped line in the middle of a paragraph
- looked like a list item.
+ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list
+ item. Because a hard-wrapped line in the middle of a paragraph looked like
+ a list item.
</para>
<para>
Here's one with a bullet. * criminey.
</para>
<para>
- There should be a hard line
- break<literallayout></literallayout>here.
+ There should be a hard line break<literallayout></literallayout>here.
</para>
</section>
<section id="block-quotes">
@@ -866,45 +864,41 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<div>
foo
</div>
-
<para>
And nested without indentation:
</para>
<div>
-<div>
-<div>
+ <div>
+ <div>
foo
</div>
-</div>
-<div>
+ </div>
+ <div>
bar
</div>
-</div>
-
+ </div>
<para>
Interpreted markdown in a table:
</para>
<table>
-<tr>
-<td>
+ <tr>
+ <td>
This is <emphasis>emphasized</emphasis>
</td>
-<td>
+ <td>
And this is <emphasis role="strong">strong</emphasis>
</td>
-</tr>
-</table>
-
-<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+ </tr>
+ </table>
+ <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
<para>
Here's a simple block:
</para>
<div>
-
+
foo
</div>
-
<para>
This should be a code block, though:
</para>
@@ -923,31 +917,28 @@ These should not be escaped: \$ \\ \&gt; \[ \{
Now, nested:
</para>
<div>
- <div>
- <div>
-
+ <div>
+ <div>
+
foo
</div>
- </div>
-</div>
-
+ </div>
+ </div>
<para>
This should just be an HTML comment:
</para>
<!-- Comment -->
-
<para>
Multiline:
</para>
<!--
-Blah
-Blah
--->
-
-<!--
- This is another comment.
--->
+ Blah
+ Blah
+ -->
+ <!--
+ This is another comment.
+ -->
<para>
Code block:
</para>
@@ -958,7 +949,6 @@ Blah
Just plain comment, with trailing spaces on the line:
</para>
<!-- foo -->
-
<para>
Code:
</para>
@@ -970,28 +960,27 @@ Blah
</para>
<hr>
-<hr />
-
-<hr />
+ <hr />
-<hr>
+ <hr />
-<hr />
+ <hr>
-<hr />
+ <hr />
-<hr class="foo" id="bar" />
+ <hr />
-<hr class="foo" id="bar" />
+ <hr class="foo" id="bar" />
-<hr class="foo" id="bar">
+ <hr class="foo" id="bar" />
+ <hr class="foo" id="bar">
</section>
<section id="inline-markup">
<title>Inline Markup</title>
<para>
- This is <emphasis>emphasized</emphasis>, and so
- <emphasis>is this</emphasis>.
+ This is <emphasis>emphasized</emphasis>, and so <emphasis>is
+ this</emphasis>.
</para>
<para>
This is <emphasis role="strong">strong</emphasis>, and so
@@ -1001,18 +990,18 @@ Blah
An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>.
</para>
<para>
- <emphasis role="strong"><emphasis>This is strong and em.</emphasis></emphasis>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
</para>
<para>
- So is <emphasis role="strong"><emphasis>this</emphasis></emphasis>
- word.
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
</para>
<para>
- <emphasis role="strong"><emphasis>This is strong and em.</emphasis></emphasis>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
</para>
<para>
- So is <emphasis role="strong"><emphasis>this</emphasis></emphasis>
- word.
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
</para>
<para>
This is code: <literal>&gt;</literal>, <literal>$</literal>,
@@ -1020,7 +1009,8 @@ Blah
<literal>&lt;html&gt;</literal>.
</para>
<para>
- <emphasis role="strikethrough">This is <emphasis>strikeout</emphasis>.</emphasis>
+ <emphasis role="strikethrough">This is
+ <emphasis>strikeout</emphasis>.</emphasis>
</para>
<para>
Superscripts: a<superscript>bc</superscript>d
@@ -1028,35 +1018,35 @@ Blah
a<superscript>hello there</superscript>.
</para>
<para>
- Subscripts: H<subscript>2</subscript>O,
- H<subscript>23</subscript>O, H<subscript>many of them</subscript>O.
+ Subscripts: H<subscript>2</subscript>O, H<subscript>23</subscript>O,
+ H<subscript>many of them</subscript>O.
</para>
<para>
- These should not be superscripts or subscripts, because of the
- unescaped spaces: a^b c^d, a~b c~d.
+ These should not be superscripts or subscripts, because of the unescaped
+ spaces: a^b c^d, a~b c~d.
</para>
</section>
<section id="smart-quotes-ellipses-dashes">
<title>Smart quotes, ellipses, dashes</title>
<para>
- <quote>Hello,</quote> said the spider.
- <quote><quote>Shelob</quote> is my name.</quote>
+ <quote>Hello,</quote> said the spider. <quote><quote>Shelob</quote> is my
+ name.</quote>
</para>
<para>
- <quote>A</quote>, <quote>B</quote>, and <quote>C</quote> are
- letters.
+ <quote>A</quote>, <quote>B</quote>, and <quote>C</quote> are letters.
</para>
<para>
- <quote>Oak,</quote> <quote>elm,</quote> and <quote>beech</quote>
- are names of trees. So is <quote>pine.</quote>
+ <quote>Oak,</quote> <quote>elm,</quote> and <quote>beech</quote> are names
+ of trees. So is <quote>pine.</quote>
</para>
<para>
- <quote>He said, <quote>I want to go.</quote></quote> Were you alive
- in the 70's?
+ <quote>He said, <quote>I want to go.</quote></quote> Were you alive in the
+ 70's?
</para>
<para>
Here is some quoted <quote><literal>code</literal></quote> and a
- <quote><ulink url="http://example.com/?foo=1&amp;bar=2">quoted link</ulink></quote>.
+ <quote><ulink url="http://example.com/?foo=1&amp;bar=2">quoted
+ link</ulink></quote>.
</para>
<para>
Some dashes: one—two — three—four — five.
@@ -1135,16 +1125,14 @@ Blah
</listitem>
<listitem>
<para>
- Escaped <literal>$</literal>: $73
- <emphasis>this should be emphasized</emphasis> 23$.
+ Escaped <literal>$</literal>: $73 <emphasis>this should be
+ emphasized</emphasis> 23$.
</para>
</listitem>
</itemizedlist>
<para>
Here's a LaTeX table:
</para>
- <para>
- </para>
</section>
<section id="special-characters">
<title>Special Characters</title>
@@ -1316,8 +1304,8 @@ Blah
<section id="with-ampersands">
<title>With ampersands</title>
<para>
- Here's a
- <ulink url="http://example.com/?foo=1&amp;bar=2">link with an ampersand in the URL</ulink>.
+ Here's a <ulink url="http://example.com/?foo=1&amp;bar=2">link with an
+ ampersand in the URL</ulink>.
</para>
<para>
Here's a link with an amersand in the link text:
@@ -1327,8 +1315,8 @@ Blah
Here's an <ulink url="/script?foo=1&amp;bar=2">inline link</ulink>.
</para>
<para>
- Here's an
- <ulink url="/script?foo=1&amp;bar=2">inline link in pointy braces</ulink>.
+ Here's an <ulink url="/script?foo=1&amp;bar=2">inline link in pointy
+ braces</ulink>.
</para>
</section>
<section id="autolinks">
@@ -1387,78 +1375,67 @@ or here: &lt;http://example.com/&gt;
</mediaobject>
</figure>
<para>
- Here is a movie
- <inlinemediaobject>
+ Here is a movie <inlinemediaobject>
<imageobject>
<imagedata fileref="movie.jpg" />
</imageobject>
- </inlinemediaobject>
- icon.
+ </inlinemediaobject> icon.
</para>
</section>
<section id="footnotes">
<title>Footnotes</title>
<para>
- Here is a footnote
- reference,<footnote>
- <para>
- Here is the footnote. It can go anywhere after the footnote
- reference. It need not be placed at the end of the document.
- </para>
- </footnote>
- and
- another.<footnote>
- <para>
- Here's the long note. This one contains multiple blocks.
- </para>
- <para>
- Subsequent blocks are indented to show that they belong to the
- footnote (as with list items).
- </para>
- <screen>
+ Here is a footnote reference,<footnote>
+ <para>
+ Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
+ </para>
+ </footnote> and another.<footnote>
+ <para>
+ Here's the long note. This one contains multiple blocks.
+ </para>
+ <para>
+ Subsequent blocks are indented to show that they belong to the
+ footnote (as with list items).
+ </para>
+ <screen>
{ &lt;code&gt; }
</screen>
- <para>
- If you want, you can indent every line, but you can also be lazy
- and just indent the first line of each block.
- </para>
- </footnote>
- This should <emphasis>not</emphasis> be a footnote reference,
- because it contains a space.[^my note] Here is an inline
- note.<footnote>
- <para>
- This is <emphasis>easier</emphasis> to type. Inline notes may
- contain <ulink url="http://google.com">links</ulink> and
- <literal>]</literal> verbatim characters, as well as [bracketed
- text].
- </para>
- </footnote>
+ <para>
+ If you want, you can indent every line, but you can also be lazy and
+ just indent the first line of each block.
+ </para>
+ </footnote> This should <emphasis>not</emphasis> be a footnote reference,
+ because it contains a space.[^my note] Here is an inline note.<footnote>
+ <para>
+ This is <emphasis>easier</emphasis> to type. Inline notes may contain
+ <ulink url="http://google.com">links</ulink> and <literal>]</literal>
+ verbatim characters, as well as [bracketed text].
+ </para>
+ </footnote>
</para>
<blockquote>
<para>
- Notes can go in
- quotes.<footnote>
- <para>
- In quote.
- </para>
- </footnote>
+ Notes can go in quotes.<footnote>
+ <para>
+ In quote.
+ </para>
+ </footnote>
</para>
</blockquote>
<orderedlist numeration="arabic">
<listitem>
<para>
- And in list
- items.<footnote>
- <para>
- In list.
- </para>
- </footnote>
+ And in list items.<footnote>
+ <para>
+ In list.
+ </para>
+ </footnote>
</para>
</listitem>
</orderedlist>
<para>
- This paragraph should not be part of the note, as it is not
- indented.
+ This paragraph should not be part of the note, as it is not indented.
</para>
</section>
</article>
diff --git a/tests/writer.html b/tests/writer.html
index 39ae2ebb7..60f5f4a45 100644
--- a/tests/writer.html
+++ b/tests/writer.html
@@ -1,12 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>Pandoc Test Suite</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="John MacFarlane" />
<meta name="author" content="Anonymous" />
<meta name="date" content="July 17, 2006" />
+ <title>Pandoc Test Suite</title>
</head>
<body>
<h1 class="title">Pandoc Test Suite</h1>
@@ -74,7 +74,7 @@
></pre
><p
>A list:</p
- ><ol style="list-style-type: decimal;"
+ ><ol style="list-style-type: decimal"
><li
>item one</li
><li
@@ -207,7 +207,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
>Ordered</h2
><p
>Tight:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
>First</li
><li
@@ -217,7 +217,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
><p
>and:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
>One</li
><li
@@ -227,7 +227,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
><p
>Loose using tabs:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
><p
>First</p
@@ -243,7 +243,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
><p
>and using spaces:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
><p
>One</p
@@ -259,7 +259,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
><p
>Multiple paragraphs:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
><p
>Item 1, graf one.</p
@@ -291,7 +291,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ul
><p
>Here’s another:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
>First</li
><li
@@ -309,7 +309,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
><p
>Same thing but with paragraphs:</p
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
><p
>First</p
@@ -355,7 +355,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ul
><h2 id="fancy-list-markers"
>Fancy list markers</h2
-><ol start="2" style="list-style-type: decimal;"
+><ol start="2" style="list-style-type: decimal"
><li
>begins with 2</li
><li
@@ -363,11 +363,11 @@ These should not be escaped: \$ \\ \&gt; \[ \{
>and now 3</p
><p
>with a continuation</p
- ><ol start="4" style="list-style-type: lower-roman;"
+ ><ol start="4" style="list-style-type: lower-roman"
><li
>sublist with roman numerals, starting with 4</li
><li
- >more items<ol style="list-style-type: upper-alpha;"
+ >more items<ol style="list-style-type: upper-alpha"
><li
>a subsublist</li
><li
@@ -379,13 +379,13 @@ These should not be escaped: \$ \\ \&gt; \[ \{
></ol
><p
>Nesting:</p
-><ol style="list-style-type: upper-alpha;"
+><ol style="list-style-type: upper-alpha"
><li
- >Upper Alpha<ol style="list-style-type: upper-roman;"
+ >Upper Alpha<ol style="list-style-type: upper-roman"
><li
- >Upper Roman.<ol start="6" style="list-style-type: decimal;"
+ >Upper Roman.<ol start="6" style="list-style-type: decimal"
><li
- >Decimal start with 6<ol start="3" style="list-style-type: lower-alpha;"
+ >Decimal start with 6<ol start="3" style="list-style-type: lower-alpha"
><li
>Lower alpha with paren</li
></ol
@@ -559,7 +559,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
><dd
><p
>orange fruit</p
- ><ol style="list-style-type: decimal;"
+ ><ol style="list-style-type: decimal"
><li
>sublist</li
><li
@@ -846,8 +846,6 @@ Blah
></ul
><p
>Here’s a LaTeX table:</p
-><p
-></p
><hr
/><h1 id="special-characters"
>Special Characters</h1
@@ -1026,7 +1024,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'Email link'+'<\/'+'a'+'>')
>Autolinks</h2
><p
>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2"
- ><code
+ ><code class="url"
>http://example.com/?foo=1&amp;bar=2</code
></a
></p
@@ -1035,7 +1033,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'Email link'+'<\/'+'a'+'>')
>In a list?</li
><li
><a href="http://example.com/"
- ><code
+ ><code class="url"
>http://example.com/</code
></a
></li
@@ -1056,7 +1054,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'<code>'+e+'</code>'+'<\/'+
><blockquote
><p
>Blockquoted: <a href="http://example.com/"
- ><code
+ ><code class="url"
>http://example.com/</code
></a
></p
@@ -1110,7 +1108,7 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+'<code>'+e+'</code>'+'<\/'+
></sup
></p
></blockquote
-><ol style="list-style-type: decimal;"
+><ol style="list-style-type: decimal"
><li
>And in list items.<sup
><a href="#fn5" class="footnoteRef" id="fnref5"
diff --git a/tests/writer.latex b/tests/writer.latex
index 1621a4844..e6adff585 100644
--- a/tests/writer.latex
+++ b/tests/writer.latex
@@ -11,6 +11,8 @@
}\makeatother
\usepackage{enumerate}
\usepackage[normalem]{ulem}
+% avoid problems with \sout in headers with hyperref:
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
\usepackage{url}
\usepackage{graphicx}
@@ -23,7 +25,7 @@
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
-\usepackage[breaklinks=true,unicode=true]{hyperref}
+\usepackage[breaklinks=true,unicode=true,pdfborder={0 0 0}]{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setcounter{secnumdepth}{0}
@@ -36,8 +38,8 @@
\begin{document}
\maketitle
-This is a set of tests for pandoc. Most of them are adapted from
-John Gruber's markdown test suite.
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
\begin{center}\rule{3in}{0.4pt}\end{center}
@@ -47,9 +49,9 @@ John Gruber's markdown test suite.
\subsubsection{Level 3 with \emph{emphasis}}
-Level 4
+\paragraph{Level 4}
-Level 5
+\subparagraph{Level 5}
\section{Level 1}
@@ -69,9 +71,9 @@ with no blank line
Here's a regular paragraph.
-In Markdown 1.0.0 and earlier. Version 8. This line turns into a
-list item. Because a hard-wrapped line in the middle of a paragraph
-looked like a list item.
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
Here's one with a bullet. * criminey.
@@ -161,13 +163,10 @@ Asterisks loose:
\begin{itemize}
\item
asterisk 1
-
\item
asterisk 2
-
\item
asterisk 3
-
\end{itemize}
Pluses tight:
@@ -184,13 +183,10 @@ Pluses loose:
\begin{itemize}
\item
Plus 1
-
\item
Plus 2
-
\item
Plus 3
-
\end{itemize}
Minuses tight:
@@ -207,13 +203,10 @@ Minuses loose:
\begin{itemize}
\item
Minus 1
-
\item
Minus 2
-
\item
Minus 3
-
\end{itemize}
\subsection{Ordered}
@@ -242,26 +235,20 @@ Loose using tabs:
\begin{enumerate}[1.]
\item
First
-
\item
Second
-
\item
Third
-
\end{enumerate}
and using spaces:
\begin{enumerate}[1.]
\item
One
-
\item
Two
-
\item
Three
-
\end{enumerate}
Multiple paragraphs:
@@ -269,15 +256,11 @@ Multiple paragraphs:
\item
Item 1, graf one.
- Item 1. graf two. The quick brown fox jumped over the lazy dog's
- back.
-
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
\item
Item 2.
-
\item
Item 3.
-
\end{enumerate}
\subsection{Nested}
@@ -316,7 +299,6 @@ Same thing but with paragraphs:
\begin{enumerate}[1.]
\item
First
-
\item
Second:
@@ -330,24 +312,20 @@ Same thing but with paragraphs:
\end{itemize}
\item
Third
-
\end{enumerate}
\subsection{Tabs and spaces}
\begin{itemize}
\item
this is a list item indented with tabs
-
\item
this is a list item indented with spaces
\begin{itemize}
\item
this is an example list item indented with tabs
-
\item
this is an example list item indented with spaces
-
\end{itemize}
\end{itemize}
\subsection{Fancy list markers}
@@ -487,13 +465,11 @@ Multiple definitions, loose:
\item[apple]
red fruit
-
computer
\item[orange]
orange fruit
-
bank
\end{description}
@@ -503,7 +479,6 @@ Blank line after term, indented marker, alternate markers:
\item[apple]
red fruit
-
computer
\item[orange]
@@ -583,20 +558,17 @@ So is \textbf{\emph{this}} word.
So is \textbf{\emph{this}} word.
-This is code: \verb!>!, \verb!$!, \verb!\!, \verb!\$!,
-\verb!<html>!.
+This is code: \verb!>!, \verb!$!, \verb!\!, \verb!\$!, \verb!<html>!.
\sout{This is \emph{strikeout}.}
-Superscripts: a\textsuperscript{bc}d
-a\textsuperscript{\emph{hello}} a\textsuperscript{hello~there}.
+Superscripts: a\textsuperscript{bc}d a\textsuperscript{\emph{hello}}
+a\textsuperscript{hello~there}.
-Subscripts: H\textsubscr{2}O, H\textsubscr{23}O,
-H\textsubscr{many~of~them}O.
+Subscripts: H\textsubscr{2}O, H\textsubscr{23}O, H\textsubscr{many~of~them}O.
-These should not be superscripts or subscripts, because of the
-unescaped spaces: a\^{}b c\^{}d, a\ensuremath{\sim}b
-c\ensuremath{\sim}d.
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\^{}b c\^{}d, a\ensuremath{\sim}b c\ensuremath{\sim}d.
\begin{center}\rule{3in}{0.4pt}\end{center}
@@ -611,7 +583,7 @@ c\ensuremath{\sim}d.
`He said, ``I want to go.''\,' Were you alive in the 70's?
Here is some quoted `\verb!code!' and a
-``\href{http://example.com/?foo=1&bar=2}{quoted link}''.
+``\href{http://example.com/?foo=1\&bar=2}{quoted link}''.
Some dashes: one---two --- three---four --- five.
@@ -640,8 +612,7 @@ Ellipses\ldots{}and\ldots{}and\ldots{}.
Here's some display math:
\[\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}\]
\item
- Here's one that has a line break in it:
- $\alpha + \omega \times x^2$.
+ Here's one that has a line break in it: $\alpha + \omega \times x^2$.
\end{itemize}
These shouldn't be math:
@@ -649,8 +620,8 @@ These shouldn't be math:
\item
To get the famous equation, write \verb!$e = mc^2$!.
\item
- \$22,000 is a \emph{lot} of money. So is \$34,000. (It worked if
- ``lot'' is emphasized.)
+ \$22,000 is a \emph{lot} of money. So is \$34,000. (It worked if ``lot'' is
+ emphasized.)
\item
Shoes (\$20) and socks (\$5).
\item
@@ -704,9 +675,9 @@ Left brace: \{
Right brace: \}
-Left bracket: [
+Left bracket: {[}
-Right bracket: ]
+Right bracket: {]}
Left paren: (
@@ -742,7 +713,7 @@ Just a \href{/url/}{URL}.
\href{/url/}{URL and title}
-\href{/url/with_underscore}{with\_underscore}
+\href{/url/with\_underscore}{with\_underscore}
\href{mailto:nobody@nowhere.net}{Email link}
@@ -756,7 +727,7 @@ Foo \href{/url/}{bar}.
Foo \href{/url/}{bar}.
-With \href{/url/}{embedded [brackets]}.
+With \href{/url/}{embedded {[}brackets{]}}.
\href{/url/}{b} by itself should be a link.
@@ -766,7 +737,7 @@ Indented \href{/url}{twice}.
Indented \href{/url}{thrice}.
-This should [not][] be a link.
+This should {[}not{]}{[}{]} be a link.
\begin{verbatim}
[not]: /url
@@ -777,16 +748,15 @@ Foo \href{/url/}{biz}.
\subsection{With ampersands}
-Here's a
-\href{http://example.com/?foo=1&bar=2}{link with an ampersand in the URL}.
+Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
+URL}.
Here's a link with an amersand in the link text:
\href{http://att.com/}{AT\&T}.
-Here's an \href{/script?foo=1&bar=2}{inline link}.
+Here's an \href{/script?foo=1\&bar=2}{inline link}.
-Here's an
-\href{/script?foo=1&bar=2}{inline link in pointy braces}.
+Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
\subsection{Autolinks}
@@ -830,37 +800,32 @@ Here is a movie \includegraphics{movie.jpg} icon.
\section{Footnotes}
-Here is a footnote reference,%
-\footnote{Here is the footnote. It can go anywhere after the footnote
-reference. It need not be placed at the end of the document.}
-and another.%
-\footnote{Here's the long note. This one contains multiple blocks.
+Here is a footnote reference,\footnote{Here is the footnote. It can go
+ anywhere after the footnote reference. It need not be placed at the end of
+ the document.} and another.\footnote{Here's the long note. This one contains
+ multiple blocks.
-Subsequent blocks are indented to show that they belong to the
-footnote (as with list items).
+ Subsequent blocks are indented to show that they belong to the footnote (as
+ with list items).
-\begin{Verbatim}
+ \begin{Verbatim}
{ <code> }
-\end{Verbatim}
-If you want, you can indent every line, but you can also be lazy
-and just indent the first line of each block.}
-This should \emph{not} be a footnote reference, because it contains
-a space.[\^{}my note] Here is an inline note.%
-\footnote{This is \emph{easier} to type. Inline notes may contain
-\href{http://google.com}{links} and \verb!]! verbatim characters,
-as well as [bracketed text].}
+ \end{Verbatim}
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.} This should \emph{not} be a footnote
+reference, because it contains a space.{[}\^{}my note{]} Here is an inline
+note.\footnote{This is \emph{easier} to type. Inline notes may contain
+ \href{http://google.com}{links} and \verb!]! verbatim characters, as well as
+ {[}bracketed text{]}.}
\begin{quote}
-Notes can go in quotes.%
-\footnote{In quote.}
+Notes can go in quotes.\footnote{In quote.}
\end{quote}
\begin{enumerate}[1.]
\item
- And in list items.%
- \footnote{In list.}
+ And in list items.\footnote{In list.}
\end{enumerate}
-This paragraph should not be part of the note, as it is not
-indented.
+This paragraph should not be part of the note, as it is not indented.
\end{document}
diff --git a/tests/writer.man b/tests/writer.man
index e4dc0c7de..bdbb91604 100644
--- a/tests/writer.man
+++ b/tests/writer.man
@@ -26,8 +26,8 @@ Here's a regular paragraph.
In Markdown 1.0.0 and earlier.
Version 8.
This line turns into a list item.
-Because a hard-wrapped line in the middle of a paragraph looked
-like a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
.PP
Here's one with a bullet.
* criminey.
@@ -531,8 +531,8 @@ Superscripts: a^bc^d a^\f[I]hello\f[]^ a^hello\ there^.
.PP
Subscripts: H~2~O, H~23~O, H~many\ of\ them~O.
.PP
-These should not be superscripts or subscripts, because of the
-unescaped spaces: a^b c^d, a~b c~d.
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
.PP
* * * * *
.SH Smart quotes, ellipses, dashes
@@ -547,8 +547,8 @@ So is `pine.'
.PP
`He said, \[lq]I want to go.\[rq]' Were you alive in the 70's?
.PP
-Here is some quoted `\f[C]code\f[]' and a
-\[lq]quoted link (http://example.com/?foo=1&bar=2)\[rq].
+Here is some quoted `\f[C]code\f[]' and a \[lq]quoted
+link (http://example.com/?foo=1&bar=2)\[rq].
.PP
Some dashes: one\[em]two \[em] three\[em]four \[em] five.
.PP
@@ -591,7 +591,6 @@ Escaped \f[C]$\f[]: $73 \f[I]this should be emphasized\f[] 23$.
.PP
Here's a LaTeX table:
.PP
-.PP
* * * * *
.SH Special Characters
.PP
@@ -641,7 +640,7 @@ Greater-than: >
.PP
Hash: #
.PP
-Period: \&.
+Period: .
.PP
Bang: !
.PP
@@ -701,11 +700,9 @@ Foo bar (/url/).
Foo biz (/url/).
.SS With ampersands
.PP
-Here's a
-link with an ampersand in the URL (http://example.com/?foo=1&bar=2).
+Here's a link with an ampersand in the URL (http://example.com/?foo=1&bar=2).
.PP
-Here's a link with an amersand in the link text:
-AT&T (http://att.com/).
+Here's a link with an amersand in the link text: AT&T (http://att.com/).
.PP
Here's an inline link (/script?foo=1&bar=2).
.PP
@@ -746,9 +743,9 @@ Here is a movie [IMAGE: movie (movie.jpg)] icon.
* * * * *
.SH Footnotes
.PP
-Here is a footnote reference,[1] and another.[2] This should
-\f[I]not\f[] be a footnote reference, because it contains a
-space.[^my note] Here is an inline note.[3]
+Here is a footnote reference,[1] and another.[2] This should \f[I]not\f[] be a
+footnote reference, because it contains a space.[^my note] Here is an inline
+note.[3]
.RS
.PP
Notes can go in quotes.[4]
@@ -756,23 +753,20 @@ Notes can go in quotes.[4]
.IP "1." 3
And in list items.[5]
.PP
-This paragraph should not be part of the note, as it is not
-indented.
+This paragraph should not be part of the note, as it is not indented.
.SH NOTES
-
.SS [1]
.PP
Here is the footnote.
It can go anywhere after the footnote reference.
It need not be placed at the end of the document.
-
.SS [2]
.PP
Here's the long note.
This one contains multiple blocks.
.PP
-Subsequent blocks are indented to show that they belong to the
-footnote (as with list items).
+Subsequent blocks are indented to show that they belong to the footnote (as
+with list items).
.IP
.nf
\f[C]
@@ -780,19 +774,16 @@ footnote (as with list items).
\f[]
.fi
.PP
-If you want, you can indent every line, but you can also be lazy
-and just indent the first line of each block.
-
+If you want, you can indent every line, but you can also be lazy and just
+indent the first line of each block.
.SS [3]
.PP
This is \f[I]easier\f[] to type.
-Inline notes may contain links (http://google.com) and \f[C]]\f[]
-verbatim characters, as well as [bracketed text].
-
+Inline notes may contain links (http://google.com) and \f[C]]\f[] verbatim
+characters, as well as [bracketed text].
.SS [4]
.PP
In quote.
-
.SS [5]
.PP
In list.
diff --git a/tests/writer.markdown b/tests/writer.markdown
index b417a8fee..cc56b8b3a 100644
--- a/tests/writer.markdown
+++ b/tests/writer.markdown
@@ -2,9 +2,8 @@
% John MacFarlane; Anonymous
% July 17, 2006
-This is a set of tests for pandoc. Most of them are adapted from
-John Gruber’s markdown test suite.
-
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
* * * * *
@@ -30,23 +29,21 @@ with no blank line
with no blank line
-
* * * * *
# Paragraphs
Here’s a regular paragraph.
-In Markdown 1.0.0 and earlier. Version 8. This line turns into a
-list item. Because a hard-wrapped line in the middle of a paragraph
-looked like a list item.
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
Here’s one with a bullet. \* criminey.
-There should be a hard line break
+There should be a hard line break\
here.
-
* * * * *
# Block Quotes
@@ -56,27 +53,26 @@ E-mail style:
> This is a block quote. It is pretty short.
> Code in a block quote:
->
+>
> sub status {
> print "working";
> }
->
+>
> A list:
->
+>
> 1. item one
> 2. item two
->
+>
> Nested block quotes:
->
+>
> > nested
->
+>
> > nested
This should not be a block quote: 2 \> 1.
And a following paragraph.
-
* * * * *
# Code Blocks
@@ -84,19 +80,18 @@ And a following paragraph.
Code:
---- (should be four hyphens)
-
+
sub status {
print "working";
}
-
+
this code block is indented by one tab
And:
this code block is indented by two tabs
-
- These should not be escaped: \$ \\ \> \[ \{
+ These should not be escaped: \$ \\ \> \[ \{
* * * * *
@@ -118,7 +113,6 @@ Asterisks loose:
- asterisk 3
-
Pluses tight:
- Plus 1
@@ -133,7 +127,6 @@ Pluses loose:
- Plus 3
-
Minuses tight:
- Minus 1
@@ -148,7 +141,6 @@ Minuses loose:
- Minus 3
-
## Ordered
Tight:
@@ -171,7 +163,6 @@ Loose using tabs:
3. Third
-
and using spaces:
1. One
@@ -180,27 +171,22 @@ and using spaces:
3. Three
-
Multiple paragraphs:
1. Item 1, graf one.
- Item 1. graf two. The quick brown fox jumped over the lazy dog’s
- back.
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
2. Item 2.
3. Item 3.
-
## Nested
- Tab
- Tab
- Tab
-
-
Here’s another:
1. First
@@ -223,7 +209,6 @@ Same thing but with paragraphs:
3. Third
-
## Tabs and spaces
- this is a list item indented with tabs
@@ -234,8 +219,6 @@ Same thing but with paragraphs:
- this is an example list item indented with spaces
-
-
## Fancy list markers
(2) begins with 2
@@ -248,8 +231,6 @@ Same thing but with paragraphs:
(A) a subsublist
(B) a subsublist
-
-
Nesting:
A. Upper Alpha
@@ -257,23 +238,18 @@ A. Upper Alpha
(6) Decimal start with 6
c) Lower alpha with paren
-
-
-
Autonumbering:
1. Autonumber.
2. More.
1. Nested.
-
Should not be a list item:
M.A. 2007
B. Williams
-
* * * * *
# Definition Lists
@@ -307,7 +283,6 @@ orange
banana
~ yellow fruit
-
Multiple blocks with italics:
*apple*
@@ -322,7 +297,6 @@ Multiple blocks with italics:
> orange block quote
-
Multiple definitions, tight:
apple
@@ -344,7 +318,6 @@ orange
~ bank
-
Blank line after term, indented marker, alternate markers:
apple
@@ -358,7 +331,6 @@ orange
1. sublist
2. sublist
-
# HTML Blocks
Simple block on one line:
@@ -470,7 +442,6 @@ Hr’s:
<hr class="foo" id="bar">
-
* * * * *
# Inline Markup
@@ -497,9 +468,8 @@ Superscripts: a^bc^d a^*hello*^ a^hello there^.
Subscripts: H~2~O, H~23~O, H~many of them~O.
-These should not be superscripts or subscripts, because of the
-unescaped spaces: a\^b c\^d, a\~b c\~d.
-
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\^b c\^d, a\~b c\~d.
* * * * *
@@ -513,8 +483,8 @@ unescaped spaces: a\^b c\^d, a\~b c\~d.
‘He said, “I want to go.”’ Were you alive in the 70’s?
-Here is some quoted ‘`code`’ and a
-“[quoted link](http://example.com/?foo=1&bar=2)”.
+Here is some quoted ‘`code`’ and a “[quoted
+link](http://example.com/?foo=1&bar=2)”.
Some dashes: one—two — three—four — five.
@@ -522,7 +492,6 @@ Dashes between numbers: 5–7, 255–66, 1987–1999.
Ellipses…and…and….
-
* * * * *
# LaTeX
@@ -535,14 +504,13 @@ Ellipses…and…and….
- $p$-Tree
- Here’s some display math:
$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
-- Here’s one that has a line break in it:
- $\alpha + \omega \times x^2$.
+- Here’s one that has a line break in it: $\alpha + \omega \times x^2$.
These shouldn’t be math:
- To get the famous equation, write `$e = mc^2$`.
-- $22,000 is a *lot* of money. So is $34,000. (It worked if “lot”
- is emphasized.)
+- $22,000 is a *lot* of money. So is $34,000. (It worked if “lot” is
+ emphasized.)
- Shoes ($20) and socks ($5).
- Escaped `$`: $73 *this should be emphasized* 23$.
@@ -554,7 +522,6 @@ Dog & 2 \\
Cat & 1 \\ \hline
\end{tabular}
-
* * * * *
# Special Characters
@@ -609,7 +576,6 @@ Plus: +
Minus: -
-
* * * * *
# Links
@@ -662,8 +628,7 @@ Foo [biz](/url/ "Title with "quote" inside").
## With ampersands
-Here’s a
-[link with an ampersand in the URL](http://example.com/?foo=1&bar=2).
+Here’s a [link with an ampersand in the URL](http://example.com/?foo=1&bar=2).
Here’s a link with an amersand in the link text:
[AT&T](http://att.com/ "AT&T").
@@ -688,7 +653,6 @@ Auto-links should not occur here: `<http://example.com/>`
or here: <http://example.com/>
-
* * * * *
# Images
@@ -699,44 +663,37 @@ From “Voyage dans la Lune” by Georges Melies (1902):
Here is a movie ![movie](movie.jpg) icon.
-
* * * * *
# Footnotes
-Here is a footnote reference,[^1] and another.[^2] This should
-*not* be a footnote reference, because it contains a space.[\^my
-note] Here is an inline note.[^3]
+Here is a footnote reference,[^1] and another.[^2] This should *not* be a
+footnote reference, because it contains a space.[\^my note] Here is an inline
+note.[^3]
> Notes can go in quotes.[^4]
1. And in list items.[^5]
-This paragraph should not be part of the note, as it is not
-indented.
+This paragraph should not be part of the note, as it is not indented.
-[^1]:
- Here is the footnote. It can go anywhere after the footnote
- reference. It need not be placed at the end of the document.
+[^1]: Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
-[^2]:
- Here’s the long note. This one contains multiple blocks.
+[^2]: Here’s the long note. This one contains multiple blocks.
- Subsequent blocks are indented to show that they belong to the
- footnote (as with list items).
+ Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).
{ <code> }
- If you want, you can indent every line, but you can also be lazy
- and just indent the first line of each block.
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
-[^3]:
- This is *easier* to type. Inline notes may contain
+[^3]: This is *easier* to type. Inline notes may contain
[links](http://google.com) and `]` verbatim characters, as well as
[bracketed text].
-[^4]:
- In quote.
+[^4]: In quote.
-[^5]:
- In list.
+[^5]: In list.
diff --git a/tests/writer.mediawiki b/tests/writer.mediawiki
index 557396bfb..af4f7050c 100644
--- a/tests/writer.mediawiki
+++ b/tests/writer.mediawiki
@@ -496,7 +496,6 @@ Here&rsquo;s a LaTeX table:
-
-----
= Special Characters =
diff --git a/tests/writer.native b/tests/writer.native
index ced38537c..879cb24fc 100644
--- a/tests/writer.native
+++ b/tests/writer.native
@@ -1,417 +1,396 @@
-Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17,",Space,Str "2006"]})
-[ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
-, HorizontalRule
-, Header 1 [Str "Headers"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
-, Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 4 [Str "Level",Space,Str "4"]
-, Header 5 [Str "Level",Space,Str "5"]
-, Header 1 [Str "Level",Space,Str "1"]
-, Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
-, Header 3 [Str "Level",Space,Str "3"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, Header 2 [Str "Level",Space,Str "2"]
-, Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
-, HorizontalRule
-, Header 1 [Str "Paragraphs"]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
-, Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
-, Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here",Str "."]
-, HorizontalRule
-, Header 1 [Str "Block",Space,Str "Quotes"]
-, Para [Str "E",Str "-",Str "mail",Space,Str "style:"]
-, BlockQuote
- [ Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."] ]
-
-, BlockQuote
- [ Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
- , CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
- , Para [Str "A",Space,Str "list:"]
- , OrderedList (1,Decimal,Period)
- [ [ Plain [Str "item",Space,Str "one"] ]
- , [ Plain [Str "item",Space,Str "two"] ] ]
- , Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
- , BlockQuote
- [ Para [Str "nested"] ]
-
- , BlockQuote
- [ Para [Str "nested"] ]
- ]
-, Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]
-, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
-, HorizontalRule
-, Header 1 [Str "Code",Space,Str "Blocks"]
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
-, Para [Str "And:"]
-, CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
-, HorizontalRule
-, Header 1 [Str "Lists"]
-, Header 2 [Str "Unordered"]
-, Para [Str "Asterisks",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "asterisk",Space,Str "1"] ]
- , [ Plain [Str "asterisk",Space,Str "2"] ]
- , [ Plain [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Asterisks",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "asterisk",Space,Str "1"] ]
- , [ Para [Str "asterisk",Space,Str "2"] ]
- , [ Para [Str "asterisk",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "Plus",Space,Str "1"] ]
- , [ Plain [Str "Plus",Space,Str "2"] ]
- , [ Plain [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Pluses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Plus",Space,Str "1"] ]
- , [ Para [Str "Plus",Space,Str "2"] ]
- , [ Para [Str "Plus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "tight:"]
-, BulletList
- [ [ Plain [Str "Minus",Space,Str "1"] ]
- , [ Plain [Str "Minus",Space,Str "2"] ]
- , [ Plain [Str "Minus",Space,Str "3"] ] ]
-, Para [Str "Minuses",Space,Str "loose:"]
-, BulletList
- [ [ Para [Str "Minus",Space,Str "1"] ]
- , [ Para [Str "Minus",Space,Str "2"] ]
- , [ Para [Str "Minus",Space,Str "3"] ] ]
-, Header 2 [Str "Ordered"]
-, Para [Str "Tight:"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second"] ]
- , [ Plain [Str "Third"] ] ]
-, Para [Str "and:"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "One"] ]
- , [ Plain [Str "Two"] ]
- , [ Plain [Str "Three"] ] ]
-, Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second"] ]
- , [ Para [Str "Third"] ] ]
-, Para [Str "and",Space,Str "using",Space,Str "spaces:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "One"] ]
- , [ Para [Str "Two"] ]
- , [ Para [Str "Three"] ] ]
-, Para [Str "Multiple",Space,Str "paragraphs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
- , Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."] ], [ Para [Str "Item",Space,Str "2",Str "."] ]
- , [ Para [Str "Item",Space,Str "3",Str "."] ] ]
-, Header 2 [Str "Nested"]
-, BulletList
- [ [ Plain [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"]
- , BulletList
- [ [ Plain [Str "Tab"] ]
- ] ] ] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "another:"]
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "First"] ]
- , [ Plain [Str "Second:"]
- , BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ], [ Plain [Str "Third"] ] ]
-, Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
-, OrderedList (1,Decimal,Period)
- [ [ Para [Str "First"] ]
- , [ Para [Str "Second:"]
- , BulletList
- [ [ Plain [Str "Fee"] ]
- , [ Plain [Str "Fie"] ]
- , [ Plain [Str "Foe"] ] ] ], [ Para [Str "Third"] ] ]
-, Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
-, BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
- , BulletList
- [ [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"] ]
- , [ Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"] ] ] ] ]
-, Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
-, OrderedList (2,Decimal,TwoParens)
- [ [ Plain [Str "begins",Space,Str "with",Space,Str "2"] ]
- , [ Para [Str "and",Space,Str "now",Space,Str "3"]
- , Para [Str "with",Space,Str "a",Space,Str "continuation"]
- , OrderedList (4,LowerRoman,Period)
- [ [ Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"] ]
- , [ Plain [Str "more",Space,Str "items"]
- , OrderedList (1,UpperAlpha,TwoParens)
- [ [ Plain [Str "a",Space,Str "subsublist"] ]
- , [ Plain [Str "a",Space,Str "subsublist"] ] ] ] ] ] ]
-, Para [Str "Nesting:"]
-, OrderedList (1,UpperAlpha,Period)
- [ [ Plain [Str "Upper",Space,Str "Alpha"]
- , OrderedList (1,UpperRoman,Period)
- [ [ Plain [Str "Upper",Space,Str "Roman",Str "."]
- , OrderedList (6,Decimal,TwoParens)
- [ [ Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
- , OrderedList (3,LowerAlpha,OneParen)
- [ [ Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"] ]
- ] ] ] ] ] ] ]
-, Para [Str "Autonumbering:"]
-, OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Autonumber",Str "."] ]
- , [ Plain [Str "More",Str "."]
- , OrderedList (1,DefaultStyle,DefaultDelim)
- [ [ Plain [Str "Nested",Str "."] ]
- ] ] ]
-, Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
-, Para [Str "M.A.\160",Str "2007"]
-, Para [Str "B",Str ".",Space,Str "Williams"]
-, HorizontalRule
-, Header 1 [Str "Definition",Space,Str "Lists"]
-, Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Plain [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Plain [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Plain [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Plain [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Plain [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Plain [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Loose:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- ])
- , ([Str "banana"],
- [ [ Para [Str "yellow",Space,Str "fruit"] ]
- ]) ]
-, Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
-, DefinitionList
- [ ([Emph [Str "apple"]],
- [ [ Para [Str "red",Space,Str "fruit"]
- , Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"] ]])
- , ([Emph [Str "orange"]],
- [ [ Para [Str "orange",Space,Str "fruit"]
- , CodeBlock ("",[],[]) "{ orange code block }"
- , BlockQuote
- [ Para [Str "orange",Space,Str "block",Space,Str "quote"] ]
- ]]) ]
-, Para [Str "Multiple",Space,Str "definitions,",Space,Str "tight:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Plain [Str "red",Space,Str "fruit"] ]
- , [ Plain [Str "computer"] ]
- ])
- , ([Str "orange"],
- [ [ Plain [Str "orange",Space,Str "fruit"] ]
- , [ Plain [Str "bank"] ]
- ]) ]
-, Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- , [ Para [Str "computer"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"] ]
- , [ Para [Str "bank"] ]
- ]) ]
-, Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"]
-, DefinitionList
- [ ([Str "apple"],
- [ [ Para [Str "red",Space,Str "fruit"] ]
- , [ Para [Str "computer"] ]
- ])
- , ([Str "orange"],
- [ [ Para [Str "orange",Space,Str "fruit"]
- , OrderedList (1,Decimal,Period)
- [ [ Plain [Str "sublist"] ]
- , [ Plain [Str "sublist"] ] ] ]]) ]
-, Header 1 [Str "HTML",Space,Str "Blocks"]
-, Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
-, RawHtml "<div>"
-, Plain [Str "foo"]
-, RawHtml "</div>\n"
-, Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
-, RawHtml "<div>\n<div>\n<div>"
-, Plain [Str "foo"]
-, RawHtml "</div>\n</div>\n<div>"
-, Plain [Str "bar"]
-, RawHtml "</div>\n</div>\n"
-, Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
-, RawHtml "<table>\n<tr>\n<td>"
-, Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
-, RawHtml "</td>\n<td>"
-, Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
-, RawHtml "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
-, RawHtml "<div>\n "
-, Plain [Str "foo"]
-, RawHtml "</div>\n"
-, Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
-, CodeBlock ("",[],[]) "<div>\n foo\n</div>"
-, Para [Str "As",Space,Str "should",Space,Str "this:"]
-, CodeBlock ("",[],[]) "<div>foo</div>"
-, Para [Str "Now,",Space,Str "nested:"]
-, RawHtml "<div>\n <div>\n <div>\n "
-, Plain [Str "foo"]
-, RawHtml "</div>\n </div>\n</div>\n"
-, Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
-, RawHtml "<!-- Comment -->\n"
-, Para [Str "Multiline:"]
-, RawHtml "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
-, Para [Str "Code",Space,Str "block:"]
-, CodeBlock ("",[],[]) "<!-- Comment -->"
-, Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
-, RawHtml "<!-- foo --> \n"
-, Para [Str "Code:"]
-, CodeBlock ("",[],[]) "<hr />"
-, Para [Str "Hr",Apostrophe,Str "s:"]
-, RawHtml "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
-, HorizontalRule
-, Header 1 [Str "Inline",Space,Str "Markup"]
-, Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
-, Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
-, Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
-, Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
-, Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
-, Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ">",Str ",",Space,Code "$",Str ",",Space,Code "\\",Str ",",Space,Code "\\$",Str ",",Space,Code "<html>",Str "."]
-, Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
-, Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Str "\160",Str "there"],Str "."]
-, Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many",Str "\160",Str "of",Str "\160",Str "them"],Str "O",Str "."]
-, Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d,",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."]
-, HorizontalRule
-, Header 1 [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
-, Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name",Str "."]]
-, Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters",Str "."]
-, Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]]
-, Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str "."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Apostrophe,Str "s?"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
-, Para [Str "Some",Space,Str "dashes:",Space,Str "one",EmDash,Str "two",Space,EmDash,Space,Str "three",EmDash,Str "four",Space,EmDash,Space,Str "five",Str "."]
-, Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",EnDash,Str "7,",Space,Str "255",EnDash,Str "66,",Space,Str "1987",EnDash,Str "1999",Str "."]
-, Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."]
-, HorizontalRule
-, Header 1 [Str "LaTeX"]
-, BulletList
- [ [ Plain [TeX "\\cite[22-23]{smith.1899}"] ]
- , [ Plain [Math InlineMath "2+2=4"] ]
- , [ Plain [Math InlineMath "x \\in y"] ]
- , [ Plain [Math InlineMath "\\alpha \\wedge \\omega"] ]
- , [ Plain [Math InlineMath "223"] ]
- , [ Plain [Math InlineMath "p",Str "-",Str "Tree"] ]
- , [ Plain [Str "Here",Apostrophe,Str "s",Space,Str "some",Space,Str "display",Space,Str "math:",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"] ]
- , [ Plain [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."] ] ]
-, Para [Str "These",Space,Str "shouldn",Apostrophe,Str "t",Space,Str "be",Space,Str "math:"]
-, BulletList
- [ [ Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code "$e = mc^2$",Str "."] ]
- , [ Plain [Str "$",Str "22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$",Str "34,000",Str ".",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized",Str ".",Str ")"] ]
- , [ Plain [Str "Shoes",Space,Str "(",Str "$",Str "20)",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5)",Str "."] ]
- , [ Plain [Str "Escaped",Space,Code "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."] ] ]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
-, Para [TeX "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"]
-, HorizontalRule
-, Header 1 [Str "Special",Space,Str "Characters"]
-, Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
-, BulletList
- [ [ Plain [Str "I",Space,Str "hat:",Space,Str "\206"] ]
- , [ Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"] ]
- , [ Plain [Str "section:",Space,Str "\167"] ]
- , [ Plain [Str "set",Space,Str "membership:",Space,Str "\8712"] ]
- , [ Plain [Str "copyright:",Space,Str "\169"] ] ]
-, Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
-, Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]
-, Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
-, Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
-, Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
-, Para [Str "Backslash:",Space,Str "\\"]
-, Para [Str "Backtick:",Space,Str "`"]
-, Para [Str "Asterisk:",Space,Str "*"]
-, Para [Str "Underscore:",Space,Str "_"]
-, Para [Str "Left",Space,Str "brace:",Space,Str "{"]
-, Para [Str "Right",Space,Str "brace:",Space,Str "}"]
-, Para [Str "Left",Space,Str "bracket:",Space,Str "["]
-, Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
-, Para [Str "Left",Space,Str "paren:",Space,Str "("]
-, Para [Str "Right",Space,Str "paren:",Space,Str ")"]
-, Para [Str "Greater",Str "-",Str "than:",Space,Str ">"]
-, Para [Str "Hash:",Space,Str "#"]
-, Para [Str "Period:",Space,Str "."]
-, Para [Str "Bang:",Space,Str "!"]
-, Para [Str "Plus:",Space,Str "+"]
-, Para [Str "Minus:",Space,Str "-"]
-, HorizontalRule
-, Header 1 [Str "Links"]
-, Header 2 [Str "Explicit"]
-, Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
-, Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
-, Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]
-, Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
-, Para [Link [Str "Empty"] ("",""),Str "."]
-, Header 2 [Str "Reference"]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
-, Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]
-, Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
-, Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
-, Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
-, Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
-, CodeBlock ("",[],[]) "[not]: /url"
-, Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
-, Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
-, Header 2 [Str "With",Space,Str "ampersands"]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
-, Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
-, Header 2 [Str "Autolinks"]
-, Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Code "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
-, BulletList
- [ [ Plain [Str "In",Space,Str "a",Space,Str "list?"] ]
- , [ Plain [Link [Code "http://example.com/"] ("http://example.com/","")] ]
- , [ Plain [Str "It",Space,Str "should",Str "."] ] ]
-, Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Link [Code "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
-, BlockQuote
- [ Para [Str "Blockquoted:",Space,Link [Code "http://example.com/"] ("http://example.com/","")] ]
-
-, Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code "<http://example.com/>"]
-, CodeBlock ("",[],[]) "or here: <http://example.com/>"
-, HorizontalRule
-, Header 1 [Str "Images"]
-, Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
-, Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
-, HorizontalRule
-, Header 1 [Str "Footnotes"]
-, Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference",Str ".",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document",Str "."]],Space,Str "and",Space,Str "another",Str ".",Note [Para [Str "Here",Apostrophe,Str "s",Space,Str "the",Space,Str "long",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)",Str "."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block",Str "."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space",Str ".",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note",Str ".",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type",Str ".",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]
-, BlockQuote
- [ Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]] ]
-
-, OrderedList (1,Decimal,Period)
- [ [ Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]] ]
- ]
-, Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."] ]
+Pandoc (Meta {docTitle = [Str "Pandoc",Space,Str "Test",Space,Str "Suite"], docAuthors = [[Str "John",Space,Str "MacFarlane"],[Str "Anonymous"]], docDate = [Str "July",Space,Str "17",Str ",",Space,Str "2006"]})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Apostrophe,Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+,HorizontalRule
+,Header 1 [Str "Headers"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 [Str "Level",Space,Str "4"]
+,Header 5 [Str "Level",Space,Str "5"]
+,Header 1 [Str "Level",Space,Str "1"]
+,Header 2 [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 [Str "Paragraphs"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here",Str "."]
+,HorizontalRule
+,Header 1 [Str "Block",Space,Str "Quotes"]
+,Para [Str "E",Str "-",Str "mail",Space,Str "style",Str ":"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list",Str ":"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes",Str ":"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote",Str ":",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
+,HorizontalRule
+,Header 1 [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code",Str ":"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And",Str ":"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 [Str "Lists"]
+,Header 2 [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight",Str ":"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose",Str ":"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 [Str "Ordered"]
+,Para [Str "Tight",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1",Str ",",Space,Str "graf",Space,Str "one",Str "."]
+ ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Apostrophe,Str "s",Space,Str "back",Str "."]]
+ ,[Para [Str "Item",Space,Str "2",Str "."]]
+ ,[Para [Str "Item",Space,Str "3",Str "."]]]
+,Header 2 [Str "Nested"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "another",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second",Str ":"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs",Str ":"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second",Str ":"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals",Str ",",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting",Str ":"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Plain [Str "Upper",Space,Str "Roman",Str "."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering",Str ":"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber",Str "."]]
+ ,[Plain [Str "More",Str "."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested",Str "."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item",Str ":"]
+,Para [Str "M.A.\160",Str "2007"]
+,Para [Str "B",Str ".",Space,Str "Williams"]
+,HorizontalRule
+,Header 1 [Str "Definition",Space,Str "Lists"]
+,Para [Str "Tight",Space,Str "using",Space,Str "spaces",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Tight",Space,Str "using",Space,Str "tabs",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Loose",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics",Str ":"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds",Str ",",Space,Str "crisp",Str ",",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "tight",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]
+ ,[Plain [Str "computer"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]
+ ,[Plain [Str "bank"]]])]
+,Para [Str "Multiple",Space,Str "definitions",Str ",",Space,Str "loose",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]
+ ,[Para [Str "bank"]]])]
+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term",Str ",",Space,Str "indented",Space,Str "marker",Str ",",Space,Str "alternate",Space,Str "markers",Str ":"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "sublist"]]
+ ,[Plain [Str "sublist"]]]]])]
+,Header 1 [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line",Str ":"]
+,RawBlock "html" "<div>"
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n"
+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation",Str ":"]
+,RawBlock "html" "<div>\n<div>\n<div>"
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n</div>\n<div>"
+,Plain [Str "bar"]
+,RawBlock "html" "</div>\n</div>\n"
+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table",Str ":"]
+,RawBlock "html" "<table>\n<tr>\n<td>"
+,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
+,RawBlock "html" "</td>\n<td>"
+,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
+,RawBlock "html" "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "simple",Space,Str "block",Str ":"]
+,RawBlock "html" "<div>\n "
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n"
+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block",Str ",",Space,Str "though",Str ":"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this",Str ":"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now",Str ",",Space,Str "nested",Str ":"]
+,RawBlock "html" "<div>\n <div>\n <div>\n "
+,Plain [Str "foo"]
+,RawBlock "html" "</div>\n </div>\n</div>\n"
+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment",Str ":"]
+,RawBlock "html" "<!-- Comment -->\n"
+,Para [Str "Multiline",Str ":"]
+,RawBlock "html" "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
+,Para [Str "Code",Space,Str "block",Str ":"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment",Str ",",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line",Str ":"]
+,RawBlock "html" "<!-- foo --> \n"
+,Para [Str "Code",Str ":"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr",Apostrophe,Str "s",Str ":"]
+,RawBlock "html" "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
+,HorizontalRule
+,Header 1 [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Str "This",Space,Str "is",Space,Str "code",Str ":",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Str "\160",Str "there"],Str "."]
+,Para [Str "Subscripts",Str ":",Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Str "\160",Str "of",Str "\160",Str "them"],Str "O",Str "."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts",Str ",",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces",Str ":",Space,Str "a",Str "^",Str "b",Space,Str "c",Str "^",Str "d",Str ",",Space,Str "a",Str "~",Str "b",Space,Str "c",Str "~",Str "d",Str "."]
+,HorizontalRule
+,Header 1 [Str "Smart",Space,Str "quotes",Str ",",Space,Str "ellipses",Str ",",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello",Str ","],Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name",Str "."]]
+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters",Str "."]
+,Para [Quoted SingleQuote [Str "Oak",Str ","],Space,Quoted SingleQuote [Str "elm",Str ","],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine",Str "."]]
+,Para [Quoted SingleQuote [Str "He",Space,Str "said",Str ",",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str "."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Apostrophe,Str "s",Str "?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
+,Para [Str "Some",Space,Str "dashes",Str ":",Space,Str "one",EmDash,Str "two",Space,EmDash,Space,Str "three",EmDash,Str "four",Space,EmDash,Space,Str "five",Str "."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers",Str ":",Space,Str "5",EnDash,Str "7",Str ",",Space,Str "255",EnDash,Str "66",Str ",",Space,Str "1987",EnDash,Str "1999",Str "."]
+,Para [Str "Ellipses",Ellipses,Str "and",Ellipses,Str "and",Ellipses,Str "."]
+,HorizontalRule
+,Header 1 [Str "LaTeX"]
+,BulletList
+ [[Plain [RawInline "tex" "\\cite[22-23]{smith.1899}"]]
+ ,[Plain [Math InlineMath "2+2=4"]]
+ ,[Plain [Math InlineMath "x \\in y"]]
+ ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]]
+ ,[Plain [Math InlineMath "223"]]
+ ,[Plain [Math InlineMath "p",Str "-",Str "Tree"]]
+ ,[Plain [Str "Here",Apostrophe,Str "s",Space,Str "some",Space,Str "display",Space,Str "math",Str ":",Space,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]
+ ,[Plain [Str "Here",Apostrophe,Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it",Str ":",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]
+,Para [Str "These",Space,Str "shouldn",Apostrophe,Str "t",Space,Str "be",Space,Str "math",Str ":"]
+,BulletList
+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation",Str ",",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Plain [Str "$",Str "22",Str ",",Str "000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money",Str ".",Space,Str "So",Space,Str "is",Space,Str "$",Str "34",Str ",",Str "000",Str ".",Space,Str "(",Str "It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]]
+ ,[Plain [Str "Shoes",Space,Str "(",Str "$",Str "20",Str ")",Space,Str "and",Space,Str "socks",Space,Str "(",Str "$",Str "5",Str ")",Str "."]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$",Str "73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23",Str "$",Str "."]]]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table",Str ":"]
+,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,HorizontalRule
+,Header 1 [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode",Str ":"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat",Str ":",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut",Str ":",Space,Str "\246"]]
+ ,[Plain [Str "section",Str ":",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership",Str ":",Space,Str "\8712"]]
+ ,[Plain [Str "copyright",Str ":",Space,Str "\169"]]]
+,Para [Str "AT",Str "&",Str "T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
+,Para [Str "AT",Str "&",Str "T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]
+,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
+,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
+,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
+,Para [Str "Backslash",Str ":",Space,Str "\\"]
+,Para [Str "Backtick",Str ":",Space,Str "`"]
+,Para [Str "Asterisk",Str ":",Space,Str "*"]
+,Para [Str "Underscore",Str ":",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace",Str ":",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace",Str ":",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket",Str ":",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket",Str ":",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren",Str ":",Space,Str "("]
+,Para [Str "Right",Space,Str "paren",Str ":",Space,Str ")"]
+,Para [Str "Greater",Str "-",Str "than",Str ":",Space,Str ">"]
+,Para [Str "Hash",Str ":",Space,Str "#"]
+,Para [Str "Period",Str ":",Space,Str "."]
+,Para [Str "Bang",Str ":",Space,Str "!"]
+,Para [Str "Plus",Str ":",Space,Str "+"]
+,Para [Str "Minus",Str ":",Space,Str "-"]
+,HorizontalRule
+,Header 1 [Str "Links"]
+,Header 2 [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
+,Para [Link [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
+,Para [Link [Str "with",Str "_",Str "underscore"] ("/url/with_underscore","")]
+,Para [Link [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Link [Str "Empty"] ("",""),Str "."]
+,Header 2 [Str "Reference"]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link [Str "embedded",Space,Str "[",Str "brackets",Str "]"] ("/url/",""),Str "."]
+,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
+,Para [Str "Indented",Space,Link [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[",Str "not",Str "]",Str "[",Str "]",Space,Str "be",Space,Str "a",Space,Str "link",Str "."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
+,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
+,Header 2 [Str "With",Space,Str "ampersands"]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text",Str ":",Space,Link [Str "AT",Str "&",Str "T"] ("http://att.com/","AT&T"),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here",Apostrophe,Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Plain [Str "In",Space,Str "a",Space,Str "list",Str "?"]]
+ ,[Plain [Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]
+ ,[Plain [Str "It",Space,Str "should",Str "."]]]
+,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address",Str ":",Space,Link [Code ("",["url"],[]) "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted",Str ":",Space,Link [Code ("",["url"],[]) "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here",Str ":",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(",Str "1902",Str ")",Str ":"]
+,Para [Image [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon",Str "."]
+,HorizontalRule
+,Header 1 [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference",Str ".",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document",Str "."]],Space,Str "and",Space,Str "another",Str ".",Note [Para [Str "Here",Apostrophe,Str "s",Space,Str "the",Space,Str "long",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(",Str "as",Space,Str "with",Space,Str "list",Space,Str "items",Str ")",Str "."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want",Str ",",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line",Str ",",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block",Str "."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference",Str ",",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space",Str ".",Str "[",Str "^",Str "my",Space,Str "note",Str "]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note",Str ".",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type",Str ".",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[",Str "bracketed",Space,Str "text",Str "]",Str "."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes",Str ".",Note [Para [Str "In",Space,Str "quote",Str "."]]]]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items",Str ".",Note [Para [Str "In",Space,Str "list",Str "."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note",Str ",",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented",Str "."]]
diff --git a/tests/writer.opendocument b/tests/writer.opendocument
index a08e5cf0a..05d45792a 100644
--- a/tests/writer.opendocument
+++ b/tests/writer.opendocument
@@ -859,29 +859,41 @@
<text:p text:style-name="Author">John MacFarlane</text:p>
<text:p text:style-name="Author">Anonymous</text:p>
<text:p text:style-name="Date">July 17, 2006</text:p>
-<text:p text:style-name="Text_20_body">This is a set of tests for pandoc. Most of them are adapted from John Gruber&#8217;s markdown test suite.</text:p>
+<text:p text:style-name="Text_20_body">This is a set of tests for pandoc. Most
+of them are adapted from John Gruber&#8217;s markdown test suite.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">Headers</text:h>
-<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with an <text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">embedded link</text:span></text:a></text:h>
-<text:h text:style-name="Heading_20_3" text:outline-level="3">Level 3 with <text:span text:style-name="T1">emphasis</text:span></text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with an
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">embedded
+link</text:span></text:a></text:h>
+<text:h text:style-name="Heading_20_3" text:outline-level="3">Level 3 with
+<text:span text:style-name="T1">emphasis</text:span></text:h>
<text:h text:style-name="Heading_20_4" text:outline-level="4">Level 4</text:h>
<text:h text:style-name="Heading_20_5" text:outline-level="5">Level 5</text:h>
<text:h text:style-name="Heading_20_1" text:outline-level="1">Level 1</text:h>
-<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with <text:span text:style-name="T2">emphasis</text:span></text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with
+<text:span text:style-name="T2">emphasis</text:span></text:h>
<text:h text:style-name="Heading_20_3" text:outline-level="3">Level 3</text:h>
<text:p text:style-name="Text_20_body">with no blank line</text:p>
<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2</text:h>
<text:p text:style-name="Text_20_body">with no blank line</text:p>
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">Paragraphs</text:h>
-<text:p text:style-name="Text_20_body">Here&#8217;s a regular paragraph.</text:p>
-<text:p text:style-name="Text_20_body">In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.</text:p>
-<text:p text:style-name="Text_20_body">Here&#8217;s one with a bullet. * criminey.</text:p>
-<text:p text:style-name="Text_20_body">There should be a hard line break<text:line-break />here.</text:p>
+<text:p text:style-name="Text_20_body">Here&#8217;s a regular
+paragraph.</text:p>
+<text:p text:style-name="Text_20_body">In Markdown 1.0.0 and earlier. Version
+8. This line turns into a list item. Because a hard-wrapped line in the middle
+of a paragraph looked like a list item.</text:p>
+<text:p text:style-name="Text_20_body">Here&#8217;s one with a bullet. *
+criminey.</text:p>
+<text:p text:style-name="Text_20_body">There should be a hard line
+break<text:line-break />here.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
-<text:h text:style-name="Heading_20_1" text:outline-level="1">Block Quotes</text:h>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Block
+Quotes</text:h>
<text:p text:style-name="Text_20_body">E-mail style:</text:p>
-<text:p text:style-name="P1">This is a block quote. It is pretty short.</text:p>
+<text:p text:style-name="P1">This is a block quote. It is pretty
+short.</text:p>
<text:p text:style-name="P2">Code in a block quote:</text:p>
<text:p text:style-name="P3">sub status {</text:p>
<text:p text:style-name="P4"><text:s text:c="4" />print &quot;working&quot;;</text:p>
@@ -898,10 +910,12 @@
<text:p text:style-name="P2">Nested block quotes:</text:p>
<text:p text:style-name="P7">nested</text:p>
<text:p text:style-name="P8">nested</text:p>
-<text:p text:style-name="Text_20_body">This should not be a block quote: 2 &gt; 1.</text:p>
+<text:p text:style-name="Text_20_body">This should not be a block quote: 2
+&gt; 1.</text:p>
<text:p text:style-name="Text_20_body">And a following paragraph.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
-<text:h text:style-name="Heading_20_1" text:outline-level="1">Code Blocks</text:h>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Code
+Blocks</text:h>
<text:p text:style-name="Text_20_body">Code:</text:p>
<text:p text:style-name="P9">---- (should be four hyphens)</text:p>
<text:p text:style-name="P10"></text:p>
@@ -1042,7 +1056,8 @@
<text:list text:style-name="L12">
<text:list-item>
<text:p text:style-name="P29">Item 1, graf one.</text:p>
- <text:p text:style-name="P29">Item 1. graf two. The quick brown fox jumped over the lazy dog&#8217;s back.</text:p>
+ <text:p text:style-name="P29">Item 1. graf two. The quick brown fox jumped
+ over the lazy dog&#8217;s back.</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P29">Item 2.</text:p>
@@ -1055,14 +1070,14 @@
<text:list text:style-name="L13">
<text:list-item>
<text:p text:style-name="P30">Tab</text:p><text:list text:style-name="L14">
- <text:list-item>
- <text:p text:style-name="P31">Tab</text:p><text:list text:style-name="L15">
- <text:list-item>
- <text:p text:style-name="P32">Tab</text:p>
- </text:list-item>
- </text:list>
- </text:list-item>
- </text:list>
+ <text:list-item>
+ <text:p text:style-name="P31">Tab</text:p><text:list text:style-name="L15">
+ <text:list-item>
+ <text:p text:style-name="P32">Tab</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ </text:list>
</text:list-item>
</text:list>
<text:p text:style-name="Text_20_body">Here&#8217;s another:</text:p>
@@ -1088,7 +1103,8 @@
<text:p text:style-name="P33">Third</text:p>
</text:list-item>
</text:list>
-<text:p text:style-name="Text_20_body">Same thing but with paragraphs:</text:p>
+<text:p text:style-name="Text_20_body">Same thing but with
+paragraphs:</text:p>
<text:list text:style-name="L18">
<text:list-item>
<text:p text:style-name="P35">First</text:p>
@@ -1111,23 +1127,29 @@
<text:p text:style-name="P35">Third</text:p>
</text:list-item>
</text:list>
-<text:h text:style-name="Heading_20_2" text:outline-level="2">Tabs and spaces</text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Tabs and
+spaces</text:h>
<text:list text:style-name="L20">
<text:list-item>
- <text:p text:style-name="P37">this is a list item indented with tabs</text:p>
+ <text:p text:style-name="P37">this is a list item indented with
+ tabs</text:p>
</text:list-item>
<text:list-item>
- <text:p text:style-name="P37">this is a list item indented with spaces</text:p><text:list text:style-name="L21">
- <text:list-item>
- <text:p text:style-name="P38">this is an example list item indented with tabs</text:p>
- </text:list-item>
- <text:list-item>
- <text:p text:style-name="P38">this is an example list item indented with spaces</text:p>
- </text:list-item>
- </text:list>
+ <text:p text:style-name="P37">this is a list item indented with
+ spaces</text:p><text:list text:style-name="L21">
+ <text:list-item>
+ <text:p text:style-name="P38">this is an example list item indented
+ with tabs</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P38">this is an example list item indented
+ with spaces</text:p>
+ </text:list-item>
+ </text:list>
</text:list-item>
</text:list>
-<text:h text:style-name="Heading_20_2" text:outline-level="2">Fancy list markers</text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Fancy list
+markers</text:h>
<text:list text:style-name="L22">
<text:list-item>
<text:p text:style-name="P39">begins with 2</text:p>
@@ -1137,7 +1159,8 @@
<text:p text:style-name="P39">with a continuation</text:p>
<text:list>
<text:list-item>
- <text:p text:style-name="P39">sublist with roman numerals, starting with 4</text:p>
+ <text:p text:style-name="P39">sublist with roman numerals, starting
+ with 4</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P39">more items</text:p>
@@ -1192,21 +1215,26 @@
<text:p text:style-name="Text_20_body">M.A. 2007</text:p>
<text:p text:style-name="Text_20_body">B. Williams</text:p>
<text:p text:style-name="Horizontal_20_Line" />
-<text:h text:style-name="Heading_20_1" text:outline-level="1">Definition Lists</text:h>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Definition
+Lists</text:h>
<text:p text:style-name="Text_20_body">Tight using spaces:</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">apple</text:p>
<text:p text:style-name="Definition_20_Definition_20_Tight">red fruit</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">orange</text:p>
-<text:p text:style-name="Definition_20_Definition_20_Tight">orange fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">orange
+fruit</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">banana</text:p>
-<text:p text:style-name="Definition_20_Definition_20_Tight">yellow fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">yellow
+fruit</text:p>
<text:p text:style-name="Text_20_body">Tight using tabs:</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">apple</text:p>
<text:p text:style-name="Definition_20_Definition_20_Tight">red fruit</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">orange</text:p>
-<text:p text:style-name="Definition_20_Definition_20_Tight">orange fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">orange
+fruit</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">banana</text:p>
-<text:p text:style-name="Definition_20_Definition_20_Tight">yellow fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">yellow
+fruit</text:p>
<text:p text:style-name="Text_20_body">Loose:</text:p>
<text:p text:style-name="Definition_20_Term">apple</text:p>
<text:p text:style-name="Definition_20_Definition">red fruit</text:p>
@@ -1216,15 +1244,19 @@
<text:p text:style-name="Definition_20_Definition">yellow fruit</text:p>
<text:p text:style-name="Text_20_body">Multiple blocks with italics:</text:p>
<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T3">apple</text:span></text:p>
-<text:p text:style-name="Definition_20_Definition">red fruit</text:p><text:p text:style-name="Definition_20_Definition">contains seeds, crisp, pleasant to taste</text:p>
+<text:p text:style-name="Definition_20_Definition">red
+fruit</text:p><text:p text:style-name="Definition_20_Definition">contains
+seeds, crisp, pleasant to taste</text:p>
<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T4">orange</text:span></text:p>
-<text:p text:style-name="Definition_20_Definition">orange fruit</text:p><text:p text:style-name="P42">{ orange code block }</text:p><text:p text:style-name="P43">orange block quote</text:p>
+<text:p text:style-name="Definition_20_Definition">orange fruit</text:p><text:p text:style-name="P42">{ orange code block }</text:p><text:p text:style-name="P43">orange
+block quote</text:p>
<text:p text:style-name="Text_20_body">Multiple definitions, tight:</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">apple</text:p>
<text:p text:style-name="Definition_20_Definition_20_Tight">red fruit</text:p>
<text:p text:style-name="Definition_20_Definition_20_Tight">computer</text:p>
<text:p text:style-name="Definition_20_Term_20_Tight">orange</text:p>
-<text:p text:style-name="Definition_20_Definition_20_Tight">orange fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">orange
+fruit</text:p>
<text:p text:style-name="Definition_20_Definition_20_Tight">bank</text:p>
<text:p text:style-name="Text_20_body">Multiple definitions, loose:</text:p>
<text:p text:style-name="Definition_20_Term">apple</text:p>
@@ -1233,31 +1265,39 @@
<text:p text:style-name="Definition_20_Term">orange</text:p>
<text:p text:style-name="Definition_20_Definition">orange fruit</text:p>
<text:p text:style-name="Definition_20_Definition">bank</text:p>
-<text:p text:style-name="Text_20_body">Blank line after term, indented marker, alternate markers:</text:p>
+<text:p text:style-name="Text_20_body">Blank line after term, indented marker,
+alternate markers:</text:p>
<text:p text:style-name="Definition_20_Term">apple</text:p>
<text:p text:style-name="Definition_20_Definition">red fruit</text:p>
<text:p text:style-name="Definition_20_Definition">computer</text:p>
<text:p text:style-name="Definition_20_Term">orange</text:p>
-<text:p text:style-name="Definition_20_Definition">orange fruit</text:p><text:list text:style-name="L25">
- <text:list-item>
- <text:p text:style-name="P44">sublist</text:p>
- </text:list-item>
- <text:list-item>
- <text:p text:style-name="P44">sublist</text:p>
- </text:list-item>
- </text:list>
-<text:h text:style-name="Heading_20_1" text:outline-level="1">HTML Blocks</text:h>
+<text:p text:style-name="Definition_20_Definition">orange
+fruit</text:p><text:list text:style-name="L25">
+ <text:list-item>
+ <text:p text:style-name="P44">sublist</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P44">sublist</text:p>
+ </text:list-item>
+</text:list>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">HTML
+Blocks</text:h>
<text:p text:style-name="Text_20_body">Simple block on one line:</text:p>
<text:p text:style-name="Text_20_body">foo</text:p>
-<text:p text:style-name="Text_20_body">And nested without indentation:</text:p>
+<text:p text:style-name="Text_20_body">And nested without
+indentation:</text:p>
<text:p text:style-name="Text_20_body">foo</text:p>
<text:p text:style-name="Text_20_body">bar</text:p>
-<text:p text:style-name="Text_20_body">Interpreted markdown in a table:</text:p>
-<text:p text:style-name="Text_20_body">This is <text:span text:style-name="T5">emphasized</text:span></text:p>
-<text:p text:style-name="Text_20_body">And this is <text:span text:style-name="T6">strong</text:span></text:p>
+<text:p text:style-name="Text_20_body">Interpreted markdown in a
+table:</text:p>
+<text:p text:style-name="Text_20_body">This is
+<text:span text:style-name="T5">emphasized</text:span></text:p>
+<text:p text:style-name="Text_20_body">And this is
+<text:span text:style-name="T6">strong</text:span></text:p>
<text:p text:style-name="Text_20_body">Here&#8217;s a simple block:</text:p>
<text:p text:style-name="Text_20_body">foo</text:p>
-<text:p text:style-name="Text_20_body">This should be a code block, though:</text:p>
+<text:p text:style-name="Text_20_body">This should be a code block,
+though:</text:p>
<text:p text:style-name="P45">&lt;div&gt;</text:p>
<text:p text:style-name="P46"><text:s text:c="4" />foo</text:p>
<text:p text:style-name="P47">&lt;/div&gt;</text:p>
@@ -1265,43 +1305,88 @@
<text:p text:style-name="P48">&lt;div&gt;foo&lt;/div&gt;</text:p>
<text:p text:style-name="Text_20_body">Now, nested:</text:p>
<text:p text:style-name="Text_20_body">foo</text:p>
-<text:p text:style-name="Text_20_body">This should just be an HTML comment:</text:p>
+<text:p text:style-name="Text_20_body">This should just be an HTML
+comment:</text:p>
<text:p text:style-name="Text_20_body">Multiline:</text:p>
<text:p text:style-name="Text_20_body">Code block:</text:p>
<text:p text:style-name="P49">&lt;!-- Comment --&gt;</text:p>
-<text:p text:style-name="Text_20_body">Just plain comment, with trailing spaces on the line:</text:p>
+<text:p text:style-name="Text_20_body">Just plain comment, with trailing
+spaces on the line:</text:p>
<text:p text:style-name="Text_20_body">Code:</text:p>
<text:p text:style-name="P50">&lt;hr /&gt;</text:p>
<text:p text:style-name="Text_20_body">Hr&#8217;s:</text:p>
<text:p text:style-name="Horizontal_20_Line" />
-<text:h text:style-name="Heading_20_1" text:outline-level="1">Inline Markup</text:h>
-<text:p text:style-name="Text_20_body">This is <text:span text:style-name="T7">emphasized</text:span>, and so <text:span text:style-name="T8">is</text:span><text:span text:style-name="T9"> </text:span><text:span text:style-name="T10">this</text:span>.</text:p>
-<text:p text:style-name="Text_20_body">This is <text:span text:style-name="T11">strong</text:span>, and so <text:span text:style-name="T12">is</text:span><text:span text:style-name="T13"> </text:span><text:span text:style-name="T14">this</text:span>.</text:p>
-<text:p text:style-name="Text_20_body">An <text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="T15">emphasized</text:span><text:span text:style-name="T16"> </text:span><text:span text:style-name="T17">link</text:span></text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body"><text:span text:style-name="T18">This</text:span><text:span text:style-name="T19"> </text:span><text:span text:style-name="T20">is</text:span><text:span text:style-name="T21"> </text:span><text:span text:style-name="T22">strong</text:span><text:span text:style-name="T23"> </text:span><text:span text:style-name="T24">and</text:span><text:span text:style-name="T25"> </text:span><text:span text:style-name="T26">em</text:span><text:span text:style-name="T27">.</text:span></text:p>
-<text:p text:style-name="Text_20_body">So is <text:span text:style-name="T28">this</text:span> word.</text:p>
-<text:p text:style-name="Text_20_body"><text:span text:style-name="T29">This</text:span><text:span text:style-name="T30"> </text:span><text:span text:style-name="T31">is</text:span><text:span text:style-name="T32"> </text:span><text:span text:style-name="T33">strong</text:span><text:span text:style-name="T34"> </text:span><text:span text:style-name="T35">and</text:span><text:span text:style-name="T36"> </text:span><text:span text:style-name="T37">em</text:span><text:span text:style-name="T38">.</text:span></text:p>
-<text:p text:style-name="Text_20_body">So is <text:span text:style-name="T39">this</text:span> word.</text:p>
-<text:p text:style-name="Text_20_body">This is code: <text:span text:style-name="Teletype">&gt;</text:span>, <text:span text:style-name="Teletype">$</text:span>, <text:span text:style-name="Teletype">\</text:span>, <text:span text:style-name="Teletype">\$</text:span>, <text:span text:style-name="Teletype">&lt;html&gt;</text:span>.</text:p>
-<text:p text:style-name="Text_20_body"><text:span text:style-name="T40">This</text:span><text:span text:style-name="T41"> </text:span><text:span text:style-name="T42">is</text:span><text:span text:style-name="T43"> </text:span><text:span text:style-name="T44">strikeout</text:span><text:span text:style-name="T45">.</text:span></text:p>
-<text:p text:style-name="Text_20_body">Superscripts: a<text:span text:style-name="T46">bc</text:span>d a<text:span text:style-name="T47">hello</text:span> a<text:span text:style-name="T48">hello</text:span><text:span text:style-name="T49"> </text:span><text:span text:style-name="T50">there</text:span>.</text:p>
-<text:p text:style-name="Text_20_body">Subscripts: H<text:span text:style-name="T51">2</text:span>O, H<text:span text:style-name="T52">23</text:span>O, H<text:span text:style-name="T53">many</text:span><text:span text:style-name="T54"> </text:span><text:span text:style-name="T55">of</text:span><text:span text:style-name="T56"> </text:span><text:span text:style-name="T57">them</text:span>O.</text:p>
-<text:p text:style-name="Text_20_body">These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</text:p>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Inline
+Markup</text:h>
+<text:p text:style-name="Text_20_body">This is
+<text:span text:style-name="T7">emphasized</text:span>, and so
+<text:span text:style-name="T8">is</text:span><text:span text:style-name="T9">
+</text:span><text:span text:style-name="T10">this</text:span>.</text:p>
+<text:p text:style-name="Text_20_body">This is
+<text:span text:style-name="T11">strong</text:span>, and so
+<text:span text:style-name="T12">is</text:span><text:span text:style-name="T13">
+</text:span><text:span text:style-name="T14">this</text:span>.</text:p>
+<text:p text:style-name="Text_20_body">An
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="T15">emphasized</text:span><text:span text:style-name="T16">
+</text:span><text:span text:style-name="T17">link</text:span></text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T18">This</text:span><text:span text:style-name="T19">
+</text:span><text:span text:style-name="T20">is</text:span><text:span text:style-name="T21">
+</text:span><text:span text:style-name="T22">strong</text:span><text:span text:style-name="T23">
+</text:span><text:span text:style-name="T24">and</text:span><text:span text:style-name="T25">
+</text:span><text:span text:style-name="T26">em</text:span><text:span text:style-name="T27">.</text:span></text:p>
+<text:p text:style-name="Text_20_body">So is
+<text:span text:style-name="T28">this</text:span> word.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T29">This</text:span><text:span text:style-name="T30">
+</text:span><text:span text:style-name="T31">is</text:span><text:span text:style-name="T32">
+</text:span><text:span text:style-name="T33">strong</text:span><text:span text:style-name="T34">
+</text:span><text:span text:style-name="T35">and</text:span><text:span text:style-name="T36">
+</text:span><text:span text:style-name="T37">em</text:span><text:span text:style-name="T38">.</text:span></text:p>
+<text:p text:style-name="Text_20_body">So is
+<text:span text:style-name="T39">this</text:span> word.</text:p>
+<text:p text:style-name="Text_20_body">This is code:
+<text:span text:style-name="Teletype">&gt;</text:span>,
+<text:span text:style-name="Teletype">$</text:span>,
+<text:span text:style-name="Teletype">\</text:span>,
+<text:span text:style-name="Teletype">\$</text:span>,
+<text:span text:style-name="Teletype">&lt;html&gt;</text:span>.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T40">This</text:span><text:span text:style-name="T41">
+</text:span><text:span text:style-name="T42">is</text:span><text:span text:style-name="T43">
+</text:span><text:span text:style-name="T44">strikeout</text:span><text:span text:style-name="T45">.</text:span></text:p>
+<text:p text:style-name="Text_20_body">Superscripts:
+a<text:span text:style-name="T46">bc</text:span>d
+a<text:span text:style-name="T47">hello</text:span>
+a<text:span text:style-name="T48">hello</text:span><text:span text:style-name="T49"> </text:span><text:span text:style-name="T50">there</text:span>.</text:p>
+<text:p text:style-name="Text_20_body">Subscripts:
+H<text:span text:style-name="T51">2</text:span>O,
+H<text:span text:style-name="T52">23</text:span>O,
+H<text:span text:style-name="T53">many</text:span><text:span text:style-name="T54"> </text:span><text:span text:style-name="T55">of</text:span><text:span text:style-name="T56"> </text:span><text:span text:style-name="T57">them</text:span>O.</text:p>
+<text:p text:style-name="Text_20_body">These should not be superscripts or
+subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
-<text:h text:style-name="Heading_20_1" text:outline-level="1">Smart quotes, ellipses, dashes</text:h>
-<text:p text:style-name="Text_20_body">&#8220;Hello,&#8221; said the spider. &#8220;&#8216;Shelob&#8217; is my name.&#8221;</text:p>
-<text:p text:style-name="Text_20_body">&#8216;A&#8217;, &#8216;B&#8217;, and &#8216;C&#8217; are letters.</text:p>
-<text:p text:style-name="Text_20_body">&#8216;Oak,&#8217; &#8216;elm,&#8217; and &#8216;beech&#8217; are names of trees. So is &#8216;pine.&#8217;</text:p>
-<text:p text:style-name="Text_20_body">&#8216;He said, &#8220;I want to go.&#8221;&#8217; Were you alive in the 70&#8217;s?</text:p>
-<text:p text:style-name="Text_20_body">Here is some quoted &#8216;<text:span text:style-name="Teletype">code</text:span>&#8217; and a &#8220;<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">quoted link</text:span></text:a>&#8221;.</text:p>
-<text:p text:style-name="Text_20_body">Some dashes: one&#8212;two &#8212; three&#8212;four &#8212; five.</text:p>
-<text:p text:style-name="Text_20_body">Dashes between numbers: 5&#8211;7, 255&#8211;66, 1987&#8211;1999.</text:p>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Smart quotes,
+ellipses, dashes</text:h>
+<text:p text:style-name="Text_20_body">&#8220;Hello,&#8221; said the spider.
+&#8220;&#8216;Shelob&#8217; is my name.&#8221;</text:p>
+<text:p text:style-name="Text_20_body">&#8216;A&#8217;, &#8216;B&#8217;, and
+&#8216;C&#8217; are letters.</text:p>
+<text:p text:style-name="Text_20_body">&#8216;Oak,&#8217; &#8216;elm,&#8217;
+and &#8216;beech&#8217; are names of trees. So is &#8216;pine.&#8217;</text:p>
+<text:p text:style-name="Text_20_body">&#8216;He said, &#8220;I want to
+go.&#8221;&#8217; Were you alive in the 70&#8217;s?</text:p>
+<text:p text:style-name="Text_20_body">Here is some quoted
+&#8216;<text:span text:style-name="Teletype">code</text:span>&#8217; and a
+&#8220;<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">quoted
+link</text:span></text:a>&#8221;.</text:p>
+<text:p text:style-name="Text_20_body">Some dashes: one&#8212;two &#8212;
+three&#8212;four &#8212; five.</text:p>
+<text:p text:style-name="Text_20_body">Dashes between numbers: 5&#8211;7,
+255&#8211;66, 1987&#8211;1999.</text:p>
<text:p text:style-name="Text_20_body">Ellipses&#8230;and&#8230;and&#8230;.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">LaTeX</text:h>
<text:list text:style-name="L26">
<text:list-item>
- <text:p text:style-name="P51"><text:span text:style-name="Teletype">\cite[22-23]{smith.1899}</text:span></text:p>
+ <text:p text:style-name="P51"></text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P51">2 + 2 = 4</text:p>
@@ -1319,35 +1404,43 @@
<text:p text:style-name="P51"><text:span text:style-name="T60">p</text:span>-Tree</text:p>
</text:list-item>
<text:list-item>
- <text:p text:style-name="P51">Here&#8217;s some display math: $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</text:p>
+ <text:p text:style-name="P51">Here&#8217;s some display math:
+ $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</text:p>
</text:list-item>
<text:list-item>
- <text:p text:style-name="P51">Here&#8217;s one that has a line break in it: α + ω × <text:span text:style-name="T61">x</text:span><text:span text:style-name="T62">2</text:span>.</text:p>
+ <text:p text:style-name="P51">Here&#8217;s one that has a line break in
+ it:
+ α + ω × <text:span text:style-name="T61">x</text:span><text:span text:style-name="T62">2</text:span>.</text:p>
</text:list-item>
</text:list>
<text:p text:style-name="Text_20_body">These shouldn&#8217;t be math:</text:p>
<text:list text:style-name="L27">
<text:list-item>
- <text:p text:style-name="P52">To get the famous equation, write <text:span text:style-name="Teletype">$e = mc^2$</text:span>.</text:p>
+ <text:p text:style-name="P52">To get the famous equation, write
+ <text:span text:style-name="Teletype">$e = mc^2$</text:span>.</text:p>
</text:list-item>
<text:list-item>
- <text:p text:style-name="P52">$22,000 is a <text:span text:style-name="T63">lot</text:span> of money. So is $34,000. (It worked if &#8220;lot&#8221; is emphasized.)</text:p>
+ <text:p text:style-name="P52">$22,000 is a
+ <text:span text:style-name="T63">lot</text:span> of money. So is $34,000.
+ (It worked if &#8220;lot&#8221; is emphasized.)</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P52">Shoes ($20) and socks ($5).</text:p>
</text:list-item>
<text:list-item>
- <text:p text:style-name="P52">Escaped <text:span text:style-name="Teletype">$</text:span>: $73 <text:span text:style-name="T64">this</text:span><text:span text:style-name="T65"> </text:span><text:span text:style-name="T66">should</text:span><text:span text:style-name="T67"> </text:span><text:span text:style-name="T68">be</text:span><text:span text:style-name="T69"> </text:span><text:span text:style-name="T70">emphasized</text:span> 23$.</text:p>
+ <text:p text:style-name="P52">Escaped
+ <text:span text:style-name="Teletype">$</text:span>: $73
+ <text:span text:style-name="T64">this</text:span><text:span text:style-name="T65">
+ </text:span><text:span text:style-name="T66">should</text:span><text:span text:style-name="T67">
+ </text:span><text:span text:style-name="T68">be</text:span><text:span text:style-name="T69">
+ </text:span><text:span text:style-name="T70">emphasized</text:span>
+ 23$.</text:p>
</text:list-item>
</text:list>
<text:p text:style-name="Text_20_body">Here&#8217;s a LaTeX table:</text:p>
-<text:p text:style-name="Text_20_body"><text:span text:style-name="Teletype">\begin{tabular}{|l|l|}\hline
-Animal &amp; Number \\ \hline
-Dog <text:s text:c="3" />&amp; 2 <text:s text:c="5" />\\
-Cat <text:s text:c="3" />&amp; 1 <text:s text:c="5" />\\ \hline
-\end{tabular}</text:span></text:p>
<text:p text:style-name="Horizontal_20_Line" />
-<text:h text:style-name="Heading_20_1" text:outline-level="1">Special Characters</text:h>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Special
+Characters</text:h>
<text:p text:style-name="Text_20_body">Here is some unicode:</text:p>
<text:list text:style-name="L28">
<text:list-item>
@@ -1366,8 +1459,10 @@ Cat <text:s text:c="3" />&amp; 1 <text:s text:c="5" />\\ \hline
<text:p text:style-name="P53">copyright: ©</text:p>
</text:list-item>
</text:list>
-<text:p text:style-name="Text_20_body">AT&amp;T has an ampersand in their name.</text:p>
-<text:p text:style-name="Text_20_body">AT&amp;T is another way to write it.</text:p>
+<text:p text:style-name="Text_20_body">AT&amp;T has an ampersand in their
+name.</text:p>
+<text:p text:style-name="Text_20_body">AT&amp;T is another way to write
+it.</text:p>
<text:p text:style-name="Text_20_body">This &amp; that.</text:p>
<text:p text:style-name="Text_20_body">4 &lt; 5.</text:p>
<text:p text:style-name="Text_20_body">6 &gt; 5.</text:p>
@@ -1390,35 +1485,63 @@ Cat <text:s text:c="3" />&amp; 1 <text:s text:c="5" />\\ \hline
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">Links</text:h>
<text:h text:style-name="Heading_20_2" text:outline-level="2">Explicit</text:h>
-<text:p text:style-name="Text_20_body">Just a <text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">URL</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title"><text:span text:style-name="Definition">URL and title</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title preceded by two spaces"><text:span text:style-name="Definition">URL and title</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title preceded by a tab"><text:span text:style-name="Definition">URL and title</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title with &quot;quotes&quot; in it"><text:span text:style-name="Definition">URL and title</text:span></text:a></text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title with single quotes"><text:span text:style-name="Definition">URL and title</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body">Just a
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">URL</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title"><text:span text:style-name="Definition">URL
+and title</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title preceded by two spaces"><text:span text:style-name="Definition">URL
+and title</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title preceded by a tab"><text:span text:style-name="Definition">URL
+and title</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title with &quot;quotes&quot; in it"><text:span text:style-name="Definition">URL
+and title</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title with single quotes"><text:span text:style-name="Definition">URL
+and title</text:span></text:a></text:p>
<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/with_underscore" office:name=""><text:span text:style-name="Definition">with_underscore</text:span></text:a></text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition">Email link</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition">Email
+link</text:span></text:a></text:p>
<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="" office:name=""><text:span text:style-name="Definition">Empty</text:span></text:a>.</text:p>
<text:h text:style-name="Heading_20_2" text:outline-level="2">Reference</text:h>
-<text:p text:style-name="Text_20_body">Foo <text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Foo <text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Foo <text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">With <text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">embedded [brackets]</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">b</text:span></text:a> by itself should be a link.</text:p>
-<text:p text:style-name="Text_20_body">Indented <text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">once</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Indented <text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">twice</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Indented <text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">thrice</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">With
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">embedded
+[brackets]</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">b</text:span></text:a>
+by itself should be a link.</text:p>
+<text:p text:style-name="Text_20_body">Indented
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">once</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Indented
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">twice</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Indented
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">thrice</text:span></text:a>.</text:p>
<text:p text:style-name="Text_20_body">This should [not][] be a link.</text:p>
<text:p text:style-name="P54">[not]: /url</text:p>
-<text:p text:style-name="Text_20_body">Foo <text:a xlink:type="simple" xlink:href="/url/" office:name="Title with &quot;quotes&quot; inside"><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Foo <text:a xlink:type="simple" xlink:href="/url/" office:name="Title with &quot;quote&quot; inside"><text:span text:style-name="Definition">biz</text:span></text:a>.</text:p>
-<text:h text:style-name="Heading_20_2" text:outline-level="2">With ampersands</text:h>
-<text:p text:style-name="Text_20_body">Here&#8217;s a <text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">link with an ampersand in the URL</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Here&#8217;s a link with an amersand in the link text: <text:a xlink:type="simple" xlink:href="http://att.com/" office:name="AT&amp;T"><text:span text:style-name="Definition">AT&amp;T</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Here&#8217;s an <text:a xlink:type="simple" xlink:href="/script?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">inline link</text:span></text:a>.</text:p>
-<text:p text:style-name="Text_20_body">Here&#8217;s an <text:a xlink:type="simple" xlink:href="/script?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">inline link in pointy braces</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name="Title with &quot;quotes&quot; inside"><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name="Title with &quot;quote&quot; inside"><text:span text:style-name="Definition">biz</text:span></text:a>.</text:p>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">With
+ampersands</text:h>
+<text:p text:style-name="Text_20_body">Here&#8217;s a
+<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">link
+with an ampersand in the URL</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Here&#8217;s a link with an amersand in
+the link text:
+<text:a xlink:type="simple" xlink:href="http://att.com/" office:name="AT&amp;T"><text:span text:style-name="Definition">AT&amp;T</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Here&#8217;s an
+<text:a xlink:type="simple" xlink:href="/script?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">inline
+link</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Here&#8217;s an
+<text:a xlink:type="simple" xlink:href="/script?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">inline
+link in pointy braces</text:span></text:a>.</text:p>
<text:h text:style-name="Heading_20_2" text:outline-level="2">Autolinks</text:h>
-<text:p text:style-name="Text_20_body">With an ampersand: <text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/?foo=1&amp;bar=2</text:span></text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body">With an ampersand:
+<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/?foo=1&amp;bar=2</text:span></text:span></text:a></text:p>
<text:list text:style-name="L29">
<text:list-item>
<text:p text:style-name="P55">In a list?</text:p>
@@ -1430,25 +1553,55 @@ Cat <text:s text:c="3" />&amp; 1 <text:s text:c="5" />\\ \hline
<text:p text:style-name="P55">It should.</text:p>
</text:list-item>
</text:list>
-<text:p text:style-name="Text_20_body">An e-mail address: <text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">nobody@nowhere.net</text:span></text:span></text:a></text:p>
-<text:p text:style-name="P56">Blockquoted: <text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/</text:span></text:span></text:a></text:p>
-<text:p text:style-name="Text_20_body">Auto-links should not occur here: <text:span text:style-name="Teletype">&lt;http://example.com/&gt;</text:span></text:p>
+<text:p text:style-name="Text_20_body">An e-mail address:
+<text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">nobody@nowhere.net</text:span></text:span></text:a></text:p>
+<text:p text:style-name="P56">Blockquoted:
+<text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="Teletype">http://example.com/</text:span></text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body">Auto-links should not occur here:
+<text:span text:style-name="Teletype">&lt;http://example.com/&gt;</text:span></text:p>
<text:p text:style-name="P57">or here: &lt;http://example.com/&gt;</text:p>
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">Images</text:h>
-<text:p text:style-name="Text_20_body">From &#8220;Voyage dans la Lune&#8221; by Georges Melies (1902):</text:p>
+<text:p text:style-name="Text_20_body">From &#8220;Voyage dans la Lune&#8221;
+by Georges Melies (1902):</text:p>
<text:p text:style-name="Text_20_body"><draw:frame><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p>
-<text:p text:style-name="Text_20_body">Here is a movie <draw:frame><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame> icon.</text:p>
+<text:p text:style-name="Text_20_body">Here is a movie
+<draw:frame><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame>
+icon.</text:p>
<text:p text:style-name="Horizontal_20_Line" />
<text:h text:style-name="Heading_20_1" text:outline-level="1">Footnotes</text:h>
-<text:p text:style-name="Text_20_body">Here is a footnote reference,<text:note text:id="ftn0" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</text:p></text:note-body></text:note> and another.<text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>2</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here&#8217;s the long note. This one contains multiple blocks.</text:p><text:p text:style-name="Footnote">Subsequent blocks are indented to show that they belong to the footnote (as with list items).</text:p><text:p text:style-name="P58"><text:s text:c="2" />{ &lt;code&gt; }</text:p><text:p text:style-name="Footnote">If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</text:p></text:note-body></text:note> This should <text:span text:style-name="T71">not</text:span> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>3</text:note-citation><text:note-body><text:p text:style-name="Footnote">This is <text:span text:style-name="T72">easier</text:span> to type. Inline notes may contain <text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a> and <text:span text:style-name="Teletype">]</text:span> verbatim characters, as well as [bracketed text].</text:p></text:note-body></text:note></text:p>
-<text:p text:style-name="P59">Notes can go in quotes.<text:note text:id="ftn3" text:note-class="footnote"><text:note-citation>4</text:note-citation><text:note-body><text:p text:style-name="Footnote">In quote.</text:p></text:note-body></text:note></text:p>
+<text:p text:style-name="Text_20_body">Here is a footnote
+reference,<text:note text:id="ftn0" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here
+is the footnote. It can go anywhere after the footnote reference. It need not
+be placed at the end of the document.</text:p></text:note-body></text:note>
+and
+another.<text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>2</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here&#8217;s
+the long note. This one contains multiple
+blocks.</text:p><text:p text:style-name="Footnote">Subsequent blocks are
+indented to show that they belong to the footnote (as with list
+items).</text:p><text:p text:style-name="P58"><text:s text:c="2" />{ &lt;code&gt; }</text:p><text:p text:style-name="Footnote">If
+you want, you can indent every line, but you can also be lazy and just indent
+the first line of each block.</text:p></text:note-body></text:note> This
+should <text:span text:style-name="T71">not</text:span> be a footnote
+reference, because it contains a space.[^my note] Here is an inline
+note.<text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>3</text:note-citation><text:note-body><text:p text:style-name="Footnote">This
+is <text:span text:style-name="T72">easier</text:span> to type. Inline notes
+may contain
+<text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a>
+and <text:span text:style-name="Teletype">]</text:span> verbatim characters,
+as well as [bracketed text].</text:p></text:note-body></text:note></text:p>
+<text:p text:style-name="P59">Notes can go in
+quotes.<text:note text:id="ftn3" text:note-class="footnote"><text:note-citation>4</text:note-citation><text:note-body><text:p text:style-name="Footnote">In
+quote.</text:p></text:note-body></text:note></text:p>
<text:list text:style-name="L30">
<text:list-item>
- <text:p text:style-name="P60">And in list items.<text:note text:id="ftn4" text:note-class="footnote"><text:note-citation>5</text:note-citation><text:note-body><text:p text:style-name="Footnote">In list.</text:p></text:note-body></text:note></text:p>
+ <text:p text:style-name="P60">And in list
+ items.<text:note text:id="ftn4" text:note-class="footnote"><text:note-citation>5</text:note-citation><text:note-body><text:p text:style-name="Footnote">In
+ list.</text:p></text:note-body></text:note></text:p>
</text:list-item>
</text:list>
-<text:p text:style-name="Text_20_body">This paragraph should not be part of the note, as it is not indented.</text:p>
+<text:p text:style-name="Text_20_body">This paragraph should not be part of
+the note, as it is not indented.</text:p>
</office:text>
</office:body>
</office:document-content>
diff --git a/tests/writer.org b/tests/writer.org
new file mode 100644
index 000000000..642b2a3ef
--- /dev/null
+++ b/tests/writer.org
@@ -0,0 +1,774 @@
+#+TITLE: Pandoc Test Suite
+
+#+AUTHOR: John MacFarlane; Anonymous
+#+DATE: July 17, 2006
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
+
+--------------
+
+* Headers
+
+** Level 2 with an [[/url][embedded link]]
+
+*** Level 3 with /emphasis/
+
+**** Level 4
+
+***** Level 5
+
+* Level 1
+
+** Level 2 with /emphasis/
+
+*** Level 3
+
+with no blank line
+
+** Level 2
+
+with no blank line
+
+--------------
+
+* Paragraphs
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here's one with a bullet. * criminey.
+
+There should be a hard line break
+here.
+
+--------------
+
+* Block Quotes
+
+E-mail style:
+
+#+BEGIN_QUOTE
+ This is a block quote. It is pretty short.
+#+END_QUOTE
+
+#+BEGIN_QUOTE
+ Code in a block quote:
+
+ #+BEGIN_EXAMPLE
+ sub status {
+ print "working";
+ }
+ #+END_EXAMPLE
+
+ A list:
+
+ 1. item one
+ 2. item two
+
+ Nested block quotes:
+
+ #+BEGIN_QUOTE
+ nested
+ #+END_QUOTE
+
+ #+BEGIN_QUOTE
+ nested
+ #+END_QUOTE
+#+END_QUOTE
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+--------------
+
+* Code Blocks
+
+Code:
+
+#+BEGIN_EXAMPLE
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+#+END_EXAMPLE
+
+And:
+
+#+BEGIN_EXAMPLE
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+#+END_EXAMPLE
+
+--------------
+
+* Lists
+
+** Unordered
+
+Asterisks tight:
+
+- asterisk 1
+- asterisk 2
+- asterisk 3
+
+Asterisks loose:
+
+- asterisk 1
+
+- asterisk 2
+
+- asterisk 3
+
+Pluses tight:
+
+- Plus 1
+- Plus 2
+- Plus 3
+
+Pluses loose:
+
+- Plus 1
+
+- Plus 2
+
+- Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+** Ordered
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
+
+2. Item 2.
+
+3. Item 3.
+
+** Nested
+
+- Tab
+
+ - Tab
+
+ - Tab
+
+Here's another:
+
+1. First
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+** Tabs and spaces
+
+- this is a list item indented with tabs
+
+- this is a list item indented with spaces
+
+ - this is an example list item indented with tabs
+
+ - this is an example list item indented with spaces
+
+** Fancy list markers
+
+2) begins with 2
+3) and now 3
+
+ with a continuation
+
+ 4. sublist with roman numerals, starting with 4
+ 5. more items
+
+ 1) a subsublist
+ 2) a subsublist
+
+Nesting:
+
+1. Upper Alpha
+
+ 1. Upper Roman.
+
+ 6) Decimal start with 6
+
+ 3) Lower alpha with paren
+
+Autonumbering:
+
+1. Autonumber.
+2. More.
+
+ 1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+--------------
+
+* Definition Lists
+
+Tight using spaces:
+
+- apple :: red fruit
+- orange :: orange fruit
+- banana :: yellow fruit
+
+Tight using tabs:
+
+- apple :: red fruit
+- orange :: orange fruit
+- banana :: yellow fruit
+
+Loose:
+
+- apple :: red fruit
+
+- orange :: orange fruit
+
+- banana :: yellow fruit
+
+Multiple blocks with italics:
+
+- /apple/ :: red fruit
+
+ contains seeds, crisp, pleasant to taste
+
+- /orange/ :: orange fruit
+
+ #+BEGIN_EXAMPLE
+ { orange code block }
+ #+END_EXAMPLE
+
+ #+BEGIN_QUOTE
+ orange block quote
+ #+END_QUOTE
+
+Multiple definitions, tight:
+
+- apple :: red fruit
+ computer
+- orange :: orange fruit
+ bank
+
+Multiple definitions, loose:
+
+- apple :: red fruit
+
+ computer
+
+- orange :: orange fruit
+
+ bank
+
+Blank line after term, indented marker, alternate markers:
+
+- apple :: red fruit
+
+ computer
+
+- orange :: orange fruit
+
+ 1. sublist
+ 2. sublist
+
+* HTML Blocks
+
+Simple block on one line:
+
+#+BEGIN_HTML
+ <div>
+#+END_HTML
+
+foo
+
+#+BEGIN_HTML
+ </div>
+#+END_HTML
+
+And nested without indentation:
+
+#+BEGIN_HTML
+ <div>
+ <div>
+ <div>
+#+END_HTML
+
+foo
+
+#+BEGIN_HTML
+ </div>
+ </div>
+ <div>
+#+END_HTML
+
+bar
+
+#+BEGIN_HTML
+ </div>
+ </div>
+#+END_HTML
+
+Interpreted markdown in a table:
+
+#+BEGIN_HTML
+ <table>
+ <tr>
+ <td>
+#+END_HTML
+
+This is /emphasized/
+
+#+BEGIN_HTML
+ </td>
+ <td>
+#+END_HTML
+
+And this is *strong*
+
+#+BEGIN_HTML
+ </td>
+ </tr>
+ </table>
+
+ <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+#+END_HTML
+
+Here's a simple block:
+
+#+BEGIN_HTML
+ <div>
+
+#+END_HTML
+
+foo
+
+#+BEGIN_HTML
+ </div>
+#+END_HTML
+
+This should be a code block, though:
+
+#+BEGIN_EXAMPLE
+ <div>
+ foo
+ </div>
+#+END_EXAMPLE
+
+As should this:
+
+#+BEGIN_EXAMPLE
+ <div>foo</div>
+#+END_EXAMPLE
+
+Now, nested:
+
+#+BEGIN_HTML
+ <div>
+ <div>
+ <div>
+
+#+END_HTML
+
+foo
+
+#+BEGIN_HTML
+ </div>
+ </div>
+ </div>
+#+END_HTML
+
+This should just be an HTML comment:
+
+#+BEGIN_HTML
+ <!-- Comment -->
+#+END_HTML
+
+Multiline:
+
+#+BEGIN_HTML
+ <!--
+ Blah
+ Blah
+ -->
+
+ <!--
+ This is another comment.
+ -->
+#+END_HTML
+
+Code block:
+
+#+BEGIN_EXAMPLE
+ <!-- Comment -->
+#+END_EXAMPLE
+
+Just plain comment, with trailing spaces on the line:
+
+#+BEGIN_HTML
+ <!-- foo -->
+#+END_HTML
+
+Code:
+
+#+BEGIN_EXAMPLE
+ <hr />
+#+END_EXAMPLE
+
+Hr's:
+
+#+BEGIN_HTML
+ <hr>
+
+ <hr />
+
+ <hr />
+
+ <hr>
+
+ <hr />
+
+ <hr />
+
+ <hr class="foo" id="bar" />
+
+ <hr class="foo" id="bar" />
+
+ <hr class="foo" id="bar">
+#+END_HTML
+
+--------------
+
+* Inline Markup
+
+This is /emphasized/, and so /is this/.
+
+This is *strong*, and so *is this*.
+
+An /[[/url][emphasized link]]/.
+
+*/This is strong and em./*
+
+So is */this/* word.
+
+*/This is strong and em./*
+
+So is */this/* word.
+
+This is code: =>=, =$=, =\=, =\$=, =<html>=.
+
++This is /strikeout/.+
+
+Superscripts: a^{bc}d a^{/hello/} a^{hello there}.
+
+Subscripts: H_{2}O, H_{23}O, H_{many of them}O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\^b c\^d, a~b c~d.
+
+--------------
+
+* Smart quotes, ellipses, dashes
+
+"Hello," said the spider. "'Shelob' is my name."
+
+'A', 'B', and 'C' are letters.
+
+'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'
+
+'He said, "I want to go."' Were you alive in the 70's?
+
+Here is some quoted '=code=' and a "[[http://example.com/?foo=1&bar=2][quoted
+link]]".
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses...and...and....
+
+--------------
+
+* LaTeX
+
+- \cite[22-23]{smith.1899}
+- $2+2=4$
+- $x \in y$
+- $\alpha \wedge \omega$
+- $223$
+- $p$-Tree
+- Here's some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+- Here's one that has a line break in it: $\alpha + \omega \times x^2$.
+
+These shouldn't be math:
+
+- To get the famous equation, write =$e = mc^2$=.
+- $22,000 is a /lot/ of money. So is $34,000. (It worked if "lot" is
+ emphasized.)
+- Shoes ($20) and socks ($5).
+- Escaped =$=: $73 /this should be emphasized/ 23$.
+
+Here's a LaTeX table:
+
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+
+--------------
+
+* Special Characters
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: \_
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+--------------
+
+* Links
+
+** Explicit
+
+Just a [[/url/][URL]].
+
+[[/url/][URL and title]].
+
+[[/url/][URL and title]].
+
+[[/url/][URL and title]].
+
+[[/url/][URL and title]]
+
+[[/url/][URL and title]]
+
+[[/url/with_underscore][with\_underscore]]
+
+[[mailto:nobody@nowhere.net][Email link]]
+
+[[][Empty]].
+
+** Reference
+
+Foo [[/url/][bar]].
+
+Foo [[/url/][bar]].
+
+Foo [[/url/][bar]].
+
+With [[/url/][embedded [brackets]]].
+
+[[/url/][b]] by itself should be a link.
+
+Indented [[/url][once]].
+
+Indented [[/url][twice]].
+
+Indented [[/url][thrice]].
+
+This should [not][] be a link.
+
+#+BEGIN_EXAMPLE
+ [not]: /url
+#+END_EXAMPLE
+
+Foo [[/url/][bar]].
+
+Foo [[/url/][biz]].
+
+** With ampersands
+
+Here's a [[http://example.com/?foo=1&bar=2][link with an ampersand in the
+URL]].
+
+Here's a link with an amersand in the link text: [[http://att.com/][AT&T]].
+
+Here's an [[/script?foo=1&bar=2][inline link]].
+
+Here's an [[/script?foo=1&bar=2][inline link in pointy braces]].
+
+** Autolinks
+
+With an ampersand: [[http://example.com/?foo=1&bar=2]]
+
+- In a list?
+- [[http://example.com/]]
+- It should.
+
+An e-mail address: [[mailto:nobody@nowhere.net][=nobody@nowhere.net=]]
+
+#+BEGIN_QUOTE
+ Blockquoted: [[http://example.com/]]
+#+END_QUOTE
+
+Auto-links should not occur here: =<http://example.com/>=
+
+#+BEGIN_EXAMPLE
+ or here: <http://example.com/>
+#+END_EXAMPLE
+
+--------------
+
+* Images
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+#+CAPTION: lalune
+
+[[lalune.jpg]]
+Here is a movie [[movie.jpg]] icon.
+
+--------------
+
+* Footnotes
+
+Here is a footnote reference, [1] and another. [2] This should /not/ be a
+footnote reference, because it contains a space.[\^my note] Here is an inline
+note. [3]
+
+#+BEGIN_QUOTE
+ Notes can go in quotes. [4]
+#+END_QUOTE
+
+1. And in list items. [5]
+
+This paragraph should not be part of the note, as it is not indented.
+
+[1] Here is the footnote. It can go anywhere after the footnote reference. It
+ need not be placed at the end of the document.
+
+[2] Here's the long note. This one contains multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).
+
+ #+BEGIN_EXAMPLE
+ { <code> }
+ #+END_EXAMPLE
+
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
+
+[3] This is /easier/ to type. Inline notes may contain
+ [[http://google.com][links]] and =]= verbatim characters, as well as
+ [bracketed text].
+
+[4] In quote.
+
+[5] In list.
diff --git a/tests/writer.plain b/tests/writer.plain
index bc6d25467..cc61916d2 100644
--- a/tests/writer.plain
+++ b/tests/writer.plain
@@ -2,9 +2,8 @@ Pandoc Test Suite
John MacFarlane; Anonymous
July 17, 2006
-This is a set of tests for pandoc. Most of them are adapted from
-John Gruber’s markdown test suite.
-
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
* * * * *
@@ -35,7 +34,6 @@ Level 2
with no blank line
-
* * * * *
Paragraphs
@@ -43,16 +41,15 @@ Paragraphs
Here’s a regular paragraph.
-In Markdown 1.0.0 and earlier. Version 8. This line turns into a
-list item. Because a hard-wrapped line in the middle of a paragraph
-looked like a list item.
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
Here’s one with a bullet. * criminey.
There should be a hard line break
here.
-
* * * * *
Block Quotes
@@ -63,27 +60,26 @@ E-mail style:
This is a block quote. It is pretty short.
Code in a block quote:
-
+
sub status {
print "working";
}
-
+
A list:
-
+
1. item one
2. item two
-
+
Nested block quotes:
-
+
nested
-
+
nested
This should not be a block quote: 2 > 1.
And a following paragraph.
-
* * * * *
Code Blocks
@@ -92,19 +88,18 @@ Code Blocks
Code:
---- (should be four hyphens)
-
+
sub status {
print "working";
}
-
+
this code block is indented by one tab
And:
this code block is indented by two tabs
-
- These should not be escaped: \$ \\ \> \[ \{
+ These should not be escaped: \$ \\ \> \[ \{
* * * * *
@@ -128,7 +123,6 @@ Asterisks loose:
- asterisk 3
-
Pluses tight:
- Plus 1
@@ -143,7 +137,6 @@ Pluses loose:
- Plus 3
-
Minuses tight:
- Minus 1
@@ -158,7 +151,6 @@ Minuses loose:
- Minus 3
-
Ordered
-------
@@ -182,7 +174,6 @@ Loose using tabs:
3. Third
-
and using spaces:
1. One
@@ -191,19 +182,16 @@ and using spaces:
3. Three
-
Multiple paragraphs:
1. Item 1, graf one.
- Item 1. graf two. The quick brown fox jumped over the lazy dog’s
- back.
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
2. Item 2.
3. Item 3.
-
Nested
------
@@ -211,8 +199,6 @@ Nested
- Tab
- Tab
-
-
Here’s another:
1. First
@@ -235,7 +221,6 @@ Same thing but with paragraphs:
3. Third
-
Tabs and spaces
---------------
@@ -247,8 +232,6 @@ Tabs and spaces
- this is an example list item indented with spaces
-
-
Fancy list markers
------------------
@@ -262,8 +245,6 @@ Fancy list markers
(A) a subsublist
(B) a subsublist
-
-
Nesting:
A. Upper Alpha
@@ -271,23 +252,18 @@ A. Upper Alpha
(6) Decimal start with 6
c) Lower alpha with paren
-
-
-
Autonumbering:
1. Autonumber.
2. More.
1. Nested.
-
Should not be a list item:
M.A. 2007
B. Williams
-
* * * * *
Definition Lists
@@ -322,7 +298,6 @@ orange
banana
yellow fruit
-
Multiple blocks with italics:
apple
@@ -337,7 +312,6 @@ orange
orange block quote
-
Multiple definitions, tight:
apple
@@ -359,7 +333,6 @@ orange
bank
-
Blank line after term, indented marker, alternate markers:
apple
@@ -373,7 +346,6 @@ orange
1. sublist
2. sublist
-
HTML Blocks
===========
@@ -420,7 +392,6 @@ Code:
Hr’s:
-
* * * * *
Inline Markup
@@ -448,9 +419,8 @@ Superscripts: abcd ahello ahello there.
Subscripts: H2O, H23O, Hmany of themO.
-These should not be superscripts or subscripts, because of the
-unescaped spaces: a^b c^d, a~b c~d.
-
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
* * * * *
@@ -473,7 +443,6 @@ Dashes between numbers: 5–7, 255–66, 1987–1999.
Ellipses…and…and….
-
* * * * *
LaTeX
@@ -487,22 +456,18 @@ LaTeX
- p-Tree
- Here’s some display math:
\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
-- Here’s one that has a line break in it:
- \alpha + \omega \times x^2.
+- Here’s one that has a line break in it: \alpha + \omega \times x^2.
These shouldn’t be math:
- To get the famous equation, write $e = mc^2$.
-- $22,000 is a lot of money. So is $34,000. (It worked if “lot”
- is emphasized.)
+- $22,000 is a lot of money. So is $34,000. (It worked if “lot” is
+ emphasized.)
- Shoes ($20) and socks ($5).
- Escaped $: $73 this should be emphasized 23$.
Here’s a LaTeX table:
-
-
-
* * * * *
Special Characters
@@ -558,7 +523,6 @@ Plus: +
Minus: -
-
* * * * *
Links
@@ -640,7 +604,6 @@ Auto-links should not occur here: <http://example.com/>
or here: <http://example.com/>
-
* * * * *
Images
@@ -648,48 +611,41 @@ Images
From “Voyage dans la Lune” by Georges Melies (1902):
+[lalune]
-
-Here is a movie icon.
-
+Here is a movie [movie] icon.
* * * * *
Footnotes
=========
-Here is a footnote reference,[^1] and another.[^2] This should not
-be a footnote reference, because it contains a space.[^my note]
-Here is an inline note.[^3]
+Here is a footnote reference,[^1] and another.[^2] This should not be a
+footnote reference, because it contains a space.[^my note] Here is an inline
+note.[^3]
Notes can go in quotes.[^4]
1. And in list items.[^5]
-This paragraph should not be part of the note, as it is not
-indented.
+This paragraph should not be part of the note, as it is not indented.
-[^1]:
- Here is the footnote. It can go anywhere after the footnote
- reference. It need not be placed at the end of the document.
+[^1]: Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
-[^2]:
- Here’s the long note. This one contains multiple blocks.
+[^2]: Here’s the long note. This one contains multiple blocks.
- Subsequent blocks are indented to show that they belong to the
- footnote (as with list items).
+ Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).
{ <code> }
- If you want, you can indent every line, but you can also be lazy
- and just indent the first line of each block.
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
-[^3]:
- This is easier to type. Inline notes may contain links and ]
- verbatim characters, as well as [bracketed text].
+[^3]: This is easier to type. Inline notes may contain links and ] verbatim
+ characters, as well as [bracketed text].
-[^4]:
- In quote.
+[^4]: In quote.
-[^5]:
- In list.
+[^5]: In list.
diff --git a/tests/writer.rst b/tests/writer.rst
index dff04bc81..189886a87 100644
--- a/tests/writer.rst
+++ b/tests/writer.rst
@@ -9,8 +9,8 @@ Pandoc Test Suite
.. role:: math(raw)
:format: html latex
-This is a set of tests for pandoc. Most of them are adapted from
-John Gruber’s markdown test suite.
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
--------------
@@ -52,9 +52,9 @@ Paragraphs
Here’s a regular paragraph.
-In Markdown 1.0.0 and earlier. Version 8. This line turns into a
-list item. Because a hard-wrapped line in the middle of a paragraph
-looked like a list item.
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
Here’s one with a bullet. \* criminey.
@@ -70,7 +70,6 @@ E-mail style:
This is a block quote. It is pretty short.
-
Code in a block quote:
::
@@ -81,7 +80,6 @@ E-mail style:
A list:
-
1. item one
2. item two
@@ -89,11 +87,8 @@ E-mail style:
nested
-
nested
-
-
This should not be a block quote: 2 > 1.
And a following paragraph.
@@ -108,11 +103,11 @@ Code:
::
---- (should be four hyphens)
-
+
sub status {
print "working";
}
-
+
this code block is indented by one tab
And:
@@ -120,7 +115,7 @@ And:
::
this code block is indented by two tabs
-
+
These should not be escaped: \$ \\ \> \[ \{
--------------
@@ -133,123 +128,101 @@ Unordered
Asterisks tight:
-
- asterisk 1
- asterisk 2
- asterisk 3
Asterisks loose:
-
- asterisk 1
- asterisk 2
- asterisk 3
-
Pluses tight:
-
- Plus 1
- Plus 2
- Plus 3
Pluses loose:
-
- Plus 1
- Plus 2
- Plus 3
-
Minuses tight:
-
- Minus 1
- Minus 2
- Minus 3
Minuses loose:
-
- Minus 1
- Minus 2
- Minus 3
-
Ordered
-------
Tight:
-
1. First
2. Second
3. Third
and:
-
1. One
2. Two
3. Three
Loose using tabs:
-
1. First
2. Second
3. Third
-
and using spaces:
-
1. One
2. Two
3. Three
-
Multiple paragraphs:
-
1. Item 1, graf one.
- Item 1. graf two. The quick brown fox jumped over the lazy dog’s
- back.
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
2. Item 2.
3. Item 3.
-
Nested
------
-
- Tab
-
- - Tab
-
- - Tab
+ - Tab
+ - Tab
Here’s another:
-
1. First
2. Second:
-
+
- Fee
- Fie
- Foe
@@ -258,74 +231,57 @@ Here’s another:
Same thing but with paragraphs:
-
1. First
2. Second:
-
- Fee
- Fie
- Foe
3. Third
-
Tabs and spaces
---------------
-
- this is a list item indented with tabs
- this is a list item indented with spaces
-
- this is an example list item indented with tabs
- this is an example list item indented with spaces
-
-
Fancy list markers
------------------
-
(2) begins with 2
(3) and now 3
with a continuation
-
iv. sublist with roman numerals, starting with 4
v. more items
-
+
(A) a subsublist
(B) a subsublist
-
-
Nesting:
-
A. Upper Alpha
-
- I. Upper Roman.
-
- (6) Decimal start with 6
-
- c) Lower alpha with paren
+ I. Upper Roman.
+ (6) Decimal start with 6
+ c) Lower alpha with paren
Autonumbering:
-
#. Autonumber.
#. More.
-
- #. Nested.
+ #. Nested.
Should not be a list item:
@@ -367,7 +323,6 @@ orange
banana
yellow fruit
-
Multiple blocks with italics:
*apple*
@@ -384,8 +339,6 @@ Multiple blocks with italics:
orange block quote
-
-
Multiple definitions, tight:
apple
@@ -407,7 +360,6 @@ orange
bank
-
Blank line after term, indented marker, alternate markers:
apple
@@ -418,36 +370,32 @@ apple
orange
orange fruit
-
1. sublist
2. sublist
-
HTML Blocks
===========
Simple block on one line:
-
.. raw:: html
<div>
-
+
foo
.. raw:: html
</div>
-
-And nested without indentation:
+And nested without indentation:
.. raw:: html
<div>
<div>
<div>
-
+
foo
.. raw:: html
@@ -455,30 +403,29 @@ foo
</div>
</div>
<div>
-
+
bar
.. raw:: html
</div>
</div>
-
-Interpreted markdown in a table:
+Interpreted markdown in a table:
.. raw:: html
<table>
<tr>
<td>
-
+
This is *emphasized*
.. raw:: html
</td>
<td>
-
+
And this is **strong**
.. raw:: html
@@ -486,23 +433,22 @@ And this is **strong**
</td>
</tr>
</table>
-
+
<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
-
-Here’s a simple block:
+Here’s a simple block:
.. raw:: html
<div>
-
+
foo
.. raw:: html
</div>
-
+
This should be a code block, though:
::
@@ -519,14 +465,13 @@ As should this:
Now, nested:
-
.. raw:: html
<div>
<div>
<div>
-
+
foo
.. raw:: html
@@ -534,16 +479,14 @@ foo
</div>
</div>
</div>
-
-This should just be an HTML comment:
+This should just be an HTML comment:
.. raw:: html
<!-- Comment -->
-
-Multiline:
+Multiline:
.. raw:: html
@@ -551,11 +494,11 @@ Multiline:
Blah
Blah
-->
-
+
<!--
This is another comment.
-->
-
+
Code block:
::
@@ -564,11 +507,10 @@ Code block:
Just plain comment, with trailing spaces on the line:
-
.. raw:: html
<!-- foo -->
-
+
Code:
::
@@ -577,27 +519,26 @@ Code:
Hr’s:
-
.. raw:: html
<hr>
-
+
<hr />
-
+
<hr />
-
+
<hr>
-
+
<hr />
-
+
<hr />
-
+
<hr class="foo" id="bar" />
-
+
<hr class="foo" id="bar" />
-
+
<hr class="foo" id="bar">
-
+
--------------
Inline Markup
@@ -621,14 +562,12 @@ This is code: ``>``, ``$``, ``\``, ``\$``, ``<html>``.
[STRIKEOUT:This is *strikeout*.]
-Superscripts: a\ :sup:`bc`\ d a\ :sup:`*hello*`\
-a\ :sup:`hello there`\ .
+Superscripts: a\ :sup:`bc`\ d a\ :sup:`*hello*`\ a\ :sup:`hello there`\ .
-Subscripts: H\ :sub:`2`\ O, H\ :sub:`23`\ O,
-H\ :sub:`many of them`\ O.
+Subscripts: H\ :sub:`2`\ O, H\ :sub:`23`\ O, H\ :sub:`many of them`\ O.
-These should not be superscripts or subscripts, because of the
-unescaped spaces: a^b c^d, a~b c~d.
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
--------------
@@ -643,8 +582,8 @@ Smart quotes, ellipses, dashes
‘He said, “I want to go.”’ Were you alive in the 70’s?
-Here is some quoted ‘``code``’ and a
-“`quoted link <http://example.com/?foo=1&bar=2>`_”.
+Here is some quoted ‘``code``’ and a “`quoted
+link <http://example.com/?foo=1&bar=2>`_”.
Some dashes: one—two — three—four — five.
@@ -657,7 +596,6 @@ Ellipses…and…and….
LaTeX
=====
-
-
- :math:`$2+2=4$`
- :math:`$x \in y$`
@@ -671,16 +609,21 @@ LaTeX
These shouldn’t be math:
-
- To get the famous equation, write ``$e = mc^2$``.
-- $22,000 is a *lot* of money. So is $34,000. (It worked if “lot”
- is emphasized.)
+- $22,000 is a *lot* of money. So is $34,000. (It worked if “lot” is
+ emphasized.)
- Shoes ($20) and socks ($5).
- Escaped ``$``: $73 *this should be emphasized* 23$.
Here’s a LaTeX table:
+.. raw:: latex
+ \begin{tabular}{|l|l|}\hline
+ Animal & Number \\ \hline
+ Dog & 2 \\
+ Cat & 1 \\ \hline
+ \end{tabular}
--------------
@@ -689,7 +632,6 @@ Special Characters
Here is some unicode:
-
- I hat: Î
- o umlaut: ö
- section: §
@@ -796,11 +738,10 @@ Foo `biz </url/>`_.
With ampersands
---------------
-Here’s a
-`link with an ampersand in the URL <http://example.com/?foo=1&bar=2>`_.
+Here’s a `link with an ampersand in the
+URL <http://example.com/?foo=1&bar=2>`_.
-Here’s a link with an amersand in the link text:
-`AT&T <http://att.com/>`_.
+Here’s a link with an amersand in the link text: `AT&T <http://att.com/>`_.
Here’s an `inline link </script?foo=1&bar=2>`_.
@@ -811,7 +752,6 @@ Autolinks
With an ampersand: http://example.com/?foo=1&bar=2
-
- In a list?
- http://example.com/
- It should.
@@ -820,7 +760,6 @@ An e-mail address: nobody@nowhere.net
Blockquoted: http://example.com/
-
Auto-links should not occur here: ``<http://example.com/>``
::
@@ -837,9 +776,8 @@ From “Voyage dans la Lune” by Georges Melies (1902):
.. figure:: lalune.jpg
:align: center
:alt: Voyage dans la Lune
-
- lalune
+ lalune
Here is a movie |movie| icon.
--------------
@@ -847,40 +785,37 @@ Here is a movie |movie| icon.
Footnotes
=========
-Here is a footnote reference, [1]_ and another. [2]_ This should
-*not* be a footnote reference, because it contains a space.[^my
-note] Here is an inline note. [3]_
+Here is a footnote reference, [1]_ and another. [2]_ This should *not* be a
+footnote reference, because it contains a space.[^my note] Here is an inline
+note. [3]_
Notes can go in quotes. [4]_
-
-
1. And in list items. [5]_
-This paragraph should not be part of the note, as it is not
-indented.
+This paragraph should not be part of the note, as it is not indented.
.. [1]
- Here is the footnote. It can go anywhere after the footnote
- reference. It need not be placed at the end of the document.
+ Here is the footnote. It can go anywhere after the footnote reference. It
+ need not be placed at the end of the document.
.. [2]
Here’s the long note. This one contains multiple blocks.
- Subsequent blocks are indented to show that they belong to the
- footnote (as with list items).
+ Subsequent blocks are indented to show that they belong to the footnote (as
+ with list items).
::
{ <code> }
- If you want, you can indent every line, but you can also be lazy
- and just indent the first line of each block.
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
.. [3]
This is *easier* to type. Inline notes may contain
- `links <http://google.com>`_ and ``]`` verbatim characters, as well
- as [bracketed text].
+ `links <http://google.com>`_ and ``]`` verbatim characters, as well as
+ [bracketed text].
.. [4]
In quote.
diff --git a/tests/writer.rtf b/tests/writer.rtf
index 3cb1d2996..6bca9387f 100644
--- a/tests/writer.rtf
+++ b/tests/writer.rtf
@@ -277,7 +277,6 @@ quoted link
{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Shoes ($20) and socks ($5).\par}
{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Escaped {\f1 $}: $73 {\i this should be emphasized} 23$.\sa180\par}
{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a LaTeX table:\par}
-{\pard \ql \f0 \sa180 \li0 \fi0 \par}
{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Special Characters\par}
{\pard \ql \f0 \sa180 \li0 \fi0 Here is some unicode:\par}
@@ -430,8 +429,8 @@ inline link in pointy braces
{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Images\par}
{\pard \ql \f0 \sa180 \li0 \fi0 From \u8220"Voyage dans la Lune\u8221" by Georges Melies (1902):\par}
-{\pard \ql \f0 \sa180 \li0 \fi0 {\cf1 [image: lalune.jpg]\cf0}\par}
-{\pard \ql \f0 \sa180 \li0 \fi0 Here is a movie {\cf1 [image: movie.jpg]\cf0} icon.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\pict\jpegblip ffd8ffe000104a46494600010101007800780000ffdb00430006040506050406060506070706080a100a0a09090a140e0f0c1017141818171416161a1d251f1a1b231c1616202c20232627292a29191f2d302d283025282928ffdb0043010707070a080a130a0a13281a161a2828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828ffc000110800fa00fa03011100021101031101ffc4001c0000000701010000000000000000000000010203040506070008ffc4003e100002010303020404040502050500030001020300041105122106311322415107617181143291a1234252b1c115f016336272d1082443e1f1265382ffc40017010101010100000000000000000000000000010204ffc4001b11010101010003010000000000000000000001110212213141ffda000c03010002110311003f00dadd18a10a704f6a95ccc57e37750782b0d8d9ea0cd32e7c5446e07e9f4ad723119a7b89e61e348f260719278aad613cbb640002938c76a182b264fc87bd13009c0c019c76e3d68a072e1cf6f4cd502d330c28269a61bb39c923923d4fad44c08dccb95cfd28b8280769ee08a263891e1808739e4f1d8d149392172cc714050dbb9fde8960ed8c60b79b1ed44103b05c331dbdb1dc5026ac1946d20ff8140aa631c773ec738a0346a003bf93e9cf02801895e7b9a01886796c923bd0090a06393c76a0142003ce3d86680d8dd9392303f5341ccc1b3cf7a2c812c37e4923d381429757013209fa511c18146c9247a0f6a007900c0c671c6280854e086c673eb45c27c038fd68aedff2fda836ef881f136f25d5e6b7d1262964aa02b03f98fbf153131935edcc97576f35c33349212cc4f39f7ab26186dfce5b200f73451f7600dcb8cf27e7400c0b291914046c9e0718fde81371b8e7273f4ef4007691919240e714097f31f376e7b5008caee27807b0f5a02c8e1b3c6d27d33cd0201d839523144d1a149ae084b78da47638211771fd050d582c3a0faab5119b6d12f8ab1c06788a0fd4e2ac356fd1fe08754ddccaba849696309e598c9e2103fed1dcfdeadc44fea5ff00a7f956366d375e492403ca935bedcf1eea4ff6ac68a55efc1beb3b552574f8e7009ff933a927ec715bc82b3a8f4d6bba5ca1352d22fe061cf9a0383f71dea5119cc6c0baed3eaac0f1fad40897dcc3d81f7a052366c1007df3400f21edefc5008c28f30c9c5170ee4fc37830086395250a7c66770c18e78da31c0c63de8609b41f7c515c5172a30c3b76344a3e377cb2339cf7a242aea89808cce368272b8c1a2e107c672a49f5c1a181c9c7ae7da8a2119e7b1f5068099ffa68258a132062d8f9e0f34059502b61bf2824e681bb297ced2a71efda80f19c47b9c77fdbe74057c13e539cf3c1a0eeeb9c73f33405ddb4f18249c1e28062b79ae242902024465b9214614649e7bd0362a7249eddc513456e5720f38f5a1a98e96e95d6baa6ebc2d1ad1e65521649bb469f563534d6d7d31f04347d2a2fc5f535db6a0e83718906c887cbbe5a9a8bef44dce9f731ca9a2e89169d6d6f2184b1455dc07b11dcfeb4d16f119c649a681285b03d3e5500f87820ff006a0e098191de80ac9b8904647b55d11da9681a56a31f87a869f6970b8ffe4883629a289aefc16e92d441682da5b098f21ed9f033f353914d19b751fc08d66cc16d12fe2bf45ec92ff0df1fdbfb559ec667aff4eeb1a04db359d3ae6d40eccebe53f46ec7f5ab82263da7dcf3eb5174e5181076918c7de869503232491ee4515c1803824f03b51287f30e0e7d803449494832c157278a2e8c71fcb9f9d144639236824d01e142efb1768cfb9c7ef40512a818de78ff00a682518e7cc30ab9e00a02cce9953247bd41e467191ed9a04205ee99da4e4e3d283a524b0427b5026c18a8e082067db8341ce0e39ed409b6502907391edda80f2dfdc496f0c124ac6184b144cf0a4e338fd2894f7a7342d4ba9b568f4fd261f12571966270a8bfd47d8511bae85f02b47b7fc34bac5d5c5dc88a0c90ab6c8d9bedce3ef4d1ad691a6dae976a96d616d15b409f9638d70054a1dbc68ea51d4329f4619a8022b78e04548515117b05000a035c5c4702a995c26e3819f534047bcb68a458cce866719540724d02e41c0f7a012a40f6141cbc8e7bd01719e38e6838af1c0a04ca8206d3cd037bdb082fad9e0bd8a39e0718649141047d0d5d18f759fc0cd3af164b8e9999acae4e4f81236e898f7c0f55fed574615aee83a96817ef67abda3db4ebdb7f66f983d88a061bb8db9e3d45165076db83c1f950a53780d8247c80a2398f182724f1c7ad080c608cfa7a51a0062adc7afbd0130173bb9c5070f071cb37e82826106e8f615e01c9e680d6b35bc534be3c1e3831b2aa962bb188f2b71df1de819ae4b1048c7f57bd01a58268e332642ae0704f7cf6207af6a01b99e17b7b6416e227407c494139909ed9f4c0a04a4e501e0f1eb40d263e53dce7fa682c9d0bd13abf58dd6db18bc2b157c4975270ab8ef8f563f21447a73a03a1f4de8eb031582b497328066b97fcd21ff038edfde88b7e32703bd64188e7e6283864b73400cd804b67ca3268317eacea6d56ff005233592f8b6303f953fa4af7c2fa93417fe98b763e0ea171297bab98558068f695ce0e08fdbd281e5c6a57ba5e9d14d716ef7774f2ec112601da4f27ec2827ada74bab559a20e148fcae36b0f91140283729c77a0e0a7777a01dac68395719e39a029607cb901b19c501480ab9279f4a086ea8d0b48d76c0586b7143224a76c61ce1831fe93e86b43cd1f12fe19ea7d2533dcdbeebcd20b612651e68f9ece3fcf6fa5067cbcf20ff009a051724905411e94032799060723da8406d6c67e7ea68d0e1770fe5cfb5026c37039ef9a02eca098c91e6e01e71c500b1d8a49c12786cf6a06a4e256008e3d050119958007920e2801154e32fb4120927b014017eb1c523ac5209a356215c291b87be28957ef853f0d66eaa99352d515e1d190f947669ce7b0ffa7e74a8f4be996569a5d9c56b6704705b46bb5238d42851f2ac875712bc70b3c30f892019540704d01ad2669a0491936330c95ce7140b2e4939a03638c7e8680ae485e33bbe540d60d3ada162c90a02c7270a39340a4f28b68da4645007a8f6a069a746f73235ddcefc391e12b2e1916824948742c99382473c73404791c617695279dc0640f9502c578c9efeb4095cb4cb0830ba21cf999c6401f4f5a05061d430c8079a02e03b3004311c7d281b5e3cd676c65489ee594e4aafe6c7ae07a9a0a075bbea3a8ea96f047d3935ebc404f04ad29411e08e011d98fed416fd212ee5b05b4d5ad6300c615807f1171eaa49eff5ad418c7c55f8466dd66d57a521f20cbcd66a7247a9283dbe5418a63862479877cf1f6c5008e400bdf1ce684016fe53dfbd1a73794600e08ce3d6800377c8c7d6800a9cf75fd4503d91492460f7ee3d28247a7b459f5fd592d22711c206f9e563858a31f99cfd050583518ba75247b1d134f9aed21396d4669769931dc01c003f7a329c4d17458ac5b55d36c12e040a3f1da75c1cb04ede2447f7f6a94567ad7a66db4fbbb29ba7d65b8b4bd8ccd09c8231eaa07b8ab04a7c2cf87b3f53ea8d77abc72c1a5dabe2452bb5a561fc83e5ee7e541e988218ed2dd22b7855228d76a46a00000ec00a510bd4dd511f4fe84da95cc31f880022da4902b1e7d3e99ac86fd03d631f565b4ee6d4dbbc649009cab2e48c83f514165b8b94b6895c44f279c280839e78ce28178ae6de46748a789e453865570483ec6812d42e85a421fc37918b00a883924d024c6e99b7a2a966c0009e17dc9f9fed40f81c77e28139218e4ff9815b9cf23340a01c907b9140201038ed402fcafd28386464e4fd33c50272bc60032609cf00fbd024f722dc66f24822ddf972f8feff00e280f69b24844919cac9ce7de83a447f30ded823007b50459d6ecacb528349b979127651b1dc795f1f3f7a0990148054823dc5015d491c0a0c3be337c2ff00c489b5ee9c87172016b9b541c49ff5a8f7f71eb560c1fc43e0a47e1aa94277310431f91fa551c1727f29ed409b641c86e31839a3454805739c1f6a026f1fd740f64665fc8c31cfde82db79bb40e9e8f49b62eb7d7e8b717ec832c91ff247fa1dc7df2281bcc9369d671493c422b7911654c1215f92bb8827bf068624ba635392df5eb4b9924558ee5bc19b71cee43c6dc7cf34c657be8db0b0b9d0f51d2afe668934dbf9628ddb8c2b8c0073f3a80da37546a7d25174fd95dc125c69f7313ee5655dfc313bd483cf07b1f6a68d5b48d5ec758b612e9d7293211c8fe653f35ee2a084eb9e8bb1eafb3582fe496278f3e1c919fcb9f97ad03ee8dd017a6741b6d3229dae161057c5750a48249ec3eb4139238568f6a9e7b103b5037934cb3793c610a2cd9277a8da73f5140ee38f6280c4b11c65b934023006d50050030e4647de80c846de3b500fcf9fbd0197273ed4007b91400e580c8e45074a82400e72682b36fd2162b7f25ddc09af2766ceeb872db79cf00f6a0b3229550140e07007a50092db860673de818df473c862686dad6470d9cce3b7b63e740fa1de6252ebb5bd81cd00bee2d800d003a6464004763ce683ce9f1cbe1f1d3a67ea1d1a30b68edffba814708c7f9c63d0fafceaca31e6dc71e1f07daa82608c83819f7a1a11ce149238fd68d0a579ec682cfd27a7c3a86bd10bc38b3b756b8b93c1fe1a8c91f7381f7a034f752ea5aa5c5eb292f732128037619c018f6ec282e5a2cb047abda74d5ce9b6da80f136de4a496219b3e48c92000323ea73467519d3da5bb757dbda410ac90c77c23058f99007ee7ec31416882ee47d23acb5185caf8bab4691b1efe57fff0038a9457ee75a82f6e7429350466b482f2742c0f74241c80c38c64541a9cfa1e89ac0177d33ab3d8de28f2b5bca429f91140e2c7a9b5ae9fb85b6ea9b46b9b3c796fe040768f76ec0fafb1f9505df4ebdb3d4edd6e74db98ee216fe68ce47d280648f75e2485a44da385ddc13f4a025ddbdbea16a633286566ce55f9c8f6c502ad750db2c514f30dec428247e6340bbf04100b73402afb943ed2b9e30683836defe9403bc1e06734020e06280cafe8683a375941d841c77c1a0151b467b50159f00e4127e5402872371040c5046eb5aadbe9b1c02e2f6dad25b89047099c677b7b0140fe3f1010afc803f3018e68160c3041ee2823f5dba92d34db89a1d9e2843b03b6d05bd013560c1748d57aa2797c6b35bab78e6959dc47231580ff336dcfb03c1a58364b5bbb7d7fa7b7427f1f673830c8664285bd1815238fad20f2c7c41e979ba43aa2e2c1cb1b663bede438f3a13c7dc76fb5515e9065b851f7a02950002a09c51a1b83cf14176e90d3645e9ad7752752aac23b3439c066665c827e944d29a6410aea725c4567135bd840d3c88a723728c29c9efe6c50d3ee9545b0bf8ef2e6e3c2fc2c6f72f2920e5f19039ee4938a9a875d03278377acf52ddf867f036ef71923932bfe51fbd3475cdc369df0db4fb389d4ea37970fa9cc0b00511795ce7d4f181eb4cd2451755fc45ac16d637381b14ca36b641dfce723e4053170d6cb52bbb362f6d3cb19241f2b9029862f09f143549ba7e7d2eef6caf2797c66ee17fdfd69862d1a069da7dfdac579d17adcda5ea9e1a992376c4723e39e3b024fd7e94c458ac3e25dee8d31d3bae74e7b79002bf8b8549471db38f5f4ed4c165e943a06a328d4ba605b4b22a1523c420c64fbaf38a82d36f0ce7cf7463790729b53017e940e0b0ceceed8ce0500e1b70daa08f5c9ed41d271cd0132476e7d7ff00aa069797d2411168ed9a41fcc858211f73c5075acb25ca6fb82aa31e58a36c81f561dcd033d42169e158ac64b98151b3981c2966cf639f4a064c7a8ac55e4865b7d493701e1c8e52403ea3cbfda827e390ca3f2c914aa81991bd281cdacc2747215c60e0ee5c67e940cb51b0b2bcbd824bfb08ee1a252d1caea1821cfa67b1fa504982b2283ce08f518a08abb82f6dd0369a5662081e14ce40c7ae1b04fda82275cb0bfd4f4536f7114589a5412461f3e4ce4e0e060f63f6ab2893d3b4b5b5b78e22ed22aae3cc3cc7e64fad3449a22a461500007602a0cd7e3b74c26b5d2ad79147baf34eccca40e4a7f30ff3f6aba3cd0543267eb5427b86f1f4c76ef45d0eca1ad5ef224d13e1cf4fd9b22192fa67bc955f8c8c617fba9fb510d7a6ed3fd43a735e5b54964be658c048fb6cdd9e7eb8a186bac97d174e6d22e23437b7ac26b95e77c68bf950fa7279e2b22dba45b59e97a669fa4ea36aeff89cea9a90451fc355ff0096ad9f4ce3f41570675d4fa8c77da8de5cde5be26bc653171ca47dc1f6c9fed5562b97f70276808da7c24f0c1c63804e33fa8a2928c0e0383c8f7ed41d92a41393f4a2548595c2c37493db4cd04e8a08f139566edfef3445b6e7aeaf65d2df48ea2b11776ae02a93e564c772adef409f4ee8ba9a21d73a36fa579ad9f325afe599171ed9c30a960d5ba0fe2843abb47a6f510fc26a4c36890f9558fcc6783506a1147b510024e30339ce680d2c6ae9861eb9a009178a0205443b989e39cd01d8075e3047ce80563057ca381ed4011c4531e503d85013c91b804a21279c903341131cda8c3abdc8650f6d20c4321232adec3dc504bab2c113c9293bb1963df3408dd4b75e1efb2856463dbc43b4631fad047e9177ad4fe32ea16b1db4b8fe1aa92571f5f5a0916bc8e0895af5c46c17cd8c9ff7da80f6d736f7f6915c59cab35bc837238ed8a072a31c1ef4062870718a06f7702dc5b3c522ee4752ae0fa8230683c75d6ba3b74ef535fe984929149e4278ca9e47edfdab42058003763ed409f88ffd6dfad06b1f12ae612fa0c76e0b471e9916d23f973eb4158d3efeff004a984da5debc1295d8e4018dbf3145d583a2ad96f356bbd7f5d90dc59587f1e79a6392f28fcaa3ee47159444ea3aa5ddfc7acf50dcdc344d7a4dbc317f52641200f6000fdeb41b5ef51d8eab672ffa9e971c97c11638268e431a46000012a3b9a351567db823b11f3ef40948e428048207a8340ab48ae83cb83ee0f3428a982719edf3e68c9cc97d3fe15ad8c9be138f2bf38e7b8f6ef40f7a5f55bdd3f56b46d3649127f1405f08e7249c76f5fa50689d48ba5f545cdcbdb462cba9206411b2b055bb07d4fb1c73528d4fa8f52d62cf47b6b8d2e65fc458c49f8a818795c151939f977a823ba0fe253750eb7fe937b04293f9f6c90be41dbdc7ff006283473c1efc1a06f69776d73bbf0f2aca32572bc80470450284a46dfca19f819f5a04e799614def26c0bdce09cfd85045dc75769d12dc3c3e2491db0dd3c85195235f7c91cfd066ae0cdba9be31f4ec61a386c1ef9d4ee473e45cfb1cf34c101d3ff1ac9d481d46c628ed24751881880833f988e7b0fa5328dfed2f2def2ce2b9b79925b791772ca87208f7a60182ee2b95cc0c48f53823fbd40ac658b30f4f4a086d4ee1d75bb6b78f4e965596366fc5211b23238008fde81f43692da5bc30d97831a0397dc09e3d714087506bf61a2c4cd77324726d2caaec141f9fd2ae0c435bf8c57173ad7876f7a2daca10489121244cdf319ce3dbf5a834fe81f881a6f57bcb6ba7c53c72c11873e28cee1db391dbef4199ff00ea4348116a5a66a8a8a04aad04847a90723f6ad7d18c312ddc02a3815423ba0f63fa541687bd9efe1b533b3c9e0a78473e899e318a09bd0ba6eef543e3b2bd8e9b10064bd9e4da001dc81401aeeb29a984d0ba7d5e1d06d4e6594f06523bc8e7f5c0ac8af752dfc17d7090d9218ec6d9447129ee71fcc4fb9cd6842ab10dc0014f3e5a2c1704b671dfdc734525226dc939e283a362c7f940344a380393df144733e2276e38f5efcd01b4bbbfc3dda4a9298a44395902e4a9c70682660d4265d62de40b1bdc1545054f95c8fe627df141af7c3af8808f3dd68dd5d2a45765884b8908d8c3b6c27b7a77a945d7a5fa474bd2ba8e4d5748b28624955d5d8b13b79ee9e983d8d40a753758c7a46b96f6114725dc92279a2810b3a64f94900763cfafa503fd3b59b79ed84da34713c0cd890f0a158fa1f981de826e1b548959fc4dc5cee24b6467e59ed4101ff19e9f676baa5d6a72c50adb4ad1ac790ccc076200f7ad41e7df881d79a87576a5f87b0f161d381db1c2a36e7e6d8ff3416bf87ff082c6f208ef7a82f22b9761bd6d619785f6dc477fa53705ab57f83bd297ceb1e9caf67708db9c4526723e849e3e94f212dd25d117fd29a8c09a76b534fa39cf8b6b71ced38e36fb73417f52e64548e34007e673e9f21ef590a1c918c90718dc281a69b68f67118d9da5058b798f6fa7fe280daadd1b2d36eae70710c4d263df0a4d583cc7a668fd4bf11b5837d7c93dcd9a3146959822a0e781f4cfa55161e9dd7fa67a4f55b9e9aea3e9f81fc09ca0ba118998fcdb2338c7b528d39f4cd2ba76e2d357d292df4eb391809963420ce1b1b576fa1e7359119f1eb4e17dd033ca172d6b2a4df303383fdeb5c8f2eef3bce4e0e335684cb0c9f354160d36f64b0baf16072b91b5f03391f43c51aab23a5debe91c4fad4d73689e6fc3a290573ff4f03e59f4a3280d67581ce916567f84b58ce0a1fccec3d58fa9a084de08c90464e4d1a8e419059b201f4a05630a176918efc50176293872c17bf14042aa0125b03db14046c60b60123fde6827fa0c68edd5365ff11346ba6292ee64194240c807e59a32b7fc51bfe8bd5ed5db424860beb62b89218422ce09c11c01dbbd0660ae110bf1bf2154838dbebfefeb41a8f4cdac7f117458f4d9ecd2df53b4cf81a822808c47255c0f7c8e7fb54a2ec2cfabba3b4b4b8d3af12eedad40926b0f070a13f9b633649f7a82eba6ea4357d321d4ecad512daf20df26e016507fa4fbfaf3e98f9d067dd2bd2faac9aa4d72d72d1e9510ca46a7631c7a320e18f1dfd7bd059afb7da816d23de4ba5de211346a1e4785f190548e4648c63b64e6b43ce9d5baafe3b539c5b452dbda46c638a167cb281c73ee4ff9340e3a3fa5f5aea4ba58f4bb57dbfcf2b02a8bf7f7a0de3a5fa0b50d2a2d92eb3e048c0a97c867dbedcf6a944e5cf4f6b76d1b3d8ea42795066266c87c81c65b9cfaf15048e83af3cd64abac08edaf01546c38dae4e0657ee6826e5b892de3702292e2545ddb55700fd0fbfca81c4b3bc718716eef9eeaa402280d14ab3c0b2c65c06fe571823ed40df56b217fa6dd5ab9216689a33f2c8c558307e83b8d77a37aaa7d22f2512c28768800c9954671b3d33ebef568d0ef7a7749eb0b5bbbb162d657b32b46d2e1564c8ed9c5644d1b0b9bbd261d2a440af6cb0e2e5b1e7dbc1238e0f7a0375b696daa7496a3a4dac8a92cf078685b271db04d391e40d5ec4586a1716de2a49e0c8c85d3b120f715ba1899173ff305413070abd89cfe9f5a2d3ee9c8639fa874eb6b804c52dc46b20c9f302c3bd11e84d47e1af4d5dc6521d3e3b662c19a58721ff5a9a321f89bd27a374b456d158dccd34d333332c9b4b2afbe47a7cb1f7aa33d2bc0d8c0f1c8f6a2c14b6d501b39cf63450897380c319e3de8065031c038f7ed40d8faf1ce41e4d004876a8dc3cc7e743025c956c818028c904579e7f0e15695c9c0541924f6c00283d0bf07f42d6b48820b8d62d20b2b58d656404959e52f83c8ff00fcfafbd4a35bb06f12391a48dd55cee2b2f3818ed8f6a8158a159890f02242079147623e631c502b0db436d1ecb7458d4738038fb0a087d6eeb508f48bb7d32d95750752b6c26c905b3ddb6f61eb574794f5cb6b9d0fa9678b512b25d24bbe52b8c1638278fbd582c57ff12afaed45b5bc0d0d8a8c08a2731ee3eec5793f40450466a1d59af446293c186cd53ca0c36eab93dc649e49fbd048e89f1675ed35e301e293919dcbf9867b37cbe94a35fe94ea4d33aba6824306dc48015750d86c6e247b0cf63591a40b8dc23fc30f14138dcac3000f9d03687547f12e8dd5af816b13148dddbcd29039c0f6f6f7a0eb5d62caf5636825db70c9bc4328f0dc0271c8a090627d3073ce681acf6505ccf14d35bc2f2c2731bb28254fb8a075144a83ca806792400334049ee6281e2496408656d880ff0031f61fa50446bd76058ea1b9e21025a3bb48afe71df9c7b71de9c8f196a0de23ca7b827d4f7add117e0cbfd4b5059392369663ff004e71c51aa97e8f555eadd258f2bf8a889cff00dc28cbd0bf123a926e96d163bdb74490bca2321c678209ff001591e71eafd7a7d7ef45cde2c20aae144638033fb9ad2e1b5e69d058da431ccf21d4a5c3b4631b62523807feaf5c7a50222f2d648c25f5aeec8c2cd19dae3d3e87e944d3eb7e90d425b49ef2292de38224f1505c3f8724a9eeaa7bd0d57a60406059436306868a7803839c7ad1a158039c13f4a33a716767f8cb9b6b55e1ae2458813e9938cd07a9f42d0b4de99b4b7d1f41b58ff19b03c93ba06607fa8b1f5f619a5b8266d74a65d42da6ba90cce996dcdc8c9fff006a5a2c2635083b05ef83eb5028076341db4b1ed9f7a04651fc41db18ed419d75b744dbea335fcb0db0335f2057901c05da73c8f9d5d18a75174a3f4c47335e35da4ce418a489374254f707d463d33565d1529b569a489a17944b06ec8057d71dcd037b4b6b8bfba31584124b27e62a8a4f1ea68357f83da7ea5a76bfe0912453ccabb49194653cb60f6ce3dfda983d196cd108c2401711f9768e306b2297d73fc6d02773a8b591922693c5004bb9d72542fa2f6efde8314ff867aeeec27500b77bb5670e36ca19b1dff2e7f2fd2837ce8bd5dd348b78b552219022870d9c46e792a4f6c608a0b846c8e03232b29ec41cd0199f1410fd4b24b1e8f712c0a5e4452d851e6c639dbf3238a0afa42ba77475e4ba8470896681da45180b18da76af3c9029c8f26dc1df2b9c606e273e86b743331924f27f4a82c12280e59b008e79f6a2d4d74188ff00e30d203a82ad7519c1ff00b860d11ba7c5e86c9fa3afae6f4091e043e021270b21e01c7dcd6479ab4dd3aeb56be4b7b184cf2b301b57d07bfd2b4bad0fe25e9f6960ba7c7a55ac50cd750335ccaade7723b83b8f6e38a2207a5ba4e7ea3d93780cb616ca53781f99fbff009a0b675a5be9765d43a75a6ad3b25adb4185429b831c70303dfdfd2831eb8954ca48f3827819c71ed406b2b1b9bf9a5fc1c4ce2253238047957dc9345d122b792eee522811a495ce1157b93ed444ff0049f476b1aaf51c761345269d25be269259570c833c6077249e062a68f53e8ef0da69509d4ae225b92a04af232ab16f98cf1f4a5a266d4dbca8af13a329ecca723f51502d14f0cb9f05d1c8ee01c91f6a0393b4edfe63c8a031608859b38f97340d84d04e5846eae50f9829ce3eb400fb24466041f5e3d2823f56d22db57b192d6e61468a41c823ff0035651916bbf04ada7badda5cad6d1b72c09dc33f2a6875d25f0865d06fe2bc6d4c4d3282026cca8cfafcfd29a34cd234a10c768f711a78f1bb392a3001208e3ec69a26a58d640c832091c90706a084ea1d3eeafdadf4f86da3166c0b4b397c18f046140f5ce4d04f4702436e91c28a9122e028ed8a0a9f5a5b6a09a1bc5a135bc72cce048b3c5bc15c638f9d59043fc2db997481aa69dae49e1cb6bb643239211939e467818f97bd305965ebce9a10bc8da9dbaa2679dd9ce3d8530572cfac87566ab05ae9f1490692b9696e1f833738555f96793504df5f25945d2576b7ec16dc46792381c7b7ad5e60f234980e42f6c9c56a82ec3eff00bd4124e49700f1c646e3cd169ce9575f83d52cee324347323f6e3861ff008a23d47d4ba6a75074fdcd8ef317e2e2ff0098bdd4706a60c3f4ae8cd5f44eb8fc3e97248a638cbc73bf90483d463b373e9574685abf42a6b5649fea72bbdeac4a8d3b018cfae31f7a6895b6b29b41d30d8e9f6bbed9213e1b7a994e724fcbb5064bd7835a9752d3af75d8116354778f660788cbd9483dbb0a0cd20b2b8d43528ad2088bdcccf854039cff00e2827a0d34e9da1de896f2182492efc0976f998aa827d3d334113a74aa9a9298628e74570478bc0c7cf1da83724bb8246d3e6416b0384da61b5501c9f5c3704f152c037561a95f5fce61d3ad6db4ab950f34b331dd9f4191db8fdcd406d67a675ab4b6d325d1af248272a43430315ddec7038f6ad4b3f448bf47eb71cb69abddebf21d5e26896203846c30c8603b9c6452d9835901405660376319ac84bf13180779d8bb82827d4fb0a06f777367a75acd7170f1430a9f331200cfceae061a0cf6dac692d7365266191db0578f5edf3a6075a6c9278b3433188a467860d96fbd40fe540471409aa0c1140750001ed8ed4058e15133c983960077edf6a06faade5c5b7822d2d926766cb967da2341dd8f0727d85033d27597d62e2ee3163756915bbf8799d71e2f19dcbf2a092b88dd9a311950a0e5b70ce47fe6ac18af53f5b69da9752dd69da9ca906876e24465d9e69881c6ff005c679c0aa2bfd267a347512c93dbb5d42d90d3c800b68c9ce0ec3cfa528db74ad034db5905ee8be1ac728dc153984f3f980f4fb56453be2de8f647a6aff53796596f0aed46798ec033ce149c0fb0ad71479c9bb9dc3bf3c55a0b95f65a825150b481a407b93c0fda8a29c06671dc93803bd131eafd0af6dffe18d2ee25982a4b04603b7a9c631fad03bbe586381bc5945b96385718c827db3eb5288eb8ba934eb15fc3c535f05427796dcccdec7150637d5bd55d5362b7975aa4d0d919018adec8637807bb60723000e4f7cd58203538aefa8aeb478a7b9beba924547b8774cf8608036a80704639cf1f9855d1a7f4c68b67a03de5e5d59dad8d988c62e1c0f107a1e7fdf7a082ea6d07a6e3e99375a7cb6b3db093c727701e2360f7f53dfb50653d4130d42ee18f48b3f0232a15218936963ebf5fbd06dbf0cfa74855b9d46e04b730c6144691e12307d33ea7de8348ba6b5478a279a004f98c479247b81f5a9438805ac0be2e02e73c9ef8fbd40c2346d43578eefc40da7da1dc8b8eefea4fcb9fef419beabf12a4bcebcb2d2fa7ee0dc58492084b30236bb6467dce383f6a0b87556a67a7f4d95a0bbb5468816f0a69c78b2e072572719ce78357079dfab3af2e7a92c963b88d94abbbf91cedc93edf418aa2c5f0dbe2a6a9a0c90d8de34773a6a8da1186d6403fa48fec682d9adeb7a9b4c9d572dacc9a6c9700456e5ca910e000ecbd8e580352fb1ae7476bd6dd49a325e5a9f3025245fe961dea097523cc0919a032af039a006936c81423104649c703ef40dcce64bc3035a87b6f0c378f9fe7cf2b8fdf340a4b6e25962915d94a67807839f7a043586922b5636ec44c061063f31f6ab079d7fe19b7eb2d4efeef55d5d74f992e9a0fc3a441dcb13927b838c9aa2d4bf042c618e178efee6e18104870172318edf5c1e6945bbe1a748ea7d2315edbea3a99bcb190030c401010e4e783ee0fa56455be3d6b90c1a6268d69e17f1486900ee98ec29ccc183119419e7e55ba11f089f523ef5058363a8059fb8e31e9421b491056c01819e28d3d0ff07eea3d53a1e3b6b8db235aca63c139c0eea68ca47a9fa6ef757b83ff00bf68ad428c2f248c7a8f9fcea518df516adac74e7544f63a2ea172f1800291e6cee19ec78cd5826344e85b6bad25ba8fade5b99dae0ee11efc71e858f7e7d054a2d7d39a75ae8f7b6b00b8917f1516624b78429da327cec493db1db1d8540cf4aea28f58d6aeae2f6dd64b498082d880488d149fcea7d4939ab04175e6850a8d32de3b78e380c8de32c4db4e18e430fef543cf86fd0d691b4fabdf6648b3b2db69ce7dd87be68342d2f4fb9b5b891af1a28a2dc05bc5036d001e0eef7352884b961a2ea9aa7555c885e08d45b5bc52b61b686c120fb939fb541276bd4b61d53624d942e2f6200bc32290633e99f4233416dd3ad3f0d611c0c77b632e71dc9ef41156dd27a45addcb3dbd9c513b1dd941821bdc7b558333b9f873757fd69a85e3f813e9c7723b5d93265d872473c11544a68ff08fa75e290b42ec4e4124e70738fa5048e89f0f745d2aeadd2decedda6525c975121183c77f7a945c754d0e0d563682ed43425369403bff00bcd58308ba7d5fe13f5a05889974a9d8b46aede4914f707d88ff001528ddf4fd7edb54d1a1d56c312dab2e64dbc9418e78f5c541296d70b716d1cd6f8789977230ecc280cb7519b816f212b205de4e0843ce300f6cfcb39a0545c42cee88e0b458ddec33ee680eac92266360debc7b5056fad2d354b9b189745744be121daf27e550548ce3d4d58324d07a725e98ea2b7ff5381f5169a7579d021fe13904ee43ddfbe49038ab46e76cf05cc714f6d309232a4a98ce54fd6b2196bb7f2e9b631b2c427b891b6851db3eff002007341e5bf887aa2ea3d4f77378be381e42fdb711ed5a1554395caf1cd07617dcd04fc85402101da791421b49920331381c60d1a69bf02f56f03a925b12c162b98c955f775e47df19a32d99b518268e4491668704a79d4aeec7b7bd4a30feb7e9144d76e265697c3e2693631674273803e556087d76f35fd49859e9925ccf611141106f2e182e3241f727f5a94681a268f79ad1b1b8b9dd66b1c2b1ce9bb06361c1e7bf3fe6a096b0d3ba57488e485b52b40909c386901607d47bf7a0ae758eb69ac4d15be81a748f0a9c35cc90b2eff4c03c1c638a0b77405c5d5d45f87be5fe359a88b81b401dc1c7d38fb50586fed18ea3015790091591e447c1518c8c7a0a0a5754d8c9d49a8d9f4ee9dba0b3b5224b9692327728f627e7c6682f9a7e996b6b3a8b6b748a348820c7720761412c064e3041ce282b5d4bd73d3bd3f33daea97ac2e540dd0a292dc8cd043c1f15ba2a7923b65bb910371b9a12141f9d02edf13ba2ade56857551e5e77244c54fd0e280746ebfe99bbbd655d56dcdc9ce08465565f4ee3bfca82d53eb3a6dac3e25c5f5ba646402e33fa77a0aff5b74ad8757e9ca972844aa37c520fcca7d3f5ab067bd369a8f467544d626c98e9f7118f0200e4465c903049c8c9e6ad1b24334b6fa6249716cab20037c309dd83db03b5640dddac3764a4f02cb1103863919fa7a1a06d6f600c37162911b7b252b87dc773f1927393f4a079f868edae1ae6328a8b1ed38e30050226e85d5dc1f879011b3c47c2f604719f9d01eff4f4b83e3c6b18bb452b1cac9b8a83de80b16e8208a3b7b58e1407cc061427cc0ff1560ce7a8f592d69a97504cad2dac01a2b53900c3e9e51ea58f727d0551e73bfb86b99a49a46dcf21c96340dc13804f20f6f9501c0e3b8a0963316fcc4607007f57bd084d64dec01200ce483468ff0040d525d1755b4d4206ff0095207c11dc67ff0019a18f56584f6daad9dade4211e39104a8ded9152b235cd8c530613229c8c1c8ef50472e81690ee00322b0c100f0debdbb7ca8111ace856371358cba85aa5cc407891ccf83f2ef4048b4ad2e59bf116769672c72f99dd1437239078e2824a4d3e1b94559234110e781839fa0a0561b38ad532a12319c86c6307e740a9732a3a00cac870cd8e0faf0681be8b6db965bb909df3c85806eeabced5a09523647e6e0fef419a6adf116daf7ac34be9dd1da686e7f1ca2e243b76320ce57df9ff1560cc3e3f470ff00c78255b842b35bc6c4af9b6e323d3e95467b6365f8dbcf062beb68c119595d8aaff6e282422e9899b4f6bb5d46cda2562a76316c1078f4a0859e1b9b762c0bf94f0e84feb4125a57505c58ea70dd5d0174a986d92b1c13f6f5a0de7a5be366877260b5d42dee2d2423124a487507ebdf15289dd3fac7a7bab6feded74d61733473acdb5a162142ff00313d81ed505fa58fc6d809380c1b9f5c502e0e05040ea367a85dea454de2ff00a610375b04c16c7a16ef8340b5f6930dce9375636acf6a278f04c5dd4f1dbf4a084e91d06f3a52dee62bbd4a2b882494ced3c8a448063b63b638fde803ab7ae749b2b3096d792c93c8c109b55dcd18ce3710473ffdd043dc758dc5869044565aa5dda4c3c2b7bc78c1f14e3963db03e7c0ab066bf1327d41ba76ca6bc48ecad24c456f6b0c87cf8e4bbfa138c0fa9aa3297c83dd4e28395811cf2680a5b93c7ed413cd1ff0f3c797b8031406645236b0508406f30e68ba49c051b97d0e0e7d28ad57e19f575c5be8f269515dac772877c11bc464dea7ba8c739ce78f9d3193bb8ebfea2bcbd6b5b6b8b58bb7f13c2f0ce31cf0deb4c0f2dbad6d743d2ee99efae752d6c02a86e0054524f6383c7ff94c0b6af274c75149a46a5a82c46f1e1479fc3190bd8156fbe7f4a960bf74e9d253f1167a3ac09e0856610e3041ec7f6c540f67b892cee7f8d18368232ef2af2508c7047cf340ead5bf130accc9b1186541e723d09ffc5033bbb1b82d74d6b37f1244daa1b38073df3f4a08eeb1d3b50d4fa6a5b4d32f12cef1902ee73e523d476fde8306eb0d3fabfa4ba92c278af67bb7281606472f90bdd58558253a6afb40ea1d62283a8b461a66a6f931cf6a7c2466f7cfb939e7b5515fbed3747b5eb8f06eb78d35080a2ec9719c76f98049a0b4ebdd37d1bad869acbf0b03c5c16b29444adf50ded41995f68564a263a66b31cd02be152505493f51c1a088bab69ad1bc179e320f07c37c8a0692b46c4995f0381db39a0b2fc34e971d57d4705bc8db6c50ef9dd97b81fcbf7381528f5ae97a1d8e996d1db69b0c7648855b10a81b80f43c739c54134147b9a036063279fb5046e957726a0f2cfe04915b06db1788305ffeac7a0a00d72f8d9c491c06337533050ac7185cf2df6a06da2da4293488f34973328c34aea428c9ec3eded40ee7d2ad249448f6b133820ee2833df3fde819ea96897461b05b87815f2ee919e5d47704fa039ab079b3e326b70eafd4ef6d6650d8e9ebf868b69c8247723efebf2aa280eb9193ebedc5002a124e015340018fb8fde82cf32b1603d0678cd02406dce3008e47ce81b499c331383c9c9f5a2e9c69377369f7d6f796a4acf148acb83fb511e91b3b3d0bab745b7d45acedd8e3732b71b1fd73f7a5a19eafd09a56a0a96b1c705b49c48510761ce4fcfbd4d0d752826b2b583476fc3daacb295b79d768de8a32b1e71f989e49f6a7d14dd1af5ba275a45b8b093c054492ea769092373765c1da4679fbd306e36ba9595fe9f0dcdbcc92c33e1579cf27d0d409ea178f68521b6b76926ee8a7853f7ff140bc768d78f6f73748d1cd103b543f0091cf6efc502f7319dac194371d8b6326829f0c501d7ae6fa568d5d4942c806d4db81839f53c8cd59456fae6e628749b5bab8b1865b08e4726588ec11e7f2e49071c93da9a31dd4341d675e9a5bad374f9858162d0b4ac70e18f0573df35a0c759f87bd53a404f174f965dfff00f479b1ef570576e34bd4b4cc0bdb3b9b7258a00e846e3f2a94376475cee4914af7ca9150685f09ba61efb52fc7dd69bf8eb7c158d1d0b47bb38f37efde968d6eeb4eb5e91d6ad25b660aee59974db6881690918e31ce39279e062a5a34bb57b88adedd1e379679065d80036679e6a07e8391bce7e940c659ef5afe1286de3b16f2b8903094b7b2fa7ce81eb380c4260ed193f2a0cd6fa5d4a4ea0fc7bdadcce923158a3039db83c038e3ef41a0e96b2ad8a35e009291b8a939d9f227e43bd590436bbd6fa269202c974b7123602c76e779624e00e29833bf897d493e896525dbcb2a6b5a9c3e1456b91b6d60cf989c7f31f7a60c02490961ebcf3eb541308e39e067b507007b96007a67fb50178f97eb4165ce18165c2927b773fad023202d9c8dbb7818ff003408300b87f2f1c107d0d0c15a4f2e339c90467f6a18bdfc2cea8ff4bd561b4b9ba686d6e64552c4f954e7d7e46a60f4688d240af1b2bc6cbf5047ca960617ba658de1b792f2d94a5ab33461b18524633fa1a81b5c8b5168967369d23c0e0a24622dc981d81c76aba29df0bb48d660d52fceb88d069f04aeb69130037127f37b9c0ed9a8350781240bbc06da72323b1f7a0eb8816e633192ebc8c9472a78fa50349b4c83c068e24f0ddbcc1c13b837be4d055b57e98b996d4db5b4a893dc1e6620b6ccf2c467efc504ce97a38d3f4d874bf09af6d46e2f25cb82724e791db15650a43f878b51fc34f3da8f132b6d6a98c80a39ff007e99aba249631b58b9047239ec3e55368aeeb7d2da6f52c0eb7f16e87f2c6e836ba90724ab7a67b55d115ac7c3e8aed2182def4c56a14096368959a423d77e3229a27b41e9d8343b01069c8a8dc9660aa3713df3c64d4a1c695d3d6b67a8cba94b9b8d4e61869e4e4a8c636a7f4afcaa09a485519caae19b966f7a0435196582c656b74df3e308beec7b50629375775b691ac5bdb6b16d6378779f019b00a31cf391c9c2f1daae0b35ef52f5374de88d77aa45a6cd25ddc0108694ee2188c28007603d6a0d16c92430a4b2ed3230dc401855cfa0a0a07c45d7b5db9d462e9ee960b14b2ee134ef8c850012147ec78ab0670b643a2efae753d72686e6e2da211db42176079c8e768f65e39f7aa332d6f58bbd635096f6fe6692695b24f603d801e82823cb900ee00e68006460051dfd680ed9f0c905b713d8d006d5f5419fa505a18f94e40501b1b81a04186d62402c87be3d6810b81290aea8467201231cd1749dbc437f9f1e201db3de8ba07dc0175c027f28a335b17c26f888d6b6d0e8fabf892a29c453b1e547f49f7a946d6424f08236491c833ee0835073294888894120700f0280813c40a6711bc8843e00fca7d3ef40e41dc081f9a811681c6f7565329185623b7e9de812b3bcf11ff0b74563bd50494cf120071b97e5fda80d7577046c9019d5669dbc340324eec67fb734103d5da96bf67a7cf0e916f6e2765f25ddc4c11107ab1c8c647cce2816d3ec7f0f6564cae6e67da375e6d52cc4af2e4fb13ed4145f899d47b3499f4bb6d46cda49b69b92921565c3648e3dd40c81cd5c0ae89f13ec246d3e379ed2d6da180b5d34849da1780b128e49271c9f4a60ba685d5fa36bc42d95c324ec7090cc9b1d87b81ed50588958977cacaaa3b9341c655f12348d1dcb8dc1946540f99a019e2134454eeda7bed3839cd052fe2136b536b5d3563a1ca53c49da4b9507198940ce7e5c9fbe281c6b7a974cf4ee4ea7242d76dc784a3c595b3e9b464e3f6ad0ac745ccbd4fadcbabea42da56959a382ce7460d6b1a93c01f97272093ebf6a82f1ad6af0e9da5cb3cecf6902216919f82aa3818c7a9f4c530649a9f5269ba7429d472239bc991a1b0d3c3152880f0f23039e7bf3de90635ab6a377aa5ebdcdecef2c9239e59f3827e5ed54302195fcc38cd01245395c1f5f4a05b606538e483c501b6939e3b5077860f3914165754c33e549000dbe87de813b820c27fa7baafb8a04a69c98e281e42618c795338033df1f3a06c03e4e029247007ad010093c35674da71f977640340081a190658e41c820f141b0fc33f8926c218b4ed609366a02249bb2d19ce3ea4528dbece68eead926b7916689c643a9e0d643387521fea2f693c2d6efc786ee46d9bfed3eff2a04669edf5295ff057a60bd865309246d3bbbedc1efef41d63a8dec9ab4fa7dd4510fc3c69234ca186e2d9c003b7a67bd034bad0a5bb96e25d575267889cc1b54446d9bd0a37bfbfbd02925945a72cba8dddc48b3f87b1e58f23c623f292bdb7fa7cf38a0a5750f54ebba56a9a67fc516b6d6fd3970ea9234677c8dc7f38f6e4640ce282d1ac4b16bfa72c1d2bad430cd1ba822061865f5007d3daac19cf547c189357d561bbd3eee683c62cd786e9b73337b8c7bd512bd39f06adedec2de0d5ae639da372e6485363107f97767b505cee755d03a5e58ac228659af123184b7b733322e38c91dbf5a943ab3d52e64b49ee755d2e64950e238e35f10c884e17cbe87dc540e6d7509a4f110e9f7566a471712850abf6ce463e6280bacea36fd33a4497f773cf32c698dcc4beee33938edc7ad05534aea683ae61d64c4d2a69b6b88d16d5ca5c303f3e386cf61db140e27b5e99e96b64bdd562b6b30aa36c6c37cac7dc9eec6b42c1a66a962fa70beb6b516d0cbe76322f86c78f6c66831bf8b5d5d2dfa35a5dce60b1933b6ce3c788769f2b331ec1b8fd2831b79649984b239773c1dc68129725c1c640e73400ec781d8fb1a03c4a85d0c8582640257bd01e51fc42236263c9c67be280429c6037eb405dbf5fd682c2a0bb976cf07d3fc5009279ef8ec4e68193a9902b28e7dc71fb501d95b098e0f6dd9e0d0049131019b047b8390281bb292484e47c8500c4f242c3076bf704704739a0be7c3febfbae9a5daf23cd017c7e19fb107bb67d0f6fd6837cd2757d1fab34f4f05e37dde630b1c3a91edf4f7159103d6eb7da65fdbdf59dadb5e2460ac876ed9e1c8c060f9efe9c8a0a75cfc42d5742d2ee5a7e9dbb494b6d6b9bc930cce4f940e3cd81ed4160e98f88315e689fff0022b57664199cc5196f0c7a164ef8f98cd0589baffa68590985eb15c0db1985839f6c2919340b69d03f5285bdd6f4bf021424db4329cb153fccc3d09c76a090d3340d2f479a7bab3b38e2924e5e451cfd280d7dafe936f6c5e4bd89813b02a36589ce318a0358dc35cc4e17f9bf234cdbb78fa0c607a7340e6cec20b1596610c6934b8323226379edda81da8dcb9ec40a042f50b5bb21645473b58b11dbd7bfca8304f8add5d67a9ea8ba5d8ea72c1a4d8a952f10f2c920e368cf71e99fad5833dd0754d6ed66bdb2e9a91a5babb2a310465a57c1ddc1038e7bd5171d3748b8d46ee1ff005298dc6a764c27d4eeaee7fe1c01795881c9e7804fe940dbe287c4b6d75a1b1d1c986d62277c91bf131f4c0f6fad0663737135d3b497124924871f98e7803007d2811dc5b83903dc0a0333f03be7de8122df2c9a05a11e5f51f7a05ce7071804fca8033e5da0734020b0183bb23e5416269577ed0e5323078ceeefdff6a03dbcd62914c2f629a47c622689800879e4fbd046f9d8a2a03e31385c0e73da8b83ca590947dcaead8208e73da8849b3e19ce704f7c5015586d006431f5cf61f3a04ee586ff002481c8fe6191408f0011eb8e30682774dea9bbb5784492ca6385832e1ca95e3d2834be9df8c312e2db5eb4375080337000f1303d18763591a469baef4d755989ec6f6dae5a23e20b599406dd8e080ddbed41272f4dd8caf1c86d163910f9595882a3d718a035edd695d3b6a926b57d0ac65b10b4e06eedd863bf141077fd7af2782bd3fa26a1a8891d57c630948c0279393dcd04cf5875258f4de9f0cb7b7b6d66d2b81ba752d85f5214724fed41036bd79d2fe319d7a8f4b9c81e58de2f04827b9ce09a07a3acecf54b790685ace8697606009e52c377b7f2e682b097d7d36acf0f55df5edbdc0977412468cb6ce3be10af3c63b9c8a0b0751f505be9690dd5d752436f62a3fe4c6448f3b7b0c64e38f615734651f107e3045ac42b67a7693018633b965bc1bc838ee173807bf7cd33065baaeb1a95f2c11dfcd2bc51fe48880aa3e8a062a8b059f595df4ae9a74de9e9ec499d43c97b1427c6e47e525bb63e4282ad3ea3712893c599dbc4259c1627713c927de81043950df97db1406da8411c92063be280230839627078e79a0390a71b5bb5003a8c1232338e4507025573e9fbd02a0e41dc0e680c3691cf714053bb34160895dc16f291d98d02322aa39f3e14707ffaa06f202a5bb0c7201f4a343aca51090497efdfbfce89840c8db8e46573923ff14410b00490d9f5c1a0425dd8ce4673e873cd0265e4dbe7041ed814009b8cbb8e5863bd07163b7716e0607b6698060b96b7b9478dc8643918247ee39a60b7e97f133a8b4e0c63d4ee597380923970a3ef4c0e13e25dfcfab457ba95bdbddb212016501867b9cfbfda982f907c74b282da34874a9048aa479c83838edc62982b7ac7c42d235cd67f15ac5b40c366418a2cb0c1c81e6f5e31db14c160d035de8cd4a3f18ea96562cc37359dfe9cac887fef039fd6b39446f56ea5d13a9dca4579a922496b1975b8d22dfc3566cf9557230703be715ac1431d4d2275325d7fae6b4f6f182a93ef1e32a9f41938f6a60afeb1a95c5fea53dccf772cf2c8c489240031f627e7565c0d67bbf160487c1801073bc0c31f91f953420f2bc8c7c52cc540032738a809905c0f4fa501940208e73df34028e703938a0577ae013f4a001300db4f03b71407461ce0502dca8c9c7dcf6a003fafcbdcd0070bc1e0fd734070db467b8a04cb9c9e68274b93bcb1daa40200ed4099765249ec476cf340849b8b264823bf34689ee009cb671df1409bc8e8b8e770e3ec68984d9c953cf97be2860b248caaebc107dc67f7a184c31232db88fd451031ce50e76039f5c8045026efb8f93279e0fd680b239504f0483d88ef409ee25bb90c79c0e050151c6e21b39ce783eb40adbcc2cefa17bdb61322387781c950e3dbdf9c8a066f28790b22e013db3dbef54726081e63c6460d34191b1bb0720f634060e7600412c781502409c8e3d7b500ed71dbef8ed40243f181c0a02e5d4e0fad006f644e4819e3b501f7e3049e7b501bc43b4e391da80558003392d40a23305e320d02e64cf998e1bf5a032b0c927b8e68049c8c8e71c6280377043118f4e680bbff00de0504ddbb3128371c1c64668024e59f3cd02521254e4fad1a2107e48fe6a6809ddb9e78a029e1463d05027ffc744a6c3857c7b1a205ff00e637fbf4a02b12b1794e39f4a02024e7249ed409924720906800005173fd7404989698ee39e4f7a04cf723d07a501fff0097ed406ffe36a018ff00281e99a037f4d0731f3bfd28007e53400ff99a810248c0cf140bc60123233cff008a0557f9beb4056eff007a07109243e79a03778b27bfbd02b128c27039a054001b818a06609de793da815006070283ffd9}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here is a movie {\pict\jpegblip ffd8ffe000104a46494600010101004800480000fffe0050546869732061727420697320696e20746865207075626c696320646f6d61696e2e204b6576696e204875676865732c206b6576696e68406569742e636f6d2c2053657074656d6265722031393935ffdb00430001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ffdb00430101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ffc00011080016001403012200021101031101ffc4001a000100020301000000000000000000000000080905060a07ffc400231000010501000300010500000000000000060304050708020001090a11153976b7ffc400160101010100000000000000000000000000060800ffc400261101000102050109000000000000000000010200030405061121b33134365154717475b4ffda000c03010002110311003f00a90cf388f366a62aa720ed6ae07f96901f3831d973452b8cf36fe3570fc908e46d466433e5dd954f2e96992d9e498c7753faa44916e016ca91cc7d88b38fe60a5b97737defcbcc539c98d336a57f4fc2ca9a486bf07ab575ad9a3af4df221d8215e36df86c4504ff0024574551b3d687ee0575757b3ad64e311ee62bd94158d37e24198c43973099f1fc0c41614d950246513a081abf76cfe7061f6863281e6352fd1670949c148dd6dfb0d25f5b3689b1d5c965b0eacbf4e0932ad28e22ab9ae945633f4744bd3c8cee0a7fdf085b9000f449c5f7afa30b83e0b6fd7b0c8429c9467ff9715347c891e25fa24a205861aa715e6a09bd0488237dc2723414d9891381524e8ca7c0894664f835653631ab55ee7e3de433e4ff001b30949124e4c10c8b6ad0a479b3f9c937b2cf5bc0095ad600a0a41a0e9faee174a1c605e161c6c7a313539650b0113190f1a8368e60d5b24f30ff008ea7f0bf867fa6595feeb6978f1fe0f9c26177f4d63a51a9235184750e7d18811339cd000000c75f000e00380380ae390c350def826ed42ad051fa6f501c50f9b699c3b69cbeb76476d202bf3ac985b6e0e968be66572893e6a744540bd9722e5c87956848629bc2559306bd113e8653d3b6aff651dfad7a3ac8b02958cba02a93ccf525757039bae6cff090e1d90688e8aa233ee86a4c4a3e0586d6b2340522e47dcb7d0046d8a5acb05a123ee25d2b230b2ada6e2e2f9ede3c05202520ec2487b0d56562529d8b3393bca76adca4ec1bca508abb001babc007915d84fe3dd14e207e3c62f8379da2a3b861fb6629d28dba53b6ea388ebfed866bf6dfb553455e91ed547ae92e9445253a4fdf3efb4f8ebdfbe7d3c78f1ee0bb9e13e358e942a4ed49e22cff00eeb35fdd7ebfffd9} icon.\par}
{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Footnotes\par}
{\pard \ql \f0 \sa180 \li0 \fi0 Here is a footnote reference,{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.\par}
diff --git a/tests/writer.texinfo b/tests/writer.texinfo
index 3344845b0..4e08e8f63 100644
--- a/tests/writer.texinfo
+++ b/tests/writer.texinfo
@@ -101,7 +101,6 @@ Level 5
@subsection Level 3
with no blank line
-
@node Level 2
@section Level 2
with no blank line
@@ -136,7 +135,6 @@ E-mail style:
@quotation
This is a block quote. It is pretty short.
-
@end quotation
@quotation
Code in a block quote:
@@ -159,11 +157,9 @@ Nested block quotes:
@quotation
nested
-
@end quotation
@quotation
nested
-
@end quotation
@end quotation
This should not be a block quote: 2 > 1.
@@ -291,7 +287,6 @@ Minus 3
@end itemize
-
@node Ordered
@section Ordered
Tight:
@@ -360,7 +355,6 @@ Item 3.
@end enumerate
-
@node Nested
@section Nested
@itemize
@@ -421,7 +415,6 @@ Third
@end enumerate
-
@node Tabs and spaces
@section Tabs and spaces
@itemize
@@ -442,7 +435,6 @@ this is an example list item indented with spaces
@end itemize
-
@node Fancy list markers
@section Fancy list markers
@enumerate 2
@@ -583,7 +575,6 @@ orange fruit
@quotation
orange block quote
-
@end quotation
@end table
@@ -639,7 +630,6 @@ sublist
@end table
-
@node HTML Blocks
@chapter HTML Blocks
Simple block on one line:
@@ -799,7 +789,6 @@ Dog & 2 \\
Cat & 1 \\ \hline
\end{tabular}
@end tex
-
@iftex
@bigskip@hrule@bigskip
@end iftex
@@ -902,7 +891,6 @@ Just a @uref{/url/,URL}.
@uref{,Empty}.
-
@node Reference
@section Reference
Foo @uref{/url/,bar}.
@@ -930,7 +918,6 @@ Foo @uref{/url/,bar}.
Foo @uref{/url/,biz}.
-
@node With ampersands
@section With ampersands
Here's a @uref{http://example.com/?foo=1&bar=2,link with an ampersand in the URL}.
@@ -941,7 +928,6 @@ Here's an @uref{/script?foo=1&bar=2,inline link}.
Here's an @uref{/script?foo=1&bar=2,inline link in pointy braces}.
-
@node Autolinks
@section Autolinks
With an ampersand: @url{http://example.com/?foo=1&bar=2}
@@ -959,7 +945,6 @@ An e-mail address: @uref{mailto:nobody@@nowhere.net,@code{nobody@@nowhere.net}}
@quotation
Blockquoted: @url{http://example.com/}
-
@end quotation
Auto-links should not occur here: @code{<http://example.com/>}
@verbatim
@@ -1004,7 +989,6 @@ If you want@comma{} you can indent every line@comma{} but you can also be lazy a
@quotation
Notes can go in quotes.@footnote{In quote.}
-
@end quotation
@enumerate
@item
diff --git a/tests/writer.textile b/tests/writer.textile
new file mode 100644
index 000000000..51aca5a08
--- /dev/null
+++ b/tests/writer.textile
@@ -0,0 +1,716 @@
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's markdown test suite.
+
+<hr />
+
+h1. Headers
+
+h2. Level 2 with an "embedded link":/url
+
+h3. Level 3 with _emphasis_
+
+h4. Level 4
+
+h5. Level 5
+
+h1. Level 1
+
+h2. Level 2 with _emphasis_
+
+h3. Level 3
+
+with no blank line
+
+h2. Level 2
+
+with no blank line
+
+<hr />
+
+h1. Paragraphs
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.
+
+Here's one with a bullet. &#42; criminey.
+
+There should be a hard line break
+here.
+
+<hr />
+
+h1. Block Quotes
+
+E-mail style:
+
+bq. This is a block quote. It is pretty short.
+
+
+
+<blockquote>
+
+Code in a block quote:
+
+bc. sub status {
+ print "working";
+}
+
+
+A list:
+
+# item one
+# item two
+
+Nested block quotes:
+
+bq. nested
+
+
+
+bq. nested
+
+
+
+</blockquote>
+
+This should not be a block quote: 2 &gt; 1.
+
+And a following paragraph.
+
+<hr />
+
+h1. Code Blocks
+
+Code:
+
+<pre>
+---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab
+</pre>
+
+And:
+
+<pre>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{
+</pre>
+
+<hr />
+
+h1. Lists
+
+h2. Unordered
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Asterisks loose:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Pluses tight:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Pluses loose:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Minuses tight:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+Minuses loose:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+h2. Ordered
+
+Tight:
+
+# First
+# Second
+# Third
+
+and:
+
+# One
+# Two
+# Three
+
+Loose using tabs:
+
+# First
+# Second
+# Third
+
+and using spaces:
+
+# One
+# Two
+# Three
+
+Multiple paragraphs:
+
+<ol style="list-style-type: decimal;">
+<li><p>Item 1, graf one.</p>
+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p></li>
+<li><p>Item 2.</p></li>
+<li><p>Item 3.</p></li>
+</ol>
+
+h2. Nested
+
+* Tab
+** Tab
+*** Tab
+
+Here's another:
+
+# First
+# Second:
+#* Fee
+#* Fie
+#* Foe
+# Third
+
+Same thing but with paragraphs:
+
+# First
+# Second:
+#* Fee
+#* Fie
+#* Foe
+# Third
+
+h2. Tabs and spaces
+
+* this is a list item indented with tabs
+* this is a list item indented with spaces
+** this is an example list item indented with tabs
+** this is an example list item indented with spaces
+
+h2. Fancy list markers
+
+<ol start="2" style="list-style-type: decimal;">
+<li>begins with 2</li>
+<li><p>and now 3</p>
+<p>with a continuation</p>
+<ol start="4" style="list-style-type: lower-roman;">
+<li>sublist with roman numerals, starting with 4</li>
+<li>more items
+<ol style="list-style-type: upper-alpha;">
+<li>a subsublist</li>
+<li>a subsublist</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
+
+Nesting:
+
+<ol style="list-style-type: upper-alpha;">
+<li>Upper Alpha
+<ol style="list-style-type: upper-roman;">
+<li>Upper Roman.
+<ol start="6" style="list-style-type: decimal;">
+<li>Decimal start with 6
+<ol start="3" style="list-style-type: lower-alpha;">
+<li>Lower alpha with paren</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
+
+Autonumbering:
+
+# Autonumber.
+# More.
+## Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+<hr />
+
+h1. Definition Lists
+
+Tight using spaces:
+
+<dl>
+<dt>apple</dt>
+<dd>red fruit</dd>
+<dt>orange</dt>
+<dd>orange fruit</dd>
+<dt>banana</dt>
+<dd>yellow fruit</dd>
+</dl>
+
+Tight using tabs:
+
+<dl>
+<dt>apple</dt>
+<dd>red fruit</dd>
+<dt>orange</dt>
+<dd>orange fruit</dd>
+<dt>banana</dt>
+<dd>yellow fruit</dd>
+</dl>
+
+Loose:
+
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p></dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p></dd>
+<dt>banana</dt>
+<dd><p>yellow fruit</p></dd>
+</dl>
+
+Multiple blocks with italics:
+
+<dl>
+<dt>_apple_</dt>
+<dd><p>red fruit</p>
+<p>contains seeds, crisp, pleasant to taste</p></dd>
+<dt>_orange_</dt>
+<dd><p>orange fruit</p>
+bc. { orange code block }
+
+
+bq. <p>orange block quote</p>
+
+</dd>
+</dl>
+
+Multiple definitions, tight:
+
+<dl>
+<dt>apple</dt>
+<dd>red fruit</dd>
+<dd>computer</dd>
+<dt>orange</dt>
+<dd>orange fruit</dd>
+<dd>bank</dd>
+</dl>
+
+Multiple definitions, loose:
+
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p></dd>
+<dd><p>computer</p></dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p></dd>
+<dd><p>bank</p></dd>
+</dl>
+
+Blank line after term, indented marker, alternate markers:
+
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p></dd>
+<dd><p>computer</p></dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+<ol style="list-style-type: decimal;">
+<li>sublist</li>
+<li>sublist</li>
+</ol>
+</dd>
+</dl>
+
+h1. HTML Blocks
+
+Simple block on one line:
+
+<div>
+foo
+</div>
+
+And nested without indentation:
+
+<div>
+<div>
+<div>
+foo
+</div>
+</div>
+<div>
+bar
+</div>
+</div>
+
+Interpreted markdown in a table:
+
+<table>
+<tr>
+<td>
+This is _emphasized_
+</td>
+<td>
+And this is *strong*
+</td>
+</tr>
+</table>
+
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+
+Here's a simple block:
+
+<div>
+
+foo
+</div>
+
+This should be a code block, though:
+
+bc. <div>
+ foo
+</div>
+
+
+As should this:
+
+bc. <div>foo</div>
+
+
+Now, nested:
+
+<div>
+ <div>
+ <div>
+
+foo
+</div>
+ </div>
+</div>
+
+This should just be an HTML comment:
+
+<!-- Comment -->
+
+Multiline:
+
+<!--
+Blah
+Blah
+-->
+
+<!--
+ This is another comment.
+-->
+
+Code block:
+
+bc. <!-- Comment -->
+
+
+Just plain comment, with trailing spaces on the line:
+
+<!-- foo -->
+
+Code:
+
+bc. <hr />
+
+
+Hr's:
+
+<hr>
+
+<hr />
+
+<hr />
+
+<hr>
+
+<hr />
+
+<hr />
+
+<hr class="foo" id="bar" />
+
+<hr class="foo" id="bar" />
+
+<hr class="foo" id="bar">
+
+<hr />
+
+h1. Inline Markup
+
+This is _emphasized_, and so _is this_.
+
+This is *strong*, and so *is this*.
+
+An _"emphasized link":/url_.
+
+*_This is strong and em._*
+
+So is *_this_* word.
+
+*_This is strong and em._*
+
+So is *_this_* word.
+
+This is code: @>@, @$@, @\@, @\$@, @<html>@.
+
+-This is _strikeout_.-
+
+Superscripts: a[^bc^]d a[^_hello_^] a[^hello there^].
+
+Subscripts: H[~2~]O, H[~23~]O, H[~many of them~]O.
+
+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
+
+<hr />
+
+h1. Smart quotes, ellipses, dashes
+
+"Hello," said the spider. "'Shelob' is my name."
+
+'A', 'B', and 'C' are letters.
+
+'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'
+
+'He said, "I want to go."' Were you alive in the 70's?
+
+Here is some quoted '@code@' and a ""quoted link":http://example.com/?foo=1&bar=2".
+
+Some dashes: one -- two -- three -- four -- five.
+
+Dashes between numbers: 5 - 7, 255 - 66, 1987 - 1999.
+
+Ellipses...and...and....
+
+<hr />
+
+h1. LaTeX
+
+*
+* <span class="math">2+2=4</math>
+* <span class="math">x \in y</math>
+* <span class="math">\alpha \wedge \omega</math>
+* <span class="math">223</math>
+* <span class="math">p</math>-Tree
+* Here's some display math: <span class="math">\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math>
+* Here's one that has a line break in it: <span class="math">\alpha + \omega \times x^2</math>.
+
+These shouldn't be math:
+
+* To get the famous equation, write @$e = mc^2$@.
+* $22,000 is a _lot_ of money. So is $34,000. (It worked if "lot" is emphasized.)
+* Shoes ($20) and socks ($5).
+* Escaped @$@: $73 _this should be emphasized_ 23$.
+
+Here's a LaTeX table:
+
+
+<hr />
+
+h1. Special Characters
+
+Here is some unicode:
+
+* I hat: Î
+* o umlaut: ö
+* section: §
+* set membership: ∈
+* copyright: ©
+
+AT&amp;T has an ampersand in their name.
+
+AT&amp;T is another way to write it.
+
+This &amp; that.
+
+4 &lt; 5.
+
+6 &gt; 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: &#42;
+
+Underscore: &#95;
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: &gt;
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+<hr />
+
+h1. Links
+
+h2. Explicit
+
+Just a "URL":/url/.
+
+"URL and title":/url/.
+
+"URL and title":/url/.
+
+"URL and title":/url/.
+
+"URL and title":/url/
+
+"URL and title":/url/
+
+"with&#95;underscore":/url/with_underscore
+
+"Email link":mailto:nobody@nowhere.net
+
+"Empty":.
+
+h2. Reference
+
+Foo "bar":/url/.
+
+Foo "bar":/url/.
+
+Foo "bar":/url/.
+
+With "embedded [brackets]":/url/.
+
+"b":/url/ by itself should be a link.
+
+Indented "once":/url.
+
+Indented "twice":/url.
+
+Indented "thrice":/url.
+
+This should [not][] be a link.
+
+bc. [not]: /url
+
+
+Foo "bar":/url/.
+
+Foo "biz":/url/.
+
+h2. With ampersands
+
+Here's a "link with an ampersand in the URL":http://example.com/?foo=1&bar=2.
+
+Here's a link with an amersand in the link text: "AT&amp;T":http://att.com/.
+
+Here's an "inline link":/script?foo=1&bar=2.
+
+Here's an "inline link in pointy braces":/script?foo=1&bar=2.
+
+h2. Autolinks
+
+With an ampersand: "http://example.com/?foo=1&bar=2":http://example.com/?foo=1&bar=2
+
+* In a list?
+* "http://example.com/":http://example.com/
+* It should.
+
+An e-mail address: "nobody@nowhere.net":mailto:nobody@nowhere.net
+
+bq. Blockquoted: "http://example.com/":http://example.com/
+
+
+
+Auto-links should not occur here: @<http://example.com/>@
+
+bc. or here: <http://example.com/>
+
+
+<hr />
+
+h1. Images
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+!lalune.jpg(Voyage dans la Lune)!
+lalune
+
+Here is a movie !movie.jpg(movie)! icon.
+
+<hr />
+
+h1. Footnotes
+
+Here is a footnote reference,[1] and another.[2] This should _not_ be a footnote reference, because it contains a space.[^my note] Here is an inline note.[3]
+
+bq. Notes can go in quotes.[4]
+
+
+
+# And in list items.[5]
+
+This paragraph should not be part of the note, as it is not indented.
+
+
+fn1. Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.
+
+
+fn2. Here's the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as with list items).
+
+bc. { <code> }
+
+
+If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
+
+
+fn3. This is _easier_ to type. Inline notes may contain "links":http://google.com and @]@ verbatim characters, as well as [bracketed text].
+
+
+fn4. In quote.
+
+
+fn5. In list.
+