packages feed

pandoc 2.7.3 → 2.8

raw patch · 373 files changed

+46701/−41807 lines, 373 filesdep +doclayoutdep +skylighting-coredep +text-conversionsdep −semigroupsdep ~Diffdep ~HsYAMLdep ~base-compatbinary-added

Dependencies added: doclayout, skylighting-core, text-conversions

Dependencies removed: semigroups

Dependency ranges changed: Diff, HsYAML, base-compat, basement, doctemplates, foundation, haddock-library, pandoc-types, skylighting, texmath

Files

AUTHORS.md view
@@ -2,6 +2,7 @@  - Anabra - Arata Mizuki+- Arfon Smith - Aaron Wolen - Albert Krewinkel - Alex Ivkin@@ -11,6 +12,7 @@ - Alexander Sulfrian - Alexander V Vershilov - Alfred Wechselberger+- Amogh Rathore - Anders Waldenborg - Andreas Lööw - Andrew Dunning@@ -24,6 +26,7 @@ - B. Scott Michel - Ben Firshman - Ben Gamari+- Ben Steinberg - Beni Cherniavsky-Paskin - Benoit Schweblin - Bjorn Buckwalter@@ -36,6 +39,7 @@ - Carlos Sosa - Chris Black - Christian Conkle+- Christian Despres - Christoffer Ackelman - Christoffer Sawicki - Clare Macrae@@ -53,7 +57,9 @@ - David Röthlisberger - Denis Laxalde - Derek Chen-Becker+- Dmitry Pogodin - Douglas Calvert+- Eigil Rischel - Emanuel Evans - Emily Eisenberg - Eric Kow@@ -61,7 +67,10 @@ - Eric Schrijver - Étienne Bersac - Felix Yan+- Félix Baylac-Jacqué+- Florian Beeres - Florian Eitel+- Florian Klink - Francesco Occhipinti - François Gannaz - Freiric Barral@@ -92,11 +101,13 @@ - Jamie F. Olson - Jan Larres - Jan Schulz+- Jan-Otto Kröpke - Jason Ronallo - Jeff Arnold - Jeff Runningen - Jens Getreu - Jens Petersen+- Jeroen de Haas - Jesse Rosenthal - Joe Hermaszewski - Joe Hillenbrand@@ -114,13 +125,16 @@ - Juliusz Gonera - Justin Bogner - Jérémy Bobbio+- Karl Pettersson - Keiichiro Shikano - Kelsey Hightower - Kolen Cheung - Konstantin Zudov - Kristof Bastiaensen+- Krystof Beuermann - Herwig Stuetz - Lars-Dominik Braun+- Leif Metcalf - Luke Plant - Marc Schreiber - Mark Szepieniec@@ -141,6 +155,7 @@ - Merijn Verstraaten - Michael Beaumont - Michael Chladek+- Michael Peyton Jones - Michael Snoyman - Michael Thompson - MinRK@@ -153,16 +168,20 @@ - Nikolay Yakimov - Nils Carlson - Nokome Bentley+- Ole Martin Ruud - Oliver Matthews - Ophir Lifshitz - Or Neeman - OvidiusCicero+- Owen McGrath - Pablo Rodríguez - Pascal Wagler - Paul Tilley - Paul Rivier - Paulo Tanimoto+- Pete Ryland - Peter Wang+- Philip Pesca - Philippe Ombredanne - Phillip Alday - Prayag Verma@@ -196,12 +215,17 @@ - Tiziano Müller - Todd Sifleet - Tom Leese+- Tristan Stenner - Uli Köhler+- Urs Liska - Václav Zeman+- Vanessa McHale - Viktor Kronvall - Vincent - Václav Haisman - Václav Zeman+- Vanessa McHale+- Vasily Alferov - Wandmalfarbe - Waldir Pimenta - Wikiwide@@ -210,6 +234,8 @@ - Yan Pashkovsky - Yoan Blanc - Yuchen Pei+- Zihang Chen+- blmage - bucklereed - bumper314 - chinapedia@@ -218,11 +244,14 @@ - ebiim - iandol - infinity0x+- jeongminkim-islab - kaizshang91 - lux-lth - lwolfsonkin - nkalvi+- niszet - oltolm+- oquechy - quasicomputational - qerub - robabla@@ -233,4 +262,5 @@ - takahashim - tgkokk - thsutton+- vijayphoenix - wiefling
CONTRIBUTING.md view
@@ -165,6 +165,41 @@  The test program is `test/test-pandoc.hs`. +To run particular tests (pattern-matching on their names), use+the `-p` option:++    cabal install pandoc --enable-tests+    cabal test --test-options='-p markdown'++Or with stack:++    stack test --test-arguments='-p markdown'++It is often helpful to add `-j4` (run tests in parallel)+and `--hide-successes` (don't clutter output with successes)+to the test arguments as well.++If you add a new feature to pandoc, please add tests as well, following+the pattern of the existing tests. The test suite code is in+`test/test-pandoc.hs`. If you are adding a new reader or writer, it is+probably easiest to add some data files to the `test` directory, and+modify `test/Tests/Old.hs`. Otherwise, it is better to modify the module+under the `test/Tests` hierarchy corresponding to the pandoc module you+are changing.  Alternatively, you may add a "command test" to+the `/test/command/` hierarchy, following the pattern of the tests there.+These test files should have a meaningful name, which can include the issue+number and/or the feature that's being tested. For example, `5474-tables.md`+refers to both issue and feature.++You can rebuild the golden tests in `tests/` by passing+`--accept` to the test script. (If you're using stack, `stack+test --test-arguments "--accept"`; or `make TESTARGS=--accept`).+Then check the changed golden files for accuracy, and+commit the changes.  For docx or pptx tests, open the files in Word+or Powerpoint to ensure that they weren't corrupted and that+they had the expected result, and mention the Word/Powerpoint+version and OS in your commit comment.+ Benchmarks ---------- @@ -178,10 +213,9 @@      stack bench -You can also build pandoc with the `weigh-pandoc` flag and-run `weigh-pandoc` to get some statistics on memory usage.-(Eventually this should be incorporated into the benchmark-suite.)+You can also build `weigh-pandoc` (`stack build pandoc:weigh-pandoc`)+to get some statistics on memory usage.  (Eventually this should+be incorporated into the benchmark suite.)  Using the REPL --------------
INSTALL.md view
@@ -81,7 +81,7 @@    - Check whether the pandoc version in your package manager is     not outdated. Pandoc is in the [Debian], [Ubuntu], [Slackware],-    [Arch], [Fedora], [NiXOS], [openSUSE], and [gentoo] repositories.+    [Arch], [Fedora], [NiXOS], [openSUSE], [gentoo] and [Void] repositories.    - To get the latest release, we provide a binary package for amd64     architecture on the **[download page]**.@@ -241,9 +241,10 @@     vary by platform.  Here is how it might work on macOS with Homebrew:          brew install icu4c-        cabal install --extra-lib-dirs=/usr/local/Cellar/icu4c/51.1/lib \-          --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \-          -funicode_collation text-icu pandoc-citeproc+        stack install pandoc-citeproc \+          --flag "pandoc-citeproc:unicode_collation" \+          --extra-lib-dirs=/usr/local/opt/icu4c/lib \+          --extra-include-dirs=/usr/local/opt/icu4c/include  6.  The `pandoc.1` man page will be installed automatically.  cabal shows     you where it is installed: you may need to set your `MANPATH`@@ -398,4 +399,5 @@ [source tarball]: http://hackage.haskell.org/package/pandoc [stack]: https://docs.haskellstack.org/en/stable/install_and_upgrade.html [cabal-install]: http://hackage.haskell.org/package/cabal-install+[Void]: https://voidlinux.org/ [uninstaller]: https://raw.githubusercontent.com/jgm/pandoc/master/macos/uninstall-pandoc.pl
MANUAL.txt view
@@ -1,5315 +1,5867 @@-% Pandoc User's Guide-% John MacFarlane-% June 11, 2019--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.--Pandoc can convert between numerous markup and word processing formats,-including, but not limited to, various flavors of [Markdown], [HTML],-[LaTeX] and [Word docx]. For the full lists of input and output formats,-see the `--from` and `--to` [options below][General options].-Pandoc can also produce [PDF] output: see [creating a PDF], below.--Pandoc's enhanced version of Markdown includes syntax for [tables],-[definition lists], [metadata blocks], [footnotes], [citations], [math],-and much more.  See below under [Pandoc's Markdown].--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-(an _abstract syntax tree_ or AST), 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. Users can also-run custom [pandoc filters] to modify the intermediate AST.--Because pandoc's intermediate representation of a document is less-expressive than many of the formats it converts between, one should-not expect perfect conversions between every format and every other.-Pandoc attempts to preserve the structural elements of a document, but-not formatting details such as margin size.  And some document elements,-such as complex tables, may not fit into pandoc's simple document-model.  While conversions from pandoc's Markdown to all formats aspire-to be perfect, conversions from formats more expressive than pandoc's-Markdown can be expected to be lossy.--Using pandoc---------------If no *input-files* are specified, input is read from *stdin*.-Output goes to *stdout* by default. For output to a file,-use the `-o` option:--    pandoc -o output.html input.txt--By default, pandoc produces a document fragment. To produce a standalone-document (e.g. a valid HTML file including `<head>` and `<body>`),-use the `-s` or `--standalone` flag:--    pandoc -s -o output.html input.txt--For more information on how standalone documents are produced, see-[Templates] below.--If multiple input files are given, `pandoc` will concatenate them all (with-blank lines between them) before parsing. (Use `--file-scope` to parse files-individually.)--Specifying formats---------------------The format of the input and output can be specified explicitly using-command-line options.  The input format can be specified using the-`-f/--from` option, the output format using the `-t/--to` option.-Thus, to convert `hello.txt` from Markdown to LaTeX, you could type:--    pandoc -f markdown -t latex hello.txt--To convert `hello.html` from HTML to Markdown:--    pandoc -f html -t markdown hello.html--Supported input and output formats are listed below under [Options]-(see `-f` for input formats and `-t` for output formats).  You-can also use `pandoc --list-input-formats` and-`pandoc --list-output-formats` to print lists of supported-formats.--If the input or output format is not specified explicitly, `pandoc`-will attempt to guess it from the extensions of the 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-extension is unknown, the output format will default to HTML.-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.--Character encoding---------------------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--Note that in some output formats (such as HTML, LaTeX, ConTeXt,-RTF, OPML, DocBook, and Texinfo), information about-the character encoding is included in the document header, which-will only be included if you use the `-s/--standalone` option.--[`iconv`]: http://www.gnu.org/software/libiconv/--Creating a PDF-----------------To produce a PDF, specify an output file with a `.pdf` extension:--    pandoc test.txt -o test.pdf--By default, pandoc will use LaTeX to create the PDF, which requires-that a LaTeX engine be installed (see `--pdf-engine` below).--Alternatively, pandoc can use [ConTeXt], `pdfroff`, or any of the-following HTML/CSS-to-PDF-engines, to create a PDF: [`wkhtmltopdf`],-[`weasyprint`] or [`prince`].-To do this, specify an output file with a `.pdf` extension, as before,-but add the `--pdf-engine` option or `-t context`, `-t html`, or `-t ms`-to the command line (`-t html` defaults to `--pdf-engine=wkhtmltopdf`).--PDF output uses [variables for LaTeX] (with a LaTeX engine);-[variables for ConTeXt] (with ConTeXt); or [variables for `wkhtmltopdf`]-(an HTML/CSS-to-PDF engine; `--css` also affects the output).--To debug the PDF creation, it can be useful to look at the intermediate-representation: instead of `-o test.pdf`, use for example `-s -o test.tex`-to output the generated LaTeX. You can then test it with `pdflatex test.tex`.--When using LaTeX, the following packages need to be available-(they are included with all recent versions of [TeX Live]):-[`amsfonts`], [`amsmath`], [`lm`], [`unicode-math`],-[`ifxetex`], [`ifluatex`], [`listings`] (if the-`--listings` option is used), [`fancyvrb`], [`longtable`],-[`booktabs`], [`graphicx`] and [`grffile`] (if the document-contains images), [`hyperref`], [`xcolor`],-[`ulem`], [`geometry`] (with the `geometry` variable set),-[`setspace`] (with `linestretch`), and-[`babel`] (with `lang`).  The use of `xelatex` or `lualatex` as-the PDF engine requires [`fontspec`].  `xelatex` uses-[`polyglossia`] (with `lang`), [`xecjk`], and [`bidi`] (with the-`dir` variable set). If the `mathspec` variable is set,-`xelatex` will use [`mathspec`] instead of [`unicode-math`].-The [`upquote`] and [`microtype`] packages are used if-available, and [`csquotes`] will be used for [typography]-if `\usepackage{csquotes}` is present in the template or-included via `/H/--include-in-header`.  The [`natbib`],-[`biblatex`], [`bibtex`], and [`biber`] packages can optionally-be used for [citation rendering].  The following packages-will be used to improve output quality if present, but-pandoc does not require them to be present:-[`upquote`] (for straight quotes in verbatim environments),-[`microtype`] (for better spacing adjustments),-[`parskip`] (for better inter-paragraph spaces),-[`xurl`] (for better line breaks in URLs),-[`bookmark`] (for better PDF bookmarks),-and [`footnotehyper`] or [`footnote`] (to allow footnotes in tables).--[TeX Live]: http://www.tug.org/texlive/-[`amsfonts`]: https://ctan.org/pkg/amsfonts-[`amsmath`]: https://ctan.org/pkg/amsmath-[`babel`]: https://ctan.org/pkg/babel-[`biber`]: https://ctan.org/pkg/biber-[`biblatex`]: https://ctan.org/pkg/biblatex-[`bibtex`]: https://ctan.org/pkg/bibtex-[`bidi`]: https://ctan.org/pkg/bidi-[`bookmark`]: https://ctan.org/pkg/bookmark-[`booktabs`]: https://ctan.org/pkg/booktabs-[`csquotes`]: https://ctan.org/pkg/csquotes-[`fancyvrb`]: https://ctan.org/pkg/fancyvrb-[`fontspec`]: https://ctan.org/pkg/fontspec-[`footnote`]: https://ctan.org/pkg/footnote-[`footnotehyper`]: https://ctan.org/pkg/footnotehyper-[`geometry`]: https://ctan.org/pkg/geometry-[`graphicx`]: https://ctan.org/pkg/graphicx-[`grffile`]: https://ctan.org/pkg/grffile-[`hyperref`]: https://ctan.org/pkg/hyperref-[`ifluatex`]: https://ctan.org/pkg/ifluatex-[`ifxetex`]: https://ctan.org/pkg/ifxetex-[`listings`]: https://ctan.org/pkg/listings-[`lm`]: https://ctan.org/pkg/lm-[`longtable`]: https://ctan.org/pkg/longtable-[`mathspec`]: https://ctan.org/pkg/mathspec-[`microtype`]: https://ctan.org/pkg/microtype-[`natbib`]: https://ctan.org/pkg/natbib-[`parskip`]: https://ctan.org/pkg/parskip-[`polyglossia`]: https://ctan.org/pkg/polyglossia-[`prince`]: https://www.princexml.com/-[`setspace`]: https://ctan.org/pkg/setspace-[`ulem`]: https://ctan.org/pkg/ulem-[`unicode-math`]: https://ctan.org/pkg/unicode-math-[`upquote`]: https://ctan.org/pkg/upquote-[`weasyprint`]: http://weasyprint.org-[`wkhtmltopdf`]: https://wkhtmltopdf.org-[`xcolor`]: https://ctan.org/pkg/xcolor-[`xecjk`]: https://ctan.org/pkg/xecjk-[`xurl`]: https://ctan.org/pkg/xurl----Reading from the Web-----------------------Instead of an input 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--It is possible to supply a custom User-Agent string or other-header when requesting a document from a URL:--    pandoc -f html -t markdown --request-header User-Agent:"Mozilla/5.0" \-      http://www.fsf.org--Options-=======--General options {.options}------------------`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*--:   Specify input format.  *FORMAT* can be:--    ::: {#input-formats}-    - `commonmark` ([CommonMark] Markdown)-    - `creole` ([Creole 1.0])-    - `docbook` ([DocBook])-    - `docx` ([Word docx])-    - `dokuwiki` ([DokuWiki markup])-    - `epub` ([EPUB])-    - `fb2` ([FictionBook2] e-book)-    - `gfm` ([GitHub-Flavored Markdown]),-      or the deprecated and less accurate `markdown_github`;-      use [`markdown_github`](#markdown-variants) only-      if you need extensions not supported in [`gfm`](#markdown-variants).-    - `haddock` ([Haddock markup])-    - `html` ([HTML])-    - `ipynb` ([Jupyter notebook])-    - `jats` ([JATS] XML)-    - `json` (JSON version of native AST)-    - `latex` ([LaTeX])-    - `markdown` ([Pandoc's Markdown])-    - `markdown_mmd` ([MultiMarkdown])-    - `markdown_phpextra` ([PHP Markdown Extra])-    - `markdown_strict` (original unextended [Markdown])-    - `mediawiki` ([MediaWiki markup])-    - `man` ([roff man])-    - `muse` ([Muse])-    - `native` (native Haskell)-    - `odt` ([ODT])-    - `opml` ([OPML])-    - `org` ([Emacs Org mode])-    - `rst` ([reStructuredText])-    - `t2t` ([txt2tags])-    - `textile` ([Textile])-    - `tikiwiki` ([TikiWiki markup])-    - `twiki` ([TWiki markup])-    - `vimwiki` ([Vimwiki])-    :::--    Extensions can be individually enabled or disabled by-    appending `+EXTENSION` or `-EXTENSION` to the format name.-    See [Extensions] below, for a list of extensions and-    their names.  See `--list-input-formats` and `--list-extensions`,-    below.--`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*--:   Specify output format.  *FORMAT* can be:--    ::: {#output-formats}-    - `asciidoc` ([AsciiDoc]) or `asciidoctor` ([AsciiDoctor])-    - `beamer` ([LaTeX beamer][`beamer`] slide show)-    - `commonmark` ([CommonMark] Markdown)-    - `context` ([ConTeXt])-    - `docbook` or `docbook4` ([DocBook] 4)-    - `docbook5` (DocBook 5)-    - `docx` ([Word docx])-    - `dokuwiki` ([DokuWiki markup])-    - `epub` or `epub3` ([EPUB] v3 book)-    - `epub2` (EPUB v2)-    - `fb2` ([FictionBook2] e-book)-    - `gfm` ([GitHub-Flavored Markdown]),-      or the deprecated and less accurate `markdown_github`;-      use [`markdown_github`](#markdown-variants) only-      if you need extensions not supported in [`gfm`](#markdown-variants).-    - `haddock` ([Haddock markup])-    - `html` or `html5` ([HTML], i.e. [HTML5]/XHTML [polyglot markup])-    - `html4` ([XHTML] 1.0 Transitional)-    - `icml` ([InDesign ICML])-    - `ipynb` ([Jupyter notebook])-    - `jats` ([JATS] XML)-    - `jira` ([Jira] wiki markup)-    - `json` (JSON version of native AST)-    - `latex` ([LaTeX])-    - `man` ([roff man])-    - `markdown` ([Pandoc's Markdown])-    - `markdown_mmd` ([MultiMarkdown])-    - `markdown_phpextra` ([PHP Markdown Extra])-    - `markdown_strict` (original unextended [Markdown])-    - `mediawiki` ([MediaWiki markup])-    - `ms` ([roff ms])-    - `muse` ([Muse]),-    - `native` (native Haskell),-    - `odt` ([OpenOffice text document][ODT])-    - `opml` ([OPML])-    - `opendocument` ([OpenDocument])-    - `org` ([Emacs Org mode])-    - `plain` (plain text),-    - `pptx` ([PowerPoint] slide show)-    - `rst` ([reStructuredText])-    - `rtf` ([Rich Text Format])-    - `texinfo` ([GNU Texinfo])-    - `textile` ([Textile])-    - `slideous` ([Slideous] HTML and JavaScript slide show)-    - `slidy` ([Slidy] HTML and JavaScript slide show)-    - `dzslides` ([DZSlides] HTML5 + JavaScript slide show),-    - `revealjs` ([reveal.js] HTML5 + JavaScript slide show)-    - `s5` ([S5] HTML and JavaScript slide show)-    - `tei` ([TEI Simple])-    - `xwiki` ([XWiki markup])-    - `zimwiki` ([ZimWiki markup])-    - the path of a custom lua writer, see [Custom writers] below-    :::--    Note that `odt`, `docx`, and `epub` output will not be directed-    to *stdout* unless forced with `-o -`.--    Extensions can be individually enabled or-    disabled by appending `+EXTENSION` or `-EXTENSION` to the format-    name.  See [Extensions] below, for a list of extensions and their-    names.  See `--list-output-formats` and `--list-extensions`, below.--`-o` *FILE*, `--output=`*FILE*--:   Write output to *FILE* instead of *stdout*.  If *FILE* is-    `-`, output will go to *stdout*, even if a non-textual format-    (`docx`, `odt`, `epub2`, `epub3`) is specified.--`--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.  On \*nix and macOS systems this will be the `pandoc`-    subdirectory of the XDG data directory (by default,-    `$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`-    environment variable).  If that directory does not exist,-    `$HOME/.pandoc` will be used (for backwards compatibility).-    In Windows the default user data directory is-    `C:\Users\USERNAME\AppData\Roaming\pandoc`.-    You can find the default user data directory on your system by-    looking at the output of `pandoc --version`.-    A `reference.odt`, `reference.docx`, `epub.css`, `templates`,-    `slidy`, `slideous`, or `s5` directory-    placed in this directory will override pandoc's normal defaults.--`--bash-completion`--:   Generate a bash completion script.  To enable bash completion-    with pandoc, add this to your `.bashrc`:--        eval "$(pandoc --bash-completion)"--`--verbose`--:   Give verbose debugging output.  Currently this only has an effect-    with PDF output.--`--quiet`--:   Suppress warning messages.--`--fail-if-warnings`--:   Exit with error status if there are any warnings.--`--log=`*FILE*--:   Write log messages in machine-readable JSON format to-    *FILE*.  All messages above DEBUG level will be written,-    regardless of verbosity settings (`--verbose`, `--quiet`).--`--list-input-formats`--:   List supported input formats, one per line.--`--list-output-formats`--:   List supported output formats, one per line.--`--list-extensions`[`=`*FORMAT*]--:   List supported extensions, one per line, preceded-    by a `+` or `-` indicating whether it is enabled by default-    in *FORMAT*. If *FORMAT* is not specified, defaults for-    pandoc's Markdown are given.--`--list-highlight-languages`--:   List supported languages for syntax highlighting, one per-    line.--`--list-highlight-styles`--:   List supported styles for syntax highlighting, one per line.-    See `--highlight-style`.--`-v`, `--version`--:   Print version.--`-h`, `--help`--:   Show usage message.--[Markdown]: http://daringfireball.net/projects/markdown/-[CommonMark]: http://commonmark.org-[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/-[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/-[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/-[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/-[Slideous]: http://goessner.net/articles/slideous/-[HTML]: http://www.w3.org/html/-[HTML5]: http://www.w3.org/TR/html5/-[polyglot markup]: https://www.w3.org/TR/html-polyglot/-[XHTML]: http://www.w3.org/TR/xhtml1/-[LaTeX]: http://latex-project.org-[`beamer`]: https://ctan.org/pkg/beamer-[Beamer User's Guide]: http://mirrors.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf-[ConTeXt]: http://www.contextgarden.net/-[Rich Text Format]: http://en.wikipedia.org/wiki/Rich_Text_Format-[DocBook]: http://docbook.org-[JATS]: https://jats.nlm.nih.gov-[Jira]: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all-[txt2tags]: http://txt2tags.org-[EPUB]: http://idpf.org/epub-[OPML]: http://dev.opml.org/spec2.html-[OpenDocument]: http://opendocument.xml.org-[ODT]: http://en.wikipedia.org/wiki/OpenDocument-[Textile]: http://redcloth.org/textile-[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting-[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki-[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html-[XWiki markup]: https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiSyntax/-[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules-[TikiWiki markup]: https://doc.tiki.org/Wiki-Syntax-Text#The_Markup_Language_Wiki-Syntax-[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html-[Creole 1.0]: http://www.wikicreole.org/wiki/Creole1.0-[roff man]: http://man7.org/linux/man-pages/man7/groff_man.7.html-[roff ms]: http://man7.org/linux/man-pages/man7/groff_ms.7.html-[Haskell]: https://www.haskell.org-[GNU Texinfo]: http://www.gnu.org/software/texinfo/-[Emacs Org mode]: http://orgmode.org-[AsciiDoc]: http://www.methods.co.nz/asciidoc/-[AsciiDoctor]: https://asciidoctor.org/-[DZSlides]: http://paulrouget.com/dzslides/-[Word docx]: https://en.wikipedia.org/wiki/Office_Open_XML-[PDF]: https://www.adobe.com/pdf/-[reveal.js]: http://lab.hakim.se/reveal-js/-[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1-[Jupyter notebook]: https://nbformat.readthedocs.io/en/latest/-[InDesign ICML]: http://wwwimages.adobe.com/www.adobe.com/content/dam/acom/en/devnet/indesign/sdk/cs6/idml/idml-cookbook.pdf-[TEI Simple]: https://github.com/TEIC/TEI-Simple-[Muse]: https://amusewiki.org/library/manual-[PowerPoint]: https://en.wikipedia.org/wiki/Microsoft_PowerPoint-[Vimwiki]: https://vimwiki.github.io--Reader options {.options}-----------------`--base-header-level=`*NUMBER*--:   Specify the base level for headings (defaults to 1).--`--strip-empty-paragraphs`--:   *Deprecated.  Use the `+empty_paragraphs` extension instead.*-    Ignore paragraphs with no content.  This option is useful-    for converting word processing documents where users have-    used empty paragraphs to create inter-paragraph space.--`--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.--`--default-image-extension=`*EXTENSION*--:   Specify a default extension to use when image paths/URLs have no-    extension.  This allows you to use the same source for formats that-    require different kinds of images.  Currently this option only affects-    the Markdown and LaTeX readers.--`--file-scope`--:   Parse each file individually before combining for multifile-    documents. This will allow footnotes in different files with the-    same identifiers to work as expected. If this option is set,-    footnotes and links will not work across files. Reading binary-    files (docx, odt, epub) implies `--file-scope`.--`-F` *PROGRAM*, `--filter=`*PROGRAM*--:   Specify an executable to be used as a filter transforming the-    pandoc AST after the input is parsed and before the output is-    written.  The executable should read JSON from stdin and write-    JSON to stdout.  The JSON must be formatted like  pandoc's own-    JSON input and output.  The name of the output format will be-    passed to the filter as the first argument.  Hence,--        pandoc --filter ./caps.py -t latex--    is equivalent to--        pandoc -t json | ./caps.py latex | pandoc -f json -t latex--    The latter form may be useful for debugging filters.--    Filters may be written in any language.  `Text.Pandoc.JSON`-    exports `toJSONFilter` to facilitate writing filters in Haskell.-    Those who would prefer to write filters in python can use the-    module [`pandocfilters`], installable from PyPI. There are also-    pandoc filter libraries in [PHP], [perl], and-    [JavaScript/node.js].--    In order of preference, pandoc will look for filters in--     1. a specified full or relative path (executable or-     non-executable)--     2. `$DATADIR/filters` (executable or non-executable)-     where `$DATADIR` is the user data directory (see-     `--data-dir`, above).--     3. `$PATH` (executable only)--    Filters and lua-filters are applied in the order specified-    on the command line.--`--lua-filter=`*SCRIPT*--:   Transform the document in a similar fashion as JSON filters (see-    `--filter`), but use pandoc's build-in lua filtering system.  The given-    lua script is expected to return a list of lua filters which will be-    applied in order.  Each lua filter must contain element-transforming-    functions indexed by the name of the AST element on which the filter-    function should be applied.--    The `pandoc` lua module provides helper functions for element-    creation.  It is always loaded into the script's lua environment.--    The following is an example lua script for macro-expansion:--        function expand_hello_world(inline)-          if inline.c == '{{helloworld}}' then-            return pandoc.Emph{ pandoc.Str "Hello, World" }-          else-            return inline-          end-        end--        return {{Str = expand_hello_world}}--    In order of preference, pandoc will look for lua filters in--     1. a specified full or relative path (executable or-     non-executable)--     2. `$DATADIR/filters` (executable or non-executable)-     where `$DATADIR` is the user data directory (see-     `--data-dir`, above).--`-M` *KEY*[`=`*VAL*], `--metadata=`*KEY*[`:`*VAL*]--:   Set the metadata field *KEY* to the value *VAL*.  A value specified-    on the command line overrides a value specified in the document-    using [YAML metadata blocks][Extension: `yaml_metadata_block`].-    Values will be parsed as YAML boolean or string values. If no value is-    specified, the value will be treated as Boolean true.  Like-    `--variable`, `--metadata` causes template variables to be set.-    But unlike `--variable`, `--metadata` affects the metadata of the-    underlying document (which is accessible from filters and may be-    printed in some output formats) and metadata values will be escaped-    when inserted into the template.--`--metadata-file=`*FILE*--:   Read metadata from the supplied YAML (or JSON) file.-    This option can be used with every input format, but string-    scalars in the YAML file will always be parsed as Markdown.-    Generally, the input will be handled the same as in-    [YAML metadata blocks][Extension: `yaml_metadata_block`].-    Metadata values specified inside the document, or by using `-M`,-    overwrite values specified with this option.--`-p`, `--preserve-tabs`--:   Preserve tabs instead of converting them to spaces (the default).-    Note that this will only affect tabs in literal code spans and code-    blocks; tabs in regular text will be treated as spaces.--`--tab-stop=`*NUMBER*--:   Specify the number of spaces per tab (default is 4).--`--track-changes=accept`|`reject`|`all`--:   Specifies what to do with insertions, deletions, and comments-    produced by the MS Word "Track Changes" feature.  `accept` (the-    default), inserts all insertions, and ignores all-    deletions. `reject` inserts all deletions and ignores-    insertions. Both `accept` and `reject` ignore comments. `all` puts-    in insertions, deletions, and comments, wrapped in spans with-    `insertion`, `deletion`, `comment-start`, and `comment-end`-    classes, respectively. The author and time of change is-    included. `all` is useful for scripting: only accepting changes-    from a certain reviewer, say, or before a certain date. If a-    paragraph is inserted or deleted, `track-changes=all` produces a-    span with the class `paragraph-insertion`/`paragraph-deletion`-    before the affected paragraph break. This option only affects the-    docx reader.--`--extract-media=`*DIR*--:   Extract images and other media contained in or linked from-    the source document to the path *DIR*, creating it if-    necessary, and adjust the images references in the document-    so they point to the extracted files.  If the source format is-    a binary container (docx, epub, or odt), the media is-    extracted from the container and the original-    filenames are used. Otherwise the media is read from the-    file system or downloaded, and new filenames are constructed-    based on SHA1 hashes of the contents.--`--abbreviations=`*FILE*--:   Specifies a custom abbreviations file, with abbreviations-    one to a line.  If this option is not specified, pandoc will-    read the data file `abbreviations` from the user data-    directory or fall back on a system default.  To see the-    system default, use-    `pandoc --print-default-data-file=abbreviations`.  The only-    use pandoc makes of this list is in the Markdown reader.-    Strings ending in a period that are found in this list will-    be followed by a nonbreaking space, so that the period will-    not produce sentence-ending space in formats like LaTeX.--[`pandocfilters`]: https://github.com/jgm/pandocfilters-[PHP]: https://github.com/vinai/pandocfilters-php-[perl]: https://metacpan.org/pod/Pandoc::Filter-[JavaScript/node.js]: https://github.com/mvhenderson/pandoc-filter-node--General writer options {.options}-------------------------`-s`, `--standalone`--:   Produce output with an appropriate header and footer (e.g. a-    standalone HTML, LaTeX, TEI, or RTF file, not a fragment).  This option-    is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`-    output.  For `native` output, this option causes metadata to-    be included; otherwise, metadata is suppressed.--`--template=`*FILE*|*URL*--:   Use the specified file as a custom template for the generated document.-    Implies `--standalone`. See [Templates], below, for a description-    of template syntax. If no extension is specified, an extension-    corresponding to the writer will be added, so that `--template=special`-    looks for `special.html` for HTML output.  If the template is not-    found, pandoc will search for it in the `templates` subdirectory of-    the user data directory (see `--data-dir`). If this option is not used,-    a default template appropriate for the output format will be used (see-    `-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 generally only useful when the-    `--template` option is used to specify a custom template, since-    pandoc automatically sets the variables used in the default-    templates.  If no *VAL* is specified, the key will be given the-    value `true`.--`-D` *FORMAT*, `--print-default-template=`*FORMAT*--:   Print the system default template for an output *FORMAT*. (See `-t`-    for a list of possible *FORMAT*s.)  Templates in the user data-    directory are ignored.  This option may be used with-    `-o`/`--output` to redirect output to a file, but-    `-o`/`--output` must come before `--print-default-template`-    on the command line.--`--print-default-data-file=`*FILE*--:   Print a system default data file.  Files in the user data directory-    are ignored.  This option may be used with `-o`/`--output` to-    redirect output to a file, but `-o`/`--output` must come before-    `--print-default-data-file` on the command line.--`--eol=crlf`|`lf`|`native`--:   Manually specify line endings: `crlf` (Windows), `lf`-    (macOS/Linux/UNIX), or `native` (line endings appropriate-    to the OS on which pandoc is being run).  The default is-    `native`.--`--dpi`=*NUMBER*--:   Specify the dpi (dots per inch) value for conversion from pixels-    to inch/centimeters and vice versa. The default is 96dpi.-    Technically, the correct term would be ppi (pixels per inch).--`--wrap=auto`|`none`|`preserve`--:   Determine how text is wrapped in the output (the source-    code, not the rendered version).  With `auto` (the default),-    pandoc will attempt to wrap lines to the column width specified by-    `--columns` (default 72).  With `none`, pandoc will not wrap-    lines at all.  With `preserve`, pandoc will attempt to-    preserve the wrapping from the source document (that is,-    where there are nonsemantic newlines in the source, there-    will be nonsemantic newlines in the output as well).-    Automatic wrapping does not currently work in HTML output.-    In `ipynb` output, this option affects wrapping of the-    contents of markdown cells.--`--columns=`*NUMBER*--:   Specify length of lines in characters.  This affects text wrapping-    in the generated source code (see `--wrap`).  It also affects-    calculation of column widths for plain text tables (see [Tables] below).--`--toc`, `--table-of-contents`--:   Include an automatically generated table of contents (or, in-    the case of `latex`, `context`, `docx`, `odt`,-    `opendocument`, `rst`, or `ms`, an instruction to create-    one) in the output document. This option has no effect-    unless `-s/--standalone` is used, and it has no effect-    on `man`, `docbook4`, `docbook5`, or `jats` output.--    Note that if you are producing a PDF via `ms`, the table-    of contents will appear at the beginning of the-    document, before the title.  If you would prefer it to-    be at the end of the document, use the option-    `--pdf-engine-opt=--no-toc-relocation`.--`--toc-depth=`*NUMBER*--:   Specify the number of section levels to include in the table-    of contents.  The default is 3 (which means that level-1, 2, and 3-    headings will be listed in the contents).--`--strip-comments`--:   Strip out HTML comments in the Markdown or Textile source,-    rather than passing them on to Markdown, Textile or HTML-    output as raw HTML.  This does not apply to HTML comments-    inside raw HTML blocks when the `markdown_in_html_blocks`-    extension is not set.--`--no-highlight`--:   Disables syntax highlighting for code blocks and inlines, even when-    a language attribute is given.--`--highlight-style=`*STYLE*|*FILE*--:   Specifies the coloring style to be used in highlighted source code.-    Options are `pygments` (the default), `kate`, `monochrome`,-    `breezeDark`, `espresso`, `zenburn`, `haddock`, and `tango`.-    For more information on syntax highlighting in pandoc, see-    [Syntax highlighting], below.  See also-    `--list-highlight-styles`.--    Instead of a *STYLE* name, a JSON file with extension-    `.theme` may be supplied.  This will be parsed as a KDE-    syntax highlighting theme and (if valid) used as the-    highlighting style.--    To generate the JSON version of an existing style,-    use `--print-highlight-style`.--`--print-highlight-style=`*STYLE*|*FILE*--:   Prints a JSON version of a highlighting style, which can-    be modified, saved with a `.theme` extension, and used-    with `--highlight-style`.  This option may be used with-    `-o`/`--output` to redirect output to a file, but-    `-o`/`--output` must come before `--print-highlight-style`-    on the command line.--`--syntax-definition=`*FILE*--:   Instructs pandoc to load a KDE XML syntax definition file,-    which will be used for syntax highlighting of appropriately-    marked code blocks.  This can be used to add support for-    new languages or to use altered syntax definitions for-    existing languages.--`-H` *FILE*, `--include-in-header=`*FILE*|*URL*--:   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` *FILE*, `--include-before-body=`*FILE*|*URL*--:   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` *FILE*, `--include-after-body=`*FILE*|*URL*--:   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 used-    repeatedly to include multiple files. They will be included in the-    order specified.  Implies `--standalone`.--`--resource-path=`*SEARCHPATH*--:   List of paths to search for images and other resources.-    The paths should be separated by `:` on Linux, UNIX, and-    macOS systems, and by `;` on Windows.  If `--resource-path`-    is not specified, the default resource path is the working-    directory. Note that, if `--resource-path` is specified,-    the working directory must be explicitly listed or it-    will not be searched.  For example:-    `--resource-path=.:test` will search the working directory-    and the `test` subdirectory, in that order.--    `--resource-path` only has an effect if (a) the output-    format embeds images (for example, `docx`, `pdf`, or `html`-    with `--self-contained`) or (b) it is used together with-    `--extract-media`.--`--request-header=`*NAME*`:`*VAL*--:   Set the request header *NAME* to the value *VAL* when making-    HTTP requests (for example, when a URL is given on the-    command line, or when resources used in a document must be-    downloaded). If you're behind a proxy, you also need to set-    the environment variable `http_proxy` to `http://...`.--Options affecting specific writers {.options}-------------------------------------`--self-contained`--:   Produce a standalone HTML file with no external dependencies, using-    `data:` URIs to incorporate the contents of linked scripts, stylesheets,-    images, and videos. Implies `--standalone`. The resulting file should be-    "self-contained," in the sense that it needs no external files and no net-    access to be displayed properly by a browser. This option works only with-    HTML output formats, including `html4`, `html5`, `html+lhs`, `html5+lhs`,-    `s5`, `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images,-    and stylesheets at absolute URLs will be downloaded; those at relative-    URLs will be sought relative to the working directory (if the first source-    file is local) or relative to the base URL (if the first source-    file is remote).  Elements with the attribute-    `data-external="1"` will be left alone; the documents they-    link to will not be incorporated in the document.-    Limitation: resources that are loaded dynamically through-    JavaScript cannot be incorporated; as a result,-    `--self-contained` does not work with `--mathjax`, and some-    advanced features (e.g.  zoom or speaker notes) may not work-    in an offline "self-contained" `reveal.js` slide show.--`--html-q-tags`--:   Use `<q>` tags for quotes in HTML.--`--ascii`--:   Use only ASCII characters in output. Currently supported for XML-    and HTML formats (which use entities instead of UTF-8 when this-    option is selected), CommonMark, gfm, and Markdown (which use-    entities), roff ms (which use hexadecimal escapes), and to a-    limited degree LaTeX (which uses standard commands for accented-    characters when possible). roff man output uses ASCII by default.--`--reference-links`--:   Use reference-style links, rather than inline links, in writing Markdown-    or reStructuredText.  By default inline links are used.  The-    placement of link references is affected by the-    `--reference-location` option.--`--reference-location = block`|`section`|`document`--:   Specify whether footnotes (and references, if `reference-links` is-    set) are placed at the end of the current (top-level) block, the-    current section, or the document. The default is-    `document`. Currently only affects the markdown writer.--`--atx-headers`--:   Use ATX-style headings in Markdown output. The default is-    to use setext-style headings for levels 1 to 2, and then ATX headings.-    (Note: for `gfm` output, ATX headings are always used.)-    This option also affects markdown cells in `ipynb` output.--`--top-level-division=[default|section|chapter|part]`--:   Treat top-level headings as the given division type in LaTeX, ConTeXt,-    DocBook, and  TEI output. The hierarchy order is part, chapter, then section;-    all headings are shifted such that the top-level heading becomes the specified-    type. The default behavior is to determine the best division type via-    heuristics: unless other conditions apply, `section` is chosen. When the-    LaTeX document class is set to `report`, `book`, or `memoir` (unless the-    `article` option is specified), `chapter` is implied as the setting for this-    option. If `beamer` is the output format, specifying either `chapter` or-    `part` will cause top-level headings to become `\part{..}`, while-    second-level headings remain as their default type.--`-N`, `--number-sections`--:   Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.-    By default, sections are not numbered.  Sections with class-    `unnumbered` will never be numbered, even if `--number-sections`-    is specified.--`--number-offset=`*NUMBER*[`,`*NUMBER*`,`*...*]--:   Offset for section headings in HTML output (ignored in other-    output formats).  The first number is added to the section number for-    top-level headings, the second for second-level headings, and so on.-    So, for example, if you want the first top-level heading in your-    document to be numbered "6", specify `--number-offset=5`.-    If your document starts with a level-2 heading which you want to-    be numbered "1.5", specify `--number-offset=1,4`.-    Offsets are 0 by default.  Implies `--number-sections`.--`--listings`--:   Use the [`listings`] package for LaTeX code blocks. The package-    does not support multi-byte encoding for source code. To handle UTF-8-    you would need to use a custom template. This issue is fully -    documented here: [Encoding issue with the listings package].--`-i`, `--incremental`--:   Make list items in slide shows display incrementally (one by one).-    The default is for lists to be displayed all at once.--`--slide-level=`*NUMBER*--:   Specifies that headings with the specified level create-    slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`).  Headings-    above this level in the hierarchy are used to divide the-    slide show into sections; headings below this level create-    subheads within a slide.  Note that content that is-    not contained under slide-level headings will not appear in-    the slide show.  The default is to set the slide level based-    on the contents of the document; see [Structuring the slide-    show].--`--section-divs`--:   Wrap sections in `<section>` tags (or `<div>` tags for `html4`),-    and attach identifiers to the enclosing `<section>` (or `<div>`)-    rather than the heading itself. See-    [Heading identifiers], below.--`--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.  The default-    is `none`.--`--id-prefix=`*STRING*--:   Specify a prefix to be added to all identifiers and internal links-    in HTML and DocBook output, and to footnote numbers in Markdown-    and Haddock output. This is useful for preventing duplicate-    identifiers when generating fragments to be included in other pages.--`-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`.--`-c` *URL*, `--css=`*URL*--:   Link to a CSS style sheet. This option can be used repeatedly to-    include multiple files. They will be included in the order specified.--    A stylesheet is required for generating EPUB.  If none is-    provided using this option (or the `css` or `stylesheet`-    metadata fields), pandoc will look for a file `epub.css` in the-    user data directory (see `--data-dir`).  If it is not-    found there, sensible defaults will be used.--`--reference-doc=`*FILE*--:   Use the specified file as a style reference in producing a-    docx or ODT file.--    Docx--    :   For best results, the reference docx should be a modified-        version of a docx file produced using pandoc.  The contents-        of the reference docx are ignored, but its stylesheets and-        document properties (including margins, page size, header,-        and footer) are used in the new docx. If no reference docx-        is specified on the command line, pandoc will look for a-        file `reference.docx` in the user data directory (see-        `--data-dir`). If this is not found either, sensible-        defaults will be used.--        To produce a custom `reference.docx`, first get a copy of-        the default `reference.docx`: `pandoc-        -o custom-reference.docx --print-default-data-file reference.docx`.-        Then open `custom-reference.docx` in Word, modify the-        styles as you wish, and save the file.  For best-        results, do not make changes to this file other than-        modifying the styles used by pandoc:--        Paragraph styles:--        - Normal-        - Body Text-        - First Paragraph-        - Compact-        - Title-        - Subtitle-        - Author-        - Date-        - Abstract-        - Bibliography-        - Heading 1-        - Heading 2-        - Heading 3-        - Heading 4-        - Heading 5-        - Heading 6-        - Heading 7-        - Heading 8-        - Heading 9-        - Block Text-        - Footnote Text-        - Definition Term-        - Definition-        - Caption-        - Table Caption-        - Image Caption-        - Figure-        - Captioned Figure-        - TOC Heading--        Character styles:--        - Default Paragraph Font-        - Body Text Char-        - Verbatim Char-        - Footnote Reference-        - Hyperlink--        Table style:--        - Table--    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.--        To produce a custom `reference.odt`, first get a copy of-        the default `reference.odt`: `pandoc-        -o custom-reference.odt --print-default-data-file reference.odt`.-        Then open `custom-reference.odt` in LibreOffice, modify-        the styles as you wish, and save the file.--    PowerPoint--    :   Templates included with Microsoft PowerPoint 2013 (either with-        `.pptx` or `.potx` extension) are known to work, as are most-        templates derived from these.--        The specific requirement is that the template should begin with-        the following first four layouts:--        1. Title Slide-        2. Title and Content-        3. Section Header-        4. Two Content--        All templates included with a recent version of MS PowerPoint-        will fit these criteria. (You can click on `Layout` under the-        `Home` menu to check.)--        You can also modify the default `reference.pptx`: first run-        `pandoc -o custom-reference.pptx --print-default-data-file-        reference.pptx`, and then modify `custom-reference.pptx`-        in MS PowerPoint (pandoc will use the first four layout-        slides, as mentioned above).--`--epub-cover-image=`*FILE*--:   Use the specified image as the EPUB cover.  It is recommended-    that the image be less than 1000px in width and height. Note that-    in a Markdown source document you can also specify `cover-image`-    in a YAML metadata block (see [EPUB Metadata], below).--`--epub-metadata=`*FILE*--:   Look in the specified XML file for metadata for the EPUB.-    The file should contain a series of [Dublin Core elements].-    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:date>` (from the document date, which should-    be in [ISO 8601 format]), `<dc:language>` (from the `lang`-    variable, or, if is not set, the locale), and `<dc:identifier-    id="BookId">` (a randomly generated UUID). Any of these may be-    overridden by elements in the metadata file.--    Note: if the source document is Markdown, a YAML metadata block-    in the document can be used instead.  See below under-    [EPUB Metadata].--`--epub-embed-font=`*FILE*--:   Embed the specified font in the EPUB. This option can be repeated-    to embed multiple fonts.  Wildcards can also be used: for example,-    `DejaVuSans-*.ttf`.  However, if you use wildcards on the command-    line, be sure to escape them or put the whole filename in single quotes,-    to prevent them from being interpreted by the shell. To use the-    embedded fonts, you will need to add declarations like the following-    to your CSS (see `--css`):--        @font-face {-        font-family: DejaVuSans;-        font-style: normal;-        font-weight: normal;-        src:url("DejaVuSans-Regular.ttf");-        }-        @font-face {-        font-family: DejaVuSans;-        font-style: normal;-        font-weight: bold;-        src:url("DejaVuSans-Bold.ttf");-        }-        @font-face {-        font-family: DejaVuSans;-        font-style: italic;-        font-weight: normal;-        src:url("DejaVuSans-Oblique.ttf");-        }-        @font-face {-        font-family: DejaVuSans;-        font-style: italic;-        font-weight: bold;-        src:url("DejaVuSans-BoldOblique.ttf");-        }-        body { font-family: "DejaVuSans"; }--`--epub-chapter-level=`*NUMBER*--:   Specify the heading level at which to split the EPUB into separate-    "chapter" files. The default is to split into chapters at level-1-    headings. This option only affects the internal composition of the-    EPUB, not the way chapters and sections are displayed to users. Some-    readers may be slow if the chapter files are too large, so for large-    documents with few level-1 headings, one might want to use a chapter-    level of 2 or 3.--`--epub-subdirectory=`*DIRNAME*--:   Specify the subdirectory in the OCF container that is to hold-    the EPUB-specific contents.  The default is `EPUB`.  To put-    the EPUB contents in the top level, use an empty string.--`--ipynb-output=all|none|best`--:   Determines how ipynb output cells are treated. `all` means-    that all of the data formats included in the original are-    preserved.  `none` means that the contents of data cells-    are omitted.  `best` causes pandoc to try to pick the-    richest data block in each output cell that is compatible-    with the output format.  The default is `best`.--`--pdf-engine=`*PROGRAM*--:   Use the specified engine when producing PDF output.-    Valid values are `pdflatex`, `lualatex`, `xelatex`, `latexmk`,-    `tectonic`, `wkhtmltopdf`, `weasyprint`, `prince`, `context`,-    and `pdfroff`. The default is `pdflatex`.  If the engine is-    not in your PATH, the full path of the engine may be specified here.--`--pdf-engine-opt=`*STRING*--:   Use the given string as a command-line argument to the `pdf-engine`.-    For example, to use a persistent directory `foo` for `latexmk`'s-    auxiliary files, use `--pdf-engine-opt=-outdir=foo`.-    Note that no check for duplicate options is done.--[Dublin Core elements]: http://dublincore.org/documents/dces/-[ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime-[Encoding issue with the listings package]:-  https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Encoding_issue--Citation rendering {.options}---------------------`--bibliography=`*FILE*--:   Set the `bibliography` field in the document's metadata to *FILE*,-    overriding any value set in the metadata, and process citations-    using `pandoc-citeproc`. (This is equivalent to-    `--metadata bibliography=FILE --filter pandoc-citeproc`.)-    If `--natbib` or `--biblatex` is also supplied, `pandoc-citeproc` is not-    used, making this equivalent to `--metadata bibliography=FILE`.-    If you supply this argument multiple times, each *FILE* will be added-    to bibliography.--`--csl=`*FILE*--:   Set the `csl` field in the document's metadata to *FILE*,-    overriding any value set in the metadata.  (This is equivalent to-    `--metadata csl=FILE`.)-    This option is only relevant with `pandoc-citeproc`.--`--citation-abbreviations=`*FILE*--:   Set the `citation-abbreviations` field in the document's metadata to-    *FILE*, overriding any value set in the metadata.  (This is equivalent to-    `--metadata citation-abbreviations=FILE`.)-    This option is only relevant with `pandoc-citeproc`.--`--natbib`--:   Use [`natbib`] for citations in LaTeX output.  This option is not for use-    with the `pandoc-citeproc` filter or with PDF output.  It is intended for-    use in producing a LaTeX file that can be processed with [`bibtex`].--`--biblatex`--:   Use [`biblatex`] for citations in LaTeX output.  This option is not for use-    with the `pandoc-citeproc` filter or with PDF output. It is intended for-    use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].--Math rendering in HTML {.options}-------------------------The default is to render TeX math as far as possible using Unicode characters.-Formulas are put inside a `span` with `class="math"`, so that they may be styled-differently from the surrounding text if needed. However, this gives acceptable-results only for basic math, usually you will want to use `--mathjax` or another-of the following options.--`--mathjax`[`=`*URL*]--:   Use [MathJax] to display embedded TeX math in HTML output.-    TeX math will be put between `\(...\)` (for inline math)-    or `\[...\]` (for display math) and wrapped in `<span>` tags-    with class `math`. Then the MathJax JavaScript will render it.-    The *URL* should point to the `MathJax.js` load script.-    If a *URL* is not provided, a link to the Cloudflare CDN will-    be inserted.--`--mathml`--:   Convert TeX math to [MathML] (in `epub3`, `docbook4`, `docbook5`, `jats`,-    `html4` and `html5`).  This is the default in `odt` output. Note that-    currently only Firefox and Safari (and select e-book readers) natively-    support MathML.--`--webtex`[`=`*URL*]--:   Convert TeX formulas 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. For SVG images you can for-    example use `--webtex https://latex.codecogs.com/svg.latex?`.-    If no URL is specified, the CodeCogs URL generating PNGs-    will be used (`https://latex.codecogs.com/png.latex?`).-    Note:  the `--webtex` option will affect Markdown output-    as well as HTML, which is useful if you're targeting a-    version of Markdown without native math support.--`--katex`[`=`*URL*]--:   Use [KaTeX] to display embedded TeX math in HTML output.-    The *URL* is the base URL for the KaTeX library. That directory-    should contain a `katex.min.js` and a `katex.min.css` file.-    If a *URL* is not provided, a link to the KaTeX CDN will be inserted.--`--gladtex`--:   Enclose TeX math in `<eq>` tags in HTML output.  The resulting HTML-    can then be processed by [GladTeX] to produce images of the typeset-    formulas and an HTML file with links to these images.-    So, the procedure is:--        pandoc -s --gladtex input.md -o myfile.htex-        gladtex -d myfile-images myfile.htex-        # produces myfile.html and images in myfile-images--[MathML]: http://www.w3.org/Math/-[MathJax]: https://www.mathjax.org-[KaTeX]: https://github.com/Khan/KaTeX-[GladTeX]: http://humenda.github.io/GladTeX/--Options for wrapper scripts {.options}------------------------------`--dump-args`--:   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`--:   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--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 -D *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/default.*FORMAT*` in the user data-directory (see `--data-dir`, above). *Exceptions:*--- For `odt` output, customize the `default.opendocument`-  template.-- For `pdf` output, customize the `default.latex` template-  (or the `default.context` template, if you use `-t context`,-  or the `default.ms` template, if you use `-t ms`, or the-  `default.html` template, if you use `-t html`).-- `docx` and `pptx` have no template (however, you can use-  `--reference-doc` to customize the output).--Templates contain *variables*, which allow for the inclusion of-arbitrary information at any point in the file. They may be set at the-command line using the `-V/--variable` option. If a variable is not set,-pandoc will look for the key in the document's metadata – which can be set-using either [YAML metadata blocks][Extension: `yaml_metadata_block`]-or with the `-M/--metadata` option.--Metadata variables---------------------`title`, `author`, `date`-:   allow identification of basic aspects of the document.  Included-    in PDF metadata through LaTeX and ConTeXt.  These can be set-    through a [pandoc title block][Extension: `pandoc_title_block`],-    which allows for multiple authors, or through a YAML metadata block:--        ----        author:-        - Aristotle-        - Peter Abelard-        ...--    Note that if you just want to set PDF or HTML metadata, without-    including a title block in the document itself, you can-    set the `title-meta`, `author-meta`, and `date-meta`-    variables.  (By default these are set automatically, based-    on `title`, `author`, and `date`.)--`subtitle`-:   document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx-    documents--`abstract`-:   document summary, included in LaTeX, ConTeXt, AsciiDoc, and docx-    documents--`keywords`-:   list of keywords to be included in HTML, PDF, ODT, pptx, docx-    and AsciiDoc metadata; repeat as for `author`, above--`subject`-:   document subject, included in ODT, PDF, docx and pptx metadata--`description`-:   document description, included in ODT, docx and pptx metadata. Some-    applications show this as `Comments` metadata.--`category`-:   document category, included in docx and pptx metadata--Additionally,-any root-level string metadata, not included in ODT, docx-or pptx metadata is added as a *custom property*.-The following YAML metadata block for instance:--    ----    title:  'This is the title'-    subtitle: "This is the subtitle"-    author:-    - Author One-    - Author Two-    description: |-        This is a long-        description.--        It consists of two paragraphs-    ...--will include `title`, `author` and `description` as standard document-properties and `subtitle` as a custom property when converting to docx,-ODT or pptx.--Language variables---------------------`lang`-:   identifies the main language of the document using IETF language-    tags (following the [BCP 47] standard), such as `en` or `en-GB`.-    The [Language subtag lookup] tool can look up or verify these tags.-    This affects most formats, and controls hyphenation in PDF output-    when using LaTeX (through [`babel`] and [`polyglossia`]) or ConTeXt.--    Use native pandoc [Divs and Spans] with the `lang` attribute to-    switch the language:--        ----        lang: en-GB-        ...--        Text in the main document language (British English).--        ::: {lang=fr-CA}-        > Cette citation est écrite en français canadien.-        :::--        More text in English. ['Zitat auf Deutsch.']{lang=de}--`dir`-:   the base script direction, either `rtl` (right-to-left)-    or `ltr` (left-to-right).--    For bidirectional documents, native pandoc `span`s and `div`s-    with the `dir` attribute (value `rtl` or `ltr`) can be used to-    override the base direction in some output formats.-    This may not always be necessary if the final renderer-    (e.g. the browser, when generating HTML) supports the-    [Unicode Bidirectional Algorithm].--    When using LaTeX for bidirectional documents, only the `xelatex` engine-    is fully supported (use `--pdf-engine=xelatex`).--[BCP 47]: https://tools.ietf.org/html/bcp47-[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics-[Language subtag lookup]: https://r12a.github.io/app-subtags/--Variables for HTML slides----------------------------These affect HTML output when [producing slide shows with pandoc].-All [reveal.js configuration options] are available as variables.--`revealjs-url`-:   base URL for reveal.js documents (defaults to `reveal.js`)--`s5-url`-:   base URL for S5 documents (defaults to `s5/default`)--`slidy-url`-:   base URL for Slidy documents (defaults to-    `https://www.w3.org/Talks/Tools/Slidy2`)--`slideous-url`-:   base URL for Slideous documents (defaults to `slideous`)--[reveal.js configuration options]: https://github.com/hakimel/reveal.js#configuration--Variables for Beamer slides------------------------------These variables change the appearance of PDF slides using [`beamer`].--`aspectratio`-:   slide aspect ratio (`43` for 4:3 [default], `169` for 16:9,-    `1610` for 16:10, `149` for 14:9, `141` for 1.41:1, `54` for 5:4,-    `32` for 3:2)--`beamerarticle`-:   produce an article from Beamer slides--`beameroption`-:   add extra beamer option with `\setbeameroption{}`--`institute`-:   author affiliations: can be a list when there are multiple authors--`logo`-:   logo image for slides--`navigation`-:   controls navigation symbols (default is `empty` for no navigation-    symbols; other valid values are `frame`, `vertical`, and `horizontal`)--`section-titles`-:   enables "title pages" for new sections (default is true)--`theme`, `colortheme`, `fonttheme`, `innertheme`, `outertheme`-:   beamer themes: --`themeoptions`-:   options for LaTeX beamer themes (a list).--`titlegraphic`-:   image for title slide--Variables for LaTeX----------------------Pandoc uses these variables when [creating a PDF] with a LaTeX engine.--### Layout--`block-headings`-:   make `\paragraph` and `\subparagraph` (fourth- and fifth-level headings, or-    fifth- and sixth-level with book classes) free-standing rather than run-in;-    requires further formatting to distinguish from `\subsubsection` (third- or-    fourth-level headings). Instead of using this option, [KOMA-Script] can adjust-    headings more extensively:--        ----        documentclass: scrartcl-        header-includes: |-          \RedeclareSectionCommand[-            beforeskip=-10pt plus -2pt minus -1pt,-            afterskip=1sp plus -1sp minus 1sp,-            font=\normalfont\itshape]{paragraph}-          \RedeclareSectionCommand[-            beforeskip=-10pt plus -2pt minus -1pt,-            afterskip=1sp plus -1sp minus 1sp,-            font=\normalfont\scshape,-            indent=0pt]{subparagraph}-        ...--`classoption`-:   option for document class, e.g. `oneside`; repeat for multiple options:--        ----        classoption:-        - twocolumn-        - landscape-        ...--`documentclass`-:   document class: usually one of the standard classes, [`article`], [`book`],-    and [`report`]; the [KOMA-Script] equivalents, `scrartcl`, `scrbook`,-    and `scrreprt`, which default to smaller margins; or [`memoir`]--`geometry`-:   option for [`geometry`] package, e.g. `margin=1in`;-    repeat for multiple options:--        ----        geometry:-        - top=30mm-        - left=20mm-        - heightrounded-        ...--`indent`-:   uses document class settings for indentation (the default LaTeX template-    otherwise removes indentation and adds space between paragraphs)--`linestretch`-:   adjusts line spacing using the [`setspace`]-    package, e.g. `1.25`, `1.5`--`margin-left`, `margin-right`, `margin-top`, `margin-bottom`-:   sets margins if `geometry` is not used (otherwise `geometry`-    overrides these)--`pagestyle`-:   control `\pagestyle{}`: the default article class-    supports `plain` (default), `empty` (no running heads or page numbers),-    and `headings` (section titles in running heads)--`papersize`-:   paper size, e.g. `letter`, `a4`--`secnumdepth`-:   numbering depth for sections (with `--number-sections` option-    or `numbersections` variable)--### Fonts--`fontenc`-:   allows font encoding to be specified through `fontenc` package (with `pdflatex`);-    default is `T1` (see [LaTeX font encodings guide])--`fontfamily`-:   font package for use with `pdflatex`:-    [TeX Live] includes many options, documented in the [LaTeX Font Catalogue].-    The default is [Latin Modern][`lm`].--`fontfamilyoptions`-:   options for package used as `fontfamily`; repeat for multiple options.-    For example, to use the Libertine font with proportional lowercase-    (old-style) figures through the [`libertinus`] package:--        ----        fontfamily: libertinus-        fontfamilyoptions:-        - osf-        - p-        ...--`fontsize`-:   font size for body text. The standard classes allow 10pt, 11pt, and 12pt.-    To use another size, set `documentclass` to one of the [KOMA-Script] classes,-    such as `scrartcl` or `scrbook`.--`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`-:   font families for use with `xelatex` or-    `lualatex`: take the name of any system font, using the-    [`fontspec`] package.  `CJKmainfont` uses the [`xecjk`] package.--`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`-:   options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`,-    `CJKmainfont` in `xelatex` and `lualatex`.  Allow for any choices-    available through [`fontspec`]; repeat for multiple options. For example,-    to use the [TeX Gyre] version of Palatino with lowercase figures:--        ----        mainfont: TeX Gyre Pagella-        mainfontoptions:-        - Numbers=Lowercase-        - Numbers=Proportional-        ...--`microtypeoptions`-:    options to pass to the microtype package--### Links--`colorlinks`-:   add color to link text; automatically enabled if any of-    `linkcolor`, `filecolor`, `citecolor`, `urlcolor`, or `toccolor` are set--`linkcolor`, `filecolor`, `citecolor`, `urlcolor`, `toccolor`-:   color for internal links, external links, citation links, linked-    URLs, and links in table of contents, respectively: uses options-    allowed by [`xcolor`], including the `dvipsnames`, `svgnames`, and-    `x11names` lists--`links-as-notes`-:   causes links to be printed as footnotes--### Front matter--`lof`, `lot`-:   include list of figures, list of tables--`thanks`-:   contents of acknowledgments footnote after document title--`toc`-:   include table of contents (can also be set using `--toc/--table-of-contents`)--`toc-depth`-:   level of section to include in table of contents--### BibLaTeX Bibliographies--These variables function when using BibLaTeX for [citation rendering].--`biblatexoptions`-:   list of options for biblatex--`biblio-style`-:   bibliography style, when used with `--natbib` and `--biblatex`.--`biblio-title`-:   bibliography title, when used with `--natbib` and `--biblatex`.--`bibliography`-:   bibliography to use for resolving references--`natbiboptions`-:   list of options for natbib--[KOMA-Script]: https://ctan.org/pkg/koma-script-[LaTeX Font Catalogue]: http://www.tug.dk/FontCatalogue/-[LaTeX font encodings guide]: https://ctan.org/pkg/encguide-[TeX Gyre]: http://www.gust.org.pl/projects/e-foundry/tex-gyre-[`article`]: https://ctan.org/pkg/article-[`book`]: https://ctan.org/pkg/book-[`libertinus`]: https://ctan.org/pkg/libertinus-[`memoir`]: https://ctan.org/pkg/memoir-[`report`]: https://ctan.org/pkg/report--Variables for ConTeXt------------------------Pandoc uses these variables when [creating a PDF] with ConTeXt.--`fontsize`-:   font size for body text (e.g. `10pt`, `12pt`)--`headertext`, `footertext`-:   text to be placed in running header or footer (see [ConTeXt Headers and Footers]);-    repeat up to four times for different placement--`indenting`-:   controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);-    repeat for multiple options--`interlinespace`-:   adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);-    repeat for multiple options--`layout`-:   options for page margins and text arrangement (see [ConTeXt Layout]);-    repeat for multiple options--`linkcolor`, `contrastcolor`-:   color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])--`linkstyle`-:   typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`--`lof`, `lot`-:   include list of figures, list of tables--`mainfont`, `sansfont`, `monofont`, `mathfont`-:   font families: take the name of any system font (see [ConTeXt Font Switching])--`margin-left`, `margin-right`, `margin-top`, `margin-bottom`-:   sets margins, if `layout` is not used (otherwise `layout`-    overrides these)--`pagenumbering`-:   page number style and location (using [`setuppagenumbering`]);-    repeat for multiple options--`papersize`-:   paper size, e.g. `letter`, `A4`, `landscape` (see [ConTeXt Paper Setup]);-    repeat for multiple options--`pdfa`-:   adds to the preamble the setup necessary to generate PDF/A-1b:2005.-    To successfully generate PDF/A the required ICC color profiles have to-    be available and the content and all included files (such as images)-    have to be standard conforming.  The ICC profiles can be obtained-    from [ConTeXt ICC Profiles].  See also [ConTeXt PDFA] for more-    details.--`toc`-:   include table of contents (can also be set using `--toc/--table-of-contents`)--`whitespace`-:   spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])--[ConTeXt Paper Setup]: https://wiki.contextgarden.net/PaperSetup-[ConTeXt Layout]: https://wiki.contextgarden.net/Layout-[ConTeXt Font Switching]: https://wiki.contextgarden.net/Font_Switching-[ConTeXt Color]: https://wiki.contextgarden.net/Color-[ConTeXt Headers and Footers]: https://wiki.contextgarden.net/Headers_and_Footers-[ConTeXt Indentation]: https://wiki.contextgarden.net/Indentation-[ConTeXt ICC Profiles]: https://wiki.contextgarden.net/PDFX#ICC_profiles-[ConTeXt PDFA]: https://wiki.contextgarden.net/PDF/A-[`setupwhitespace`]: https://wiki.contextgarden.net/Command/setupwhitespace-[`setupinterlinespace`]: https://wiki.contextgarden.net/Command/setupinterlinespace-[`setuppagenumbering`]: https://wiki.contextgarden.net/Command/setuppagenumbering--Variables for `wkhtmltopdf`------------------------------Pandoc uses these variables when [creating a PDF] with [`wkhtmltopdf`].-The `--css` option also affects the output.--`footer-html`, `header-html`-:   add information to the header and footer--`margin-left`, `margin-right`, `margin-top`, `margin-bottom`-:   set the page margins--`papersize`-:   sets the PDF paper size--Variables for man pages--------------------------`adjusting`-:   adjusts text to left (`l`), right (`r`), center (`c`),-    or both (`b`) margins--`footer`-:   footer in man pages--`header`-:   header in man pages--`hyphenate`-:   if `true` (the default), hyphenation will be used--`section`-:   section number in man pages--Variables for ms-------------------`fontfamily`-:    font family (e.g. `T` or `P`)--`indent`-:    paragraph indent (e.g. `2m`)--`lineheight`-:    line height (e.g. `12p`)--`pointsize`-:    point size (e.g. `10p`)--Structural variables-----------------------Pandoc sets these variables automatically in response to [options] or-document contents; users can also modify them. These vary depending-on the output format, and include the following:--`body`-:   body of document--`date-meta`-:   the `date` variable converted to ISO 8601 YYYY-MM-DD,-    included in all HTML based formats (dzslides, epub,-    html, html4, html5, revealjs, s5, slideous, slidy).-    The recognized formats for `date` are: `mm/dd/yyyy`,-    `mm/dd/yy`, `yyyy-mm-dd` (ISO 8601), `dd MM yyyy`-    (e.g. either `02 Apr 2018` or `02 April 2018`),-    `MM dd, yyyy` (e.g. `Apr. 02, 2018` or `April 02, 2018),-    `yyyy[mm[dd]]]` (e.g. `20180402, `201804` or `2018`).--`header-includes`-:   contents specified by `-H/--include-in-header` (may have multiple-    values)--`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)--`meta-json`-:   JSON representation of all of the document's metadata. Field-    values are transformed to the selected output format.--`numbersections`-:   non-null value if `-N/--number-sections` was specified--`sourcefile`, `outputfile`-:   source and destination filenames, as given on the command line.-    `sourcefile` can also be a list if input comes from multiple files, or empty-    if input is from stdin. You can use the following snippet in your template-    to distinguish them:--        $if(sourcefile)$-        $for(sourcefile)$-        $sourcefile$-        $endfor$-        $else$-        (stdin)-        $endif$--    Similarly, `outputfile` can be `-` if output goes to the terminal.--    If you need absolute paths, use e.g. `$curdir$/$sourcefile$`.--`curdir`-:   working directory from which pandoc is run.--`toc`-:   non-null value if `--toc/--table-of-contents` was specified--`toc-title`-:   title of table of contents (works only with EPUB,-    opendocument, odt, docx, pptx, beamer, LaTeX)--Using variables in templates-------------------------------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 `$$`.--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 truthy-value; otherwise it will include `Y`. Here a truthy value is any-of the following:--- a string that is not entirely white space,-- a non-empty array where the first value is truthy,-- any number (including zero),-- any object,-- the boolean `true` (to specify the boolean `true`-  value using YAML metadata or the `--metadata` flag,-  use `true`, `True`, or `TRUE`; with the `--variable`-  flag, simply omit a value for the variable, e.g.-  `--variable draft`).--`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$--Note that the separator needs to be specified immediately before the `$endfor` -keyword.--A dot can be used to select a field of a variable that takes-an object as its value.  So, for example:--    $author.name$ ($author.affiliation$)--The value of a variable will be indented to the same level as the variable.--If you use custom templates, you may need to revise them as pandoc-changes.  We recommend tracking the changes in the default templates,-and modifying your custom templates accordingly. An easy way to do this-is to fork the [pandoc-templates] repository and merge in changes after each-pandoc release.--Templates may contain comments:  anything on a line after `$--`-will be treated as a comment and ignored.--[pandoc-templates]: https://github.com/jgm/pandoc-templates--Extensions-==========--The behavior of some of the readers and writers can be adjusted by-enabling or disabling various extensions.--An extension can be enabled by adding `+EXTENSION`-to the format name and disabled by adding `-EXTENSION`. For example,-`--from markdown_strict+footnotes` is strict Markdown with footnotes-enabled, while `--from markdown-footnotes-pipe_tables` is pandoc's-Markdown without footnotes or pipe tables.--The markdown reader and writer make by far the most use of extensions.-Extensions only used by them are therefore covered in the-section [Pandoc's Markdown] below (See [Markdown variants] for-`commonmark` and `gfm`.) In the following, extensions that also work-for other formats are covered.--Note that markdown extensions added to the `ipynb` format-affect Markdown cells in Jupyter notebooks (as do command-line-options like `--atx-headers`).--Typography-------------#### Extension: `smart` ####--Interpret straight quotes as curly quotes, `---` as em-dashes,-`--` as en-dashes, and `...` as ellipses. Nonbreaking spaces are-inserted after certain abbreviations, such as "Mr."--This extension can be enabled/disabled for the following formats:--input formats-:  `markdown`, `commonmark`, `latex`, `mediawiki`, `org`, `rst`, `twiki`--output formats-:  `markdown`, `latex`, `context`, `rst`--enabled by default in-:  `markdown`, `latex`, `context` (both input and output)--Note: If you are *writing* Markdown, then the `smart` extension-has the reverse effect: what would have been curly quotes comes-out straight.--In LaTeX, `smart` means to use the standard TeX ligatures-for quotation marks (` `` ` and ` '' ` for double quotes,-`` ` `` and `` ' `` for single quotes) and dashes (`--` for-en-dash and `---` for em-dash).  If `smart` is disabled,-then in reading LaTeX pandoc will parse these characters-literally.  In writing LaTeX, enabling `smart` tells pandoc-to use the ligatures when possible; if `smart` is disabled-pandoc will use unicode quotation mark and dash characters.--Headings and sections------------------------#### Extension: `auto_identifiers` ####--A heading without an explicitly specified identifier will be-automatically assigned a unique identifier based on the heading text.--This extension can be enabled/disabled for the following formats:--input formats-:  `markdown`, `latex`, `rst`, `mediawiki`, `textile`--output formats-:  `markdown`, `muse`--enabled by default in-:  `markdown`, `muse`--The default algorithm used to derive the identifier from the-heading text is:--  - Remove all formatting, links, etc.-  - Remove all footnotes.-  - Remove all non-alphanumeric characters,-    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,--  Heading                           Identifier-  -------------------------------   -----------------------------  `Heading identifiers in HTML`     `heading-identifiers-in-html`-  `Maître d'hôtel`                  `maître-dhôtel`-  `*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 heading text. The exception is when several headings 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.--(However, a different algorithm is used if-`gfm_auto_identifiers` is enabled; see below.)--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-    [heading identifiers](#heading-identifiers-in-html-latex-and-context).--Note, however, that this method of providing links to sections works-only in HTML, LaTeX, and ConTeXt formats.--If the `--section-divs` option is specified, then each section will-be wrapped in a `section` (or a `div`, if `html4` was specified),-and the identifier will be attached to the enclosing `<section>`-(or `<div>`) tag rather than the heading itself. This allows entire-sections to be manipulated using JavaScript or treated differently in-CSS.--#### Extension: `ascii_identifiers` ####--Causes the identifiers produced by `auto_identifiers` to be pure ASCII.-Accents are stripped off of accented Latin letters, and non-Latin-letters are omitted.--#### Extension: `gfm_auto_identifiers` ####--Changes the algorithm used by `auto_identifiers` to conform to-GitHub's method.  Spaces are converted to dashes (`-`),-uppercase characters to lowercase characters, and punctuation-characters other than `-` and `_` are removed.--Math Input-------------The extensions [`tex_math_dollars`](#extension-tex_math_dollars),-[`tex_math_single_backslash`](#extension-tex_math_single_backslash), and-[`tex_math_double_backslash`](#extension-tex_math_double_backslash)-are described in the section about Pandoc's Markdown.--However, they can also be used with HTML input. This is handy for-reading web pages formatted using MathJax, for example.--Raw HTML/TeX---------------The following extensions (especially how they affect Markdown-input/output) are also described in more detail in their respective-sections of [Pandoc's Markdown].--#### Extension: `raw_html` {#raw_html}--When converting from HTML, parse elements to raw HTML which are not-representable in pandoc's AST.-By default, this is disabled for HTML input.--#### Extension: `raw_tex` {#raw_tex}--Allows raw LaTeX, TeX, and ConTeXt to be included in a document.--This extension can be enabled/disabled for the following formats-(in addition to `markdown`):--input formats-:  `latex`, `org`, `textile`, `html` (environments, `\ref`, and-   `\eqref` only), `ipynb`--output formats-:  `textile`, `commonmark`--Note: as applied to `ipynb`, `raw_html` and `raw_tex` affect not-only raw TeX in markdown cells, but data with mime type-`text/html` in output cells.  Since the `ipynb` reader attempts-to preserve the richest possible outputs when several options-are given, you will get best results if you disable `raw_html`-and `raw_tex` when converting to formats like `docx` which don't-allow raw `html` or `tex`.--#### Extension: `native_divs` {#native_divs}--This extension is enabled by default for HTML input. This means that-`div`s are parsed to pandoc native elements. (Alternatively, you-can parse them to raw HTML using `-f html-native_divs+raw_html`.)--When converting HTML to Markdown, for example, you may want to drop all-`div`s and `span`s:--    pandoc -f html-native_divs-native_spans -t markdown--#### Extension: `native_spans` {#native_spans}--Analogous to `native_divs` above.---Literate Haskell support---------------------------#### Extension: `literate_haskell` ####--Treat the document as literate Haskell source.--This extension can be enabled/disabled for the following formats:--input formats-:  `markdown`, `rst`, `latex`--output formats-:  `markdown`, `rst`, `latex`, `html`--If you append `+lhs` (or `+literate_haskell`) to one of the formats-above, pandoc will treat the document as literate Haskell source.-This means that--  - In Markdown input, "bird track" sections will be parsed as Haskell-    code rather than block quotations.  Text between `\begin{code}`-    and `\end{code}` will also be treated as Haskell code.  For-    ATX-style headings the character '=' will be used instead of '#'.--  - In Markdown output, code blocks with classes `haskell` and `literate`-    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, headings will be rendered setext-style (with underlines)-    rather than ATX-style (with '#' characters). (This is because ghc-    treats '#' characters in column 1 as introducing line numbers.)--  - In restructured text input, "bird track" sections will be parsed-    as Haskell code.--  - In restructured text output, code blocks with class `haskell` will-    be rendered using bird tracks.--  - In LaTeX input, text in `code` environments will be parsed as-    Haskell code.--  - In LaTeX output, code blocks with class `haskell` will be rendered-    inside `code` environments.--  - In HTML output, code blocks with class `haskell` will be rendered-    with class `literatehaskell` and bird tracks.--Examples:--    pandoc -f markdown+lhs -t html--reads literate Haskell source formatted with Markdown conventions and writes-ordinary HTML (without bird tracks).--    pandoc -f markdown+lhs -t html+lhs--writes HTML with the Haskell code in bird tracks, so it can be copied-and pasted as literate Haskell source.--Note that GHC expects the bird tracks in the first column, so indented-literate code blocks (e.g. inside an itemized environment) will not be-picked up by the Haskell compiler.--Other extensions-------------------#### Extension: `empty_paragraphs` ####--Allows empty paragraphs.  By default empty paragraphs are-omitted.--This extension can be enabled/disabled for the following formats:--input formats-:  `docx`, `html`--output formats-:  `docx`, `odt`, `opendocument`, `html`--#### Extension: `styles` #### {#ext-styles}--When converting from docx, read all docx styles as divs (for-paragraph styles) and spans (for character styles) regardless-of whether pandoc understands the meaning of these styles.-This can be used with [docx custom styles](#custom-styles).-Disabled by default.--input formats-:  `docx`--#### Extension: `amuse` ####--In the `muse` input format, this enables Text::Amuse-extensions to Emacs Muse markup.--#### Extension: `citations` {#org-citations}--Some aspects of [Pandoc's Markdown citation syntax](#citations) are also accepted-in `org` input.--#### Extension: `ntb` ####--In the `context` output format this enables the use of [Natural Tables-(TABLE)](http://wiki.contextgarden.net/TABLE) instead of the default-[Extreme Tables (xtables)](http://wiki.contextgarden.net/xtables).-Natural tables allow more fine-grained global customization but come-at a performance penalty compared to extreme tables.---Pandoc's Markdown-=================--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 using the `markdown_strict` format instead-of `markdown`. Extensions can be enabled or disabled to specify the-behavior more granularly. They are described in the following. See also-[Extensions] above, for extensions that work also on other formats.--Philosophy-------------Markdown is designed to be easy to write, and, even more importantly,-easy to read:--> 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)--This principle has guided pandoc's decisions in finding syntax for-tables, footnotes, and other extensions.--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.--Paragraphs-------------A paragraph is one or more lines of text followed by one or more blank lines.-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.--#### Extension: `escaped_line_breaks` ####--A backslash followed by a newline is also a hard line break.-Note:  in multiline and grid table cells, this is the only way-to create a hard line break, since trailing spaces in the cells-are ignored.--Headings-----------There are two kinds of headings: Setext and ATX.--### Setext-style headings ###--A setext-style heading is a line of text "underlined" with a row of `=` signs-(for a level-one heading) or `-` signs (for a level-two heading):--    A level-one heading-    ===================--    A level-two heading-    ---------------------The heading text can contain inline formatting, such as emphasis (see-[Inline formatting], below).---### ATX-style headings ###--An ATX-style heading 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 heading level:--    ## A level-two heading--    ### A level-three heading ###--As with setext-style headings, the heading text can contain formatting:--    # A level-one heading with a [link](/url) and *emphasis*--#### Extension: `blank_before_header` ####--Standard Markdown syntax does not require a blank line before a heading.-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:--    I like several of their flavors of ice cream:-    #22, for example, and #5.--#### Extension: `space_in_atx_header` ####--Many Markdown implementations do not require a space between the-opening `#`s of an ATX heading and the heading text, so that-`#5 bolt` and `#hashtag` count as headings.  With this extension,-pandoc does require the space.--### Heading identifiers ###--See also the [`auto_identifiers` extension](#extension-auto_identifiers) above.--#### Extension: `header_attributes` ####--Headings can be assigned attributes using this syntax at the end-of the line containing the heading text:--    {#identifier .class .class key=value key=value}--Thus, for example, the following headings will all be assigned the identifier-`foo`:--    # My heading {#foo}--    ## My heading ##    {#foo}--    My other heading   {#foo}-    -----------------(This syntax is compatible with [PHP Markdown Extra].)--Note that although this syntax allows assignment of classes and key/value-attributes, writers generally don't use all of this information.  Identifiers,-classes, and key/value attributes are used in HTML and HTML-based formats such-as EPUB and slidy.  Identifiers are used for labels and link anchors in the-LaTeX, ConTeXt, Textile, Jira markup, and AsciiDoc writers.--Headings with the class `unnumbered` will not be numbered, even if-`--number-sections` is specified.  A single hyphen (`-`) in an attribute-context is equivalent to `.unnumbered`, and preferable in non-English-documents.  So,--    # My heading {-}--is just the same as--    # My heading {.unnumbered}--#### Extension: `implicit_header_references` ####--Pandoc behaves as if reference links have been defined for each heading.-So, to link to a heading--    # Heading identifiers in HTML--you can simply write--    [Heading identifiers in HTML]--or--    [Heading identifiers in HTML][]--or--    [the section on heading identifiers][heading identifiers in-    HTML]--instead of giving the identifier explicitly:--    [Heading identifiers in HTML](#heading-identifiers-in-html)--If there are multiple headings with identical text, the corresponding-reference will link to the first one only, and you will need to use explicit-links to link to the others, as described above.--Like regular reference links, these references are case-insensitive.--Explicit link reference definitions always take priority over-implicit heading references.  So, in the following example, the-link will point to `bar`, not to `#foo`:--    # Foo--    [foo]: bar--    See [foo]--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 headings), with each line preceded by a `>` character-and an optional 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.--If the `>` character is followed by an optional space, that space-will be considered part of the block quote marker and not part of-the indentation of the contents.  Thus, to put an indented code-block in a block quote, you need five spaces after the `>`:--    >     code--#### Extension: `blank_before_blockquote` ####--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 the `markdown_strict` format 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.---### Fenced code blocks ###--#### Extension: `fenced_code_blocks` ####--In addition to standard indented code blocks, pandoc supports-*fenced* 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 these lines is treated as code. No-indentation is necessary:--    ~~~~~~~-    if (a > 3) {-      moveShip(5 * gravity, DOWN);-    }-    ~~~~~~~--Like regular code blocks, fenced code blocks must be separated-from surrounding text by blank lines.--If the code itself contains a row of tildes or backticks, just use a longer-row of tildes or backticks at the start and end:--    ~~~~~~~~~~~~~~~~-    ~~~~~~~~~~-    code including tildes-    ~~~~~~~~~~-    ~~~~~~~~~~~~~~~~--#### Extension: `backtick_code_blocks` ####--Same as `fenced_code_blocks`, but uses backticks (`` ` ``) instead of tildes-(`~`).--#### Extension: `fenced_code_attributes` ####--Optionally, you may attach attributes to fenced or backtick code block using-this syntax:--    ~~~~ {#mycode .haskell .numberLines startFrom="100"}-    qsort []     = []-    qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++-                   qsort (filter (>= x) xs)-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and-`startFrom` is an attribute with value `100`. Some output formats can use this-information to do syntax highlighting. Currently, the only output formats-that uses this information are HTML, LaTeX, Docx, Ms, and PowerPoint. If-highlighting is supported for your output format and language, then the code-block above will appear highlighted, with numbered lines. (To see which-languages are supported, type `pandoc --list-highlight-languages`.) Otherwise,-the code block above will appear as follows:--    <pre id="mycode" class="haskell numberLines" startFrom="100">-      <code>-      ...-      </code>-    </pre>--The `numberLines` (or `number-lines`) class will cause the lines-of the code block to be numbered, starting with `1` or the value-of the `startFrom` attribute.  The `lineAnchors` (or-`line-anchors`) class will cause the lines to be clickable-anchors in HTML output.--A shortcut form can also be used for specifying the language of-the code block:--    ```haskell-    qsort [] = []-    ```--This is equivalent to:--    ``` {.haskell}-    qsort [] = []-    ```--If the `fenced_code_attributes` extension is disabled, but-input contains class attribute(s) for the code block, the first-class attribute will be printed after the opening fence as a bare-word.--To prevent all highlighting, use the `--no-highlight` flag.-To set the highlighting style, use `--highlight-style`.-For more information on highlighting, see [Syntax highlighting],-below.--Line blocks--------------#### Extension: `line_blocks` ####--A line block is a sequence of lines beginning with a vertical bar (`|`)-followed by a space.  The division into lines will be preserved in-the output, as will any leading spaces; otherwise, the lines will-be formatted as Markdown.  This is useful for verse and addresses:--    | The limerick packs laughs anatomical-    | In space that is quite economical.-    |    But the good ones I've seen-    |    So seldom are clean-    | And the clean ones so seldom are comical--    | 200 Main St.-    | Berkeley, CA 94718--The lines can be hard-wrapped if needed, but the continuation-line must begin with a space.--    | The Right Honorable Most Venerable and Righteous Samuel L.-      Constable, Jr.-    | 200 Main St.-    | Berkeley, CA 94718--This syntax is borrowed from [reStructuredText].--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.--List items look best if subsequent lines are flush with the first-line (after the bullet):--    * here is my first-      list item.-    * and my second.--But Markdown also allows a "lazy" format:--    * here is my first-    list item.-    * and my second.--### Block content in list items ###--A list item may contain multiple paragraphs and other block-level-content. However, subsequent paragraphs must be preceded by a blank line-and indented to line up with the first non-space content after-the list marker.--      * First paragraph.--        Continued.--      * Second paragraph. With a code block, which must be indented-        eight spaces:--            { code }--Exception: if the list marker is followed by an indented code-block, which must begin 5 spaces after the list marker, then-subsequent paragraphs must begin two columns after the last-character of the list marker:--    *     code--      continuation paragraph--List items may include other lists.  In this case the preceding blank-line is optional.  The nested list must be indented to line up with-the first non-space character after the list marker of the-containing list item.--    * fruits-      + apples-        - macintosh-        - red delicious-      + pears-      + peaches-    * vegetables-      + broccoli-      + chard--As noted above, 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--#### Extension: `fancy_lists` ####--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.[^2]--[^2]:  The point of this rule is to ensure that normal paragraphs-    starting with people's initials, like--        B. Russell was an English philosopher.--    do not get treated as list items.--    This rule will not prevent--        (C) 2007 Joe Smith--    from being interpreted as a list item.  In this case, a backslash-    escape can be used:--        (C\) 2007 Joe Smith--The `fancy_lists` extension also allows '`#`' to be used as an-ordered list marker in place of a numeral:--    #. one-    #. two--#### Extension: `startnum` ####--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:--     9)  Ninth-    10)  Tenth-    11)  Eleventh-           i. subone-          ii. subtwo-         iii. subthree--Pandoc will start a new list each time a different type of list-marker is used.  So, the following will create three lists:--    (2) Two-    (5) Three-    1.  Four-    *   Five--If default list markers are desired, use `#.`:--    #.  one-    #.  two-    #.  three--#### Extension: `task_lists` ####--Pandoc supports task lists, using the syntax of GitHub-Flavored Markdown.--    - [ ] an unchecked task list item-    - [x] checked item--### Definition lists ###--#### Extension: `definition_lists` ####--Pandoc supports definition lists, using the syntax of-[PHP Markdown Extra] with some extensions.[^3]--    Term 1--    :   Definition 1--    Term 2 with *inline markup*--    :   Definition 2--            { some code, part of Definition 2 }--        Third paragraph of definition 2.--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.  The body of the definition (including the first line,-aside from the colon or tilde) should be indented four spaces. However,-as with other Markdown lists, you can "lazily" omit indentation except-at the beginning of a paragraph or other block element:--    Term 1--    :   Definition-    with lazy continuation.--        Second paragraph of the definition.--If you leave space before the definition (as in the example above),-the text of the definition will be treated as a paragraph.  In some-output formats, this will mean greater spacing between term/definition-pairs. For a more compact definition list, omit the space before the-definition:--    Term 1-      ~ Definition 1--    Term 2-      ~ Definition 2a-      ~ Definition 2b--Note that space between items in a definition list is required.-(A variant that loosens this requirement, but disallows "lazy"-hard wrapping, can be activated with `compact_definition_lists`: see-[Non-pandoc extensions], below.)--[^3]:  I have been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).--### Numbered example lists ###--#### Extension: `example_lists` ####--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.--Note:  continuation paragraphs in example lists must always-be indented four spaces, regardless of the length of the-list marker.  That is, example lists always behave as if the-`four_space_rule` extension is set.  This is because example-labels tend to be long, and indenting content to the-first non-space character after the label would be awkward.--### Compact and loose lists ###--Pandoc behaves differently from `Markdown.pl` on some "edge-cases" involving lists.  Consider this source:--    +   First-    +   Second:-        -   Fee-        -   Fie-        -   Foe--    +   Third--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 `markdown_strict` format is specified. This-behavior is consistent with the official Markdown syntax description,-even though it is different from that of `Markdown.pl`.)---### 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--    <!-- -->--    1.  uno-    2.  dos-    3.  tres--Horizontal rules-------------------A line containing a row of three or more `*`, `-`, or `_` characters-(optionally separated by spaces) produces a horizontal rule:--    *  *  *  *--    ------------------Tables---------Four kinds of tables may be used. The first three kinds presuppose the use of-a fixed-width font, such as Courier. The fourth kind can be used with-proportionally spaced fonts, as it does not require lining up columns.--#### Extension: `table_captions` ####--A caption may optionally be provided with all 4 kinds of tables (as-illustrated in the examples below). A caption is a paragraph beginning-with the string `Table:` (or just `:`), which will be stripped off.-It may appear either before or after the table.--#### Extension: `simple_tables` ####--Simple tables look like this:--      Right     Left     Center     Default-    -------     ------ ----------   --------         12     12        12            12-        123     123       123          123-          1     1          1             1--    Table:  Demonstration of simple table syntax.--The header 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:[^4]--  - 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.-  - 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.-  - If the dashed line extends beyond the header text on both sides,-    the column is centered.-  - 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).--[^4]:  This scheme is due to Michel Fortin, who proposed it on the-       [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).--The table must end with a blank line, or a line of dashes followed by-a blank line.--The column header row may be omitted, provided a dashed line is used-to end the table. For example:--    -------     ------ ----------   --------         12     12        12             12-        123     123       123           123-          1     1          1              1-    -------     ------ ----------   ---------When the header row is 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.--#### Extension: `multiline_tables` ####--Multiline tables allow header 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:--    --------------------------------------------------------------     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's another one. Note-                                        the blank line between-                                        rows.-    ---------------------------------------------------------------    Table: Here's the caption. It, too, may span-    multiple lines.--These work like simple tables, but with the following differences:--  - They must begin with a row of dashes, before the header text-    (unless the header row is omitted).-  - They must end with a row of dashes, then a blank line.-  - The rows must be separated by blank lines.--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.--The header may be omitted in multiline tables as well as simple tables:--    ----------- ------- --------------- --------------------------       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 a multiline table without a header.--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.--#### Extension: `grid_tables` ####--Grid tables look like this:--    : Sample grid table.--    +---------------+---------------+--------------------+-    | Fruit         | Price         | Advantages         |-    +===============+===============+====================+-    | Bananas       | $1.34         | - built-in wrapper |-    |               |               | - bright color     |-    +---------------+---------------+--------------------+-    | Oranges       | $2.10         | - cures scurvy     |-    |               |               | - tasty            |-    +---------------+---------------+--------------------+--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.). Cells that span multiple columns or rows are not-supported. Grid tables can be created easily using [Emacs table mode].--[Emacs table mode]: http://table.sourceforge.net/--Alignments can be specified as with pipe tables, by putting-colons at the boundaries of the separator line after the-header:--    +---------------+---------------+--------------------+-    | Right         | Left          | Centered           |-    +==============:+:==============+:==================:+-    | Bananas       | $1.34         | built-in wrapper   |-    +---------------+---------------+--------------------+--For headerless tables, the colons go on the top line instead:--    +--------------:+:--------------+:------------------:+-    | Right         | Left          | Centered           |-    +---------------+---------------+--------------------+--##### Grid Table Limitations #####--Pandoc does not support grid tables with row spans or column spans.-This means that neither variable numbers of columns across rows nor-variable numbers of rows across columns are supported by Pandoc.-All grid tables must have the same number of columns in each row,-and the same number of rows in each column.  For example, the-Docutils [sample grid tables] will not render as expected with-Pandoc.--[sample grid tables]: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables---#### Extension: `pipe_tables` ####--Pipe tables look like this:--    | Right | Left | Default | Center |-    |------:|:-----|---------|:------:|-    |   12  |  12  |    12   |    12  |-    |  123  |  123 |   123   |   123  |-    |    1  |    1 |     1   |     1  |--      : Demonstration of pipe table syntax.--The syntax is identical to [PHP Markdown Extra tables].  The beginning and-ending pipe characters are optional, but pipes are required between all-columns.  The colons indicate column alignment as shown.  The header-cannot be omitted.  To simulate a headerless table, include a header-with blank cells.--Since the pipes indicate column boundaries, columns need not be vertically-aligned, as they are in the above example.  So, this is a perfectly-legal (though ugly) pipe table:--    fruit| price-    -----|-----:-    apple|2.05-    pear|1.37-    orange|3.09--The cells of pipe tables cannot contain block elements like paragraphs-and lists, and cannot span multiple lines.  If a pipe table contains a-row whose printable content is wider than the column width (see-`--columns`), then the table will take up the full text width and-the cell contents will wrap, with the relative cell widths determined-by the number of dashes in the line separating the table header from-the table body. (For example `---|-` would make the first column 3/4-and the second column 1/4 of the full text width.)-On the other hand, if no lines are wider than column width, then-cell contents will not be wrapped, and the cells will be sized-to their contents.--Note:  pandoc also recognizes pipe tables of the following-form, as can be produced by Emacs' orgtbl-mode:--    | One | Two   |-    |-----+-------|-    | my  | table |-    | is  | nice  |--The difference is that `+` is used instead of `|`. Other orgtbl features-are not supported. In particular, to get non-default column alignment,-you'll need to add colons as above.--[PHP Markdown Extra tables]: https://michelf.ca/projects/php-markdown/extra/#table--Metadata blocks------------------#### Extension: `pandoc_title_block` ####--If the file begins with a title block--    % title-    % author(s) (separated by semicolons)-    % date--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:--    %-    % Author--    % My title-    %-    % June 15, 2006--The title may occupy multiple lines, but continuation lines must-begin with leading space, thus:--    % My title-      on multiple lines--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:--    % Author One-      Author Two--    % Author One; Author Two--    % Author One;-      Author Two--The date must fit on one line.--All three metadata fields may contain standard inline formatting-(italics, links, footnotes, etc.).--Title blocks will always be parsed, but they will affect the output only-when the `--standalone` (`-s`) 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 (`--title-prefix` or `-T` 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-`-T` and no title block appears in the document, the title prefix will-be used by itself as the HTML title.--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 (`|`) should be used to separate the footer text from the header-text.  Thus,--    % PANDOC(1)--will yield a man page with the title `PANDOC` and section 1.--    % PANDOC(1) Pandoc User Manuals--will also have "Pandoc User Manuals" in the footer.--    % PANDOC(1) Pandoc User Manuals | Version 4.0--will also have "Version 4.0" in the header.--#### Extension: `yaml_metadata_block` ####--A YAML metadata block is a valid YAML object, delimited by a line of three-hyphens (`---`) at the top and a line of three hyphens (`---`) or three dots-(`...`) at the bottom.  A YAML metadata block may occur anywhere in the-document, but if it is not at the beginning, it must be preceded by a blank-line.  (Note that, because of the way pandoc concatenates input files when-several are provided, you may also keep the metadata in a separate YAML file-and pass it to pandoc as an argument, along with your Markdown files:--    pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html--Just be sure that the YAML file begins with `---` and ends with `---` or-`...`.) Alternatively, you can use the `--metadata-file` option. Using-that approach however, you cannot reference content (like footnotes)-from the main markdown input document.--Metadata will be taken from the fields of the YAML object and added to any-existing document metadata.  Metadata can contain lists and objects (nested-arbitrarily), but all string scalars will be interpreted as Markdown.  Fields-with names ending in an underscore will be ignored by pandoc.  (They may be-given a role by external processors.)  Field names must not be-interpretable as YAML numbers or boolean values (so, for-example, `yes`, `True`, and `15` cannot be used as field names).--A document may contain multiple metadata blocks.  The metadata fields will-be combined through a *left-biased union*:  if two metadata blocks attempt-to set the same field, the value from the first block will be taken.--When pandoc is used with `-t markdown` to create a Markdown document,-a YAML metadata block will be produced only if the `-s/--standalone`-option is used.  All of the metadata will appear in a single block-at the beginning of the document.--Note that YAML escaping rules must be followed. Thus, for example,-if a title contains a colon, it must be quoted.  The pipe character-(`|`) can be used to begin an indented block that will be interpreted-literally, without need for escaping.  This form is necessary-when the field contains blank lines or block-level formatting:--    ----    title:  'This is the title: it contains a colon'-    author:-    - Author One-    - Author Two-    keywords: [nothing, nothingness]-    abstract: |-      This is the abstract.--      It consists of two paragraphs.-    ...--Template variables will be set automatically from the metadata.  Thus, for-example, in writing HTML, the variable `abstract` will be set to the HTML-equivalent of the Markdown in the `abstract` field:--    <p>This is the abstract.</p>-    <p>It consists of two paragraphs.</p>--Variables can contain arbitrary YAML structures, but the template must match-this structure.  The `author` variable in the default templates expects a-simple list or string, but can be changed to support more complicated-structures.  The following combination, for example, would add an affiliation-to the author if one is given:--    ----    title: The document title-    author:-    - name: Author One-      affiliation: University of Somewhere-    - name: Author Two-      affiliation: University of Nowhere-    ...--To use the structured authors in the example above, you would need a custom-template:--    $for(author)$-    $if(author.name)$-    $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$-    $else$-    $author$-    $endif$-    $endfor$--Raw content to include in the document's header may be specified-using `header-includes`; however, it is important to mark up-this content as raw code for a particular output format, using-the [`raw_attribute` extension](#extension-raw_attribute)), or it-will be interpreted as markdown. For example:--    header-includes:-    - |-      ```{=latex}-      \let\oldsection\section-      \renewcommand{\section}[1]{\clearpage\oldsection{#1}}-      ```--Backslash escapes--------------------#### Extension: `all_symbols_escapable` ####--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 `markdown_strict` format is used, 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.--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\*.--#### Extension: `intraword_underscores` ####--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 ###--#### Extension: `strikeout` ####--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 ###--#### Extension: `superscript`, `subscript` ####--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: `\*`.--#### Extension: `inline_code_attributes` ####--Attributes can be attached to verbatim text, just as with-[fenced code blocks]:--    `<$>`{.haskell}--### Small caps ###--To write small caps, use the `smallcaps` class:--    [Small caps]{.smallcaps}--Or, without the `bracketed_spans` extension:--    <span class="smallcaps">Small caps</span>--For compatibility with other Markdown flavors, CSS is also supported:--    <span style="font-variant:small-caps;">Small caps</span>--This will work in all output formats that support small caps.---Math-------#### Extension: `tex_math_dollars` ####--Anything between two `$` characters will be treated as TeX math.  The-opening `$` must have a non-space character immediately to its right,-while the closing `$` must have a non-space character immediately to its-left, and must not be followed immediately by a digit.  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:--LaTeX-  ~ It will appear verbatim surrounded by `\(...\)` (for inline-    math) or `\[...\]` (for display math).--Markdown, Emacs Org mode, ConTeXt, ZimWiki-  ~ It will appear verbatim surrounded by `$...$` (for inline-    math) or `$$...$$` (for display math).--XWiki-  ~ It will appear verbatim surrounded by `{{formula}}..{{/formula}}`.--reStructuredText-  ~ It will be rendered using an [interpreted text role `:math:`].--AsciiDoc-  ~ For AsciiDoc output format (`-t asciidoc`) it will appear verbatim-    surrounded by `latexmath:[$...$]` (for inline math) or-    `[latexmath]++++\[...\]+++` (for display math).-    For AsciiDoctor output format (`-t asciidoctor`) the LaTex delimiters-    (`$..$` and `\[..\]`) are omitted.--Texinfo-  ~ It will be rendered inside a `@math` command.--roff man, Jira markup-  ~ It will be rendered verbatim without `$`'s.--MediaWiki, DokuWiki-  ~ It will be rendered inside `<math>` tags.--Textile-  ~ It will be rendered inside `<span class="math">` tags.--RTF, OpenDocument-  ~ It will be rendered, if possible, using Unicode characters,-    and will otherwise appear verbatim.--ODT-  ~ It will be rendered, if possible, using MathML.--DocBook-  ~ If the `--mathml` flag is used, it will be rendered using MathML-    in an `inlineequation` or `informalequation` tag.  Otherwise it-    will be rendered, if possible, using Unicode characters.--Docx-  ~ It will be rendered using OMML math markup.--FictionBook2-  ~ If the `--webtex` option is used, formulas are rendered as images-    using CodeCogs or other compatible web service, downloaded-    and embedded in the e-book. Otherwise, they will appear verbatim.--HTML, Slidy, DZSlides, S5, EPUB-  ~ The way math is rendered in HTML will depend on the-    command-line options selected. Therefore see [Math rendering in HTML]-    above.--[interpreted text role `:math:`]: http://docutils.sourceforge.net/docs/ref/rst/roles.html#math--Raw HTML-----------#### Extension: `raw_html` ####--Markdown allows you to insert raw HTML (or DocBook) anywhere in a document-(except verbatim contexts, where `<`, `>`, and `&` are interpreted-literally).  (Technically this is not an extension, since standard-Markdown allows it, but it has been made an extension so that it can-be disabled if desired.)--The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,-DZSlides, EPUB, Markdown, CommonMark, Emacs Org mode, and Textile-output, and suppressed in other formats.--For a more explicit way of including raw HTML in a Markdown-document, see the [`raw_attribute` extension][Extension: `raw_attribute`].--In the CommonMark format, if `raw_html` is enabled, superscripts,-subscripts, strikeouts and small capitals will be represented as HTML.-Otherwise, plain-text fallbacks will be used. Note that even if-`raw_html` is disabled, tables will be rendered with HTML syntax if-they cannot use pipe syntax.--#### Extension: `markdown_in_html_blocks` ####--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 the `markdown_strict` format is used; but-by default, pandoc interprets material between HTML block tags as Markdown.-Thus, for example, pandoc will turn--    <table>-    <tr>-    <td>*one*</td>-    <td>[a link](http://google.com)</td>-    </tr>-    </table>--into--    <table>-    <tr>-    <td><em>one</em></td>-    <td><a href="http://google.com">a link</a></td>-    </tr>-    </table>--whereas `Markdown.pl` will preserve it as is.--There is one exception to this rule:  text between `<script>` and-`<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.--#### Extension: `native_divs` ####--Use native pandoc `Div` blocks for content inside `<div>` tags.-For the most part this should give the same output as-`markdown_in_html_blocks`, but it makes it easier to write pandoc-filters to manipulate groups of blocks.--#### Extension: `native_spans` ####--Use native pandoc `Span` blocks for content inside `<span>` tags.-For the most part this should give the same output as `raw_html`,-but it makes it easier to write pandoc filters to manipulate groups-of inlines.--#### Extension: `raw_tex` ####--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:--    This result was proved in \cite{jones.1967}.--Note that in LaTeX environments, like--    \begin{tabular}{|l|l|}\hline-    Age & Frequency \\ \hline-    18--25  & 15 \\-    26--35  & 33 \\-    36--45  & 22 \\ \hline-    \end{tabular}--the material between the begin and end tags will be interpreted as raw-LaTeX, not as Markdown.--For a more explicit and flexible way of including raw TeX in a-Markdown document, see the [`raw_attribute`-extension][Extension: `raw_attribute`].--Inline LaTeX is ignored in output formats other than Markdown, LaTeX,-Emacs Org mode, and ConTeXt.--### Generic raw attribute ###--#### Extension: `raw_attribute` ####--Inline spans and fenced code blocks with a special-kind of attribute will be parsed as raw content with the-designated format.  For example, the following produces a raw-roff `ms` block:--    ```{=ms}-    .MYMACRO-    blah blah-    ```-And the following produces a raw `html` inline element:--    This is `<a>html</a>`{=html}--This can be useful to insert raw xml into `docx` documents, e.g.-a pagebreak:--    ```{=openxml}-    <w:p>-      <w:r>-        <w:br w:type="page"/>-      </w:r>-    </w:p>-    ```--The format name should match the target format name (see-`-t/--to`, above, for a list, or use `pandoc---list-output-formats`). Use `openxml` for `docx` output,-`opendocument` for `odt` output, `html5` for `epub3` output,-`html4` for `epub2` output, and `latex`, `beamer`,-`ms`, or `html5` for `pdf` output (depending on what you-use for `--pdf-engine`).--This extension presupposes that the relevant kind of-inline code or fenced code block is enabled.  Thus, for-example, to use a raw attribute with a backtick code block,-`backtick_code_blocks` must be enabled.--The raw attribute cannot be combined with regular attributes.--LaTeX macros---------------#### Extension: `latex_macros` ####--When this extension is enabled, pandoc will parse LaTeX-macro definitions and apply the resulting macros to all LaTeX-math and raw LaTeX.  So, for example, the following will work in-all output formats, not just LaTeX:--    \newcommand{\tuple}[1]{\langle #1 \rangle}--    $\tuple{a, b, c}$--Note that LaTeX macros will not be applied if they occur-inside a raw span or block marked with the-[`raw_attribute` extension](#extension-raw_attribute).--When `latex_macros` is disabled, the raw LaTeX and math will-not have macros applied. This is usually a better approach when-you are targeting LaTeX or PDF.--Whether or not `latex_macros` is enabled, the macro definitions-will still be passed through as raw LaTeX.--Links--------Markdown allows links to be specified in several ways.--### Automatic links ###--If you enclose a URL or email address in pointy brackets, it-will become a link:--    <http://google.com>-    <sam@green.eggs.ham>--### 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.--Email addresses in inline links are not autodetected, so they have to be-prefixed with `mailto`:--    [Write me!](mailto:sam@green.eggs.ham)--### 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 cannot be space between the two unless the-`spaced_reference_links` extension is enabled.) The link definition-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.  The label must not be parseable as a citation (assuming-the `citations` extension is enabled):  citations take precedence over-link labels.--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:--    See [my website][].--    [my website]: http://foo.bar.baz--Note:  In `Markdown.pl` and most other Markdown implementations,-reference link definitions cannot occur in nested constructions-such as list items or block quotes.  Pandoc lifts this arbitrary-seeming restriction.  So the following is fine in pandoc, though-not in most other implementations:--    > My block [quote].-    >-    > [quote]: /foo--#### Extension: `shortcut_reference_links` ####--In a *shortcut* reference link, the second pair of brackets may-be omitted entirely:--    See [my website].--    [my website]: http://foo.bar.baz--### Internal links ###--To link to another section of the same document, use the automatically-generated identifier (see [Heading identifiers]). For example:--    See the [Introduction](#introduction).--or--    See the [Introduction].--    [Introduction]: #introduction--Internal links are currently supported for HTML formats (including-HTML slide shows and EPUB), LaTeX, and ConTeXt.--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--#### Extension: `implicit_figures` ####--An image with nonempty alt text, occurring by itself in a-paragraph, will be rendered as a figure with a caption.  The-image's alt text will be used as the caption.--    ![This is the caption](/url/of/image.png)--How this is rendered depends on the output format. Some output-formats (e.g. RTF) do not yet support figures.  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)\--Note that in reveal.js slide shows, an image in a paragraph-by itself that has the `stretch` class will fill the screen,-and the caption and figure tags will be omitted.--#### Extension: `link_attributes` ####--Attributes can be set on links and images:--    An inline ![image](foo.jpg){#id .class width=30 height=20px}-    and a reference ![image][ref] with attributes.--    [ref]: foo.jpg "optional title" {#id .class key=val key2="val 2"}--(This syntax is compatible with [PHP Markdown Extra] when only `#id`-and `.class` are used.)--For HTML and EPUB, all attributes except `width` and `height` (but-including `srcset` and `sizes`) are passed through as is. The other-writers ignore attributes that are not supported by their output-format.--The `width` and `height` attributes on images are treated specially. When-used without a unit, the unit is assumed to be pixels. However, any of-the following unit identifiers can be used: `px`, `cm`, `mm`, `in`, `inch`-and `%`. There must not be any spaces between the number and the unit.-For example:--```-![](file.jpg){ width=50% }-```--- Dimensions are converted to inches for output in page-based formats like-  LaTeX. Dimensions are converted to pixels for output in HTML-like-  formats.  Use the `--dpi` option to specify the number of pixels per-  inch.  The default is 96dpi.-- The `%` unit is generally relative to some available space.-  For example the above example will render to the following.-  - HTML: `<img href="file.jpg" style="width: 50%;" />`-  - LaTeX: `\includegraphics[width=0.5\textwidth,height=\textheight]{file.jpg}`-    (If you're using a custom template, you need to configure `graphicx`-    as in the default template.)-  - ConTeXt: `\externalfigure[file.jpg][width=0.5\textwidth]`-- Some output formats have a notion of a class-  ([ConTeXt](http://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))-  or a unique identifier (LaTeX `\caption`), or both (HTML).-- When no `width` or `height` attributes are specified, the fallback-  is to look at the image resolution and the dpi metadata embedded in-  the image file.--Divs and Spans-----------------Using the `native_divs` and `native_spans` extensions-(see [above][Extension: `native_divs`]), HTML syntax can-be used as part of markdown to create native `Div` and `Span`-elements in the pandoc AST (as opposed to raw HTML).-However, there is also nicer syntax available:--#### Extension: `fenced_divs` ####--Allow special fenced syntax for native `Div` blocks.  A Div-starts with a fence containing at least three consecutive-colons plus some attributes. The attributes may optionally-be followed by another string of consecutive colons.-The attribute syntax is exactly as in fenced code blocks (see-[Extension: `fenced_code_attributes`]).  As with fenced-code blocks, one can use either attributes in curly braces-or a single unbraced word, which will be treated as a class-name.  The Div ends with another line containing a string of at-least three consecutive colons.  The fenced Div should be-separated by blank lines from preceding and following blocks.--Example:--    ::::: {#special .sidebar}-    Here is a paragraph.--    And another.-    :::::--Fenced divs can be nested.  Opening fences are distinguished-because they *must* have attributes:--    ::: Warning ::::::-    This is a warning.--    ::: Danger-    This is a warning within a warning.-    :::-    ::::::::::::::::::--Fences without attributes are always closing fences.  Unlike-with fenced code blocks, the number of colons in the closing-fence need not match the number in the opening fence.  However,-it can be helpful for visual clarity to use fences of different-lengths to distinguish nested divs from their parents.---#### Extension: `bracketed_spans` ####--A bracketed sequence of inlines, as one would use to begin-a link, will be treated as a `Span` with attributes if it is-followed immediately by attributes:--    [This is *some text*]{.class key="val"}--Footnotes------------#### Extension: `footnotes` ####--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.).  Each footnote should be-separated from surrounding content (including other footnotes)-by blank lines.--#### Extension: `inline_notes` ####--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------------#### Extension: `citations` ####--Using an external filter, `pandoc-citeproc`, pandoc can automatically generate-citations and a bibliography in a number of styles.  Basic usage is--    pandoc --filter pandoc-citeproc myinput.txt--In order to use this feature, you will need to specify a bibliography file-using the `bibliography` metadata field in a YAML metadata section, or-`--bibliography` command line argument. You can supply multiple `--bibliography`-arguments or set `bibliography` metadata field to YAML array, if you want to-use multiple bibliography files.  The bibliography may have any of these-formats:--  Format            File extension-  ------------      ---------------  BibLaTeX          .bib-  BibTeX            .bibtex-  Copac             .copac-  CSL JSON          .json-  CSL YAML          .yaml-  EndNote           .enl-  EndNote XML       .xml-  ISI               .wos-  MEDLINE           .medline-  MODS              .mods-  RIS               .ris--Note that `.bib` can be used with both BibTeX and BibLaTeX files;-use `.bibtex` to force BibTeX.--Note that `pandoc-citeproc --bib2json` and `pandoc-citeproc --bib2yaml`-can produce `.json` and `.yaml` files from any of the supported formats.--In-field markup: In BibTeX and BibLaTeX databases,-pandoc-citeproc parses a subset of LaTeX markup; in CSL YAML-databases, pandoc Markdown; and in CSL JSON databases, an-[HTML-like markup][CSL markup specs]:--`<i>...</i>`-:   italics--`<b>...</b>`-:   bold--`<span style="font-variant:small-caps;">...</span>` or `<sc>...</sc>`-:   small capitals--`<sub>...</sub>`-:   subscript--`<sup>...</sup>`-:   superscript--`<span class="nocase">...</span>`-:   prevent a phrase from being capitalized as title case--`pandoc-citeproc -j` and `-y` interconvert the CSL JSON-and CSL YAML formats as far as possible.--As an alternative to specifying a bibliography file using `--bibliography`-or the YAML metadata field `bibliography`, you can include-the citation data directly in the `references` field of the-document's YAML metadata. The field should contain an array of-YAML-encoded references, for example:--    ----    references:-    - type: article-journal-      id: WatsonCrick1953-      author:-      - family: Watson-        given: J. D.-      - family: Crick-        given: F. H. C.-      issued:-        date-parts:-        - - 1953-          - 4-          - 25-      title: 'Molecular structure of nucleic acids: a structure for deoxyribose-        nucleic acid'-      title-short: Molecular structure of nucleic acids-      container-title: Nature-      volume: 171-      issue: 4356-      page: 737-738-      DOI: 10.1038/171737a0-      URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html-      language: en-GB-    ...--(`pandoc-citeproc --bib2yaml` can produce these from a bibliography file in one-of the supported formats.)--Citations and references can be formatted using any style supported by the-[Citation Style Language], listed in the [Zotero Style Repository].-These files are specified using the `--csl` option or the `csl` metadata field.-By default, `pandoc-citeproc` will use the [Chicago Manual of Style] author-date-format.  The CSL project provides further information on [finding and editing styles].--To make your citations hyperlinks to the corresponding bibliography-entries, add `link-citations: true` to your YAML metadata.--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.  The citation key must begin with a letter, digit,-or `_`, and may contain alphanumerics, `_`, and internal punctuation-characters (`:.#$%&-+?<>~/`).  Here are some examples:--    Blah blah [see @doe99, pp. 33-35; also @smith04, chap. 1].--    Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].--    Blah blah [@smith04; @doe99].--`pandoc-citeproc` detects locator terms in the [CSL locale files].-Either abbreviated or unabbreviated forms are accepted. In the `en-US`-locale, locator terms can be written in either singular or plural forms,-as `book`, `bk.`/`bks.`; `chapter`, `chap.`/`chaps.`; `column`,-`col.`/`cols.`; `figure`, `fig.`/`figs.`; `folio`, `fol.`/`fols.`;-`number`, `no.`/`nos.`; `line`, `l.`/`ll.`; `note`, `n.`/`nn.`; `opus`,-`op.`/`opp.`; `page`, `p.`/`pp.`; `paragraph`, `para.`/`paras.`; `part`,-`pt.`/`pts.`; `section`, `sec.`/`secs.`; `sub verbo`, `s.v.`/`s.vv.`;-`verse`, `v.`/`vv.`; `volume`, `vol.`/`vols.`; `¶`/`¶¶`; `§`/`§§`. If no-locator term is used, "page" is assumed.--`pandoc-citeproc` will use heuristics to distinguish the locator-from the suffix. In complex cases, the locator can be enclosed-in curly braces (using `pandoc-citeproc` 0.15 and higher only):--    [@smith{ii, A, D-Z}, with a suffix]-    [@smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]--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-in a div with id `refs`, if one exists:--    ::: {#refs}-    :::--Otherwise, it will be placed at the end of the document.-Generation of the bibliography can be suppressed by setting-`suppress-bibliography: true` in the YAML metadata.--If you wish the bibliography to have a section heading, you can-set `reference-section-title` in the metadata, or put the heading-at the beginning of the div with id `refs` (if you are using it)-or at the end of your document:--    last paragraph...--    # References--The bibliography will be inserted after this heading.  Note that-the `unnumbered` class will be added to this heading, so that the-section will not be numbered.--If you want to include items in the bibliography without actually-citing them in the body text, you can define a dummy `nocite` metadata-field and put the citations there:--    ----    nocite: |-      @item1, @item2-    ...--    @item3--In this example, the document will contain a citation for `item3`-only, but the bibliography will contain entries for `item1`, `item2`, and-`item3`.--It is possible to create a bibliography with all the citations,-whether or not they appear in the document, by using a wildcard:--    ----    nocite: |-      @*-    ...--For LaTeX output, you can also use [`natbib`] or [`biblatex`] to-render the bibliography. In order to do so, specify bibliography-files as outlined above, and add `--natbib` or `--biblatex`-argument to `pandoc` invocation. Bear in mind that bibliography-files have to be in respective format (either BibTeX or-BibLaTeX).--For more information, see the [pandoc-citeproc man page].--[CSL markup specs]: http://docs.citationstyles.org/en/1.0/release-notes.html#rich-text-markup-within-fields-[Chicago Manual of Style]: http://chicagomanualofstyle.org-[Citation Style Language]: http://citationstyles.org-[Zotero Style Repository]: https://www.zotero.org/styles-[finding and editing styles]: https://citationstyles.org/authors/-[CSL locale files]: https://github.com/citation-style-language/locales-[pandoc-citeproc man page]: https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md--Non-pandoc extensions------------------------The following Markdown syntax extensions are not enabled by default-in pandoc, but may be enabled by adding `+EXTENSION` to the format-name, where `EXTENSION` is the name of the extension.  Thus, for-example, `markdown+hard_line_breaks` is Markdown with hard line breaks.--#### Extension: `old_dashes` ####--Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:-`-` before a numeral is an en-dash, and `--` is an em-dash.-This option only has an effect if `smart` is enabled. It is-selected automatically for `textile` input.--#### Extension: `angle_brackets_escapable` ####--Allow `<` and `>` to be backslash-escaped, as they can be in-GitHub flavored Markdown but not original Markdown.  This is-implied by pandoc's default `all_symbols_escapable`.--#### Extension: `lists_without_preceding_blankline` ####--Allow a list to occur right after a paragraph, with no intervening-blank space.--#### Extension: `four_space_rule` ####--Selects the pandoc <= 2.0 behavior for parsing lists, so that-four spaces indent are needed for list item continuation-paragraphs.--#### Extension: `spaced_reference_links` ####--Allow whitespace between the two components of a reference link,-for example,--    [foo] [bar].--#### Extension: `hard_line_breaks` ####--Causes all newlines within a paragraph to be interpreted as hard line-breaks instead of spaces.--#### Extension: `ignore_line_breaks` ####--Causes newlines within a paragraph to be ignored, rather than being-treated as spaces or as hard line breaks.  This option is intended for-use with East Asian languages where spaces are not used between words,-but text is divided into lines for readability.--#### Extension: `east_asian_line_breaks` ####--Causes newlines within a paragraph to be ignored, rather than-being treated as spaces or as hard line breaks, when they occur-between two East Asian wide characters.  This is a better choice-than `ignore_line_breaks` for texts that include a mix of East-Asian wide characters and other characters.--#### Extension: `emoji` ####--Parses textual emojis like `:smile:` as Unicode emoticons.--#### Extension: `tex_math_single_backslash` ####--Causes anything between `\(` and `\)` to be interpreted as inline-TeX math, and anything between `\[` and `\]` to be interpreted-as display TeX math.  Note: a drawback of this extension is that-it precludes escaping `(` and `[`.--#### Extension: `tex_math_double_backslash` ####--Causes anything between `\\(` and `\\)` to be interpreted as inline-TeX math, and anything between `\\[` and `\\]` to be interpreted-as display TeX math.--#### Extension: `markdown_attribute` ####--By default, pandoc interprets material inside block-level tags as Markdown.-This extension changes the behavior so that Markdown is only parsed-inside block-level tags if the tags have the attribute `markdown=1`.--#### Extension: `mmd_title_block` ####--Enables a [MultiMarkdown] style title block at the top of-the document, for example:--    Title:   My title-    Author:  John Doe-    Date:    September 1, 2008-    Comment: This is a sample mmd title block, with-             a field spanning multiple lines.--See the MultiMarkdown documentation for details.  If `pandoc_title_block` or-`yaml_metadata_block` is enabled, it will take precedence over-`mmd_title_block`.--#### Extension: `abbreviations` ####--Parses PHP Markdown Extra abbreviation keys, like--    *[HTML]: Hypertext Markup Language--Note that the pandoc document model does not support-abbreviations, so if this extension is enabled, abbreviation keys are-simply skipped (as opposed to being parsed as paragraphs).--#### Extension: `autolink_bare_uris` ####--Makes all absolute URIs into links, even when not surrounded by-pointy braces `<...>`.--#### Extension: `mmd_link_attributes` ####--Parses multimarkdown style key-value attributes on link-and image references. This extension should not be confused with the-[`link_attributes`](#extension-link_attributes) extension.--    This is a reference ![image][ref] with multimarkdown attributes.--    [ref]: http://path.to/image "Image title" width=20px height=30px-           id=myId class="myClass1 myClass2"--#### Extension: `mmd_header_identifiers` ####--Parses multimarkdown style heading identifiers (in square brackets,-after the heading but before any trailing `#`s in an ATX heading).--#### Extension: `compact_definition_lists` ####--Activates the definition list syntax of pandoc 1.12.x and earlier.-This syntax differs from the one described above under [Definition lists]-in several respects:--  - No blank line is required between consecutive items of the-    definition list.-  - To get a "tight" or "compact" list, omit space between consecutive-    items; the space between a term and its definition does not affect-    anything.-  - Lazy wrapping of paragraphs is not allowed:  the entire definition must-    be indented four spaces.[^6]--[^6]:  To see why laziness is incompatible with relaxing the requirement-    of a blank line between items, consider the following example:--        bar-        :    definition-        foo-        :    definition--    Is this a single list item with two definitions of "bar," the first of-    which is lazily wrapped, or two list items?  To remove the ambiguity-    we must either disallow lazy wrapping or require a blank line between-    list items.--Markdown variants--------------------In addition to pandoc's extended Markdown, the following Markdown-variants are supported:--`markdown_phpextra` (PHP Markdown Extra)-:   `footnotes`, `pipe_tables`, `raw_html`, `markdown_attribute`,-    `fenced_code_blocks`, `definition_lists`, `intraword_underscores`,-    `header_attributes`, `link_attributes`, `abbreviations`,-    `shortcut_reference_links`, `spaced_reference_links`.--`markdown_github` (deprecated GitHub-Flavored Markdown)-:   `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,-    `gfm_auto_identifiers`, `backtick_code_blocks`,-    `autolink_bare_uris`, `space_in_atx_header`,-    `intraword_underscores`, `strikeout`, `task_lists`, `emoji`,-    `shortcut_reference_links`, `angle_brackets_escapable`,-    `lists_without_preceding_blankline`.--`markdown_mmd` (MultiMarkdown)-:   `pipe_tables`, `raw_html`, `markdown_attribute`, `mmd_link_attributes`,-    `tex_math_double_backslash`, `intraword_underscores`,-    `mmd_title_block`, `footnotes`, `definition_lists`,-    `all_symbols_escapable`, `implicit_header_references`,-    `auto_identifiers`, `mmd_header_identifiers`,-    `shortcut_reference_links`, `implicit_figures`,-    `superscript`, `subscript`, `backtick_code_blocks`,-    `spaced_reference_links`, `raw_attribute`.--`markdown_strict` (Markdown.pl)-:   `raw_html`, `shortcut_reference_links`,-    `spaced_reference_links`.--We also support `commonmark` and `gfm` (GitHub-Flavored Markdown,-which is implemented as a set of extensions on `commonmark`).--Note, however, that `commonmark` and `gfm` have limited support-for extensions. Only those  listed below (and `smart`,-`raw_tex`, and `hard_line_breaks`) will work. The extensions-can, however, all be individually disabled.  Also, `raw_tex`-only affects `gfm` output, not input.--`gfm` (GitHub-Flavored Markdown)-:   `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,-    `gfm_auto_identifiers`, `backtick_code_blocks`,-    `autolink_bare_uris`, `space_in_atx_header`,-    `intraword_underscores`, `strikeout`, `task_lists`, `emoji`,-    `shortcut_reference_links`, `angle_brackets_escapable`,-    `lists_without_preceding_blankline`.---Producing slide shows with pandoc-=================================--You can use pandoc to produce an HTML + JavaScript slide presentation-that can be viewed via a web browser.  There are five ways to do this,-using [S5], [DZSlides], [Slidy], [Slideous], or [reveal.js].-You can also produce a PDF slide show using LaTeX [`beamer`], or-slides shows in Microsoft [PowerPoint] format.--Here's the Markdown source for a simple slide show, `habits.txt`:--    % Habits-    % John Doe-    % March 22, 2005--    # In the morning--    ## Getting up--    - Turn off alarm-    - Get out of bed--    ## Breakfast--    - Eat eggs-    - Drink coffee--    # In the evening--    ## Dinner--    - Eat spaghetti-    - Drink wine--    --------------------    ![picture of spaghetti](images/spaghetti.jpg)--    ## Going to sleep--    - Get in bed-    - Count sheep--To produce an HTML/JavaScript slide show, simply type--    pandoc -t FORMAT -s habits.txt -o habits.html--where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.--For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the-`-s/--standalone` option embeds a link to JavaScript and CSS files, which are-assumed to be available at the relative path `s5/default` (for S5), `slideous`-(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at-`w3.org` (for Slidy).  (These paths can be changed by setting the `slidy-url`,-`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for HTML slides],-above.) For DZSlides, the (relatively short) JavaScript and CSS are included in-the file by default.--With all HTML slide formats, the `--self-contained` option can be used to-produce a single file that contains all of the data necessary to display the-slide show, including linked scripts, stylesheets, images, and videos.--To produce a PDF slide show using beamer, type--    pandoc -t beamer habits.txt -o habits.pdf--Note that a reveal.js slide show can also be converted to a PDF-by printing it to a file from the browser.--To produce a Powerpoint slide show, type--    pandoc habits.txt -o habits.pptx--Structuring the slide show-----------------------------By default, the *slide level* is the highest heading level in-the hierarchy that is followed immediately by content, and not another-heading, somewhere in the document. In the example above, level-1 headings-are always followed by level-2 headings, which are followed by content,-so the slide level is 2.  This default can be overridden using-the `--slide-level` option.--The document is carved up into slides according to the following-rules:--  * A horizontal rule always starts a new slide.--  * A heading at the slide level always starts a new slide.--  * Headings *below* the slide level in the hierarchy create-    headings *within* a slide.--  * Headings *above* the slide level in the hierarchy create-    "title slides," which just contain the section title-    and help to break the slide show into sections.-    Non-slide content under these headings will be included-    on the title slide (for HTML slide shows) or in a-    subsequent slide with the same title (for beamer).--  * A title page is constructed automatically from the document's title-    block, if present.  (In the case of beamer, this can be disabled-    by commenting out some lines in the default template.)--These rules are designed to support many different styles of slide show. If-you don't care about structuring your slides into sections and subsections,-you can just use level-1 headings for all each slide. (In that case, level-1-will be the slide level.) But you can also structure the slide show into-sections, as in the example above.--Note:  in reveal.js slide shows, if slide level is 2, a two-dimensional-layout will be produced, with level-1 headings building horizontally-and level-2 headings building vertically.  It is not recommended that-you use deeper nesting of section levels with reveal.js.--Incremental lists--------------------By default, these writers produce lists that display "all at once."-If you want your lists to display incrementally (one item at a time),-use the `-i` option. If you want a particular list to depart from the-default, put it in a `div` block with class `incremental` or-`nonincremental`. So, for example, using the `fenced div` syntax, the-following would be incremental regardless of the document default:--    ::: incremental--    - Eat spaghetti-    - Drink wine--    :::--or--    ::: nonincremental--    - Eat spaghetti-    - Drink wine--    :::--While using `incremental` and `nonincremental` divs are the-recommended method of setting incremental lists on a per-case basis,-an older method is also supported: putting lists inside a blockquote-will depart from the document default (that is, it will display-incrementally without the `-i` option and all at once with the `-i`-option):--    > - Eat spaghetti-    > - Drink wine--Both methods allow incremental and nonincremental lists to be mixed-in a single document.--Inserting pauses-------------------You can add "pauses" within a slide by including a paragraph containing-three dots, separated by spaces:--    # Slide with a pause--    content before the pause--    . . .--    content after the pause--Styling the slides---------------------You can change the style of HTML slides by putting customized CSS files-in `$DATADIR/s5/default` (for S5), `$DATADIR/slidy` (for Slidy),-or `$DATADIR/slideous` (for Slideous),-where `$DATADIR` is the user data directory (see `--data-dir`, above).-The originals may be found in pandoc's system data directory (generally-`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any-files it does not find in the user data directory.--For dzslides, the CSS is included in the HTML file itself, and may-be modified there.--All [reveal.js configuration options] can be set through variables.-For example, themes can be used by setting the `theme` variable:--    -V theme=moon--Or you can specify a custom stylesheet using the `--css` option.--To style beamer slides, you can specify a `theme`, `colortheme`,-`fonttheme`, `innertheme`, and `outertheme`, using the `-V` option:--    pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf--Note that heading attributes will turn into slide attributes-(on a `<div>` or `<section>`) in HTML slide formats, allowing you-to style individual slides.  In beamer, the only heading attribute-that affects slides is the `allowframebreaks` class, which sets the-`allowframebreaks` option, causing multiple slides to be created-if the content overfills the frame.  This is recommended especially for-bibliographies:--    # References {.allowframebreaks}--Speaker notes----------------Speaker notes are supported in reveal.js and PowerPoint (pptx)-output. You can add notes to your Markdown document thus:--    ::: notes--    This is my note.--    - It can contain Markdown-    - like this list--    :::--To show the notes window in reveal.js, press `s` while viewing the-presentation. Speaker notes in PowerPoint will be available, as usual,-in handouts and presenter view.--Notes are not yet supported for other slide formats, but the notes-will not appear on the slides themselves.--Columns----------To put material in side by side columns, you can use a native-div container with class `columns`, containing two or more div-containers with class `column` and a `width` attribute:--    :::::::::::::: {.columns}-    ::: {.column width="40%"}-    contents...-    :::-    ::: {.column width="60%"}-    contents...-    :::-    ::::::::::::::--Frame attributes in beamer-----------------------------Sometimes it is necessary to add the LaTeX `[fragile]` option to-a frame in beamer (for example, when using the `minted` environment).-This can be forced by adding the `fragile` class to the heading-introducing the slide:--    # Fragile slide {.fragile}--All of the other frame attributes described in Section 8.1 of-the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,-`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,-`shrink`, `standout`, `noframenumbering`.--Background in reveal.js and beamer-------------------------------------Background images can be added to self-contained reveal.js slideshows and -to beamer slideshows.--For the same image on every slide, use the  configuration-option `background-image` either in the YAML metadata block-or as a command-line variable. (There are no other options in-beamer and the rest of this section concerns reveal.js slideshows.)--For reveal.js, you can instead use the reveal.js-native option -`parallaxBackgroundImage`. You can also set `parallaxBackgroundHorizontal` -and `parallaxBackgroundVertical` the same way and must also set -`parallaxBackgroundSize` to have your values take effect.--To set an image for a particular reveal.js slide, add-`{data-background-image="/path/to/image"}`-to the first slide-level heading on the slide (which may even be empty).--In reveal.js's overview mode, the parallaxBackgroundImage will show up-only on the first slide.--Other reveal.js background settings also work on individual slides, including-`data-background-size`, `data-background-repeat`, `data-background-color`,-`data-transition`, and `data-transition-speed`.--See the [reveal.js-documentation](https://github.com/hakimel/reveal.js#slide-backgrounds)-for more details.--For example in reveal.js:--```-----title: My Slideshow-parallaxBackgroundImage: /path/to/my/background_image.png------## Slide One--Slide 1 has background_image.png as its background.--## {data-background-image="/path/to/special_image.jpg"}--Slide 2 has a special image for its background, even though the heading has no content.-```--Creating EPUBs with pandoc-==========================--EPUB Metadata----------------EPUB metadata may be specified using the `--epub-metadata` option, but-if the source document is Markdown, it is better to use a [YAML metadata-block][Extension: `yaml_metadata_block`].  Here is an example:--    ----    title:-    - type: main-      text: My Book-    - type: subtitle-      text: An investigation of metadata-    creator:-    - role: author-      text: John Smith-    - role: editor-      text: Sarah Jones-    identifier:-    - scheme: DOI-      text: doi:10.234234.234/33-    publisher:  My Press-    rights: © 2007 John Smith, CC BY-NC-    ibooks:-      version: 1.3.4-    ...--The following fields are recognized:--`identifier`-  ~ Either a string value or an object with fields `text` and-    `scheme`.  Valid values for `scheme` are `ISBN-10`,-    `GTIN-13`, `UPC`, `ISMN-10`, `DOI`, `LCCN`, `GTIN-14`,-    `ISBN-13`, `Legal deposit number`, `URN`, `OCLC`,-    `ISMN-13`, `ISBN-A`, `JP`, `OLCC`.--`title`-  ~ Either a string value, or an object with fields `file-as` and-    `type`, or a list of such objects.  Valid values for `type` are-    `main`, `subtitle`, `short`, `collection`, `edition`, `extended`.--`creator`-  ~ Either a string value, or an object with fields `role`, `file-as`,-    and `text`, or a list of such objects.  Valid values for `role` are-    [MARC relators], but-    pandoc will attempt to translate the human-readable versions-    (like "author" and "editor") to the appropriate marc relators.--`contributor`-  ~ Same format as `creator`.--`date`-  ~ A string value in `YYYY-MM-DD` format.  (Only the year is necessary.)-    Pandoc will attempt to convert other common date formats.--`lang` (or legacy: `language`)-  ~ A string value in [BCP 47] format.  Pandoc will default to the local-    language if nothing is specified.--`subject`-  ~ A string value or a list of such values.--`description`-  ~ A string value.--`type`-  ~ A string value.--`format`-  ~ A string value.--`relation`-  ~ A string value.--`coverage`-  ~ A string value.--`rights`-  ~ A string value.--`cover-image`-  ~ A string value (path to cover image).--`css` (or legacy: `stylesheet`)-  ~ A string value (path to CSS stylesheet).--`page-progression-direction`-  ~ Either `ltr` or `rtl`. Specifies the `page-progression-direction`-    attribute for the [`spine` element].--`ibooks`-  ~ iBooks-specific metadata, with the following fields:--    - `version`: (string)-    - `specified-fonts`: `true`|`false` (default `false`)-    - `ipad-orientation-lock`: `portrait-only`|`landscape-only`-    - `iphone-orientation-lock`: `portrait-only`|`landscape-only`-    - `binding`: `true`|`false` (default `true`)-    - `scroll-axis`: `vertical`|`horizontal`|`default`--[MARC relators]: http://loc.gov/marc/relators/relaterm.html-[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem--The `epub:type` attribute----------------------------For `epub3` output, you can mark up the heading that corresponds to an EPUB-chapter using the [`epub:type` attribute][epub-type]. For example, to set-the attribute to the value `prologue`, use this markdown:--    # My chapter {epub:type=prologue}--Which will result in:--    <body epub:type="frontmatter">-      <section epub:type="prologue">-        <h1>My chapter</h1>--Pandoc will output `<body epub:type="bodymatter">`, unless-you use one of the following values, in which case either-`frontmatter` or `backmatter` will be output.--`epub:type` of first section      `epub:type` of body-----------------------------      -------------------prologue                          frontmatter-abstract                          frontmatter-acknowledgments                   frontmatter-copyright-page                    frontmatter-dedication                        frontmatter-credits                           frontmatter-keywords                          frontmatter-imprint                           frontmatter-contributors                      frontmatter-other-credits                     frontmatter-errata                            frontmatter-revision-history                  frontmatter-titlepage                         frontmatter-halftitlepage                     frontmatter-seriespage                        frontmatter-foreword                          frontmatter-preface                           frontmatter-seriespage                        frontmatter-titlepage                         frontmatter-appendix                          backmatter-colophon                          backmatter-bibliography                      backmatter-index                             backmatter--[epub-type]: http://www.idpf.org/epub/31/spec/epub-contentdocs.html#sec-epub-type-attribute--Linked media---------------By default, pandoc will download media referenced from any `<img>`, `<audio>`,-`<video>` or `<source>` element present in the generated EPUB,-and include it in the EPUB container, yielding a completely-self-contained EPUB.  If you want to link to external media resources-instead, use raw HTML in your source and add `data-external="1"` to the tag-with the `src` attribute.  For example:--    <audio controls="1">-      <source src="http://example.com/music/toccata.mp3"-              data-external="1" type="audio/mpeg">-      </source>-    </audio>--Creating Jupyter notebooks with pandoc-======================================--When creating a [Jupyter notebook], pandoc will try to infer the-notebook structure.  Code blocks with the class `code` will be-taken as code cells, and intervening content will be taken as-Markdown cells.  Attachments will automatically be created for-images in Markdown cells. Metadata will be taken from the-`jupyter` metadata field.  For example:--````-----title: My notebook-jupyter:-  nbformat: 4-  nbformat_minor: 5-  kernelspec:-     display_name: Python 2-     language: python-     name: python2-  language_info:-     codemirror_mode:-       name: ipython-       version: 2-     file_extension: ".py"-     mimetype: "text/x-python"-     name: "python"-     nbconvert_exporter: "python"-     pygments_lexer: "ipython2"-     version: "2.7.15"------# Lorem ipsum--**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus-bibendum felis dictum sodales.--``` code-print("hello")-```--## Pyout--``` code-from IPython.display import HTML-HTML("""-<script>-console.log("hello");-</script>-<b>HTML</b>-""")-```--## Image--This image ![image](myimage.png) will be-included as a cell attachment.-````--If you want to add cell attributes, group cells differently, or-add output to code cells, then you need to include divs to-indicate the structure. You can use either [fenced-divs][Extension: `fenced_divs`] or [native divs][Extension:-`native_divs`] for this.  Here is an example:--````-:::::: {.cell .markdown}-# Lorem--**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus-bibendum felis dictum sodales.-::::::--:::::: {.cell .code execution_count=1}-``` {.python}-print("hello")-```--::: {.output .stream .stdout}-```-hello-```-:::-::::::--:::::: {.cell .code execution_count=2}-``` {.python}-from IPython.display import HTML-HTML("""-<script>-console.log("hello");-</script>-<b>HTML</b>-""")-```--::: {.output .execute_result execution_count=2}-```{=html}-<script>-console.log("hello");-</script>-<b>HTML</b>-hello-```-:::-::::::-````--If you include raw HTML or TeX in an output cell, use the-[raw attribute][Extension: `fenced_attribute`], as shown-in the last cell of the example above.  Although pandoc can-process "bare" raw HTML and TeX, the result is often-interspersed raw elements and normal textual elements, and-in an output cell pandoc expects a single, connected raw-block.  To avoid using raw HTML or TeX except when-marked explicitly using raw attributes, we recommend-specifying the extensions `-raw_html-raw_tex+raw_attribute` when-translating between Markdown and ipynb notebooks.--Note that options and extensions that affect reading and-writing of Markdown will also affect Markdown cells in ipynb-notebooks.  For example, `--wrap=preserve` will preserve-soft line breaks in Markdown cells; `--atx-headers` will-cause ATX-style headings to be used; and `--preserve-tabs` will-prevent tabs from being turned to spaces.--Syntax highlighting-===================--Pandoc will automatically highlight syntax in [fenced code blocks] that-are marked with a language name.  The Haskell library [skylighting] is-used for highlighting. Currently highlighting is supported only for-HTML, EPUB, Docx, Ms, and LaTeX/PDF output. To see a list of language names-that pandoc will recognize, type `pandoc --list-highlight-languages`.--The color scheme can be selected using the `--highlight-style` option.-The default color scheme is `pygments`, which imitates the default color-scheme used by the Python library pygments (though pygments is not actually-used to do the highlighting).  To see a list of highlight styles,-type `pandoc --list-highlight-styles`.--If you are not satisfied with the predefined styles, you can-use `--print-highlight-style` to generate a JSON `.theme` file which-can be modified and used as the argument to `--highlight-style`. To-get a JSON version of the `pygments` style, for example:--    pandoc --print-highlight-style pygments > my.theme--Then edit `my.theme` and use it like this:--    pandoc --highlight-style my.theme--If you are not satisfied with the built-in highlighting, or you-want highlight a language that isn't supported, you can use the-`--syntax-definition` option to load a [KDE-style XML syntax definition-file](https://docs.kde.org/stable5/en/applications/katepart/highlight.html).-Before writing your own, have a look at KDE's [repository of syntax-definitions](https://github.com/KDE/syntax-highlighting/tree/master/data/syntax).--To disable highlighting, use the `--no-highlight` option.--[skylighting]: https://github.com/jgm/skylighting--Custom Styles-=============--Custom styles can be used in the docx and ICML formats.--Output---------By default, pandoc's docx and ICML output applies a predefined set of styles-for blocks such as paragraphs and block quotes, and uses largely default-formatting (italics, bold) for inlines. This will work for most-purposes, especially alongside a `reference.docx` file. However, if you-need to apply your own styles to blocks, or match a preexisting set of-styles, pandoc allows you to define custom styles for blocks and text-using `div`s and `span`s, respectively.--If you define a `div` or `span` with the attribute `custom-style`,-pandoc will apply your specified style to the contained elements. So,-for example using the `bracketed_spans` syntax,--    [Get out]{custom-style="Emphatically"}, he said.--would produce a docx file with "Get out" styled with character-style `Emphatically`. Similarly, using the `fenced_divs` syntax,--    Dickinson starts the poem simply:--    ::: {custom-style="Poetry"}-    | A Bird came down the Walk----    | He did not know I saw----    :::--would style the two contained lines with the `Poetry` paragraph style.--For docx output, styles will be defined in the output file as inheriting-from normal text, if the styles are not yet in your reference.docx.-If they are already defined, pandoc will not alter the definition.--This feature allows for greatest customization in conjunction with-[pandoc filters]. If you want all paragraphs after block quotes to be-indented, you can write a filter to apply the styles necessary. If you-want all italics to be transformed to the `Emphasis` character style-(perhaps to change their color), you can write a filter which will-transform all italicized inlines to inlines within an `Emphasis`-custom-style `span`.--For docx output, you don't need to enable any extensions for-custom styles to work.--[pandoc filters]: http://pandoc.org/filters.html--Input--------The docx reader, by default, only reads those styles that it can-convert into pandoc elements, either by direct conversion or-interpreting the derivation of the input document's styles.--By enabling the [`styles` extension](#ext-styles) in the docx reader-(`-f docx+styles`), you can produce output that maintains the styles-of the input document, using the `custom-style` class. Paragraph-styles are interpreted as divs, while character styles are interpreted-as spans.--For example, using the `custom-style-reference.docx` file in the test-directory, we have the following different outputs:--Without the `+styles` extension:--    $ pandoc test/docx/custom-style-reference.docx -f docx -t markdown-    This is some text.--    This is text with an *emphasized* text style. And this is text with a-    **strengthened** text style.--    > Here is a styled paragraph that inherits from Block Text.--And with the extension:--    $ pandoc test/docx/custom-style-reference.docx -f docx+styles -t markdown--    ::: {custom-style="FirstParagraph"}-    This is some text.-    :::--    ::: {custom-style="BodyText"}-    This is text with an [emphasized]{custom-style="Emphatic"} text style.-    And this is text with a [strengthened]{custom-style="Strengthened"}-    text style.-    :::--    ::: {custom-style="MyBlockStyle"}-    > Here is a styled paragraph that inherits from Block Text.-    :::--With these custom styles, you can use your input document as a-reference-doc while creating docx output (see below), and maintain the-same styles in your input and output files.--Custom writers-==============--Pandoc can be extended with custom writers written in [lua].  (Pandoc-includes a lua interpreter, so lua need not be installed separately.)--To use a custom writer, simply specify the path to the lua script-in place of the output format. For example:--    pandoc -t data/sample.lua--Creating a custom writer requires writing a lua function for each-possible element in a pandoc document.  To get a documented example-which you can modify according to your needs, do--    pandoc --print-default-data-file sample.lua--[lua]: http://www.lua.org--A note on security-==================--If you use pandoc to convert user-contributed content in a web-application, here are some things to keep in mind:--1. Although pandoc itself will not create or modify any files other-   than those you explicitly ask it create (with the exception-   of temporary files used in producing PDFs), a filter or custom-   writer could in principle do anything on your file system. Please-   audit filters and custom writers very carefully before using them.--2. If your application uses pandoc as a Haskell library (rather than-   shelling out to the executable), it is possible to use it in a mode-   that fully isolates pandoc from your file system, by running the-   pandoc operations in the `PandocPure` monad. See the document-   [Using the pandoc API](http://pandoc.org/using-the-pandoc-api.html)-   for more details.--3. Pandoc's parsers can exhibit pathological performance on some-   corner cases.  It is wise to put any pandoc operations under-   a timeout, to avoid DOS attacks that exploit these issues.-   If you are using the pandoc executable, you can add the-   command line options `+RTS -M512M -RTS` (for example) to limit-   the heap size to 512MB.--4. The HTML generated by pandoc is not guaranteed to be safe.-   If `raw_html` is enabled for the Markdown input, users can-   inject arbitrary HTML.  Even if `raw_html` is disabled,-   users can include dangerous content in attributes for-   headings, spans, and code blocks.  To be safe, you should-   run all the generated HTML through an HTML sanitizer.--Authors-=======--Copyright 2006--2019 John MacFarlane (jgm@berkeley.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.) For a full list of contributors, see the file-AUTHORS.md in the pandoc source code.--[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"+---+title: Pandoc User's Guide+author: John MacFarlane+date: November 22, 2019+---++# 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.++Pandoc can convert between numerous markup and word processing formats,+including, but not limited to, various flavors of [Markdown], [HTML],+[LaTeX] and [Word docx]. For the full lists of input and output formats,+see the `--from` and `--to` [options below][General options].+Pandoc can also produce [PDF] output: see [creating a PDF], below.++Pandoc's enhanced version of Markdown includes syntax for [tables],+[definition lists], [metadata blocks], [footnotes], [citations], [math],+and much more.  See below under [Pandoc's Markdown].++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+(an _abstract syntax tree_ or AST), 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. Users can also+run custom [pandoc filters] to modify the intermediate AST.++Because pandoc's intermediate representation of a document is less+expressive than many of the formats it converts between, one should+not expect perfect conversions between every format and every other.+Pandoc attempts to preserve the structural elements of a document, but+not formatting details such as margin size.  And some document elements,+such as complex tables, may not fit into pandoc's simple document+model.  While conversions from pandoc's Markdown to all formats aspire+to be perfect, conversions from formats more expressive than pandoc's+Markdown can be expected to be lossy.++## Using pandoc++If no *input-files* are specified, input is read from *stdin*.+Output goes to *stdout* by default. For output to a file,+use the `-o` option:++    pandoc -o output.html input.txt++By default, pandoc produces a document fragment. To produce a standalone+document (e.g. a valid HTML file including `<head>` and `<body>`),+use the `-s` or `--standalone` flag:++    pandoc -s -o output.html input.txt++For more information on how standalone documents are produced, see+[Templates] below.++If multiple input files are given, `pandoc` will concatenate them all (with+blank lines between them) before parsing. (Use `--file-scope` to parse files+individually.)++## Specifying formats++The format of the input and output can be specified explicitly using+command-line options.  The input format can be specified using the+`-f/--from` option, the output format using the `-t/--to` option.+Thus, to convert `hello.txt` from Markdown to LaTeX, you could type:++    pandoc -f markdown -t latex hello.txt++To convert `hello.html` from HTML to Markdown:++    pandoc -f html -t markdown hello.html++Supported input and output formats are listed below under [Options]+(see `-f` for input formats and `-t` for output formats).  You+can also use `pandoc --list-input-formats` and+`pandoc --list-output-formats` to print lists of supported+formats.++If the input or output format is not specified explicitly, `pandoc`+will attempt to guess it from the extensions of the 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+extension is unknown, the output format will default to HTML.+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.++## Character encoding++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++Note that in some output formats (such as HTML, LaTeX, ConTeXt,+RTF, OPML, DocBook, and Texinfo), information about+the character encoding is included in the document header, which+will only be included if you use the `-s/--standalone` option.++[`iconv`]: http://www.gnu.org/software/libiconv/++## Creating a PDF++To produce a PDF, specify an output file with a `.pdf` extension:++    pandoc test.txt -o test.pdf++By default, pandoc will use LaTeX to create the PDF, which requires+that a LaTeX engine be installed (see `--pdf-engine` below).++Alternatively, pandoc can use [ConTeXt], `pdfroff`, or any of the+following HTML/CSS-to-PDF-engines, to create a PDF: [`wkhtmltopdf`],+[`weasyprint`] or [`prince`].+To do this, specify an output file with a `.pdf` extension, as before,+but add the `--pdf-engine` option or `-t context`, `-t html`, or `-t ms`+to the command line (`-t html` defaults to `--pdf-engine=wkhtmltopdf`).++PDF output uses [variables for LaTeX] (with a LaTeX engine);+[variables for ConTeXt] (with ConTeXt); or [variables for `wkhtmltopdf`]+(an HTML/CSS-to-PDF engine; `--css` also affects the output).++To debug the PDF creation, it can be useful to look at the intermediate+representation: instead of `-o test.pdf`, use for example `-s -o test.tex`+to output the generated LaTeX. You can then test it with `pdflatex test.tex`.++When using LaTeX, the following packages need to be available+(they are included with all recent versions of [TeX Live]):+[`amsfonts`], [`amsmath`], [`lm`], [`unicode-math`],+[`ifxetex`], [`ifluatex`], [`listings`] (if the+`--listings` option is used), [`fancyvrb`], [`longtable`],+[`booktabs`], [`graphicx`] and [`grffile`] (if the document+contains images), [`hyperref`], [`xcolor`],+[`ulem`], [`geometry`] (with the `geometry` variable set),+[`setspace`] (with `linestretch`), and+[`babel`] (with `lang`).  The use of `xelatex` or `lualatex` as+the PDF engine requires [`fontspec`].  `xelatex` uses+[`polyglossia`] (with `lang`), [`xecjk`], and [`bidi`] (with the+`dir` variable set). If the `mathspec` variable is set,+`xelatex` will use [`mathspec`] instead of [`unicode-math`].+The [`upquote`] and [`microtype`] packages are used if+available, and [`csquotes`] will be used for [typography]+if the `csquotes` variable or metadata field is set to a+true value.  The [`natbib`], [`biblatex`], [`bibtex`], and+[`biber`] packages can optionally be used for [citation+rendering].  The following packages will be used to improve+output quality if present, but pandoc does not require them to+be present: [`upquote`] (for straight quotes in verbatim+environments), [`microtype`] (for better spacing adjustments),+[`parskip`] (for better inter-paragraph spaces), [`xurl`] (for+better line breaks in URLs), [`bookmark`] (for better PDF+bookmarks), and [`footnotehyper`] or [`footnote`] (to allow+footnotes in tables).++[TeX Live]: http://www.tug.org/texlive/+[`amsfonts`]: https://ctan.org/pkg/amsfonts+[`amsmath`]: https://ctan.org/pkg/amsmath+[`babel`]: https://ctan.org/pkg/babel+[`biber`]: https://ctan.org/pkg/biber+[`biblatex`]: https://ctan.org/pkg/biblatex+[`bibtex`]: https://ctan.org/pkg/bibtex+[`bidi`]: https://ctan.org/pkg/bidi+[`bookmark`]: https://ctan.org/pkg/bookmark+[`booktabs`]: https://ctan.org/pkg/booktabs+[`csquotes`]: https://ctan.org/pkg/csquotes+[`fancyvrb`]: https://ctan.org/pkg/fancyvrb+[`fontspec`]: https://ctan.org/pkg/fontspec+[`footnote`]: https://ctan.org/pkg/footnote+[`footnotehyper`]: https://ctan.org/pkg/footnotehyper+[`geometry`]: https://ctan.org/pkg/geometry+[`graphicx`]: https://ctan.org/pkg/graphicx+[`grffile`]: https://ctan.org/pkg/grffile+[`hyperref`]: https://ctan.org/pkg/hyperref+[`ifluatex`]: https://ctan.org/pkg/ifluatex+[`ifxetex`]: https://ctan.org/pkg/ifxetex+[`listings`]: https://ctan.org/pkg/listings+[`lm`]: https://ctan.org/pkg/lm+[`longtable`]: https://ctan.org/pkg/longtable+[`mathspec`]: https://ctan.org/pkg/mathspec+[`microtype`]: https://ctan.org/pkg/microtype+[`natbib`]: https://ctan.org/pkg/natbib+[`parskip`]: https://ctan.org/pkg/parskip+[`polyglossia`]: https://ctan.org/pkg/polyglossia+[`prince`]: https://www.princexml.com/+[`setspace`]: https://ctan.org/pkg/setspace+[`ulem`]: https://ctan.org/pkg/ulem+[`unicode-math`]: https://ctan.org/pkg/unicode-math+[`upquote`]: https://ctan.org/pkg/upquote+[`weasyprint`]: http://weasyprint.org+[`wkhtmltopdf`]: https://wkhtmltopdf.org+[`xcolor`]: https://ctan.org/pkg/xcolor+[`xecjk`]: https://ctan.org/pkg/xecjk+[`xurl`]: https://ctan.org/pkg/xurl++++## Reading from the Web++Instead of an input 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++It is possible to supply a custom User-Agent string or other+header when requesting a document from a URL:++    pandoc -f html -t markdown --request-header User-Agent:"Mozilla/5.0" \+      http://www.fsf.org++# Options++## General options {.options}++`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*++:   Specify input format.  *FORMAT* can be:++    ::: {#input-formats}+    - `commonmark` ([CommonMark] Markdown)+    - `creole` ([Creole 1.0])+    - `docbook` ([DocBook])+    - `docx` ([Word docx])+    - `dokuwiki` ([DokuWiki markup])+    - `epub` ([EPUB])+    - `fb2` ([FictionBook2] e-book)+    - `gfm` ([GitHub-Flavored Markdown]),+      or the deprecated and less accurate `markdown_github`;+      use [`markdown_github`](#markdown-variants) only+      if you need extensions not supported in [`gfm`](#markdown-variants).+    - `haddock` ([Haddock markup])+    - `html` ([HTML])+    - `ipynb` ([Jupyter notebook])+    - `jats` ([JATS] XML)+    - `json` (JSON version of native AST)+    - `latex` ([LaTeX])+    - `markdown` ([Pandoc's Markdown])+    - `markdown_mmd` ([MultiMarkdown])+    - `markdown_phpextra` ([PHP Markdown Extra])+    - `markdown_strict` (original unextended [Markdown])+    - `mediawiki` ([MediaWiki markup])+    - `man` ([roff man])+    - `muse` ([Muse])+    - `native` (native Haskell)+    - `odt` ([ODT])+    - `opml` ([OPML])+    - `org` ([Emacs Org mode])+    - `rst` ([reStructuredText])+    - `t2t` ([txt2tags])+    - `textile` ([Textile])+    - `tikiwiki` ([TikiWiki markup])+    - `twiki` ([TWiki markup])+    - `vimwiki` ([Vimwiki])+    :::++    Extensions can be individually enabled or disabled by+    appending `+EXTENSION` or `-EXTENSION` to the format name.+    See [Extensions] below, for a list of extensions and+    their names.  See `--list-input-formats` and `--list-extensions`,+    below.++`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*++:   Specify output format.  *FORMAT* can be:++    ::: {#output-formats}+    - `asciidoc` ([AsciiDoc]) or `asciidoctor` ([AsciiDoctor])+    - `beamer` ([LaTeX beamer][`beamer`] slide show)+    - `commonmark` ([CommonMark] Markdown)+    - `context` ([ConTeXt])+    - `docbook` or `docbook4` ([DocBook] 4)+    - `docbook5` (DocBook 5)+    - `docx` ([Word docx])+    - `dokuwiki` ([DokuWiki markup])+    - `epub` or `epub3` ([EPUB] v3 book)+    - `epub2` (EPUB v2)+    - `fb2` ([FictionBook2] e-book)+    - `gfm` ([GitHub-Flavored Markdown]),+      or the deprecated and less accurate `markdown_github`;+      use [`markdown_github`](#markdown-variants) only+      if you need extensions not supported in [`gfm`](#markdown-variants).+    - `haddock` ([Haddock markup])+    - `html` or `html5` ([HTML], i.e. [HTML5]/XHTML [polyglot markup])+    - `html4` ([XHTML] 1.0 Transitional)+    - `icml` ([InDesign ICML])+    - `ipynb` ([Jupyter notebook])+    - `jats` ([JATS] XML)+    - `jira` ([Jira] wiki markup)+    - `json` (JSON version of native AST)+    - `latex` ([LaTeX])+    - `man` ([roff man])+    - `markdown` ([Pandoc's Markdown])+    - `markdown_mmd` ([MultiMarkdown])+    - `markdown_phpextra` ([PHP Markdown Extra])+    - `markdown_strict` (original unextended [Markdown])+    - `mediawiki` ([MediaWiki markup])+    - `ms` ([roff ms])+    - `muse` ([Muse]),+    - `native` (native Haskell),+    - `odt` ([OpenOffice text document][ODT])+    - `opml` ([OPML])+    - `opendocument` ([OpenDocument])+    - `org` ([Emacs Org mode])+    - `pdf` ([PDF])+    - `plain` (plain text),+    - `pptx` ([PowerPoint] slide show)+    - `rst` ([reStructuredText])+    - `rtf` ([Rich Text Format])+    - `texinfo` ([GNU Texinfo])+    - `textile` ([Textile])+    - `slideous` ([Slideous] HTML and JavaScript slide show)+    - `slidy` ([Slidy] HTML and JavaScript slide show)+    - `dzslides` ([DZSlides] HTML5 + JavaScript slide show),+    - `revealjs` ([reveal.js] HTML5 + JavaScript slide show)+    - `s5` ([S5] HTML and JavaScript slide show)+    - `tei` ([TEI Simple])+    - `xwiki` ([XWiki markup])+    - `zimwiki` ([ZimWiki markup])+    - the path of a custom lua writer, see [Custom writers] below+    :::++    Note that `odt`, `docx`, `epub`, and `pdf` output will not be directed+    to *stdout* unless forced with `-o -`.++    Extensions can be individually enabled or+    disabled by appending `+EXTENSION` or `-EXTENSION` to the format+    name.  See [Extensions] below, for a list of extensions and their+    names.  See `--list-output-formats` and `--list-extensions`, below.++`-o` *FILE*, `--output=`*FILE*++:   Write output to *FILE* instead of *stdout*.  If *FILE* is+    `-`, output will go to *stdout*, even if a non-textual format+    (`docx`, `odt`, `epub2`, `epub3`) is specified.++`--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.  On \*nix and macOS systems this will be the `pandoc`+    subdirectory of the XDG data directory (by default,+    `$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`+    environment variable).  If that directory does not exist,+    `$HOME/.pandoc` will be used (for backwards compatibility).+    In Windows the default user data directory is+    `C:\Users\USERNAME\AppData\Roaming\pandoc`.+    You can find the default user data directory on your system by+    looking at the output of `pandoc --version`.+    A `reference.odt`, `reference.docx`, `epub.css`, `templates`,+    `slidy`, `slideous`, or `s5` directory+    placed in this directory will override pandoc's normal defaults.++`-d` *FILE*, `--defaults=`*FILE*++:   Specify a set of default option settings.  *FILE* is a YAML+    file whose fields correspond to command-line option+    settings.  All options for document conversion, including input+    and output files, can be set using a defaults file.  The file will+    be searched for first in the working directory, and then in+    the `defaults` subdirectory of the user data directory+    (see `--data-dir`).  The `.yaml` extension may be omitted.+    See the section [Default files] for more information on the+    file format.  Settings from the defaults file may be+    overridden or extended by subsequent options on the command+    line.++`--bash-completion`++:   Generate a bash completion script.  To enable bash completion+    with pandoc, add this to your `.bashrc`:++        eval "$(pandoc --bash-completion)"++`--verbose`++:   Give verbose debugging output.  Currently this only has an effect+    with PDF output.++`--quiet`++:   Suppress warning messages.++`--fail-if-warnings`++:   Exit with error status if there are any warnings.++`--log=`*FILE*++:   Write log messages in machine-readable JSON format to+    *FILE*.  All messages above DEBUG level will be written,+    regardless of verbosity settings (`--verbose`, `--quiet`).++`--list-input-formats`++:   List supported input formats, one per line.++`--list-output-formats`++:   List supported output formats, one per line.++`--list-extensions`[`=`*FORMAT*]++:   List supported extensions for *FORMAT*, one per line, preceded+    by a `+` or `-` indicating whether it is enabled by default+    in *FORMAT*. If *FORMAT* is not specified, defaults for+    pandoc's Markdown are given.++`--list-highlight-languages`++:   List supported languages for syntax highlighting, one per+    line.++`--list-highlight-styles`++:   List supported styles for syntax highlighting, one per line.+    See `--highlight-style`.++`-v`, `--version`++:   Print version.++`-h`, `--help`++:   Show usage message.++[Markdown]: http://daringfireball.net/projects/markdown/+[CommonMark]: http://commonmark.org+[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/+[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/+[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/+[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/+[Slideous]: http://goessner.net/articles/slideous/+[HTML]: http://www.w3.org/html/+[HTML5]: http://www.w3.org/TR/html5/+[polyglot markup]: https://www.w3.org/TR/html-polyglot/+[XHTML]: http://www.w3.org/TR/xhtml1/+[LaTeX]: http://latex-project.org+[`beamer`]: https://ctan.org/pkg/beamer+[Beamer User's Guide]: http://mirrors.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf+[ConTeXt]: http://www.contextgarden.net/+[Rich Text Format]: http://en.wikipedia.org/wiki/Rich_Text_Format+[DocBook]: http://docbook.org+[JATS]: https://jats.nlm.nih.gov+[Jira]: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all+[txt2tags]: http://txt2tags.org+[EPUB]: http://idpf.org/epub+[OPML]: http://dev.opml.org/spec2.html+[OpenDocument]: http://opendocument.xml.org+[ODT]: http://en.wikipedia.org/wiki/OpenDocument+[Textile]: http://redcloth.org/textile+[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting+[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki+[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html+[XWiki markup]: https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiSyntax/+[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules+[TikiWiki markup]: https://doc.tiki.org/Wiki-Syntax-Text#The_Markup_Language_Wiki-Syntax+[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html+[Creole 1.0]: http://www.wikicreole.org/wiki/Creole1.0+[roff man]: http://man7.org/linux/man-pages/man7/groff_man.7.html+[roff ms]: http://man7.org/linux/man-pages/man7/groff_ms.7.html+[Haskell]: https://www.haskell.org+[GNU Texinfo]: http://www.gnu.org/software/texinfo/+[Emacs Org mode]: http://orgmode.org+[AsciiDoc]: http://www.methods.co.nz/asciidoc/+[AsciiDoctor]: https://asciidoctor.org/+[DZSlides]: http://paulrouget.com/dzslides/+[Word docx]: https://en.wikipedia.org/wiki/Office_Open_XML+[PDF]: https://www.adobe.com/pdf/+[reveal.js]: http://lab.hakim.se/reveal-js/+[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1+[Jupyter notebook]: https://nbformat.readthedocs.io/en/latest/+[InDesign ICML]: http://wwwimages.adobe.com/www.adobe.com/content/dam/acom/en/devnet/indesign/sdk/cs6/idml/idml-cookbook.pdf+[TEI Simple]: https://github.com/TEIC/TEI-Simple+[Muse]: https://amusewiki.org/library/manual+[PowerPoint]: https://en.wikipedia.org/wiki/Microsoft_PowerPoint+[Vimwiki]: https://vimwiki.github.io++## Reader options {.options}++`--shift-heading-level-by=`*NUMBER*++:   Shift heading levels by a positive or negative integer.+    For example, with `--shift-heading-level-by=-1`, level 2+    headings become level 1 headings, and level 3 headings+    become level 2 headings.  Headings cannot have a level+    less than 1, so a heading that would be shifted below level 1+    becomes a regular paragraph.  Exception: with a shift of -1,+    a level-1 heading at the beginning of the document+    replaces the metadata title. Conversely, with a shift+    of +1, a nonempty metadata title becomes a level-1 heading at+    the beginning of the document.  `--shift-heading-level-by=-1`+    is a good choice when converting HTML or Markdown documents that+    use an initial level-1 heading for the document title and+    level-2+ headings for sections.++`--base-header-level=`*NUMBER*++:   *Deprecated.  Use `--shift-heading-level-by` instead.*+    Specify the base level for headings (defaults to 1).++`--strip-empty-paragraphs`++:   *Deprecated.  Use the `+empty_paragraphs` extension instead.*+    Ignore paragraphs with no content.  This option is useful+    for converting word processing documents where users have+    used empty paragraphs to create inter-paragraph space.++`--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.++`--default-image-extension=`*EXTENSION*++:   Specify a default extension to use when image paths/URLs have no+    extension.  This allows you to use the same source for formats that+    require different kinds of images.  Currently this option only affects+    the Markdown and LaTeX readers.++`--file-scope`++:   Parse each file individually before combining for multifile+    documents. This will allow footnotes in different files with the+    same identifiers to work as expected. If this option is set,+    footnotes and links will not work across files. Reading binary+    files (docx, odt, epub) implies `--file-scope`.++`-F` *PROGRAM*, `--filter=`*PROGRAM*++:   Specify an executable to be used as a filter transforming the+    pandoc AST after the input is parsed and before the output is+    written.  The executable should read JSON from stdin and write+    JSON to stdout.  The JSON must be formatted like  pandoc's own+    JSON input and output.  The name of the output format will be+    passed to the filter as the first argument.  Hence,++        pandoc --filter ./caps.py -t latex++    is equivalent to++        pandoc -t json | ./caps.py latex | pandoc -f json -t latex++    The latter form may be useful for debugging filters.++    Filters may be written in any language.  `Text.Pandoc.JSON`+    exports `toJSONFilter` to facilitate writing filters in Haskell.+    Those who would prefer to write filters in python can use the+    module [`pandocfilters`], installable from PyPI. There are also+    pandoc filter libraries in [PHP], [perl], and+    [JavaScript/node.js].++    In order of preference, pandoc will look for filters in++     1. a specified full or relative path (executable or+     non-executable)++     2. `$DATADIR/filters` (executable or non-executable)+     where `$DATADIR` is the user data directory (see+     `--data-dir`, above).++     3. `$PATH` (executable only)++    Filters and lua-filters are applied in the order specified+    on the command line.++`-L` *SCRIPT*, `--lua-filter=`*SCRIPT*++:   Transform the document in a similar fashion as JSON filters (see+    `--filter`), but use pandoc's build-in lua filtering system.  The given+    lua script is expected to return a list of lua filters which will be+    applied in order.  Each lua filter must contain element-transforming+    functions indexed by the name of the AST element on which the filter+    function should be applied.++    The `pandoc` lua module provides helper functions for element+    creation.  It is always loaded into the script's lua environment.++    The following is an example lua script for macro-expansion:++        function expand_hello_world(inline)+          if inline.c == '{{helloworld}}' then+            return pandoc.Emph{ pandoc.Str "Hello, World" }+          else+            return inline+          end+        end++        return {{Str = expand_hello_world}}++    In order of preference, pandoc will look for lua filters in++     1. a specified full or relative path (executable or+     non-executable)++     2. `$DATADIR/filters` (executable or non-executable)+     where `$DATADIR` is the user data directory (see+     `--data-dir`, above).++`-M` *KEY*[`=`*VAL*], `--metadata=`*KEY*[`:`*VAL*]++:   Set the metadata field *KEY* to the value *VAL*.  A value specified+    on the command line overrides a value specified in the document+    using [YAML metadata blocks][Extension: `yaml_metadata_block`].+    Values will be parsed as YAML boolean or string values. If no value is+    specified, the value will be treated as Boolean true.  Like+    `--variable`, `--metadata` causes template variables to be set.+    But unlike `--variable`, `--metadata` affects the metadata of the+    underlying document (which is accessible from filters and may be+    printed in some output formats) and metadata values will be escaped+    when inserted into the template.++`--metadata-file=`*FILE*++:   Read metadata from the supplied YAML (or JSON) file. This+    option can be used with every input format, but string scalars+    in the YAML file will always be parsed as Markdown. Generally,+    the input will be handled the same as in [YAML metadata+    blocks][Extension: `yaml_metadata_block`]. This option can be+    used repeatedly to include multiple metadata files; values in+    files specified later on the command line will be preferred+    over those specified in earlier files. Metadata values+    specified inside the document, or by using `-M`, overwrite+    values specified with this option.++`-p`, `--preserve-tabs`++:   Preserve tabs instead of converting them to spaces. (By default, pandoc+    converts tabs to spaces before parsing its input.)  Note that this will+    only affect tabs in literal code spans and code blocks. Tabs in regular+    text are always treated as spaces.++`--tab-stop=`*NUMBER*++:   Specify the number of spaces per tab (default is 4).++`--track-changes=accept`|`reject`|`all`++:   Specifies what to do with insertions, deletions, and comments+    produced by the MS Word "Track Changes" feature.  `accept` (the+    default), inserts all insertions, and ignores all+    deletions. `reject` inserts all deletions and ignores+    insertions. Both `accept` and `reject` ignore comments. `all` puts+    in insertions, deletions, and comments, wrapped in spans with+    `insertion`, `deletion`, `comment-start`, and `comment-end`+    classes, respectively. The author and time of change is+    included. `all` is useful for scripting: only accepting changes+    from a certain reviewer, say, or before a certain date. If a+    paragraph is inserted or deleted, `track-changes=all` produces a+    span with the class `paragraph-insertion`/`paragraph-deletion`+    before the affected paragraph break. This option only affects the+    docx reader.++`--extract-media=`*DIR*++:   Extract images and other media contained in or linked from+    the source document to the path *DIR*, creating it if+    necessary, and adjust the images references in the document+    so they point to the extracted files.  If the source format is+    a binary container (docx, epub, or odt), the media is+    extracted from the container and the original+    filenames are used. Otherwise the media is read from the+    file system or downloaded, and new filenames are constructed+    based on SHA1 hashes of the contents.++`--abbreviations=`*FILE*++:   Specifies a custom abbreviations file, with abbreviations+    one to a line.  If this option is not specified, pandoc will+    read the data file `abbreviations` from the user data+    directory or fall back on a system default.  To see the+    system default, use+    `pandoc --print-default-data-file=abbreviations`.  The only+    use pandoc makes of this list is in the Markdown reader.+    Strings ending in a period that are found in this list will+    be followed by a nonbreaking space, so that the period will+    not produce sentence-ending space in formats like LaTeX.++[`pandocfilters`]: https://github.com/jgm/pandocfilters+[PHP]: https://github.com/vinai/pandocfilters-php+[perl]: https://metacpan.org/pod/Pandoc::Filter+[JavaScript/node.js]: https://github.com/mvhenderson/pandoc-filter-node++## General writer options {.options}++`-s`, `--standalone`++:   Produce output with an appropriate header and footer (e.g. a+    standalone HTML, LaTeX, TEI, or RTF file, not a fragment).  This option+    is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`+    output.  For `native` output, this option causes metadata to+    be included; otherwise, metadata is suppressed.++`--template=`*FILE*|*URL*++:   Use the specified file as a custom template for the generated document.+    Implies `--standalone`. See [Templates], below, for a description+    of template syntax. If no extension is specified, an extension+    corresponding to the writer will be added, so that `--template=special`+    looks for `special.html` for HTML output.  If the template is not+    found, pandoc will search for it in the `templates` subdirectory of+    the user data directory (see `--data-dir`). If this option is not used,+    a default template appropriate for the output format will be used (see+    `-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. If no *VAL* is specified, the+    key will be given the value `true`.++`-D` *FORMAT*, `--print-default-template=`*FORMAT*++:   Print the system default template for an output *FORMAT*. (See `-t`+    for a list of possible *FORMAT*s.)  Templates in the user data+    directory are ignored.  This option may be used with+    `-o`/`--output` to redirect output to a file, but+    `-o`/`--output` must come before `--print-default-template`+    on the command line.++    Note that some of the default templates use partials, for+    example `styles.html`.  To print the partials, use+    `--print-default-data-file`: for example,+    `--print-default-data-file=templates/styles.html`.++`--print-default-data-file=`*FILE*++:   Print a system default data file.  Files in the user data directory+    are ignored.  This option may be used with `-o`/`--output` to+    redirect output to a file, but `-o`/`--output` must come before+    `--print-default-data-file` on the command line.++`--eol=crlf`|`lf`|`native`++:   Manually specify line endings: `crlf` (Windows), `lf`+    (macOS/Linux/UNIX), or `native` (line endings appropriate+    to the OS on which pandoc is being run).  The default is+    `native`.++`--dpi`=*NUMBER*++:   Specify the default dpi (dots per inch) value for conversion+    from pixels to inch/centimeters and vice versa. (Technically,+    the correct term would be ppi: pixels per inch.) The default+    is 96dpi.   When images contain information about dpi+    internally, the encoded value is used instead of the default+    specified by this option.++`--wrap=auto`|`none`|`preserve`++:   Determine how text is wrapped in the output (the source+    code, not the rendered version).  With `auto` (the default),+    pandoc will attempt to wrap lines to the column width specified by+    `--columns` (default 72).  With `none`, pandoc will not wrap+    lines at all.  With `preserve`, pandoc will attempt to+    preserve the wrapping from the source document (that is,+    where there are nonsemantic newlines in the source, there+    will be nonsemantic newlines in the output as well).+    Automatic wrapping does not currently work in HTML output.+    In `ipynb` output, this option affects wrapping of the+    contents of markdown cells.++`--columns=`*NUMBER*++:   Specify length of lines in characters.  This affects text wrapping+    in the generated source code (see `--wrap`).  It also affects+    calculation of column widths for plain text tables (see [Tables] below).++`--toc`, `--table-of-contents`++:   Include an automatically generated table of contents (or, in+    the case of `latex`, `context`, `docx`, `odt`,+    `opendocument`, `rst`, or `ms`, an instruction to create+    one) in the output document. This option has no effect+    unless `-s/--standalone` is used, and it has no effect+    on `man`, `docbook4`, `docbook5`, or `jats` output.++    Note that if you are producing a PDF via `ms`, the table+    of contents will appear at the beginning of the+    document, before the title.  If you would prefer it to+    be at the end of the document, use the option+    `--pdf-engine-opt=--no-toc-relocation`.++`--toc-depth=`*NUMBER*++:   Specify the number of section levels to include in the table+    of contents.  The default is 3 (which means that level-1, 2, and 3+    headings will be listed in the contents).++`--strip-comments`++:   Strip out HTML comments in the Markdown or Textile source,+    rather than passing them on to Markdown, Textile or HTML+    output as raw HTML.  This does not apply to HTML comments+    inside raw HTML blocks when the `markdown_in_html_blocks`+    extension is not set.++`--no-highlight`++:   Disables syntax highlighting for code blocks and inlines, even when+    a language attribute is given.++`--highlight-style=`*STYLE*|*FILE*++:   Specifies the coloring style to be used in highlighted source code.+    Options are `pygments` (the default), `kate`, `monochrome`,+    `breezeDark`, `espresso`, `zenburn`, `haddock`, and `tango`.+    For more information on syntax highlighting in pandoc, see+    [Syntax highlighting], below.  See also+    `--list-highlight-styles`.++    Instead of a *STYLE* name, a JSON file with extension+    `.theme` may be supplied.  This will be parsed as a KDE+    syntax highlighting theme and (if valid) used as the+    highlighting style.++    To generate the JSON version of an existing style,+    use `--print-highlight-style`.++`--print-highlight-style=`*STYLE*|*FILE*++:   Prints a JSON version of a highlighting style, which can+    be modified, saved with a `.theme` extension, and used+    with `--highlight-style`.  This option may be used with+    `-o`/`--output` to redirect output to a file, but+    `-o`/`--output` must come before `--print-highlight-style`+    on the command line.++`--syntax-definition=`*FILE*++:   Instructs pandoc to load a KDE XML syntax definition file,+    which will be used for syntax highlighting of appropriately+    marked code blocks.  This can be used to add support for+    new languages or to use altered syntax definitions for+    existing languages.  This option may be repeated to add+    multiple syntax definitions.++`-H` *FILE*, `--include-in-header=`*FILE*|*URL*++:   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` *FILE*, `--include-before-body=`*FILE*|*URL*++:   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` *FILE*, `--include-after-body=`*FILE*|*URL*++:   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 used+    repeatedly to include multiple files. They will be included in the+    order specified.  Implies `--standalone`.++`--resource-path=`*SEARCHPATH*++:   List of paths to search for images and other resources.+    The paths should be separated by `:` on Linux, UNIX, and+    macOS systems, and by `;` on Windows.  If `--resource-path`+    is not specified, the default resource path is the working+    directory. Note that, if `--resource-path` is specified,+    the working directory must be explicitly listed or it+    will not be searched.  For example:+    `--resource-path=.:test` will search the working directory+    and the `test` subdirectory, in that order.++    `--resource-path` only has an effect if (a) the output+    format embeds images (for example, `docx`, `pdf`, or `html`+    with `--self-contained`) or (b) it is used together with+    `--extract-media`.++`--request-header=`*NAME*`:`*VAL*++:   Set the request header *NAME* to the value *VAL* when making+    HTTP requests (for example, when a URL is given on the+    command line, or when resources used in a document must be+    downloaded). If you're behind a proxy, you also need to set+    the environment variable `http_proxy` to `http://...`.++## Options affecting specific writers {.options}++`--self-contained`++:   Produce a standalone HTML file with no external dependencies, using+    `data:` URIs to incorporate the contents of linked scripts, stylesheets,+    images, and videos. Implies `--standalone`. The resulting file should be+    "self-contained," in the sense that it needs no external files and no net+    access to be displayed properly by a browser. This option works only with+    HTML output formats, including `html4`, `html5`, `html+lhs`, `html5+lhs`,+    `s5`, `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images,+    and stylesheets at absolute URLs will be downloaded; those at relative+    URLs will be sought relative to the working directory (if the first source+    file is local) or relative to the base URL (if the first source+    file is remote).  Elements with the attribute+    `data-external="1"` will be left alone; the documents they+    link to will not be incorporated in the document.+    Limitation: resources that are loaded dynamically through+    JavaScript cannot be incorporated; as a result,+    `--self-contained` does not work with `--mathjax`, and some+    advanced features (e.g.  zoom or speaker notes) may not work+    in an offline "self-contained" `reveal.js` slide show.++`--html-q-tags`++:   Use `<q>` tags for quotes in HTML.++`--ascii`++:   Use only ASCII characters in output. Currently supported for XML+    and HTML formats (which use entities instead of UTF-8 when this+    option is selected), CommonMark, gfm, and Markdown (which use+    entities), roff ms (which use hexadecimal escapes), and to a+    limited degree LaTeX (which uses standard commands for accented+    characters when possible). roff man output uses ASCII by default.++`--reference-links`++:   Use reference-style links, rather than inline links, in writing Markdown+    or reStructuredText.  By default inline links are used.  The+    placement of link references is affected by the+    `--reference-location` option.++`--reference-location = block`|`section`|`document`++:   Specify whether footnotes (and references, if `reference-links` is+    set) are placed at the end of the current (top-level) block, the+    current section, or the document. The default is+    `document`. Currently only affects the markdown writer.++`--atx-headers`++:   Use ATX-style headings in Markdown output. The default is+    to use setext-style headings for levels 1 to 2, and then ATX headings.+    (Note: for `gfm` output, ATX headings are always used.)+    This option also affects markdown cells in `ipynb` output.++`--top-level-division=[default|section|chapter|part]`++:   Treat top-level headings as the given division type in LaTeX, ConTeXt,+    DocBook, and  TEI output. The hierarchy order is part, chapter, then section;+    all headings are shifted such that the top-level heading becomes the specified+    type. The default behavior is to determine the best division type via+    heuristics: unless other conditions apply, `section` is chosen. When the+    `documentclass` variable is set to `report`, `book`, or `memoir` (unless the+    `article` option is specified), `chapter` is implied as the setting for this+    option. If `beamer` is the output format, specifying either `chapter` or+    `part` will cause top-level headings to become `\part{..}`, while+    second-level headings remain as their default type.++`-N`, `--number-sections`++:   Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.+    By default, sections are not numbered.  Sections with class+    `unnumbered` will never be numbered, even if `--number-sections`+    is specified.++`--number-offset=`*NUMBER*[`,`*NUMBER*`,`*...*]++:   Offset for section headings in HTML output (ignored in other+    output formats).  The first number is added to the section number for+    top-level headings, the second for second-level headings, and so on.+    So, for example, if you want the first top-level heading in your+    document to be numbered "6", specify `--number-offset=5`.+    If your document starts with a level-2 heading which you want to+    be numbered "1.5", specify `--number-offset=1,4`.+    Offsets are 0 by default.  Implies `--number-sections`.++`--listings`++:   Use the [`listings`] package for LaTeX code blocks. The package+    does not support multi-byte encoding for source code. To handle UTF-8+    you would need to use a custom template. This issue is fully +    documented here: [Encoding issue with the listings package].++`-i`, `--incremental`++:   Make list items in slide shows display incrementally (one by one).+    The default is for lists to be displayed all at once.++`--slide-level=`*NUMBER*++:   Specifies that headings with the specified level create+    slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`).  Headings+    above this level in the hierarchy are used to divide the+    slide show into sections; headings below this level create+    subheads within a slide.  Note that content that is+    not contained under slide-level headings will not appear in+    the slide show.  The default is to set the slide level based+    on the contents of the document; see [Structuring the slide+    show].++`--section-divs`++:   Wrap sections in `<section>` tags (or `<div>` tags for `html4`),+    and attach identifiers to the enclosing `<section>` (or `<div>`)+    rather than the heading itself. See+    [Heading identifiers], below.++`--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.  The default+    is `none`.++`--id-prefix=`*STRING*++:   Specify a prefix to be added to all identifiers and internal links+    in HTML and DocBook output, and to footnote numbers in Markdown+    and Haddock output. This is useful for preventing duplicate+    identifiers when generating fragments to be included in other pages.++`-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`.++`-c` *URL*, `--css=`*URL*++:   Link to a CSS style sheet. This option can be used repeatedly to+    include multiple files. They will be included in the order specified.++    A stylesheet is required for generating EPUB.  If none is+    provided using this option (or the `css` or `stylesheet`+    metadata fields), pandoc will look for a file `epub.css` in the+    user data directory (see `--data-dir`).  If it is not+    found there, sensible defaults will be used.++`--reference-doc=`*FILE*++:   Use the specified file as a style reference in producing a+    docx or ODT file.++    Docx++    :   For best results, the reference docx should be a modified+        version of a docx file produced using pandoc.  The contents+        of the reference docx are ignored, but its stylesheets and+        document properties (including margins, page size, header,+        and footer) are used in the new docx. If no reference docx+        is specified on the command line, pandoc will look for a+        file `reference.docx` in the user data directory (see+        `--data-dir`). If this is not found either, sensible+        defaults will be used.++        To produce a custom `reference.docx`, first get a copy of+        the default `reference.docx`: `pandoc+        -o custom-reference.docx --print-default-data-file reference.docx`.+        Then open `custom-reference.docx` in Word, modify the+        styles as you wish, and save the file.  For best+        results, do not make changes to this file other than+        modifying the styles used by pandoc:++        Paragraph styles:++        - Normal+        - Body Text+        - First Paragraph+        - Compact+        - Title+        - Subtitle+        - Author+        - Date+        - Abstract+        - Bibliography+        - Heading 1+        - Heading 2+        - Heading 3+        - Heading 4+        - Heading 5+        - Heading 6+        - Heading 7+        - Heading 8+        - Heading 9+        - Block Text+        - Footnote Text+        - Definition Term+        - Definition+        - Caption+        - Table Caption+        - Image Caption+        - Figure+        - Captioned Figure+        - TOC Heading++        Character styles:++        - Default Paragraph Font+        - Body Text Char+        - Verbatim Char+        - Footnote Reference+        - Hyperlink++        Table style:++        - Table++    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.++        To produce a custom `reference.odt`, first get a copy of+        the default `reference.odt`: `pandoc+        -o custom-reference.odt --print-default-data-file reference.odt`.+        Then open `custom-reference.odt` in LibreOffice, modify+        the styles as you wish, and save the file.++    PowerPoint++    :   Templates included with Microsoft PowerPoint 2013 (either with+        `.pptx` or `.potx` extension) are known to work, as are most+        templates derived from these.++        The specific requirement is that the template should begin with+        the following first four layouts:++        1. Title Slide+        2. Title and Content+        3. Section Header+        4. Two Content++        All templates included with a recent version of MS PowerPoint+        will fit these criteria. (You can click on `Layout` under the+        `Home` menu to check.)++        You can also modify the default `reference.pptx`: first run+        `pandoc -o custom-reference.pptx --print-default-data-file+        reference.pptx`, and then modify `custom-reference.pptx`+        in MS PowerPoint (pandoc will use the first four layout+        slides, as mentioned above).++`--epub-cover-image=`*FILE*++:   Use the specified image as the EPUB cover.  It is recommended+    that the image be less than 1000px in width and height. Note that+    in a Markdown source document you can also specify `cover-image`+    in a YAML metadata block (see [EPUB Metadata], below).++`--epub-metadata=`*FILE*++:   Look in the specified XML file for metadata for the EPUB.+    The file should contain a series of [Dublin Core elements].+    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:date>` (from the document date, which should+    be in [ISO 8601 format]), `<dc:language>` (from the `lang`+    variable, or, if is not set, the locale), and `<dc:identifier+    id="BookId">` (a randomly generated UUID). Any of these may be+    overridden by elements in the metadata file.++    Note: if the source document is Markdown, a YAML metadata block+    in the document can be used instead.  See below under+    [EPUB Metadata].++`--epub-embed-font=`*FILE*++:   Embed the specified font in the EPUB. This option can be repeated+    to embed multiple fonts.  Wildcards can also be used: for example,+    `DejaVuSans-*.ttf`.  However, if you use wildcards on the command+    line, be sure to escape them or put the whole filename in single quotes,+    to prevent them from being interpreted by the shell. To use the+    embedded fonts, you will need to add declarations like the following+    to your CSS (see `--css`):++        @font-face {+        font-family: DejaVuSans;+        font-style: normal;+        font-weight: normal;+        src:url("DejaVuSans-Regular.ttf");+        }+        @font-face {+        font-family: DejaVuSans;+        font-style: normal;+        font-weight: bold;+        src:url("DejaVuSans-Bold.ttf");+        }+        @font-face {+        font-family: DejaVuSans;+        font-style: italic;+        font-weight: normal;+        src:url("DejaVuSans-Oblique.ttf");+        }+        @font-face {+        font-family: DejaVuSans;+        font-style: italic;+        font-weight: bold;+        src:url("DejaVuSans-BoldOblique.ttf");+        }+        body { font-family: "DejaVuSans"; }++`--epub-chapter-level=`*NUMBER*++:   Specify the heading level at which to split the EPUB into separate+    "chapter" files. The default is to split into chapters at level-1+    headings. This option only affects the internal composition of the+    EPUB, not the way chapters and sections are displayed to users. Some+    readers may be slow if the chapter files are too large, so for large+    documents with few level-1 headings, one might want to use a chapter+    level of 2 or 3.++`--epub-subdirectory=`*DIRNAME*++:   Specify the subdirectory in the OCF container that is to hold+    the EPUB-specific contents.  The default is `EPUB`.  To put+    the EPUB contents in the top level, use an empty string.++`--ipynb-output=all|none|best`++:   Determines how ipynb output cells are treated. `all` means+    that all of the data formats included in the original are+    preserved.  `none` means that the contents of data cells+    are omitted.  `best` causes pandoc to try to pick the+    richest data block in each output cell that is compatible+    with the output format.  The default is `best`.++`--pdf-engine=`*PROGRAM*++:   Use the specified engine when producing PDF output.+    Valid values are `pdflatex`, `lualatex`, `xelatex`, `latexmk`,+    `tectonic`, `wkhtmltopdf`, `weasyprint`, `prince`, `context`,+    and `pdfroff`. The default is `pdflatex`.  If the engine is+    not in your PATH, the full path of the engine may be specified here.++`--pdf-engine-opt=`*STRING*++:   Use the given string as a command-line argument to the `pdf-engine`.+    For example, to use a persistent directory `foo` for `latexmk`'s+    auxiliary files, use `--pdf-engine-opt=-outdir=foo`.+    Note that no check for duplicate options is done.++[Dublin Core elements]: http://dublincore.org/documents/dces/+[ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime+[Encoding issue with the listings package]:+  https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Encoding_issue++## Citation rendering {.options}++`--bibliography=`*FILE*++:   Set the `bibliography` field in the document's metadata to *FILE*,+    overriding any value set in the metadata, and process citations+    using `pandoc-citeproc`. (This is equivalent to+    `--metadata bibliography=FILE --filter pandoc-citeproc`.)+    If `--natbib` or `--biblatex` is also supplied, `pandoc-citeproc` is not+    used, making this equivalent to `--metadata bibliography=FILE`.+    If you supply this argument multiple times, each *FILE* will be added+    to bibliography.++`--csl=`*FILE*++:   Set the `csl` field in the document's metadata to *FILE*,+    overriding any value set in the metadata.  (This is equivalent to+    `--metadata csl=FILE`.)+    This option is only relevant with `pandoc-citeproc`.++`--citation-abbreviations=`*FILE*++:   Set the `citation-abbreviations` field in the document's metadata to+    *FILE*, overriding any value set in the metadata.  (This is equivalent to+    `--metadata citation-abbreviations=FILE`.)+    This option is only relevant with `pandoc-citeproc`.++`--natbib`++:   Use [`natbib`] for citations in LaTeX output.  This option is not for use+    with the `pandoc-citeproc` filter or with PDF output.  It is intended for+    use in producing a LaTeX file that can be processed with [`bibtex`].++`--biblatex`++:   Use [`biblatex`] for citations in LaTeX output.  This option is not for use+    with the `pandoc-citeproc` filter or with PDF output. It is intended for+    use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].++## Math rendering in HTML {.options}++The default is to render TeX math as far as possible using Unicode characters.+Formulas are put inside a `span` with `class="math"`, so that they may be styled+differently from the surrounding text if needed. However, this gives acceptable+results only for basic math, usually you will want to use `--mathjax` or another+of the following options.++`--mathjax`[`=`*URL*]++:   Use [MathJax] to display embedded TeX math in HTML output.+    TeX math will be put between `\(...\)` (for inline math)+    or `\[...\]` (for display math) and wrapped in `<span>` tags+    with class `math`. Then the MathJax JavaScript will render it.+    The *URL* should point to the `MathJax.js` load script.+    If a *URL* is not provided, a link to the Cloudflare CDN will+    be inserted.++`--mathml`++:   Convert TeX math to [MathML] (in `epub3`, `docbook4`, `docbook5`, `jats`,+    `html4` and `html5`).  This is the default in `odt` output. Note that+    currently only Firefox and Safari (and select e-book readers) natively+    support MathML.++`--webtex`[`=`*URL*]++:   Convert TeX formulas 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. For SVG images you can for+    example use `--webtex https://latex.codecogs.com/svg.latex?`.+    If no URL is specified, the CodeCogs URL generating PNGs+    will be used (`https://latex.codecogs.com/png.latex?`).+    Note:  the `--webtex` option will affect Markdown output+    as well as HTML, which is useful if you're targeting a+    version of Markdown without native math support.++`--katex`[`=`*URL*]++:   Use [KaTeX] to display embedded TeX math in HTML output.+    The *URL* is the base URL for the KaTeX library. That directory+    should contain a `katex.min.js` and a `katex.min.css` file.+    If a *URL* is not provided, a link to the KaTeX CDN will be inserted.++`--gladtex`++:   Enclose TeX math in `<eq>` tags in HTML output.  The resulting HTML+    can then be processed by [GladTeX] to produce images of the typeset+    formulas and an HTML file with links to these images.+    So, the procedure is:++        pandoc -s --gladtex input.md -o myfile.htex+        gladtex -d myfile-images myfile.htex+        # produces myfile.html and images in myfile-images++[MathML]: http://www.w3.org/Math/+[MathJax]: https://www.mathjax.org+[KaTeX]: https://github.com/Khan/KaTeX+[GladTeX]: http://humenda.github.io/GladTeX/++## Options for wrapper scripts {.options}++`--dump-args`++:   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`++:   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++# Exit codes++If pandoc completes successfully, it will return exit code 0.+Nonzero exit codes have the following meanings:++ Code Error+----- ------------------------------------+    3 PandocFailOnWarningError+    4 PandocAppError+    5 PandocTemplateError+    6 PandocOptionError+   21 PandocUnknownReaderError+   22 PandocUnknownWriterError+   23 PandocUnsupportedExtensionError+   31 PandocEpubSubdirectoryError+   43 PandocPDFError+   47 PandocPDFProgramNotFoundError+   61 PandocHttpError+   62 PandocShouldNeverHappenError+   63 PandocSomeError+   64 PandocParseError+   65 PandocParsecError+   66 PandocMakePDFError+   67 PandocSyntaxMapError+   83 PandocFilterError+   91 PandocMacroLoop+   92 PandocUTF8DecodingError+   93 PandocIpynbDecodingError+   97 PandocCouldNotFindDataFileError+   99 PandocResourceNotFound+----- ------------------------------------++# Default files++The `--defaults` option may be used to specify a package+of options.  Here is a sample defaults file demonstrating all of+the fields that may be used:++``` yaml+from: markdown+emoji+# reader: may be used instead of from:+to: html5+# writer: may be used instead of to:++# leave blank for output to stdout:+output-file:+# leave blank for input from stdin, use [] for no input:+input-files:+- preface.md+- content.md+# or you may use input-file: with a single value++template: letter+standalone: true+self-contained: false++# note that structured variables may be specified:+variables:+  documentclass: book+  classoption:+    - twosides+    - draft++# metadata values specified here are parsed as literal+# string text, not markdown:+metadata:+  author:+  - Sam Smith+  - Julie Liu+metadata-files:+- boilerplate.yaml+# or you may use metadata-file: with a single value++# Note that these take files, not their contents:+include-before-body: []+include-after-body: []+include-in-header: []+resource-path: ["."]++# filters will be assumed to be lua filters if they have+# the .lua extension, and json filters otherwise.  But+# the filter type can also be specified explicitly, as shown:+filters:+- pandoc-citeproc+- wordcount.lua+- type: json+  path: foo.lua++file-scope: false++data-dir:++# ERROR, WARNING, or INFO+verbosity: INFO+log-file: log.json++# citeproc, natbib, or biblatex+cite-method: citeproc+# part, chapter, section, or default:+top-level-division: chapter+abbreviations:++pdf-engine: pdflatex+pdf-engine-opts:+- "-shell-escape"+# you may also use pdf-engine-opt: with a single option+# pdf-engine-opt: "-shell-escape"++# auto, preserve, or none+wrap: auto+columns: 78+dpi: 72++extract-media: mediadir++table-of-contents: true+toc-depth: 2+number-sections: false+# a list of offsets at each heading level+number-offset: [0,0,0,0,0,0]+# toc: may also be used instead of table-of-contents:+shift-heading-level-by: 1+section-divs: true+identifier-prefix: foo+title-prefix: ""+strip-empty-paragraphs: true+# lf, crlf, or native+eol: lf+strip-comments: false+indented-code-classes: []+ascii: true+default-image-extension: ".jpg"++# either a style name of a style definition file:+highlight-style: pygments+syntax-definitions:+- c.xml+# or you may use syntax-definition: with a single value+listings: false++reference-doc: myref.docx++# method is plain, webtex, gladtex, mathml, mathjax, katex+# you may specify a url with webtex, mathjax, katex+html-math-method:+  method: mathjax+  url: "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"+# none, references, or javascript+email-obfuscation: javascript++tab-stop: 8+preserve-tabs: true++incremental: false+slide-level: 2++epub-subdirectory: EPUB+epub-metadata: meta.xml+epub-fonts:+- foobar.otf+epub-chapter-level: 1+epub-cover-image: cover.jpg++reference-links: true+# block, section, or document+reference-location: block+atx-headers: false++# accept, reject, or all+track-changes: accept++html-q-tags: false+css:+- site.css++# none, all, or best+ipynb-output: best++# A list of two-element lists+request-headers:+- ["User-Agent", "Mozilla/5.0"]++fail-if-warnings: false+dump-args: false+ignore-args: false+trace: false+```++Fields that are omitted will just have their regular+default values.  So a defaults file can be as simple as+one line:++``` yaml+verbosity: INFO+```++Default files can be placed in the `defaults` subdirectory of+the user data directory and used from any directory.  For+example, one could create a file specifying defaults for writing+letters, save it as `letter.yaml` in the `defaults` subdirectory+of the user data directory, and then invoke these defaults+from any directory using `pandoc --defaults letter`+or `pandoc -dletter`.++When multiple defaults are used, their contents will be combined.++Note that, where command-line arguments may be repeated+(`--metadata-file`, `--css`, `--include-in-header`,+`--include-before-body`, `--include-after-body`, `--variable`,+`--metadata`, `--syntax-definition`), the values specified on+the command line will combine with values specified in the+defaults file, rather than replacing them.++# 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 -D *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/default.*FORMAT*` in the user data+directory (see `--data-dir`, above). *Exceptions:*++- For `odt` output, customize the `default.opendocument`+  template.+- For `pdf` output, customize the `default.latex` template+  (or the `default.context` template, if you use `-t context`,+  or the `default.ms` template, if you use `-t ms`, or the+  `default.html` template, if you use `-t html`).+- `docx` and `pptx` have no template (however, you can use+  `--reference-doc` to customize the output).++Templates contain *variables*, which allow for the inclusion of+arbitrary information at any point in the file. They may be set at the+command line using the `-V/--variable` option. If a variable is not set,+pandoc will look for the key in the document's metadata, which can be set+using either [YAML metadata blocks][Extension: `yaml_metadata_block`]+or with the `-M/--metadata` option.  In addition, some variables+are given default values by pandoc.  See [Variables] below for+a list of variables used in pandoc's default templates.++If you use custom templates, you may need to revise them as pandoc+changes.  We recommend tracking the changes in the default templates,+and modifying your custom templates accordingly. An easy way to do this+is to fork the [pandoc-templates] repository and merge in+changes after each pandoc release.++  [pandoc-templates]: https://github.com/jgm/pandoc-templates++## Template syntax++### Comments++Anything between the sequence `$--` and the end of the+line will be treated as a comment and omitted from the output.++### Delimiters++To mark variables and control structures in the template,+either `$`...`$` or `${`...`}` may be used as delimiters.+The styles may also be mixed in the same template, but the+opening and closing delimiter must match in each case.  The+opening delimiter may be followed by one or more spaces+or tabs, which will be ignored. The closing delimiter may+be followed by one or more spaces or tabs, which will be+ignored.++To include a literal `$` in the document, use `$$`.++### Interpolated variables++A slot for an interpolated variable is a variable name surrounded+by matched delimiters.  Variable names must begin with a letter+and can contain letters, numbers, `_`, `-`, and `.`.  The+keywords `it`, `if`, `else`, `endif`, `for`, `sep`, and `endfor` may+not be used as variable names. Examples:++```+$foo$+$foo.bar.baz$+$foo_bar.baz-bim$+$ foo $+${foo}+${foo.bar.baz}+${foo_bar.baz-bim}+${ foo }+```++Variable names with periods are used to get at structured+variable values.  So, for example, `employee.salary` will return the+value of the `salary` field of the object that is the value of+the `employee` field.++- If the value of the variable is simple value, it will be+  rendered verbatim.  (Note that no escaping is done;+  the assumption is that the calling program will escape+  the strings appropriately for the output format.)+- If the value is a list, the values will be concatenated.+- If the value is a map, the string `true` will be rendered.+- Every other value will be rendered as the empty string.++### Conditionals++A conditional begins with `if(variable)` (enclosed in+matched delimiters) and ends with `endif` (enclosed in matched+delimiters).  It may optionally contain an `else` (enclosed in+matched delimiters).  The `if` section is used if+`variable` has a non-empty value, otherwise the `else`+section is used (if present).  Examples:++```+$if(foo)$bar$endif$++$if(foo)$+  $foo$+$endif$++$if(foo)$+part one+$else$+part two+$endif$++${if(foo)}bar${endif}++${if(foo)}+  ${foo}+${endif}++${if(foo)}+${ foo.bar }+${else}+no foo!+${endif}+```++The keyword `elseif` may be used to simplify complex nested+conditionals:++```+$if(foo)$+XXX+$elseif(bar)$+YYY+$else$+ZZZ+$endif$+```++### For loops++A for loop begins with `for(variable)` (enclosed in+matched delimiters) and ends with `endfor` (enclosed in matched+delimiters.++- If `variable` is an array, the material inside the loop will+  be evaluated repeatedly, with `variable` being set to each+  value of the array in turn, and concatenated.+- If the value of the associated variable is not an array or+  a map, a single iteration will be performed on its value.++Examples:++```+$for(foo)$$foo$$sep$, $endfor$++$for(foo)$+  - $foo.last$, $foo.first$+$endfor$++${ for(foo.bar) }+  - ${ foo.bar.last }, ${ foo.bar.first }+${ endfor }+```++You may optionally specify a separator between consecutive+values using `sep` (enclosed in matched delimiters).  The+material between `sep` and the `endfor` is the separator.++```+${ for(foo) }${ foo }${ sep }, ${ endfor }+```++Instead of using `variable` inside the loop, the special+anaphoric keyword `it` may be used.++```+${ for(foo.bar) }+  - ${ it.last }, ${ it.first }+${ endfor }+```++### Partials++Partials (subtemplates stored in different files) may be+included using the syntax++```+${ boilerplate() }+```++Partials will be sought in the directory containing+the main template, and will be assumed to have the+same extension as the main template if they lack+an explicit extension.  (If the partials are not+found here, they will also be sought in the `templates`+subdirectory of the user data directory.)++Partials may optionally be applied to variables using+a colon:++```+${ date:fancy() }++${ articles:bibentry() }+```++If `articles` is an array, this will iterate over its+values, applying the partial `bibentry()` to each one.  So the+second example above is equivalent to++```+${ for(articles) }+${ it:bibentry() }+${ endfor }+```++Note that the anaphoric keyword `it` must be used when+iterating over partials.  In the above examples,+the `bibentry` partial should contain `it.title`+(and so on) instead of `articles.title`.++Final newlines are omitted from included partials.++Partials may include other partials.++A separator between values of an array may be specified+in square brackets, immediately after the variable name+or partial:++```+${months[, ]}$++${articles:bibentry()[; ]$+```++The separator in this case is literal and (unlike with `sep`+in an explicit `for` loop) cannot contain interpolated+variables or other template directives.++### Nesting++To ensure that content is "nested," that is, subsequent lines+indented, use the `^` directive:++```+$item.number$  $^$$item.description$ ($item.price$)+```++In this example, if `item.description` has multiple lines,+they will all be indented to line up with the first line:++```+00123  A fine bottle of 18-year old+       Oban whiskey. ($148)+```++To nest multiple lines to the same level, align them+with the `^` directive in the template. For example:++```+$item.number$  $^$$item.description$ ($item.price$)+               (Available til $item.sellby$.)+```++will produce++```+00123  A fine bottle of 18-year old+       Oban whiskey. ($148)+       (Available til March 30, 2020.)+```++If a variable occurs by itself on a line, preceded by whitespace+and not followed by further text or directives on the same line,+and the variable's value contains multiple lines, it will be+nested automatically.++### Breakable spaces++Normally, spaces in the template itself (as opposed to values of+the interpolated variables) are not breakable, but they can be+made breakable in part of the template by using the `~` keyword+(ended with another `~`).++```+$~$This long line may break if the document is rendered+with a short line length.$~$+```++### Filters++A filter transforms the value of a variable or partial. Filters are+specified using a slash (`/`) between the variable name (or partial)+and the filter name. Example:++```+$for(name)$+$name/uppercase$+$endfor$++$for(metadata/pairs)$+- $it.key$: $it.value$+$endfor$++$employee:name()/uppercase$+```++Filters may be chained:++```+$for(employees/pairs)$+$it.key/alpha/uppercase$. $it.name$+$endfor$+```++Some filters take parameters:++```+|----------------------|------------|+$for(employee)$+$it.name.first/uppercase/left 20 "| "$$it.name.salary/right 10 " | " " |"$+$endfor$+|----------------------|------------|+```++Currently the following filters are predefined:++- `pairs`:  Converts a map or array to an array of maps,+  each with `key` and `value` fields.  If the original+  value was an array, the `key` will be the array index,+  starting with 1.++- `uppercase`:  Converts a textual value to uppercase,+  and has no effect on other values.++- `lowercase`:  Converts a textual value to lowercase,+  and has no effect on other values.++- `length`:  Returns the length of the value:  number+  of characters for a textual value, number of elements+  for a map or array.++- `reverse`:  Reverses a textual value or array,+  and has no effect on other values.++- `chomp`:  Removes trailing newlines (and breakable space)+  from a textual value, and has no effect on other values.++- `alpha`:  Converts a textual value that can be+  read as an integer into a lowercase alphabetic+  character `a..z` (mod 26), and has no effect on+  other values.  This can be used to get lettered+  enumeration from array indices.  To get uppercase+  letters, chain with `uppercase`.++- `roman`:  Converts a textual value that can be+  read as an integer into a lowercase roman numerial,+  and has no effect on other values.  This can be used+  to get lettered enumeration from array indices.  To+  get uppercase roman, chain with `uppercase`.++- `left n "leftborder" "rightborder"`:  Renders a textual value+  in a block of width `n`, aligned to the left, with an optional+  left and right border.  Has no effect on other values. This+  can be used to align material in tables.  Widths are positive+  integers indicating the number of characters.  Borders+  are strings inside double quotes; literal `"` and `\` characters+  must be backslash-escaped.++- `right n "leftborder" "rightborder"`:  Renders a textual value+  in a block of width `n`, aligned to the right, and has no+  effect on other values.++- `center n "leftborder" "rightborder"`:  Renders a textual+  value in a block of width `n`, aligned to the center, and has+  no effect on other values.+++## Variables++### Metadata variables++`title`, `author`, `date`+:   allow identification of basic aspects of the document.  Included+    in PDF metadata through LaTeX and ConTeXt.  These can be set+    through a [pandoc title block][Extension: `pandoc_title_block`],+    which allows for multiple authors, or through a+    [YAML metadata block][Extension: `yaml_metadata_block`]:++        ---+        author:+        - Aristotle+        - Peter Abelard+        ...++    Note that if you just want to set PDF or HTML metadata, without+    including a title block in the document itself, you can+    set the `title-meta`, `author-meta`, and `date-meta`+    variables.  (By default these are set automatically, based+    on `title`, `author`, and `date`.)++`subtitle`+:   document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx+    documents++`abstract`+:   document summary, included in LaTeX, ConTeXt, AsciiDoc, and docx+    documents++`keywords`+:   list of keywords to be included in HTML, PDF, ODT, pptx, docx+    and AsciiDoc metadata; repeat as for `author`, above++`subject`+:   document subject, included in ODT, PDF, docx and pptx metadata++`description`+:   document description, included in ODT, docx and pptx metadata. Some+    applications show this as `Comments` metadata.++`category`+:   document category, included in docx and pptx metadata++Additionally,+any root-level string metadata, not included in ODT, docx+or pptx metadata is added as a *custom property*.+The following [YAML] metadata block for instance:++    ---+    title:  'This is the title'+    subtitle: "This is the subtitle"+    author:+    - Author One+    - Author Two+    description: |+        This is a long+        description.++        It consists of two paragraphs+    ...++will include `title`, `author` and `description` as standard document+properties and `subtitle` as a custom property when converting to docx,+ODT or pptx.++### Language variables++`lang`+:   identifies the main language of the document using IETF language+    tags (following the [BCP 47] standard), such as `en` or `en-GB`.+    The [Language subtag lookup] tool can look up or verify these tags.+    This affects most formats, and controls hyphenation in PDF output+    when using LaTeX (through [`babel`] and [`polyglossia`]) or ConTeXt.++    Use native pandoc [Divs and Spans] with the `lang` attribute to+    switch the language:++        ---+        lang: en-GB+        ...++        Text in the main document language (British English).++        ::: {lang=fr-CA}+        > Cette citation est écrite en français canadien.+        :::++        More text in English. ['Zitat auf Deutsch.']{lang=de}++`dir`+:   the base script direction, either `rtl` (right-to-left)+    or `ltr` (left-to-right).++    For bidirectional documents, native pandoc `span`s and `div`s+    with the `dir` attribute (value `rtl` or `ltr`) can be used to+    override the base direction in some output formats.+    This may not always be necessary if the final renderer+    (e.g. the browser, when generating HTML) supports the+    [Unicode Bidirectional Algorithm].++    When using LaTeX for bidirectional documents, only the `xelatex` engine+    is fully supported (use `--pdf-engine=xelatex`).++[BCP 47]: https://tools.ietf.org/html/bcp47+[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics+[Language subtag lookup]: https://r12a.github.io/app-subtags/++### Variables for HTML math++`classoption`+:   when using [KaTeX](#option--katex), you can render display math equations+    flush left using [YAML metadata](#layout) or with `-M classoption=fleqn`.++### Variables for HTML slides++These affect HTML output when [producing slide shows with pandoc].++All [reveal.js configuration options] are available as variables.+To turn off boolean flags that default to true in reveal.js, use `0`.++`revealjs-url`+:   base URL for reveal.js documents (defaults to `reveal.js`)++`s5-url`+:   base URL for S5 documents (defaults to `s5/default`)++`slidy-url`+:   base URL for Slidy documents (defaults to+    `https://www.w3.org/Talks/Tools/Slidy2`)++`slideous-url`+:   base URL for Slideous documents (defaults to `slideous`)++[reveal.js configuration options]: https://github.com/hakimel/reveal.js#configuration++### Variables for Beamer slides++These variables change the appearance of PDF slides using [`beamer`].++`aspectratio`+:   slide aspect ratio (`43` for 4:3 [default], `169` for 16:9,+    `1610` for 16:10, `149` for 14:9, `141` for 1.41:1, `54` for 5:4,+    `32` for 3:2)++`beamerarticle`+:   produce an article from Beamer slides++`beameroption`+:   add extra beamer option with `\setbeameroption{}`++`institute`+:   author affiliations: can be a list when there are multiple authors++`logo`+:   logo image for slides++`navigation`+:   controls navigation symbols (default is `empty` for no navigation+    symbols; other valid values are `frame`, `vertical`, and `horizontal`)++`section-titles`+:   enables "title pages" for new sections (default is true)++`theme`, `colortheme`, `fonttheme`, `innertheme`, `outertheme`+:   beamer themes++`themeoptions`+:   options for LaTeX beamer themes (a list).++`titlegraphic`+:   image for title slide++### Variables for PowerPoint++These variables control the visual aspects of a slide show that+are not easily controlled via templates.++`monofont`+:   font to use for code.++### Variables for LaTeX++Pandoc uses these variables when [creating a PDF] with a LaTeX engine.++#### Layout++`block-headings`+:   make `\paragraph` and `\subparagraph` (fourth- and+    fifth-level headings, or fifth- and sixth-level with book+    classes) free-standing rather than run-in; requires further+    formatting to distinguish from `\subsubsection` (third- or+    fourth-level headings). Instead of using this option,+    [KOMA-Script] can adjust headings more extensively:++        ---+        documentclass: scrartcl+        header-includes: |+          \RedeclareSectionCommand[+            beforeskip=-10pt plus -2pt minus -1pt,+            afterskip=1sp plus -1sp minus 1sp,+            font=\normalfont\itshape]{paragraph}+          \RedeclareSectionCommand[+            beforeskip=-10pt plus -2pt minus -1pt,+            afterskip=1sp plus -1sp minus 1sp,+            font=\normalfont\scshape,+            indent=0pt]{subparagraph}+        ...++`classoption`+:   option for document class, e.g. `oneside`; repeat for multiple options:++        ---+        classoption:+        - twocolumn+        - landscape+        ...++`documentclass`+:   document class: usually one of the standard classes, [`article`], [`book`],+    and [`report`]; the [KOMA-Script] equivalents, `scrartcl`, `scrbook`,+    and `scrreprt`, which default to smaller margins; or [`memoir`]++`geometry`+:   option for [`geometry`] package, e.g. `margin=1in`;+    repeat for multiple options:++        ---+        geometry:+        - top=30mm+        - left=20mm+        - heightrounded+        ...++`hyperrefoptions`+:   option for [`hyperref`] package, e.g. `linktoc=all`;+    repeat for multiple options:++        ---+        hyperrefoptions:+        - linktoc=all+        - pdfwindowui+        - pdfpagemode=FullScreen+        ...++`indent`+:   uses document class settings for indentation (the default LaTeX template+    otherwise removes indentation and adds space between paragraphs)++`linestretch`+:   adjusts line spacing using the [`setspace`]+    package, e.g. `1.25`, `1.5`++`margin-left`, `margin-right`, `margin-top`, `margin-bottom`+:   sets margins if `geometry` is not used (otherwise `geometry`+    overrides these)++`pagestyle`+:   control `\pagestyle{}`: the default article class+    supports `plain` (default), `empty` (no running heads or page numbers),+    and `headings` (section titles in running heads)++`papersize`+:   paper size, e.g. `letter`, `a4`++`secnumdepth`+:   numbering depth for sections (with `--number-sections` option+    or `numbersections` variable)++#### Fonts++`fontenc`+:   allows font encoding to be specified through `fontenc` package (with `pdflatex`);+    default is `T1` (see [LaTeX font encodings guide])++`fontfamily`+:   font package for use with `pdflatex`:+    [TeX Live] includes many options, documented in the [LaTeX Font Catalogue].+    The default is [Latin Modern][`lm`].++`fontfamilyoptions`+:   options for package used as `fontfamily`; repeat for multiple options.+    For example, to use the Libertine font with proportional lowercase+    (old-style) figures through the [`libertinus`] package:++        ---+        fontfamily: libertinus+        fontfamilyoptions:+        - osf+        - p+        ...++`fontsize`+:   font size for body text. The standard classes allow 10pt, 11pt, and+    12pt.  To use another size, set `documentclass` to one of+    the [KOMA-Script] classes, such as `scrartcl` or `scrbook`.++`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`+:   font families for use with `xelatex` or+    `lualatex`: take the name of any system font, using the+    [`fontspec`] package.  `CJKmainfont` uses the [`xecjk`] package.++`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`+:   options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`,+    `CJKmainfont` in `xelatex` and `lualatex`.  Allow for any+    choices available through [`fontspec`]; repeat for multiple+    options. For example, to use the [TeX Gyre] version of+    Palatino with lowercase figures:++        ---+        mainfont: TeX Gyre Pagella+        mainfontoptions:+        - Numbers=Lowercase+        - Numbers=Proportional+        ...++`microtypeoptions`+:    options to pass to the microtype package++#### Links++`colorlinks`+:   add color to link text; automatically enabled if any of+    `linkcolor`, `filecolor`, `citecolor`, `urlcolor`, or `toccolor` are set++`linkcolor`, `filecolor`, `citecolor`, `urlcolor`, `toccolor`+:   color for internal links, external links, citation links, linked+    URLs, and links in table of contents, respectively: uses options+    allowed by [`xcolor`], including the `dvipsnames`, `svgnames`, and+    `x11names` lists++`links-as-notes`+:   causes links to be printed as footnotes++#### Front matter++`lof`, `lot`+:   include list of figures, list of tables++`thanks`+:   contents of acknowledgments footnote after document title++`toc`+:   include table of contents (can also be set using `--toc/--table-of-contents`)++`toc-depth`+:   level of section to include in table of contents++#### BibLaTeX Bibliographies++These variables function when using BibLaTeX for [citation rendering].++`biblatexoptions`+:   list of options for biblatex++`biblio-style`+:   bibliography style, when used with `--natbib` and `--biblatex`.++`biblio-title`+:   bibliography title, when used with `--natbib` and `--biblatex`.++`bibliography`+:   bibliography to use for resolving references++`natbiboptions`+:   list of options for natbib++[KOMA-Script]: https://ctan.org/pkg/koma-script+[LaTeX Font Catalogue]: http://www.tug.dk/FontCatalogue/+[LaTeX font encodings guide]: https://ctan.org/pkg/encguide+[TeX Gyre]: http://www.gust.org.pl/projects/e-foundry/tex-gyre+[`article`]: https://ctan.org/pkg/article+[`book`]: https://ctan.org/pkg/book+[`libertinus`]: https://ctan.org/pkg/libertinus+[`memoir`]: https://ctan.org/pkg/memoir+[`report`]: https://ctan.org/pkg/report++### Variables for ConTeXt++Pandoc uses these variables when [creating a PDF] with ConTeXt.++`fontsize`+:   font size for body text (e.g. `10pt`, `12pt`)++`headertext`, `footertext`+:   text to be placed in running header or footer (see [ConTeXt Headers and Footers]);+    repeat up to four times for different placement++`indenting`+:   controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);+    repeat for multiple options++`interlinespace`+:   adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);+    repeat for multiple options++`layout`+:   options for page margins and text arrangement (see [ConTeXt Layout]);+    repeat for multiple options++`linkcolor`, `contrastcolor`+:   color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])++`linkstyle`+:   typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`++`lof`, `lot`+:   include list of figures, list of tables++`mainfont`, `sansfont`, `monofont`, `mathfont`+:   font families: take the name of any system font (see [ConTeXt Font Switching])++`margin-left`, `margin-right`, `margin-top`, `margin-bottom`+:   sets margins, if `layout` is not used (otherwise `layout`+    overrides these)++`pagenumbering`+:   page number style and location (using [`setuppagenumbering`]);+    repeat for multiple options++`papersize`+:   paper size, e.g. `letter`, `A4`, `landscape` (see [ConTeXt Paper Setup]);+    repeat for multiple options++`pdfa`+:   adds to the preamble the setup necessary to generate PDF/A of the type+    specified, e.g. `1a:2005`, `2a`. If no type is specified (i.e. the value+    is set to True, by e.g. `--metadata=pdfa` or `pdfa: true` in a YAML metadata+    block), `1b:2005` will be used as default, for reasons of backwards+    compatibility. Using `--variable=pdfa` without specified value is not supported.+    To successfully generate PDF/A the required ICC color profiles have to+    be available and the content and all included files (such as images)+    have to be standard conforming.  The ICC profiles and output intent+    may be specified using the variables `pdfaiccprofile` and `pdfaintent`.+    See also [ConTeXt PDFA] for more details.++`pdfaiccprofile`+:   when used in conjunction with `pdfa`, specifies the ICC profile to use+    in the PDF, e.g. `default.cmyk`. If left unspecified, `sRGB.icc` is+    used as default. May be repeated to include multiple profiles. Note that+    the profiles have to be available on the system. They can be obtained+    from [ConTeXt ICC Profiles].++`pdfaintent`+:   when used in conjunction with `pdfa`, specifies the output intent for+    the colors, e.g. `ISO coated v2 300\letterpercent\space (ECI)`+    If left unspecified, `sRGB IEC61966-2.1` is used as default.++`toc`+:   include table of contents (can also be set using `--toc/--table-of-contents`)++`whitespace`+:   spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])++`includesource`+:   include all source documents as file attachments in the PDF file++[ConTeXt Paper Setup]: https://wiki.contextgarden.net/PaperSetup+[ConTeXt Layout]: https://wiki.contextgarden.net/Layout+[ConTeXt Font Switching]: https://wiki.contextgarden.net/Font_Switching+[ConTeXt Color]: https://wiki.contextgarden.net/Color+[ConTeXt Headers and Footers]: https://wiki.contextgarden.net/Headers_and_Footers+[ConTeXt Indentation]: https://wiki.contextgarden.net/Indentation+[ConTeXt ICC Profiles]: https://wiki.contextgarden.net/PDFX#ICC_profiles+[ConTeXt PDFA]: https://wiki.contextgarden.net/PDF/A+[`setupwhitespace`]: https://wiki.contextgarden.net/Command/setupwhitespace+[`setupinterlinespace`]: https://wiki.contextgarden.net/Command/setupinterlinespace+[`setuppagenumbering`]: https://wiki.contextgarden.net/Command/setuppagenumbering++### Variables for `wkhtmltopdf`++Pandoc uses these variables when [creating a PDF] with [`wkhtmltopdf`].+The `--css` option also affects the output.++`footer-html`, `header-html`+:   add information to the header and footer++`margin-left`, `margin-right`, `margin-top`, `margin-bottom`+:   set the page margins++`papersize`+:   sets the PDF paper size++### Variables for man pages++`adjusting`+:   adjusts text to left (`l`), right (`r`), center (`c`),+    or both (`b`) margins++`footer`+:   footer in man pages++`header`+:   header in man pages++`hyphenate`+:   if `true` (the default), hyphenation will be used++`section`+:   section number in man pages++### Variables for ms++`fontfamily`+:    font family (e.g. `T` or `P`)++`indent`+:    paragraph indent (e.g. `2m`)++`lineheight`+:    line height (e.g. `12p`)++`pointsize`+:    point size (e.g. `10p`)++### Variables set automatically++Pandoc sets these variables automatically in response to [options] or+document contents; users can also modify them. These vary depending+on the output format, and include the following:++`body`+:   body of document++`date-meta`+:   the `date` variable converted to ISO 8601 YYYY-MM-DD,+    included in all HTML based formats (dzslides, epub,+    html, html4, html5, revealjs, s5, slideous, slidy).+    The recognized formats for `date` are: `mm/dd/yyyy`,+    `mm/dd/yy`, `yyyy-mm-dd` (ISO 8601), `dd MM yyyy`+    (e.g. either `02 Apr 2018` or `02 April 2018`),+    `MM dd, yyyy` (e.g. `Apr. 02, 2018` or `April 02, 2018),+    `yyyy[mm[dd]]]` (e.g. `20180402, `201804` or `2018`).++`header-includes`+:   contents specified by `-H/--include-in-header` (may have multiple+    values)++`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)++`meta-json`+:   JSON representation of all of the document's metadata. Field+    values are transformed to the selected output format.++`numbersections`+:   non-null value if `-N/--number-sections` was specified++`sourcefile`, `outputfile`+:   source and destination filenames, as given on the command line.+    `sourcefile` can also be a list if input comes from multiple files,+    or empty if input is from stdin. You can use the following snippet in+    your template to distinguish them:++        $if(sourcefile)$+        $for(sourcefile)$+        $sourcefile$+        $endfor$+        $else$+        (stdin)+        $endif$++    Similarly, `outputfile` can be `-` if output goes to the terminal.++    If you need absolute paths, use e.g. `$curdir$/$sourcefile$`.++`curdir`+:   working directory from which pandoc is run.++`toc`+:   non-null value if `--toc/--table-of-contents` was specified++`toc-title`+:   title of table of contents (works only with EPUB,+    opendocument, odt, docx, pptx, beamer, LaTeX)++[pandoc-templates]: https://github.com/jgm/pandoc-templates++# Extensions++The behavior of some of the readers and writers can be adjusted by+enabling or disabling various extensions.++An extension can be enabled by adding `+EXTENSION`+to the format name and disabled by adding `-EXTENSION`. For example,+`--from markdown_strict+footnotes` is strict Markdown with footnotes+enabled, while `--from markdown-footnotes-pipe_tables` is pandoc's+Markdown without footnotes or pipe tables.++The markdown reader and writer make by far the most use of extensions.+Extensions only used by them are therefore covered in the+section [Pandoc's Markdown] below (See [Markdown variants] for+`commonmark` and `gfm`.) In the following, extensions that also work+for other formats are covered.++Note that markdown extensions added to the `ipynb` format+affect Markdown cells in Jupyter notebooks (as do command-line+options like `--atx-headers`).++## Typography++#### Extension: `smart` ####++Interpret straight quotes as curly quotes, `---` as em-dashes,+`--` as en-dashes, and `...` as ellipses. Nonbreaking spaces are+inserted after certain abbreviations, such as "Mr."++This extension can be enabled/disabled for the following formats:++input formats+:  `markdown`, `commonmark`, `latex`, `mediawiki`, `org`, `rst`, `twiki`++output formats+:  `markdown`, `latex`, `context`, `rst`++enabled by default in+:  `markdown`, `latex`, `context` (both input and output)++Note: If you are *writing* Markdown, then the `smart` extension+has the reverse effect: what would have been curly quotes comes+out straight.++In LaTeX, `smart` means to use the standard TeX ligatures+for quotation marks (` `` ` and ` '' ` for double quotes,+`` ` `` and `` ' `` for single quotes) and dashes (`--` for+en-dash and `---` for em-dash).  If `smart` is disabled,+then in reading LaTeX pandoc will parse these characters+literally.  In writing LaTeX, enabling `smart` tells pandoc+to use the ligatures when possible; if `smart` is disabled+pandoc will use unicode quotation mark and dash characters.++## Headings and sections++#### Extension: `auto_identifiers` ####++A heading without an explicitly specified identifier will be+automatically assigned a unique identifier based on the heading text.++This extension can be enabled/disabled for the following formats:++input formats+:  `markdown`, `latex`, `rst`, `mediawiki`, `textile`++output formats+:  `markdown`, `muse`++enabled by default in+:  `markdown`, `muse`++The default algorithm used to derive the identifier from the+heading text is:++  - Remove all formatting, links, etc.+  - Remove all footnotes.+  - Remove all non-alphanumeric characters,+    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,++  Heading                           Identifier+  -------------------------------   ----------------------------+  `Heading identifiers in HTML`     `heading-identifiers-in-html`+  `Maître d'hôtel`                  `maître-dhôtel`+  `*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 heading text. The exception is when several headings 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.++(However, a different algorithm is used if+`gfm_auto_identifiers` is enabled; see below.)++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+    [heading identifiers](#heading-identifiers-in-html-latex-and-context).++Note, however, that this method of providing links to sections works+only in HTML, LaTeX, and ConTeXt formats.++If the `--section-divs` option is specified, then each section will+be wrapped in a `section` (or a `div`, if `html4` was specified),+and the identifier will be attached to the enclosing `<section>`+(or `<div>`) tag rather than the heading itself. This allows entire+sections to be manipulated using JavaScript or treated differently in+CSS.++#### Extension: `ascii_identifiers` ####++Causes the identifiers produced by `auto_identifiers` to be pure ASCII.+Accents are stripped off of accented Latin letters, and non-Latin+letters are omitted.++#### Extension: `gfm_auto_identifiers` ####++Changes the algorithm used by `auto_identifiers` to conform to+GitHub's method.  Spaces are converted to dashes (`-`),+uppercase characters to lowercase characters, and punctuation+characters other than `-` and `_` are removed.+Emojis are replaced by their names.++## Math Input++The extensions [`tex_math_dollars`](#extension-tex_math_dollars),+[`tex_math_single_backslash`](#extension-tex_math_single_backslash), and+[`tex_math_double_backslash`](#extension-tex_math_double_backslash)+are described in the section about Pandoc's Markdown.++However, they can also be used with HTML input. This is handy for+reading web pages formatted using MathJax, for example.++## Raw HTML/TeX++The following extensions (especially how they affect Markdown+input/output) are also described in more detail in their respective+sections of [Pandoc's Markdown].++#### Extension: `raw_html` {#raw_html}++When converting from HTML, parse elements to raw HTML which are not+representable in pandoc's AST.+By default, this is disabled for HTML input.++#### Extension: `raw_tex` {#raw_tex}++Allows raw LaTeX, TeX, and ConTeXt to be included in a document.++This extension can be enabled/disabled for the following formats+(in addition to `markdown`):++input formats+:  `latex`, `org`, `textile`, `html` (environments, `\ref`, and+   `\eqref` only), `ipynb`++output formats+:  `textile`, `commonmark`++Note: as applied to `ipynb`, `raw_html` and `raw_tex` affect not+only raw TeX in markdown cells, but data with mime type+`text/html` in output cells.  Since the `ipynb` reader attempts+to preserve the richest possible outputs when several options+are given, you will get best results if you disable `raw_html`+and `raw_tex` when converting to formats like `docx` which don't+allow raw `html` or `tex`.++#### Extension: `native_divs` {#native_divs}++This extension is enabled by default for HTML input. This means that+`div`s are parsed to pandoc native elements. (Alternatively, you+can parse them to raw HTML using `-f html-native_divs+raw_html`.)++When converting HTML to Markdown, for example, you may want to drop all+`div`s and `span`s:++    pandoc -f html-native_divs-native_spans -t markdown++#### Extension: `native_spans` {#native_spans}++Analogous to `native_divs` above.+++## Literate Haskell support++#### Extension: `literate_haskell` ####++Treat the document as literate Haskell source.++This extension can be enabled/disabled for the following formats:++input formats+:  `markdown`, `rst`, `latex`++output formats+:  `markdown`, `rst`, `latex`, `html`++If you append `+lhs` (or `+literate_haskell`) to one of the formats+above, pandoc will treat the document as literate Haskell source.+This means that++  - In Markdown input, "bird track" sections will be parsed as Haskell+    code rather than block quotations.  Text between `\begin{code}`+    and `\end{code}` will also be treated as Haskell code.  For+    ATX-style headings the character '=' will be used instead of '#'.++  - In Markdown output, code blocks with classes `haskell` and `literate`+    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, headings will be rendered setext-style (with underlines)+    rather than ATX-style (with '#' characters). (This is because ghc+    treats '#' characters in column 1 as introducing line numbers.)++  - In restructured text input, "bird track" sections will be parsed+    as Haskell code.++  - In restructured text output, code blocks with class `haskell` will+    be rendered using bird tracks.++  - In LaTeX input, text in `code` environments will be parsed as+    Haskell code.++  - In LaTeX output, code blocks with class `haskell` will be rendered+    inside `code` environments.++  - In HTML output, code blocks with class `haskell` will be rendered+    with class `literatehaskell` and bird tracks.++Examples:++    pandoc -f markdown+lhs -t html++reads literate Haskell source formatted with Markdown conventions and writes+ordinary HTML (without bird tracks).++    pandoc -f markdown+lhs -t html+lhs++writes HTML with the Haskell code in bird tracks, so it can be copied+and pasted as literate Haskell source.++Note that GHC expects the bird tracks in the first column, so indented+literate code blocks (e.g. inside an itemized environment) will not be+picked up by the Haskell compiler.++## Other extensions++#### Extension: `empty_paragraphs` ####++Allows empty paragraphs.  By default empty paragraphs are+omitted.++This extension can be enabled/disabled for the following formats:++input formats+:  `docx`, `html`++output formats+:  `docx`, `odt`, `opendocument`, `html`++#### Extension: `native_numbering` ####++Enables native numbering of figures and tables. Enumeration+starts at 1.++This extension can be enabled/disabled for the following formats:++output formats+:  `odt`, `opendocument`++#### Extension: `styles` #### {#ext-styles}++When converting from docx, read all docx styles as divs (for+paragraph styles) and spans (for character styles) regardless+of whether pandoc understands the meaning of these styles.+This can be used with [docx custom styles](#custom-styles).+Disabled by default.++input formats+:  `docx`++#### Extension: `amuse` ####++In the `muse` input format, this enables Text::Amuse+extensions to Emacs Muse markup.++#### Extension: `citations` {#org-citations}++Some aspects of [Pandoc's Markdown citation syntax](#citations) are also accepted+in `org` input.++#### Extension: `ntb` ####++In the `context` output format this enables the use of [Natural Tables+(TABLE)](http://wiki.contextgarden.net/TABLE) instead of the default+[Extreme Tables (xtables)](http://wiki.contextgarden.net/xtables).+Natural tables allow more fine-grained global customization but come+at a performance penalty compared to extreme tables.+++# Pandoc's Markdown++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 using the `markdown_strict` format instead+of `markdown`. Extensions can be enabled or disabled to specify the+behavior more granularly. They are described in the following. See also+[Extensions] above, for extensions that work also on other formats.++## Philosophy++Markdown is designed to be easy to write, and, even more importantly,+easy to read:++> 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)++This principle has guided pandoc's decisions in finding syntax for+tables, footnotes, and other extensions.++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.++## Paragraphs++A paragraph is one or more lines of text followed by one or more blank lines.+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.++#### Extension: `escaped_line_breaks` ####++A backslash followed by a newline is also a hard line break.+Note:  in multiline and grid table cells, this is the only way+to create a hard line break, since trailing spaces in the cells+are ignored.++## Headings++There are two kinds of headings: Setext and ATX.++### Setext-style headings ###++A setext-style heading is a line of text "underlined" with a row of `=` signs+(for a level-one heading) or `-` signs (for a level-two heading):++    A level-one heading+    ===================++    A level-two heading+    -------------------++The heading text can contain inline formatting, such as emphasis (see+[Inline formatting], below).+++### ATX-style headings ###++An ATX-style heading 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 heading level:++    ## A level-two heading++    ### A level-three heading ###++As with setext-style headings, the heading text can contain formatting:++    # A level-one heading with a [link](/url) and *emphasis*++#### Extension: `blank_before_header` ####++Standard Markdown syntax does not require a blank line before a heading.+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:++    I like several of their flavors of ice cream:+    #22, for example, and #5.++#### Extension: `space_in_atx_header` ####++Many Markdown implementations do not require a space between the+opening `#`s of an ATX heading and the heading text, so that+`#5 bolt` and `#hashtag` count as headings.  With this extension,+pandoc does require the space.++### Heading identifiers ###++See also the [`auto_identifiers` extension](#extension-auto_identifiers) above.++#### Extension: `header_attributes` ####++Headings can be assigned attributes using this syntax at the end+of the line containing the heading text:++    {#identifier .class .class key=value key=value}++Thus, for example, the following headings will all be assigned the identifier+`foo`:++    # My heading {#foo}++    ## My heading ##    {#foo}++    My other heading   {#foo}+    ---------------++(This syntax is compatible with [PHP Markdown Extra].)++Note that although this syntax allows assignment of classes and key/value+attributes, writers generally don't use all of this information.  Identifiers,+classes, and key/value attributes are used in HTML and HTML-based formats such+as EPUB and slidy.  Identifiers are used for labels and link anchors in the+LaTeX, ConTeXt, Textile, Jira markup, and AsciiDoc writers.++Headings with the class `unnumbered` will not be numbered, even if+`--number-sections` is specified.  A single hyphen (`-`) in an attribute+context is equivalent to `.unnumbered`, and preferable in non-English+documents.  So,++    # My heading {-}++is just the same as++    # My heading {.unnumbered}++If the `unlisted` class is present in addition to `unnumbered`,+the heading will not be included in a table of contents.+(Currently this feature is only implemented for certain+formats: those based on LaTeX and HTML, PowerPoint, and RTF.)++#### Extension: `implicit_header_references` ####++Pandoc behaves as if reference links have been defined for each heading.+So, to link to a heading++    # Heading identifiers in HTML++you can simply write++    [Heading identifiers in HTML]++or++    [Heading identifiers in HTML][]++or++    [the section on heading identifiers][heading identifiers in+    HTML]++instead of giving the identifier explicitly:++    [Heading identifiers in HTML](#heading-identifiers-in-html)++If there are multiple headings with identical text, the corresponding+reference will link to the first one only, and you will need to use explicit+links to link to the others, as described above.++Like regular reference links, these references are case-insensitive.++Explicit link reference definitions always take priority over+implicit heading references.  So, in the following example, the+link will point to `bar`, not to `#foo`:++    # Foo++    [foo]: bar++    See [foo]++## 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 headings), with each line preceded by a `>` character+and an optional 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.++If the `>` character is followed by an optional space, that space+will be considered part of the block quote marker and not part of+the indentation of the contents.  Thus, to put an indented code+block in a block quote, you need five spaces after the `>`:++    >     code++#### Extension: `blank_before_blockquote` ####++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 the `markdown_strict` format 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.+++### Fenced code blocks ###++#### Extension: `fenced_code_blocks` ####++In addition to standard indented code blocks, pandoc supports+*fenced* 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 these lines is treated as code. No+indentation is necessary:++    ~~~~~~~+    if (a > 3) {+      moveShip(5 * gravity, DOWN);+    }+    ~~~~~~~++Like regular code blocks, fenced code blocks must be separated+from surrounding text by blank lines.++If the code itself contains a row of tildes or backticks, just use a longer+row of tildes or backticks at the start and end:++    ~~~~~~~~~~~~~~~~+    ~~~~~~~~~~+    code including tildes+    ~~~~~~~~~~+    ~~~~~~~~~~~~~~~~++#### Extension: `backtick_code_blocks` ####++Same as `fenced_code_blocks`, but uses backticks (`` ` ``) instead of tildes+(`~`).++#### Extension: `fenced_code_attributes` ####++Optionally, you may attach attributes to fenced or backtick code block using+this syntax:++    ~~~~ {#mycode .haskell .numberLines startFrom="100"}+    qsort []     = []+    qsort (x:xs) = qsort (filter (< x) xs) ++ [x] +++                   qsort (filter (>= x) xs)+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and+`startFrom` is an attribute with value `100`. Some output formats can use this+information to do syntax highlighting. Currently, the only output formats+that uses this information are HTML, LaTeX, Docx, Ms, and PowerPoint. If+highlighting is supported for your output format and language, then the code+block above will appear highlighted, with numbered lines. (To see which+languages are supported, type `pandoc --list-highlight-languages`.) Otherwise,+the code block above will appear as follows:++    <pre id="mycode" class="haskell numberLines" startFrom="100">+      <code>+      ...+      </code>+    </pre>++The `numberLines` (or `number-lines`) class will cause the lines+of the code block to be numbered, starting with `1` or the value+of the `startFrom` attribute.  The `lineAnchors` (or+`line-anchors`) class will cause the lines to be clickable+anchors in HTML output.++A shortcut form can also be used for specifying the language of+the code block:++    ```haskell+    qsort [] = []+    ```++This is equivalent to:++    ``` {.haskell}+    qsort [] = []+    ```++If the `fenced_code_attributes` extension is disabled, but+input contains class attribute(s) for the code block, the first+class attribute will be printed after the opening fence as a bare+word.++To prevent all highlighting, use the `--no-highlight` flag.+To set the highlighting style, use `--highlight-style`.+For more information on highlighting, see [Syntax highlighting],+below.++## Line blocks++#### Extension: `line_blocks` ####++A line block is a sequence of lines beginning with a vertical bar (`|`)+followed by a space.  The division into lines will be preserved in+the output, as will any leading spaces; otherwise, the lines will+be formatted as Markdown.  This is useful for verse and addresses:++    | The limerick packs laughs anatomical+    | In space that is quite economical.+    |    But the good ones I've seen+    |    So seldom are clean+    | And the clean ones so seldom are comical++    | 200 Main St.+    | Berkeley, CA 94718++The lines can be hard-wrapped if needed, but the continuation+line must begin with a space.++    | The Right Honorable Most Venerable and Righteous Samuel L.+      Constable, Jr.+    | 200 Main St.+    | Berkeley, CA 94718++This syntax is borrowed from [reStructuredText].++## 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.++List items look best if subsequent lines are flush with the first+line (after the bullet):++    * here is my first+      list item.+    * and my second.++But Markdown also allows a "lazy" format:++    * here is my first+    list item.+    * and my second.++### Block content in list items ###++A list item may contain multiple paragraphs and other block-level+content. However, subsequent paragraphs must be preceded by a blank line+and indented to line up with the first non-space content after+the list marker.++      * First paragraph.++        Continued.++      * Second paragraph. With a code block, which must be indented+        eight spaces:++            { code }++Exception: if the list marker is followed by an indented code+block, which must begin 5 spaces after the list marker, then+subsequent paragraphs must begin two columns after the last+character of the list marker:++    *     code++      continuation paragraph++List items may include other lists.  In this case the preceding blank+line is optional.  The nested list must be indented to line up with+the first non-space character after the list marker of the+containing list item.++    * fruits+      + apples+        - macintosh+        - red delicious+      + pears+      + peaches+    * vegetables+      + broccoli+      + chard++As noted above, 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++#### Extension: `fancy_lists` ####++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.[^2]++[^2]:  The point of this rule is to ensure that normal paragraphs+    starting with people's initials, like++        B. Russell was an English philosopher.++    do not get treated as list items.++    This rule will not prevent++        (C) 2007 Joe Smith++    from being interpreted as a list item.  In this case, a backslash+    escape can be used:++        (C\) 2007 Joe Smith++The `fancy_lists` extension also allows '`#`' to be used as an+ordered list marker in place of a numeral:++    #. one+    #. two++#### Extension: `startnum` ####++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:++     9)  Ninth+    10)  Tenth+    11)  Eleventh+           i. subone+          ii. subtwo+         iii. subthree++Pandoc will start a new list each time a different type of list+marker is used.  So, the following will create three lists:++    (2) Two+    (5) Three+    1.  Four+    *   Five++If default list markers are desired, use `#.`:++    #.  one+    #.  two+    #.  three++#### Extension: `task_lists` ####++Pandoc supports task lists, using the syntax of GitHub-Flavored Markdown.++    - [ ] an unchecked task list item+    - [x] checked item++### Definition lists ###++#### Extension: `definition_lists` ####++Pandoc supports definition lists, using the syntax of+[PHP Markdown Extra] with some extensions.[^3]++    Term 1++    :   Definition 1++    Term 2 with *inline markup*++    :   Definition 2++            { some code, part of Definition 2 }++        Third paragraph of definition 2.++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.  The body of the definition (including the first line,+aside from the colon or tilde) should be indented four spaces. However,+as with other Markdown lists, you can "lazily" omit indentation except+at the beginning of a paragraph or other block element:++    Term 1++    :   Definition+    with lazy continuation.++        Second paragraph of the definition.++If you leave space before the definition (as in the example above),+the text of the definition will be treated as a paragraph.  In some+output formats, this will mean greater spacing between term/definition+pairs. For a more compact definition list, omit the space before the+definition:++    Term 1+      ~ Definition 1++    Term 2+      ~ Definition 2a+      ~ Definition 2b++Note that space between items in a definition list is required.+(A variant that loosens this requirement, but disallows "lazy"+hard wrapping, can be activated with `compact_definition_lists`: see+[Non-pandoc extensions], below.)++[^3]:  I have been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).++### Numbered example lists ###++#### Extension: `example_lists` ####++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.++Note:  continuation paragraphs in example lists must always+be indented four spaces, regardless of the length of the+list marker.  That is, example lists always behave as if the+`four_space_rule` extension is set.  This is because example+labels tend to be long, and indenting content to the+first non-space character after the label would be awkward.++### Compact and loose lists ###++Pandoc behaves differently from `Markdown.pl` on some "edge+cases" involving lists.  Consider this source:++    +   First+    +   Second:+        -   Fee+        -   Fie+        -   Foe++    +   Third++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 `markdown_strict` format is specified. This+behavior is consistent with the official Markdown syntax description,+even though it is different from that of `Markdown.pl`.)+++### 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++    <!-- -->++    1.  uno+    2.  dos+    3.  tres++## Horizontal rules++A line containing a row of three or more `*`, `-`, or `_` characters+(optionally separated by spaces) produces a horizontal rule:++    *  *  *  *++    ---------------+++## Tables++Four kinds of tables may be used. The first three kinds presuppose the use of+a fixed-width font, such as Courier. The fourth kind can be used with+proportionally spaced fonts, as it does not require lining up columns.++#### Extension: `table_captions` ####++A caption may optionally be provided with all 4 kinds of tables (as+illustrated in the examples below). A caption is a paragraph beginning+with the string `Table:` (or just `:`), which will be stripped off.+It may appear either before or after the table.++#### Extension: `simple_tables` ####++Simple tables look like this:++      Right     Left     Center     Default+    -------     ------ ----------   -------+         12     12        12            12+        123     123       123          123+          1     1          1             1++    Table:  Demonstration of simple table syntax.++The header 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:[^4]++  - 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.+  - 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.+  - If the dashed line extends beyond the header text on both sides,+    the column is centered.+  - 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).++[^4]:  This scheme is due to Michel Fortin, who proposed it on the+       [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).++The table must end with a blank line, or a line of dashes followed by+a blank line.++The column header row may be omitted, provided a dashed line is used+to end the table. For example:++    -------     ------ ----------   -------+         12     12        12             12+        123     123       123           123+          1     1          1              1+    -------     ------ ----------   -------++When the header row is 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.++#### Extension: `multiline_tables` ####++Multiline tables allow header 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:++    -------------------------------------------------------------+     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's another one. Note+                                        the blank line between+                                        rows.+    -------------------------------------------------------------++    Table: Here's the caption. It, too, may span+    multiple lines.++These work like simple tables, but with the following differences:++  - They must begin with a row of dashes, before the header text+    (unless the header row is omitted).+  - They must end with a row of dashes, then a blank line.+  - The rows must be separated by blank lines.++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.++The header may be omitted in multiline tables as well as simple tables:++    ----------- ------- --------------- -------------------------+       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 a multiline table without a header.++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.++#### Extension: `grid_tables` ####++Grid tables look like this:++    : Sample grid table.++    +---------------+---------------+--------------------++    | Fruit         | Price         | Advantages         |+    +===============+===============+====================++    | Bananas       | $1.34         | - built-in wrapper |+    |               |               | - bright color     |+    +---------------+---------------+--------------------++    | Oranges       | $2.10         | - cures scurvy     |+    |               |               | - tasty            |+    +---------------+---------------+--------------------+++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.). Cells that span multiple columns or rows are not+supported. Grid tables can be created easily using Emacs' table-mode+(`M-x table-insert`).++Alignments can be specified as with pipe tables, by putting+colons at the boundaries of the separator line after the+header:++    +---------------+---------------+--------------------++    | Right         | Left          | Centered           |+    +==============:+:==============+:==================:++    | Bananas       | $1.34         | built-in wrapper   |+    +---------------+---------------+--------------------+++For headerless tables, the colons go on the top line instead:++    +--------------:+:--------------+:------------------:++    | Right         | Left          | Centered           |+    +---------------+---------------+--------------------+++##### Grid Table Limitations #####++Pandoc does not support grid tables with row spans or column spans.+This means that neither variable numbers of columns across rows nor+variable numbers of rows across columns are supported by Pandoc.+All grid tables must have the same number of columns in each row,+and the same number of rows in each column.  For example, the+Docutils [sample grid tables] will not render as expected with+Pandoc.++[sample grid tables]: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables+++#### Extension: `pipe_tables` ####++Pipe tables look like this:++    | Right | Left | Default | Center |+    |------:|:-----|---------|:------:|+    |   12  |  12  |    12   |    12  |+    |  123  |  123 |   123   |   123  |+    |    1  |    1 |     1   |     1  |++      : Demonstration of pipe table syntax.++The syntax is identical to [PHP Markdown Extra tables].  The beginning and+ending pipe characters are optional, but pipes are required between all+columns.  The colons indicate column alignment as shown.  The header+cannot be omitted.  To simulate a headerless table, include a header+with blank cells.++Since the pipes indicate column boundaries, columns need not be vertically+aligned, as they are in the above example.  So, this is a perfectly+legal (though ugly) pipe table:++    fruit| price+    -----|-----:+    apple|2.05+    pear|1.37+    orange|3.09++The cells of pipe tables cannot contain block elements like paragraphs+and lists, and cannot span multiple lines.  If a pipe table contains a+row whose printable content is wider than the column width (see+`--columns`), then the table will take up the full text width and+the cell contents will wrap, with the relative cell widths determined+by the number of dashes in the line separating the table header from+the table body. (For example `---|-` would make the first column 3/4+and the second column 1/4 of the full text width.)+On the other hand, if no lines are wider than column width, then+cell contents will not be wrapped, and the cells will be sized+to their contents.++Note:  pandoc also recognizes pipe tables of the following+form, as can be produced by Emacs' orgtbl-mode:++    | One | Two   |+    |-----+-------|+    | my  | table |+    | is  | nice  |++The difference is that `+` is used instead of `|`. Other orgtbl features+are not supported. In particular, to get non-default column alignment,+you'll need to add colons as above.++[PHP Markdown Extra tables]: https://michelf.ca/projects/php-markdown/extra/#table++## Metadata blocks++#### Extension: `pandoc_title_block` ####++If the file begins with a title block++    % title+    % author(s) (separated by semicolons)+    % date++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:++    %+    % Author++    % My title+    %+    % June 15, 2006++The title may occupy multiple lines, but continuation lines must+begin with leading space, thus:++    % My title+      on multiple lines++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:++    % Author One+      Author Two++    % Author One; Author Two++    % Author One;+      Author Two++The date must fit on one line.++All three metadata fields may contain standard inline formatting+(italics, links, footnotes, etc.).++Title blocks will always be parsed, but they will affect the output only+when the `--standalone` (`-s`) 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 (`--title-prefix` or `-T` 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+`-T` and no title block appears in the document, the title prefix will+be used by itself as the HTML title.++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 (`|`) should be used to separate the footer text from the header+text.  Thus,++    % PANDOC(1)++will yield a man page with the title `PANDOC` and section 1.++    % PANDOC(1) Pandoc User Manuals++will also have "Pandoc User Manuals" in the footer.++    % PANDOC(1) Pandoc User Manuals | Version 4.0++will also have "Version 4.0" in the header.++#### Extension: `yaml_metadata_block` ####++A [YAML] metadata block is a valid YAML object, delimited by a line of three+hyphens (`---`) at the top and a line of three hyphens (`---`) or three dots+(`...`) at the bottom.  A YAML metadata block may occur anywhere in the+document, but if it is not at the beginning, it must be preceded by a blank+line.  (Note that, because of the way pandoc concatenates input files when+several are provided, you may also keep the metadata in a separate YAML file+and pass it to pandoc as an argument, along with your Markdown files:++    pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html++Just be sure that the YAML file begins with `---` and ends with `---` or+`...`.) Alternatively, you can use the `--metadata-file` option. Using+that approach however, you cannot reference content (like footnotes)+from the main markdown input document.++Metadata will be taken from the fields of the YAML object and added to any+existing document metadata.  Metadata can contain lists and objects (nested+arbitrarily), but all string scalars will be interpreted as Markdown.  Fields+with names ending in an underscore will be ignored by pandoc.  (They may be+given a role by external processors.)  Field names must not be+interpretable as YAML numbers or boolean values (so, for+example, `yes`, `True`, and `15` cannot be used as field names).++A document may contain multiple metadata blocks.  If two+metadata blocks attempt to set the same field, the value from+the second block will be taken.++When pandoc is used with `-t markdown` to create a Markdown document,+a YAML metadata block will be produced only if the `-s/--standalone`+option is used.  All of the metadata will appear in a single block+at the beginning of the document.++Note that [YAML] escaping rules must be followed. Thus, for example,+if a title contains a colon, it must be quoted.  The pipe character+(`|`) can be used to begin an indented block that will be interpreted+literally, without need for escaping.  This form is necessary+when the field contains blank lines or block-level formatting:++    ---+    title:  'This is the title: it contains a colon'+    author:+    - Author One+    - Author Two+    keywords: [nothing, nothingness]+    abstract: |+      This is the abstract.++      It consists of two paragraphs.+    ...++Template variables will be set automatically from the metadata.  Thus, for+example, in writing HTML, the variable `abstract` will be set to the HTML+equivalent of the Markdown in the `abstract` field:++    <p>This is the abstract.</p>+    <p>It consists of two paragraphs.</p>++Variables can contain arbitrary YAML structures, but the template must match+this structure.  The `author` variable in the default templates expects a+simple list or string, but can be changed to support more complicated+structures.  The following combination, for example, would add an affiliation+to the author if one is given:++    ---+    title: The document title+    author:+    - name: Author One+      affiliation: University of Somewhere+    - name: Author Two+      affiliation: University of Nowhere+    ...++To use the structured authors in the example above, you would need a custom+template:++    $for(author)$+    $if(author.name)$+    $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$+    $else$+    $author$+    $endif$+    $endfor$++Raw content to include in the document's header may be specified+using `header-includes`; however, it is important to mark up+this content as raw code for a particular output format, using+the [`raw_attribute` extension](#extension-raw_attribute)), or it+will be interpreted as markdown. For example:++    header-includes:+    - |+      ```{=latex}+      \let\oldsection\section+      \renewcommand{\section}[1]{\clearpage\oldsection{#1}}+      ```++## Backslash escapes++#### Extension: `all_symbols_escapable` ####++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 `markdown_strict` format is used, 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.++## 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\*.++#### Extension: `intraword_underscores` ####++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 ###++#### Extension: `strikeout` ####++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 ###++#### Extension: `superscript`, `subscript` ####++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.++The text between `^...^` or `~...~` may not contain spaces or+newlines.  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 `^`, and also bad interactions with+footnotes.) 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: `\*`.++#### Extension: `inline_code_attributes` ####++Attributes can be attached to verbatim text, just as with+[fenced code blocks]:++    `<$>`{.haskell}++### Small caps ###++To write small caps, use the `smallcaps` class:++    [Small caps]{.smallcaps}++Or, without the `bracketed_spans` extension:++    <span class="smallcaps">Small caps</span>++For compatibility with other Markdown flavors, CSS is also supported:++    <span style="font-variant:small-caps;">Small caps</span>++This will work in all output formats that support small caps.+++## Math++#### Extension: `tex_math_dollars` ####++Anything between two `$` characters will be treated as TeX math.  The+opening `$` must have a non-space character immediately to its right,+while the closing `$` must have a non-space character immediately to its+left, and must not be followed immediately by a digit.  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:++LaTeX+  ~ It will appear verbatim surrounded by `\(...\)` (for inline+    math) or `\[...\]` (for display math).++Markdown, Emacs Org mode, ConTeXt, ZimWiki+  ~ It will appear verbatim surrounded by `$...$` (for inline+    math) or `$$...$$` (for display math).++XWiki+  ~ It will appear verbatim surrounded by `{{formula}}..{{/formula}}`.++reStructuredText+  ~ It will be rendered using an [interpreted text role `:math:`].++AsciiDoc+  ~ For AsciiDoc output format (`-t asciidoc`) it will appear verbatim+    surrounded by `latexmath:[$...$]` (for inline math) or+    `[latexmath]++++\[...\]+++` (for display math).+    For AsciiDoctor output format (`-t asciidoctor`) the LaTex delimiters+    (`$..$` and `\[..\]`) are omitted.++Texinfo+  ~ It will be rendered inside a `@math` command.++roff man, Jira markup+  ~ It will be rendered verbatim without `$`'s.++MediaWiki, DokuWiki+  ~ It will be rendered inside `<math>` tags.++Textile+  ~ It will be rendered inside `<span class="math">` tags.++RTF, OpenDocument+  ~ It will be rendered, if possible, using Unicode characters,+    and will otherwise appear verbatim.++ODT+  ~ It will be rendered, if possible, using MathML.++DocBook+  ~ If the `--mathml` flag is used, it will be rendered using MathML+    in an `inlineequation` or `informalequation` tag.  Otherwise it+    will be rendered, if possible, using Unicode characters.++Docx+  ~ It will be rendered using OMML math markup.++FictionBook2+  ~ If the `--webtex` option is used, formulas are rendered as images+    using CodeCogs or other compatible web service, downloaded+    and embedded in the e-book. Otherwise, they will appear verbatim.++HTML, Slidy, DZSlides, S5, EPUB+  ~ The way math is rendered in HTML will depend on the+    command-line options selected. Therefore see [Math rendering in HTML]+    above.++[interpreted text role `:math:`]: http://docutils.sourceforge.net/docs/ref/rst/roles.html#math++## Raw HTML++#### Extension: `raw_html` ####++Markdown allows you to insert raw HTML (or DocBook) anywhere in a document+(except verbatim contexts, where `<`, `>`, and `&` are interpreted+literally).  (Technically this is not an extension, since standard+Markdown allows it, but it has been made an extension so that it can+be disabled if desired.)++The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,+DZSlides, EPUB, Markdown, CommonMark, Emacs Org mode, and Textile+output, and suppressed in other formats.++For a more explicit way of including raw HTML in a Markdown+document, see the [`raw_attribute` extension][Extension: `raw_attribute`].++In the CommonMark format, if `raw_html` is enabled, superscripts,+subscripts, strikeouts and small capitals will be represented as HTML.+Otherwise, plain-text fallbacks will be used. Note that even if+`raw_html` is disabled, tables will be rendered with HTML syntax if+they cannot use pipe syntax.++#### Extension: `markdown_in_html_blocks` ####++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 the `markdown_strict` format is used; but+by default, pandoc interprets material between HTML block tags as Markdown.+Thus, for example, pandoc will turn++    <table>+    <tr>+    <td>*one*</td>+    <td>[a link](http://google.com)</td>+    </tr>+    </table>++into++    <table>+    <tr>+    <td><em>one</em></td>+    <td><a href="http://google.com">a link</a></td>+    </tr>+    </table>++whereas `Markdown.pl` will preserve it as is.++There is one exception to this rule:  text between `<script>` and+`<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.++#### Extension: `native_divs` ####++Use native pandoc `Div` blocks for content inside `<div>` tags.+For the most part this should give the same output as+`markdown_in_html_blocks`, but it makes it easier to write pandoc+filters to manipulate groups of blocks.++#### Extension: `native_spans` ####++Use native pandoc `Span` blocks for content inside `<span>` tags.+For the most part this should give the same output as `raw_html`,+but it makes it easier to write pandoc filters to manipulate groups+of inlines.++#### Extension: `raw_tex` ####++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:++    This result was proved in \cite{jones.1967}.++Note that in LaTeX environments, like++    \begin{tabular}{|l|l|}\hline+    Age & Frequency \\ \hline+    18--25  & 15 \\+    26--35  & 33 \\+    36--45  & 22 \\ \hline+    \end{tabular}++the material between the begin and end tags will be interpreted as raw+LaTeX, not as Markdown.++For a more explicit and flexible way of including raw TeX in a+Markdown document, see the [`raw_attribute`+extension][Extension: `raw_attribute`].++Inline LaTeX is ignored in output formats other than Markdown, LaTeX,+Emacs Org mode, and ConTeXt.++### Generic raw attribute ###++#### Extension: `raw_attribute` ####++Inline spans and fenced code blocks with a special+kind of attribute will be parsed as raw content with the+designated format.  For example, the following produces a raw+roff `ms` block:++    ```{=ms}+    .MYMACRO+    blah blah+    ```+And the following produces a raw `html` inline element:++    This is `<a>html</a>`{=html}++This can be useful to insert raw xml into `docx` documents, e.g.+a pagebreak:++    ```{=openxml}+    <w:p>+      <w:r>+        <w:br w:type="page"/>+      </w:r>+    </w:p>+    ```++The format name should match the target format name (see+`-t/--to`, above, for a list, or use `pandoc+--list-output-formats`). Use `openxml` for `docx` output,+`opendocument` for `odt` output, `html5` for `epub3` output,+`html4` for `epub2` output, and `latex`, `beamer`,+`ms`, or `html5` for `pdf` output (depending on what you+use for `--pdf-engine`).++This extension presupposes that the relevant kind of+inline code or fenced code block is enabled.  Thus, for+example, to use a raw attribute with a backtick code block,+`backtick_code_blocks` must be enabled.++The raw attribute cannot be combined with regular attributes.++## LaTeX macros++#### Extension: `latex_macros` ####++When this extension is enabled, pandoc will parse LaTeX+macro definitions and apply the resulting macros to all LaTeX+math and raw LaTeX.  So, for example, the following will work in+all output formats, not just LaTeX:++    \newcommand{\tuple}[1]{\langle #1 \rangle}++    $\tuple{a, b, c}$++Note that LaTeX macros will not be applied if they occur+inside a raw span or block marked with the+[`raw_attribute` extension](#extension-raw_attribute).++When `latex_macros` is disabled, the raw LaTeX and math will+not have macros applied. This is usually a better approach when+you are targeting LaTeX or PDF.++Macro definitions in LaTeX will be passed through as raw LaTeX+only if `latex_macros` is not enabled.  Macro definitions in+Markdown source (or other formats allowing `raw_tex`) will+be passed through regardless of whether `latex_macros` is+enabled.++## Links++Markdown allows links to be specified in several ways.++### Automatic links ###++If you enclose a URL or email address in pointy brackets, it+will become a link:++    <http://google.com>+    <sam@green.eggs.ham>++### 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.++Email addresses in inline links are not autodetected, so they have to be+prefixed with `mailto`:++    [Write me!](mailto:sam@green.eggs.ham)++### 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 cannot be space between the two unless the+`spaced_reference_links` extension is enabled.) The link definition+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.  The label must not be parseable as a citation (assuming+the `citations` extension is enabled):  citations take precedence over+link labels.++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:++    See [my website][].++    [my website]: http://foo.bar.baz++Note:  In `Markdown.pl` and most other Markdown implementations,+reference link definitions cannot occur in nested constructions+such as list items or block quotes.  Pandoc lifts this arbitrary+seeming restriction.  So the following is fine in pandoc, though+not in most other implementations:++    > My block [quote].+    >+    > [quote]: /foo++#### Extension: `shortcut_reference_links` ####++In a *shortcut* reference link, the second pair of brackets may+be omitted entirely:++    See [my website].++    [my website]: http://foo.bar.baz++### Internal links ###++To link to another section of the same document, use the automatically+generated identifier (see [Heading identifiers]). For example:++    See the [Introduction](#introduction).++or++    See the [Introduction].++    [Introduction]: #introduction++Internal links are currently supported for HTML formats (including+HTML slide shows and EPUB), LaTeX, and ConTeXt.++## 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++#### Extension: `implicit_figures` ####++An image with nonempty alt text, occurring by itself in a+paragraph, will be rendered as a figure with a caption.  The+image's alt text will be used as the caption.++    ![This is the caption](/url/of/image.png)++How this is rendered depends on the output format. Some output+formats (e.g. RTF) do not yet support figures.  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)\++Note that in reveal.js slide shows, an image in a paragraph+by itself that has the `stretch` class will fill the screen,+and the caption and figure tags will be omitted.++#### Extension: `link_attributes` ####++Attributes can be set on links and images:++    An inline ![image](foo.jpg){#id .class width=30 height=20px}+    and a reference ![image][ref] with attributes.++    [ref]: foo.jpg "optional title" {#id .class key=val key2="val 2"}++(This syntax is compatible with [PHP Markdown Extra] when only `#id`+and `.class` are used.)++For HTML and EPUB, all known HTML5 attributes except `width` and+`height` (but including `srcset` and `sizes`) are passed through+as is. Unknown attributes are passed through as custom+attributes, with `data-` prepended. The other writers ignore+attributes that are not specifically supported by their output format.++The `width` and `height` attributes on images are treated specially. When+used without a unit, the unit is assumed to be pixels. However, any of+the following unit identifiers can be used: `px`, `cm`, `mm`, `in`, `inch`+and `%`. There must not be any spaces between the number and the unit.+For example:++```+![](file.jpg){ width=50% }+```++- Dimensions are converted to inches for output in page-based formats like+  LaTeX. Dimensions are converted to pixels for output in HTML-like+  formats.  Use the `--dpi` option to specify the number of pixels per+  inch.  The default is 96dpi.+- The `%` unit is generally relative to some available space.+  For example the above example will render to the following.+  - HTML: `<img href="file.jpg" style="width: 50%;" />`+  - LaTeX: `\includegraphics[width=0.5\textwidth,height=\textheight]{file.jpg}`+    (If you're using a custom template, you need to configure `graphicx`+    as in the default template.)+  - ConTeXt: `\externalfigure[file.jpg][width=0.5\textwidth]`+- Some output formats have a notion of a class+  ([ConTeXt](http://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))+  or a unique identifier (LaTeX `\caption`), or both (HTML).+- When no `width` or `height` attributes are specified, the fallback+  is to look at the image resolution and the dpi metadata embedded in+  the image file.++## Divs and Spans++Using the `native_divs` and `native_spans` extensions+(see [above][Extension: `native_divs`]), HTML syntax can+be used as part of markdown to create native `Div` and `Span`+elements in the pandoc AST (as opposed to raw HTML).+However, there is also nicer syntax available:++#### Extension: `fenced_divs` ####++Allow special fenced syntax for native `Div` blocks.  A Div+starts with a fence containing at least three consecutive+colons plus some attributes. The attributes may optionally+be followed by another string of consecutive colons.+The attribute syntax is exactly as in fenced code blocks (see+[Extension: `fenced_code_attributes`]).  As with fenced+code blocks, one can use either attributes in curly braces+or a single unbraced word, which will be treated as a class+name.  The Div ends with another line containing a string of at+least three consecutive colons.  The fenced Div should be+separated by blank lines from preceding and following blocks.++Example:++    ::::: {#special .sidebar}+    Here is a paragraph.++    And another.+    :::::++Fenced divs can be nested.  Opening fences are distinguished+because they *must* have attributes:++    ::: Warning ::::::+    This is a warning.++    ::: Danger+    This is a warning within a warning.+    :::+    ::::::::::::::::::++Fences without attributes are always closing fences.  Unlike+with fenced code blocks, the number of colons in the closing+fence need not match the number in the opening fence.  However,+it can be helpful for visual clarity to use fences of different+lengths to distinguish nested divs from their parents.+++#### Extension: `bracketed_spans` ####++A bracketed sequence of inlines, as one would use to begin+a link, will be treated as a `Span` with attributes if it is+followed immediately by attributes:++    [This is *some text*]{.class key="val"}++## Footnotes++#### Extension: `footnotes` ####++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.).  Each footnote should be+separated from surrounding content (including other footnotes)+by blank lines.++#### Extension: `inline_notes` ####++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++#### Extension: `citations` ####++Using an external filter, `pandoc-citeproc`, pandoc can automatically generate+citations and a bibliography in a number of styles.  Basic usage is++    pandoc --filter pandoc-citeproc myinput.txt++In order to use this feature, you will need to specify a bibliography file+using the `bibliography` metadata field in a YAML metadata section, or+`--bibliography` command line argument. You can supply multiple `--bibliography`+arguments or set `bibliography` metadata field to YAML array, if you want to+use multiple bibliography files.  The bibliography may have any of these+formats:++  Format            File extension+  ------------      --------------+  BibLaTeX          .bib+  BibTeX            .bibtex+  Copac             .copac+  CSL JSON          .json+  CSL YAML          .yaml+  EndNote           .enl+  EndNote XML       .xml+  ISI               .wos+  MEDLINE           .medline+  MODS              .mods+  RIS               .ris++Note that `.bib` can be used with both BibTeX and BibLaTeX files;+use `.bibtex` to force BibTeX.++Note that `pandoc-citeproc --bib2json` and `pandoc-citeproc --bib2yaml`+can produce `.json` and `.yaml` files from any of the supported formats.++In-field markup: In BibTeX and BibLaTeX databases,+pandoc-citeproc parses a subset of LaTeX markup; in CSL YAML+databases, pandoc Markdown; and in CSL JSON databases, an+[HTML-like markup][CSL markup specs]:++`<i>...</i>`+:   italics++`<b>...</b>`+:   bold++`<span style="font-variant:small-caps;">...</span>` or `<sc>...</sc>`+:   small capitals++`<sub>...</sub>`+:   subscript++`<sup>...</sup>`+:   superscript++`<span class="nocase">...</span>`+:   prevent a phrase from being capitalized as title case++`pandoc-citeproc -j` and `-y` interconvert the CSL JSON+and CSL YAML formats as far as possible.++As an alternative to specifying a bibliography file using `--bibliography`+or the YAML metadata field `bibliography`, you can include+the citation data directly in the `references` field of the+document's YAML metadata. The field should contain an array of+YAML-encoded references, for example:++    ---+    references:+    - type: article-journal+      id: WatsonCrick1953+      author:+      - family: Watson+        given: J. D.+      - family: Crick+        given: F. H. C.+      issued:+        date-parts:+        - - 1953+          - 4+          - 25+      title: 'Molecular structure of nucleic acids: a structure for deoxyribose+        nucleic acid'+      title-short: Molecular structure of nucleic acids+      container-title: Nature+      volume: 171+      issue: 4356+      page: 737-738+      DOI: 10.1038/171737a0+      URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html+      language: en-GB+    ...++(`pandoc-citeproc --bib2yaml` can produce these from a bibliography file in one+of the supported formats.)++Citations and references can be formatted using any style supported by the+[Citation Style Language], listed in the [Zotero Style Repository].+These files are specified using the `--csl` option or the `csl` metadata field.+By default, `pandoc-citeproc` will use the [Chicago Manual of Style] author-date+format.  The CSL project provides further information on [finding and editing styles].++To make your citations hyperlinks to the corresponding bibliography+entries, add `link-citations: true` to your YAML metadata.++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.  The citation key must begin with a letter, digit,+or `_`, and may contain alphanumerics, `_`, and internal punctuation+characters (`:.#$%&-+?<>~/`).  Here are some examples:++    Blah blah [see @doe99, pp. 33-35; also @smith04, chap. 1].++    Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].++    Blah blah [@smith04; @doe99].++`pandoc-citeproc` detects locator terms in the [CSL locale files].+Either abbreviated or unabbreviated forms are accepted. In the `en-US`+locale, locator terms can be written in either singular or plural forms,+as `book`, `bk.`/`bks.`; `chapter`, `chap.`/`chaps.`; `column`,+`col.`/`cols.`; `figure`, `fig.`/`figs.`; `folio`, `fol.`/`fols.`;+`number`, `no.`/`nos.`; `line`, `l.`/`ll.`; `note`, `n.`/`nn.`; `opus`,+`op.`/`opp.`; `page`, `p.`/`pp.`; `paragraph`, `para.`/`paras.`; `part`,+`pt.`/`pts.`; `section`, `sec.`/`secs.`; `sub verbo`, `s.v.`/`s.vv.`;+`verse`, `v.`/`vv.`; `volume`, `vol.`/`vols.`; `¶`/`¶¶`; `§`/`§§`. If no+locator term is used, "page" is assumed.++`pandoc-citeproc` will use heuristics to distinguish the locator+from the suffix. In complex cases, the locator can be enclosed+in curly braces (using `pandoc-citeproc` 0.15 and higher only):++    [@smith{ii, A, D-Z}, with a suffix]+    [@smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]++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+in a div with id `refs`, if one exists:++    ::: {#refs}+    :::++Otherwise, it will be placed at the end of the document.+Generation of the bibliography can be suppressed by setting+`suppress-bibliography: true` in the YAML metadata.++If you wish the bibliography to have a section heading, you can+set `reference-section-title` in the metadata, or put the heading+at the beginning of the div with id `refs` (if you are using it)+or at the end of your document:++    last paragraph...++    # References++The bibliography will be inserted after this heading.  Note that+the `unnumbered` class will be added to this heading, so that the+section will not be numbered.++If you want to include items in the bibliography without actually+citing them in the body text, you can define a dummy `nocite` metadata+field and put the citations there:++    ---+    nocite: |+      @item1, @item2+    ...++    @item3++In this example, the document will contain a citation for `item3`+only, but the bibliography will contain entries for `item1`, `item2`, and+`item3`.++It is possible to create a bibliography with all the citations,+whether or not they appear in the document, by using a wildcard:++    ---+    nocite: |+      @*+    ...++For LaTeX output, you can also use [`natbib`] or [`biblatex`] to+render the bibliography. In order to do so, specify bibliography+files as outlined above, and add `--natbib` or `--biblatex`+argument to `pandoc` invocation. Bear in mind that bibliography+files have to be in respective format (either BibTeX or+BibLaTeX).++For more information, see the [pandoc-citeproc man page].++[CSL markup specs]: http://docs.citationstyles.org/en/1.0/release-notes.html#rich-text-markup-within-fields+[Chicago Manual of Style]: http://chicagomanualofstyle.org+[Citation Style Language]: http://citationstyles.org+[Zotero Style Repository]: https://www.zotero.org/styles+[finding and editing styles]: https://citationstyles.org/authors/+[CSL locale files]: https://github.com/citation-style-language/locales+[pandoc-citeproc man page]: https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md++## Non-pandoc extensions++The following Markdown syntax extensions are not enabled by default+in pandoc, but may be enabled by adding `+EXTENSION` to the format+name, where `EXTENSION` is the name of the extension.  Thus, for+example, `markdown+hard_line_breaks` is Markdown with hard line breaks.++#### Extension: `old_dashes` ####++Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:+`-` before a numeral is an en-dash, and `--` is an em-dash.+This option only has an effect if `smart` is enabled. It is+selected automatically for `textile` input.++#### Extension: `angle_brackets_escapable` ####++Allow `<` and `>` to be backslash-escaped, as they can be in+GitHub flavored Markdown but not original Markdown.  This is+implied by pandoc's default `all_symbols_escapable`.++#### Extension: `lists_without_preceding_blankline` ####++Allow a list to occur right after a paragraph, with no intervening+blank space.++#### Extension: `four_space_rule` ####++Selects the pandoc <= 2.0 behavior for parsing lists, so that+four spaces indent are needed for list item continuation+paragraphs.++#### Extension: `spaced_reference_links` ####++Allow whitespace between the two components of a reference link,+for example,++    [foo] [bar].++#### Extension: `hard_line_breaks` ####++Causes all newlines within a paragraph to be interpreted as hard line+breaks instead of spaces.++#### Extension: `ignore_line_breaks` ####++Causes newlines within a paragraph to be ignored, rather than being+treated as spaces or as hard line breaks.  This option is intended for+use with East Asian languages where spaces are not used between words,+but text is divided into lines for readability.++#### Extension: `east_asian_line_breaks` ####++Causes newlines within a paragraph to be ignored, rather than+being treated as spaces or as hard line breaks, when they occur+between two East Asian wide characters.  This is a better choice+than `ignore_line_breaks` for texts that include a mix of East+Asian wide characters and other characters.++#### Extension: `emoji` ####++Parses textual emojis like `:smile:` as Unicode emoticons.++#### Extension: `tex_math_single_backslash` ####++Causes anything between `\(` and `\)` to be interpreted as inline+TeX math, and anything between `\[` and `\]` to be interpreted+as display TeX math.  Note: a drawback of this extension is that+it precludes escaping `(` and `[`.++#### Extension: `tex_math_double_backslash` ####++Causes anything between `\\(` and `\\)` to be interpreted as inline+TeX math, and anything between `\\[` and `\\]` to be interpreted+as display TeX math.++#### Extension: `markdown_attribute` ####++By default, pandoc interprets material inside block-level tags as Markdown.+This extension changes the behavior so that Markdown is only parsed+inside block-level tags if the tags have the attribute `markdown=1`.++#### Extension: `mmd_title_block` ####++Enables a [MultiMarkdown] style title block at the top of+the document, for example:++    Title:   My title+    Author:  John Doe+    Date:    September 1, 2008+    Comment: This is a sample mmd title block, with+             a field spanning multiple lines.++See the MultiMarkdown documentation for details.  If `pandoc_title_block` or+`yaml_metadata_block` is enabled, it will take precedence over+`mmd_title_block`.++#### Extension: `abbreviations` ####++Parses PHP Markdown Extra abbreviation keys, like++    *[HTML]: Hypertext Markup Language++Note that the pandoc document model does not support+abbreviations, so if this extension is enabled, abbreviation keys are+simply skipped (as opposed to being parsed as paragraphs).++#### Extension: `autolink_bare_uris` ####++Makes all absolute URIs into links, even when not surrounded by+pointy braces `<...>`.++#### Extension: `mmd_link_attributes` ####++Parses multimarkdown style key-value attributes on link+and image references. This extension should not be confused with the+[`link_attributes`](#extension-link_attributes) extension.++    This is a reference ![image][ref] with multimarkdown attributes.++    [ref]: http://path.to/image "Image title" width=20px height=30px+           id=myId class="myClass1 myClass2"++#### Extension: `mmd_header_identifiers` ####++Parses multimarkdown style heading identifiers (in square brackets,+after the heading but before any trailing `#`s in an ATX heading).++#### Extension: `compact_definition_lists` ####++Activates the definition list syntax of pandoc 1.12.x and earlier.+This syntax differs from the one described above under [Definition lists]+in several respects:++  - No blank line is required between consecutive items of the+    definition list.+  - To get a "tight" or "compact" list, omit space between consecutive+    items; the space between a term and its definition does not affect+    anything.+  - Lazy wrapping of paragraphs is not allowed:  the entire definition must+    be indented four spaces.[^6]++[^6]:  To see why laziness is incompatible with relaxing the requirement+    of a blank line between items, consider the following example:++        bar+        :    definition+        foo+        :    definition++    Is this a single list item with two definitions of "bar," the first of+    which is lazily wrapped, or two list items?  To remove the ambiguity+    we must either disallow lazy wrapping or require a blank line between+    list items.++#### Extension: `gutenberg` ####++Use [Project Gutenberg] conventions for `plain` output:+all-caps for strong emphasis, surround by underscores+for regular emphasis, add extra blank space around headings.++  [Project Gutenberg]: https://www.gutenberg.org++## Markdown variants++In addition to pandoc's extended Markdown, the following Markdown+variants are supported:++`markdown_phpextra` (PHP Markdown Extra)+:   `footnotes`, `pipe_tables`, `raw_html`, `markdown_attribute`,+    `fenced_code_blocks`, `definition_lists`, `intraword_underscores`,+    `header_attributes`, `link_attributes`, `abbreviations`,+    `shortcut_reference_links`, `spaced_reference_links`.++`markdown_github` (deprecated GitHub-Flavored Markdown)+:   `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,+    `gfm_auto_identifiers`, `backtick_code_blocks`,+    `autolink_bare_uris`, `space_in_atx_header`,+    `intraword_underscores`, `strikeout`, `task_lists`, `emoji`,+    `shortcut_reference_links`, `angle_brackets_escapable`,+    `lists_without_preceding_blankline`.++`markdown_mmd` (MultiMarkdown)+:   `pipe_tables`, `raw_html`, `markdown_attribute`, `mmd_link_attributes`,+    `tex_math_double_backslash`, `intraword_underscores`,+    `mmd_title_block`, `footnotes`, `definition_lists`,+    `all_symbols_escapable`, `implicit_header_references`,+    `auto_identifiers`, `mmd_header_identifiers`,+    `shortcut_reference_links`, `implicit_figures`,+    `superscript`, `subscript`, `backtick_code_blocks`,+    `spaced_reference_links`, `raw_attribute`.++`markdown_strict` (Markdown.pl)+:   `raw_html`, `shortcut_reference_links`,+    `spaced_reference_links`.++We also support `commonmark` and `gfm` (GitHub-Flavored Markdown,+which is implemented as a set of extensions on `commonmark`).++Note, however, that `commonmark` and `gfm` have limited support+for extensions. Only those  listed below (and `smart`,+`raw_tex`, and `hard_line_breaks`) will work. The extensions+can, however, all be individually disabled.  Also, `raw_tex`+only affects `gfm` output, not input.++`gfm` (GitHub-Flavored Markdown)+:   `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,+    `gfm_auto_identifiers`, `backtick_code_blocks`,+    `autolink_bare_uris`, `space_in_atx_header`,+    `intraword_underscores`, `strikeout`, `task_lists`, `emoji`,+    `shortcut_reference_links`, `angle_brackets_escapable`,+    `lists_without_preceding_blankline`.+++# Producing slide shows with pandoc++You can use pandoc to produce an HTML + JavaScript slide presentation+that can be viewed via a web browser.  There are five ways to do this,+using [S5], [DZSlides], [Slidy], [Slideous], or [reveal.js].+You can also produce a PDF slide show using LaTeX [`beamer`], or+slides shows in Microsoft [PowerPoint] format.++Here's the Markdown source for a simple slide show, `habits.txt`:++    % Habits+    % John Doe+    % March 22, 2005++    # In the morning++    ## Getting up++    - Turn off alarm+    - Get out of bed++    ## Breakfast++    - Eat eggs+    - Drink coffee++    # In the evening++    ## Dinner++    - Eat spaghetti+    - Drink wine++    ------------------++    ![picture of spaghetti](images/spaghetti.jpg)++    ## Going to sleep++    - Get in bed+    - Count sheep++To produce an HTML/JavaScript slide show, simply type++    pandoc -t FORMAT -s habits.txt -o habits.html++where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.++For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the+`-s/--standalone` option embeds a link to JavaScript and CSS files, which are+assumed to be available at the relative path `s5/default` (for S5), `slideous`+(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at+`w3.org` (for Slidy).  (These paths can be changed by setting the `slidy-url`,+`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for HTML slides],+above.) For DZSlides, the (relatively short) JavaScript and CSS are included in+the file by default.++With all HTML slide formats, the `--self-contained` option can be used to+produce a single file that contains all of the data necessary to display the+slide show, including linked scripts, stylesheets, images, and videos.++To produce a PDF slide show using beamer, type++    pandoc -t beamer habits.txt -o habits.pdf++Note that a reveal.js slide show can also be converted to a PDF+by printing it to a file from the browser.++To produce a Powerpoint slide show, type++    pandoc habits.txt -o habits.pptx++## Structuring the slide show++By default, the *slide level* is the highest heading level in+the hierarchy that is followed immediately by content, and not another+heading, somewhere in the document. In the example above, level-1 headings+are always followed by level-2 headings, which are followed by content,+so the slide level is 2.  This default can be overridden using+the `--slide-level` option.++The document is carved up into slides according to the following+rules:++  * A horizontal rule always starts a new slide.++  * A heading at the slide level always starts a new slide.++  * Headings *below* the slide level in the hierarchy create+    headings *within* a slide.++  * Headings *above* the slide level in the hierarchy create+    "title slides," which just contain the section title+    and help to break the slide show into sections.+    Non-slide content under these headings will be included+    on the title slide (for HTML slide shows) or in a+    subsequent slide with the same title (for beamer).++  * A title page is constructed automatically from the document's title+    block, if present.  (In the case of beamer, this can be disabled+    by commenting out some lines in the default template.)++These rules are designed to support many different styles of slide show. If+you don't care about structuring your slides into sections and subsections,+you can just use level-1 headings for all each slide. (In that case, level-1+will be the slide level.) But you can also structure the slide show into+sections, as in the example above.++Note:  in reveal.js slide shows, if slide level is 2, a two-dimensional+layout will be produced, with level-1 headings building horizontally+and level-2 headings building vertically.  It is not recommended that+you use deeper nesting of section levels with reveal.js.++## Incremental lists++By default, these writers produce lists that display "all at once."+If you want your lists to display incrementally (one item at a time),+use the `-i` option. If you want a particular list to depart from the+default, put it in a `div` block with class `incremental` or+`nonincremental`. So, for example, using the `fenced div` syntax, the+following would be incremental regardless of the document default:++    ::: incremental++    - Eat spaghetti+    - Drink wine++    :::++or++    ::: nonincremental++    - Eat spaghetti+    - Drink wine++    :::++While using `incremental` and `nonincremental` divs are the+recommended method of setting incremental lists on a per-case basis,+an older method is also supported: putting lists inside a blockquote+will depart from the document default (that is, it will display+incrementally without the `-i` option and all at once with the `-i`+option):++    > - Eat spaghetti+    > - Drink wine++Both methods allow incremental and nonincremental lists to be mixed+in a single document.++Note: Neither the `-i/--incremental` option nor any of the+methods described here currently works for PowerPoint output.++## Inserting pauses++You can add "pauses" within a slide by including a paragraph containing+three dots, separated by spaces:++    # Slide with a pause++    content before the pause++    . . .++    content after the pause++Note: this feature is not yet implemented for PowerPoint output.++## Styling the slides++You can change the style of HTML slides by putting customized CSS files+in `$DATADIR/s5/default` (for S5), `$DATADIR/slidy` (for Slidy),+or `$DATADIR/slideous` (for Slideous),+where `$DATADIR` is the user data directory (see `--data-dir`, above).+The originals may be found in pandoc's system data directory (generally+`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any+files it does not find in the user data directory.++For dzslides, the CSS is included in the HTML file itself, and may+be modified there.++All [reveal.js configuration options] can be set through variables.+For example, themes can be used by setting the `theme` variable:++    -V theme=moon++Or you can specify a custom stylesheet using the `--css` option.++To style beamer slides, you can specify a `theme`, `colortheme`,+`fonttheme`, `innertheme`, and `outertheme`, using the `-V` option:++    pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf++Note that heading attributes will turn into slide attributes+(on a `<div>` or `<section>`) in HTML slide formats, allowing you+to style individual slides.  In beamer, the only heading attribute+that affects slides is the `allowframebreaks` class, which sets the+`allowframebreaks` option, causing multiple slides to be created+if the content overfills the frame.  This is recommended especially for+bibliographies:++    # References {.allowframebreaks}++## Speaker notes++Speaker notes are supported in reveal.js and PowerPoint (pptx)+output. You can add notes to your Markdown document thus:++    ::: notes++    This is my note.++    - It can contain Markdown+    - like this list++    :::++To show the notes window in reveal.js, press `s` while viewing the+presentation. Speaker notes in PowerPoint will be available, as usual,+in handouts and presenter view.++Notes are not yet supported for other slide formats, but the notes+will not appear on the slides themselves.++## Columns++To put material in side by side columns, you can use a native+div container with class `columns`, containing two or more div+containers with class `column` and a `width` attribute:++    :::::::::::::: {.columns}+    ::: {.column width="40%"}+    contents...+    :::+    ::: {.column width="60%"}+    contents...+    :::+    ::::::::::::::++## Frame attributes in beamer++Sometimes it is necessary to add the LaTeX `[fragile]` option to+a frame in beamer (for example, when using the `minted` environment).+This can be forced by adding the `fragile` class to the heading+introducing the slide:++    # Fragile slide {.fragile}++All of the other frame attributes described in Section 8.1 of+the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,+`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,+`shrink`, `standout`, `noframenumbering`.++## Background in reveal.js and beamer++Background images can be added to self-contained reveal.js slideshows and +to beamer slideshows.++For the same image on every slide, use the  configuration+option `background-image` either in the YAML metadata block+or as a command-line variable. (There are no other options in+beamer and the rest of this section concerns reveal.js slideshows.)++For reveal.js, you can instead use the reveal.js-native option +`parallaxBackgroundImage`. You can also set `parallaxBackgroundHorizontal` +and `parallaxBackgroundVertical` the same way and must also set +`parallaxBackgroundSize` to have your values take effect.++To set an image for a particular reveal.js slide, add+`{data-background-image="/path/to/image"}`+to the first slide-level heading on the slide (which may even be empty).++In reveal.js's overview mode, the parallaxBackgroundImage will show up+only on the first slide.++Other reveal.js background settings also work on individual slides, including+`data-background-size`, `data-background-repeat`, `data-background-color`,+`data-transition`, and `data-transition-speed`.++See the [reveal.js+documentation](https://github.com/hakimel/reveal.js#slide-backgrounds)+for more details.++For example in reveal.js:++```+---+title: My Slideshow+parallaxBackgroundImage: /path/to/my/background_image.png+---++## Slide One++Slide 1 has background_image.png as its background.++## {data-background-image="/path/to/special_image.jpg"}++Slide 2 has a special image for its background, even though the heading has no content.+```++# Creating EPUBs with pandoc++## EPUB Metadata++EPUB metadata may be specified using the `--epub-metadata` option, but+if the source document is Markdown, it is better to use a [YAML metadata+block][Extension: `yaml_metadata_block`].  Here is an example:++    ---+    title:+    - type: main+      text: My Book+    - type: subtitle+      text: An investigation of metadata+    creator:+    - role: author+      text: John Smith+    - role: editor+      text: Sarah Jones+    identifier:+    - scheme: DOI+      text: doi:10.234234.234/33+    publisher:  My Press+    rights: © 2007 John Smith, CC BY-NC+    ibooks:+      version: 1.3.4+    ...++The following fields are recognized:++`identifier`+  ~ Either a string value or an object with fields `text` and+    `scheme`.  Valid values for `scheme` are `ISBN-10`,+    `GTIN-13`, `UPC`, `ISMN-10`, `DOI`, `LCCN`, `GTIN-14`,+    `ISBN-13`, `Legal deposit number`, `URN`, `OCLC`,+    `ISMN-13`, `ISBN-A`, `JP`, `OLCC`.++`title`+  ~ Either a string value, or an object with fields `file-as` and+    `type`, or a list of such objects.  Valid values for `type` are+    `main`, `subtitle`, `short`, `collection`, `edition`, `extended`.++`creator`+  ~ Either a string value, or an object with fields `role`, `file-as`,+    and `text`, or a list of such objects.  Valid values for `role` are+    [MARC relators], but+    pandoc will attempt to translate the human-readable versions+    (like "author" and "editor") to the appropriate marc relators.++`contributor`+  ~ Same format as `creator`.++`date`+  ~ A string value in `YYYY-MM-DD` format.  (Only the year is necessary.)+    Pandoc will attempt to convert other common date formats.++`lang` (or legacy: `language`)+  ~ A string value in [BCP 47] format.  Pandoc will default to the local+    language if nothing is specified.++`subject`+  ~ A string value or a list of such values.++`description`+  ~ A string value.++`type`+  ~ A string value.++`format`+  ~ A string value.++`relation`+  ~ A string value.++`coverage`+  ~ A string value.++`rights`+  ~ A string value.++`cover-image`+  ~ A string value (path to cover image).++`css` (or legacy: `stylesheet`)+  ~ A string value (path to CSS stylesheet).++`page-progression-direction`+  ~ Either `ltr` or `rtl`. Specifies the `page-progression-direction`+    attribute for the [`spine` element].++`ibooks`+  ~ iBooks-specific metadata, with the following fields:++    - `version`: (string)+    - `specified-fonts`: `true`|`false` (default `false`)+    - `ipad-orientation-lock`: `portrait-only`|`landscape-only`+    - `iphone-orientation-lock`: `portrait-only`|`landscape-only`+    - `binding`: `true`|`false` (default `true`)+    - `scroll-axis`: `vertical`|`horizontal`|`default`++[MARC relators]: http://loc.gov/marc/relators/relaterm.html+[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem++## The `epub:type` attribute++For `epub3` output, you can mark up the heading that corresponds to an EPUB+chapter using the [`epub:type` attribute][epub-type]. For example, to set+the attribute to the value `prologue`, use this markdown:++    # My chapter {epub:type=prologue}++Which will result in:++    <body epub:type="frontmatter">+      <section epub:type="prologue">+        <h1>My chapter</h1>++Pandoc will output `<body epub:type="bodymatter">`, unless+you use one of the following values, in which case either+`frontmatter` or `backmatter` will be output.++`epub:type` of first section      `epub:type` of body+----------------------------      ------------------+prologue                          frontmatter+abstract                          frontmatter+acknowledgments                   frontmatter+copyright-page                    frontmatter+dedication                        frontmatter+credits                           frontmatter+keywords                          frontmatter+imprint                           frontmatter+contributors                      frontmatter+other-credits                     frontmatter+errata                            frontmatter+revision-history                  frontmatter+titlepage                         frontmatter+halftitlepage                     frontmatter+seriespage                        frontmatter+foreword                          frontmatter+preface                           frontmatter+seriespage                        frontmatter+titlepage                         frontmatter+appendix                          backmatter+colophon                          backmatter+bibliography                      backmatter+index                             backmatter++[epub-type]: http://www.idpf.org/epub/31/spec/epub-contentdocs.html#sec-epub-type-attribute++## Linked media++By default, pandoc will download media referenced from any `<img>`, `<audio>`,+`<video>` or `<source>` element present in the generated EPUB,+and include it in the EPUB container, yielding a completely+self-contained EPUB.  If you want to link to external media resources+instead, use raw HTML in your source and add `data-external="1"` to the tag+with the `src` attribute.  For example:++    <audio controls="1">+      <source src="http://example.com/music/toccata.mp3"+              data-external="1" type="audio/mpeg">+      </source>+    </audio>++# Creating Jupyter notebooks with pandoc++When creating a [Jupyter notebook], pandoc will try to infer the+notebook structure.  Code blocks with the class `code` will be+taken as code cells, and intervening content will be taken as+Markdown cells.  Attachments will automatically be created for+images in Markdown cells. Metadata will be taken from the+`jupyter` metadata field.  For example:++````+---+title: My notebook+jupyter:+  nbformat: 4+  nbformat_minor: 5+  kernelspec:+     display_name: Python 2+     language: python+     name: python2+  language_info:+     codemirror_mode:+       name: ipython+       version: 2+     file_extension: ".py"+     mimetype: "text/x-python"+     name: "python"+     nbconvert_exporter: "python"+     pygments_lexer: "ipython2"+     version: "2.7.15"+---++# Lorem ipsum++**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus+bibendum felis dictum sodales.++``` code+print("hello")+```++## Pyout++``` code+from IPython.display import HTML+HTML("""+<script>+console.log("hello");+</script>+<b>HTML</b>+""")+```++## Image++This image ![image](myimage.png) will be+included as a cell attachment.+````++If you want to add cell attributes, group cells differently, or+add output to code cells, then you need to include divs to+indicate the structure. You can use either [fenced+divs][Extension: `fenced_divs`] or [native divs][Extension:+`native_divs`] for this.  Here is an example:++````+:::::: {.cell .markdown}+# Lorem++**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus+bibendum felis dictum sodales.+::::::++:::::: {.cell .code execution_count=1}+``` {.python}+print("hello")+```++::: {.output .stream .stdout}+```+hello+```+:::+::::::++:::::: {.cell .code execution_count=2}+``` {.python}+from IPython.display import HTML+HTML("""+<script>+console.log("hello");+</script>+<b>HTML</b>+""")+```++::: {.output .execute_result execution_count=2}+```{=html}+<script>+console.log("hello");+</script>+<b>HTML</b>+hello+```+:::+::::::+````++If you include raw HTML or TeX in an output cell, use the+[raw attribute][Extension: `fenced_attribute`], as shown+in the last cell of the example above.  Although pandoc can+process "bare" raw HTML and TeX, the result is often+interspersed raw elements and normal textual elements, and+in an output cell pandoc expects a single, connected raw+block.  To avoid using raw HTML or TeX except when+marked explicitly using raw attributes, we recommend+specifying the extensions `-raw_html-raw_tex+raw_attribute` when+translating between Markdown and ipynb notebooks.++Note that options and extensions that affect reading and+writing of Markdown will also affect Markdown cells in ipynb+notebooks.  For example, `--wrap=preserve` will preserve+soft line breaks in Markdown cells; `--atx-headers` will+cause ATX-style headings to be used; and `--preserve-tabs` will+prevent tabs from being turned to spaces.++# Syntax highlighting++Pandoc will automatically highlight syntax in [fenced code blocks] that+are marked with a language name.  The Haskell library [skylighting] is+used for highlighting. Currently highlighting is supported only for+HTML, EPUB, Docx, Ms, and LaTeX/PDF output. To see a list of language names+that pandoc will recognize, type `pandoc --list-highlight-languages`.++The color scheme can be selected using the `--highlight-style` option.+The default color scheme is `pygments`, which imitates the default color+scheme used by the Python library pygments (though pygments is not actually+used to do the highlighting).  To see a list of highlight styles,+type `pandoc --list-highlight-styles`.++If you are not satisfied with the predefined styles, you can+use `--print-highlight-style` to generate a JSON `.theme` file which+can be modified and used as the argument to `--highlight-style`. To+get a JSON version of the `pygments` style, for example:++    pandoc --print-highlight-style pygments > my.theme++Then edit `my.theme` and use it like this:++    pandoc --highlight-style my.theme++If you are not satisfied with the built-in highlighting, or you+want highlight a language that isn't supported, you can use the+`--syntax-definition` option to load a [KDE-style XML syntax definition+file](https://docs.kde.org/stable5/en/applications/katepart/highlight.html).+Before writing your own, have a look at KDE's [repository of syntax+definitions](https://github.com/KDE/syntax-highlighting/tree/master/data/syntax).++To disable highlighting, use the `--no-highlight` option.++[skylighting]: https://github.com/jgm/skylighting++# Custom Styles++Custom styles can be used in the docx and ICML formats.++## Output++By default, pandoc's docx and ICML output applies a predefined set of styles+for blocks such as paragraphs and block quotes, and uses largely default+formatting (italics, bold) for inlines. This will work for most+purposes, especially alongside a `reference.docx` file. However, if you+need to apply your own styles to blocks, or match a preexisting set of+styles, pandoc allows you to define custom styles for blocks and text+using `div`s and `span`s, respectively.++If you define a `div` or `span` with the attribute `custom-style`,+pandoc will apply your specified style to the contained elements (with+the exception of elements whose function depends on a style, like+headings, code blocks, block quotes, or links). So, for example, using+the `bracketed_spans` syntax,++    [Get out]{custom-style="Emphatically"}, he said.++would produce a docx file with "Get out" styled with character+style `Emphatically`. Similarly, using the `fenced_divs` syntax,++    Dickinson starts the poem simply:++    ::: {custom-style="Poetry"}+    | A Bird came down the Walk---+    | He did not know I saw---+    :::++would style the two contained lines with the `Poetry` paragraph style.++For docx output, styles will be defined in the output file as inheriting+from normal text, if the styles are not yet in your reference.docx.+If they are already defined, pandoc will not alter the definition.++This feature allows for greatest customization in conjunction with+[pandoc filters]. If you want all paragraphs after block quotes to be+indented, you can write a filter to apply the styles necessary. If you+want all italics to be transformed to the `Emphasis` character style+(perhaps to change their color), you can write a filter which will+transform all italicized inlines to inlines within an `Emphasis`+custom-style `span`.++For docx output, you don't need to enable any extensions for+custom styles to work.++[pandoc filters]: http://pandoc.org/filters.html++## Input++The docx reader, by default, only reads those styles that it can+convert into pandoc elements, either by direct conversion or+interpreting the derivation of the input document's styles.++By enabling the [`styles` extension](#ext-styles) in the docx reader+(`-f docx+styles`), you can produce output that maintains the styles+of the input document, using the `custom-style` class. Paragraph+styles are interpreted as divs, while character styles are interpreted+as spans.++For example, using the `custom-style-reference.docx` file in the test+directory, we have the following different outputs:++Without the `+styles` extension:++    $ pandoc test/docx/custom-style-reference.docx -f docx -t markdown+    This is some text.++    This is text with an *emphasized* text style. And this is text with a+    **strengthened** text style.++    > Here is a styled paragraph that inherits from Block Text.++And with the extension:++    $ pandoc test/docx/custom-style-reference.docx -f docx+styles -t markdown++    ::: {custom-style="First Paragraph"}+    This is some text.+    :::++    ::: {custom-style="Body Text"}+    This is text with an [emphasized]{custom-style="Emphatic"} text style.+    And this is text with a [strengthened]{custom-style="Strengthened"}+    text style.+    :::++    ::: {custom-style="My Block Style"}+    > Here is a styled paragraph that inherits from Block Text.+    :::++With these custom styles, you can use your input document as a+reference-doc while creating docx output (see below), and maintain the+same styles in your input and output files.++# Custom writers++Pandoc can be extended with custom writers written in [lua].  (Pandoc+includes a lua interpreter, so lua need not be installed separately.)++To use a custom writer, simply specify the path to the lua script+in place of the output format. For example:++    pandoc -t data/sample.lua++Creating a custom writer requires writing a lua function for each+possible element in a pandoc document.  To get a documented example+which you can modify according to your needs, do++    pandoc --print-default-data-file sample.lua++Note that custom writers have no default template.  If you want+to use `--standalone` with a custom writer, you will need to+specify a template manually using `--template` or add a new+default template with the name+`default.NAME_OF_CUSTOM_WRITER.lua` to the `templates`+subdirectory of your user data directory (see [Templates]).++[lua]: http://www.lua.org++# A note on security++If you use pandoc to convert user-contributed content in a web+application, here are some things to keep in mind:++1. Although pandoc itself will not create or modify any files other+   than those you explicitly ask it create (with the exception+   of temporary files used in producing PDFs), a filter or custom+   writer could in principle do anything on your file system. Please+   audit filters and custom writers very carefully before using them.++2. If your application uses pandoc as a Haskell library (rather than+   shelling out to the executable), it is possible to use it in a mode+   that fully isolates pandoc from your file system, by running the+   pandoc operations in the `PandocPure` monad. See the document+   [Using the pandoc API](http://pandoc.org/using-the-pandoc-api.html)+   for more details.++3. Pandoc's parsers can exhibit pathological performance on some+   corner cases.  It is wise to put any pandoc operations under+   a timeout, to avoid DOS attacks that exploit these issues.+   If you are using the pandoc executable, you can add the+   command line options `+RTS -M512M -RTS` (for example) to limit+   the heap size to 512MB.++4. The HTML generated by pandoc is not guaranteed to be safe.+   If `raw_html` is enabled for the Markdown input, users can+   inject arbitrary HTML.  Even if `raw_html` is disabled,+   users can include dangerous content in attributes for+   headings, spans, and code blocks.  To be safe, you should+   run all the generated HTML through an HTML sanitizer.++# Authors++Copyright 2006--2019 John MacFarlane (jgm@berkeley.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.) For a full list of contributors, see the file+AUTHORS.md in the pandoc source code.++[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"+[YAML]: https://yaml.org/spec/1.2/spec.html "YAML v1.2 Spec"
README.md view
@@ -13,8 +13,8 @@ [![stackage LTS package](http://stackage.org/package/pandoc/badge/lts)](http://stackage.org/lts/package/pandoc) [![CircleCI](https://circleci.com/gh/jgm/pandoc.svg?style=svg)](https://circleci.com/gh/jgm/pandoc)-[![appveyor build-status](https://ci.appveyor.com/api/projects/status/nvqs4ct090igjiqc?svg=true)](https://ci.appveyor.com/project/jgm/pandoc)+[![CI+tests](https://github.com/jgm/pandoc/workflows/CI%20tests/badge.svg)](https://github.com/jgm/pandoc/actions) [![license](https://img.shields.io/badge/license-GPLv2+-lightgray.svg)](https://www.gnu.org/licenses/gpl.html) [![pandoc-discuss on google groups](https://img.shields.io/badge/pandoc-discuss-red.svg?style=social)](https://groups.google.com/forum/#!forum/pandoc-discuss)@@ -136,6 +136,7 @@   - `opml` ([OPML](http://dev.opml.org/spec2.html))   - `opendocument` ([OpenDocument](http://opendocument.xml.org))   - `org` ([Emacs Org mode](http://orgmode.org))+  - `pdf` ([PDF](https://www.adobe.com/pdf/))   - `plain` (plain text),   - `pptx`     ([PowerPoint](https://en.wikipedia.org/wiki/Microsoft_PowerPoint)
benchmark/benchmark-pandoc.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TupleSections     #-} {- Copyright (C) 2012-2019 John MacFarlane <jgm@berkeley.edu> @@ -19,56 +20,74 @@ -} import Prelude import Text.Pandoc+import Text.Pandoc.MIME import Text.Pandoc.Error (PandocError(..)) import Control.Monad.Except (throwError) import qualified Text.Pandoc.UTF8 as UTF8 import qualified Data.ByteString as B+import qualified Data.Text as T import Criterion.Main import Criterion.Types (Config(..)) import Data.List (intersect) import Data.Maybe (mapMaybe) import System.Environment (getArgs)+import qualified Data.ByteString.Lazy as BL  readerBench :: Pandoc-            -> String+            -> T.Text             -> Maybe Benchmark readerBench doc name =   case res of        Right (readerFun, inp) ->-          Just $ bench (name ++ " reader")+          Just $ bench (T.unpack $ name <> " reader")                $ nf (\i -> either (error . show) id $ runPure (readerFun i))                  inp        Left _ -> Nothing-  where res = runPure $-          case (getReader name, getWriter name) of-            (Right (TextReader r, rexts),-             Right (TextWriter w, wexts)) -> do-               inp <- w def{ writerWrapText = WrapAuto-                           , writerExtensions = wexts } doc-               return $ (r def{ readerExtensions = rexts }, inp)-            _ -> throwError $ PandocSomeError-                 $ "could not get text reader and writer for " ++ name+  where res = runPure $ do+          (rdr, rexts) <- getReader name+          (wtr, wexts) <- getWriter name+          case (rdr, wtr) of+            (TextReader r, TextWriter w) -> do+                     setResourcePath ["../test"]+                     inp <- w def{ writerWrapText = WrapAuto+                                 , writerExtensions = wexts } doc+                     return $ (r def{ readerExtensions = rexts }, inp)+            _ -> throwError $ PandocSomeError $ "not a text format: "+                                 <> name +getImages :: IO [(FilePath, MimeType, BL.ByteString)]+getImages = do+  ll <- BL.readFile "test/lalune.jpg"+  mv <- BL.readFile "test/movie.jpg"+  return [("lalune.jpg", "image/jpg", ll)+         ,("movie.jpg", "image/jpg", mv)]+ writerBench :: Pandoc-            -> String+            -> T.Text             -> Maybe Benchmark writerBench doc name =   case res of        Right writerFun ->-          Just $ bench (name ++ " writer")+          Just $ env getImages $ \imgs ->+            bench (T.unpack $ name <> " writer")                $ nf (\d -> either (error . show) id $-                            runPure (writerFun d)) doc+                            runPure (do mapM_+                                          (\(fp, mt, bs) ->+                                              insertMedia fp (Just mt) bs)+                                          imgs+                                        writerFun d)) doc        Left _ -> Nothing   where res = runPure $ do-          case (getWriter name) of-            Right (TextWriter w, wexts) ->+          (wtr, wexts) <- getWriter name+          case wtr of+            TextWriter w ->               return $ w def{ writerExtensions = wexts }             _ -> throwError $ PandocSomeError-                 $ "could not get text reader and writer for " ++ name+                 $ "could not get text writer for " <> name  main :: IO () main = do-  args <- filter (\x -> take 1 x /= "-") <$> getArgs+  args <- filter (\x -> T.take 1 x /= "-") . fmap T.pack <$> getArgs   print args   let matchReader (n, TextReader _) =          null args || ("reader" `elem` args && n `elem` args)@@ -77,9 +96,9 @@          null args || ("writer" `elem` args && n `elem` args)       matchWriter _                 = False   let matchedReaders = map fst $ (filter matchReader readers-                                    :: [(String, Reader PandocPure)])+                                    :: [(T.Text, Reader PandocPure)])   let matchedWriters = map fst $ (filter matchWriter writers-                                    :: [(String, Writer PandocPure)])+                                    :: [(T.Text, Writer PandocPure)])   inp <- UTF8.toText <$> B.readFile "test/testsuite.txt"   let opts = def   let doc = either (error . show) id $ runPure $ readMarkdown opts inp
benchmark/weigh-pandoc.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Main    Copyright   : © 2016-2019 John MacFarlane <jgm@berkeley.edu>@@ -13,7 +14,7 @@ import Prelude import Weigh import Text.Pandoc-import Data.Text (Text)+import Data.Text (Text, unpack)  main :: IO () main = do@@ -40,12 +41,12 @@ weighWriter :: Pandoc -> String -> (Pandoc -> Text) -> Weigh () weighWriter doc name writer = func (name ++ " writer") writer doc -weighReader :: Pandoc -> String -> (Text -> Pandoc) -> Weigh ()+weighReader :: Pandoc -> Text -> (Text -> Pandoc) -> Weigh () weighReader doc name reader = do   case lookup name writers of        Just (TextWriter writer) ->          let inp = either (error . show) id $ runPure $ writer def{ writerWrapText = WrapAuto} doc-         in func (name ++ " reader") reader inp+         in func (unpack $ name <> " reader") reader inp        _ -> return () -- no writer for reader  
+ cabal.project view
@@ -0,0 +1,14 @@+packages: pandoc.cabal++package pandoc+  flags: +embed_data_files -trypandoc+  ghc-options: -j +RTS -A32M -RTS++package pandoc-citeproc+  flags: +embed_data_files +bibutils -unicode_collation -test_citeproc -debug+  ghc-options: -j +RTS -A32M -RTS++source-repository-package+    type: git+    location: https://github.com/jgm/pandoc-citeproc+    tag: 0.16.4
− changelog
@@ -1,17192 +0,0 @@-pandoc (2.7.3)--  * Add `jira` (Atlassian's Jira wiki markup) as output format (#2497,-    Albert Krewinkel).--  * Add `tex_math_dollars` to `multimarkdownExtensions` (#5512).-    This form is now supported in multimarkdown,-    in addition to `tex_math_double_backslash`.--  * Fix `--self-contained` so it works when output format has extensions.-    Previously if you used `--self-contained` with `html-smart` or-    `html+smart`, it wouldn't work.--  * Add template variable `curdir` with working directory-    from which pandoc is run (#5464).--  * Markdown reader: don't create implicit reference for empty header-    (#5549).--  * Muse reader: allow images inside link descriptions (Alexander Krotov).--  * HTML reader: epub related fixes.--    + With epub extensions, check for `epub:type` in addition to `type`.-    + Fix problem with noteref parsing which caused block-level-      content to be eaten with the noteref.-    + Rename `pAnyTag` to `pAny`.-    + Refactor note resolution.-    + Trim definition list terms (Alexander Krotov).--  * LaTeX reader:--    + Add braces when resolving `\DeclareMathOperator`-      (#5441).  These seem to be needed for xelatex but not pdflatex.-    + Allow newlines in `\mintinline`.-    + Pass through unknown listings language as class (#5540).-      Previously if the language was not in the list of languages supported-      by listings, it would not be added as a class, so highlighting-      would not be triggered.-    + `rawLaTeXInline`: Include trailing `{}`s in raw latex commands (#5439).-      This change affects the markdown reader and other readers that allow raw-      LaTeX.  Previously, trailing `{}` would be included for unknown-      commands, but not for known commands.  However, they are sometimes used-      to avoid a trailing space after the command.  The chances that a `{}`-      after a LaTeX command is not part of the command are very small.--  * MediaWiki reader: handle multiple attributes in table row (#5471,-    chinapedia).--  * Docx reader: Add support for `w:rtl` (#5545).  Elements with this-    property are put into Span inlines with `dir="rtl"`.--  * DocBook reader: Issue `IgnoredElement` warnings.--  * Org reader (Albert Krewinkel):--    + Fix planning elements in headers level 3 and higher-      (#5494).  Planning info is now always placed before-      the subtree contents.  Previously, the planning info was placed after-      the content if the header's subtree was converted to a list, which-      happens with headers of level 3 and higher per default.-    + Omit, but warn about unknown export options.  Unknown export-      options are properly ignored and omitted from the output.-    + Prefer plain symbols over math symbols (#5483).-      Symbols like `\alpha` are output plain and unemphasized, not as math.-    + Recognize emphasis after TODO/DONE keyword (#5484).--  * FB2 reader:--    + Skip unknown elements rather than throwing errors (#5560).-      Sometimes custom elements are used (e.g. `id` element-      inside `author`); previously the reader would halt with an error.-      Now it skips the element and issues an `IgnoredElement` warning.-    + Parse notes (#5493, Alexander Krotov).-    + Internal improvements (Alexander Krotov).--  * OpenDocument writer:  Roll back automatic figure/table numbering-    (#5474).  This was added in pandoc 2.7.2, but it makes it impossible-    to use pandoc-crossref. So this has been rolled back for now,-    until we find a good solution to make this behavior optional-    (or a creative way to let pandoc-crossref and this feature-    to coexist).--  * New module Text.Pandoc.Writers.Jira, exporting `writeJira` [API-    change] (Albert Krewinkel).--  * EPUB writer:--    + Don't include 'landmarks' if there aren't any.-      Previously we could get an empty ol element, which caused-      validation errors with epubcheck.-    + Ensure unique ids for styleesheets in content.opf (#5463).-    + Make stylesheet link compatible with kindlegen (#5466,-      Eric Schrijver).  Pandoc omitted `type="text/css"` from both-      `<style>` and `<rel="stylesheet">` elements in all templates, which-      is valid according to the spec. However, Amazon’s kindlegen software-      relies on this attribute on `<link>` elements when detecting-      stylesheets to include.--  * HTML writer:--    + Output video and audio elements depending on file-      extension of the image path (Mauro Bieg).-    + Emit empty alt tag in figures (#5518, Mauro Bieg).-      The same text is already in the <figcaption> and-      screen-readers would read it twice, see #4737.-    + Don't add variation selector if it's already there.-      This fixes round-trip failures.-    + Prevent gratuitious emojification on iOS (#5469).-      iOS chooses to render a number of Unicode entities, including '↩', as-      big colorful emoji.  This can be defeated by appending Unicode VARIATION-      SELECTOR-15'/'VARIATION SELECTOR-16'.  So we now append this character-      when escaping strings, for both '↩' and '↔'.  If other characters prove-      problematic, they can simply be added to `needsVariationSelector`.-    + Add `class="heading"` to level 7+ Headers rendered as `<p>` elements-      (#5457).--  * RST writer: treat Span with no attributes as transparent (#5446).-    Previously an Emph inside a Span was being treated as-    nested markup and ignored.  With this patch, the Span-    is just ignored.--  * LaTeX writer:--    + Include inline code attributes with `--listings` (#5420).-    + Don't produce columns environment unless beamer (#5485).-    + Fix footnote in image caption.  Regression: the fix for #4683 broke-      this case.-    + Don't highlight code in headings (#5574).  This causes-      compilation errors.-    + Use `\mbox` to get proper behavior inside `\sout` (#5529).--  * EPUB writer: Fix document section assignments (#5546).-    For example, introduction should go in bodymatter, not frontmatter, and-    epigraph, conclusion, and afterward should go in bodymatter, not-    backmatter.  For the full list of assignments, see the manual.--  * Markdown writer:--    + Add backslashes to avoid unwanted interpretation of-      definition list terms as other kinds of block (#554).-    + Ensure the code fence is long enough (#5519).-      Previously too few backticks were used when the code block-      contained an indented line of backticks.  (Ditto tildes.)-    + Handle labels with integer names (Jesse Rosenthal, #5495).-      Previously if labels had integer names, it could produce a conflict-      with auto-labeled reference links. Now we test for a conflict and-      find the next available integer.  This involves adding a new state-      variable `stPrevRefs` to keep track of refs used in other document-      parts when using `--reference-location=block|section`--  * Textile writer: fix closing tag for math output (Albert Krewinkel).-    Opening and closing tag for math output match now.--  * Org writer: always indent src blocks content by 2 spaces (#5440, Albert-    Krewinkel).  Emacs always uses two spaces when indenting the content of-    src blocks, e.g., when exiting a `C-c '` edit-buffer. Pandoc used to-    indent contents by the space-equivalent of one tab, but now always uses-    two spaces, too.--  * Asciidoc writer:--    + Use `` `+...+` `` form for inline code.-      The old `` `a__b__c` `` yields emphasis inside code in asciidoc.-      To get a pure literal code span, use `` `+a__b__c+` ``.-    + Use proper smart quotes with asciidoctor (#5487).-      Asciidoctor has a different format for smart quotes.-    + Use doubled ## when necessary for spans (#5566).-    + Ensure correct nesting of strong/emph (#5565): strong-      must be the outer element.--  * JATS writer:--    + Wrap elements with p when needed (#5570).  The JATS spec restricts-      what elements can go inside `fn` and `list-item`.  So we wrap other-      elements inside `<p specific-use="wrapper">` when needed.-    + Properly handle footnotes (#5511) according to "best practice."-      (Group them at the end in `<fn-group>` and use `<xref>` elements-      to link them.)-    + Fix citations with PMID so they validate (#5481).  This includes-      an update to data/jats.csl.-    + Ensure validity of `<pub-date>` by parsing the date and-      extracting year, month, and day, as expected.  Also add an-      iso-8601-date attribute automatically.-    + Don't use `<break>` element for LineBreak. It is only-      allowed in a few special contexts, and not in `<p>` elements.-    + Don't make `<string-name>` a child of `<string>`, which is illegal.--  * FB2 writer:--    + Do not wrap note references into `<sup>` and brackets-      (Alexander Krotov).  Existing FB2 readers, such as FBReader, already-      display links with type="note" as a superscript.-    + Use genre metadata field (#5478).--  * Muse writer: do not escape empty line after `<br>` (Alexander Krotov).--  * Add unicode code point in "Missing character" warning (#5538).-    If the character isn't in the console font, the message is pretty useless,-    so we show the code point for anything non-ASCII.--  * Lua: add Version type to simplify comparisons (Albert Krewinkel).-    Version specifiers like `PANDOC_VERSION` and `PANDOC_API_VERSION` are-    turned into `Version` objects. The objects simplify version-appropriate-    comparisons while maintaining backward-compatibility.-    A function `pandoc.types.Version` is added as part of the newly-    introduced module `pandoc.types`, allowing users to create version-    objects in scripts.--  * pandoc lua module (Albert Krewinkel):--    - Fix deletion of nonexistent attributes (#5569).-    - Better tests for Attr and AttributeList.--  * pandoc.mediabag lua module (Albert Krewinkel):--    + Add function `delete` for deleting a single item.-    + Add function `empty` for removing all entries.-    + Add function `items` for iterating over mediabag.--  * Text.Pandoc.Class: Fix handling of `file:` URL scheme in-    `downloadOrRead` (#5517, Mauro Bieg).  Previously `file:/`-    URLs were handled wrongly and pandoc attempted to make HTTP-    requests, which failed.--  * Text.Pandoc.MIME: add `mediaCategory` [API change] (Mauro Bieg).--  * Text.Pandoc.Shared:--    + Add `onlySimpleTableCells` [API change]-      (Mauro Bieg) and use this to consolidate simple-table detection-      (#5524).  This fixes an inconsistency in the HTML reader, which did not-      treat tables with `<p>` inside cells as simple.-    + `metaToJSON`: treat digits starting with 0 as a string, not a number-      (#5479).  This fixes a regression in YAML metadata in pandoc 2.7.2.--  * Text.Pandoc.Logging: Add `IgnoredElement` constructor for-    `LogMessage`.  `SkippedConetnt` doesn't work for some XML-based-    readers which don't have access to parsec source positions.--  * Text.Pandoc.Asciify: Add Turkish undotted-i (#5433, Mauro Bieg).--  * Improve output of Lua tests (#5499, Albert Krewinkel).-    This makes use of tasty-lua, a package to write tests in Lua-    and integrate the results into Tasty output. Test output becomes-    more informative: individual tests and test groups become visible-    in test output. Failures are reported with helpful error messages.--  * Lua: add `pandoc.system` module (#5468, Albert Krewinkel).-    The `system` Lua module provides utility functions to interact with the-    operating- and file system. E.g.-    `print(pandoc.system.get_current_directory())`-    or-    ```lua-        pandoc.system.with_temporary_directory('tikz', function (dir)-          -- write and compile a TikZ file with pdflatex-        end)-    ```--  * LaTeX template: Add pdflang to hypersetup if lang is set (#5443).--  * beamer template: Fix using Beamer with geometry (#5505, Daniel Maslowski).-    Beamer already loads geometry, so we need to use the `\geometry`-    command to set geometry options.--  * EPUB2/3 templates: Move inline styles to default epub.css (#5466).-    NOTE: Those who use a custom CSS stylesheet with EPUB should-    add these lines:--        code{ white-space: pre-wrap; }-        span.smallcaps{ font-variant: small-caps; }-        span.underline{ text-decoration: underline; }-        q { quotes: "“" "”" "‘" "’"; }-        div.column{ display: inline-block; vertical-align: top; width: 50%; }--  * reveal.js template:--    + Updates for revealjs 3.8.0 (#5435, ebiim).-    + Remove reference to head.min.js (#5448, Winnie Hellmann).-      NOTE: users will need to update reveal.js to at least 3.8.0-      for their presentations generated with this version of pandoc-      to work correctly.--  * Text.Pandoc.PDF:--    + Replace `</>` with literal `/` (#5451).-      We use forward-slash for a directory separator in tmpDir,-      even on Windows (because that's what tex likes).  So we-      should not put a backslash between the tmpDir and the-      filename on Windows.  This is harmless enough in normal-      Windows setups, but it breaks on Cygwin.-      Thanks to @cc2x for noticing and diagnosing the problem.-    + Allow use of `-output-directory` in `--pdf-engine-opt` (#5462).-      This is currently possible with `mklatex` and `-outdir`, but-      was not yet possible with xelatex and `-output-directory`.-    + For PDF via ms/pdfroff, make TOC appear at beginning and in-      PDF bookmarks (#5553).  Previously the TOC appeared at the end-      of the document, and was not bookmarked.  To keep it at the end,-      add `--pdf-engine-opt=--no-toc-relocation` to your command line.--  * Fix broken links in documents (#5473, Shim Myeongseob).-    Also, use absolute links to pandoc.org when possible, so that-    the links can be followed by people viewing these documents-    on GitHub.--  * Improved sample lua tikz filter in lua-filters docs (#5445,-    Matthew Doty).  There are three changes:--    + It only processes elements which begin with `\begin{tikzpicture}`-    + It uses pdf2svg instead of imagemagick to preserve fidelity-    + The images produced have transparent backgrounds--  * MANUAL.txt:--    + Add note about `title-meta`, `author-meta`, `date-meta` (#5486).-    + Fix typo (#5489, Christian Krause).--  * add test/tables.xwiki to git and pandoc.cabal (#5498, Mauro Bieg).--  * Disable missing-home-modules warning in `stack.yaml`.-    Otherwise `stack ghci` fails.---pandoc (2.7.2)--  * Add XWiki writer (#1800, Derek Chen-Becker).-    Add `Text.Pandoc.Writers.XWiki`, exporting `writeXWiki` [API change].--  * Dokuwiki Reader: parse single curly brace (#5416, Mauro Bieg).--  * Vimwiki reader: improve handling of internal links (#5414).-    We no longer append `.html` to link targets, and we add a title-    `wikilink`.  This mirrors behavior of other wiki readers.  Generally-    the `.html` extension is not wanted.  It may be important for output-    to HTML in certain circumstances, but it can always be added using a-    filter that matches on links with title `wikilink`.--    If your workflow requires the current behavior, here is a lua filter-    that will add the `.html` extension:--    ```lua-    function Link(el)-      if el.title == 'wikilink' then-        el.target = el.target .. ".html"-      end-      return el-    end-    ```-  * ipynb reader:--    + Use format `ipynb` for raw cell where no format given.-    + Avoid introducing spurious `.0` on integers in metadata.--  * Markdown reader: fenced div takes priority over setext header.--  * HTML reader: read `data-foo` attribute into `foo` (#5392).-    The HTML writer adds the `data-` prefix for HTML5 for nonstandard-    attributes.  But the attributes are represented in the AST without-    the `data-` prefix, so we should strip this when reading HTML.--  * LaTeX reader: Improve autolink detection (#5340).--  * PowerPoint writer (Jesse Rosenthal):--    + Expand builtin reference doc to model all layouts.-      The previous built-in reference doc had only title and content-      layouts. Add in a section-header slide and a two-content slide, so-      users can more easily modify it to build their own templates.-    + Always open up in slide view.  When editing a-      template/reference-doc, the user might be in Master view, but when-      producing a slide show, it is assumed that slide view will be-      desired.-    + Remove `handoutsMasterList` from template presentation.xml-    + Fix numerous errors in templating (#5402). Previously, some templates-      produced by Office 365 (MacOS) would not render with `--reference-doc`-      correctly. We now apply correct shapes for content, and build-      shape trees correctly.-    + Make default placeholder type for template lookup.-    + Apply speaker notes to metadata slide if applicable.-    + Test for speaker notes after breaking header.-    + Correctly handle notes after section-title header.-      Previously, if notes came after a section-title header (ie, a level-1-      header in a slide-level=2 presentation), they would go on the next-      slide. This keeps them on the slide with the header.-    + Internal improvements.--  * ipynb writer:--    + Use format `ipynb` for raw cell where no format given.-      According to nbformat docs, this is supposed to render in every-      format.  We don't do that, but we at least preserve it as a raw-      block in markdown, so you can round-trip.-    + Consolidate adjacent raw blocks.  Sometimes pandoc creates two-      HTML blocks, e.g. one for the open tag and one for a close tag.-      If these aren't consolidated, only one will show up in output cell.-    + Fixed carry-over of nbformat from metadata.-    + Preserve `nbformat_minor` if it's given.  This helps with round-tripping.--  * LaTeX writer:--    + Avoid inadvertently creating ?` or !` ligatures (#5407).-      These are upside down ? and !, resp.-    + Fix footnotes in table caption and cells (#5367).  This fixes a-      bug wherein footnotes appeared in the wrong order, and with-      duplicate numbers, when in table captions and cells.-      We now use regular `\footnote` commands, even in the table-      caption and the minipages containing cells. Apparently-      longtable knows how to handle this.--  * HTML writer: Don't add data- prefix to RDFa attributes (#5403).--  * JATS writer: Ensure that plain strings go inside `<pub-id>` tag (#5397).--  * Markdown writer:--    + Better rendering of numbers (#5398).  If the number is integral,-      we render it as an integral not a float.-    + Proper rendering of empty map in YAML metadata (#5398).  Should-      be `{}`, not empty string.-    + Properly escape attributes in Markdown writer (#5369).-    + Be sure implicit figures work in list contexts (#5368).-      Previously they would sometimes not work: e.g., when they-      occured in final paragraphs in lists that were originally-      parsed as Plain and converted later using PlainToPara.--  * Docx writer: Use `w:br` without attributes for line breaks (#5377).-    We previously added the attribute `type="textWrapping"`, but-    this causes problems on Word Online.--  * LaTeX template (Andrew Dunning):--    + Ensure correct heading/table order (#5365).  Improve workaround-      (#1658) for tables following headings.  The new solution works whether-      or not the `indent` variable is enabled.-    + Remove `subparagraph` variable. The default is now to use run-in-      style for level 4 and 5 headings (`\paragraph` and `\subparagraph`).-      To get the previous default behavior (where these were formatted as-      blocks, like `\subsubsection`), set the `block-headings` variable.-    + Add pandoc to PDF metadata (#5388).-    + Group graphics-related code (#5389).-    + Move `\setstretch` after front matter (#5179).  Ensures that-      `\maketitle`, `\tableofcontents`, and so forth are not affected by-      changes to line spacing.--  * Update data/jats.csl to avoid commas between name-part elements-    (#5397).--  * Add support for golang (`go`) with `--listings` (#5427).--  * Text.Pandoc.Shared - improve `metaToJSON` behavior with numbers.-    We now do a better job marshalling numbers from MetaString-    or MetaInlines into JSON Number.--  * Text.Pandoc.Writers.Shared: `metaValueToJSON`: use Number Values for-    integers.  Pandoc's MetaValue doesn't have a distinguished number type,-    so numbers are put in MetaStrings.  If the MetaString consists-    entirely of digits, we convert it to a Number.  We should probably-    consider adding a MetaNumber constructor to MetaValue, for better-    round-tripping with JSON etc.  This change aids round-tripping in-    ipynb metadata fields, like `toc_depth`.--  * Text.Pandoc.Class: `fetchItem`: don't treat UNC paths as-    protocol-relative URLs (#5127).  These are paths beginning `//?/UNC/...`.--  * Text.Pandoc.ImageSize: Improve `pdfSize` so it handles-    a wider range of PDFs (#4322, with help from Richard Davis).--  * Text.Pandoc.Pretty: avoid stack overflow by using strict sum (#5401).--  * Fix harmless error in file-scope code (#5422).--  * MANUAL.txt:--    + Improve 'header' and 'heading' usage (#5423, Andrew-      Dunning).  The term 'header' was being used where 'heading'-      is more appropriate.-    + Add paragraph on options affecting markdown in ipynb.--  * stack.yaml - remove -Wmissing-home-modules-    This seems to cause problems with stack ghci.  Remove RTS options.--  * Add ghc-options to cabal.project.--  * appveyor.yml - use ghc 8.6.4.  Fixes segfault issues on Windows (#5037).--  * linux build process: Remove clone of pandoc-citeproc (#5366).-    It wasn't being used; cabal.project specifies the version to use.--pandoc (2.7.1)--  * Add tectonic as an option for --pdf-engine (#5345, Cormac Relf).-    Runs tectonic on STDIN instead of a temporary .tex file, so that it-    looks in the working directory for `\include` and `\input` like the rest-    of the engines.  Allows overriding the output directory-    args with `--pdf-engine-opt=--outdir --pdf-engine-opt="$DIR"`.--  * Allow `-o/--output` to be used with `--print-default-data-file`,-    `--print-highlighting-style`, `--print-default-template`.-    Note that `-o` must occur BEFORE the `--print*` command on the command-    line (this is documented, #5357).--  * LaTeX reader:--    + Support `\underline`, `\ul`, `\uline` (#5359, Paul-      Tilley).  These are parsed as a Span with class `underline`, as-      with other readers.-    + Ensure that `\Footcite` and `\Footcites` get put in a note.--  * ipynb reader:--    + Remove sensitivity to `raw_html`, `raw_tex` extensions.-      We now include every output format. Pruning is handled by-      `--ipynb-output`.-    + Better handling of cell metadata.  We now include even complex cell-      metadata in the Div's attributes (as JSON, in complex cases, or-      as plain strings in simple cases).--  * ipynb writer:--    + Recurse into native divs for output cell data (#5354).-    + Render cell metadata fields from div attributes.--  * Docx writer: avoid extra copy of abstractNum and num elements-    in numbering.xml.  This caused pandoc-produced docx files to-    be uneditable using Word Online (#5358).--  * Markdown writer: improve handling of raw blocks/inline.-    We now emit raw content using `raw_attribute` when no more-    direct method is available.  Use of `raw_attribute` can be-    forced by disabling `raw_html` and `raw_tex`.--  * LaTeX writer: Add classes for frontmatter support (#5353, Andrew Dunning)-    and remove frontmatter from `scrreprt`.--  * LaTeX template:--    + Improve readability (#5363, Andrew Dunning).-    + Robust section numbering removal (#5351, Andrew Dunning).-      Ensures that section numbering does not reappear with custom-      section levels.  See <https://tex.stackexchange.com/questions/473653/>.-    + Better handling of front/main/backmatter (#5348).-      In pandoc 2.7 we assumed that every class with chapters would accept-      `\frontmatter`, `\mainmatter`, and `\backmatter`.  This is not so (e.g.-      report does not).  So pandoc 2.7 breaks on report class by including an-      unsupported command.  Instead of the `book-class` variable, we use two-      variables, `has-chapters` and `has-frontmatter`, and set these-      intelligently in the writer.--  * Text.Pandoc.Shared: Improve `filterIpynbOutput`.  Ensure that-    images are prioritized over text. `best` should include everything-    for ipynb.--  * Tests.Old: specify `--data-dir=../data` to ensure tests can find-    data files even if they haven't been installed.  Remove old-    `pandoc_datadir` environment variable, which hasn't done anything for a-    long time.--  * MANUAL.txt: Add recommendation to use `raw_attribute` with ipynb (#5354).--  * Use cmark-gfm-hs 0.1.8 (note that 0.1.7 is buggy).--  * Use latest pandoc-citeproc, texmath.---pandoc (2.7)--  * Use XDG data directory for user data directory (#3582). Instead of-    `$HOME/.pandoc`, the default user data directory is now-    `$XDG_DATA_HOME/pandoc`, where `XDG_DATA_HOME` defaults to-    `$HOME/.local/share` but can be overridden by setting the-    environment variable. If this directory is missing, then-    `$HOME/.pandoc` is searched instead, for backwards compatibility.-    However, we recommend moving local pandoc data files from-    `$HOME/.pandoc` to `$HOME/.local/share/pandoc`. On Windows the-    default user data directory remains the same.--  * Slide show formats behavior change:  content under headers-    less than slide level is no longer ignored, but included in-    the title slide (for HTML slide shows) or in a slide after-    the title slide (for beamer).  This change makes possible-    2D reveal.js slideshows with content in the top slide on-    each stack (#4317, #5237).- -  * Add command line option `--ipynb-output=all|none|best` (#5339).-    Output cells in ipynb notebooks often contain several different-    versions of an output, with different MIME types, e.g. an HTML-    table and a plain-text fallback.  Specifying `--ipynb-output=best`-    (the default) ensures that the best version for the output format-    is used.  `all` includes all versions, and `none` suppresses them-    all, leaving output cells empty.--  * `asciidoctor` is now an output format separate from `asciidoc`,-    to accommodate some minor implementation-specific differences-    (currently just in the treatment of display math).--  * Add `latexmk` as an option for `--pdf-engine` (#3195).-    Note that you can use `--pdf-engine-opt=-outdir=bar` to specify-    a persistent temp directory.--  * Markdown reader:--    + Improve tight/loose list handling (#5285). Previously the-      algorithm allowed list items with a mix of Para and Plain, which-      is never wanted.-    + Add newline when parsing blocks in YAML (#5271). Otherwise last-      block gets parsed as a Plain rather than a Para. This is a-      regression in pandoc 2.x. This patch restores pandoc 1.19-      behavior.-    + Make `yamlToMeta` respect extensions (#5272, Mauro Bieg).-      This adds a `ReaderOptions` parameter to `yamlToMeta` [API change].-    + Fix bug parsing fenced code blocks (#5304). Previously parsing-      would break if the code block contained a string of backticks of-      sufficient length followed by something other than end of line.--  * LaTeX reader: don't let `\egroup` match `{`. `braced` now actually-    requires nested braces. Otherwise some legitimate command and-    environment definitions can break.--  * Docx reader (Jesse Rosenthal):--    + Rename `getDocumentPath` as `getDocumentXmlPath`.-    + Use field notation for setting `ReaderEnv`.-    + Figure out `document.xml` path once at the beginning of parsing, and-      add it to the environment, so we can avoid repeated lookups.-    + Dynamically determine main document xml path (#5277).-      The desktop Word program places the main document file in-      `word/document.xml`, but the online word places it in-      `word/document2.xml`. This file path is actually stated in the root-      `_rels/.rels` file, in the `Relationship` element with an-      `http://../officedocument` type.-    + Fix paths in archive to prevent Windows failure (#5277).-      Some paths in archives are absolute (have an opening slash) which, for-      reasons unknown, produces a failure in the test suite on MS-      Windows. This fixes that by removing the leading slash if it exists.-    + Add comments to aid code readability.-    + Trim space inside the last inline (#5273).-    + Unwrap sdt elements in footnotes and comments (#5302).--  * Muse reader (Alexander Krotov):--    + Test that block level markup does not break `<verbatim>`.-    + Add secondary note support.--  * ipynb reader: handle images referring to attachments. Previously-    we didn't strip off the attachment: prefix, so even though the-    attachment was available in the mediabag, pandoc couldn't find it.--  * JATS reader:--    + Fix parsing of figures (#5321). This ensures that a figure-      containing a single image is parsed as a pandoc "implicit-      figure" (i.e., a Para with a single Image whose title attribute-      begins with `fig:`). More complex figures will still be parsed-      as divs.-    + Support `fig-group` block element (#5317).-    + Handle citations with multiple references (#5310). The `rid`-      attribute can have a space-separated list of ids.--  * AsciiDoc Writer: Add `writeAsciiDoctor` [API change, Tarik Graba].-    Handle display math appropriately for Asciidoctor.--  * JATS writer: wrap figure caption in `<p>` to fix validation (#5290,-    Mauro Bieg).--  * HTML writer:--    + Implement WAI-ARIA roles for (end)notes, citations, and-      bibliography (#4213). Note that doc-biblioref is only used when-      link-citations produces links, since it belongs on links.-    + Include content (including speaker notes) in title slides-      (#4317, #5237).--  * ipynb writer:--    + Ensure final newline.-    + Only include metadata under `jupyter` field.-    + Don't create attachments for images with absolute URIs,-      including data: URIs (#5303).-    + Keep plain text fallbacks in output even if a richer format is-      included (#5293). We don't know what output format will be needed.-      See the `--ipynb-output` command line option for a way to control-      what formats are included in the output.--  * Markdown writer: use `markdown="1"` when appropriate for Divs:-    when `native_divs` and `markdown_in_html_blocks` are disabled-    but `raw_html` and `markdown_attribute` are enabled.--  * LaTeX writer:--    + Use right fold for `escapeString`.  This is more elegant than-      the explicit recursive code we were using.-    + Avoid `{}` after control sequences when escaping.-      `\ldots{}.` doesn't behave as well as `\ldots.` with the latex-      ellipsis package.  This patch causes pandoc to avoid emitting-      the `{}` when it is not necessary.  Now `\ldots` and other-      control sequences used in escaping will be followed by either-      a `{}`, a space, or nothing, depending on context.-    + For beamer, include contents under headers superordinate to-      slidelevel (#4317). Currently we keep the fancy title slide, and-      add a new slide with the same title and whatever content was-      under the header.--  * Powerpoint writer (Jesse Rosenthal): support underlines.-    Use span with single class "underline" as in docx writer.--  * Muse writer: escape secondary notes (Alexander Krotov).--  * FB2 writer: add section identifiers support (#5229, John KetzerX).--  * Make `--fail-if-warnings` work for PDF output (#5343).--  * Lua filters (Albert Krewinkel):--    + Load module `pandoc` before calling `init.lua` (#5287). The file-      `init.lua` in pandoc's data directory is run as part of pandoc's-      Lua initialization process. Previously, the `pandoc` module was-      loaded in `init.lua`, and the structure for marshaling was-      set up after. This allowed simple patching of element-      marshaling, but made using `init.lua` more difficult. Now, all-      required modules are now loaded before calling `init.lua`. The-      file can be used entirely for user customization. Patching-      marshaling functions, while discouraged, is still possible via-      the `debug` module.-    + All Lua modules bundled with pandoc, i.e., `pandoc.List`,-      `pandoc.mediabag`, `pandoc.utils`, and `text` are re-exported from the-      `pandoc` module. They are assigned to the fields `List`, `mediabag`,-      `utils`, and `text`, respectively.--  * Text.Pandoc.Lua (Albert Krewinkel):-  -    + Split `StackInstances` into smaller Marshaling modules.-    + Get `CommonState` from Lua global. This allows more control over-      the common state from within Lua scripts.--  * LaTeX template:--    + Support the `subject` metadata variable (#5289, Pascal Wagler).-    + Add `\frontmatter`, `\mainmatter`, `\backmatter`-      for book classes (#5306).--  * epub3 template: Add titlepage class to section (#5269).--  * HTML5 template: Add ARIA role `doc-toc` for table of contents (#4213).--  * Make `--metadata-file` use selected extensions (#5279, #5272, Mauro Bieg).--  * Text.Pandoc.Shared:--    + Remove `withTempDir` [API change].-    + Add new exported function `defaultUserDataDirs` [API change].-    + Add `filterIpynbOutput` [API change].-    + `compactify`: Avoid lists with a mix of Plain and Para elements-      (#5285).--  * Text.Pandoc.Translations: reorder alphabetically and remove `Author`-    (#5334, Mauro Bieg).--  * Text.Pandoc.Extensions:--    + More carefully groom ipynb default extensions.-    + Add `all_symbols_escapable` to `githubMarkdownExtensions`.--  * Text.Pandoc.PDF:--    + Use system temp directory when possible (#1192). Previously we-      created temp dirs in the working directory, partly (a) because-      there were problems using the system temp directory on Windows,-      when their pathnames included tildes, and partly (b) because-      programs like `epstopdf.pl` would not be allowed to write to-      directories outside the working directory in restricted mode. We-      now (a) use the system temp dir except when the path includes-      tildes, and (b) set `TEXMFOUTPUT` when creating the PDF, so that-      subsidiary programs can use the system temp directory. This-      addresses problems that occurred when pandoc was used in a-      synced directory (such as Dropbox).-    + Change types of subsidiary functions to PandocIO, to allow-      warnings to be threaded through (#5343).--  * Text.Pandoc.MIME: add WebP (#5267, Mauro Bieg).--  * Tests: avoid calling `findPandoc` multiple times.--  * Old tests: remove need for temp files by using `pipeProcess`.--  * Added simple ipynb reader/writer tests (#5274).--  * Rearrange `--help` output in a more rational way, with common-    options at the beginning and options grouped by function (#5336).--  * trypandoc: Add JATS and other missing formats (Arfon Smith, #5291).--  * Add missing copyright notices and remove license boilerplate (#4592,-    Albert Krewinkel).--  * Use latest basement/foundation on 32bit windows.--  * Use latest skylighting (#5328). Custom syntax definitions no-    longer try to load `language.dtd`.--  * Require texmath 0.11.2.1--  * Use latest pandoc-citeproc (0.16.1.1).--  * MANUAL.txt:--    + Clarify variable substitution indentation in templates (#5338,-      Agustín Martín Barbero).-    + Reorder custom-styles section (#5324, Mauro Bieg).--pandoc (2.6)--  * Support ipynb (Jupyter notebook) as input and output format.--    + Add `ipynb` as input and output format (extension `.ipynb`).-    + Added Text.Pandoc.Readers.Ipynb [API change].-    + Added Text.Pandoc.Writers.Ipynb [API change].-    + Add `PandocIpynbDecodingError` constructor to Text.Pandoc.Error.Error-      [API change].-    + Depend on ipynb library.-    + Note: there is no template for ipynb.--  * Add DokuWiki reader (#1792, Alexander Krotov).  This adds-    Text.Pandoc.Readers.DokuWiki [API change], and adds `dokuwiki`-    as an input format.--  * Implement task lists (#3051, Mauro Bieg). Added `task_lists`-    extension. Task lists are supported from markdown and gfm input.-    They should work, to some degree, in all output formats, though in-    most formats you'll get a bullet list with a unicode character for-    the box. In HTML, you get checkboxes and in LaTeX/PDF output, a-    box is used as the list marker. API changes:--    + Added constructor `Ext_task_lists` to `Extension`.-    + Added `taskListItemFromAscii` and `taskListItemToAscii` to-      Text.Pandoc.Shared.--  * Allow some command line options to take URL in addition to FILE.-    `--include-in-header`, `--include-before-body`, `--include-after-body`.--  * HTML reader:--    + Handle empty `start` attribute (see #5162).-    + Treat `textarea` as a verbatim environment (#5241) and preserve-      spacing.--  * RST reader:--    + Change treatment of `number-lines` directive (Brian Leung,-      #5207). Directives of this type without numeric inputs should-      not have a `startFrom` attribute; with a blank value, the-      writers can produce extra whitespace.-    + Removed superfluous `sourceCode` class on code blocks (#5047).-    + Handle `sourcecode` directive as synonynm for `code` (#5204).--  * Markdown reader:--    + Remove `sourceCode` class for literate Haskell code blocks-      (#5047). Reverse order of `literate` and `haskell` classes on-      code blocks when parsing literate Haskell, so `haskell` is-      first.-    + Treat `<textarea>` as a verbatim environment (#5241).--  * Org reader:--    + Handle `minlevel` option differently (#5190, Brian Leung).-      When `minlevel` exceeds the original minimum level observed in-      the file to be included, every heading should be shifted-      rightward.-    + Allow for case of `:minlevel == 0` (#5190).-    + Fix treatment of links to images (#5191, Albert Krewinkel).-      Links with descriptions which are pointing to images are no-      longer parsed as inline images, but as links.-    + Add support for #+SELECT_TAGS (Brian Leung).-    + Separate filtering logic from conversion function (Brian Leung).--  * TWiki reader: Fix performance issue with underscores (#3921).--  * MediaWiki reader: use `_` instead of `-` in auto-identifiers (#4731).-    We may not still be exactly matching mediawiki's algorithm.--  * LaTeX reader:--    + Remove `sourceCode` class for literate Haskell code blocks-      (#5047). Reverse order of `literate` and `haskell` classes on-      code blocks when parsing literate Haskell, so `haskell` is-      first.-    + Support `\DeclareMathOperator` (#5149).-    + Support `\inputminted` (#5103).-    + Support `\endinput` (#5233).-    + Allow includes with dots like `cc_by_4.0`.  Previously the `.0`-      was interpreted as a file extension, leading pandoc not to add-      `.tex` (and thus not to find the file).  The new behavior matches-      tex more closely.--  * Man reader:--    + Use `mapLeft` from Shared instead of defining own.--  * Docx reader (Jesse Rosenthal):--    + Handle level overrides (#5134).--  * Docx writer:--    + Support custom properties (#3024, #5252, Agustín Martín Barbero).-      Also supports additional core properties:  `subject`, `lang`,-      `category`, `description`.-    + Make Level into a real type, instead of an alias for a tuple-      (Jesse Rosenthal).--  * ICML writer (Mauro Bieg):--    + Support custom-styles (#5137, see #2106).-    + Support unnumbered headers (#5140).--  * Texinfo writer: Use header identifier for anchor if present (#4731).-    Previously we were overwriting an existing identifier with a new one.--  * Org writer: Preserve line-numbering for example and code blocks-    (Brian Leung).--  * Man/Ms writers: Don't escape `-` as `\-`. The `\-` gets rendered-    in HTML and PDF as a unicode minus sign.--  * Ms writer: Ensure we have a newline after .EN in disply math (#5251).--  * RST writer: Don't wrap simple table header lines (#5128).--  * Asciidoc writer: Shorter delimiters for tables, blockquotes-    (#4364). This matches asciidoctor reference docs.--  * Dokuwiki writer: Remove automatic `:` prefix before internal image-    links (#5183, Damien Clochard).  This prevented users from making-    relative image links.-- *  Zimwiki writer: remove automatic colon prefix before internal-    images (#5183, Damien Clochard).--  * MediaWiki writer: fix caption, use 'thumb' instead of 'frame'-    (#5105). Captions used to have the word 'caption' prepended; this-    has been removed. Also, 'thumb' is used instead of 'frame' to-    allow images to be resized.--  * reveal.js writer:--    + Ensure that we don't get > 2 levels of section nesting,-      even with slide level > 2 (#5168).-    + If slide level == N but there is no N-level header, make-      sure the next header with level > N gets treated as a slide-      and put in a section, rather than remaining loose (#5168).--  * Markdown writer:--    + Make `plain` RawBlocks pass through in `plain` output.-    + Include needed whitespace after HTML figure (#5121).-      We use HTML for a figure in markdown dialects that can't-      represent it natively.--  * Commonmark writer:--    + Fix handling of SoftBreak with `hard_line_breaks` (#5195).-    + Implement `--toc` (`writerTableOfContents`)-      in commonmark/gfm writers (#5172).--  * EPUB writer:--    + Ensure that picture transforms are done on metadata too.-    + Small fixes to `nav.xhtml`:-      Add 'landmarks' id attribute to the landmarks nav.-      Replace old default CSS removing numbers from ol.toc li-      with new rules that match `nav#toc ol, nav#landmarks ol`.-      We keep the `toc` class on `ol` for backwards compatibility.--  * LaTeX writer:--    + Make raw content marked `beamer` pass through in `beamer`-      output (pandoc/lua-filters#40).-    + Beamer: avoid duplicated `fragile` property in some cases-      (#5208).-    + Add `#` special characters for listings (#4939).-      This character needs special handling in `\lstinline`.-- *  RTF writer: use `toTableOfContents` from Shared to replace-    old duplicated code.--  * Pptx writer:--    + Support custom properties.  Also supports additional core-      properties: `subject`, `category`, `description` (#5252,-      Agustín Martín Barbero).-    + Use `toTableOfContents` from Shared to replace old duplicated code.--  * ODT writer (Augustín Martín Barbero):--    + Fix typo in custom properties (#2839).-    + Improve standard properties, including the following core-      properties: `generator` (Pandoc/VERSION), `description`, `subject`,-      `keywords`, `initial-creator` (from authors), `creation-date`-      (actual creation date) (#5252).--  * Custom writers:--    + Allow '-' in filenames for custom lua writers (#5187).-    + sample.lua: add `SingleQuoted`, `DoubleQuoted` (#5104).-    + sample.lua: Add a missing `>` (MichaWiedenmann).--  * reveal.js template:  Add `zoomKey` config (#4249).--  * HTML5 template: Remove unnecessary type="text/css" on style and-    link for HTML5 (#5146).--  * LaTeX template (Andrew Dunning, except where noted):--    + Prevent fontspec from scaling `mainfont` to match the default-      font, Latin Modern. A main font set to 12pt could-      previously appear between 11pt to 13pt depending on its design.-      To return to the earlier rendering, use `-V-      mainfontoptions="Scale=MatchLowercase"` (#5212, #5218).-    + Display monospaced fonts without TeX ligatures when using-      `--pdf-engine=lualatex`. It now matches the behaviour of other-      engines (#5212, #5218).-    + Remove the deprecated `romanfont` variable. The functionality of-      `mainfont` is identical (#5218).-    + Render `\subtitle` with the standard document classes.-      Previously, `subtitle` only appeared when using the KOMA-Script-      classes or Beamer (#5213, #5244).-    + Use Babel instead of Polyglossia for LuaLaTeX. This avoids-      several language selection problems, notably with retaining-      French spacing conventions when switching to a verbatim-      environment or another language; and in printing Greek text-      without hyphenation (#5193).-    + Use the [`xurl`](https://ctan.org/pkg/xurl) package if-      available, improving the appearance of URLs by allowing them to-      break at additional points (#5193).-    + Use [`bookmark`](https://ctan.org/pkg/bookmark) if available-      to correct heading levels in PDF bookmarks: see the [KOMA-Script-      3.26 release notes](https://komascript.de/release3.26) (#5193).-    + Require the [`xcolor`](https://ctan.org/pkg/xcolor) package to-      avoid a possible error when using additional packages alongside-      footnotes in tables (#5193, closes #4861).-    + Remove obsolete `fixltx2e` package, which has no functionality-      with TeX Live 2015 or later (#5193).-    + Allow multiple `fontfamilies.options` (#5193, closes #5194).-    + Restrict `institute` variable to Beamer (#5219).-    + Use [`footnotehyper`](https://ctan.org/pkg/footnotehyper)-      package if available to make footnotes in tables compatible-      with `hyperref` (#5234).-    + Number parts and chapters in book classes only if the-      `numbersections` variable is set, for consistency with other-      output formats. To return to the previous behaviour, use-      `-V numbersections -V secnumdepth=0` (#5235).-    + Reindent file (#5193).-    + Use built-in parskip handling with KOMA-Script classes (#5143, Enno).-    + Set default listings language for lua, assembler (#5227, John-      MacFarlane).  Otherwise we get an error when trying to compile code-      with lua or assembler code.  To change the default dialect-      (currenty 5.3 for lua and x86masm for assembler), you can use-      `--include-in-header` to inject something like-      `\lstset{defaultdialect=[5.2]Lua}`.--  * Text.Pandoc.Readers: Changed types of `readJSON`; it now runs-    in an instance of PandocMonad, like the other readers and-    writers.  [API change]--  * Text.Pandoc.Writers: Changed types of `writeJSON`; it now runs-    in an instance of PandocMonad, like the other readers and-    writers.  [API change] --  * Text.Pandoc.Error: Added `PandocUTF8DecodingError` constructor-    for `PandocError`. [API change]--  * Text.Pandoc.Writers.Shared - add `toTableOfContents`. [API change]-    This is refactored out from the Markdown writer.-    It can be used in other writers to create a table of contents.--  * Improve error messages for UTF-8 decoding errors. Now we give-    the filename and byte offset (#4765).--  * Text.Pandoc.XML: Strip out illegal XML characters in-    `escapeXMLString` (#5119).--  * Text.Pandoc.Process: update `pipeProcess` (Albert Krewinkel).-    The implementation of `pipeProcess` was rewritten to fix sporadic-    failures caused by prematurely closed pipes.--  * Use `safeRead` instead of `read` everywhere in the code-    (John MacFarlane, Mauro Bieg, #5162, #5180).--  * Text.Pandoc.SelfContained: Decompress `.svgz` when-    converting to `data:` URI (#5163, Alexander Krotov).--  * Text.Pandoc.Parsing: Remove unused `HasHeaderMap`-    (#5175, Alexander Krotov). [API change]--  * Normalize Windows paths to account for change in ghc 8.6 (#5127).-    When pandoc is compiled with ghc 8.6, Windows paths are treated-    differently, and paths beginning `\\server` no longer work.-    This commit rewrites such patsh to `\\?\UNC\server` which works.-    The change operates at the level of argument parsing, so it-    only affects the command line program.--  * Simplify/fix reading of `--metadata` values on command line-    to avoid problems relating to hvr/HsYAML#7 (#5177).--  * data/pandoc.lua: auto-fix nested constructor arguments (Albert-    Krewinkel).  Incorrect types to pandoc element constructors are-    automatically converted to the correct types when possible. This was-    already done for most constructors, but conversions are now also done-    for nested types (like lists of lists).--  * Removed custom Setup.hs, use build-type: simple. The only thing we-    gained from the custom build was automatic installation of the man-    page when using 'cabal install'. But custom builds cause problems,-    e.g., with cross-compilation. Installation of the man page is-    better handled by packagers. Note to packagers (e.g. Debian): it-    may be necessary to add a step installing the man page with the-    next release.--  * Allow latest http-client, tasty, zip-archive, Glob.--  * Require skylighting >= 0.7.5, adding support for sml, J,-    typescript.--   * Tests:  Cleaned up `findPandoc` in `Tests.Helpers`, so it-     works well with cabal v2.--  * INSTALL.md:--    + Use button for installer links (John MacFarlane, Mauro Bieg,-      #5167).-    + Fix links and bump required stack version (max).-    + Improve installation notes on associated software (Andrew-      Dunning). Includes explanation of how to install related tools-      with package managers (since the method of installing-      `rsvg-convert` is not obvious).--  * doc/org.md: improve documentation of org features (Albert-    Krewinkel).--  * doc/lua-filters.md:  use 3rd level headers for module fields.--  * MANUAL:--    + Clarify automatic identifiers (#5201). We remove-      non-alphanumerics. This includes, e.g., emojis.-    + Fix example for Div with id (Geoffrey Ely).-    + Update list of LaTeX packages used.-    + Make it clear that `hard_line_breaks` works in `gfm` (see #5195).-    + Mention `raw_attribute` in documentation for `raw_html` and-      `raw_tex` (#5240, thanks to @eiro).-    + Clarify that `$sep$` must come right before `$endfor$` in templates-      (#5243, Lev Givon).-    + Document metadata support for docx, odt, pptx writers (Agustín-      Martín Barbero).-    + Reorganize template variables (#5249, Andrew Dunning).-      Add additional headings to categorize variables, and-      alphabetize when there is large number; add more examples.-    + Document `date-meta` template variable (#5260, Tristan Stenner).--  * trypandoc: Fix CSS and viewport.--pandoc (2.5)--  * Text.Pandoc.App: split into several unexported submodules (Albert-    Krewinkel):  Text.Pandoc.App.FormatHeuristics,-    Text.Pandoc.App.Opt, Text.Pandoc.App.CommandLineOptions,-    Text.Pandoc.App.OutputSettings.  This is motivated partly by the-    desire to reduce recompilations when something is modified,-    since App previously depended on virtually every other module.--  * Text.Pandoc.Extensions--    + Semantically, `gfm_auto_identifiers` is now a modifier of-      `auto_identifiers`; for identifiers to be set, `auto_identifiers` must-      be turned on, and then the type of identifier produced depends on-      `gfm_auto_identifiers` and `ascii_identifiers` are set. Accordingly,-      `auto_identifiers` is now added to `githubMarkdownExtensions` (#5057).-    + Remove `ascii_identifiers` from `githubMarkdownExtensions`.-      GitHub doesn't seem to strip non-ascii characters any more.--  * Text.Pandoc.Lua.Module.Utils (Albert Krewinkel)--    + Test AST object equality via Haskell (#5092).  Equality of Lua-      objects representing pandoc AST elements is tested by unmarshalling-      the objects and comparing the result in Haskell.-      A new function `equals` which performs this test has been added to the-      `pandoc.utils` module.-    + Improve stringify.  Meta value strings (MetaString)-      and booleans (MetaBool) are now converted to the literal string and the-      lowercase boolean name, respectively. Previously, all values of these-      types were converted to the empty string.--  * Text.Pandoc.Parsing: Remove Functor and Applicative constraints where Monad-    already exists (Alexander Krotov).--  * Text.Pandoc.Pretty: Don't render BreakingSpace at end of line-    or beginning of line (#5050).--  * Text.Pandoc.Readers.Markdown--    + Fix parsing of citations, quotes, and underline emphasis-      after symbols.  Starting with pandoc 2.4, citations, quoted inlines,-      and underline emphasis were no longer recognized after certain-      symbols, like parentheses (#5099, #5053).-    + In pandoc 2.4, a soft break after an abbreviation would be-      relocated before it to allow for insertion of a nonbreaking-      space after the abbreviation. This behavior is here reverted.-      A soft break after an abbreviation will remain, and no nonbreaking-      space will be added. Those who care about this issue should take care not-      to end lines with an abbreviation, or to insert nonbreaking spaces-      manually.--  * Text.Pandoc.Readers.FB2: Do not throw error for unknown elements in-    `<body>` (Alexander Krotov).  Some libraries include custom elements-    in their FB2 files.--  * Text.Pandoc.Readers.HTML--    + Allow `tfoot` before body rows (#5079).-    + Parse `<small>` as a Span with class "small" (#5080).-    + Allow thead containing a row with `td` rather than `th` (#5014).--  * Text.Pandoc.Readers.LaTeX--    + Cleaned up handling of dimension arguments.  Allow decimal points,-      preceding space.-    + Don't allow arguments for verbatim, etc.-    + Allow space before bracketed options.-    + Allow optional arguments after `\\` in tables.-    + Improve parsing of `\tiny`, `\scriptsize`, etc.  Parse as raw,-      but know that these font changing commands take no arguments.--  * Text.Pandoc.Readers.Muse--    + Trim whitespace before parsing grid table cells (Alexander Krotov).-    + Add grid tables support (Alexander Krotov).--  * Text.Pandoc.Shared--    + For bibliography match Div with id `refs`, not class `references`.-      This was a mismatch between pandoc's docx, epub, latex, and markdown-      writers and the behavior of pandoc-citeproc, which actually looks for a-      div with id `refs` rather than one with class `references`.-    + Exactly match GitHub's identifier generating algorithm (#5057).-    + Add parameter for `Extensions` to `uniqueIdent` and-      `inlineListToIdentifier` (#5057).  [API change]-      This allows these functions to be sensitive to the settings of-      `Ext_gfm_auto_identifiers` and `Ext_ascii_identifiers`, and allows us to-      use `uniqueIdent` in the CommonMark reader, replacing custom code.  It-      also means that `gfm_auto_identifiers` can now be used in all formats.--  * Text.Pandoc.Writers.AsciiDoc--    + Use `.`+ as list markers to support nested ordered lists (#5087).-    + Support list number styles (#5089).-    + Render Spans using `[#id .class]#contents#` (#5080).--  * Text.Pandoc.Writers.CommonMark--    + Respect `--ascii` (#5043, quasicomputational).-    + Make sure `--ascii` affects quotes, super/subscript.--  * Text.Pandoc.Writers.Docx--    + Fix bookmarks to headers with long titles (#5091).-      Word has a 40 character limit for bookmark names.  In addition, bookmarks-      must begin with a letter.  Since pandoc's auto-generated identifiers may-      not respect these constraints, some internal links did not work.  With-      this change, pandoc uses a bookmark name based on the SHA1 hash of the-      identifier when the identifier isn't a legal bookmark name.-    + Add bookmarks to code blocks (Nikolay Yakimov).-    + Add bookmarks to images (Nikolay Yakimov).-    + Refactor common bookmark creation code into a function (Nikolay Yakimov).--  * Text.Pandoc.Writers.EPUB: Handle calibre metadata (#5098).-    Nodes of the form--          <meta name="calibre:series" content="Classics on War and Politics"/>--      are now included from an epub XML metadata file.  You can also include-      this information in your YAML metadata, like so:--          calibre:-           series: Classics on War and Policitics--      In addition, ibooks-specific metadata can now be included via an XML-      file. (Previously, it could only be included via YAML metadata, see-      #2693.)--  * Text.Pandoc.Writers.HTML: Use plain `"` instead of `&quot;` outside of-    attributes.--  * Text.Pandoc.Writers.ICML: Consolidate adjacent strings, inc. spaces.-    This avoids splitting up the output unnecessarily into separate elements.--  * Text.Pandoc.Writers.LaTeX: Don't emit `[<+->]` unless beamer output, even-    if `writerIncremental` is True (#5072).--  * Text.Pandoc.Writers.Muse (Alexander Krotov).--    + Output tables as grid tables if they have multi-line cells.-    + Indent simple tables only on the top level.-    + Output tables with one column as grid tables.-    + Add support for `--reference-location`.-    + Internal improvements.--  * Text.Pandoc.Writers.OpenDocument: Fix list indentation (Nils Carlson,-    #5095).  This was a regression in pandoc 2.4.--  * Text.Pandoc.Writers.RTF: Fix warnings for skipped raw inlines.--  * Text.Pandoc.Writers.Texinfo: Add blank line before `@menu` section (#5055).--  * Text.Pandoc.XML: in `toHtml5Entities`, prefer shorter entities-    when there are several choices for a particular character.--  * data/abbreviations--    + Add additional abbreviations (Andrew Dunning)-      Many of these borrowed from the Chicago Manual of Style 10.42,-      'Scholarly abbreviations'.--  * Templates--    + Asciidoc template:  add :lang: to title header is lang is set in-      metadata (#5088).--  * pandoc.cabal: Add cabal flag `derive_json_via_th` (Albert Krewinkel)-    Disabling the flag will cause derivation of ToJSON and FromJSON-    instances via GHC Generics instead of Template Haskell. The flag is-    enabled by default, as deriving via Generics can be slow (see #4083).--  * trypandoc:--    + Tweaked drop-down lists.-    + Put link to site in footer.-    + Preselect output format.-    + Update on change of in or out format.-    + Add man input format.--  * MANUAL.txt:--    + Fix outdated description of latex_macros extension.-    + Clarified placement of bibliography.-    + Added "A note on security."-    + Fix note on curly brace syntx for locators.-    + Document new explicit syntax for citeproc locators.-    + Remove confusing cross-links for some extensions.-    + Don't put pandoc in code ticks in heading.-    + Document that `--ascii` works for gfm and commonmark too.-    + Add `man` to `--from` options.--  * doc/customizing-pandoc.md: various improvements (Mauro Bieg).---pandoc (2.4)--  [new features]--  * New input format `man` (Yan Pashkovsky, John MacFarlane).--  [behavior changes]--  * `--ascii` is now implemented in the writers, not in Text.Pandoc.App,-    via the new `writerPreferAscii` field in `WriterOptions`.-    Now the `write*` functions for Docbook, HTML, ICML, JATS, LaTeX,-    Ms, Markdown, and OPML are sensitive to `writerPreferAscii`.-    Previously the to-ascii translation was done in Text.Pandoc.App,-    and thus not available to those using the writer functions-    directly.--  * `--ascii` now works with Markdown output.  HTML5 character reference-    entities are used.--  * `--ascii` now works with LaTeX output. 100% ASCII output can't be-    guaranteed, but the writer will use commands like `\"{a}` and `\l`-    whenever possible, to avoid emiting a non-ASCII character.--  * For HTML5 output, `--ascii` now uses HTML5 character reference-    entities rather than numerical entities.--  * Improved detection of format based on extension (in Text.Pandoc.App).-    We now ensure that if someone tries to convert a file for a-    format that has a pandoc writer but not a reader, it won't just-    default to markdown.--  * Add viz. to abbreviations file (#5007, Nick Fleisher).--  * AsciiDoc writer:  always use single-line section headers,-    instead of the old underline style (#5038).  Previously the single-line-    style would be used if `--atx-headers` was specified, but-    now it is always used.--  * RST writer: Use simple tables when possible (#4750).--  * CommonMark (and gfm) writer: Add plain text fallbacks. (#4528,-    quasicomputational). Previously, the writer would unconditionally-    emit HTML output for subscripts, superscripts, strikeouts (if the-    strikeout extension is disabled) and small caps, even with-    `raw_html` disabled. Now there are plain-text (and, where-    possible, fancy Unicode) fallbacks for all of these corresponding-    (mostly) to the Markdown fallbacks, and the HTML output is only-    used when `raw_html` is enabled.--  * Powerpoint writer: support raw openxml (Jesse Rosenthal, #4976).-    This allows raw openxml blocks and inlines to be used in the pptx -    writer. Caveats: (1) It's up to the user to write-    well-formed openxml. The chances for corruption, especially with-    such a brittle format as pptx, is high. (2) Because of-    the tricky way that blocks map onto shapes, if you are using-    a raw block, it should be the only block on a slide-    (otherwise other text might end up overlapping it). (3) The-    pptx ooxml namespace abbreviations are different from the-    docx ooxml namespaces. Again, it's up to the user to get it-    right. Unzipped document and ooxml specification should be-    consulted.--  * With `--katex` in HTML formats, do not use the autorenderer (#4946).-    We no longer surround formulas with `\(..\)` or `\[..\]`. Instead,-    we tell katex to convert the contents of span elements with-    class "math". Since math has already been identified, this-    avoids wasted time parsing for LaTeX delimiters. Note, however,-    that this may yield unexpected results if you have span elements-    with class "math" that don't contain LaTeX math.-    Also, use latest version of KaTeX by default (0.9.0).--  * The man writer now produces ASCII-only output, using groff escapes,-    for portability.--  * ODT writer:--    + Add title, author and date to metadata; any remaining-      metadata fields are added as `meta:user-defined` tags.-    + Implement table caption numbering (#4949, Nils Carlson).-      Captioned tables are numbered and labeled with format "Table 1:-      caption", where "Table" is replaced by a translation, depending-      on the value of `lang` in metadata. Uncaptioned tables are not-      enumerated.-    + OpenDocument writer: Implement figure numbering in captions (#4944,-      Nils Carlson). Figure captions are now numbered 1, 2, 3, ...-      The format in the caption is "Figure 1: caption" and so on-      (where "Figure" is replaced by a translation, depending on the-      value of `lang` in the metadata). Captioned figures are numbered-      consecutively and uncaptioned figures are not enumerated. This-      is necessary in order for LibreOffice to generate an-      Illustration Index (Table of Figures) for included figures.--  * RST reader: Pass through fields in unknown directives as div attributes-    (#4715). Support `class` and `name` attributes for all directives.--  * Org reader: Add partial support for `#+EXCLUDE_TAGS` option. (#4284,-    Brian Leung). Headers with the corresponding tags should not-    appear in the output.--  * Log warnings about missing title attributes now include a-    suggestion about how to fix the problem (#4909).--  * Lua filter changes (Albert Krewinkel):--    + Report traceback when an error occurs. A proper Lua traceback is-      added if either loading of a file or execution of a filter-      function fails. This should be of help to authors of Lua filters-      who need to debug their code.--    + Allow access to pandoc state (#5015). Lua filters and custom-      writers now have read-only access to most fields of pandoc's-      internal state via the global variable `PANDOC_STATE`.--    + Push ListAttributes via constructor (Albert Krewinkel).-      This ensures that ListAttributes, as present in OrderedList elements,-      have additional accessors (viz. `start`, `style`, and `delimiter`).--    + Rename ReaderOptions fields, use snake_case. Snake case is used-      in most variable names, using camelCase for these fields was an-      oversight. A metatable is added to ensure that the old field-      names remain functional.--    + Iterate over AST element fields when using `pairs`. This makes-      it possible to iterate over all ield names of an AST element by-      using a generic `for` loop with pairs`:--          for field_name, field_content in pairs(element) do-          ... -          end--      Raw table fields of AST elements should be considered an-      implementation detail and might change in the future. Accessing-      element properties should always happen through the fields-      listed in the Lua filter docs.--      Note that the iterator currently excludes the `t`/`tag` field.--    + Ensure that MetaList elements behave like Lists. Methods usable-      on Lists can also be used on MetaList objects.--    + Fix MetaList constructor (Albert Krewinkel). Passing a MetaList-      object to the constructor `pandoc.MetaList` now returns the-      passed list as a MetaList. This is consistent with the-      constructor behavior when passed an (untagged) list.--  * Custom writers: Custom writers have access to the global variable-    `PANDOC_DOCUMENT`(Albert Krewinkel, #4957). The variable contains-    a userdata wrapper around the full pandoc AST and exposes two-    fields, `meta` and `blocks`. The field content is only-    marshaled on-demand, performance of scripts not accessing the-    fields remains unaffected.--  [API changes]--  * Text.Pandoc.Options: add `writerPreferAscii` to `WriterOptions`.--  * Text.Pandoc.Shared:--    + Export `splitSentences`. This was previously duplicated in the Man and-      Ms writers.-    + Add `ToString` typeclass (Alexander Krotov).--  * New exported module Text.Pandoc.Filter (Albert Krewinkel).--  * Text.Pandoc.Parsing--    + Generalize `gridTableWith` to any `Char` Stream (Alexander Krotov).-    + Generalize `readWithM` from `[Char]` to any `Char` Stream-      that is a `ToString` instance (Alexander Krotov).--  * New exposed module Text.Pandoc.Filter (Albert Krewinkel).--  * Text.Pandoc.XML: add `toHtml5Entities`.--  * New exported module Text.Pandoc.Readers.Man (Yan Pashkovsky, John-    MacFarlane).--  * Text.Pandoc.Writers.Shared--    + Add exported functions `toSuperscript` and-      `toSubscript` (quasicomputational, #4528).-    + Remove exported functions `metaValueToInlines`,-      `metaValueToString`. Add new exported functions-      `lookupMetaBool`, `lookupMetaBlocks`, `lookupMetaInlines`,-      `lookupMetaString`. Use these whenever possible for uniformity-      in writers (Mauro Bieg, #4907). (Note that-      removed function `metaValueToInlines` was in previous-      released versions.)-    + Add `metaValueToString`.--  * Text.Pandoc.Lua--    + Expose more useful internals (Albert Krewinkel):--      - `runFilterFile` to run a Lua filter from file;-      - data type `Global` and its constructors; and-      - `setGlobals` to add globals to a Lua environment.--      This module also contains `Pushable` and `Peekable` instances-      required to get pandoc's data types to and from Lua. Low-level-      Lua operation remain hidden in Text.Pandoc.Lua.--    + Rename `runPandocLua` to `runLua` (Albert Krewinkel).--    + Remove `runLuaFilter`, merging this into Text.Pandoc.Filter.Lua's-      `apply` (Albert Krewinkel).--  [bug fixes and under-the-hood improvements]--  * Text.Pandoc.Parsing--    + Make `uri` accept any stream with Char tokens (Alexander Krotov).-    + Rewrite `uri` without `withRaw` (Alexander Krotov).-    + Generalize `parseFromString` and `parseFromString'` to any-      streams with Char token (Alexander Krotov)-    + Rewrite `nonspaceChar` using `noneOf` (Alexander Krotov)--  * Text.Pandoc.Shared: Reimplement `mapLeft` using `Bifunctor.first`-    (Alexander Krotov).--  * Text.Pandoc.Pretty: Simplify `Text.Pandoc.Pretty.offset`-    (Alexander Krotov).--  * Text.Pandoc.App--    + Work around HXT limitation for --syntax-definition with windows-      drive (#4836).-    + Always preserve tabs for man format. We need it for tables.-    + Split command line parsing code into a separate unexported-      module, Text.Pandoc.App.CommandLineOptions (Albert Krewinkel).--  * Text.Pandoc.Readers.Roff: new unexported module for tokenizing-    roff documents.--  * New unexported module Text.Pandoc.RoffChar, provided character-    escape tables for roff formats.--  * Text.Pandoc.Readers.HTML: Fix `htmlTag` and `isInlineTag` to-    accept processing instructions (#3123, regression since 2.0).--  * Text.Pandoc.Readers.JATS: Use `foldl'` instead of `maximum` to-    account for empty lists (Alexander Krotov).--  * Text.Pandoc.Readers.RST: Don't allow single-dash separator in-    headerless table (#4382).--  * Text.Pandoc.Readers.Org: Parse empty argument array in inline src-    blocks (Brian Leung).--  * Text.Pandoc.Readers.Vimwiki:--    + Get rid of `F`, `runF` and `stateMeta'` in favor of `stateMeta`-      (Alexander Krotov).-    + Parse `Text` without converting to `[Char]` (Alexander Krotov).--  * Text.Pandoc.Readers.Creole: Parse `Text` without converting to-    `[Char]` (Alexander Krotov).--  * Text.Pandoc.Readers.LaTeX--    + Allow space at end of math after `\` (#5010).-    + Add support for `nolinkurl` command (#4992, Brian Leung).-    + Simplified type on `doMacros'`.-    + Tokenize before pulling tokens, rather than after (#4408). This-      has some performance penalty but is more reliable.-    + Make macroDef polymorphic and allow in inline context.-      Otherwise we can't parse something like `\lowercase{\def\x{Foo}}`.-     I have actually seen tex like this in the wild.-    + Improved parsing of `\def`, `\let`. We now correctly parse:-      ```-      \def\bar{hello}-      \let\fooi\bar-      \def\fooii{\bar}-      \fooi +\fooii--      \def\bar{goodbye}-      \fooi +\fooii-      ```-    + Improve parsing of `\def` argspec.-    + Skip `\PackageError` commands (see #4408).-    + Fix bugs omitting raw tex (#4527). The default is `-raw_tex`,-      so no raw tex should result unless we explicitly say `+raw_tex`.-      Previously some raw commands did make it through.-    + Moved `isArgTok` to Text.Pandoc.Readers.LaTeX.Parsing.-    + Moved `babelLangToBCP`, `polyglossiaLangToBCP` to new module,-      Text.Pandoc.Readers.LaTeX.Lang (unexported).-    + Simplified accent code using unicode-transforms.-      New dependency on unicode-transforms package for normalization.-    + Allow verbatim blocks ending with blank lines (#4624).-    + Support `breq` math environments: `dmath`, `dgroup`, `darray`.-      This collects some of the general-purpose code from the LaTeX reader,-      with the aim of making the module smaller.--  * Text.Pandoc.Readers.Markdown--    + Fix awkward soft break movements before abbreviations (#4635).-    + Add updateStrPos in a couple places where needed.--  * Text.Pandoc.Readers.Docx: Trigger bold/italic with bCs, iCs-    (#4947). These are variants for "complex scripts" like Arabic-    and are now treated just like b, i (bold, italic).--  * Text.Pandoc.Readers.Muse (Alexander Krotov)--    + Try to parse lists before trying to parse table.-      This ensures that tables inside lists are parsed correctly.-    + Forbid whitespace after opening and before closing markup-      elements.-    + Parse page breaks.-    + Simplify `museToPandocTable` to get rid of partial functions.-    + Allow footnotes to start with empty line.-    + Make sure that the whole text is parsed.-    + Allow empty headers. Previously empty headers caused parser to-      terminate without parsing the rest of the document.-    + Allow examples to be indented with tabs.-    + Remove indentation from examples indicated by `{{{` and `}}}`.-    + Fix parsing of empty cells.-    + Various changes to internals.-    + Rewrite some parsers in applicative style.-    + Avoid tagsoup dependency.-    + Allow table caption to contain `+`.--  * Text.Pandoc.Writers.LaTeX--    + Add newline if math ends in a comment (#4880). This prevents the-      closing delimiter from being swalled up in the comment.-    + With `--listings`, don't pass through org-babel attributes (#4889).-    + With `--biblatex`, use `\autocite` when possible (#4960).-      `\autocites{a1}{a2}{a3}` will not collapse the entries. So, if-      we don't have prefixes and suffixes, we use instead-      `\autocite{a1,a2,a3}`.-    + Fix description lists contining highlighted code (#4662).--  * Text.Pandoc.Writers.Man--    + Don't wrap `.SH` and `.SS` lines (#5019).-    + Avoid unnecessary `.RS`/`.RE` pair in definition lists with-      one paragraph definitions.-    + Moved common groff functions to Text.Pandoc.Writers.Groff.-    * Fix strong/code combination on man (should be `\f[CB]` not-      `\f[BC]`, see #4973).-    + Man writer: use `\f[R]` instead of `\f[]` to reset font-      (Alexander Krotov, #4973).-    + Move `splitSentences` to Text.Pandoc.Shared.--  * Text.Pandoc.Writers.Docx--    + Add framework for custom properties (#3034). So far, we don't-      actually write any custom properties, but we have the-      infrastructure to add this.--    + Handle tables in table cells (#4953). Although this is not-      documented in the spec, some versions of Word require a `w:p`-      element inside every table cell. Thus, we add one when the-      contents of a cell do not already include one (e.g. when a table-      cell contains a table).--  * Text.Pandoc.Writers.AsciiDoc:  Prevent illegal nestings.-    Adjust header levels so that n+1 level headers are only-    found under n level headers, and the top level is 1.--  * Text.Pandoc.Writers.OpenDocument: Improve bullet/numbering-    alignment (#4385). This change eliminates the large gap we used-    to have between bullet and text, and also ensures that numbers-    in numbered lists will be right-aligned.--  * Text.Pandoc.Writers.ZimWiki--    + Number ordered list items sequentially, rather than always-      with 1 (#4962).-    + Remove extra indentation on lists (#4963).--  * Text.Pandoc.Writers.EPUB: Use metadata field `css` instead of-    `stylesheet` (Mauro Bieg, #4990).--  * Text.Pandoc.Writers.Markdown: Ensure blank between raw block and-    normal content (#4629). Otherwise a raw block can prevent a-    paragraph from being recognized as such.--  * Text.Pandoc.Writers.Ms--    + Removed old `escapeBar`. We don't need this now that we use-      `@` for math delim.-    + Moved common code to Text.Pandoc.Writers.Roff and to-      Text.Pandoc.RoffChar.-    + Move `splitSentences` to Text.Pandoc.Shared (to avoid duplication-      with the man writer).--   * Text.Pandoc.Writers.Muse (Alexander Krotov).--    + Add support for grid tables.-    + Fix Muse writer style.-    + Use `length` instead of `realLength` to calculate definition-      indentation. Muse parsers don't take character width into-      account when calculating indentation.-    + Do not insert newline before lists.-    + Use lightweight markup after `</em>` tag.--  * New unexported module Text.Pandoc.Writers.Roff, providing functions-    useful for all roff format writers (man, ms).--  * Text.Pandoc.Lua--    + Move globals handling to separate module Text.Pandoc.Lua.Global-      (Albert Krewinkel).--    + Lua filter internals: push Shared.Element as userdata (Albert-      Krewinkel). Hierarchical Elements were pushed to Lua as plain-      tables. This is simple, but has the disadvantage that marshaling-      is eager: all child elements will be marshaled as part of the-      object. Using a Lua userdata object instead allows lazy access-      to fields, causing content marshaling just (but also each time)-      when a field is accessed. Filters which do not traverse the full-      element contents tree become faster as a result.--  [default template changes]--  * LaTeX template:--    + Add variable `hyperrefoptions` (#4925, Mathias Walter).-    + Add variable `romanfont`, `romanfontoptions` (#4665, OvidiusCicero).--  * AsciiDoc template: use single-line style for title.--  * revealjs template: Fix typo in the socket.io javascript plugin (#5006,-    Yoan Blanc).--  * Text.Pandoc.Lua.Util: add missing docstring to `defineHowTo`-    (Albert Krewinkel).--  * data/pandoc.lua: add datatype ListAttributes (Albert Krewinkel)--  * data/sample.lua: replace custom pipe function with pandoc.utils.pipe-    (Albert Krewinkel).--  [documentation improvements]--  * INSTALL.md--    + Add chromeos install instructions (#4958) (Evan Pratten).-    + Add note about TinyTeX.--  * MANUAL.txt--    + Change `groff` -> `roff`.-    + Implement `--ascii` for Markdown writer.-    + Clarify LaTeX image dimensions output (Mauro Bieg).--  * doc/customizing-pandoc.md: added skeleton (Mauro Bieg, #3288).--  * doc/getting-started.md: Added title to test1.md to avoid warning.--  * doc/lua-filters.md: merge type references into main document,-    fix description of Code.text (Albert Krewinkel).--  [build infrastructure improvements]--  * Makefile--    + Makefile: added quick-cabal, full-cabal targets.-    + Make .msi download targets insensitive to order of appveyor builds.--  * Update benchmarks for ghc 8.6.1.--   * pandoc.cabal:--    + Enable more compiler warnings (Albert Krewinkel).-    + Make base lower bound 4.8.-    + Bump upper bound for QuickCheck.-    + Bump upper bound for binary.-    + Updated version bounds for containers and haddock-library (#4974).-    + Added docx/docPropos/custom.xml to cabal data-files.-    + Require skylighting 0.7.4 (#4920).-    + New dependency on unicode-transforms package for normalization.--  * Improved .travis.yml testing and test with GHC 8.6.1 (Albert Krewinkel).--  * Added `tools/changelog-helper.sh`.--  * Added test/grofftest.sh for testing the man reader on real man pages.--pandoc (2.3.1)--  * RST reader:--    + Parse RST inlines containing newlines (#4912, Francesco Occhipinti).-      This eliminates a regression introduced after pandoc 2.1.1, which-      caused inline constructions containing newlines not to be recognized.-    + Fix bug with internal link targets (#4919).  They were gobbling up-      indented content underneath.--  * Markdown reader: distinguish autolinks in the AST.  With this change,-    autolinks are parsed as Links with the `uri` class. (The same is true-    for bare links, if the `autolink_bare_uris` extension is enabled.)-    Email autolinks are parsed as Links with the `email` class.  This-    allows the distinction to be represented in the AST.--  * Org reader:--    + Force inline code blocks to honor export options (Brian Leung).-    + Parse empty argument array in inline src blocks (Brian Leung).--  * Muse reader (Alexander Krotov):--    + Added additional tests.-    + Do not allow code markup to be followed by digit.-    + Remove heading level limit.-    + Simplify `<literal>` tag parsers-    + Parse Text instead of String. Benchmark shows 7% improvement.-    + Get rid of HTML parser dependency.-    + Various code improvements.--  * ConTeXt writer: change `\` to `/` in Windows image paths (#4918).-    We do this in the LaTeX writer, and it avoids problems.-    Note that `/` works as a LaTeX path separator on Windows.--  * LaTeX writer:--    + Add support for multiprenote and multipostnote arguments-      with `--biblatex` (Brian Leung, #4930).  The multiprenotes occur before-      the first prefix of a multicite, and the multipostnotes follow the-      last suffix.-    + Fix a use of `last` that might take empty list.  If you ran with-      `--biblatex` and have an empty document (metadata but no blocks),-      pandoc would previously raise an error because of the use of-      `last` on an empty list.--  * RTF writer: Fix build failure with ghc-8.6.1 caused by missing-    MonadFail instance (Jonas Scholl).--  * ODT Writer: Improve table header row style handling (Nils Carlson).-    This changes the way styles for cells in the header row-    and normal rows are handled in ODT tables.-    Previously a new (but identical) style was generated for-    every table, specifying the style of the cells within the table.-    After this change there are two style definitions for table cells,-    one for the cells in the header row, one for all other cells.-    This doesn't change the actual styles, but makes post-processing-    changes to the table styles much simpler as it is no longer-    necessary to introduce new styles for header rows and there are-    now only two styles where there was previously one per table.--  * HTML writer:--    + Don't add `uri` class to presumed autolinks.  Formerly the `uri`-      class was added to autolinks by the HTML writer, but it had to-      guess what was an autolink and could not distinguish-      `[http://example.com](http://example.com)` from-      `<http://example.com>`.  It also incorrectly recognized-      `[pandoc](pandoc)` as an autolink.  Now the HTML writer-      simply passes through the `uri` attribute if it is present,-      but does not add anything.-    + Avoid adding extra section nestings for revealjs.-      Previously revealjs title slides at level (slidelevel - 1)-      were nested under an extra section element, even when-      the section contained no additional (vertical) content.-      That caused problems for some transition effects.-    + Omit unknown attributes in EPUB2 output.  For example,-      `epub:type` attributes should not be passed through,-      or the epub produced will not validate.--  * JATS writer: remove 'role' attribute on 'bold' and 'sc' elements (#4937).-    The JATS spec does not allow these.--  * Textile writer: don't represent `uri` class explicitly-    for autolinks (#4913).--  * Lua filters (Albert Krewinkel):--    + Cleanup filter execution code.-    + Better error on test failure.--  * HTML, Muse reader tests: reduce time taken by round-trip test.--  * Added cabal.project.--  * MANUAL: `epub:type` is only useful for epub3 (Maura Bieg).--  * Use hslua v1.0.0 (Albert Krewinkel).--  * Fix `translations/ru` to use modern Russian orthography-    (Ivan Trubach).--  * Build Windows binary using ghc 8.6.1 and cabal new-build. This-    fixes issues with segfaults in the 32-bit Windows binaries (#4283).--pandoc (2.3)--  * Add `--metadata-file` option (Mauro Bieg, #1960), which allows-    users to specify metadata in a YAML file, regardless of the-    input format (#1960).--  * Text.Pandoc.Writers.Shared: export `isDisplayMath` (API change).--  * Text.Pandoc.Readers.Markdown: export `yamlToMeta` (API change,-    Mauro Bieg).--  * Text.Pandoc.Readers.LaTeX.Types:--    + New type `ArgSpec` (API change).-    + Second parameter of `Macro` constructor is now `[ArgSpec]` instead of-      `Int` (API change).--  * Markdown reader:--    + Use `tex` instead of `latex` for raw tex-ish content. We can't-      always tell if it's LaTeX, ConTeXt, or plain TeX. Better just to-      use `tex` always. Note that if `context` or `latex` specifically-      is desired, you can still force that in a markdown document by-      using the raw attribute. Note that this change may affect some-      filters, if they assume that raw tex parsed by the Markdown reader-      will be RawBlock (Format `latex`). In most cases it should be-      trivial to modify the filters to accept `tex` as well.-    + Refactor and reorganize YAML code (Mauro Bieg).-    + Make `example_lists` work for interrupted lists-      without `startnum` (#4908).--  * HTML reader:--    + Parse `<script type="math/tex` tags as math (#4877).-      These are used by MathJax in some configurations.-    + Extract spaces inside links instead of trimming them-      (Alexander Krotov, #4845).-    + Added round-trip tests (Alexander Krotov).-    + Make parsing sensitive to the `raw_tex` extension (#1126). This now-      allows raw LaTeX environments, `\ref`, and `\eqref` to be parsed-      (which is helpful for translation HTML documents using MathJaX).--  * Org reader (Albert Krewinkel):--    + Respect export option `p` for planning info.  Inclusion of planning info-      (`*DEADLINE*`, `*SCHEDULED*`, and `*CLOSED*`) can be controlled via the-      `p` export option: setting the option to `t` will add all planning-      information in a *Plain* block below the respective headline.-    + Org reader internals: don't rely on RecordWildCards and ViewPatterns-      ghc extensions.-    + Strip planning info from output.  Planning info is parsed, but not-      included in the output (as is the default with Emacs Org-mode, #4867).--  * LaTeX reader:--    + Split some general-purpose definitions into a separate, unexported-      module, Text.Pandoc.Readers.LaTeX.Parsing.  This is to avoid-      out-of-memory errors compiling the LaTeX reader.-    + Handle parameter patterns for `\def` (#4768, #4771).-      For example:  `\def\foo#1[#2]{#1 and #2}`.-    + Allow `%` characters in URLs. This affects `\href` and `\url` (#4832).-    + Fixed parsing of `\texorpdfstring`. We were returning the wrong-      argument as the content.-    + Support `blockcquote`, `foreignblockquote`, `foreigncblockquote`,-      `hyphenblockquote`, `hyphencblockquote`, `enquote*`, `foreignquote`,-      `hyphenquote` from `csquotes` (#4848). Note that `foreignquote`-      will be parsed as a regular Quoted inline (not using the quotes-      appropriate to the foreign language).-    + Support more text-mode accents (#4652). Add support for `\|`, `\b`, `\G`,-      `\h`, `\d`, `\f`, `\r`, `\t`, `\U`, `\i`, `\j`, `\newtie`,-      `\textcircled`. Also fall back to combining characters when composed-      characters are not available.-    + Resolve `\ref` for figure numbers.-    + Support `mintinline` (#4365, Marc Schreiber).-    + Fix siunitx unit commands so they are only recognized in-      siunitx contexts (#4842). For example, `\l` outside of an-      siunitx context should be l-slash, not l (for liter).-    + Fix double `unnumbered` class (#4838). The `unnumbered` class-      was being included twice for starred sections.--  * RST reader: Don't skip link definitions after comments (#4860).--  * Muse reader (Alexander Krotov):--    + Close the `</quote>` in indented tag test.-      There is already a separate test for unclosed `</quote>`.-    + Autonumber sections in the correct order.  Parsing now stops-      at each section header to ensure the header is registered before-      parsing of the next section starts.-    + Move duplicate code into `headingStart` function.-    + Allow newline after opening `*` or `**`.-    + Don't allow digits after closing marker in lightweight markup-      This change makes reader more compatible with Emacs Muse.-    + Parse `<verse>` tag in one pass instead of using-      `parseFromString`. This change makes it possible to have-      verbatim `</verse>` tag inside verse.--  * ODT reader:  deal gracefully with missing `<office:font-face-decls/>`-    (#4336). This allows pandoc to parse ODT document produced by KDE's-    Calligra.--  * Muse writer (Alexander Krotov):--    + Output headers without asterisks if not on the top level.-    + Never wrap definition list terms.-    + Set `envInsideBlock = True` when rendering notes.-    + Use `""` instead of `[]` for empty String.-    + Check for whitespace in the beginning and end of Str's.-    + Escape `-`, `;` and `>` in the beginning of strings.-    + Escape list markers in the beginning of notes.-    + Normalize inline list before testing if tags should be used.-    + Use tags instead of lightweight markup for empty strings.-    + Use lightweight markup when possible.-    + Escape empty strings.  This guarantees that `conditionalEscapeString`-      never returns empty string.-    + Wrap conditionalEscapeString result into `Muse` type.-      This removes the need to pass `envInsideLinkDescription` to it.-    + Separate `shouldEscapeString` function.-    + Simplify inline list rendering.-    + Replace newlines in strings with spaces.--  * Docx writer:--    + Add MetaString case for abstract, subtitle (#4900, Mauro Bieg).-    + Properly handle display math in spans (#4826). This isn't a-      complete solution, since other nestings of display math may still-      cause problems, but it should work for what is by far the most-      common case.--  * HTML writer:--    + Always output `<dt>` element, even if it is empty (#4883,-      Alexander Krotov).-    + Don't prefix `epub:` attributes with `data-`.--  * Org writer: Don't escape literal `_`, `^` (#4882). Org doesn't-    recognize these escapes.--  * ODT writer: Fix percentage image scaling (#4881, Nils Carlson).-    Image scaling was broken when a width was set to a percentage.--  * EPUB writer: set `epub:type` on body element in each chapter,-    depending on the `epub:type` of the first section (#4823). This-    only affects epub3. See-    http://www.idpf.org/epub/profiles/edu/structure/#h.l0bzsloklt10--  * FB2 writer: put `coverpage` element between title and date rather than in-    `document-info` element (#4854).--  * Markdown writer: Escape `~` if strikeout extension enabled (#4840).--  * Haddock writer: Use proper format for latex math in haddock (#4571, Joe-    Hermaszewski). Inline math in `\(..\)`, display math in `\[..\]`,-    tex is now used. Previously we'd "fake it with unicode" and fall-    back to tex when that didn't work. But newer haddock versions-    support latex math.--  * TEI writer:--    + Ensure that title element is always present, even if empty (#4839).-    + Put author tags in the template, rather than adding them in-      the writer (#4839).--  * LaTeX writer/template: be sensitive to `filecolor` variable (#4822).-    `linkcolor` only affects internal links, and `urlcolor` only-    affects linked URLs.  For external links, the option to use is-    `filecolor`.--  * ConTeXt writer: output raw `tex` blocks as well as `context` (#969).--  * RST writer:--    + Use `.. raw:: latex` for `tex` content.-    + Use `.. container` for generic Divs, instead of raw HTML.-    + Render Divs with admonition classes as admonitions (#4833).-      Also omit Div with class `admonition-title`. These are generated-      by the RST reader and should be omitted on round-trip.--  * Text.Pandoc.PDF: fix message printed when rsvg-convert is not available-    (#4855, Antonio Terceiro).--  * HTML5 template: add the `title-block-header` identifier to the-    `header` element, to make it easier to style precisely (#4767,-    J. B. Rainsberger).--  * OpenDocument template: Remove unnecessary indenting of TOC title (#4798,-    José de Mattos Neto).--  * latex template: Add support for $toc-title$ to LaTeX (and PDF)-    (#4853, Wandmalfarbe).--  * TEI template: improve `publicationStmt`. Add support for-    `publisher`, `address`, `pubPlace`, and `date` variables.--  * beamer template: Support "toc-title" (#4835, Cyril Roelandt).--  * Text.Pandoc.Extensions: Fix haddock on `Ext_footnotes` (Chris Martin).--  * Lua: cleanup Lua utils, remove unused functions (Albert Krewinkel).--  * MANUAL.txt:--    + Clarify that `--biblatex/--natbib` don't work directly for PDF-      (#4904).-    + Document `epub:type` attribute (Mauro Bieg, #4901)-    + Clarify when `--resource-path` has an effect.-    + More detail on customization in syntax highlighting section.-    + Document encoding issue with `--listings` (#4871, Damien Clochard).-    + Remove docs on removed `--katex-stylesheet` (Mauro Bieg, #4862).-    + Use https for context wiki links (#4910).--  * CONTRIBUTING.md:--    + Link to lua-filters repository (#4874).-    + Fix mistake in REPL instructions for stack. (#4849, Brian Leung).--  * lua-filters.md: add links to filters, and to lua-filters repository-    (#4874).--  * INSTALL.md:--    + Indicate that cabal >= 2.0 is needed.-    + Added chocolatey installation method (#4844, Miodrag Milić).--  * Travis: exclude round-trip tests, except for nightly test which can fail.--  * Use latest texmath, pandoc-citeproc.--  * Use a patched version of foundation until-    https://github.com/haskell-foundation/foundation/pull/503-    is fixed.--  * Clean up appveyor build and Windows package creation.-    We now use 64-bit stack and ghc 8.4.3, lts-12 for the 64-bit build. The-    WiX-based msi is now 64-bit for 64-bit builds (fixing #4795).--  * Remove obsolete RELEASE-CHECKLIST.md.--  * Added additional compiler warnings in Makefile and CI builds.--pandoc (2.2.3.2)--  * Markdown reader: Properly handle boolean values in YAML metadata (#4819).-    This fixes a regression in 2.2.3, which cause boolean values to-    be parsed as MetaInlines instead of MetaBool.--    We here record another undocumented (but desirable) change in 2.2.3:-    numerical metadata fields are now parsed as MetaInlines rather than-    MetaString.--pandoc (2.2.3.1)--  * Markdown reader: Fix parsing of embedded mappings in YAML metadata-    (#4817).  This fixes a regression in 2.2.3 which caused embedded-    mappings (e.g. mappings in sequences) not to work in YAML metadata.--pandoc (2.2.3)--  * RST reader: improve parsing of inline interpreted text roles (#4811).--    + Use a Span with class "title-reference" for the default-      title-reference role.-    + Use `B.text` to split up contents into `Space`s, `SoftBreak`s,-      and `Str`s for `title-reference`.-    + Use Code with class "interpreted-text" instead of Span and Str for-      unknown roles.  (The RST writer has also been modified to round-trip-      this properly.)-    + Disallow blank lines in interpreted text.-    + Backslash-escape now works in interpreted text.-    + Backticks followed by alphanumerics no longer end interpreted text.-    + Remove support for nested inlines (Francesco Occhipinti).-      RST does not allow nested emphasis, links, or other inline-      constructs.  This fixes several bugs (#4581, #4561, #4792).--  * Org reader: fix parsers relying on `parseFromString` (#4784, Albert-    Krewinkel).  Emphasis was not parsed when it followed directly after-    some block types (e.g., lists).--  * Markdown reader: Allow unquoted numbers and booleans as YAML mapping-    keys.  Previously in 2.2.2 you could not do-    ```-    ----    0: bar-    ...-    ```-    but only-    ```-    ----    '0': bar-    ...-    ```-    With this change, both forms work.--  * DocBook reader: metadata handling improvements.-    Now we properly parse title and subtitle elements that are direct-    children of book and article (as well as children of bookinfo,-    articleinfo, or info).  We also now use the `subtitle` metadata-    field for subtitles, rather than tacking the subtitle on to the-    title.--  * RST writer:--    + Allow images to be directly nested within links (#4810, Francesco-      Occhipinti).-    + Use `titleblock` instead of `title` variable for title block (#4803,-      Francesco Occhipinti).  `titleblock` contains a properly formatted-      title and subtitle (using top-level headers).  `title` and-      `subtitle` variables are still available and just contain the-      title and subtitle text.  Note that this change will require an-      update to custom rst templates.-    + Render Code with class "interpreted-text" as interpreted text role.--  * MediaWiki writer: Avoid extra blank line in tables with empty cells-    (#4794).  Note that the old output is semantically identical, but the-    new output looks better.--  * Lua Utils module: add function `blocks_to_inlines` (#4799, Albert-    Krewinkel).  Exposes a function converting which flattenes a list of-    blocks into a list of inlines. An example use case would be the-    conversion of Note elements into other inlines.--  * RST template:  use `titleblock` instead of `title`.  Users of-    custom RST templates will want to update this.--  * LaTeX template: Moved some beamer code in default.latex template.-    This change allows beamer themes to change the template and font (as-    Metropolis does) (#4450).--  * Better error message on `-t pdf -o out.pdf` (#1155, Mauro Bieg).--  * Added test case for #4669 to repository.--  * INSTALL.md: Fix broken link for cabal-install (#4806, ChanHoHo).--  * MANUAL.txt:--    + Add beamer info for slide backgrounds (#4802, John Muccigrosso).-    + Clarify when `csquotes` is used in LaTeX writer (#4514).-    + Add `commonmark` to list of output formats where `raw_tex` has an-      effect (see #4527).---pandoc (2.2.2.1)--  * Fix regression finding templates in user data directory (#4777).-    Under version 2.2.1 and prior pandoc found latex templates in the-    templates directory under the data directory, but this broke in 2.2.2.--  * Fix for bug in parsing `\input` in `rawLaTeXBlock` and-    `rawLaTeXInline` (#4781). (This primarily affects the markdown-    reader, and other readers that accept raw tex.)-    Starting in 2.2.2, everything after an `\input` (or `\include`)-    in a markdown file would be parsed as raw LaTeX.--  * MANUAL:--    + Clarify `gfm` vs `markdown_github` (#4783, Mauro Bieg).-    * Use `keywords` instead of `tags` in YAML metadata example (#4779).-      Unlike `tags`, `keywords` is used in some of the writers-      and default templates.--  * Add missing `rollingLinks` option to revealjs template (#4778,-    Igor Khorlo).--pandoc (2.2.2)--  * Use HsYAML instead of yaml for translations and YAML metadata (#4747).-    yaml wraps a C library; HsYAML is pure Haskell.  Advances #4535.--    Note: HsYAML implements YAML 1.2, in which the valid true-    values are `true`, `True`, `TRUE`.  This means a change in-    the semantics of YAML metadata that could affect users:-    `y`, `yes`, and `on` no longer count as true values.--  * Fix regression: make `--pdf-engine` work with full paths (#4681, Mauro-    Bieg).--  * CommonMark reader: Handle `ascii_identifiers` extension (#4742,-    Anders Waldenborg).  Non-ascii characters were not stripped from-    identifiers even if the `ascii_identifiers` extension was-    enabled (which is is by default for gfm).--  * TikiWiki reader: Improve list parsing (#4722, Mauro Bieg).-    Remove trailing Space from list items.  Parse lists that have no space-    after marker.--  * LaTeX reader:--    + Treat `lilypond` as a verbatim environment (#4725).-    + Parse figure label into Image id (#4700, Mauro Bieg).-    + Beamer: Allow "noframenumbering" option (#4696, Raymond Ehlers).-    + Allow spaces around `\graphicspath` arguments (#4698).-    + Handle includes without surrounding blanklines (#4553).-      In addition, `\input` can now be used in an inline context,-      e.g. to provide part of a paragraph, as it can in LaTeX.-    + In `rawLaTeXBlock`, handle macros that resolve to a-      `\begin` or `\end` (#4667).-    + In `rawLaTeXBlock`, don't expand macros in macro definitions (#4653).-      Note that this only affected LaTeX in markdown.-    + Tighten up reading of beamer overlay specifications (#4669).-      Ideally we'd turn these on only when reading beamer, but currently-      beamer is not distinguished from latex as an input format.-      This commit also activates parsing of overlay specifications-      after commands in general (e.g. `\item`), since they can occur-      in many contexts in beamer.-    + Parse more siunitx unit commands (#4296, #4773).-    + Be more forgiving in key/value option parsing (#4761).--  * Markdown reader:--    + Allow empty code spans, e.g. `` ` ` ``.-    + Emojis are now wrapped in Spans with class `emoji` and-      attribute `data-emoji` (Anders Waldenborg, #4743).-      This allows the writer to handle them in a special way-      (e.g. using a special font, or just rendering the-      emoji name).--  * Muse reader (Alexander Krotov, except where indicated):--    + Get rid of non-exhaustive pattern match warning (Mauro Bieg).-    + Add support for floating images.-    + Add support for images with specified width.-    + Parse image URLs without "guard" and "takeExtension".-    + Split link and image parsing into separate functions.-    + Parse links starting with "URL:" explicitly instead of trying to strip-      "URL:" prefix after parsing.--  * Texinfo writer: Use `@sup` and `@sub` instead of custom macros (#4728,-    Alexander Krotov).--  * Markdown writer: Preserve `implicit_figures` with attributes, even if-    `implicit_attributes` is not set, by rendering in raw HTML (#4677).--  * Markdown and commonmark/github writers now respect the `emoji`-    extension.  So, `-f markdown+emoji -t markdown+emoji` now leaves-    `:smile:` as `:smile:` rather than converting it to a smile-    character.--  * Docx writer: Be sensitive to `toc` in YAML metadata (#4645).--  * ODT/OpenDocument writer: Make internal links work (#4358).-    This adds proper bookmarks to the headers with non-null IDs.--  * EPUB writer: Properly escape pagetitle.  Previously we weren't-    escaping `&` and other XML characters in the pagetitle, so a title-    containing a `&` would be invalid.--  * AsciiDoc Writer: Eescape square brackets at start of line (#4545,-    Mauro Bieg).--  * RST writer:--    + Don't treat 'example' as a syntax name (#4748).-      This fixes conversions from org with example blocks.-    + Support `--number-sections` via the `section-numbering`-      directive in standalone output.--  * reveal.js writer and template: reuse mathjax URL-    provided by the argument to `--mathjax` or the normal pandoc default,-    rather than a hard-coded one in the template (#4701).--  * LaTeX writer:--    + Properly handle footnotes in table captions (#4683).-      Refactored code from figure captions to use in both places.-    + In beamer output, fix single digit column percentage (#4690, Mauro-      Bieg).--  * FB2 writer (Alexander Krotov):--    + Convert Plain to Para in annotation (#2424).-    + Fix order of items in title-info (#2424).--  * Custom writer: fix error message on script failure (Albert Krewinkel).-    Error messages produced by Lua were not displayed by Pandoc.--  * Text.Pandoc.Emoji now exports `emojiToInline`, which returns a Span-    inline containing the emoji character and some attributes with metadata-    (class `emoji`, attribute `data-emoji` with emoji name).  (API change,-    Anders Waldenborg, #4743).--  * Text.Pandoc.PDF:--    + Revert fix for #4484 (only compress images on last run, #4755).-      This will mean some increase in the time it takes to-      produce an image-heavy PDF with xelatex, but it will-      make tables of contents correct, which is more important.-    + Fix logic error in `runTeXProgram`.  We were running the tex program-      one more time than requested.  This should speed up PDF production.--  * Allow `--template` to take a URL as argument.--  * Text.Pandoc.Highlighting: Add missing re-export of `breezeDark`-    highlighting style (#4687, Adrian Sieber, API change).--  * Clarify macOS install in INSTALL.md (#4661).  Make the binary package-    installer the recommended method, and note that on some older versions of-    macOS, homebrew installs from source and takes a lot of disk space-    (#4664, Ian).--  * MANUAL:--    + Clarify EPUB linked media (#4756, Mauro Bieg)-    + Update manual for "true" YAML values.  Now that we're using HsYAML and-      YAML 1.2, the valid true values are `true`, `True`, `TRUE`.  NOTE!-      `y`, `yes`, `on` no longer count as true values.-    + Document `-F` as alias for `--filter` (thanks to Gandalf Saxe).-    + Update manual on how math is rendered in LaTeX.-    + Add proxy description (#4131, Mauro Bieg).-    + Clarify that `--toc` requires `--standalone` (#4703).-    + Update citation styles link (#4699, wiefling).--  * In API docs, clarify how `Ext_east_asian_line_breaks` extension works-    (kaizshang91).  Note that it will not take effect when readers/writers-    are called as libraries (#4674).--  * Improved translations/fr (#4766, lux-lth).--  * Removed inadvertently added `.orig` files from repository (#4648).--  * Remove `network-uri` flag and use 'Network.Socket'.-    This removes a compiler warning.  There is no need for the old-    `network-uri` flag, since network 2.6 was released in 2014.--  * Add stack.lts10.yaml, stack.lts11.yaml.  use lts-12 in stack.yaml.--  * Bump upper bounds for dependent packages.--  * Exclude foundation 0.0.21 for ghc 7.10.  Otherwise cabal gets-    confused because of the way ghc 7.10 is excluded in foundation's-    cabal file.  This can be removed when haskell-foundation/foundation#500-    is fixed.--  * Require cabal-version >= 2.0.  This is needed for haddock-library.---pandoc (2.2.1)--  * Restored and undeprecated gladtex for HTML math (#4607).--    + Added `GladTeX` constructor to `Text.Pandoc.Options.HTMLMathMethod`-      [API change, reverts removal in v2.2]-    + Restored and undeprecated `--gladtex` option, removed in v2.2.--  * LaTeX reader:  Handle `$` in `/text{..}` inside math (#4576).--  * Org reader: Fix image filename recognition (Albert Krewinkel).-    Use a function from the filepath library to check whether a string is a-    valid file name.  The custom validity checker that was used before gave-    wrong results (e.g. for absolute file paths on Windows,-    kawabata/ox-pandoc#52).--  * FB2 reader: Replace some errors with warnings (Alexander Krotov).--  * HTML writer:--    + Strip links from headers when creating TOC (#4340).-      Otherwise the TOC entries will not link to the sections.-    + Fix regression with tex math environments in HTML + MathJax (#4639).--  * Muse writer (Alexander Krotov): Add support for left-align and-    right-align classes (#4542).--  * Docx writer: Support underline (#4633).--  * Text.Pandoc.Parsing: Lookahead for non-whitespace after-    `singleQuoteStart` and `doubleQuoteStart` (#4637).--  * `test-pandoc-utils.lua`:  more robust testing on both windows-    and \*nix. Previously the pipe tests were only run if-    `\bin/false` and `/bin/sed` were present, which they aren't-    in default MacOS and Windows systems.  Fixed by using `tr`-    and `false`, which should always be in the path on a \*nix-    system, and `find` and `echo` for Windows.--  * Text.Pandoc.Shared: add `uriPathToPath`.-    This adjusts the path from a file: URI in a way that is sensitive-    to Windows/Linux differences.  Thus, on Windows,-    `/c:/foo` gets interpreted as `c:/foo`, but on Linux,-    `/c:/foo` gets interpreted as `/c:/foo`.  See #4613.--  * Use `uriPathToPath` with file: URIs (#4613).--  * Revert piping HTML to pdf-engine (Mauro Bieg, #4413).  Use a temp-    file as before.--  * Text.Pandoc.Class: Catch IO errors when writing media files-    and issue a warning, rather than an error (Francesco Occhipinti, #4559).--  * Don't lowercase custom writer filename (Alexander Krotov, #4610).--  * MANUAL (Mauro Bieg):--    + Clarify truthiness in template variables (#2281).-    + Clarify pipe table width calculation (#4520).--  * ConTeXt template: New Greek fallback typeface (Pablo Rodríguez, #4405).-    CMU Serif gives better typographic results than the previous-    Greek fallback DejaVu Serif.--  * Make HTML template polyglot (#4606, OvidiusCicero), by making-    `<link rel="stylesheet" href="$css$">` self-closing.--  * Use texmath 0.11, allowing better translation of non-ASCII-    characters in math (#4642).--pandoc (2.2)--  * New input format: `fb2` (FictionBook2) (Alexander Krotov).--  * Make `--ascii` work for all XML formats (ICML, OPML, JATS,...),-    and for `ms` and `man`.--  * Remove deprecated `--latexmathml`, `--gladtex`, `--mimetex`, `--jsmath`, `-m`,-    `--asciimathml` options.--  * New module Text.Pandoc.Readers.FB2, exporting readFB2 (Alexander-    Krotov, API change).--  * Markdown reader:--    + Allow empty key-value attributes, like `title=""` (#2944).-    + Handle table w/o following blank line in fenced div (#4560).-    + Remove "fallback" for `doubleQuote` parser.  Previously the-      parser tried to be efficient -- if no end double quote was found,-      it would just return the contents.  But this could backfire in a-      case `**this should "be bold**`, since the fallback would return-      the content `"be bold**` and the closing boldface delimiter-      would never be encountered.-    + Improve computation of the relative width of the last column in a-      multiline table, so we can round-trip tables without constantly-      shrinking the last column.--  * EPUB reader:--    + Fix images with space in file path (#4344).--  * LaTeX reader:--    + Properly resolve section numbers with `\ref` and chapters (#4529).-    + Parse sloppypar environment (#4517, Marc Schreiber).-    + Improve handling of raw LaTeX (for markdown etc.) (#4589, #4594).-      Previously there were some bugs in how macros were handled.-    + Support `\MakeUppercase`, `\MakeLowercase', `\uppercase`, `\lowercase`,-      and also `\MakeTextUppercase` and `\MakeTextLowercase` from textcase-      (#4959).--  * Textile reader:--    + Fixed tables with no body rows (#4513).-      Previously these raised an exception.--  * Mediawiki reader:--    + Improve table parsing (#4508).  This fixes detection of table-      attributes and also handles `!` characters in cells.--  * DocBook reader:--    + Properly handle title in `section` element (#4526).-      Previously we just got `section_title` for `section` (though `sect1`,-      `sect2`, etc. were handled properly).-    + Read tex math as output by asciidoctor (#4569, Joe Hermaszewski).--  * Docx reader:--    + Combine adjacent CodeBlocks with the same attributes into-      a single CodeBlock.  This prevents a multiline codeblock in-      Word from being read as different paragraphs.--  * RST reader:--    + Allow < 3 spaces indent under directives (#4579).-    + Fix anonymous redirects with backticks (#4598).--  * Muse reader (Alexander Krotov):--    + Add support for Text::Amuse multiline headings.-    + Add `<math>` tag support.-    + Add support for `<biblio>` and `<play>` tags.-    + Allow links to have empty descriptions.-    + Require block `<literal>` tags to be on separate lines.-    + Allow `-` in anchors.-    + Allow verse to be indented.-    + Allow nested footnotes.-    + Internal improvements.--  * Muse writer (Alexander Krotov):--    + Escape `>` only at the beginning of a line.-    + Escape `]` in image title.-    + Escape `]` brackets in URLs as `%5D`.-    + Only escape brackets when necessary.-    + Escape ordered list markers.-    + Do not escape list markers unless preceded by space.-    + Escape strings starting with space.-    + Escape semicolons and markers after line break.-    + Escape `;` to avoid accidental comments.-    + Don't break headers, line blocks and tables with line breaks.-    + Correctly output empty headings.-    + Escape horizontal rule only if at the beginning of the line.-    + Escape definition list terms starting with list markers.-    + Place header IDs before header.-    + Improve span writing.-    + Do not join Spans in normalization.-    + Don't align ordered list items.-    + Remove key-value pairs from attributes before normalization.-    + Enable `--wrap=preserve` for all tests by default.-    + Reduced `<verbatim>` tags in output.-    + Internal changes.--  * RST writer:--    + Use more consistent indentation (#4563).  Previously we-      used an odd mix of 3- and 4-space indentation.  Now we use 3-space-      indentation, except for ordered lists, where indentation must-      depend on the width of the list marker.-    + Flatten nested inlines (#4368, Francesco Occhipinti).-      Nested inlines are not valid RST syntax, so we flatten them following-      some readability criteria discussed in #4368.--  * EPUB writer:--    + Ensure that `pagetitle` is always set, even when structured titles-      are used.  This prevents spurious warnings about empty title-      elements (#4486).--  * FB2 writer (Alexander Krotov):--    + Output links inline instead of producing notes.  Previously all links-      were turned into footnotes with unclickable URLs inside.-    + Allow emphasis and notes in titles.-    + Don't intersperse paragraph with empty lines.-    + Convert metadata value `abstract` to book annotation.-    + Use `<empty-line />` for `HorizontalRule` rather than `LineBreak`.-      FB2 does not have a way to represent line breaks inside paragraphs;-      previously we used `<empty-line />` elements, but these are not allowed-      inside paragraphs.--  * Powerpoint writer (Jesse Rosenthal):--    + Handle Quoted Inlines (#4532).-    + Simplify code with `ParseXml`.-    + Allow fallback options when looking for placeholder type.-    + Check reference-doc for all layouts.-    + Simplify speaker notes logic.-    + Change notes state to a simpler per-slide value.-    + Remove `Maybe` from `SpeakerNotes` in `Slide`. `mempty`-      means no speaker notes.-    + Add tests for improved speaker notes.-    + Handle speaker notes earlier in the conversion process.-    + Keep notes with related blocks (#4477).  Some blocks automatically-      split slides (imgs, tables, `column` divs). We assume that any-      speaker notes immediately following these are connected to these-      elements, and keep them with the related blocks, splitting after them.-    + Remove `docProps/thumbnail.jpeg` in data dir (Jesse Rosenthal, #4588).-      It contained a nonfree ICC color calibration profile and is not needed-      for production of a powerpoint document.--  * Markdown writer:--    + Include a blank line at the end of the row in a single-row multiline-      table, to prevent it from being interpreted as a simple table (#4578).--  * CommonMark writer:--    + Correctly ignore LaTeX raw blocks when `raw_tex` is not-      enabled (#4527, quasicomputational).--  * EPUB writer:--    + Add `epub:type="footnotes"` to notes section in EPUB3 (#4489).--  * LaTeX writer:--    + In beamer, don't use format specifier for default ordered lists-      (#4556).  This gives better results for styles that put ordered list-      markers in boxes or circles.-    + Update `\lstinline` delimiters (#4369, Tim Parenti).--  * Ms writer:--    + Use `\f[R]` rather than `\f[]` to reset font (#4552).-    + Use `\f[BI]` and `\f[CB]` in headers, instead of `\f[I]` and `\f[C]`,-      since the header font is automatically bold (#4552).-    + Use `\f[CB]` rather than `\f[BC]` for monospace bold (#4552).-    + Create pdf anchor for a Div with an identifier (#4515).-    + Escape `/` character in anchor ids (#4515).-    + Improve escaping for anchor ids: we now use _uNNN_ instead of uNNN-      to avoid ambiguity.--  * Man writer:--    + Don't escape U+2019 as `'` (#4550).--  * Text.Pandoc.Options:--    + Removed `JsMath`, `LaTeXMathML`, and `GladTeX` constructors from-    `Text.Pandoc.Options.HTMLMathMethod` [API change].--  * Text.Pandoc.Class:--    + `writeMedia`: unescape URI-escaping in file path.  This avoids-      writing things like `file%20one.png` to the file system.--  * Text.Pandoc.Parsing:--    + Fix `romanNumeral` parser (#4480).  We previously accepted 'DDC'-      as 1100.-    + `uri`: don't treat `*` characters at end as part of URI (#4561).--  * Text.Pandoc.MIME:--    + Use the alias `application/eps` for EPS (#2067).-      This will ensure that we retain the eps extension after reading the-      image into a mediabag and writing it again.--  * Text.Pandoc.PDF:--    + Use `withTempDir` in `html2pdf`.-    + With `xelatex`, don't compress images til the last run (#4484).-      This saves time for image-heavy documents.-    + Don't try to convert EPS files (#2067).  `pdflatex` converts them-      itself, and JuicyPixels can't do it.-    + For `pdflatex`, use a temp directory in the working directory.-      Otherwise we can have problems with the EPS conversion pdflatex-      tries to do, which can't operate on a file above the working-      directory without `--shell-escape`.--  * Changes to tests to accommodate changes in pandoc-types.-    In <https://github.com/jgm/pandoc-types/pull/36> we changed-    the table builder to pad cells.  This commit changes tests-    (and two readers) to accord with this behavior.--  * Set default extensions for `beamer` same as `latex`.--  * LaTeX template:--    + Add `beameroption` variable (#4359, Étienne Bersac).-    + Use `pgfpages` package; this is needed for notes on second-      screen in beamer (Étienne Bersac).-    + Add `background-image` variable (#4601, John Muccigrosso).--  * reveal.js template: Add `background-image` variable (#4600,-    John Muccigrosso).--  * ms template: Fix date.  Previously `.ND` was used, but this only-    works if you have a title page, which we don't.  Thanks to @teoric.--  * Removed pragmas for unused extensions (#4506, Anabra).--  * Fix bash completion for `--print-default-data-file` (#4549).-    Previously this looked in the filesystem, even if pandoc-    was compiled with `embed_data_files` (and sometimes it looked-    in a nonexistent build directory).  Now the bash completion-    script just includes a hard-coded list of data file names.--  * MANUAL:--    + Clarify template vs metadata variables (#4501, Mauro Bieg).-    + Fix raw content example (#4479, Mauro Bieg).-    + Specify that you use html for raw output in epub.-    + Add examples for raw docx blocks (#4472, Tristan Stenner).-      The documentation states that the target format name should match-      the output format, which isn't the case for `docx`/`openxml` and-      some others.-    + Don't say that `empty_paragraphs` affects markdown output (#4540).-    + Consolidate input/output format documentation (#4577, Mauro Bieg).--  * New README template. Take in/out formats from manual.--  * Fix example in lua-filters docs (#4459, HeirOfNorton).--  * Use the `-threaded` GHC flag when building benchmarks (#4587,-    Francesco Occhipinti).--  * Bump temporary upper bound to 1.4.--  * Use pandoc-citeproc 0.14.3.1.--  * Use texmath-0.10.1.2 (fixes escapes in math in ms, #4597).--  * Removed old lib directory.  This was used for something long ago,-    but plays no role now.--  * Removed unneeded data file `LaTeXMathML.js`.--  * Create 64- and 32-bit versions of Windows binary packages.--pandoc (2.1.3)--  * Docx reader (Jesse Rosenthal):--    + Add tests for nested smart tags.-    + Parse nested smart tags.-    + Make unwrapSDT into a general `unwrap` function that can unwrap both-      nested SDT tags and smartTags. This makes the SmartTags constructor in-      the Docx type unnecessary, so we remove it (#4446).-    + Remove unused `docxWarnings` (Alexander Krotov).--  * RST reader: Allow unicode bullet characters (#4454).--  * Haddock reader:  Better table handling, using haddock-library's-    new table support, if compiled against a version that-    includes it.  Note that tables with col/rowspans will not-    translate well into Pandoc.--  * Muse reader (Alexander Krotov):--    + Require closing tag to have the same indentation as opening.-    + Do not reparse blocks inside unclosed block tag (#4425).-    + Parse `<class>` tag (supported by Emacs Muse).-    + Do not produce empty Str element for unindented verse lines.-    + Don't allow footnote references inside links.-    + Allow URL to be empty.-    + Require that comment semicolons are in the first column (#4551).-    + Various internal improvements.--  * LaTeX reader:--    + Add support to parse unit string of `\SI` command (closes #4296,-      Marc Schreiber).--  * Haddock writer:  In the writer, we now render tables always as-    grid tables, since Haddock supports these.--  * DokuWiki writer: rewrite backSlashLineBreaks (#4445, Mauro Bieg).--  * Docx writer: Fixed formatting of `DefaultStyle` ordered lists in-    docx writer.  We want decimal for the top level, not lower roman.--  * RST writer:--    + Strip whitespace at beginning and ending of inline containers-      (#4327, Francesco Occhipinti).-    + Filter out empty inline containers (#4434).  There is nothing in-      RST that corresponds to e.g. `Emph []`, so we just ignore elements-      like this (Francesco Occhipinti).--  * Muse writer (Alexander Krotov):--    + Support spans with anchors.-    + Replace smallcaps with emphasis before normalization.-    + Output smallcaps as emphasis.-    + Expand Cite before list normalization.-    + Write empty inline lists as `<verbatim></verbatim>`.-    + Remove empty Str from the beginning of inline lists during normalization.-    + Escape "-" to avoid creating bullet lists.-    + Fix math expansion for more than one expression per paragraph.-    + Expand math before inline list normalization.--  * Dokuwiki writer: fix LineBreaks in Tables (#4313, Mauro Bieg).--  * Ms writer:--    + Asciify pdf anchors, since unicode anchors don't work (#4436).-      Internal links should be converted automatically, so this shouldn't-      affect users directly.-    + Don't escape hyphens as `\-`; that's for a minus sign (#4467).--  * Beamer writer: put hyperlink after `\begin{frame}` and not in the title-    (#4307).  If it's in the title, then we get a titlebar on slides with-    the `plain` attribute, when the id is non-null.  This fixes a regression-    in 2.0.--  * EPUB writer: Remove notes from TOC in nav.xhtml (#4453, Mauro Bieg).--  * JATS writer: Remove extraneous, significant whitespace (#4335,-    Nokome Bentley).--  * html2pdf: inject base tag with current working directory (#4413, Mauro-    Bieg).  This helps ensure that linked resources are included.--  * Add Semigroup instances for everything for which we defined a-    Monoid instance previously (API change):--    + Text.Pandoc.Class.FileTree.-    + Text.Pandoc.Translations.Translations.-    + Text.Pandoc.Extensions.Extensions.-    + Text.Pandoc.Readers.Odt.StyleReader.Styles.-    + Text.Pandoc.Pretty.Doc.-    + Text.Pandoc.MediaBag.MediaBag.--  * Add custom Prelude to give clean code for Monoid and Semigroup-    that works with ghc 7.10-8.4.  The custom Prelude (`prelude/Prelude`)-    is used for ghc versions < 8.4.  `NoImplicitPrelude` is used-    in all source files, and Prelude is explicitly imported-    (this is necessary for ghci to work properly with the custom prelude).--  * Text.Pandoc.Writers.Shared (Francesco Occhipinti):--    + Export `stripLeadingTrailingSpace`.-    + Don't wrap lines in grid tables when `--wrap=none` (#4320).-    + `gridTable`: Don't wrap lines in tables when `--wrap=none`.  Instead,-      expand cells, even if it results in cells that don't respect relative-      widths or surpass page column width.  This change affects RST,-      Markdown, and Haddock writers.--  * Raise error if someone tries to print docx, odt, etc. template (#4441).--  * LaTeX template: Provide `bidi` package's option using-    `\PassOptionsToPackage`  (#4357, Václav Haisman).  This avoid a-    clash when   `polyglossia` loads it first and then it is loaded again-    for XeLaTeX.--  * ConTeXt template: Added `pdfa` variable to generate PDF/A (#4294, Henri-    Menke).  Instructions on how to install the ICC profiles on ConTeXt-    standalone can be found in the wiki:-    <http://wiki.contextgarden.net/PDFX#ICC_profiles>.-    If the ICC profiles are not available the log will contain error-    messages.--  * Use latest pandoc-types, skylighting--  * Use latest pandoc-citeproc in binary package.--  * Bump upper bound for time, criterion, haddock-library, exceptions,-    http-types, aeson, haddock-library.--  * Bump upper bound tasty-quickcheck 0.10 (#4429, Felix Yan).--  * pandoc.cabal:  fix up other-extensions and language fields.-    Language is now consistently `Haskell2010`, and other-extensions-    is consistently `NoImplicitPrelude`. Everything else to be specified-    in the module header as needed.--  * Removed `old-locale` flag and Text.Pandoc.Compat.Time.-    This is no longer necessary since we no longer support ghc 7.8.--  * Make `weigh-pandoc` into a benchmark program.-    Remove `weigh-pandoc` flag.  `weigh-pandoc` is now built (and run)-    automatically when you build (and run) benchmarks.--  * MANUAL: add instructions for background images reveal.js (#4325, John-    Muccigrosso).--  * appveyor: use VS 2013 environment instead of VS 2015 for Windows builds.---pandoc (2.1.2)--  * Markdown reader:--    + Fix parsing bug with nested fenced divs (#4281).  Previously we allowed-      "nonindent spaces" before the opening and closing `:::`, but this-      interfered with list parsing, so now we require the fences to be flush with-      the margin of the containing block.--  * Commonmark reader:--    + `raw_html` is now on by default.  It can be disabled explicitly-      using `-f commonmark-raw_html`.--  * Org reader (Albert Krewinkel):--    + Move citation tests to separate module.-    + Allow changing emphasis syntax (#4378).  The characters allowed before-      and after emphasis can be configured via `#+pandoc-emphasis-pre` and-      `#+pandoc-emphasis-post`, respectively. This allows to change which-      strings are recognized as emphasized text on a per-document or even-      per-paragraph basis.  Example:--          #+pandoc-emphasis-pre: "-\t ('\"{"-          #+pandoc-emphasis-post: "-\t\n .,:!?;'\")}["--  * LaTeX reader:--    + Fixed comments inside citations (#4374).-    + Fix regression in package options including underscore (#4424).-    + Make `--trace` work.-    + Fixed parsing of `tabular*` environment (#4279).--  * RST reader:--    + Fix regression in parsing of headers with trailing space (#4280).--  * Muse reader (Alexander Krotov):--    + Enable `<literal>` tags even if amuse extension is enabled.-      Amusewiki disables <literal> tags for security reasons.-      If user wants similar behavior in pandoc, RawBlocks and RawInlines-      can be removed or replaced with filters.-    + Remove space prefix from `<literal>` tag contents.-    + Do not consume whitespace while looking for closing end tag.-    + Convert alphabetical list markers to decimal in round-trip test.-      Alphabetical lists are an addition of Text::Amuse.-      They are not present in Emacs Muse and can be ambiguous-      when list starts with "i.", "c." etc.-    + Allow `<quote>` and other tags to be indented.-    + Allow single colon in definition list term.-    + Fix parsing of verse in lists.-    + Improved parsing efficiency.  Avoid `parseFromString`.-      Lists are parsed in linear instead of exponential time now.-    + Replace ParserState with MuseState.-    + Prioritize lists with roman numerals over alphabetical lists.-      This is to make sure "i." starts a roman numbered list,-      instead of a list with letter "i" (followed by "j", "k", ...").-    + Fix directive parsing.-    + Parse definition lists with multiple descriptions.-    + Parse next list item before parsing more item contents.-    + Fixed a bug: headers did not terminate lists.-    + Move indentation parsing from `definitionListItem` to `definitionList`.-    + Paragraph indentation does not indicate nested quote.-      Muse allows indentation to indicate quotation or alignment,-      but only on the top level, not within a <quote> or list.-    + Require that block tags are on separate lines.-      Text::Amuse already explicitly requires it anyway.-    + Fix matching of closing inline tags.-    + Various internal changes.-    + Fix parsing of nested definition lists.-    + Require only one space for nested definition list indentation.-    + Do not remove trailing whitespace from `<code>`.-    + Fix parsing of trailing whitespace.  Newline after whitespace now-      results in softbreak instead of space.--  * Docx reader (Jesse Rosenthal, except where noted):--    + Handle nested sdt tags (#4415).-    + Don't look up dependent run styles if `+styles` is enabled.-    + Move pandoc inline styling inside custom-style span.-    + Read custom styles (#1843).  This will read all paragraph and-      character classes as divs and spans, respectively. Dependent styles-      will still be resolved, but will be wrapped with appropriate style-      tags. It is controlled by the `+styles` extension (`-f docx+styles`).-      This can be used in conjunction with the `custom-style` feature in the-      docx writer for a pandoc-docx editing workflow. Users can convert from-      an input docx, reading the custom-styles, and then use that same input-      docx file as a reference-doc for producing an output docx file. Styles-      will be maintained across the conversion, even if pandoc doesn't-      understand them.-    + Small change to Fields hyperlink parser.  Previously, unquoted string-      required a space at the end of the line (and consumed it). Now we-      either take a space (and don't consume it), or end of input.-    + Pick table width from the longest row or header (Francesco Occhipinti,-      #4360).--  * Muse writer (Alexander Krotov):--    + Change verse markup: `> ` instead of `<verse>` tag.-    + Remove empty strings during inline normalization.-    + Don't indent nested definition lists.-    + Use unicode quotes for quoted text.-    + Write image width specified in percent in Text::Amuse mode.-    + Don't wrap displayMath into `<verse>`.-    + Escape nonbreaking space (`~~`).-    + Join code with different attributes during normalization.-    + Indent lists inside Div.-    + Support definitions with multiple descriptions.--  * Powerpoint writer (Jesse Rosenthal):--    + Use table styles This will use the default table style in the-      reference-doc file. As a result they will be easier when using-      in a template, and match the color scheme.-    + Remove empty slides.  Because of the way that slides were split, these-      could be accidentally produced by comments after images.  When animations-      are added, there will be a way to add an empty slide with either-      incremental lists or pauses.-    + Implement syntax highlighting.  Note that background colors can't-      be implemented in PowerPoint, so highlighting styles that require-      these will be incomplete.-    + New test framework for pptx.  We now compare the output of the-      Powerpoint writer with files that we know to (a) not be corrupt,-      and (b) to show the desired output behavior (details below).-    + Add `notesMaster` to `presentation.xml` if necessary.-    + Ignore links and (end)notes in speaker notes.-    + Output speaker notes.-    + Read speaker note templates conditionally.  If there are speaker-      notes in the presentation, we read in the notesMasters templates-      from the reference pptx file.-    + Fix deletion track changes (#4303, Jesse Rosenthal).--  * Markdown writer: properly escape @ to avoid capture as citation-    (#4366).--  * LaTeX writer:--    + Put hypertarget inside figure environment (#4388).-      This works around a problem with the endfloat package and-      makes pandoc's output compatible with it.-    + Fix image height with percentage (#4389).  This previously caused-      the image to be resized to a percentage of textwidth, rather than-      textheight.--  * ConTeXt writer (Henri Menke):--    + New section syntax and support `--section-divs` (#2609).-      `\section[my-header]{My Header}` ->-      `\section[title={My Header},reference={my-header}]`.-      The ConTeXt writer now supports the `--section-divs` option to-      write sections in the fenced style, with `\startsection` and-      `\stopsection`.-    + xtables: correct wrong usage of caption (Henri Menke).--  * Docx writer:--    + Fix image resizing with multiple images (#3930, Andrew Pritchard).-    + Use new golden framework (Jesse Rosenthal).-    + Make more deterministic to facilitate testing (Jesse Rosenthal).-      - `getUniqueId` now calls to the state to get an incremented digit,-        instead of calling to P.uniqueHash.-      - we always start the PRNG in mkNumbering/mkAbstractNum with the same-        seed (1848), so our randoms should be the same each time.-    + Fix ids in comment writing (Jesse Rosenthal).  Comments from-      `--track-changes=all` were producing corrupt docx, because the-      writer was trying to get id from the `(ID,_,_)` field of-      the attributes, and ignoring the "id" entry in the key-value pairs. We-      now check both.--  * Ms writer: Added papersize variable.--  * TEI writer:--    + Use `height` instead of `depth` for images (#4331).-    + Ensure that id prefix is always used.-    + Don't emit `role` attribute; that was a leftover from the-      Docbook writer.-    + Use 'xml:id', not 'id' attribute (#4371).--  * AsciiDoc writer:--    + Do not output implicit heading IDs (#4363, Alexander-      Krotov).  Convert to `asciidoc-auto_identifiers` for old behaviour.--  * RST writer:--    + Remove `blockToRST'` moving its logic into `fixBlocks`-      (Francesco Occhipinti).-    + Insert comment between lists and quotes (#4248, Francesco Occchipinti).--  * RST template: remove definition of 'math' role as raw.-    This used to be needed prior to v 0.8 of docutils, but-    now math support is built-in.--  * Slides: Use divs to set incremental/non-incremental (#4381,-    Jesse Rosenthal).  The old method (list inside blockquote) still-    works, but we are encouraging the use of divs with class-    `incremental` or `nonincremental`.--  * Text.Pandoc.ImageSize:--    + Make image size detection for PDFs more robust (#4322).-    + Determine image size for PDFs (#4322).-    + EMF Image size support (#4375, Andrew Pritchard).--  * Text.Pandoc.Extensions:--    + Add `Ext_styles` (Jesse Rosenthal, API change).  This will be used in-      the docx reader (defaulting to off) to read pargraph and character-      styles not understood by pandoc (as divs and spans, respectively).-    + Made `Ext_raw_html` default for `commonmark` format.--  * Text.Pandoc.Parsing:--    + Export `manyUntil` (Alexander Krotov, API change).-    + Export improved `sepBy1` (Alexander Krotov).-    + Export list marker parsers: `upperRoman`, `lowerRoman`,-      `decimal`, `lowerAlpha`, `upperAlpha` (Alexander Krotov, API change).--  * Tests/Lua: fix tests on windows (Albert Krewinkel).--  * Lua: register script name in global variable (#4393).  The name of the Lua-    script which is executed is made available in the global Lua variable-    `PANDOC_SCRIPT_FILE`, both for Lua filters and custom writers.--  * Tests: Abstract powerpoint tests out to OOXML tests (Jesse Rosenthal).-    There is very little pptx-specific in these tests, so we abstract out-    the basic testing function so it can be used for docx as well. This-    should allow us to catch some errors in the docx writer that slipped-    by the roundtrip testing.--  * Lua filters: store constructors in registry (Albert Krewinkel).  Lua-    functions used to construct AST element values are stored in the Lua-    registry for quicker access. Getting a value from the registry is much-    faster than getting a global value (partly to idiosyncrasies of hslua);-    this change results in a considerable performance boost.--  * Documentation:--    + `doc/org.md` Add draft of Org-mode documentation (Albert Krewinkel).-    + `doc/lua-filters.md`: document global vars set for filters-      (Albert Krewinkel).-    + INSTALL.md: mention Stack version. (#4343, Adam Brandizzi).-    + MANUAL: add documentation on custom styles (Jesse Rosenthal).-    + MANUAL.txt: Document incremental and nonincremental divs (Jesse-      Rosenthal).  Blockquoted lists are still described, but fenced divs are-      presented in preference.-    + MANUAL.txt: document header and footer variables (newmana).-    + MANUAL.txt: self-contained implies standalone (#4304, Daniel Lublin).-    + CONTRIBUTING.md: label was renamed. (#4310, Alexander Brandizzi).--  * Require tagsoup 0.14.3 (#4282), fixing HTML tokenization bug.--  * Use latest texmath.--  * Use latest pandoc-citeproc.--  * Allow exceptions 0.9.--  * Require aeson-pretty 0.8.5 (#4394).--  * Bump blaze-markup, blaze-html lower bounds to 0.8, 0.9 (#4334).--  * Update tagsoup to 0.14.6 (Alexander Krotov, #4282).--  * Removed ghc-prof-options.  As of cabal 1.24, sensible defaults are used.--  * Update default.nix to current nixpkgs-unstable for hslua-0.9.5 (#4348,-    jarlg).---pandoc (2.1.1)--  * Markdown reader:--    + Don't coalesce adjacent raw LaTeX blocks if they are separated by a-      blank line.  See lierdakil/pandoc-crossref#160.-    + Improved `inlinesInBalancedBrackets` (#4272, jgm/pandoc-citeproc#315).-      The change both improves performance and fixes a regression whereby-      normal citations inside inline notes and figure captions were not-      parsed correctly.--  * RST reader:--    + Better handling for headers with an anchor (#4240).  Instead of creating a-      Div containing the header, we put the id directly on the header.-      This way header promotion will work properly.-    + Add aligned environment when needed in math (#4254).  `rst2latex.py`-      uses an `align*` environment for math in `.. math::` blocks, so this-      math may contain line breaks.  If it does, we put the math in an-      `aligned` environment to simulate `rst2latex.py`'s behavior.--  * HTML reader:--    + Fix col width parsing for percentages < 10% (#4262, n3fariox).--  * LaTeX reader:--    + Advance source position at end of stream.-    + Pass through macro defs in `rawLaTeXBlock` even if the `latex_macros`-      extension is set (#4246).  This reverts to earlier behavior and is-      probably safer on the whole, since some macros only modify things in-      included packages, which pandoc's macro expansion can't modify.-    + Fixed pos calculation in tokenizing escaped space.-    + Allow macro definitions inside macros (#4253).  Previously we went into-      an infinite loop with-      ```-      \newcommand{\noop}[1]{#1}-      \noop{\newcommand{\foo}[1]{#1}}-      \foo{hi}-      ```-    + Fix inconsistent column widths (#4238).  This fixes a bug whereby column-      widths for the body were different from widths for the header in some-      tables.--  * Docx reader (Jesse Rosenthal):--    + Parse hyperlinks in `instrText` tags (#3389, #4266).  This was a form of-      hyperlink found in older versions of word. The changes introduced for-      this, though, create a framework for parsing further fields in MS Word-      (see the spec, ECMA-376-1:2016, §17.16.5, for more on these fields).-      We introduce a new module, `Text.Pandoc.Readers.Docx.Fields` which-      contains a simple parsec parser. At the moment, only simple hyperlink-      fields are accepted, but that can be extended in the future.--  * Muse reader (Alexander Krotov):--    + Parse `~~` as non-breaking space in Text::Amuse mode.-    + Refactor list parsing.--  * Powerpoint writer (Jesse Rosenthal):--    + Change reference to `notesSlide` to `endNotesSlide`.-    + Move image sizing into `picProps`.-    + Improve table placement.-    + Make our own `_rels/.rels` file.-    + Import reference-doc images properly.-    + Move `Presentation.hs` out of `PandocMonad`.-    + Refactor into separate modules.  T.P.W.Powerpoint.Presentation-      defines the Presentation datatype and goes Pandoc->Presentation;-      T.P.W.Pandoc.Output goes Presentation->Archive.-      Text.Pandoc.Writers.Powerpoint a thin wrapper around the two modules.-    + Avoid overlapping blocks in column output.-    + Position images correctly in two-column layout.-    + Make content shape retrieval environment-aware.-    + Improve image handling.  We now determine image and caption placement-      by getting the dimensions of the content box in a given layout.-      This allows for images to be correctly sized and positioned in a-      different template.  Note that images without captions and headers are-      no longer full-screened. We can't do this dependably in different-      layouts, because we don't know where the header is (it could be to-      the side of the content, for example).-    + Read presentation size from reference file.  Our presentation size is-      now dependent on the reference/template file we use.-    + Handle (sub)headers above slidelevel correctly.  Above the slidelevel,-      subheaders will be printed in bold and given a bit of extra space-      before them. Note that at the moment, no distinction is made between-      levels of headers above the slide header, though that can be changed.-    + Check for required files.  Since we now import from reference/dist-      file by glob, we need to make sure that we're getting the files we-      need to make a non-corrupt Powerpoint. This performs that check.-    + Improve templating using `--reference-doc`.  Templating should work-      much more reliably now.-    + Include Notes slide in TOC.-    + Set notes slide header to slide-level.-    + Add table of contents.  This is triggered by the `--toc` flag. Note-      that in a long slide deck this risks overrunning the text box. The user-      can address this by setting `--toc-depth=1`.-    + Set notes slide number correctly.-    + Clean up adding metadata slide.  We want to count the slide numbers-      correctly if it's in there.-    + Add anchor links.  For anchor-type links (`[foo](#bar)`) we produce-      an anchor link. In powerpoint these are links to slides, so we keep-      track of a map relating anchors to the slides they occur on.-    + Make the slide number available to the blocks.  For anchors,-      block-processing functions need to know what slide number-      they're in. We make the `envCurSlideId` available to blocks.-    + Move `curSlideId` to environment.-    + Allow setting `toc-title` in metadata.-    + Link notes to endnotes slide.--  * Markdown writer:--    + Fix cell width calculation (#4265).  Previously we could get-      ever-lengthening cell widths when a table was run repeatedly through-      `pandoc -f markdown -t markdown`.--  * LaTeX writer:--    + Escape `&` in lstinline (Robert Schütz).--  * ConTeXt writer:--    + Use xtables instead of Tables (#4223, Henri Menke).-      Default to xtables for context output.  Natural Tables are used-      if the new `ntb` extension is set.--  * HTML writer:--     + Fixed footnote backlinks with `--id-prefix` (#4235).--  * `Text.Pandoc.Extensions`:  Added `Ext_ntb` constructor (API change,-    Henri Menke).--  * `Text.Pandoc.ImageSize`: add derived `Eq` instance to `Dimension`-    (Jesse Rosenthal, API change).--  * Lua filters (Albert Krewinkel):--    + Make `PANDOC_READER_OPTIONS` available.-      The options which were used to read the document are made available to-      Lua filters via the `PANDOC_READER_OPTIONS` global.-    + Add lua module `pandoc.utils.run_json_filter`, which runs a JSON filter-      on a Pandoc document.-    + Refactor filter-handling code into `Text.Pandoc.Filter.JSON`,-      `Text.Pandoc.Filter.Lua`, and `Text.Pandoc.Filter.Path`.-    + Improve error messages.  Provide more context about the task-      which caused an error.--  * data/pandoc.lua (Albert Krewinkel):--    + Accept singleton inline as a list.  Every constructor which accepts a-      list of inlines now also accepts a single inline element for-      convenience.-    + Accept single block as singleton list. Every constructor which accepts-      a list of blocks now also accepts a single block element for-      convenience.  Furthermore, strings are accepted as shorthand for-      `{pandoc.Str "text"}` in constructors.-    + Add attr, listAttributes accessors.  Elements with-      attributes got an additional `attr` accessor. Attributes were-      accessible only via the `identifier`, `classes`, and `attributes`,-      which was in conflict with the documentation, which indirectly states-      that such elements have the an `attr` property.-    + Drop `_VERSION`.  Having a `_VERSION` became superfluous, as this-      module is closely tied to the pandoc version, which is available via-      `PANDOC_VERSION`.-    + Fix access to Attr components.  Accessing an Attr value (e.g.,-      ` Attr().classes`) was broken; the more common case of accessing it via-      an Inline or Block element was unaffected by this.--  * Move `metaValueToInlines` to from Docx writer to-    `Text.Pandoc.Writers.Shared`, so it can be used by other writers-    (Jesse Rosenthal).--  * MANUAL.txt:--    + Clarify otherlangs in LaTeX (#4072).-    + Clarify `latex_macros` extension.-    + Recommend use of `raw_attribute` extension in header includes (#4253).--  * Allow latest QuickCheck, tasty, criterion.--  * Remove custom prelude and ghc 7.8 support.--  * Reduce compiler noise (exact paths for compiled modules).--pandoc (2.1)--  * Allow filters and lua filters to be interspersed (#4196).  Previously-    we ran all lua filters before JSON filters.  Now we run filters in-    the order they are presented on the command line, whether lua or JSON.-    There are two incompatible API changes: The type of `applyFilters`-    has changed, and `applyLuaFilters` has been removed.  `Filter` is-    also now exported.--  * Use latest skylighting and omit the `missingIncludes` check, fixing-    a major performance regression in earlier releases of the 2.x series-    (#4226).  Behavior change: If you use a custom syntax definition that-    refers to a syntax you haven't loaded, pandoc will now complain when-    it is highlighting the text, rather than doing a check at the start.-    This change dramatically speeds up invocations of pandoc on short-    inputs.--  * Text.Pandoc.Class: make `FileTree` opaque (don't export-    `FileTree` constructor).  This forces users to interact with it using-    `insertInFileTree` and `getFileInfo`, which normalize file names.--  * Markdown reader:--    + Rewrite `inlinesInBalancedBrackets`.  The rewrite is much more-      direct, avoiding `parseFromString`.  And it performs significantly-      better; unfortunately, parsing time still increases exponentially-      (see #1735).-    + Avoid parsing raw tex unless `\` + letter seen.  This seems to-      help with the performance problem, #4216.--  * LaTeX reader: Simplified a check for raw tex command.--  * Muse reader (Alexander Krotov):--    + Enable round trip test (#4107).-    + Automatically translate `#cover` into `#cover-image`.-      Amusewiki uses #cover directive to specify cover image.--  * Docx reader (Jesse Rosenthal):--    + Allow for insertion/deletion of paragraphs (#3927).-      If the paragraph has a deleted or inserted paragraph break (depending-      on the track-changes setting) we hold onto it until the next-      paragraph. This takes care of accept and reject. For this we introduce-      a new state which holds the ils from the previous para if necessary.-      For `--track-changes=all`, we add an empty span with class-      `paragraph-insertion`/`paragraph-deletion` at the end of the paragraph-      prior to the break to be inserted or deleted.-    + Remove unused anchors (#3679).  Docx produces a lot of anchors with-      nothing pointing to them---we now remove these to produce cleaner-      output. Note that this has to occur at the end of the process-      because it has to follow link/anchor rewriting.-    + Read multiple children of `w:sdtContents`.-    + Combine adjacent anchors.  There isn't any reason to have numerous-      anchors in the same place, since we can't maintain docx's-      non-nesting overlapping. So we reduce to a single anchor.-    + Improved tests.--  * Muse writer (Alexander Krotov): don't escape URIs from AST--  * Docx writer:--    + Removed redundant subtitle in title (Sebastian Talmon).-    + `firstRow` table definition compatibility for Word 2016 (Sebastian-      Talmon).  Word 2016 seems to use a default value of "1" for table-      headers, if there is no firstRow definition (although a default-      value of 0 is documented), so all tables get the first Row formatted-      as header.  Setting the parameter to 0 if the table has no header-      row fixes this for Word 2016-    + Fix custom styles with spaces in the name (#3290).--  * Powerpoint writer (Jesse Rosenthal):--    + Ignore Notes div for parity with other slide outputs.-    + Set default slidelevel correctly.  We had previously defaulted to-      slideLevel 2. Now we use the correct behavior of defaulting to the-      highest level header followed by content. We change an expected test-      result to match this behavior.-    + Split blocks correctly for linked images.-    + Combine adjacent runs.-    + Make inline code inherit code size.  Previously (a) the code size-      wasn't set when we force size, and (b) the properties was set from-      the default, instead of inheriting.-    + Simplify `replaceNamedChildren` function.-    + Allow linked images.  The following markdown:-      `[![Image Title](image.jpg)](http://www.example.com)`-      will now produce a linked image in the resulting PowerPoint file.-    + Fix error with empty table cell.  We require an empty `<a:p>` tag,-      even if the cell contains no paragraphs---otherwise PowerPoint-      complains of corruption.-    + Implement two-column slides.  This uses the columns/column div-      format described in the pandoc manual. At the moment, only two-      columns (half the screen each) are allowed. Custom widths are not-      supported.-    + Added more tests.--  * OpenDocument/ODT writers: improved rendering of formulas (#4170, oltolm).--  * Lua filters (Albert Krewinkel):--    + `data/pandoc.lua`: drop 'pandoc-api-version' from Pandoc objects-    + The current pandoc-types version is made available to Lua programs in-      the global `PANDOC_API_VERSION`. It contains the version as a list of-      numbers.-    + The pandoc version available as a global `PANDOC_VERSION` (a list-      of numbers).-    + `data/pandoc.lua`: make `Attr` an `AstElement`.-    + `data/pandoc.lua`: make all types subtypes of `AstElement`.-      `Pandoc`, `Meta`, and `Citation` were just plain functions and did-      not set a metatable on the returned value, which made it difficult-      to amend objects of these types with new behavior. They are now-      subtypes of AstElement, meaning that all their objects can gain-      new features when a method is added to the behavior object-      (e.g., `pandoc.Pandoc.behavior`).-    + `data/pandoc.lua`: split type and behavior tables.  Clearly distinguish-      between a type and the behavioral properties of an instance of that-      type. The behavior of a type (and all its subtypes) can now be-      amended by adding methods to that types `behavior` object, without-      exposing the type objects internals.  E.g.:-      ```lua-      pandoc.Inline.behavior.frob = function () print'42' end-      local str = pandoc.Str'hello'-      str.frob() -- outputs '42'-      ```-    + `data/pandoc.lua`: fix Element inheritance.  Extending all elements-      of a given type (e.g., all inline elements) was difficult, as the-      table used to lookup unknown methods would be reset every time a-      new element of that type was created, preventing recursive property-      lookup. This is was changed in that all methods and attributes of-      supertypes are now available to their subtypes.-    + `data/pandoc.lua`: fix attribute names of Citation (#4222).  The-      fields were named like the Haskell fields, not like the documented,-      shorter version.  The names are changed to match the documentation-      and Citations are given a shared metatable to enable simple-      extensibility.-    + `data/pandoc.lua`: drop function `pandoc.global_filter`.-    + Bump `hslua` version to 0.9.5.  This version fixes a bug that made it-      difficult to handle failures while getting lists or a Map from Lua.-      A bug in pandoc, which made it necessary to always pass a tag when-      using MetaList or MetaBlock, is fixed as a result. Using the pandoc-      module's constructor functions for these values is now optional-      (if still recommended).-    + Stop exporting `pushPandocModule` (API change).  The introduction-      of `runPandocLua` renders direct use of this function obsolete.-    + Update generation of module docs for lua filters.-    + `Lua.Module.Utils`: make stringify work on `MetaValues` (John-      MacFarlane).  I'm sure this was intended in the first place,-      but currently only `Meta` is supported.--  * Improve benchmarks.--    + Set the default extensions properly.-    + Improve benchmark argument parsing.  You can now say-      `make bench BENCHARGS="markdown latex reader"` and both the-      markdown and latex readers will be benchmarked.--  * MANUAL.txt simplify and add more structure (Mauro Bieg).--  * Generate README.md from template and MANUAL.txt.-    `make README.md` will generate the README.md after changes-    to MANUAL.txt have been made.--  * Update copyright notices to include 2018 (Albert Krewinkel).--pandoc (2.0.6)--  * Added `jats` as an input format.--    + Add Text.Pandoc.Readers.JATS, exporting `readJATS` (API-      change) (Hamish Mackenzie).-    + Improved citation handling in JATS reader.  JATS citations-      are now converted to pandoc citations, and JATS ref-lists-      are converted into a `references` field in metadata, suitable-      for use with pandoc-citeproc. Thus a JATS article with embedded-      bibliographic information can be processed with pandoc and-      pandoc-citeproc to produce a formatted bibliography.--  * Allow `--list-extensions` to take an optional FORMAT argument.-    This lists the extensions set by default for the selected FORMAT.-    The extensions are now alphabetized, and the `+` or `-`-    indicating the default setting comes before, rather than after,-    the extension.--  * Markdown reader:--    + Preserve original whitespace between blocks.-    + Recognize `\placeformula` as context.-    + Be pickier about table captions.  A caption starts with a `:` which-      can't be followed by punctuation.  Otherwise we can falsely interpret-      the start of a fenced div, or even a table header line like-      `:--:|:--:`, as a caption.-    + Always use four space rule for example lists.  It would be awkward-      to indent example list contents to the first non-space character after-      the label, since example list labels are often long.  Thanks to-      Bernhard Fisseni for the suggestion.-    + Improve raw tex parsing.  Note that the Markdown reader is also-      affected by the `latex_macros` extension changes described below-      under the LaTeX reader.--  * LaTeX reader:--    + `latex_macros` extension changes (#4179).  Don't pass through macro-      definitions themselves when `latex_macros` is set.  The macros-      have already been applied.  If `latex_macros` is enabled, then-      `rawLaTeXBlock` in Text.Pandoc.Readers.LaTeX will succeed in parsing-      a macro definition, and will update pandoc's internal macro map-      accordingly, but the empty string will be returned.-    + Export `tokenize`, `untokenize` (API change).-    + Use `applyMacros` in `rawLaTeXBlock`, `rawLaTeXInline`.-    + Refactored `inlineCommand`.-    + Fix bug in tokenizer.  Material following `^^` was-      dropped if it wasn't a character escape.  This only affected-      invalid LaTeX, so we didn't see it in the wild, but it appeared-      in a QuickCheck test failure.-    + Fix regression in LateX tokenization (#4159).  This mainly affects the-      Markdown reader when parsing raw LaTeX with escaped spaces.-    + Add tests of LaTeX tokenizer.-    + Support `\foreignlanguage` from babel.-    + Be more tolerant of `&` character (#4208).  This allows us to parse-      unknown tabular environments as raw LaTeX.--  * Muse reader (Alexander Krotov):--    + Parse anchors immediately after headings as IDs.-    + Require that note references does not start with 0.-    + Parse empty comments correctly.--  * Org reader (Albert Krewinkel):--    + Fix asterisks-related parsing error (#4180).-    + Support minlevel option for includes (#4154).  The level of headers-      in included files can be shifted to a higher level by specifying a-      minimum header level via the `:minlevel` parameter. E.g.-      `#+include: "tour.org" :minlevel 1` will shift the headers in-      tour.org such that the topmost headers become level 1 headers.-    + Break-up org reader test file into multiple modules.--  * OPML reader:--    + Enable raw HTML and other extensions by default for notes-      (#4164).  This fixes a regression in 2.0.  Note that extensions can-      now be individually disabled, e.g.  `-f opml-smart-raw_html`.--  * RST reader:--    + Allow empty list items (#4193).-    + More accurate parsing of references (#4156).  Previously we erroneously-      included the enclosing backticks in a reference ID (#4156).  This-      change also disables interpretation of syntax inside references, as-      in docutils.  So, there is no emphasis in `` `my *link*`_ ``.--  * Docx reader:--    + Continue lists after interruption (#4025, Jesse Rosenthal).-      Docx expects that lists will continue where they left off after an-      interruption and introduces a new id if a list is starting again. So-      we keep track of the state of lists and use them to define a "start"-      attribute, if necessary.-    + Add tests for structured document tags unwrapping (Jesse Rosenthal).-    + Preprocess Document body to unwrap `w:sdt` elements (Jesse Rosenthal,-      #4190).--  * Plain writer:--    + Don't linkify table of contents.--  * RST writer:--    + Fix anchors for headers (#4188).  We were missing an `_`.--  * PowerPoint writer (Jesse Rosenthal):--    + Treat lists inside BlockQuotes as lists.  We don't yet produce-      incremental lists in PowerPoint, but we should at least treat lists-      inside BlockQuotes as lists, for compatibility with other slide formats.-    + Add ability to force size.  This replaces the more specific-      `blockQuote runProp`, which only affected the size of blockquotes. We-      can use this for notes, etc.-    + Implement notes.  This currently prints all notes on a final slide.-      Note that at the moment, there is a danger of text overflowing the-      note slide, since there is no logic for adding further slides.-    + Implement basic definition list functionality to PowerPoint writer.-    + Don't look for default template file for Powerpoint (#4181).-    + Add pptx to isTextFormat list.  This is used to check standalone-      and not writing to the terminal.-    + Obey slide level option (Jesse Rosenthal).-    + Introduce tests.--  * Docx writer:--    + Ensure that `distArchive` is the one that comes with pandoc-      (#4182).  Previously a `reference.docx` in `~/.pandoc` (or the user data-      dir) would be used instead, and this could cause problems because a-      user-modified docx sometimes lacks vital sections that we count-      on the `distArchive` to supply.--  * Org writer:--    + Do not wrap "-" to avoid accidental bullet lists (Alexander Krotov).-    + Don't allow fn refs to wrap to beginning of line (#4171, with help from-      Alexander Krotov).  Otherwise they can be interpreted as footnote-      definitions.--  * Muse writer (Alexander Krotov):--    + Don't wrap note references to the next line (#4172).--  * HTML writer:--    + Use br elements in line blocks instead of relying on CSS-      (#4162).  HTML-based templates have had the custom CSS for-      `div.line-block` removed.  Those maintaining custom templates will want-      to remove this too.  We still enclose line blocks in a div with class-      `line-block`.--  * LaTeX writer:--    + Use `\renewcommand` for `\textlatin` with babel (#4161).-      This avoids a clash with a deprecated `\textlatin` command defined-      in Babel.-    + Allow fragile=singleslide attribute in beamer slides (#4169).-    + Use `\endhead` after `\toprule` in headerless tables (#4207).--  * FB2 writer:--    + Add cover image specified by `cover-image` meta (Alexander Krotov,-      #4195).--  * JATS writer (Hamish Mackenzie):--    + Support writing `<fig>` and `<table-wrap>` elements-      with `<title>` and `<caption>` inside them by using Divs with class set-      to one of `fig`, `table-wrap` or `caption` (Hamish Mackenzie).  The-      title is included as a Heading so the constraint on where Heading can-      occur is also relaxed.-    + Leave out empty alt attributes on links.-    + Deduplicate image mime type code.-    + Make `<p>` optional in `<td>` and `<th>` (#4178).-    + Self closing tags for empty xref (#4187).-    + Improve support for code language.--  * Custom writer:--    + Use init file to setup Lua interpreter (Albert Krewinkel).-      The same init file (`data/init`) that is used to setup the Lua-      interpreter for Lua filters is also used to setup the interpreter of-      custom writers.lua.-    + Define instances for newtype wrapper (Albert Krewinkel).  The custom-      writer used its own `ToLuaStack` instance definitions, which made-      it difficult to share code with Lua filters, as this could result-      in conflicting instances.  A `Stringify` wrapper is introduced to-      avoid this problem.-    + Added tests for custom writer.-    + Fixed definition lists and tables in `data/sample.lua`.--  * Fixed regression: when target is PDF, writer extensions were being-    ignored.  So, for example, `pandoc -t latex-smart -o file.pdf`-    did not work properly.--  * Lua modules (Albert Krewinkel):--    + Add `pandoc.utils` module, to hold utility functions.-    + Create a Haskell module Text.Pandoc.Lua.Module.Pandoc to-      define the `pandoc` lua module.-    + Make a Haskell module for each Lua module. Move definitions for the-      `pandoc.mediabag` modules to a separate Haskell module.-    + Move `sha1` from the main `pandoc` module to `pandoc.utils`.-    + Add function `pandoc.utils.hierarchicalize` (convert list of-      Pandoc blocks into (hierarchical) list of Elements).-    + Add function `pandoc.utils.normalize_date` (parses a date and-      converts it (if possible) to "YYYY-MM-DD" format).-    + Add function `pandoc.utils.to_roman_numeral` (allows conversion-      of numbers below 4000 into roman numerals).-    + Add function `pandoc.utils.stringify` (converts any AST element-      to a string with formatting removed).-    + `data/init.lua`: load `pandoc.utils` by default-    + Turn pipe, read into full Haskell functions.  The `pipe` and `read`-      utility functions are converted from hybrid lua/haskell functions-      into full Haskell functions. This avoids the need for intermediate-      `_pipe`/`_read` helper functions, which have dropped.-    + pandoc.lua: re-add missing MetaMap function.  This was a bug-      introduced in version 2.0.4.--  * Text.Pandoc.Class: Add `insertInFileTree` [API change].  This gives-    a pure way to insert an ersatz file into a `FileTree`.  In addition, we-    normalize paths both on insertion and on lookup.--  * Text.Pandoc.Shared: export `blocksToInlines'` (API change, Maura Bieg).--  * Text.Pandoc.MIME: Add opus to MIME type table as audio/ogg (#4198).--  * Text.Pandoc.Extensions:   Alphabetical order constructors for-    `Extension`.  This makes them appear in order in `--list-extensions`.--  * Allow lenient decoding of latex error logs, which are not always-    properly UTF8-encoded (#4200).--  * Update latex template to work with recent versions of beamer.-    The old template produced numbered sections with some recent-    versions of beamer.  Thanks to Thomas Hodgson.--  * Updated reference.docx (#4175).  Instead of just "Hello, world", the-    document now contains exemplars of most of the styles that have an-    effect on pandoc documents.  This makes it easier to see the effect-    of style changes.--  * Removed `default.theme` data file (#4096).  It is no longer needed now-    that we have `--print-highlight-style`.--  * Added `stack.lts9.yaml` for building with lts 9 and ghc 8.0.2.-    We still need this for the alpine static linux build, since-    we don't have ghc 8.2.2 for that yet.--  * Removed `stack.pkg.yaml`.  We only really need `stack.yaml`; we-    can put flag settings for pandoc-citeproc there.--  * Makefile: Add 'trypandoc' and 'pandoc-templates' targets to-    make releases easier.--  * MANUAL.txt:--    + Add note on what formats have `+smart` by default.-    + Use native syntax for custom-style (#4174, Mauro Bieg).-    + Introduce dedicated Extensions section, since some extensions-      affect formats other than markdown (Mauro Bieg, #4204).-    + Clarify default html output for `--section-divs` (Richard Edwards).--  * filters.md: say that Text.Pandoc.JSON comes form pandoc-types.-    Closes jgm/pandoc-website#16.--  * epub.md: Delete removed `-S` option from command (#4151, Georger Araújo).--pandoc (2.0.5)--  * Fix a bug in 2.0.4, whereby pandoc could not read the theme files-    generated with `--print-highlight-style` (#4133).  Improve JSON-    serialization of styles.--  * Fix CSS issues involving line numbers (#4128).-    Highlighted code blocks are now enclosed in a div with class `sourceCode`.-    Highlighting CSS no longer sets a generic color for pre and code; we only-    set these for class `sourceCode`.--  * `--pdf-engine-opt`: fix bug where option order was reversed (#4137).--  * Add PowerPoint (pptx) writer (Jesse Rosenthal).-    It works following the standard Pandoc conventions for making other-    sorts of slides. Caveats:--    + Syntax highlighting is not yet implemented. (This is difficult-      because there are no character classes in Powerpoint.)-    + Footnotes and Definition lists are not yet implemented. (Notes will-      usually take the form of a final slide.-    + Image placement and auto-resizing has a few glitches.-    + Reference powerpoint files don't work dependably from the command-      line. This will be implemented, but at the moment users are advised-      to change themes from within Powerpoint.--  * Create shared Text.Pandoc.Writers.OOXML module (Jesse Rosenthal).-    This is for functions used by both Powerpoint and Docx writers.--  * Add default pptx data for Powerpoint writer (Jesse Rosenthal).--  * Add `empty_paragraphs` extension.--    + Deprecate `--strip-empty-paragraphs` option.  Instead we now-      use an `empty_paragraphs` extension that can be enabled on-      the reader or writer.  By default, disabled.-    + Add `Ext_empty_paragraphs` constructor to `Extension`.-    + Revert "Docx reader: don't strip out empty paragraphs."-      This reverts commit d6c58eb836f033a48955796de4d9ffb3b30e297b.-    + Implement `empty_paragraphs` extension in docx reader and writer,-      opendocument writer, HTML reader and writer.-    + Add tests for `empty_paragraphs` extension.--  * Markdown reader:--    + Don't parse native div as table caption (#4119).-    + Improved computation of column widths in pipe tables.-      Pipe tables with lines longer than the text width (as set-      by `--columns`) are now scaled to text width, with the relative-      widths of columns determined by the ratios between the-      header lines.  Previously we computed column widths using-      the ratio of header line lengths to column width, so that-      tables with narrow header lines were extremely thin, which-      was very rarely the desired result.--  * LaTeX reader: fix `\` before newline (#4134).  This should be a space,-    as long as it's not followed by a blank line. This has been fixed at the-    tokenizer level.--  * Muse reader (Alexander Krotov):--    + Add test for `#disable-tables` directive in Emacs mode.-    + Don't allow emphasis to be preceded by letter.-    + Add underline support in Emacs Muse mode..-    + Support multiline directives in Amusewiki mode--  * Man writer: omit internal links (#4136).  That is, just print the link-    text without the URL.--  * Markdown reader: accept processing instructions as raw HTML (#4125).--  * Lua filters (Albert Krewinkel):--    + Use script to initialize the interpreter.  The file `init.lua` is-      used to initialize the Lua interpreter which is used in Lua filters.-      This gives users the option to require libraries which they want to-      use in all of their filters, and to extend default modules.-    + Fix package loading for Lua 5.1.  The list of package searchers is-      named `package.loaders` in Lua 5.1 and LuaJIT, and `package.searchers`-      in Lua 5.2 and later.-    + Refactor lua module handling.  The integration with Lua's package/module-      system is improved: A pandoc-specific package searcher is prepended to-      the searchers in `package.searchers`. The modules `pandoc` and-      `pandoc.mediabag` can now be loaded via `require`.-    + Bump lower bound of hslua.  The release hslua 0.9.3 contains a new-      function which makes using Haskell functions as package loaders much-      easier.--  * reveal.js template:  add title-slide identifier to title slide (#4120).-    This allows it to be styled more easily.--  * LaTeX template: Added support for `pagestyle` variable (#4135,-    Thomas Hodgson)--  * Add `-threaded` to ghc-options for executable (#4130, fixes a build-    error on linux).---pandoc (2.0.4)--  * Add `--print-highlight-style` option.  This generates a JSON version-    of a highlighting style, which can be saved as a `.theme` file, modified,-    and used with `--highlight-style` (#4106, #4096).--  * Add `--strip-empty-paragraphs` option.  This works for any input format.-    It is primarily intended for use with docx and odt documents where-    empty paragraphs have been used for inter-paragraph spaces.--  * Support `--webtex` for `gfm` output.--  * Recognize `.muse` file extension.--  * Support beamer `\alert` in LaTeX reader. Closes #4091.--  * Docx reader: don't strip out empty paragraphs (#2252).-    Users who have a conversion pipeline from docx may want to consider adding-    `--strip-empty-paragraphs` to the command line.--  * Org reader (Albert Krewinkel): Allow empty list items (#4090).--  * Muse reader (Alexander Krotov):--    + Parse markup in definition list terms.-    + Allow definition to end with EOF.-    + Make code blocks round trip.-    + Drop common space prefix from list items.-    + Add partial round trip test.-    + Don't interpret XML entities.-    + Remove `nested`.-    + Parse `~~` as non-breaking space in Emacs mode.-    + Correctly remove indentation from notes.  Exactly one space is-      required and considered to be part of the marker.-    + Allow list items to be empty.-    + Add ordered list test.-    + Add more multiline definition tests.-    + Don't allow blockquotes within lists.-    + Fix reading of multiline definitions.-    + Add inline `<literal>` support.-    + Concatenate inlines of the same type--  * Docx writer: allow empty paragraphs (#2252).--  * CommonMark/gfm writer:--    + Use raw html for native divs/spans (#4113).  This allows a pandoc-      markdown native div or span to be rendered in gfm using raw html tags.-    + Implement `raw_html` and `raw_tex` extensions.  Note that `raw_html`-      is enabled by default for `gfm`, while `raw_tex` is disabled by default.--  * Muse writer (Alexander Krotov):--    + Test that inline math conversion result is normalized.-      Without normalization this test produced-      `<em>a</em><em>b</em><em>c</em>`.-    + Improve inline list normalization and move to writer.-    + Escape hash symbol.-    + Escape `----` to avoid accidental horizontal rules.-    + Escape only `</code>` inside code tag.-    + Additional `<verbatim>` is not needed as `<code>` is verbatim already.--  * LaTeX writer:--    + Allow specifying just width or height for image size.-      Previously both needed to be specified (unless the image was-      being resized to be smaller than its original size).-      If height but not width is specified, we now set width to-      textwidth. If width but not height is specified, we now set-      height to textheight.  Since we have `keepaspectratio`, this-      yields the desired result.-    + Escape `~` and `_` in code with `--listings` (#4111).--  * HTML writer: export `tagWithAttributes`.  This is a helper allowing-    other writers to create single HTML tags.--  * Let papersizes `a0`, `a1`, `a2`, ... be case-insensitive by-    converting the case as needed in LaTeX and ConTeXt writers.--  * Change `fixDisplayMath` from `Text.Pandoc.Writers.Shared`-    so that it no longer produces empty `Para`'s as an artifact.--  * `Text.Pandoc.Shared.blocksToInlines`:  rewrote using builder.-    This gives us automatic normalization, so we don't get-    for example two consecutive Spaces.--  * Include default CSS for 'underline' class in HTML-based templates.--  * revealjs template:  add `tex2jax` configuration for the-    math plugin.  With the next release of reveal.js, this will-    fix the problem of `$`s outside of math contexts being-    interpreted as math delimiters (#4027).--  * `pandoc.lua` module for use in lua filters (Albert Krewinkel):--    + Add basic lua List module (#4099, #4081).  The List module is-      automatically loaded, but not assigned to a global variable. It can be-      included in filters by calling `List = require 'List'`.  Lists of blocks,-      lists of inlines, and lists of classes are now given `List` as a metatable,-      making working with them more convenient.  E.g., it is now possible to-      concatenate lists of inlines using Lua's concatenation operator `..`-      (requires at least one of the operants to have `List` as a metatable):--          function Emph (emph)-            local s = {pandoc.Space(), pandoc.Str 'emphasized'}-            return pandoc.Span(emph.content .. s)-          end--      The `List` metatable is assigned to the tables which get passed to-      the constructors `MetaBlocks`, `MetaInline`, and `MetaList`. This-      enables the use of the resulting objects as lists.-    + `Lua/StackInstances`: push Pandoc and Meta via constructor.-      Pandoc and Meta elements are now pushed by calling the respective-      constructor functions of the pandoc Lua module. This makes serialization-      consistent with the way blocks and inlines are pushed to lua and allows-      to use List methods with the `blocks` value.-    + Add documentation for pandoc.List in `lua-filters.md`.--  * Use latest tagsoup.  This fixes a bug in parsing HTML tags with-    `&` (but not a valid entity) following them (#4094, #4088).--  * Use skylighting 0.4.4.1, fixing the color of unmarked code text-    when `numberLines` is used (#4103).--  * Make `normalizeDate` more forgiving (Mauro Bieg, #4101), not-    requiring a leading 0 on single-digit days.--  * Fix `--help` output for `--highlight-style` to include `FILE` (Mauro-    Bieg, #4095).--  * Clearer deprecation warning for `--latexmathml, --asciimathml, -m`.-    Previously we only mentioned `--latexmathml`, even if `-m` was-    used.--  * Changelog: fix description of lua filters in 2.0 release-    (Albert Krewinkel).  Lua filters were initially run *after* conventional-    (JSON) filters.  However, this was changed later to make it easier to deal-    with files in the mediabag. The changelog is updated to describe that-    feature of the 2.0 release correctly.--  * Change Generic JSON instances to TemplateHaskell (Jasper Van der Jeugt,-    #4085).  This reduces compile time and memory usage significantly.--  * `lua-filters.md`: Added tikz filter example.--  * Create alternative zip file for macOS binaries.--  * Create alternative zip file for Windows binaries.--  * Update INSTALL.md since we now provide zips for binaries.--  * Relax `http-types` dependency (Justus Sagemüller, #4084).--  * Add `epub.md`, `getting-started.md` to docs.  These used to live in-    the website repo.--  * Add `packages` target to Makefile.--  * Bump bounds for binary, http-types, tasty-hunit--pandoc (2.0.3)--  * Lua filters: preload text module (Albert Krewinkel, #4077).-    The `text` module is preloaded in lua. The module contains some UTF-8-    aware string functions, implemented in Haskell.  The module is loaded on-    request only, e.g.:--        text = require 'text'-        function Str (s)-          s.text = text.upper(s.text)-          return s-        end--  * Allow table-like access to attributes in lua filters (Albert Krewinkel,-    #4071).  Attribute lists are represented as associative lists in Lua. Pure-    associative lists are awkward to work with. A metatable is attached to-    attribute lists, allowing to access and use the associative list as if-    the attributes were stored in as normal key-value pair in table.-    Note that this changes the way `pairs` works on attribute lists. Instead-    of producing integer keys and two-element tables, the resulting iterator-    function now returns the key and value of those pairs.  Use `ipairs` to-    get the old behavior.  Warning: the new iteration mechanism only works if-    pandoc has been compiled with Lua 5.2 or later (current default: 5.3).--  * Text.Pandoc.Parsing.uri:  allow `&` and `=` as word characters (#4068).-    This fixes a bug where pandoc would stop parsing a URI with an-    empty attribute:  for example, `&a=&b=` wolud stop at `a`.-    (The uri parser tries to guess which punctuation characters-    are part of the URI and which might be punctuation after it.)--  * Introduce `HasSyntaxExtensions` typeclass (Alexander Krotov, #4074).--    + Added new `HasSyntaxExtensions` typeclass for `ReaderOptions` and-      `WriterOptions`.-    + Reimplemented `isEnabled` function from `Options.hs` to accept both-      `ReaderOptions` and `WriterOptions`.-    + Replaced `enabled` from `CommonMark.hs` with new `isEnabled`.--  * Add `amuse` extension (Alexander Krotov) to enable Amuse wiki-    behavior for `muse`.  New `Ext_amuse` constructor for-    `Extension`. Note: this is switched on by default; for-    Emacs behavior, use `muse-amuse`.--  * Muse reader (Alexander Krotov):--    + Count only one space as part of list item marker.-    + Produce SoftBreaks on newlines. Now wrapping can be preserved-      with `--wrap=preserve`.-    + Add Text::Amuse footnote extensions.  Footnote end is indicated by-      indentation, so footnotes can be placed anywhere in the text,-      not just at the end of it.-    + Accept Emacs Muse definition lists when `-amuse`.-      Emacs Muse does not require indentation.--  * HTML reader:--    + Ensure we don't produce level 0 headers (#4076), even for chapter-      sections in epubs.  This causes problems because writers aren't set-      up to expect these.-    + Allow spaces after `\(` and before `\)` with `tex_math_single_backslash`.-      Previously `\( \frac{1}{a} < \frac{1}{b} \)` was not parsed as math in-      `markdown` or `html` `+tex_math_single_backslash`.-    + Parse div with class `line-block` as LineBlock.-    + Don't fail with block-level content in figcaption (Mauro Bieg, #4183).--  * MANUAL: clarify that math extensions work with HTML.-    Clarify that `tex_math_dollars` and `tex_math_single_backslash`-    will work with HTML as well as Markdown.--  * Creole reader: Fix performance issue for longer lists (Sascha Wilde,-    #4067).--  * RST reader: better support for 'container' directive (#4066).-    Create a div, incorporate name attribute and classes.--  * LaTeX reader:--    + Support column specs like `*{2}{r}` (#4056).  This is equivalent to-      `rr`.  We now expand it like a macro.-    + Allow optional args for parbox (#4056).-    + Allow optional arguments on `\footnote` (#4062).--  * EPUB writer: Fixed path for cover image (#4069).  It was previously-    `media/media/imagename`, and should have been `media/imagename`.--  * Markdown writer: fix bug with doubled footnotes in grid tables-    (#4061).--  * LaTeX template:  include natbib/biblatex after polyglossia (#4073).-    Otherwise we seem to get an error; biblatex wants polyglossia-    language to be defined.--  * Added examples to lua filters documentation.---pandoc (2.0.2)--  * Deprecated ancient HTML math methods: `--latexmathml`, `--gladtex`,-    `--mimetex`, `--jsmath`.--  * Fixed URIs in `data/jats.csl`.  They were being rendered twice,-    leading to invalid XML in default JATS output with pandoc-citeproc.--  * `lua-filters.md`: use real-world man page filter as example.--  * Add lua filter functions `walk_inline` and `walk_block`-    in the pandoc module, to apply filters inside particular-    inline and block elements.--  * Refactored some code from `Text.Pandoc.Lua.PandocModule`-    into new internal module `Text.Pandoc.Lua.Filter`.--  * Markdown reader:--    + Allow fenced code blocks to be indented 1-3 spaces (#4011).-      This brings our handling of them into alignment with CommonMark's.-    + Fix YAML metadata with "chomp" (`|-`).  Previously if a-      YAML block under `|-` contained a blank line, pandoc would-      not parse it as metadata.--  * Removed `etc.` from abbreviations file.  Often `etc.` ends a-    sentence, and we want the period to be treated as a-    sentence-ending period.--  * Fix regression with `--metadata` (#4054).  Values specified with-    `--metadata` should replace a metadata value set in the document-    itself, rather than creating a list including a new value.--  * EPUB writer:--    + Fix EPUB OCF structure.  #3720 had been improperly implemented.-    + Fix modified paths for raw HTML tags (src, poster, etc.)-      (#4050, #4055). This had not been updated for the new EPUB-      container layout, with a separate text/ subdirectory.-    + Fix image paths with empty `--epub-subdirectory`.--  * Miscellaneous code cleanup (Alexander Krotov).--  * Use pandoc-types 1.17.3, which adds `Walkable` instances-    for `[Block] Block` and `[Inline] Inline`.--  * Remove obsolete `stack.full.yaml` (#4052).--  * Change to using pandoc-citeproc 0.12.1 in binary packages.--  * Consolidate math output method documentation (#4049, Mauro Bieg).--  * `MANUAL.txt`: fix header level of "Extension: emoji" (Albert Krewinkel).--  * Use lua filter to generate man page from `MANUAL.txt`, replacing old-    Haskell filters.  This is easier and faster.--  * Improved `INSTALL.md`.--  * Update commands to extract deb archive on Linux (#4043, Salim B).---pandoc (2.0.1.1)--  * Improved fix to #3989 (parsing of HTML tags containing-    `>` in an attribute or comment). The previous fix (in 2.0.1) only-    worked in certain cases.--  * FB2 writer (Alexander Krotov):--    + Add `unrecognised` genre to `<title-info>`-      (Alexander Krotov).  XML schema requires at least one genre.-    + Remove `<annotation>` from `<body>`.--  * CommonMark writer: fix strikethrough for `gfm` (#4038).--  * Use texmath 0.10, which adds support for a wider range of-    symbols and fixes default column alignments in MathML-    and OMML.--  * Highlighting fixes, using skylighting 0.4.3.2:--    + Fix invalid CSS.-    + Support `lineAnchors` (or `line-anchors`) in HTML code blocks.-    + Ensure that code lines don't get duplicate identifiers (#4031).-      The line identifiers are built using the code block's identifier-      as a prefix. If the code block has null identifier, we use-      `cb1`, `cb2`, etc.--  * Added a few abbreviations to `data/abbreviations`,-    and sorted the list (#3984, Wandmalfarbe).--  * Improved support for columns in HTML writer (#4028).--    + Remove `width` attribute from the `div`.-    + Remove space between `<div class="column">` elements,-      since this prevents columns whose widths sum to 100%-      (the space takes up space).-    + Move as much as possible of the CSS to the template.-    + Ensure that all the HTML-based templates (including epub)-      contain the CSS for columns.-    + Columns default to 50% width unless they are given a width-      attribute.  So if you want two equal-width columns, you-      can use a div with class `column` and no `width` attribute.--  * SelfContained: use `base64` for css links with media attribute (#4026).-    This fixes `--self-contained` with S5.--  * Improve `pandoc-template-mode.el` (Vaclav Haisman).--  * Issue INFO, not WARNING, when a .sty file cannot be-    read in LaTeX reader.  It is normally not an issue requiring-    a fix from the user if .sty files are not found.--  * INSTALL.md: MacOS instructions needed xar -f (adam234).--  * MANUAL.txt:--    + Clarify that --setext-headers doesn't affect gfm output (#4035).-    + Clarify what is needed to open and close a div in `fenced_divs`-      (#4039, Tristano Ajmone).-    + Removed reference to `default.beamer` in docs (#4024).-      Also added mention of other templates affecting PDF output-      with different settings.--pandoc (2.0.1)--  * Fixed regression in parsing of HTML comments in markdown and other-    non-HTML formats (`Text.Pandoc.Readers.HTML.htmlTag`) (#4019).-    The parser stopped at the first `>` character, even if it wasn't-    the end of the comment.--  * Creole reader (Sascha Wilde):--    + Fix some minor typos and formatting.-    + Add additional test on nowiki-block after para.-    + Fix lists with trailing white space.--  * LaTeX reader: handle `%` comment right after command.-    For example, `\emph%`.--  * Markdown reader:  make sure fenced div closers work in lists.-    Previously the following failed:--        ::: {.class}-        1. one-        2. two-        :::--    and you needed a blank line before the closing `:::`.--  * Make `fenced_divs` affect the Markdown writer.  If `fenced_divs` is-    enabled, Divs will be rendered as fenced divs.--  * LaTeX/Beamer writer: support "blocks" inside columns and other Divs-    (#4016).--  * HTML Writer: consistently use dashed class-names (Mauro Bieg, #3556).-    Note: this change may require some changes in CSS rules.-    `footnoteRef` has become `footnote-ref`, `titleslide` has-    become `title-slide`, and `footnoteBack` has become `footnote-back`.--  * JATS writer: Properly pass through author metadata (#4020).--  * FB2 writer (Alexander Krotov):--    + Write blocks outside of `<p>` in definitions.-    + Make bullet lists consistent with ordered lists, repeating-      the marker for the outer list rather than indenting sublists,-      since indentation does not work in readers.-    + Add new style FB2 tests.--  * `Text.Pandoc.ImageSize`: Add `Millimeter` constructor to `Dimension`-    (#4012) [API change]. Now sizes given in 'mm' are no longer converted-    to 'cm'.--  * Revise documentation of small caps syntax (Andrew Dunning, #4013).--  * Fix broken reference links in manual (Andrew Dunning, #4014)--  * Fixed example of slide columns structure in changelog (#4015).-    Also documented this feature in MANUAL.txt.---pandoc (2.0.0.1)--  * EPUB writer:--    + Fixed filepaths for nonstandard epub-subdirectory values.-    + Ensure that epub2 is recognized as a non-text format,-      so that a template is used.-    + Don't include "prefix" attribute for ibooks for epub2.-      It doesn't validate.-    + Fix stylesheet paths; previously we had an incorrect-      stylesheet path for the cover page and nav page.--  * LaTeX reader:--    + Insert space when needed in macro expansion (#4007).-      Sometimes we need to insert a space after a control sequence-      to prevent it merging with a following letter.-    + Allow unbraced arguments for macros (#4007).-    + Allow body of macro definition to be unbraced (#4007).--  * Linux package build: ensure that pandoc-citeproc is statically linked.--  * trypandoc: add native, ms.--pandoc (2.0)--  [new features]--  * New output format `ms` (groff ms). Complete support, including-    tables, math, syntax highlighting, and PDF bookmarks. The writer uses-    texmath's new eqn writer to convert math to eqn format, so a ms file-    produced with this writer should be processed with `groff -ms -e` if-    it contains math.--  * New output format `jats` (Journal Article Tag Suite).  This is an XML-    format used in archiving and publishing articles.  Note that a-    URI-encoded CSL stylesheet (`data/jats.csl`) is added automatically-    unless a stylesheet is specified using `--css`.--  * New output format `gfm` (GitHub-flavored CommonMark) (#3841).-    This uses bindings to GitHub's fork of cmark, so it should parse-    gfm exactly as GitHub does (excepting certain postprocessing-    steps, involving notifications, emojis, etc.).  `markdown_github`-    has been deprecated in favor of `gfm`.--  * New output format `muse` (Emacs Muse) (Alexander Krotov, #3489).--  * New input format `gfm` (GitHub-flavored CommonMark) (#3841).-    This uses bindings to GitHub's fork of cmark.  `markdown_github`-    has been deprecated in favor of `gfm`.--  * New input format `muse` (Emacs Muse) reader (Alexander Krotov, #3620).--  * New input format `tikiwiki` (TikiWiki markup) (rlpowell, #3800).--  * New input format `vimwiki` (Vimwiki markup) (Yuchen Pei, #3705).-    Note that there is a new data file, `data/vimwiki.css`, which can-    be used to display the HTML produced by this reader and-    pandoc's HTML writer in the style of vimwiki's own HTML-    export.--  * New input format `creole` (Creole 1.0) (#3994, Sascha Wilde).--  * New syntax for Divs, with `fenced_divs` extension enabled by-    default (#168).  This gives an attractive, plain-text way to create-    containers for block-level content.--  * Added new syntax for including raw content in any output format,-    enabled by the `raw_attribute` extension (which is on by default-    for `markdown` and `multimarkdown`).  The syntax is the same as-    for fenced code blocks or code inlines, only with `{=FORMAT}` for-    attributes, where `FORMAT` is the name of the output format-    (e.g., `ms`, `html`).--  * Implement multicolumn support for slide formats (#1710).-    The structure expected is:--        :::::::::::::: {.columns}-        ::: {.column width="40%"}-        contents...-        :::-        ::: {.column width="60%"}-        contents...-        :::-        ::::::::::::::--    Support has been added for beamer and all HTML slide formats.--  * Allows line comments in templates, beginning with `$--` (#3806).-    (Requires doctemplates 0.2.1.)--  * Add `--eol=crlf|lf|native` flag and writer option to control line endings-    (Stefan Dresselhaus, #3663, #2097).--  * Add `--log` option to save log messages in JSON format to a file (#3392).--  * Add `--request-header` option, to set request headers when pandoc-    makes HTTP requests to fetch external resources. For example:-    `--request-header User-Agent:blah`.--  * Added lua filters (Albert Krewinkel, #3514).  The new `--lua-filter`-    option works like `--filter` but takes pathnames of special lua filters-    and uses the lua interpreter baked into pandoc, so that no external-    interpreter is needed.  Note that lua filters are all applied before-    regular filters, regardless of their position on the command line.-    For documentation of lua filters, see `doc/lua-filters.md`.--  * Set `PANDOC_READER_OPTIONS` in environment where filters are run.-    This contains a JSON representation of `ReaderOptions`, so filters-    can access it.--  * Support creation of pdf via groff `ms` and pdfroff.-    `pandoc -t ms -o output.pdf input.txt`.--  * Support for PDF generation via HTML and `weasyprint` or `prince`-    (Mauro Bieg, #3909).  `pandoc -t html5 -o output.pdf --pdf-engine=prince`.--  * Added `--epub-subdirectory` option (#3720).  This specifies the-    subdirectory in the OCF container that holds the EPUB specific content.-    We now put all EPUB related content in an `EPUB/` subdirectory by default-    (later this will be configurable).--    ```-      mimetype-      META-INF/-        com.apple.ibooks.display-options.xml-        container.xml-      EPUB/ <<--configurable-->>-        fonts/ <<--static-->>-        font.otf-      media/ <<--static-->>-        cover.jpg-        fig1.jpg-      styles/ <<--static-->>-        stylesheet.css-      content.opf-      toc.ncx-      text/ <<--static-->>-        ch001.xhtml-    ```--  * Added `--resource-path=SEARCHPATH` command line option (#852).-    SEARCHPATH is separated by the usual character, depending on OS-    (: on unix, ; on windows).  Default resource path is just working-    directory.  However, the working directory must be explicitly-    specified if the `--resource-path` option is used.--  * Added `--abbreviations=FILE` option for custom abbreviations file-    (#256).  Default abbreviations file (`data/abbreviations`) contains-    a list of strings that will be recognized by pandoc's-    Markdown parser as abbreviations.  (A nonbreaking space will-    be inserted after the period, preventing a sentence space in-    formats like LaTeX.) Users can override the default by putting a file-    abbreviations in their user data directory (`~/.pandoc` on *nix).--  * Allow a theme file as argument to `--highlight-style`.-    Also include a sample, `default.theme`, in `data/`.--  * Allow `--syntax-definition` option for dynamic loading of syntax-    highlighting definitions (#3334).--  * Lists in `markdown` by default now use the CommonMark variable-    nesting rules (#3511). The indentation required for a block-level-    item to be included in a list item is no longer fixed, but is-    determined by the first line of the list item.  To be included in-    the list item, a block must be indented to the level of the first-    non-space content after the list marker. Exception: if are 5 or more-    spaces after the list marker, then the content is interpreted as an-    indented code block, and continuation paragraphs must be indented-    two spaces beyond the end of the list marker.  See the CommonMark-    spec for more details and examples.--    Documents that adhere to the four-space rule should, in most cases,-    be parsed the same way by the new rules.  Here are some examples-    of texts that will be parsed differently:--        - a-          - b--    will be parsed as a list item with a sublist; under the four-space-    rule, it would be a list with two items.--        - a--              code--    Here we have an indented code block under the list item, even though it-    is only indented six spaces from the margin, because it is four spaces-    past the point where a continuation paragraph could begin.  With the-    four-space rule, this would be a regular paragraph rather than a code-    block.--        - a--                code--    Here the code block will start with two spaces, whereas under-    the four-space rule, it would start with `code`.  With the four-space-    rule, indented code under a list item always must be indented eight-    spaces from the margin, while the new rules require only that it-    be indented four spaces from the beginning of the first non-space-    text after the list marker (here, `a`).--    This change was motivated by a slew of bug reports from people-    who expected lists to work differently (#3125, #2367, #2575, #2210,-     #1990, #1137, #744, #172, #137, #128) and by the growing prevalance-    of CommonMark (now used by GitHub, for example).  Those who-    prefer the old behavior can use `-f markdown+four_space_rule`.--  * Added `four_space_rule` extension.  This triggers the old pandoc-    parsing rule for content nested under list items (the "four space-    rule").--  * Added `spaced_reference_links` extension (#2602).  It allows whitespace-    between the two parts of a reference link:  e.g.--        [a] [b]--        [b]: url--    This was previously enabled by default; it is now forbidden by default.--  * Add `space_in_atx_header` extension (#3512).  This is enabled by default-    in pandoc and GitHub markdown but not the other flavors.-    This requires a space between the opening #'s and the header-    text in ATX headers (as CommonMark does but many other implementations-    do not).  This is desirable to avoid falsely capturing things like--        #hashtag--    or--        #5--  * Add `sourcefile` and `outputfile` template variables (Roland Hieber,-    #3431).--  * Allow ibooks-specific metadata in epubs (#2693).  You can now have-    the following fields in your YAML metadata, and it will be treated-    appropriately in the generated EPUB:--    ```-      ibooks:-        version: 1.3.4-        specified-fonts: false-        ipad-orientation-lock: portrait-only-        iphone-orientation-lock: landscape-only-        binding: true-        scroll-axis: vertical-    ```---  [behavior changes]--  * Reader functions no longer presuppose that CRs have been-    stripped from the input. (They strip CRs themselves, before-    parsing, to simplify the parsers.)--  * Added support for translations (localization) (#3559).-    Currently this only affects the LaTeX reader, for things-    like `\figurename`.  Translation data files for 46 languages-    can be found in `data/translations`.--  * Make `--ascii` work with DocBook output too.--  * Rename `--latex-engine` to `--pdf-engine`,-    and `--latex-engine-opt` to `--pdf-engine-opt`.--  * Removed `--parse-raw` and `readerParseRaw`.  These were confusing.-    Now we rely on the `+raw_tex` or `+raw_html` extension with latex or html-    input.  Thus, instead of `--parse-raw -f latex` we use `-f latex+raw_tex`,-    and instead of `--parse-raw -f html` we use `-f html+raw_html`.--  * With `--filter` R filters are now recognized, even if they are-    not executable (#3940, #3941, Andrie de Vries).--  * Support SVG in PDF output, converting with `rsvg2pdf` (#1793).--  * Make epub an alias for epub3, not epub2.--  * Removed `--epub-stylesheet`; use `--css` instead (#3472, #847).-    Multiple stylesheets may be used.  Stylesheets will be taken both from-    `--css` and from the `stylesheet` metadata field (which can contain-    either a file path or a list of them).--  * `--mathml` and MathML in HTMLMathMethod no longer take an argument.-    The argument was for a bridge JavaScript that used to be necessary-    in 2004.  We have removed the script already.--  * `--katex` improvements.  The latest version is used, and the-    autoload script is loaded by default.--  * Change MathJax CDN default since old one is shutting down (#3544).-    Note:  The new URL requires a version number, which we'll have-    to update manually in subsequent pandoc releases in order to-    take advantage of mathjax improvements.--  * `--self-contained`: don't incorporate elements with `data-external="1"`-    (#2656).  You can leave an external link as it is by adding the attribute-    data-external="1" to the element.  Pandoc will then not try to-    incorporate its content when `--self-contained` is used.  This is-    similar to a feature already supported by the EPUB writer.--  * Allow `--extract-media` to work with non-binary input formats-    (#1583, #2289).  If `--extract-media` is supplied with a non-binary-    input format, pandoc will attempt to extract the contents of all-    linked images, whether in local files, data: uris, or external uris.-    They will be named based on the sha1 hash of the contents.--  * Make `papersize: a4` work regardless of the case of `a4`.-    It is converted to `a4` in LaTeX and `A4` in ConTeXt.--  * Make `east_asian_line_breaks` affect all readers/writers (#3703).--  * Underlined elements are now treated consistently by readers-    (#2270, hftf); they are always put in a Span with class `underline`.-    This allows the user to treat them differently from other emphasis,-    using a filter.  Docx, Org, Textile, Txt2Tags, and HTML readers-    have been changed.--  * Improved behavior of `auto_identifiers` when there are explicit ids-    (#1745).  Previously only autogenerated ids were added to the list-    of header identifiers in state, so explicit ids weren't taken-    into account when generating unique identifiers.  Duplicated-    identifiers could result.  This simple fix ensures that explicitly given-    identifiers are also taken into account.--  * Use `table-of-contents` for contents of toc, make `toc` a boolean-    (#2872).  Changed markdown, rtf, and HTML-based templates accordingly.-    This allows you to set `toc: true` in the metadata; this-    previously produced strange results in some output formats.-    For backwards compatibility, `toc` is still set to the-    toc contents.  But it is recommended that you update templates-    to use `table-of-contents` for the toc contents and `toc`-    for a boolean flag.--  * Change behavior with binary format output to stdout.-    Previously, for binary formats, output to stdout was disabled-    unless we could detect that the output was being piped (and not-    sent to the terminal).  Unfortunately, such detection is not-    possible on Windows, leaving windows users no way to pipe binary-    output.  So we have changed the behavior in the following way:--    + Output to stdout is allowed when it can be determined that-      the output is being piped (on non-Windows platforms).-    + If the `-o` option is not used, binary output is never sent-      to stdout by default; instead, an error is raised.-    + If `-o -` is used, binary output is sent to stdout, regardless-      of whether it is being piped. This works on Windows too.--  * Better error behavior:  uses of `error` have been replaced by-    raising of `PandocError`, which can be trapped and handled by the-    calling program.--  * Removed `hard_line_breaks` extension from `markdown_github` (#3594).-    GitHub has two Markdown modes, one for long-form documents like READMEs-    and one for short things like issue comments. In issue comments, a line-    break is treated as a hard line break. In README, wikis, etc., it is-    treated as a space as in regular Markdown.  Since pandoc is more likely to-    be used to convert long-form documents from GitHub Markdown,-    `-hard_line_breaks` is a better default.--  * Include `backtick_code_blocks` extension in `mardkown_mmd` (#3637).--  * Escape `MetaString` values (as added with `-M/--metadata` flag) (#3792).-    Previously they would be transmitted to the template without any-    escaping.  Note that `--M title='*foo*'` yields a different result from--        ----        title: *foo*-        -----    In the latter case, we have emphasis; in the former case, just-    a string with literal asterisks (which will be escaped-    in formats, like Markdown, that require it).--  * Allow `em`, `cm`, `in` for image height/width in HTML, LaTeX (#3450).--  * HTML writer: Insert `data-` in front of unsupported attributes.  Thus,-    a span with attribute `foo` gets written to HTML5 with `data-foo`, so-    it is valid HTML5.  HTML4 is not affected.  This will allow us to use-    custom attributes in pandoc without producing invalid HTML. (With help-    from Wandmalfarbe, #3817.)--  * Plain writer:  improved super/subscript rendering.  We now-    handle more non-digit characters for which there are-    sub/superscripted unicode characters.  When unicode-    sub/superscripted characters are not available, we use-    `_(..)` or `^(..)` (#3518).--  * Docbook, JATS, TEI writers: print INFO message when omitting interior-    header (#3750).  This only applies to section headers inside list items,-    e.g., which were otherwise silently omitted.--  * Change to `--reference-links` in Markdown writer (#3701).  With-    `--reference-location` of `section` or `block`, pandoc will now repeat-    references that have been used in earlier sections.  The Markdown-    reader has also been modified, so that *exactly* repeated references-    do not generate a warning, only references with the same label but-    different targets.  The idea is that, with references after every block,-    one might want to repeat references sometimes.--  * ODT/OpenDocument writer:--    + Support `lang` attribute (#1667).-    + Added support for `--toc` (#2836).  Thanks to @anayrat.--  * Docx writer:--    + `lang` meta, see #1667 (Mauro Bieg, #3515).-    + Change `FigureWithCaption` to `CaptionedFigure` (iandol, #3658).-    + Use `Table` rather than `Table Normal` for table style (#3275).-      `Table Normal` is the default table style and can't be modified.-    + Pass through comments (#2994).  We assume that comments are defined as-      parsed by the docx reader:--        I want <span class="comment-start" id="0" author="Jesse Rosenthal"-        date="2016-05-09T16:13:00Z">I left a comment.</span>some text to-        have a comment <span class="comment-end" id="0"></span>on it.--      We assume also that the id attributes are unique and properly-      matched between comment-start and comment-end.-    + Bookmark improvements.  Bookmark start/end now surrounds content rather-      than preceding it.  Bookmarks generated for Div with id-      (jgm/pandoc-citeproc#205).-    + Add `keywords` metadata to docx document properties (Ian).--  * RST writer: support unknown interpreted text roles by-    parsing them as `Span` with `role` attributes (#3407).  This-    way they can be manipulated in the AST.--  * HTML writer:--    + Line block: Use class instead of style attribute (#1623).  We now-      issue `<div class="line-block">` and include a default definition-      for `line-block` in the default templates, instead of hard-coding a-      `style` on the div.-    + Add class `footnoteBack` to footnote back references (Timm Albers).-      This allows for easier CSS styling.-    + Render SmallCaps as span with smallcaps class (#1592), rather than-      using a style attribute directly.  This gives the user more flexibility-      in styling small caps in CSS.-    + With reveal.js we use `data-src` instead of `src` for images for-      lazy loading.-    + Special-case `.stretch` class for images in reveal.js (#1291).-      Now in reveal.js, an image with class `stretch` in a paragraph-      by itself will stretch to fill the whole screen, with no-      caption or figure environment.--  * Added warnings for non-rendered blocks to writers.--  * Writers now raise an error on template failure.--  * When creating a PDF via LaTeX, warn if the font is missing some-    characters (#3742).--  * Remove initial check for PDF-creating program (#3819).-    Instead, just try running it and raise the exception if it-    isn't found at that point.  This improves things for users of Cygwin-    on Windows, where the executable won't be found by `findExecutable`-    unless `.exe` is added.  The same exception is raised as before, but-    at a later point.--  * Readers issue warning for duplicate header identifiers (#1745).-    Autogenerated header identifiers are given suffixes so as not to clash-    with previously used header identifiers. But they may still coincide with-    an explicit identifier that is given for a header later in the document,-    or with an identifier on a div, span, link, or image. We now issue-    a warning in this case, so users can supply an explicit identifier.--  * CommonMark reader now supports `emoji`, `hard_line_breaks`, `smart`,-    and `raw_html` extensions.--  * Markdown reader:--    + Don't allow backslash + newline to affect block structure (#3730).-      Note that as a result of this change, the following, which formerly-      produced a header with two lines separated by a line break, will-      now produce a header followed by a paragraph:--        # Hi\-        there--      This may affect some existing documents that relied on-      this undocumented and unintended behavior.  This change makes pandoc-      more consistent with other Markdown implementations, and with itself-      (since the two-space version of a line break doesn't work inside ATX-      headers, and neither version works inside Setext headers).--    + A space between the opening # and the header is now required for-      pandoc and GitHub markdown (but not the other flavors). Disable-      the `space_in_atx_header` extension (#3512) to restore the-      original behavior.---  * Org reader (Albert Krewinkel, unless noted):--    + Support `table.el` tables (#3314).-    + Support macros (#3401).-    + Support the `#+INCLUDE:` file inclusion mechanism (#3510).-      Recognized include types are `example`, `export`, `src`, and-      normal org file inclusion.  Advanced features like line numbers-      and level selection are not implemented yet.-    + Interpret more meta value as inlines.  The values of the following-      meta variables are now interpreted using org-markup instead of-      treating them as pure strings: `keywords` (comma-separated list of-      inlines), `subtitle` (inline values), `nocite` (inline values, can-      be repeated).-    + Support `\n` export option (#3940).  This turns all newlines in the-      text into hard linebreaks.--  * RST reader:--    + Improved admonition support (#223).  We no longer add an-      `admonition` class, we just use the class for the type of admonition,-      `note` for example.  We put the word corresponding to the label in-      a paragraph inside a `Div` at the beginning of the admonition with-      class `admonition-title`.  This is about as close as we can get to-      RST's own output.-    + Initial support of `.. table` directive.  This allows adding captions-      to tables.-    + Support `.. line-block` directive.  This is deprecated but may still-      be in older documents.-    + Support scale and align attributes of images (#2662).-    + Implemented implicit internal header links (#3475).-    + Support RST-style citations (#853).  The citations appear at the end-      of the document as a definition list in a special div with id-      `citations`. Citations link to the definitions.-    + Recurse into bodies of unknown directives (#3432).-      In most cases it's better to preserve the content than-      to emit it.  This isn't guaranteed to have good results;-      it will fail spectacularly for unknown raw or verbatim directives.-    + Handle chained link definitions (#262).  For example,--          .. _hello:-          .. _goodbye: example.com--      Here both `hello` and `goodbye` should link to `example.com`.-    + Support anchors (#262).  E.g.--          `hello`--          .. _hello:--          paragraph--      This is supported by putting "paragraph" in a `Div` with id `hello`.-    + Support `:widths:` attribute for table directive.-    + Implement csv-table directive (#3533).  Most attributes are supported,-      including `:file:` and `:url:`.-    + Support unknown interpreted text roles by parsing them as Span-      with "role" attributes (#3407).  This way they can be manipulated in-      the AST.--  * HTML reader: parse a span with class `smallcaps` as `SmallCaps`.--  * LaTeX reader:--    + Implemented `\graphicspath` (#736).-    + Properly handle column prefixes/suffixes.  For example, in-      `\begin{tabular}{>{$}l<{$}>{$}l<{$} >{$}l<{$}}`-      each cell will be interpreted as if it has a `$`-      before its content and a `$` after (math mode).-    + Handle komascript `\dedication` (#1845).  It now adds a-      `dedication` field to metadata.  It is up to the user to supply-      a template that uses this variable.-    + Support all `\textXX` commands, where XX = `rm`, `tt`, `up`, `md`,-      `sf`, `bf` (#3488).  Spans with a class are used when there is-      nothing better.-    + Expand `\newenvironment` macros (#987).-    + Add support for LaTeX subfiles package (Marc Schreiber, #3530).-    + Better support for subfigure package (#3577).-      A figure with two subfigures turns into two pandoc-      figures; the subcaptions are used and the main caption-      ignored, unless there are no subcaptions.-    + Add support for \vdots (Marc Schreiber, #3607).-    + Add basic support for hyphenat package (Marc Schreiber, #3603).-    + Add basic `\textcolor` support (Marc Schreiber).-    + Add support for `tabularx` environment (Marc Schreiber, #3632).-    + Better handling of comments inside math environments (#3113).-      This solves a problem with commented out `\end{eqnarray}` inside-      an eqnarray (among other things).-    + Parse tikzpicture as raw verbatim environment if `raw_tex` extension-      is selected (#3692).  Otherwise skip with a warning.  This is better-      than trying to parse it as text!-    + Add `\colorbox` support (Marc Schreiber).-    + Set identifiers on Spans used for `\label`.-    + Have `\setmainlanguage` set `lang` in metadata.-    + Support etoolbox's `\ifstrequal`.-    + Support `plainbreak`, `fancybreak` et al from the memoir class-      (bucklereed, #3833).-    + Support `\let`.  Also, fix regular macros so they're expanded at the-      point of use, and NOT also the point of definition.  `\let` macros,-      by contrast, are expanded at the point of definition.  Added an-      `ExpansionPoint` field to `Macro` to track this difference.-    + Support simple `\def` macros.  Note that we still don't support-      macros with fancy parameter delimiters, like `\def\foo#1..#2{...}`.-    + Support \chaptername, \partname, \abstractname, etc.  (#3559,-      obsoletes #3560).-    + Put content of `\ref`, `\label`, `\eqref` commands into `Span` with-      attributes, so they can be handled in filters (Marc Schreiber, #3639)-    + Add Support for `glossaries` and `acronym` package (Marc Schreiber,-      #3589). Acronyms are not resolved by the reader, but acronym and-      glossary information is put into attributes on Spans so that they-      can be processed in filters.-    + Use `Link` instead of `Span` for `\ref`.  This makes more sense-      semantically and avoids unnecessary `Span [Link]` nestings when-      references are resolved.-    + Rudimentary support for `\hyperlink`.-    + Support `\textquoteleft|right`, `\textquotedblleft|right` (#3849).-    + Support `\lq`, `\rq`.-    + Implement `\newtoggle`, `\iftoggle`, `\toggletrue|false` from etoolbox-      (#3853).-    + Support `\RN` and `\Rn`, from biblatex (bucklereed, #3854).-    + Improved support for `\hyperlink`, `\hypertarget` (#2549).-    + Support `\k` ogonek accent.-    + Improve handling of accents.  Handle ogonek, and fall back correctly-      with forms like `\"{}`.-    + Better support for ogonek accents.-    + Support for `\faCheck` and `\faClose` (Marc Schreiber, #3727).-    + Support for `xspace` (Marc Schreiber, #3797).-    + Support `\setmainlanguage` or `\setdefaultlanguage` (polyglossia)-      and `\figurename`.-    + Better handling of `\part` in LaTeX (#1905).  Now we parse chapters as-      level 0 headers, and parts as level -1 headers.  After parsing, we-      check for the lowest header level, and if it's less than 1 we bump-      everything up so that 1 is the lowest header level.  So `\part` will-      always produce a header; no command-line options are needed.-    + Add block version of `\textcolor` (Marc Schreiber).-    + `\textcolor` works as inline and block command (Marc Schreiber).-    + `\textcolor` will be parse as span at the beginning of a paragraph-      (Marc Schreiber).-    + Read polyglossia/babel `\text(LANG){...}` (bucklereed)-    + Improved handling of include files in LaTeX reader (#3971).-      Previously `\include` wouldn't work if the included file-      contained, e.g., a begin without a matching end.-    + Support `\expandafter` (#3983).-    + Handle `\DeclareRobustCommand` (#3983).  Currently it's just treated-      as a synonym for `\newcommand`.-    + Handle `\lettrine` (Mauro Bieg).--  * Math improvements due to updates in texmath:--    + Improved handling of accents and upper/lower delimiters.-    + Support for output in GNU eqn format (used with *roff).-    + Allow `\boldsymbol` + a token without braces, and similarly-      with other styling commands.-    + Improve parsing of `\mathop` to allow multi-character operator names.-    + Add thin space after math operators when "faking it with-      unicode."--  * `walk` is now used instead of `bottomUp` in the `ToJSONFilter`-    instance for `a -> [a]` (pandoc-types).  Note that behavior-    will be slightly different, since `bottomUp`'s treatment of-    a function `[a] -> [a]` is to apply it to each sublist of a-    list, while walk applies it only to maximal sublists.-    Usually the latter behavior is what is wanted, and the-    former can be simulated when needed.  But there may be-    existing filters that need to be rewritten in light of the-    new behavior.  Performance should be improved.--  * There are some changes to syntax highlighting due to revisions-    in the `skylighting` library:--    + Support for `powershell` has been added, and many syntax-      definitions have been updated.-    + Background colors have been added to the `kate` style.-    + The way highlighted code blocks are formatted in HTML has-      been changed (David Baynard), in ways that may require-      changes in hard-coded CSS affecting highlighting.-      (If you haven't included hard-coded highlighting CSS in-      your template, you needn't change anything.)---  [API changes]--  * New module `Text.Pandoc.Class` (Jesse Rosenthal, John MacFarlane).-    This contains definitions of the `PandocMonad` typeclass, the-    `PandocIO` and `PandocPure` monads, and associated functions.--  * Changed types of all writers and readers.--    + We now use `Text` instead of `String` in the interface (#3731).-      (We have not yet changed the internals of most readers to work-      with `Text`, but making this change in the API now opens up a-      path to doing that.)-    + The result is now of form `m a` with constraint `PandocMonad m`.-      Readers and writers can be combined to form monadic values which-      can be run using either `runIO` or `runPure`.  If `runIO` is used,-      then both readers and writers will be able to do IO when needed-      (for include files, for example); if `runPure` is used,-      then the functions are pure and will not touch IO.-    + Where previously you used-      `writeRST def (readMarkdown def "[foo](url)")`, now you-      would use-      `runPure $ readMarkdown def (pack "[foo](url)") >>= writeRST def`.--  * New module `Text.Pandoc.Readers` (Albert Krewinkel).  This-    contains reader helper functions formerly defined in the-    top-level `Text.Pandoc` module.--    + Changed `StringReader` -> `TextReader`.-    + `getReader` now returns a pair of a reader and-      `Extensions`, instead of building the extensions into the-      reader (#3659).  The calling code must explicitly set-      `readerExtensions` using the `Extensions` returned.  The-      point of the change is to make it possible for the calling-      code to determine what extensions are being used.--  * New module `Text.Pandoc.Writers` (Albert Krewinkel).-    This contains writer helper functions formerly defined in the-    top-level `Text.Pandoc` module.--    + Changed `StringWriter` -> `TextWriter`.-    + `getWriter` now returns a pair of a reader and-      `Extensions`, instead of building the extensions into the-      reader (#3659).  The calling code must explicitly set-      `readerExtensions` using the `Extensions` returned.  The-      point of the change is to make it possible for the calling-      code to determine what extensions are being used.--  * New module `Text.Pandoc.Lua`, exporting `runLuaFilter` (Albert Krewinkel,-    #3514).--  * New module `Text.Pandoc.App`.  This abstracts out the functionality-    of the command line program (`convertWithOpts`), so it can be reproduced-    e.g. in a desktop or web application.  Instead of exiting, we throw errors-    (#3548), which are caught (leading to exit) in pandoc.hs, but allow other-    users of `Text.Pandoc.App` to recover.  `pandoc.hs` is now a 2-liner.-    The module also exports some utility functions for parsing options-    and running filters.--  * New module `Text.Pandoc.Logging` (exported module) (#3392).-    This now contains the `Verbosity` definition previously in-    `Text.Pandoc.Options`, as well as a new `LogMessage` datatype that will-    eventually be used instead of raw strings for warnings.  This will enable-    us, among other things, to provide machine-readable warnings if desired.-    Include ToJSON instance and showLogMessage.  This gives us the possibility-    of both machine-readable and human-readable output for log messages.--  * New module `Text.Pandoc.BCP47`, with `getLang`, `Lang(..)`, `parseBCP47`.--  * New module `Text.Pandoc.Translations`, exporting `Term`,-    `Translations`, `readTranslations`.--  * New module `Text.Pandoc.Readers.LaTeX.Types', exporting `Macro`, `Tok`,-    `TokType`, `Line`, `Column`.--  * `Text.Pandoc.Error`: added many new constructors for `PandocError`.--  * Expose some previously private modules (#3260).  These are often-    helpful to people writing their own reader or writer modules:--    + `Text.Pandoc.Writers.Shared`-    + `Text.Pandoc.Parsing`-    + `Text.Pandoc.Asciify`-    + `Text.Pandoc.Emoji`-    + `Text.Pandoc.ImageSize`-    + `Text.Pandoc.Highlighting`-`-  * New module `Text.Pandoc.Extensions` (Albert Krewinkel):-    Extension parsing and processing functions were defined in the top-level-    `Text.Pandoc` module.  These functions are moved to the Extensions-    submodule as to enable reuse in other submodules.--  * Add `Ext_raw_attribute` constructor for `Extension`.--  * Add `Ext_fenced_divs` constructor for `Extension'.--  * Add `Ext_four_space_rule` constructor in `Extension`.--  * Add `Ext_gfm_auto_identifiers` constructor for `Extension`.--  * Add `Monoid` instance for `Extensions`.--  * Add `Text.Pandoc.Writers.Ms`, exporting `writeMs`.--  * Add `Text.Pandoc.Writers.JATS`, exporting `writeJATS`.--  * Add `Text.Pandoc.Writers.Muse`, exporting `writeMuse`.--  * Add `Text.Pandoc.Readers.Muse`, exporting `readMuse`.--  * Add `Text.Pandoc.Readers.TikiWiki`, exporting `readTikiWiki`.--  * Add `Text.Pandoc.Readers.Vimwiki`, exporting `readVimwiki`.--  * Add `Text.Pandoc.Readers.Creole`, exporting `readCreole`.--  * Export `setVerbosity` from `Text.Pandoc`.--  * `Text.Pandoc.Pretty`: Add `Eq` instance for `Doc`.--  * `Text.Pandoc.XML`: `toEntities`: changed type to `Text -> Text`.--  * `Text.Pandoc.UTF8`:--    + Export `fromText`, `fromTextLazy`, `toText`, `toTextLazy`.-      Define `toString`, `toStringLazy` in terms of them.-    + Add new functions parameterized on `Newline`: `writeFileWith`,-      `putStrWith`, `putStrLnWith`, `hPutStrWith`, `hPutStrLnWith`.--  * `Text.Pandoc.MediaBag`: removed `extractMediaBag`.--  * `Text.Pandoc.Highlighting`:--    + `highlighting` now returns an Either rather than Maybe.-      This allows us to display error information returned by the skylighting-      library.  Display a warning if the highlighting library throws an error.-    + Add parameter for `SyntaxMap` to `highlight`.--  * `Text.Pandoc.Writers.Math`:--    + Export `defaultMathJaxURL`, `defaultKaTeXURL`.  This will ensure that-      we only need to update these in one place.--  * `Text.Pandoc.SelfContained`:--    + Removed `WriterOptions` parameter from `makeSelfContained`.-    + Put `makeSelfContained` in PandocMonad instead of IO.  This removes-      the need to pass MediaBag around and improves exceptions.  It also-      opens up the possibility of using makeSelfContained purely.-    + Export `makeDataURI`.--  * `Text.Pandoc.ImageSize`:--    + Export `lengthToDim`, new function `scaleDimension`.-    + Export `inEm` from ImageSize (#3450).-    + Change `showFl` and `show` instance for `Dimension` so-      extra decimal places are omitted.-    + Added `Em` as a constructor of `Dimension`.-    + Add `WriterOptions` parameter to `imageSize` signature (Mauro Bieg).--  * `Text.Pandoc.Templates`:--    + Change type of `renderTemplate'`.  Now it runs in `PandocMonad`-      and raises a proper `PandocTemplateError` if there are problems, rather-      than failing with uncatchable `error`.-    + Change signature of `getDefaultTemplate`.  Now it runs in any instance-      of `PandocMonad`, and returns a `String` rather than an `Either` value.-      And it no longer takes a `datadir` parameter, since this can be-      retrieved from `CommonState`.--  * `Text.Pandoc.Options`:--    + Added `writerEpubSubdirectory` to `WriterOptions` (#3720).-      The EPUB writer now takes its EPUB subdirectory from this option.-    + In `WriterOptions`, rename `writerLaTeXEngine` to `writerPdfEngine`-      and `writerLaTeXArgs` to `writerPdfArgs` (Mauro Bieg, #3909).-    + Add `writerSyntaxMap` to `WriterOptions`.-    + Removed `writerEpubStylesheet` from `WriterOptions`.-    + Remove `writerUserDataDir` from `WriterOptions`.  It is now carried-      in `CommonState` in `PandocMonad` instances.  (And thus it can be used-      by readers too.)-    + Changed `writerEpubMetadata` to a `Maybe String`.-    + Removed `readerApplyMacros` from `ReaderOptions`.  Now we just check-      the `latex_macros` reader extension.-    + FromJSON/ToJSON instances for `ReaderOptions`.-    + In `HTMLMathMethod`, the `KaTeX` contsructor now takes only-      one string (for the KaTeX base URL), rather than two.-    + Removed `writerSourceURL` from `WriterOptions`.  We now use-      `stSourceURL` in `CommonState`, which is set by `setInputFiles`.--  * `Text.Pandoc.Shared`:--    + `tabFilter` now takes a `Text`, not `String`.-    + `openURL`: Changed type from an Either.  Now it will just raise-      an exception to be trapped later.-    + Remove `normalizeSpaces` (#1530).-    + Remove `warn`.  (Use `report` from `Text.Pandoc.Class` instead.)-    + Export a new function `crFilter`.-    + Add `eastAsianLineBreakFilter` (previously in Markdown reader).-    + Provide custom `isURI` that rejects unknown schemes.-      (Albert Krewinkel, #2713).  We also export the set of known-      `schemes`.  The new function replaces the function of the same name-      from `Network.URI`, as the latter did not check whether a scheme is-      well-known.  All official IANA schemes (as of 2017-05-22) are-      included in the set of known schemes.  The four non-official schemes-      `doi`, `isbn`, `javascript`, and `pmid` are kept.-    + Remove `err`.-    + Remove `readDataFile`, `readDefaultDataFile`, `getReferenceDocx`,-      `getReferenceODT`. These now live in `Text.Pandoc.Class`,-      where they are defined in terms of `PandocMonad`-      primitives and have different signatures.-    + Remove `openURL`.  Use `openURL` from `Text.Pandoc.Class` instead.-    + Add `underlineSpan`.--  * `Text.Pandoc.Readers.HTML`: export new `NamedTag` class.--  * `Text.Pandoc.Readers.Markdown`: remove `readDocxWithWarnings`.-     With the new API one can simply use `getLog` after running-     the reader.--  * `Text.Pandoc.Readers.LaTeX`: Changed types for `rawLaTeXInline`-     and `rawLaTeXBlock`.  (Both now return a `String`, and they are-     polymorphic in state.)---  [bug fixes and under-the-hood improvements]--  * TEI writer: Added identifiers on `<div>` elements.--  * DokuWiki reader: Better handling for code block in list item (#3824).--  * Custom writer: Remove old preprocesesor conditionals (Albert Krewinkel).--  * ZimWiki writer: Removed internal formatting from note and table cells,-    because ZimWiki does not support it (Alex Ivkin, #3446).--  * MediaWiki writer:--    + Updated list of syntax highlighting languages (#3461).-      Now `r` gets you `<source>` rather than `<code>` (among others).-    + Add display attribute on `<math>` tags (#3452).  This allows display-      math to be rendered properly.-    + Remove newline before `</ref>` (#2652).-    + Don't softbreak lines inside list items (#3531).--  * Org writer:--    + Reduce to two spaces after bullets (#3417, Albert Krewinkel).-    + Add unit tests (Alexander Krotov).-    + Stop using raw HTML to wrap divs (Albert Krewinkel, #3771).-    + Do not strip `#` from Org anchor links (Alexander Krotov).--  * CommonMark writer:--    + Avoid excess blank lines at end of output.-    + Prefer pipe tables to HTML tables even if it means losing relative-      column width information (#3734).-    + Support table, strikethrough extensions, when enabled (as with gfm).-      Note that we bypass the commonmark writer from cmark and construct our-      own pipe tables, with better results.-    + Properly support `--wrap=none`.-    + Use smallcaps class for `SmallCaps` (#1592).-    + Omit "fig:" prefix in image titles.  This is used internally to-      indicate internal figures.--  * RST writer:--    + Properly handle table captions.-    + Don't wrap lines in in definition list terms.  Wrapping is not allowed.-    + Implemented `+/-smart` and improved escaping with `+smart`.-    + Add empty comments when needed to avoid including a blockquote-      in the indented content of a preceding block (#3675).-    + Improve grid table output, fix bug with empty rows (#3516).-      Uses the new `gridTable` in Writers.Shared, which is here-      improved to better handle 0-width cells.-    + Remove space at beginning/end of RST code span (#3496).  Otherwise-      we get invalid RST.  There seems to be no way to escape the space.-    + Add header anchors when header has non-standard id (#3937).-    + Correctly handle inline code containing backticks, using a `:literal:`-      role (#3974).-    + Don't backslash-escape word-internal punctuation (#3978).--  * Markdown writer:--    + Don't include variables in metadata blocks.  Previously variables set-      on the command line were included in e.g. YAML metadata, contrary to-      documentation and intentions.-    + Improved escaping with `+smart`.-    + Fixed grid tables embedded in grid tables (#2834).-    + Use span with class 'smallcaps' for SmallCaps, instead of a style-      attribute as before (#1592).-    + Escape initial `%` in a paragraph if the `pandoc_title_blocks`-      extension is enabled (#3454).  Otherwise in a document starting with-      a literal `%` the first line is wrongly interpreted as a title.-    + Fixed false ordered lists in YAML metadata (#3492, #1685).  Now we-      properly escape things that would otherwise start ordered lists,-      such as--          ----          title: 1. inline-          ...-    + Better handling of tables with empty columns (#3337).  We now-      calculate the number of columns based on the longest row (or the-      length of aligns or widths).-    + Escape unordered list markers at beginning of paragraph (#3497), to-      avoid false interpretation as a list.-    + Escape `|` appropriately.-    + Ensure space before list at top level (#3487).-    + Avoid spurious blanklines at end of document after tables and list,-      for example.-    + Fixed bugs in simple/multiline list output (#3384).-      Previously we got overlong lists with `--wrap=none`.  This is fixed.-      Previously a multiline list could become a simple list (and would-      always become one with `--wrap=none`).-    + Don't emit a simple table if `simple_tables` disabled (#3529).-    + Case-insensitive reference links (David A Roberts, #3616).-      Ensure that we do not generate reference links whose labels differ only-      by case.  Also allow implicit reference links when the link-      text and label are identical up to case.-    + Put space before reference link definitions (Mauro Bieg, #3630).-    + Better escaping for links (David A. Roberts, #3619).  Previously the-      Markdown writer would sometimes create links where there were none-      in the source.  This is now avoided by selectively escaping bracket-      characters when they occur in a place where a link might be created.-    + Added missing `\n` (David A. Roberts, #3647).-    + Fixed duplicated reference links with `--reference-links`-      and `--reference-location=section` (#3674).  Also ensure that there-      are no empty link references `[]`.-    + Avoid inline surround-marking with empty content (#3715).-      E.g. we don't want `<strong></strong>` to become `****`.-      Similarly for emphasis, super/subscript, strikeout.-    + Don't allow soft break in header (#3736).-    + Make sure `plain`, `markdown_github`, etc. work for raw.-      Previously only `markdown` worked.  Note: currently a raw block labeled-      `markdown_github` will be printed for any `markdown` format.-    + Ensure that `+` and `-` are escaped properly so they don't cause-      spurious lists (#3773).  Previously they were only-      if succeeded by a space, not if they were at end of line.-    + Use pipe tables if `raw_html` disabled and `pipe_tables` enabled,-      even if the table has relative width information (#3734).-    + Markdown writer: don't crash on `Str ""`.-    + Make `Span` with null attribute transparent.  That is, we don't use-      brackets or `<span>` tags to mark spans when there are no attributes;-      we simply output the contents.-    + Escape pipe characters when `pipe_tables` enabled (#3887).-    + Better escaping of `<` and `>`.  If `all_symbols_escapable` is set,-      we backslash escape these.  Otherwise we use entities as before.-    + When writing plain, don't use `&nbsp;` to separate list and indented-      code.  There's no need for it in this context, since this isn't to be-      interpreted using Markdown rules.-    + Preserve classes in JS obfuscated links (Timm Albers, #2989).-      HTML links containing classes originally now preserve them when using-      JavaScript email obfuscation.-    + Render `SmallCaps` as a native span when `native_spans` are enabled.-    + Always write attributes with `bracketed_spans` (d-dorazio).--  * Man writer:--    + Fix handling of nested font commands (#3568).  Previously pandoc emitted-      incorrect markup for bold + italic, for example, or bold + code.-    + Avoid error for definition lists with no definitions (#3832).--  * DocBook writer:--    + Fix internal links with `writerIdentifierPrefix opt`-      (#3397, Mauro Bieg).--  * Docx writer:--    + Don't include bookmarks on headers unless non-null id (#3476).-    + Support 9 levels of headers (#1642).-    + Allow 9 list levels (#3519).-    + Don't take `distArchive` from datadir (#3322).  The docx writer takes-      components from the distribution's version of `reference.docx` when it-      can't find them in a user's custom `reference.docx`.  Previously, we-      allowed a `reference.docx` in the data directory (e.g. `~/.pandoc`)-      to be used as the distribution's reference.docx.  This led to a-      bizarre situation where pandoc would produce a good docx using-      `--template ~/.pandoc/ref.docx`, but if `ref.docx` were moved to-      `~/.pandoc/reference.docx`, it would then produce a corrupted docx.-    + Fixed handling of soft hyphen (0173) (#3691).-    + Better handling of keywords (#3719).-    + Cleaner code for handling dir and style attributes for `Div`.-    + Use `Set` for dynamic styles to avoid duplicates.-    + Removed redundant element from data/docx/word/numbering.xml.-      The elements we need are generated when the document is-      compiled; this didn't do anything.-    + Activate `evenAndOddHeaders` from reference docx (#3901,-      Augustín Martín Barbero).--  * ODT/OpenDocument writer:--    + Calculate aspect ratio for percentage-sized images (Mauro Bieg, #3239).-    + Use more widely available bullet characters (#1400).  The old-      characters weren't available in some font sets.  These seem to work-      well on Windows and Linux versions of LibreOffice.-    + Wider labels for lists (#2421).  This avoids overly narrow labels for-      ordered lists with `()` delimiters.  However, arguably it creates-      overly wide labels for bullets.  Also, lists now start flush with-      the margin, rather than indented.-    + Fixed dropped elements in some ordered lists (#2434).--  * FB2 writer:--    + Don't render `RawBlock` as code.-    + Don't fail with an error on interior headers (e.g. in list) (#3750).-      Instead, omit them with an INFO message.-    + Add support for "lang" metadata (Alexander Krotov, #3625).-    + Format `LineBlock` as poem (Alexander Krotov).  Previously writer-      produced one paragraph with `<empty-line/>` elements, which are not-      allowed inside `<p>` according to FB2 schema.-    + Replace `concatMap` with `cMap` (Alexander Krotov).-    + Write FB2 lists without nesting blocks inside `<p>` (Alexander-      Krotov, #4004)--  * HTML writer:--    + Make sure `html4`, `html5` formats work for raw blocks/inlines.-    + Render raw inline environments when `--mathjax` used (#3816).-      We previously did this only with raw blocks, on the assumption-      that math environments would always be raw blocks. This has changed-      since we now parse them as inline environments.-    + Ensure we don't get two style attributes for width and height.-    + Report when not rendering raw inline/block.-    + Issue warning if no title specified and template used (#3473).-    + Info message if `lang` is unspecified (#3486).-    + Removed unused parameter in `dimensionsToAttributeList`.-    + Avoid two class attributes when adding `uri` class (#3716).-    + Fix internal links with `writerIdentifierPrefix opt` (#3397, Mauro-      Bieg).-    + Use revealjs's math plugin for mathjax (#3743).  This is a thin-      wrapper around mathjax that makes math look better on revealjs.-    + Slidy:  use h1 for all slides, even if they were originally-      level 2 headers (#3566).  Otherwise the built-in table of contents-      in Slidy breaks.--  * LaTeX writer:--    + Don't render LaTeX images with data: URIs (#3636).  Note that-      `--extract-media` can be used when the input contains data: URIs.-    + Make highlighted code blocks work in footnotes (Timm Albers).-    + Don't use figure inside table cell (#3836).-    + Use proper code for list enumerators (#3891).  This should fix problems-      with lists that don't use arabic numerals.-    + Always add hypertarget when there's a non-empty identifier (#2719).-      Previously the hypertargets were only added when there was actually-      a link to that identifier.-    + Use `%` after hypertarget before code block.-    + Add `\leavevmode` before hypertarget at start of paragraph (#2704,-      fixes formatting problems in beamer citations).-    + Don't use `lstinline` in \item[..] (#645).  If you do, the contents-      of item disappear or are misplaced.  Use `\texttt` instead.-    + Fix problem with escaping in `lstinline` (#1629).  Previously the-      LaTeX writer created invalid LaTeX when `--listings` was specified and-      a code span occurred inside emphasis or another construction.-    + Fix error with line breaks after empty content (#2874).  LaTeX-      requires something before a line break, so we insert a `~` if no-      printable content has yet been emitted.-    + Use BCP47 parser.-    + Fixed detection of otherlangs (#3770).  We weren't recursing into-      inline contexts.-    + Handle language in inline code with `--listings` (#3422).-    + Write euro symbol directly in LaTeX (Andrew Dunning, #3801).-      The textcomp package allows pdfLaTeX to parse `€` directly, making the-      `\euro` command unneeded.-    + Fixed footnotes in table captions (#2378).  Note that if the table has-      a first page header and a continuation page header, the notes will-      appear only on the first occurrence of the header.-    + In `writeBeamer` output, allow hyperlinks to frames (#3220).-      Previously you could link to a header above or below slide level but-      not *to* slide level.  This commit changes that.  Hypertargets are-      inserted inside frame titles; technically the reference is to just-      after the title, but in normal use (where slides are viewed full-      screen in a slide show), this does not matter.-    + Remove `\strut` at beginning of table cells (#3436).  This fixes a-      problem with alignment of lists in table cells.  The `\strut` at the-      end seems to be enough to avoid the too-close spacing that motivated-      addition of the strut  in #1573.-    + Add partial siunitx Support (Marc Schreiber, #3588).--  * ConTeXt writer:--    + Refactored to use BCP47 module.-    + Remove unnecessary `$` (Alexander Krotov, #3482).-    + Use header identifiers for chapters (#3968).--  * EPUB writer:--    + `title_page.xhtml` is now put in `text/`.-    + Don't strip formatting in TOC (#1611).--  * Textile reader:--    + Fix bug for certain links in table cells (#3667).-    + Allow 'pre' code in list item (#3916).--  * HTML reader:--    + Added warnings for ignored material (#3392).-    + Better sanity checks to avoid parsing unintended things as-      raw HTML in the Markdown reader (#3257).-    + Revise treatment of `li` with `id` attribute (#3596).  Previously we-      always added an empty div before the list item, but this created-      problems with spacing in tight lists.  Now we do this: If the list-      item contents begin with a `Plain` block, we modify the `Plain`-      block by adding a `Span` around its contents.  Otherwise, we add a-      `Div` around the contents of the list item (instead of adding an-      empty `Div` to the beginning, as before).-    + Add `details` tag to list of block tags (#3694).-    + Removed `button` from block tag list (#3717).  It is already in the-      `eitherBlockOrInlineTag` list, and should be both places.-    + Use `Set`s instead of lists for block tag lookup.-    + Rewrote to use `Text` throughout.  Effect on memory usage is modest-      (< 10%).-    + Use the lang value of `<html>` to set the lang meta value (bucklereed,-      #3765).-    + Ensure that paragraphs are closed properly when the parent block-      element closes, even without `</p>` (#3794).-    + Parse `<figure>` and `<figcaption>` (Mauro Bieg, #3813).-    + Parse `<main>` like `<div role=main>` (bucklereed, #3791).-      `<main>` closes `<p>` and behaves like a block element generally-    + Support column alignments (#1881).  These can be set either-      with a `width` attribute or with `text-width` in a `style` attribute.-    + Modified state type to be an instance of `HasLogMessages`, so-      `registerHeader` can issue warnings.-    + `</td>` or `</th>` should close any open block tag (#3991).-    + `<td>` should close an open `<th>` or `<td>`.-    + `htmlTag` improvements (#3989).  We previously failed on cases-      where an attribute contained a `>` character. This patch fixes the-      bug, which especially affects raw HTML in Markdown.--  * Txt2Tags reader:--    + Newline is not indentation (Alexander Krotov).--  * MediaWiki reader:--    + Allow extra hyphens after `|-` in tables (#2649).-    + Allow blank line after table start (#2649).-    + Fixed more table issues (#2649).-    + Ensure that list starts begin at left margin (#2606).  Including when-      they're in tables or other list items.-    + Make smart double quotes depend on `smart` extension (#3585).-    + Don't do curly quotes inside `<tt>` contexts (#3585).  Even if `+smart`.-    + Modified state type to be an instance of `HasLogMessages`, so-      `registerHeader` can issue warnings.--  * TWiki reader (Alexander Krotov):--    + Remove unnecessary `$` (#3597).-    + Simplify `linkText` (#3605).--  * EPUB reader:--    + Minor refactoring, avoiding explicit MediaBag handling.-      This all works behind the scenes in CommonState plumbing.--  * Docx reader:--    + Don't drop smartTag contents (#2242).-    + Handle local namespace declarations (#3365).  Previously we didn't-      recognize math, for example, when the xmlns declaration occurred on-      the element and not the root.-    + More efficient trimSps (#1530).  Replacing `trimLineBreaks`.  This-      does the work of `normalizeSpaces` as well, so we avoid the need for-      that function here.-    + Avoid 0-level headers (Jesse Rosenthal, #3830).  We used to parse-      paragraphs styled with "HeadingN" as "nth-level header." But if a-      document has a custom style named "Heading0", this will produce a-      0-level header, which shouldn't exist. We only parse this style-      if N>0. Otherwise we treat it as a normal style name, and-      follow its dependencies, if any.-    + Add tests for avoiding zero-level header (Jesse Rosenthal).--  * ODT reader:--    + Replaced `collectRights` with Rights from `Data.Either`.-    + Remove dead code (Albert Krewinkel).--  * Org reader (Albert Krewinkel, unless noted).--    + Don't allow tables inside list items (John MacFarlane, #3499).-    + Disallow tables on list marker lines (#3499).-    + Convert markup at beginning of footnotes (John MacFarlane, #3576).-    + Allow emphasized text to be followed by `[` (#3577).-    + Handle line numbering switch for src blocks.-      The line-numbering switch that can be given to source blocks (`-n` with-      an start number as an optional parameter) is parsed and translated to a-      class/key-value combination used by highlighting and other readers and-      writers.-    + Stop adding rundoc prefix to src params.  Source block parameter names-      are no longer prefixed with `rundoc`. This was intended to simplify-      working with the rundoc project, a babel runner. However, the rundoc-      project is unmaintained, and adding those markers is not the reader's-      job anyway.  The original language that is specified for a source-      element is now retained as the `data-org-language` attribute and only-      added if it differs from the translated language.-    + Allow multi-word arguments to src block params (#3477).  The reader now-      correctly parses src block parameter list even if parameter arguments-      contain multiple words.-    + Avoid creating `nullMeta` by applying `setMeta` directly-      (Alexander Krotov).-    + Replace `sequence . map` with `mapM`.-    + Fix smart parsing behavior.  Parsing of smart quotes and special-      characters can either be enabled via the `smart` language extension or-      the `'` and `-` export options. Smart parsing is active if either the-      extension or export option is enabled.  Only smart parsing of special-      characters (like ellipses and en and em dashes) is enabled by default,-      while smart quotes are disabled.  Previously, all smart parsing was-      disabled unless the language extension was enabled.-    + Subject full doc tree to headline transformations (Albert Krewinkel,-      #3695).  Emacs parses org documents into a tree structure, which is-      then post-processed during exporting. The reader is changed to do the-      same, turning the document into a single tree of headlines starting-      at level 0.-    + Fix cite parsing behaviour (Herwig Stuetz).  Until now, `org-ref`-      cite keys included special characters also at the end. This caused-      problems when citations occur right before colons or at the end of-      a sentence.  With this change, all non alphanumeric characters at-      the end of a cite key are ignored.  This also adds `,` to the list-      of special characters that are legal in cite keys to better mirror-      the behaviour of org-export.-    + Fix module names in haddock comments.  Copy-pasting had lead to-      haddock module descriptions containing the wrong module names.-    + Recognize babel result blocks with attributes (#3706).  Babel-      result blocks can have block attributes like captions and names.-      Result blocks with attributes were not recognized and were parsed-      as normal blocks without attributes.-    + Include tags in headlines.  The Emacs default is to include tags in the-      headline when exporting.  Instead of just empty spans, which contain the-      tag name as attribute, tags are rendered as small caps and wrapped in-      those spans.  Non-breaking spaces serve as separators for multiple tags.-    + Respect export option for tags (#3713).  Tags are appended to-      headlines by default, but will be omitted when the `tags` export option-      is set to nil.-    + Use `tag-name` attribute instead of `data-tag-name`.-    + Use `org-language` attribute rather than `data-org-language`.-    + Modified state type to be an instance of `HasLogMessages`, so-      `registerHeader` can issue warnings.-    + End footnotes after two blank lines.  Footnotes can not only be-      terminated by the start of a new footnote or a header, but also by two-      consecutive blank lines.-    + Update emphasis border chars (#3933).  The org reader was updated to-      match current org-mode behavior: the set of characters which are-      acceptable to occur as the first or last character in an org emphasis-      have been changed and now allows all non-whitespace chars at the-      inner border of emphasized text (see `org-emphasis-regexp-components`).--  * RST reader:--    + Fixed small bug in list parsing (#3432).  Previously the parser didn't-      handle properly this case:--          * - a-            - b-          * - c-            - d-    + Handle multiline cells in simple tables (#1166).-    + Parse list table directive (Keiichiro Shikano, #3432).-    + Make use of `anyLineNewline` (Alexander Krotov, #3686).-    + Use `anyLineNewline` in `rawListItem` (Alexander Krotov, #3702).-    + Reorganize block parsers for ~20% faster parsing.-    + Fixed `..include::` directive (#3880).-    + Handle blank lines correctly in line blocks (Alexander Krotov, #3881).-      Previously pandoc would sometimes combine two line blocks separated-      by blanks, and ignore trailing blank lines within the line block.-    + Fix indirect hyperlink targets (#512).--  * Markdown reader:--    + Allow attributes in reference links to start on next line (#3674).-    + Parse YAML metadata in a context that sees footnotes defined in-      the body of the document (#1279).-    + When splitting pipe table cells, skip tex math (#3481).-      You might have a `|` character inside math.  (Or for that matter-      something that the parser might mistake for raw HTML.)-    + Treat span with class `smallcaps` as SmallCaps.-      This allows users to specify small caps in Markdown this way:-      `[my text]{.smallcaps}` (#1592).-    + Fixed internal header links (#2397).-      This patch also adds `shortcut_reference_links` to the list-      of mmd extensions.-    + Treat certain environments as inline-      when they occur without space surrounding them (#3309, #2171).-      E.g. equation, math.  This avoids incorrect vertical space-      around equations.-    + Optimized `nonindentSpaces`.  Makes the benchmark go from 40 to 36 ms.-    + Allow latex macro definitions indented 1-3 spaces.-      Previously they only worked if nonindented.-    + Improved parsing of indented raw HTML blocks (#1841).-      Previously we inadvertently interpreted indented HTML as-      code blocks.  This was a regression.  We now seek to determine the-      indentation level of the contents of an HTML block, and (optionally)-      skip that much indentation.  As a side effect, indentation may be-      stripped off of raw HTML blocks, if `markdown_in_html_blocks` is-      used. This is better than having things interpreted as indented-      code blocks.-    + Fixed smart quotes after emphasis (#2228).  E.g. in `*foo*'s 'foo'`.-    + Warn for notes defined but not used (#1718).-    + Use `anyLineNewline` (Alexander Krotov).-    + Interpret YAML metadata as Inlines when possible (#3755).  If-      the metadata field is all on one line, we try to interpret it as-      Inlines, and only try parsing as Blocks if that fails.  If it-      extends over one line (including possibly the `|` or `>` character-      signaling an indented block), then we parse as Blocks.  This was-      motivated by some German users finding that `date: '22. Juin 2017'`-      got parsed as an ordered list.-    + Fixed spurious parsing as citation as reference def (#3840).-      We now disallow reference keys starting with `@` if the-      `citations` extension is enabled.-    + Parse `-@roe` as suppress-author citation (pandoc-citeproc#237).-      Previously only `[-@roe]` (with brackets) was recognized as-      suppress-author, and `-@roe` was treated the same as `@roe`.-    + Fixed parsing of fenced code after list when there is no intervening-      blank line (#3733).-    + Allow raw latex commands starting with `\start` (#3558).  Previously-      these weren't allowed because they were interpreted as starting-      ConTeXt environments, even without a corresponding `\stop`...-    + Added `inlines`, `inlines1`.-    + Require nonempty alt text for `implicit_figures` (#2844).-      A figure with an empty caption doesn't make sense.-    + Removed texmath macro material; now all this is handled-      in the LaTeX reader functions.-    + Fixed bug with indented code following raw LaTeX (#3947).--  * LaTeX reader:--    + Rewrote LaTeX reader with proper tokenization (#1390,-      #2118, #3236, #3779, #934, #982).  This rewrite is primarily-      motivated by the need to get macros working properly.  A side benefit-      is that the reader is significantly faster.  We now tokenize the-      input text, then parse the token stream.  Macros modify the token-      stream, so they should now be effective in any context, including-      math. Thus, we no longer need the clunky macro processing-      capacities of texmath.-    + Parse `\,` to `\8198` (six-per-em space) (Henri Werth).-    + Allow `\newcommand\foo{blah}` without braces.-    + Support `\lstinputlisting` (#2116).-    + Issue warnings when skipping unknown latex commands (#3392).-    + Include contents of `\parbox`.-    + Allow `\hspace` and `\vspace` to count as raw block or inline.-      Previously we would refuse to parse anything as raw inline if-      it was in the `blockCommands` list.  Now we allow exceptions-      if they're listed under ignoreInlines in inlineCommands.-      This should make it easier e.g. to include an `\hspace`-      between two side-by-side raw LaTeX tables.-    + Don't drop contents of `\hypertarget`.-    + Handle spaces before `\cite` arguments.-    + Allow newpage, clearpage, pagebreak in inline contexts as well as-      block contexts (#3494).-    + Treat `{{xxx}}` the same as `{xxx}` (#2115).-    + Use `pMacroDefinition` in macro (for more direct parsing).-      Note that this means that `macro` will now parse one-      macro at a time, rather than parsing a whole group together.-    + Fixed failures on \ref{}, \label{} with `+raw_tex`.  Now these-      commands are parsed as raw if `+raw_tex`; otherwise, their argument-      is parsed as a bracketed string.-    + Don't crash on empty `enumerate` environment (#3707).-    + Handle escaped `&` inside table cell (#3708).-    + Handle block structure inside table cells (#3709).  `minipage` is no-      longer required.-    + Handle some width specifiers on table columns (#3709).  Currently-      we only handle the form `0.9\linewidth`.  Anything else would have-      to be converted to a percentage, using some kind arbitrary assumptions-      about line widths.-    + Make sure `\write18` is parsed as raw LaTeX.  The change is in the-      LaTeX reader's treatment of raw commands, but it also affects the-      Markdown reader.-    + Fixed regression with starred environment names (#3803).-    + Handle optional args in raw `\titleformat` (#3804).-    + Improved heuristic for raw block/inline.  An unknown command at the-      beginning of the line that could be either block or inline is-      treated as block if we have a sequence of block commands followed by-      a newline or a `\startXXX` command (which might start a raw ConTeXt-      environment).-    + Don't remove macro definitions from the output, even if-      `Ext_latex_macros` is set, so that macros will be applied.-      Since they're only applied to math in Markdown, removing the macros-      can have bad effects.  Even for math macros, keeping them should be-      harmless.-    + Removed `macro`.  It is no longer necessary, since the-      `rawLaTeXBlock` parser will parse macro definitions.  This also avoids-      the need for a separate `latexMacro` parser in the Markdown reader.-    + Use `label` instead of `data-label` for label in caption (#3639).-    + Fixed space after \figurename etc.-    + Resolve references to section numbers.-    + Fix `\let\a=0` case, with single character token.-    + Allow `@` as a letter in control sequences.  `@` is commonly used-      in macros using `\makeatletter`.  Ideally we'd make the tokenizer-      sensitive to `\makeatletter` and `\makeatother`, but until then this-      seems a good change.-    + Track header numbers and correlate with labels.-    + Allow `]` inside group in option brackets (#3857).-    + lstinline with braces can be used (verb cannot be used with braces)-      (Marc Schreiber, #3535).-    + Fix keyval function: pandoc did not parse options in braces correctly-      (Marc Schreiber, #3642).-    + When parsing raw LaTeX commands, include trailing space (#1773).-      Otherwise things like `\noindent foo` break and turn into-      `\noindentfoo`.  Affects `-f latex+raw_tex` and `-f markdown` (and other-      formats that allow `raw_tex`).-    + Don't treat "..." as Quoted (#3958).  This caused quotes to be omitted in-      `\texttt` contexts.-    + Add tests for existing `\includegraphics` behaviour (Ben Firshman).-    + Allow space before `=` in bracketd options (Ben Firshman).-    + Be more forgiving in parsing command options.  This was needed, for-      example, to make some minted options work.-    + Strip off quotes in `\include` filenames.--  * Added `Text.Pandoc.CSV`, simple (unexported) CSV parser.--  * `Text.Pandoc.PDF`:--    + Got `--resource-path` working with PDF output (#852).-    + Fetch images when generating PDF via context (#3380).-      To do this, we create the temp directory as a subdirectory-      of the working directory. Since context mk IV by default looks-      for images in the parent directory, this works.-    + Use `report` instead of `warn`, make it sensitive to verbosity settings.-    + Use `fillMediaBag` and `extractMedia` to extract media to temp dir.-      This reduces code duplication.-    + `html2pdf`: use stdin instead of intermediate HTML file-    + Removed useless `TEXINPUTS` stuff for `context2pdf`.  mkiv context-      doesn't use `TEXINPUTS`.--  * `Text.Pandoc.Pretty`:--    + Simplified definition of `realLength`.-    + Don't error for blocks of size < 1.  Instead, resize to 1 (see #1785).--  * `Text.Pandoc.MIME`:--    + Use `application/javascript` (not `application/x-javascript`).-    + Added `emf` to mimeTypes with type `application/x-msmetafile` (#1713).--  * `Text.Pandoc.ImageSize`:--    + Improve SVG image size code (Marc Schreiber, #3580).-    + Make `imageSize` recognize basic SVG dimensions (Mauro Bieg, #3462).--  * Use `Control.Monad.State.Strict` throughout.  This gives 20-30% speedup-    and reduction of memory usage in most of the writers.--  * Use `foldrWithKey` instead of deprecated `foldWithKey`.--  * `Text.Pandoc.SelfContained`:--    + Fixed problem with embedded fonts (#3629).-    + Refactored getData from `getDataURI` in `SelfContained`.-    + Don't use data URIs for script or style (#3423).  Instead, just use-      script or style tags with the content inside.  The old method with-      data URIs prevents certain optimizations outside pandoc.  Exception:-      data URIs are still used when a script contains `</script>` or a-      style contains `</`.-    + SelfContained: Handle URL inside material retrieved from a URL-      (#3629).  This can happen e.g. with an @import of a google web font.-      (What is imported is some CSS which contains an url reference-      to the font itself.) Also, allow unescaped pipe (|) in URL.-    + Load resources from `data-src` (needed for lazy loading in-      reveal.js slide shows).-    + Handle `data-background-image` attribute on section (#3979).--  * `Text.Pandoc.Parsing`:--    + Added `indentWith` (Alexander Krotov, #3687).-    + Added `stateCitations` to `ParserState`.-    + Removed `stateChapters` from `ParserState`.-    + In `ParserState`, make `stateNotes'` a Map, add `stateNoteRefs`.-    + Added `gobbleSpaces` and `gobbleAtMostSpaces`.-    + Adjusted type of `insertIncludedFile` so it can be used with token-      parser.-    + Replace old texmath macro stuff from Parsing.  Use Macro from-      Text.Pandoc.Readers.LaTeX.Types instead.-    + Export `insertIncludedFile`.-    + Added `HasLogMessages`, `logMessage`, `reportLogMessages` (#3447).-    + Replace partial with total function (Albert Krewinkel).-    + Introduce `HasIncludeFiles` type class (Albert Krewinkel).  The-      `insertIncludeFile` function is generalized to work with all parser-      states which are instances of that class.-    + Add `insertIncludedFilesF` which returns F blocks (Albert Krewinkel).-      The `insertIncludeFiles` function was generalized and renamed-      to `insertIncludedFiles'`; the specialized versions are based on that.-    + `many1Till`: Check for the end condition before parsing (Herwig-      Stuetz).  By not checking for the end condition before the first-      parse, the parser was applied too often, consuming too much of the-      input. This only affects `many1Till p end` where `p` matches on a-      prefix of `end`.-    + Provide `parseFromString` (#3690).  This is a version of-      `parseFromString` specialied to ParserState, which resets-      `stateLastStrPos` at the end.  This is almost always what we want.-      This fixes a bug where `_hi_` wasn't treated as emphasis in the-      following, because pandoc got confused about the position of the-      last word: `- [o] _hi_`.-    + Added `takeP`, `takeWhileP` for efficient parsing of `[Char]`.-    + Fix `blanklines` documentation (Alexander Krotov, #3843).-    + Give less misleading line information with `parseWithString`.-      Previously positions would be reported past the end of the chunk.-      We now reset the source position within the chunk and report-      positions "in chunk."-    + Add `anyLineNewline` (Alexander Krotov).-    + Provide shared F monad functions for Markdown and Org readers-      (Albert Krewinkel).  The `F` monads used for delayed evaluation-      of certain values in the Markdown and Org readers are based on a-      shared data type capturing the common pattern of both `F` types.-    + Add `returnF` (Alexander Krotov).-    + Avoid parsing `Notes:**` as a bare URI (#3570).  This avoids parsing-      bare URIs that start with a scheme + colon + `*`, `_`, or `]`.-    + Added `readerAbbreviations` to `ParserState`.  Markdown reader-      now consults this to determine what is an abbreviation.-    + Combine grid table parsers (Albert Krewinkel, #3638).  The grid table-      parsers for markdown and rst was combined into one single-      parser `gridTable`, slightly changing parsing behavior of both-      parsers: (1) The markdown parser now compactifies block content-      cell-wise: pure text blocks in cells are now treated as paragraphs-      only if the cell contains multiple paragraphs, and as plain blocks-      otherwise. Before, this was true only for single-column tables. (2)-      The rst parser now accepts newlines and multiple blocks in header-      cells.-    + Generalize tableWith, gridTableWith (Albert Krewinkel).-      The parsing functions `tableWith` and `gridTableWith` are generalized-      to work with more parsers. The parser state only has to be an-      instance of the `HasOptions` class instead of requiring a concrete-      type. Block parsers are required to return blocks wrapped into a-      monad, as this makes it possible to use parsers returning results-      wrapped in `Future`s.--  * `Text.Pandoc.Shared`:--    + Simplify `toRomanNumeral` using guards (Alexander Krotov, #3445)-    + `stringify`: handle Quoted better (#3958).  Previously we were losing-      the quotation marks in Quoted elements.--  * `Text.Pandoc.Writers.Shared`:--    + Export `metaToJSON'`, `addVariablesToJSON` (#3439).-      This allows us to add the variables AFTER using the metadata-      to generate a YAML header (in the Markdown writer).-    + Added `unsmartify` (previously in RST writer).-      Undo literal double curly quotes.  Previously we left these.-    + Generalize type of `metaToJSON` so it can take a Text.  Previously a-      String was needed as argument; now any ToJSON instance will do.-    + Added `gridTable` (previously in Markdown writer).-    + `gridTable`: Refactored to use widths in chars.-    + `gridTable`:  remove unnecessary extra space in cells.-    + Fixed `addVariablesToJSON`.  It was previously not allowing multiple-      values to become lists.-    + Pipe tables: impose minimum cell size (see #3526).---  [default template changes]--  * HTML templates (including EPUB and HTML slide show templates):--    + Make default.html5 polyglot markup conformant (John Luke Bentley,-      #3473).  Polyglot markup is HTML5 that is also valid XHTML. See-      <https://www.w3.org/TR/html-polyglot>.  With this change, pandoc's-      html5 writer creates HTML that is both valid HTML5 and valid XHTML.-    + Regularized CSS in html/epub/html slide templates (#3485).-      All templates now include `code{white-space: pre-wrap}`-      and CSS for `q` if `--html-q-tags` is used.  Previously some templates-      had `pre` and others `pre-wrap`; the `q` styles were only sometimes-      included.-    + CSS for `.smallcaps`, (Mauro Bieg, #1592)-    + `default.revealjs`: make `history` default to true.-    + `default.revealjs`: use lazy loading (#2283).-    + `default.revealjs`: add `mathjax` variable and some conditional code-      to use the MathJaX plugin.-    + `default.slidy` uses `https` instead of `http` (ickc, #3848).-    + `default.dzslides`: Load Google Font using HTTPS by default-      (Yoan Blanc).--  * DocBook5 template: Use `lang` and `subtitle` variables (Jens Getreu,-    #3855).--  * LaTeX/Beamer template:--    + Combine LaTeX/Beamer templates (Andrew Dunning, #3878).-      `default.beamer` has been removed; beamer now uses the-      `default.latex` template.  Beamer-specific parts are conditional-      on the `beamer` variable set by the writer. Note that-      `pandoc -D beamer` will return this (combined) template.-    + Use `xcolor` for `colorlinks` option (Andrew Dunning, #3877).-      Beamer loads `xcolor` rather than `color`, and thus the-      `dvipsnames` option doesn't take effect. This also provides a wider-      range of colour selections with the `svgnames` option.-    + Use starred versions of `xcolor` names (Andrew Dunning).-      Prevents changes to documents defined using the `dvipsnames` list (e.g.-      `Blue` gives a different result with svgnames enabled).-    + Load `polyglossia` after header-includes (#3898).  It needs to be-      loaded as late as possible.-    + Use `unicode-math` (Vaclav Haisman).  Use `mathspec` with only-      XeLaTeX on request.-    + Don't load `fontspec` before `unicode-math` (over there).-      The `unicode-math` package loads `fontspec` so explicit loading of-      `fontspec` before `unicode-math` is not necessary.-    + Use `unicode-math` by default in default.latex template.  mathspec will-      be used in xelatex if the `mathspec` variable is set; otherwise-      unicode-math will be used (Václav Haisman).-    + Use `dvipsnames` options when `colorlinks` specified (otherwise-      we get an error for `maroon`) (Thomas Hodgson).-    + Added beamer `titlegraphic` and `logo` variables (Thomas Hodgson).-    + Fix typo in fix for notes in tables (#2378, zeeMonkeez).-    + Fix `hyperref` options clash (Andrew Dunning, #3847) Avoids an options-      clash when loading a package (e.g. `tufte-latex`) that uses-      `hyperref` settings different from those in the template.-    + Add `natbiboptions` variable (#3768).-    + Fix links inside captions in LaTeX output with links-as-notes-      (Václav Haisman, #3651).  Declare our redefined `\href` robust.-    + Load `parskip` before `hyperref` (Václav Haisman, #3654).-    + Allow setting Japanese fonts when using LuaLaTeX (Václav Haisman,-      #3873).  by using the `luatexja-fontspec` and `luatexja-preset`-      packages. Use existing `CJKmainfont` and `CJKoptions` template-      variables. Add `luatexjafontspecoptions` for `luatexja-fontspec`-      and `luatexjapresetoptions` for `luatexja-preset`.-    + Added `aspectratio` variable to beamer template (Václav Haisman,-      #3723).-    + Modified template.latex to fix XeLaTex being used with tables-      (lwolfsonkin, #3661).  Reordered `lang` variable handling to-      immediately before `bidi`.--  * ConTeXt template: Improved font handling: `simplefonts` is now-    obsolete in ConTeXt (Pablo Rodríguez).---  [documentation improvements]--  * MANUAL.txt:--    + Add URL for Prince HTML > PDF engine (Ian, #3919).-    + Document that content above slide-level will be omitted in-      slide shows.  See #3460, #2265.-    + Explain `--webtex` SVG url (Mauro Bieg, #3471)-    + Small clarification in YAML metadata section.-    + Document that html4 is technically XHTML 1.0 transitional.-    + Remove refs to highlighting-kate (#3672).-    + Document ibooks specific epub metadata.-    + Clarify that mathml is used for ODT math.-    + Mention limitations of Literate Haskell Support (#3410,-      Joachim Breitner).-    + Add documentation of limitations of grid tables (Stephen-      McDowell, #3864).-    + Clarify that meta-json contains transformed values (Jakob Voß,-      #3491) Make clear that template variable `meta-json` does not-      contain plain text values or JSON output format but field values-      transformed to the selected output format.--  * COPYRIGHT:--    + Clarify that templates are dual-licensed.-    + Clarify that pandoc-types is BSD3 licensed.-    + List new files not written by jgm (Albert Krewinkel).-    + Update dates in copyright notices (Albert Krewinkel).  This follows-      the suggestions given by the FSF for GPL licensed software.-      <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>--  * INSTALL.md:--    + Improved instructions for tests with patterns.-    + Put RPM-based distros on separate point (Mauro Bieg, #3449)--  * CONTRIBUTING.md:--    + Fixed typos (Wandmalfarbe, #3479).-    + Add "ask on pandoc-discuss" (Mauro Bieg).--  * Add lua filter documentation in `doc/lua-filters.md`.  Note that the-    end of this document is autogenerated from `data/pandoc.lua`-    using `make doc/lua-filters.md`, which uses `tools/ldoc.ltp`-    (Albert Krewinkel).--  * Add `doc/filters.md`. This is the old scripting tutorial from-    the website.--  * Add `doc/using-the-pandoc-api.md` (#3289).  This gives an introduction-    to using pandoc as a Haskell library.---  [build infrastructure improvements]--  * Removed `data/templates` submodule.  Templates are now a subtree-    in `data/templates`.  This removes the need to do `git submodule-    update`.--  * Renamed `tests` -> `test`.--  * Remove `https` flag.  Always build with HTTPS support.--  * Use `file-embed` instead of `hsb2hs` to embed data files when-    `embed_data_files` flag is set.  `file-embed` gives us better dependency-    tracking:  if a data file changes, ghc/stack/cabal know to recompile-    the Data module.  This also removes `hsb2hs` as a build dependency.--  * Add `custom-setup` stanza to pandoc, lowercase field names.--  * Add `static` Cabal flag.--  * Name change OSX -> MacOS.  Add a -MacOS suffix to mac package rather-    than -OSX.  Changed local names from osx to macos.--  * make_macos_package.sh - Use strip to reduce executable size.--  * Revised binary linux package.  Now a completely static executable-    is created, using Docker and alpine.  We create both a deb and a-    tarball.  The old `deb` directory has been replaced with a `linux`-    directory.  Running `make` in the `linux` directory should-    perform the build, putting the binary packages in `artifacts/`.--  * `linux/control.in`: add `Replaces:`, so existing pandoc-citeproc and-    pandoc-data packages will be uninstalled; this package provides-    both (#3822).  Add latex packages as 'suggested', update-    description.--  * Remove cpphs build requirement -- it is no longer needed.--  * Replaced `{deb,macos,windows}/stack.yaml` with `stack.pkg.yaml`.--  * Name change OSX -> macOS (ickc, #3869).--  * Fix casing of Linux, UNIX, and Windows (ickc).--  * `.travis.yml`:  create a source dist and do cabal build and test there.-    That way we catch errors due to files missing from the data-    section of pandoc.cabal.--  * Makefile:--    + Split `make haddock` from `make full`.-    + Add BRANCH variable for winpkg.-    + Add `lint` target.-    + Improve `make full`. Disable optimizations.-      Build everything, inc. trypandoc and benchmarks.  Use parallel build.-    + Allow `make test` to take `TESTARGS`.--  * Added new command tests (`Tests.Command`), using small text files-    in `test/command/`.  Any files added in this directory will be treated-    as shell tests (see smart.md for an example).  This makes it very easy-    to add regression tests etc.--  * Test fixes so we can find data files.  In old tests & command tests,-    we now set the environment variable `pandoc_datadir`.  In lua tests,-    we set the datadir explicitly.--  * Refactored `compareOutput` in docx writer test.--  * Consolidated some common functions in `Tests.Helper`.--  * Small change to unbalanced bracket test to speed up test suite.--  * Speed up Native writer quickcheck tests.--  * Use tasty for tests rather than test-framework.--  * Add simple Emacs mode to help with Pandoc templates editing.-    (Václav Haisman, #3889). `tools/pandoc-template-mode.el`---pandoc (1.19.2)--  * Use skylighting library instead of highlighting-kate for syntax-    highlighting. Skylighting is faster and more accurate (#3363).-    Later we'll be able to add features like warning messages, dynamic-    loading of xml syntax definitions, and dynamic loading of themes.--  * Added a new highlight style, `breezeDark`.--  * Text.Pandoc.Highlighting: Update list of `listings` languages (#3374).-    This allows more languages to be used when using the `--listings`-    option.--  * OpenDocument writer:--    + Small refactoring.  Removed separate 'parent' parameter in paraStyle.-    + Don't profilerate text styles unnecessarily (#3371).-      This change makes the writer create only as many temporary-      text styles as are absolutely necessary. It also consolidates-      adjacent nodes with the same style.--  * Org reader (Albert Krewinkel):--    + Allow short hand for single-line raw blocks (Albert Krewinkel,-      #3366).  Single-line raw blocks can be given via `#+FORMAT: raw line`,-      where `FORMAT` must be one of `latex`, `beamer`, `html`, or `texinfo`.-    + Accept org-ref citations followed by commas (Albert Krewinkel).-      Bugfix for an issue which, whenever the citation was immediately-      followed by a comma, prevented correct parsing of org-ref citations.-    + Ensure emphasis markup can be nested.  Nested emphasis markup (e.g.-      `/*strong and emphasized*/`) was interpreted incorrectly in that the-      inner markup was not recognized.-    + Remove pipe char irking the haddock coverage tool (Albert Krewinkel).--  * Docx reader: Empty header should be list of lists (Jesse Rosenthal).-    In the past, the docx reader wrote an empty header as an empty list. It-    should have the same width as a row (and be filled with empty cells).--  * MediaWiki reader:--    + Improved handling of display math (#3362).  Sometimes display math is-      indented with more than one colon.  Previously we handled these cases-      badly, generating definition lists and missing the math.-    + Fix quotation mark parsing (#3336, tgkokk).  Change MediaWiki reader's-      behavior when the smart option is parsed to match other readers'-      behavior.--  * Markdown reader:--    + Fixed `-f markdown_github-hard_line_breaks+escaped_line_breaks`-      (#3341).  Previously this did not properly enable escaped line breaks.-    + Disallow space between inline code and attributes (#3326, #3323,-      Mauro Bieg).--  * DocBook5 writer: make id attribute xml:id, fixes #3329 (#3330, Mauro Bieg).--  * Added some test cases for ODT reader (#3306, #3308, Hubert Plociniczak).--  * LaTeX writer: allow tables with empty cells to count as "plain."-    This addresses a problem of too-wide tables when empty cells-    are used.  Thanks to Joost Kremers for reporting the issue.--  * Org writer: prefix footnote numbers with `fn:` (Albert Krewinkel).-    Unprefixed numbers where used by older org-mode versions, but are no-    longer supported.--  * HTML writer: don't process pars with empty RawInline, (#1040, #3327,-    Mauro Bieg).--  * Markdown writer: Fix display math with `--webtex` (#3298).--  * Fix sample.lua so it properly handles raw blocks/inlines (#3358,-    bumper314).--  * Templates:--    + default.latex: Moved geometry after hyperref (Václav Haisman).-      Otherwise PDF sizes can be wrong in some circumstances.-    + Copied a few changes from default.latex to default.beamer-      (Wandmalfarbe).-    + default.latex, default.beamer: Changed position of `\VerbatimNotes`-      and `fancyvrb`.  This fixes hyperlinks on footnotes in documents-      that contain verbatim in notes (#3361).  (Note: the beamer template-      was updated to match the LaTeX template, but at this point verbatim-      in notes seems not to work in beamer.)-    + default.latex: Allow passing `microtypeoptions` to microtype-      (Václav Haisman).-    + default.latex: Add hyphen option to url package.-    + default.docbook5: Fix namespace declarations (Mauro Bieg).--  * Moved `make_osx_package.sh` to `osx/` directory.--  * Travis continuous integration:--    + Fix false positives with dist build.-    + Speed improvements (Kolen Cheung, #3304, #3357).--  * MANUAL.txt:--    + Clarify that blank space is needed around footnotes (#3352).-    + Fixed typo (#3351, Alexey Rogechev).-    + Note that `--wrap=auto` does not work in HTML output.-    + Default `--columns` width is 72, not 80.-    + Fixed broken links (#3316, Kolen Cheung).-    + Document usage of `@*` in nocite section (#3333, John Muccigrosso).--  * INSTALL.md:--    + Indent code so it's properly formatted (#3335, Bheesham Persaud).-    + Added instructions for extracting binary from OSX, Windows packages.--  * CONTRIBUTING.md: Describe labels currently used in issue tracker-    (Albert Krewinkel).  The labels have changed over time, the list of-    labels is updated to reflect the current set of labels used in the-    issue tracker.--  * Rearrange and extend badges in README (Albert Krewinkel, #3354)--  * Bumped version bounds for dependencies.---pandoc (1.19.1)--  * Set `PANDOC_VERSION` environment variable for filters (#2640).-    This allows filters to check the pandoc version that produced-    the JSON they are receiving.--  * Docx reader: Ensure one-row tables don't have header (#3285,-    Jesse Rosenthal).  Tables in MS Word are set by default to have-    special first-row formatting, which pandoc uses to determine whether-    or not they have a header. This means that one-row tables will, by-    default, have only a header -- which we imagine is not what people-    want. This change ensures that a one-row table is not understood to-    be a header only.  Note that this means that it is impossible to-    produce a header-only table from docx, even though it is legal-    pandoc. But we believe that in nearly all cases, it will be an-    accidental (and unwelcome) result--  * HTML reader:--    + Fixed some bad regressions in HTML table parser (#3280).-      This regression leads to the introduction of empty rows-      in some circumstances.-    + Understand `style=width:` as well as `width` in `col` (#3286).--  * RST reader:--    + Print warnings when keys, substitition, notes not found.-      Previously the parsers failed and we got raw text.  Now we get a-      link with an empty URL, or empty inlines in the case of a note or-      substitution.--    + Fix hyperlink aliases (#3283).--  * Man writer: Ensure that periods are escaped at beginning of line-    (#3270).--  * LaTeX writer: Fix unnumbered headers when used with `--top-level`-    (#3272, Albert Krewinkel).  Fix interaction of top-level divisions-    `part` or `chapter` with unnumbered headers when emitting LaTeX.  Headers-    are ensured to be written using stared commands (like `\subsection*{}`).--  * LaTeX template: use comma not semicolon to separate keywords for-    `pdfkeywords`.  Thanks to Wandmalfarbe.--  * Markdown writer: Fixed incorrect word wrapping (#3277).  Previously pandoc-    would sometimes wrap lines too early due to this bug.--  * Text.Pandoc.Pretty:  Added `afterBreak` [API change].  This makes it-    possible to insert escape codes for content that needs escaping at the-    beginning of a line.--  * Removed old MathMLInHTML.js from 2004, which should no longer-    be needed for MathML with modern browsers.--  * Fixed tests with dynamic linking (#2709).--  * Makefile: Use stack instead of cabal for targets.  This is just-    a convenience for developers.--  * Fixed bash completion of filenames with space (#2749).--  * MANUAL: improved documentation on how to create a custom `reference.docx`.--  * Fix minor spelling typos in the manual (#3273, Anthony Geoghegan)--pandoc (1.19)--  * Changed resolution of filter paths.--    + We now first treat the argument of `--filter` as a full (absolute-      or relative) path, looking for a program there. If it's found, we-      run it.-    + If not, and if it is a simple program name or a relative path, we-      try resolving it relative to `$DATADIR/filters`.-    + If this fails, then we treat it as a program name and look in the-      user's PATH.-    + Removed a hardcoded '/' that may have caused problems with-      Windows paths.--    Previously if you did `--filter foo` and you had `foo` in your path and-    also an executable `foo` in your working directory, the one in the path-    would be used. Now the one in the working directory is used.--    In addition, when you do `--filter foo/bar.hs`, pandoc will now find a-    filter `$DATADIR/filters/foo/bar.hs` -- assuming there isn't a-    `foo/bar.hs` relative to the working directory.--  * Allow `file://` URIs as arguments (#3196). Also improved default reader-    format detection. Previously with a URI ending in .md or .markdown,-    pandoc would assume HTML input. Now it treats these as markdown.--  * Allow to overwrite top-level division type heuristics (#3258,-    Albert Krewinkel). Pandoc uses heuristics to determine the most-    reasonable top-level division type when emitting LaTeX or-    Docbook markup. It is now possible to overwrite this implicitly set-    top-level division via the `top-level-division` command line parameter.--  * Text.Pandoc.Options \[API changes\]:--    + Removed `writerStandalone` field in `WriterOptions`, made-      `writerTemplate` a `Maybe` value. Previously setting-      `writerStandalone = True` did nothing unless a template was provided-      in writerTemplate. Now a fragment will be generated if-      `writerTemplate` is `Nothing`; otherwise, the specified template-      will be used and standalone output generated.-    + `Division` has been renamed `TopLevelDivision` (#3197). The-      `Section`, `Chapter`, and `Part` constructors were renamed to-      `TopLevelSection`, `TopLevelChapter`, and-      `TopLevelPart`, respectively. An additional `TopLevelDefault`-      constructor was added, which is now also the new default value of-      the `writerTopLevelDivision` field in `WriterOptions`.--  * Improved error if they give wrong arg to `--top-level-division`.--  * Use new module from texmath to lookup MS font codepoints in Docx reader.-    Removed unexported module Text.Pandoc.Readers.Docx.Fonts. Its code now-    lives in texmath (0.9).--  * DocBook reader: Fixed xref lookup (#3243). It previously only worked-    when the qnames lacked the docbook namespace URI.--  * HTML reader:--    + Improved table parsing (#3027). We now check explicitly for non-1-      rowspan or colspan attributes, and fail when we encounter them.-      Previously we checked that each row had the same number of cells,-      but that could be true even with rowspans/colspans. And there are-      cases where it isn't true in tables that we can handle fine -- e.g.-      when a tr element is empty. So now we just pad rows with empty cells-      when needed.-    + Treat `<math>` as MathML by default unless something else is-      explicitly specified in xmlns. Provided it parses as MathML,-      of course. Also fixed default which should be to inline math if no-      display attribute is used.-    + Only treat "a" element as link if it has href (#3226). Otherwise-      treat as span.--  * Docx reader (Jesse Rosenthal):--    + Add a placeholder value for CHART. We wrap `[CHART]` in a-      `<span class="chart">`. Note that it maps to inlines because, in-      docx, anything in a drawing tag can be part of a larger paragraph.-    + Be more specific in parsing images We not only want `w:drawing`,-      because that could also include charts. Now we specify-      `w:drawing/pic:pic`. This shouldn't change behavior at all, but it's-      a first step toward allowing other sorts of drawing data as well.-    + Abstract out function to avoid code repetition.-    + Update tests for img title and alt (#3204).-    + Handle Alt text and titles in images. We use the "description" field-      as alt text and the "title" field as title. These can be accessed-      through the "Format Picture" dialog in Word.-    + Docx reader utils: handle empty namespace in `elemName`. Previously,-      if given an empty namespace `(elemName ns "" "foo")` `elemName`-      would output a QName with a `Just ""` namespace. This is never what-      we want. Now we output a `Nothing`. If someone *does* want a-      `Just ""` in the namespace, they can enter the QName-      value explicitly.--  * ODT reader/writer:--    + Inline code when text has a special style (Hubert Plociniczak). When-      a piece of text has a text `Source_Text` then we assume that this is-      a piece of the document that represents a code that needs to-      be inlined. Adapted the writer to also reflect that change.-      Previously it was just writing a 'preformatted' text using a-      non-distinguishable font style. Code blocks are still not recognized-      by the ODT reader. That's a separate issue.-    + Infer table's caption from the paragraph (#3224,-      Hubert Plociniczak). ODT's reader always put empty captions for the-      parsed tables. This commit--        1.  checks paragraphs that follow the table definition-        2.  treats specially a paragraph with a style named 'Table'-        3.  does some postprocessing of the paragraphs that combines tables-            followed immediately by captions--      The ODT writer used the `TableCaption` style for the caption-      paragraph.  This commit follows the OpenOffice approach which allows-      for appending captions to table but uses a built-in style named-      `Table` instead of `TableCaption`. Users of a custom `reference.odt`-      should change the style's name from `TableCaption` to `Table`.--  * ODT reader: Infer tables' header props from rows (#3199,-    Hubert Plociniczak). ODT reader simply provided an empty header list-    which meant that the contents of the whole table, even if not empty, was-    simply ignored. While we still do not infer headers we at least have to-    provide default properties of columns.--  * Markdown reader:--    +   Allow reference link labels starting with `@...` if `citations`-        extension disabled (#3209). Example: in--            \[link text\]\[@a\]--        `link text` isn't hyperlinked because `[@a]` is parsed as-        a citation. Previously this happened whether or not the `citations`-        extension was enabled. Now it happens only if the `citations`-        extension is enabled.-    +   Allow alignments to be specified in Markdown grid tables. For-        example,--            +-------+---------------+--------------------+-            | Right    | Left                 | Centered |-            +=========:+:=================+:=============:+-            | Bananas | $1.34         | built-in wrapper |-            +-------+---------------+--------------------+--    +   Allow Small Caps elements to be created using bracketed spans (as-        they already can be using HTML-syntax spans) (#3191, Kolen Cheung).--  * LaTeX reader:--    + Don't treat `\vspace` and `\hspace` as block commands (#3256).-      Fixed an error which came up, for example, with `\vspace` inside-      a caption. (Captions expect inlines.)-    + Improved table handling. We can now parse all of the tables emitted-      by pandoc in our tests. The only thing we don't get yet are-      alignments and column widths in more complex tables. See #2669.-    + Limited support for minipage.-    + Allow for `[]`s inside LaTeX optional args. Fixes cases like:-    + Handle BVerbatim from fancyvrb (#3203).-    + Handle hungarumlaut (#3201).-    + Allow beamer-style `<...>` options in raw LaTeX (also in Markdown)-      (#3184). This allows use of things like `\only<2,3>{my content}` in-      Markdown that is going to be converted to beamer.--  * Use pre-wrap for code in dzslides template (Nicolas Porcel). Otherwise-    overly long code will appear on every slide.--  * Org reader (Albert Krewinkel):--    +   Respect column width settings (#3246). Table column properties can-        optionally specify a column's width with which it is displayed in-        the buffer. Some exporters, notably the ODT exporter in org-mode-        v9.0, use these values to calculate relative column widths. The org-        reader now implements the same behavior. Note that the org-mode-        LaTeX and HTML exporters in Emacs don't support this feature yet,-        which should be kept in mind by users who use the column-        widths parameters.-    +   Allow HTML attribs on non-figure images (#3222). Images which are-        the only element in a paragraph can still be given HTML attributes,-        even if the image does not have a caption and is hence not a figure.-        The following will add set the `width` attribute of the image to-        `50%`:--            +ATTR\_HTML: :width 50%-            =======================--            \[\[file:image.jpg\]\]--    +   Support `ATTR_HTML` for special blocks (#3182). Special-        blocks (i.e. blocks with unrecognized names) can be prefixed with an-        `ATTR_HTML` block attribute. The attributes defined in that-        meta-directive are added to the `Div` which is used to represent the-        special block.-    +   Support the `todo` export option. The `todo` export option allows to-        toggle the inclusion of TODO keywords in the output. Setting this to-        `nil` causes TODO keywords to be dropped from headlines. The default-        is to include the keywords.-    +   Add support for todo-markers. Headlines can have optional-        todo-markers which can be controlled via the `#+TODO`, `#+SEQ_TODO`,-        or `#+TYP_TODO` meta directive. Multiple such directives can be-        given, each adding a new set of recognized todo-markers. If no-        custom todo-markers are defined, the default `TODO` and `DONE`-        markers are used. Todo-markers are conceptually separate from-        headline text and are hence excluded when autogenerating-        headline IDs. The markers are rendered as spans and labelled with-        two classes: One class is the markers name, the other signals the-        todo-state of the marker (either `todo` or `done`).--  * LaTeX writer:--    + Use `\autocites*` when "suppress-author" citation used.-    + Ensure that simple tables have simple cells (#2666). If cells-      contain more than a single Plain or Para, then we need to set-      nonzero widths and put contents into minipages.-    + Remove invalid inlines in sections (#3218, Hubert Plociniczak).--  * Markdown writer:--    + Fix calculation of column widths for aligned multiline tables-      (#1911, Björn Peemöller). This also fixes excessive CPU and memory-      usage for tables when `--columns` is set in such a way that cells-      must be very tiny. Now cells are guaranteed to be big enough so that-      single words don't need to line break, even if this pushes the line-      length above the column width.-    + Use bracketed form for native spans when `bracketed_spans`-      enabled (#3229).-    + Fixed inconsistent spacing issue (#3232). Previously a tight bullet-      sublist got rendered with a blank line after, while a tight ordered-      sublist did not. Now we don't get the blank line in either case.-    + Fix escaping of spaces in super/subscript (#3225). Previously two-      backslashes were inserted, which gave a literal backslash.-    + Adjust widths in Markdown grid tables so that they match-      on round-trip.--  * Docx writer:--    + Give full detail when there are errors converting tex math.-    + Handle title text in images (Jesse Rosenthal). We already handled-      alt text. This just puts the image "title" into the docx-      "title" attr.-    + Fixed XML markup for empty cells (#3238). Previously the Compact-      style wasn't being applied properly to empty cells.--  * HTML writer:--    + Updated `renderHtml` import from blaze-html.--  * Text.Pandoc.Pretty:--    + Fixed some bugs that caused blank lines in tables (#3251). The bugs-      caused spurious blank lines in grid tables when we had things like-      `blankline $$ blankline`.-    + Add exported function `minOffet` \[API change\] (Björn Peemöller).-    + Added error message for illegal call to `block` (Björn Peemöller).--  * Text.Pandoc.Shared:--    + Put `warn` in MonadIO.-    + `fetchItem`: Better handling of protocol-relative URL (#2635). If-      URL starts with `//` and there is no "base URL" (as there would be-      if a URL were used on the command line), then default to http:.--  * Export Text.Pandoc.getDefaultExtensions \[API change\] (#3178).--  * In --version, trap error in `getAppUserDataDirectory` (#3241). This-    fixes a crash with `pandoc --version` on unusual systems with no real-    user (e.g. SQL Server 2016).--  * Added weigh-pandoc for memory usage diagnostics (#3169).--  * Use correct mime types for woff and woff2 (#3228).--  * Remove make\_travis\_yml.hs (#3235, Kolen Cheung).--  * changelog: Moved an item that was misplaced in the 1.17.2 section to the-    1.18 section where it belongs.--  * CONTRIBUTING.md: minor change in wording and punctuation (#3252,-    Kolen Cheung).--  * Further revisions to manual for `--version` changes (#3244).---pandoc (1.18)--  * Added `--list-input-formats`, `--list-output-formats`,-    `--list-extensions`, `--list-highlight-languages`, and-    `--list-highlight-styles` (#3173).  Removed list of highlighting-    languages from `--version` output.  Removed list of input and output-    formats from default `--help` output.--  * Added `--reference-location=block|section|document` option-    (Jesse Rosenthal).  This determines whether Markdown link references-    and footnotes are placed at the end of the document, the end of the-    section, or the end of the top-level block.--  * Added `--top-level-division=section|chapter|part` (Albert Krewinkel).-    This determines what a level-1 header corresponds to in LaTeX,-    ConTeXt, DocBook, and TEI output.  The default is `section`.-    The `--chapters` option has been deprecated in favor of-    `--top-level-division=chapter`.--  * Added `LineBlock` constructor for `Block` (Albert Krewinkel).  This-    is now used in parsing RST and Markdown line blocks, DocBook-    `linegroup`/`line` combinations, and Org-mode `VERSE` blocks.-    Previously `Para` blocks with hard linebreaks were used.  `LineBlock`s-    are handled specially in the following output formats: AsciiDoc-    (as `[verse]` blocks), ConTeXt (`\startlines`/`\endlines`),-    HTML (`div` with a style), Markdown (line blocks if `line_blocks`-    is enabled), Org-mode (`VERSE` blocks), RST (line blocks). In-    other output formats, a paragraph with hard linebreaks is emitted.--  * Allow binary formats to be written to stdout (but not to tty) (#2677).-    Only works on posix, since we use the unix library to check whether-    output is to tty.  On Windows, pandoc works as before and always requires-    an output file parameter for binary formats.--  * Changed JSON output format (Jesse Rosenthal).  Previously we used-    generically generated JSON, but this was subject to change depending-    on the version of aeson pandoc was compiled with.  To ensure stability,-    we switched to using manually written ToJSON and FromJSON-    instances, and encoding the API version.  **Note:**  pandoc filter-    libraries will need to be revised to handle the format change.-    Here is a summary of the essential changes:--    + The toplevel JSON format is now `{"pandoc-api-version" :-      [MAJ, MIN, REV], "meta" : META, "blocks": BLOCKS}`-      instead of `[{"unMeta": META}, [BLOCKS]]`.-      Decoding fails if the major and minor version numbers don't-      match.-    + Leaf nodes no longer have an empty array for their "c" value.-      Thus, for example, a `Space` is encoded as `{"t":"Space"}`-      rather than `{"t":"Space","c":[]}` as before.--  * Removed `tests/Tests/Arbitrary.hs` and added a `Text.Pandoc.Arbitrary`-    module to pandoc-types (Jesse Rosenthal).  This makes it easier-    to use QuickCheck with pandoc types outside of pandoc itself.--  * Add `bracketed_spans` Markdown extension, enabled by default-    in pandoc `markdown`.  This allows you to create a native span-    using this syntax:  `[Here is my span]{#id .class key="val"}`.--  * Added `angle_brackets_escapable` Markdown extension (#2846).-    This is needed because github flavored Markdown has a slightly-    different set of escapable symbols than original Markdown;-    it includes angle brackets.--  * Export `Text.Pandoc.Error` in `Text.Pandoc` [API change].--  * Print highlighting-kate version in `--version`.--  * `Text.Pandoc.Options`:--    + `Extension` has new constructors `Ext_brackted_spans` and-      `Ext_angle_brackets_escapable` [API change].-    + Added `ReferenceLocation` type [API change] (Jesse Rosenthal).-    + Added `writerReferenceLocation` field to `WriterOptions` (Jesse-      Rosenthal).--  * `--filter`:  we now check `$DATADIR/filters` for filters before-    looking in the path (#3127, Jesse Rosenthal, thanks to Jakob-    Voß for the idea).  Filters placed in this directory need not-    be executable; if the extension is `.hs`, `.php`, `.pl`, `.js`,-    or `.rb`, pandoc will run the right interpreter.--  * For `--webtex`, replace deprecated Google Chart API by CodeCogs as-    default (Kolen Cheung).--  * Removed `raw_tex` extension from `markdown_mmd` defaults (Kolen Cheung).--  * Execute .js filters with node (Jakob Voß).--  * Textile reader:--    + Support `bc..` extended code blocks (#3037).  Also, remove trailing-      newline in code blocks (consistently with Markdown reader).-    + Improve table parsing.  We now handle cell and row attributes, mostly-      by skipping them.  However, alignments are now handled properly.-      Since in pandoc alignment is per-column, not per-cell, we-      try to devine column alignments from cell alignments.-      Table captions are also now parsed, and textile indicators-      for thead and tfoot no longer cause parse failure.  (However,-      a row designated as tfoot will just be a regular row in pandoc.)-    + Improve definition list parsing.  We now allow multiple terms-      (which we concatenate with linebreaks).  An exponential parsing-      bug (#3020) is also fixed.-    + Disallow empty URL in explicit link (#3036).--  * RST reader:--    + Use Div instead of BlockQuote for admonitions (#3031).-      The Div has class `admonition` and (if relevant) one of the-      following:  `attention`, `caution`, `danger`, `error`, `hint`,-      `important`, `note`, `tip`, `warning`.  **Note:** This will change-      the rendering of some RST documents!  The word ("Warning", "Attention",-      etc.) is no longer added; that must be done with CSS or a filter.-    + A Div is now used for `sidebar` as well.-    + Skip whitespace before note (Jesse Rosenthal, #3163).  RST requires a-      space before a footnote marker. We discard those spaces so that footnotes-      will be adjacent to the text that comes before it. This is in line with-      what rst2latex does.-    + Allow empty lines when parsing line blocks (Albert Krewinkel).--  * Markdown reader:--    + Allow empty lines when parsing line blocks (Albert Krewinkel).-    + Allow attributes on autolinks (#3183, Daniele D'Orazio).--  * LaTeX reader:--    + More robust parsing of unknown environments (#3026).-      We no longer fail on things like `^` inside options for tikz.-    + Be more forgiving of non-standard characters, e.g. `^` outside of math.-      Some custom environments give these a meaning, so we should try not to-      fall over when we encounter them.-    + Drop duplicate `*` in bibtexKeyChars (Albert Krewinkel)--  * MediaWiki reader:--    + Fix for unquoted attribute values in mediawiki tables (#3053).-      Previously an unquoted attribute value in a table row-      could cause parsing problems.-    + Improved treatment of verbatim constructions (#3055).-      Previously these yielded strings of alternating Code and Space-      elements; we now incorporate the spaces into the Code.  Emphasis-      etc. is still possible inside these.-    + Properly interpret XML tags in pre environments (#3042).  They are meant-      to be interpreted as literal text.--  * EPUB reader:  don't add root path to data: URIs (#3150).-    Thanks to @lep for the bug report and patch.--  * Org reader (Albert Krewinkel):--    + Preserve indentation of verse lines (#3064).  Leading spaces in verse-      lines are converted to non-breaking spaces, so indentation is preserved.-    + Ensure image sources are proper links.  Image sources as those in plain-      images, image links, or figures, must be proper URIs or relative file-      paths to be recognized as images.  This restriction is now enforced-      for all image sources.  This also fixes the reader's usage of uncleaned-      image sources, leading to `file:` prefixes not being deleted from-      figure images.  Thanks to @bsag for noticing this bug.-    + Trim verse lines properly (Albert Krewinkel).-    + Extract meta parsing code to module.  Parsing of meta-data is well-      separable from other block parsing tasks.  Moving into new module to-      get small files and clearly arranged code.-    + Read markup only for special meta keys.  Most meta-keys should be read-      as normal string values, only a few are interpreted as marked-up text.-    + Allow multiple, comma-separated authors.  Multiple authors can be-      specified in the `#+AUTHOR` meta line if they are given as a-      comma-separated list.-    + Give precedence to later meta lines.  The last meta-line of any given-      type is the significant line.  Previously the value of the first line-      was kept, even if more lines of the same type were encountered.-    + Read LaTeX_header as header-includes.  LaTeX-specific header commands-      can be defined in `#+LaTeX_header` lines.  They are parsed as-      format-specific inlines to ensure that they will only show up in LaTeX-      output.-    + Set documentclass meta from LaTeX_class.-    + Set classoption meta from LaTeX_class_options.-    + Read HTML_head as header-includes.  HTML-specific head content can be-      defined in `#+HTML_head` lines.  They are parsed as format-specific-      inlines to ensure that they will only show up in HTML output.-    + Respect `author` export option.  The `author` option controls whether-      the author should be included in the final markup.  Setting-      `#+OPTIONS: author:nil` will drop the author from the final meta-data-      output.-    + Respect `email` export option.  The `email` option controls whether the-      email meta-field should be included in the final markup. Setting-      `#+OPTIONS: email:nil` will drop the email field from the final-      meta-data output.-    + Respect `creator` export option.  The `creator` option controls whether-      the creator meta-field should be included in the final markup.  Setting-      `#+OPTIONS: creator:nil` will drop the creator field from the final-      meta-data output.  Org-mode recognizes the special value `comment` for-      this field, causing the creator to be included in a comment.  This is-      difficult to translate to Pandoc internals and is hence interpreted the-      same as other truish values (i.e. the meta field is kept if it's-      present).-    + Respect unnumbered header property (#3095).  Sections the `unnumbered`-      property should, as the name implies, be excluded from the automatic-      numbering of section provided by some output formats.  The Pandoc-      convention for this is to add an "unnumbered" class to the header.  The-      reader treats properties as key-value pairs per default, so a special-      case is added to translate the above property to a class instead.-    + Allow figure with empty caption (Albert Krewinkel, #3161).-      A `#+CAPTION` attribute before an image is enough to turn an image into-      a figure. This wasn't the case because the `parseFromString` function,-      which processes the caption value, would fail on empty values. Adding-      a newline character to the caption value fixes this.--  * Docx reader:--    + Use XML convenience functions (Jesse Rosenthal).-      The functions `isElem` and `elemName` (defined in Docx/Util.hs) make-      the code a lot cleaner than the original XML.Light functions, but they-      had been used inconsistently. This puts them in wherever applicable.-    + Handle anchor spans with content in headers.  Previously, we would only-      be able to figure out internal links to a header in a docx if the-      anchor span was empty. We change that to read the inlines out of the-      first anchor span in a header.-    + Let headers use existing id.  Previously we always generated an id for-      headers (since they wouldn't bring one from Docx). Now we let it use an-      existing one if possible. This should allow us to recurs through anchor-      spans.-    + Use all anchor spans for header ids.  Previously we only used the first-      anchor span to affect header ids. This allows us to use all the anchor-      spans in a header, whether they're nested or not (#3088).-    + Test for nested anchor spans in header.  This ensures that anchor spans-      in header with content (or with other anchor spans inside) will resolve-      to links to a header id properly.--  * ODT reader (Hubert Plociniczak)--    + Include list's starting value.  Previously the starting value of-      the lists' items has been hardcoded to 1. In reality ODT's list-      style definition can provide a new starting value in one of its-      attributes.-    + Infer caption from the text following the image.-      Frame can contain other frames with the text boxes.-    + Add `fig:` to title for Image with a caption (as expected-      by pandoc's writers).-    + Basic support for images in ODT documents.-    + Don't duplicate text for anchors (#3143).  When creating an anchor-      element we were adding its representation as well as the original-      content, leading to text duplication.--  * DocBook writer:--    + Include an anchor element when a div or span has an id (#3102).-      Note that DocBook does not have a class attribute, but at least this-      provides an anchor for internal links.--  * LaTeX writer:--    + Don't use * for unnumbered paragraph, subparagraph.  The starred-      variants don't exist.  This helps with part of #3058...it gets rid of-      the spurious `*`s.  But we still have numbers on the 4th and 5th level-      headers.-    + Properly escape backticks in verbatim (#3121, Jesse Rosenthal).-      Otherwise they can cause unintended ligatures like `` ?` ``.-    + Handle NARRAOW NO-BREAK SPACE into LaTeX (Vaclav Zeman) as `\,`.-    + Don't include `[htbp]` placement for figures (#3103, Václav Haisman).-      This allows figure placement defaults to be changed by the user-      in the template.--  * HTML writer (slide show formats): In slide shows, don't change slide title-    to level 1 header (#2221).--  * TEI writer: remove heuristic to detect book template (Albert Krewinkel).-    TEI doesn't have `<book>` elements but only generic `<divN>` division-    elements. Checking the template for a trailing `</book>` is nonsensical.--  * MediaWiki writer:  transform filename with underscores in images (#3052).-    `foo bar.jpg` becomes `foo_bar.jpg`. This was already done-    for internal links, but it also needs to happen for images.--  * ICML writer: replace partial function (!!) in table handling (#3175,-    Mauro Bieg).--  * Man writer: allow section numbers that are not a single digit (#3089).--  * AsciiDoc writer: avoid unnecessary use of "unconstrained" emphasis-    (#3068).  In AsciiDoc, you must use a special form of emphasis-    (double `__`) for intraword emphasis.  Pandoc was previously using-    this more than necessary.--  * EPUB writer:  use stringify instead of plain writer for metadata-    (#3066).  This means that underscores won't be used for emphasis,-    or CAPS for bold.  The metadata fields will just have unadorned-    text.--  * Docx Writer:--    + Implement user-defined styles (Jesse Rosenthal).  Divs and Spans-      with a `custom-style` key in the attributes will apply the corresponding-      key to the contained blocks or inlines.-    + Add ReaderT env to the docx writer (Jesse Rosenthal).-    + Clean up and streamline RTL behavior (Jesse Rosenthal, #3140).-      You can set `dir: rtl` in YAML metadata, or use `-M dir=rtl`-      on the command line.  For finer-grained control, you can set-      the `dir` attribute in Div or Span elements.--  * Org writer (Albert Krewinkel):--    + Remove blank line after figure caption.  Org-mode only treats an image-      as a figure if it is directly preceded by a caption.-    + Ensure blank line after figure.  An Org-mode figure should be surrounded-      by blank lines.  The figure would be recognized regardless, but images-      in the following line would unintentionally be treated as figures as-      well.-    + Ensure link targets are paths or URLs.  Org-mode treats links as-      document internal searches unless the link target looks like a URL or-      file path, either relative or absolute.  This change ensures that this-      is always the case.-    + Translate language identifiers.  Pandoc and Org-mode use different-      programming language identifiers.  An additional translation between-      those identifiers is added to avoid unexpected behavior.  This fixes a-      problem where language specific source code would sometimes be output-      as example code.-    + Drop space before footnote markers (Albert Krewinkel, #3162).-      The writer no longer adds an extra space before footnote markers.--  * Markdown writer:--    + Don't emit HTML for tables unless `raw_html` extension is set (#3154).-      Emit `[TABLE]` if no suitable table formats are enabled and raw HTML-      is disabled.-    + Check for the `raw_html` extension before emitting a raw HTML block.-    + Abstract out note/ref function (Jesse Rosenthal).-    + Add ReaderT monad for environment variables (Jesse Rosenthal).--  * HTML, EPUB, slidy, revealjs templates: Use `<p>` instead of `<h1>` for-    subtitle, author, date (#3119).  Note that, as a result of this change,-    authors may need to update CSS.--  * revealjs template:  Added `notes-server` option-    (jgm/pandoc-templates#212, Yoan Blanc).--  * Beamer template:--    + Restore whitespace between paragraphs. This was-      a regression in the last release (jgm/pandoc-templates#207).-    + Added `themeoptions` variable (Carsten Gips).-    + Added `beamerarticle` variable.  This causes the `beamerarticle`-      package to be loaded in beamer, to produce an article from beamer-      slides.  (Carsten Gips)-    + Added support for `fontfamilies` structured variable-      (Artem Klevtsov).-    + Added hypersetup options (Jake Zimmerman).--  * LaTeX template:--    + Added dummy definition for `\institute`.-      This isn't a standard command, and we want to avoid a crash when-      `institute` is used with the default template.-    + Define default figure placement (Václav Haisman), since pandoc-      no longer includes `[htbp]` for figures.  Users with custom templates-      will want to add this. See #3103.-    + Use footnote package to fix notes in tables (jgm/pandoc-templates#208,-      Václav Haisman).--  * Moved template compiling/rendering code to a separate library.-    `doctemplates`.  This allows the pandoc templating system to be-    used independently.--  * Text.Pandoc.Error: Fix out of index error in `handleError`-    (Matthew Pickering).  The fix is to not try to show the exact line when-    it would cause an out-of-bounds error as a result of included files.--  * Text.Pandoc.Shared: Add `linesToBlock` function (Albert Krewinkel).--  * Text.Pandoc.Parsing.emailAddress: tighten up parsing of email-    addresses.  Technically `**@user` is a valid email address, but if we-    allow things like this, we get bad results in markdown flavors-    that autolink raw email addresses (see #2940).  So we exclude a few-    valid email addresses in order to avoid these more common bad cases.--  * Text.Pandoc.PDF:  Don't crash with nonexistent image (#3100).  Instead,-    emit the alt text, emphasized.  This accords with what the ODT writer-    currently does.  The user will still get a warning about a nonexistent-    image.--  * Fix example in API documentation (#3176, Thomas Weißschuh).--  * Tell where to get tarball in INSTALL (#3062).--  * Rename README to MANUAL.txt and add GitHub-friendly README.md-    (Albert Krewinkel, Kolen Cheung).--  * Replace COPYING with Markdown version COPYING.md from GNU (Kolen Cheung).--  * MANUAL.txt:--    + Put note on structured vars in separate paragraph (#2148, Albert-      Krewinkel).  Make it clearer that structured author variables require a-      custom template-    + Note that `--katex` works best with `html5` (#3077).-    + Fix the LaTeX and EPUB links in manual (Morton Fox).-    + Document `biblio-title` variable.--  * Improve spacing of footnotes in `--help` output (Waldir Pimenta).--  * Update KaTeX to v0.6.0 (Kolen Cheung).--  * Allow latest dependencies.--  * Use texmath 0.8.6.6 (#3040).--  * Allow http-client 0.4.30, which is the version in stackage lts.-    Previously we required 0.5.-    Remove CPP conditionals for earlier versions.--  * Remove support for GHC < 7.8 (Jesse Rosenthal).--    + Remove Compat.Monoid.-    + Remove an inline monad compatibility macro.-    + Remove Text.Pandoc.Compat.Except.-    + Remove directory compat.-    + Change constraint on mtl.-    + Remove unnecessary CPP condition in UTF8.-    + Bump base lower bound to 4.7.-    + Remove 7.6 build from .travis.yaml.-    + Bump supported ghc version in CONTRIBUTING.md.-    + Add note about GHC version support to INSTALL.-    + Remove GHC 7.6 from list of tested versions (Albert Krewinkel).-    + Remove TagSoup compat.-    + Add EOL note to time compat module.  Because time 1.4 is a boot library-      for GHC 7.8, we will support the compatibility module as long as we-      support 7.8. But we should be clear about when we will no longer need-      it.-    + Remove blaze-html CPP conditional.-    + Remove unnecessary CPP in custom Prelude.--pandoc (1.17.2)--  * Added Zim Wiki writer, template and tests. `zimwiki` is now-    a valid output format. (Alex Ivkin)--  * Changed email-obfuscation default to no obfuscation (#2988).-    + `writerEmailObfuscation` in `defaultWriterOptions` is now-      `NoObfuscation`.-    + the default for the command-line `--email-obfuscation` option is-      now `none`.--  * Docbook writer: Declare xlink namespace in Docbook5 output (Ivo Clarysse).--  * Org writer:--    + Support arbitrary raw inlines (Albert Krewinkel).-      Org mode allows arbitrary raw inlines ("export snippets" in Emacs-      parlance) to be included as `@@format:raw foreign format text@@`.-    + Improve Div handling (Albert Krewinkel).  Div blocks handling is-      changed to make the output look more like idiomatic org mode:-        - Div-wrapped content is output as-is if the div's attribute is the-          null attribute.-        - Div containers with an id but neither classes nor key-value pairs-          are unwrapped and the id is added as an anchor.-        - Divs with classes associated with greater block elements are-          wrapped in a `#+BEGIN`...`#+END` block.-        - The old behavior for Divs with more complex attributes is kept.--  * HTML writer:--    + Better support for raw LaTeX environments (#2758).-      Previously we just passed all raw TeX through when MathJax was used for-      HTML math.  This passed through too much.  With this patch, only raw-      LaTeX environments that MathJax can handle get passed through.-      This patch also causes raw LaTeX environments to be treated-      as math, when possible, with MathML and WebTeX output.--  * Markdown writer:  use raw HTML for simple, pipe tables with linebreaks-    (#2993).  Markdown line breaks involve a newline, and simple and pipe-    tables can't contain one.--  * Make --webtex work with the Markdown writer (#1177).-    This is a convenient option for people using-    websites whose Markdown flavors don't provide for math.--  * Docx writer:--    + Set paragraph to FirstPara after display math (Jesse Rosenthal).-      We treat display math like block quotes, and apply FirstParagraph style-      to paragraphs that follow them. These can be styled as the user-      wishes. (But, when the user is using indentation, this allows for-      paragraphs to continue after display math without indentation.)-    + Use actual creation time as doc prop (Jesse Rosenthal).-      Previously, we had used the user-supplied date, if available, for Word's-      document creation metadata. This could lead to weird results, as in-      cases where the user post-dates a document (so the modification might be-      prior to the creation). Here we use the actual computer time to set the-      document creation.--  * LaTeX writer:--    + Don't URI-escape image source (#2825).  Usually this is a local file,-      and replacing spaces with `%20` ruins things.-    + Allow 'standout' as a beamer frame option (#3007).-      `## Slide title {.standout}`.--  * RST reader: Fixed links with no explicit link text.  The link-    `` `<foo>`_ `` should have `foo` as both its link text and its URL.-    See RST spec at <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases>-    Closes Debian #828167 -- reported by Christian Heller.--  * Textile reader:--    + Fixed attributes (#2984).  Attributes can't be followed by-      a space.  So, `_(class)emph_` but `_(noclass) emph_`.-    + Fixed exponential parsing bug (#3020).-    + Fix overly aggressive interpretation as images (#2998).-      Spaces are not allowed in the image URL in textile.--  * LaTeX reader:--    + Fix `\cite` so it is a NormalCitation not AuthorInText.-    + Strip off double quotes around image source if present (#2825).-      Avoids interpreting these as part of the literal filename.--  * Org reader:--    + Add semicolon to list of special chars (Albert Krewinkel)-      Semicolons are used as special characters in citations syntax.  This-      ensures the correct parsing of Pandoc-style citations: `[prefix; @key;-      suffix]`.  Previously, parsing would have failed unless there was a space-      or other special character as the last <prefix> character.-    + Add support for "Berkeley-style" cites (Albert Krewinkel, #1978).-      A specification for an official Org-mode citation syntax was drafted by-      Richard Lawrence and enhanced with the help of others on the orgmode-      mailing list.  Basic support for this citation style is added to the-      reader.-    + Support arbitrary raw inlines (Albert Krewinkel).-      Org mode allows arbitrary raw inlines ("export snippets" in Emacs-      parlance) to be included as `@@format:raw foreign format text@@`.-    + Remove partial functions (Albert Krewinkel, #2991).-      Partial functions like `head` lead to avoidable errors and should be-      avoided.  They are replaced with total functions.-    + Support figure labels (Albert Krewinkel, #2496, #2999).-      Figure labels given as `#+LABEL: thelabel` are used as the ID of the-      respective image.  This allows e.g. the LaTeX to add proper `\label`-      markup.-    + Improve tag and properties type safety (Albert Krewinkel).-      Specific newtype definitions are used to replace stringly typing of tags-      and properties.  Type safety is increased while readability is improved.-    + Parse as headlines, convert to blocks (Albert Krewinkel).-      Emacs org-mode is based on outline-mode, which treats documents as trees-      with headlines are nodes.  The reader is refactored to parse into a-      similar tree structure.  This simplifies transformations acting on-      document (sub-)trees.-    * Refactor comment tree handling (Albert Krewinkel).-      Comment trees were handled after parsing, as pattern matching on lists-      is easier than matching on sequences.  The new method of reading-      documents as trees allows for more elegant subtree removal.-    * Support archived trees export options (Albert Krewinkel).-      Handling of archived trees can be modified using the `arch` option.-      Archived trees are either dropped, exported completely, or collapsed to-      include just the header when the `arch` option is nil, non-nil, or-      `headline`, respectively.-    * Put export setting parser into module (Albert Krewinkel).-      Export option parsing is distinct enough from general block parsing to-      justify putting it into a separate module.-    * Support headline levels export setting (Albert Krewinkel).-      The depths of headlines can be modified using the `H` option.  Deeper-      headlines will be converted to lists.-    * Replace ugly code with view pattern (Albert Krewinkel).-      Some less-than-smart code required a pragma switching of overlapping-      pattern warnings in order to compile seamlessly.  Using view patterns-      makes the code easier to read and also doesn't require overlapping-      pattern checks to be disabled.-    * Fix parsing of verbatim inlines (Albert Krewinkel, #3016).-      Org rules for allowed characters before or after markup chars were not-      checked for verbatim text.  This resultet in wrong parsing outcomes of-      if the verbatim text contained e.g. space enclosed markup characters as-      part of the text (`=is_substr = True=`).  Forcing the parser to update-      the positions of allowed/forbidden markup border characters fixes this.--  * LaTeX template: fix for obscure hyperref/xelatex issue.-    Here's a minimal case:--        \documentclass[]{article}-        \usepackage{hyperref}-        \begin{document}-        \section{\%á}-        \end{document}--    Without this change, this fails on the second invocation of xelatex.-    This affects inputs this like `# %á` with pdf output via xelatex.--  * trypandoc:  call results 'html' instead of 'result'.-    This is for better compatibility with babelmark2.--  * Document MultiMarkdown as input/output format (Albert Krewinkel, #2973).-    MultiMarkdown was only mentioned as a supported Markdown dialect but not-    as a possible input or output format.  A brief mention is added-    everywhere the other supported markdown dialects are mentioned.--  * Document Org mode as a format containing raw HTML (Albert Krewinkel)-    Raw HTML is kept when the output format is Emacs Org mode.--  * Implement `RawInline` and `RawBlock` in sample lua custom writer (#2985).--  * Text.Pandoc.Shared:--    + Introduce blocksToInlines function (Jesse Rosenthal).-      This is a lossy function for converting `[Block] -> [Inline]`. Its main-      use, at the moment, is for docx comments, which can contain arbitrary-      blocks (except for footnotes), but which will be converted to spans.-      This is, at the moment, pretty useless for everything but the basic-      `Para` and `Plain` comments. It can be improved, but the docx reader-      should probably emit a warning if the comment contains more than this.-    + Add BlockQuote to blocksToInlines (Jesse Rosenthal).-    + Add further formats for `normalizeDate` (Jesse Rosenthal).-      We want to avoid illegal dates -- in particular years with greater than-      four digits. We attempt to parse series of digits first as `%Y%m%d`, then-      `%Y%m`, and finally `%Y`.-    + `normalizeDate` should reject illegal years (Jesse Rosenthal).-      We only allow years between 1601 and 9999, inclusive. The ISO 8601-      actually says that years are supposed to start with 1583, but MS Word-      only allows 1601-9999. This should stop corrupted word files if the date-      is out of that range, or is parsed incorrectly.-    + Improve year sanity check in normalizeDate (Jesse Rosenthal).-      Previously we parsed a list of dates, took the first one, and then-      tested its year range. That meant that if the first one failed, we-      returned nothing, regardless of what the others did. Now we test for-      sanity before running `msum` over the list of Maybe values. Anything-      failing the test will be Nothing, so will not be a candidate.--  * Docx reader:--    + Add simple comment functionality. (Jesse Rosenthal).-      This adds simple track-changes comment parsing to the docx reader. It is-      turned on with `--track-changes=all`. All comments are converted to-      inlines, which can list some information. In the future a warning will be-      added for comments with formatting that seems like it will be excessively-      denatured.  Note that comments can extend across blocks. For that reason-      there are two spans: `comment-start` and `comment-end`.  `comment-start`-      will contain the comment. `comment-end` will always be empty.  The two-      will be associated by a numeric id.-    + Enable warnings in top-level reader (Jesse Rosenthal).-      Previously we had only allowed for warnings in the parser. Now we allow-      for them in the `Docx.hs` as well. The warnings are simply concatenated.-    + Add warning for advanced comment formatting. (Jesse Rosenthal).-      We can't guarantee we'll convert every comment correctly, though we'll-      do the best we can. This warns if the comment includes something other-      than Para or Plain.-    + Add tests for warnings. (Jesse Rosenthal).-    + Add tests for comments (Jesse Rosenthal).-      We test for comments, using all track-changes options. Note that we-      should only output comments if `--track-changes=all`. We also test for-      emitting warnings if there is complicated formatting.--  * README: update to include track-changes comments. (Jesse Rosenthal)--  * Improved Windows installer - don't ignore properties set on command-line.-    See #2708.  Needs testing to see if this resolves the issue.-    Thanks to @nkalvi.--  * Process markdown extensions on command line in L->R order (#2995).-    Previously they were processed, very unintuitively, in R->L-    order, so that `markdown-tex_math_dollars+tex_math_dollars`-    had `tex_math_dollars` disabled.--  * Added `secnumdepth` variable to LaTeX template (#2920).--  * Include table of contents in README.html in Windows package.--  * Writers: treat SoftBreak as space for stripping (Jesse Rosenthal)-    In Writers.Shared, we strip leading and trailing spaces for display-    math. Since SoftBreak's are treated as spaces, we should strip those-    too.--  * beamer, latex templates:  pass biblatexoptions directly in package load.-    This allows runtime optinos to be used.  Fixes jgm/pandoc-citeproc#201--  * CPP workaround for deprecation of `parseUrl` in http-client.--  * Removed some redundant class constraints.--  * make_oxs_package.sh - use OSX env variable.--  * Replaced INSTALL with INSTALL.md, incorporating INSTALL and the-    old installing page from website.--  * Added `winpkg` target to Makefile.  This downloads the windows package-    from appveyor and signs it using the key.--  * Document Org mode as a format containing raw TeX (Albert Krewinkel).-    Raw TeX is kept verbatim when the output format is Emacs Org mode.--  * Support math with haddock-library >= 1.4.--  * Removed `-rtsopts` from library stanza.  It has no effect, and Hackage-    wouldn't accept the package.--  * Update library dependency versions.--pandoc (1.17.1)--  * New output format: `docbook5` (Ivo Clarysse).--  * `Text.Pandoc.Options`: Add `writerDocBook5` to `WriterOptions`-    (API change).--  * Org writer:--    + Add :PROPERTIES: drawer support (Albert Krewinkel, #1962).-      This allows header attributes to be added to org documents in the form-      of `:PROPERTIES:` drawers.  All available attributes are stored as-      key/value pairs.  This reflects the way the org reader handles-      `:PROPERTIES:` blocks.-    + Add drawer capability (Carlos Sosa).  For the implementation of the-      Drawer element in the Org Writer, we make use of a generic Block-      container with attributes.  The presence of a `drawer` class defines-      that the `Div` constructor is a drawer. The first class defines the-      drawer name to use.  The key-value list in the attributes defines-      the keys to add inside the Drawer.  Lastly, the list of Block elements-      contains miscellaneous blocks elements to add inside of the Drawer.-    + Use `CUSTOM_ID` in properties (Albert Krewinkel).  The `ID` property is-      reserved for internal use by Org-mode and should not be used.-      The `CUSTOM_ID` property is to be used instead, it is converted to the-      `ID` property for certain export format.--  * LaTeX writer:--    + Ignore `--incremental` unless output format is beamer (#2843).-    + Fix polyglossia to babel env mapping (Mauro Bieg, #2728).-      Allow for optional argument in square brackets.-    + Recognize `la-x-classic` as Classical Latin (Andrew Dunning).-      This allows one to access the hyphenation patterns in CTAN's-      hyph-utf8.-    + Add missing languages from hyph-utf8 (Andrew Dunning).-    + Improve use of `\strut` with `\minipage` inside tables-      (Jose Luis Duran).  This improves spacing in multiline-      tables.-    + Use `{}` around options containing special chars (#2892).-    + Avoid lazy `foldl`.-    + Don't escape underscore in labels (#2921).  Previously they were-      escaped as `ux5f`.-    + brazilian -> brazil for polyglossia (#2953).--  * HTML writer: Ensure mathjax link is added when math appears in footnote-    (#2881).  Previously if a document only had math in a footnote, the-    MathJax link would not be added.--  * EPUB writer: set `navpage` variable on nav page.-    This allows templates to treat it differently.--  * DocBook writer:--    + Use docbook5 if `writerDocbook5` is set (Ivo Clarysse).-    + Properly handle `ulink`/`link` (Ivo Clarysse).--  * EPUB reader:--    + Unescape URIs in spine (#2924).-    + EPUB reader:  normalise link id (Mauro Bieg).--  * Docx Reader:--    + Parse `moveTo` and `moveFrom` (Jesse Rosenthal).-      `moveTo` and `moveFrom` are track-changes tags that are used when a-      block of text is moved in the document. We now recognize these tags and-      treat them the same as `insert` and `delete`, respectively. So,-      `--track-changes=accept` will show the moved version, while-      `--track-changes=reject` will show the original version.-    + Tests for track-changes moving (Jesse Rosenthal).--  * ODT, EPUB, Docx readers: throw `PandocError` on unzip failure-    (Jesse Rosenthal) Previously, `readDocx`, `readEPUB`, and `readOdt`-    would error out if zip-archive failed. We change the archive extraction-    step from `toArchive` to `toArchiveOrFail`, which returns an Either value.--  * Markdown, HTML readers:  be more forgiving about unescaped `&` in-    HTML (#2410).  We are now more forgiving about parsing invalid HTML with-    unescaped `&` as raw HTML.  (Previously any unescaped `&`-    would cause pandoc not to recognize the string as raw HTML.)--  * Markdown reader:--    + Added bracket syntax for native spans (#168).-    + Fix pandoc title blocks with lines ending in 2 spaces (#2799).-    + Added `-s` to markdown-reader-more test.--  * HTML reader: fixed bug in `pClose`.  This caused exponential parsing-    behavior in documnets with unclosed tags in `dl`, `dd`, `dt`.--  * MediaWiki reader: Allow spaces before `!` in MediaWiki table header-    (roblabla).--  * RST reader: Support `:class:` option for code block in RST reader-    (Sidharth Kapur).--  * Org reader (all Albert Krewinkel, except where noted otherwise):--    + Stop padding short table rows.-      Emacs Org-mode doesn't add any padding to table rows.  The first-      row (header or first body row) is used to determine the column count,-      no other magic is performed.-    + Refactor rows-to-table conversion.  This refactors-      the codes conversing a list table lines to an org table ADT.-      The old code was simplified and is now slightly less ugly.-    + Fix handling of empty table cells, rows (Albert Krewinkel, #2616).-      This fixes Org mode parsing of some corner cases regarding empty cells-      and rows.  Empty cells weren't parsed correctly, e.g. `|||` should be-      two empty cells, but would be parsed as a single cell containing a pipe-      character.  Empty rows where parsed as alignment rows and dropped from-      the output.-    + Fix spacing after LaTeX-style symbols.-      The org-reader was dropping space after unescaped LaTeX-style symbol-      commands: `\ForAll \Auml` resulted in `∀Ä` but should give `∀ Ä`-      instead.  This seems to be because the LaTeX-reader treats the-      command-terminating space as part of the command.  Dropping the trailing-      space from the symbol-command fixes this issue.-    + Print empty table rows.  Empty table rows should not-      be dropped from the output, so row-height is always set to be at least 1.-    + Move parser state into separate module.-      The org reader code has become large and confusing.  Extracting smaller-      parts into submodules should help to clean things up.-    + Add support for sub/superscript export options.-      Org-mode allows to specify export settings via `#+OPTIONS` lines.-      Disabling simple sub- and superscripts is one of these export options,-      this options is now supported.-    + Support special strings export option Parsing of special strings-      (like `...` as ellipsis or `--` as en dash) can be toggled using the `-`-      option.-    + Support emphasized text export option.  Parsing of emphasized text can-      be toggled using the `*` option.  This influences parsing of text marked-      as emphasized, strong, strikeout, and underline.  Parsing of inline math,-      code, and verbatim text is not affected by this option.-    + Support smart quotes export option.  Reading of smart quotes can be-      toggled using the `'` option.-    + Parse but ignore export options. All known export options are parsed-      but ignored.-    + Refactor block attribute handling.  A parser state attribute was used-      to keep track of block attributes defined in meta-lines.  Global state-      is undesirable, so block attributes are no longer saved as part of the-      parser state.  Old functions and the respective part of the parser state-      are removed.-    + Use custom `anyLine`.  Additional state changes need to be made after-      a newline is parsed, otherwise markup may not be recognized correctly.-      This fixes a bug where markup after certain block-types would not be-      recognized.-    + Add support for `ATTR_HTML` attributes (#1906).-      Arbitrary key-value pairs can be added to some block types using a-      `#+ATTR_HTML` line before the block.  Emacs Org-mode only includes these-      when exporting to HTML, but since we cannot make this distinction here,-      the attributes are always added.  The functionality is now supported-      for figures.-    + Add `:PROPERTIES:` drawer support (#1877).-      Headers can have optional `:PROPERTIES:` drawers associated with them.-      These drawers contain key/value pairs like the header's `id`.  The-      reader adds all listed pairs to the header's attributes; `id` and-      `class` attributes are handled specially to match the way `Attr` are-      defined.  This also changes behavior of how drawers of unknown type-      are handled.  Instead of including all unknown drawers, those are not-      read/exported, thereby matching current Emacs behavior.-    + Use `CUSTOM_ID` in properties.  See above on Org writer changes.-    + Respect drawer export setting.  The `d` export option can be used-      to control which drawers are exported and which are discarded.-      Basic support for this option is added here.-    + Ignore leading space in org code blocks (Emanuel Evans, #2862).-      Also fix up tab handling for leading whitespace in code blocks.-    + Support new syntax for export blocks.  Org-mode version 9-      uses a new syntax for export blocks.  Instead of `#+BEGIN_<FORMAT>`,-      where `<FORMAT>` is the format of the block's content, the new-      format uses `#+BEGIN_export <FORMAT>` instead.  Both types are-      supported.-    + Refactor `BEGIN...END` block parsing.-    + Fix handling of whitespace in blocks, allowing content to be indented-      less then the block header.-    + Support org-ref style citations.  The *org-ref* package is an-      org-mode extension commonly used to manage citations in org-      documents.  Basic support for the `cite:citeKey` and-      `[[cite:citeKey][prefix text::suffix text]]` syntax is added.-    + Split code into separate modules, making for cleaner code and-      better decoupling.--  * Added `docbook5` template.--  * `--mathjax` improvements:--    + Use new CommonHTML output for MathJax (updated default MathJax URL,-      #2858).-    + Change default mathjax setup to use `TeX-AMS_CHTML` configuration.-      This is designed for cases where the input is always TeX and maximal-      conformity with TeX is desired.  It seems to be smaller and load faster-      than what we used before.  See #2858.-    + Load the full MathJax config to maximize loading speed (KolenCheung).--  * Bumped upper version bounds to allow use of latest packages-    and compilation with ghc 8.--  * Require texmath 0.8.6.2.  Closes several texmath-related bugs (#2775,-    #2310, #2310, #2824).  This fixes behavior of roots, e.g.-    `\sqrt[3]{x}`, and issues with sub/superscript positioning-    and matrix column alignment in docx.--  * README:--    + Clarified documentation of `implicit_header_references` (#2904).-    + Improved documentation of `--columns` option.--  * Added appveyor setup, with artifacts (Jan Schulz).--  * stack.yaml versions: Use proper flags used for texmath, pandoc-citeproc.--  * LaTeX template: support for custom font families (vladipus).-    Needed for correct polyglossia operation with Cyrillic fonts and perhaps-    can find some other usages.  Example usage in YAML metadata:--          fontfamilies:-          - name: \cyrillicfont-            font: Liberation Serif-          - name: \cyrillicfonttt-            options: Scale=MatchLowercase-            font: Liberation--  * Create unsigned msi as build artifact in appveyor build.--  * On travis, test with ghc 8.0.1; drop testing for ghc 7.4.1.--pandoc (1.17.0.3)--  * LaTeX writer: Fixed position of label in figures (#2813).-    Previously the label wasn't in the right place, and `\ref`-    wouldn't work properly.-  * Added .tei test files to pandoc.cabal so they'll be included-    in tarball (#2811).-  * Updated copyright dates.--pandoc (1.17.0.2)--  * Fixed serious regression in `htmlInBalanced`, which caused-    newlines to be omitted in some raw HTML blocks in Markdown-    (#2804).--pandoc (1.17.0.1)--  * File scope is no longer used when there are no input files (i.e.,-    when input comes from stdin).  Previously file scope was triggered-    when the `json` reader was specified and input came from `stdin`,-    and this caused no output to be produced.  (Fix due to Jesse Rosenthal;-    thanks to Fedor Sheremetyev for calling the bug to our attention.)-  * Improved documentation of templates (#2797).--pandoc (1.17)--  * Added `--file-scope` option (Jesse Rosenthal).-    By default pandoc operates on multiple files by first concatenating-    them (around extra line breaks) and then processing the joined file. So-    it only parses a multi-file document at the document scope. This has the-    benefit that footnotes and links can be in different files, but for-    some purposes it is useful to parse the individual files first-    and then combine their outputs (e.g. when the files use footnotes-    or links with the same labels).  The `--file-scope` option causes-    pandoc to parse the files first, and then combine the parsed output,-    instead of combining before parsing. `--file-scope` is selected-    automatically for binary input files (which cannot be concatenated)-    and for pandoc json.--  * Add TEI Writer (Chris Forster) and `tei` output format.--  * Added a general `ByteStringReader` with warnings, used by the docx-    reader (API change, Jesse Rosenthal).--  * Add `readDocxWithWarnings` (API change, Jesse Rosenthal).--  * Changed type of `Shared.uniqueIdent`'s argument from `[String]`-    to `Set String.` This avoids performance problems in documents with-    many identically named headers (API change, #2671).--  * Removed `tex_math_single_backslash` from `markdown_github` options-    (#2707).--  * Make language extensions as well as full language names-    trigger syntax highlighting.  For example, `py` will now work as-    well as `python` (jgm/highlighting-kate#83).--  * Added `institute` variable to latex, beamer templates (Fraser-    Tweedale, Josef Svenningsson).--  * Docx reader (Jesse Rosenthal):--    + Handle alternate content.  Some word functions (especially graphics)-      give various choices for content so there can be backwards compatibility.-    + Don't turn numbered headers into lists.-    + Docx Reader: Add state to the parser, for warnings-    + Update feature checklist in source code.-    + Get rid of `Modifiable` typeclass.-    + Add tests for adjacent hyperlinks.-    + Add a "Link" modifier to `Reducible`. We want to make sure that-      links have their spaces removed, and are appropriately smushed-      together (#2689).--  * HTML reader:--    + Fixed behavior of base tag (#2777).-      If the base path does not end with slash, the last component-      will be replaced.  E.g. base = `http://example.com/foo`-      combines with `bar.html` to give `http://example.com/bar.html`.-      If the href begins with a slash, the whole path of the base-      is replaced.  E.g. base = `http://example.com/foo/` combines-      with `/bar.html` to give `http://example.com/bar.html`.-    + Rewrote `htmlInBalanced`.  This version avoids an exponential-      performance problem with `<script>` tags, and it should be faster-      in general (#2730).-    + Properly handle an empty cell in a simple table (#2718).-    + Handle multiple `<meta>` tags with same name.  Put them in a list-      in the metadata so they are all preserved, rather than (as before)-      throwing out all but one..--  * Markdown reader:--    + Improved pipe table parsing (#2765).-    + Allow `+` separators in pipe table cells.  We already allowed-      them in the header, but not in the body rows, for some reason.-      This gives compatibility with org-mode tables.-    + Don't cross line boundary parsing pipe table row.-      Previously an Emph element could be parsed across the newline-      at the end of the pipe table row.-    + Use `htmlInBalanced` for `rawVerbatimBlock`, for better-      performance (#2730).-    + Fixed bug with smart quotes around tex math.--  * LaTeX reader:--    + Handle interior `$` characters in math (#2743).  For example,-      `$$\hbox{$i$}$$`.-    + `inlineCommand` now gobbles an empty `{}` after any command (#2687).-      This gives better results when people write e.g. `\TeX{}` in Markdown.-    + Properly handle LaTeX "math" environment as inline math (#2171).--  * Textile reader: Support `>`, `<`, `=`, `<>` text alignment attributes.-    Closes #2674.--  * Org reader (Albert Krewinkel):--    + Prefix even empty figure names with "fig:" (#2643).  The-      convention used by pandoc for figures is to mark them by prefixing-      the name with `fig:`.  The org reader failed to do this if a figure-      had no name.-    + Refactor link-target processing (#2684).--  * ConTeXt writer: Fix whitespace at line beginning in line blocks (#2744).-    Thanks to @c-foster.--  * HTML writer: Don't include alignment attribute for default table columns.-    Previously these were given "left" alignment.  Better to leave off-    alignment attributes altogether (#2694).--  * Markdown writer: Use hyphens for YAML metadata block bottom line, for-    better compatibility with other Markdown flavors (Henrik Tramberend).--  * LaTeX writer:--    + Use image identifier to create a label and hypertarget for-      figures (Mauro Bieg).-    + Avoid double toprule in headerless table with caption (#2742).-    + Clean up options parser (Jesse Rosenthal).-    + Treat `memoir` template with `article` option as article, instead-      of treating all `memoir` templates as books.-    + Allow more flexible table alignment (Henrik Tramberend, #2665).-      New default is not to include `[c]` option (which is the default-      anyway if no positioning is specified).  Now LaTeX emplates can-      control the overall table alignment in a document by setting the-      longtable length variables `LTleft` and `LTright`.  For example,-      `\setlength\LTleft\parindent\setlength\LTright\fill`-      will create left-aligned tables that respect paragraph indentation.--  * Docx writer: Handle image alt text (#2754, Mauro Bieg).--  * Org writer - pass through RawInline with format "org".--  * DokuWiki writer: use `$$` for display math.--  * Custom writer: Pass attributes parameter to CaptionedImage (#2697).--  * Make protocol-relative URIs work again (#2737).--  * make_osx_package.sh:  Use env variable for developer id certs.--  * Raise `tagsoup` lower bound to 0.13.7 to fix entity-related-    problems (#2734).--  * Allow `zip-archive` 0.3.--  * Allow `aeson` 0.11.--pandoc (1.16.0.2)--  * Depend on deepseq rather than deepseq-generics (fpco/stackage#1096).--  * Fixed regression in latex smart quote parsing (#2645).-    In cases where a match was not found for a quote, everything-    from the open quote to the end of the paragraph was being dropped.--pandoc (1.16.0.1)--  * Fixed regression with `--latex-engine` (#2618).  In 1.16 `--latex-engine`-    raises an error if a full path is given.--  * Org reader: Fix function dropping subtrees tagged `:noexport`-    (Albert Krewinkel, #2628):--  * Markdown reader: renormalize table column widths if they exceed 100%-    (#2626).--  * Textile reader:  don't allow block HTML tags in inline contexts.-    The reader previously did allow this, following redcloth,-    which happily parses--        Html blocks can be <div>inlined</div> as well.--    as--        <p>Html blocks can be <div>inlined</div> as well.</p>--    This is invalid HTML.  The above sample now produces;--        <p>Html blocks can be</p>-        <div>-        <p>inlined</p>-        </div>-        <p>as well.</p>--  * Improved default template lookup for custom lua scripts (#2625).-    Previously, if you tried to do `pandoc -s -t /path/to/lua/script.lua`,-    pandoc would look for the template in-    `~/.pandoc/templates/default./path/to/lua/script.lua`.-    With this change it will look in the more reasonable-    `~/.pandoc/templates/default.script.lua`.  This makes it possible to-    store default templates for custom writers.--  * RST, Markdown writers: Fixed rendering of grid tables with blank rows-    (#2615).--  * LaTeX writer: restore old treatment of Span (#2624).  A Span is-    now rendered with surrounding `{}`, as it was before 1.16.--  * Entity handling fixes: improved handling of entities like-    `&lang;` that require a trailing semicolon.  Allow uppercase-    `x` in numerical hexadecimal character references, working-    around a tagsoup bug.--  * `stack.yaml` - use lts-4.0, but with older aeson to avoid excessive-    memory use on compile.  With aeson 0.10 we were getting an out of-    memory error on a 2GB Ubuntu 64-bit VM.--  * Improved deb package creation script. Made `DPKGVER` work.-    Renamed `COMMIT` to `TREE`.  You should now be able to do-    `TREE=1.16.0.1 DPKGVER=2 make deb`.---pandoc (1.16)--  * Added `Attr` field to `Link` and `Image` (Mauro Bieg, #261, API change).--    + Added syntax for link and image attributes to pandoc's Markdown.-    + Updated readers and writers to use link and image attributes-      when appropriate.-    + Support image attributes in Docx, Textile, RST readers.--  * Renamed link attribute extensions.  The old `link_attributes` is-    now `mmd_link_attributes`, and `link_attributes` now enables the-    new pandoc-style link and image attributes (API change).-    Note: this change could break some existing workflows.--  * Implemented `SoftBreak` and new `--wrap` option (#1701, API change).-    Added threefold wrapping option.--    + Command line option: deprecated `--no-wrap`, added-      `--wrap=[auto|none|preserve]`-    + Added `WrapOption`, exported from `Text.Pandoc.Options`-    + Changed type of `writerWrapText` in `WriterOptions` from-      `Bool` to `WrapOption`.-    + Modified `Text.Pandoc.Shared` functions to allow `SoftBreak`.-    + Supported `SoftBreak` in readers and writers.--  * Text.Pandoc.Options:  Added `writerDpi` to `WriterOptions` (API-    change, Mauro Bieg).--  * Added `--dpi` command-line option (Mauro Bieg).--  * Rationalized behavior of `--no-tex-ligatures` and `--smart` (#2541).-    This change makes `--no-tex-ligatures` affect the LaTeX reader-    as well as the LaTeX and ConTeXt writers.  If it is used,-    the LaTeX reader will parse characters `` ` ``, `'`, and `-`-    literally, rather than parsing ligatures for quotation marks-    and dashes.  And the LaTeX writer will print unicode quotation-    mark and dash characters literally, rather than converting-    them to the standard ASCII ligatures.  Note that `--smart` has-    no effect on the LaTeX reader.  `--smart` is still the default-    for all input formats when LaTeX or ConTeXt is the output format,-    *unless* `--no-tex-ligatures` is used.--    Some examples to illustrate the logic:--    ```-    % echo "'hi'" | pandoc -t latex-    `hi'-    % echo "'hi'" | pandoc -t latex --no-tex-ligatures-    'hi'-    % echo "'hi'" | pandoc -t latex --no-tex-ligatures --smart-    ‘hi’-    % echo "'hi'" | pandoc -f latex --no-tex-ligatures-    <p>'hi'</p>-    % echo "'hi'" | pandoc -f latex-    <p>’hi’</p>-    ```--  * Removed deprecated options `--offline` and `--html5`.--  * Fixed language code for Czech (`cs` not `cz`) (#2597).--  * Implemented `east_asian_line_breaks` extension (#2586).-    In `Text.Pandoc.Options`, added `Ext_east_asian_line_breaks` constructor-    to `Extension` (API change).  This extension is like-    `ignore_line_breaks`, but smarter -- it only ignores line breaks-    between two East Asian wide characters.  This makes it better suited-    for writing with a mix of East Asian and non-East Asian scripts.--  * Added support for PDF creation via `wkhtmltopdf`.-    To use this: `pandoc -t html5 -o result.pdf` (and add `--mathjax`-    if you have math.) Margins can be set using the variables-    `margin-top`, `margin-bottom`, `margin-left`, `margin-right`.-    Other styling can be done through CSS.--  * Fixed cite key parsing regression (jgm/pandoc-citeproc#201).-    We were capturing final colons as in `[@foo: bar]`; the citation id-    was being parsed as `@foo:`.--  * ICML writer:--    + Fixed image syntax for local files (#2589).-    + Changed type of `writeICML` (Mauro Bieg).-      API change:  It is now `WriterOptions -> Pandoc -> IO String`.-      Also handle new image attributes.-    + Intersperse line breaks instead of appending them to-      every `ParagraphStyleRange` (Mauro Bieg, #2501).-    + Add `Cite` style to citations (Mauro Bieg).-    + Added figure handling (#2590, Mauro Bieg).-    + Better handling of math.  Instead of just printing the raw tex,-      we now try to fake it with unicode characters.--  * HTML writer: Include `example` class for example lists (#2524).--  * ODT/OpenDocument writer: improved image attributes (Mauro Bieg).--    + Support for percentage widths/heights-    + Use `Attr` instead of title to get dimensions from ODT walker-      to `writeOpenDocument`.--  * AsciiDoc writer:--    + Support anchors in spans and divs with id elements-      (jgm/pandoc-citeproc#143).-    + Fixed code blocks (#1861).--  * Haddock writer:  omit formatting inside links, which isn't supported-    by Haddock (#2515).--  * MediaWiki writer:  Fixed spacing issues in table cells.--    + Start cell on new line unless it's a single Para or Plain-      (#2606).-    + For single Para or Plain, insert a space after the `|` to-      avoid problems when the text begins with a character like-      `-` (#2604).--  * Beamer writer: mark frame as fragile when it contains verbatim (#1613).--  * LaTeX writer:--    + Add support for GAP highlighting using listings (Raniere Silva).-    + Consider `header-includes` content as well as templates-      when determining whether to use csquotes (Andreas Lööw).-    + Create defaults for geometry using `margin-left` etc.-      If `geometry` has no value, but `margin-left`, `margin-right`,-      `margin-top`, and/or `-margin-bottom` are given, a default value-      for `geometry` is created from these.  Note that these variables-      already affect PDF production via HTML5 with `wkhtmltopdf`.--  * ConTeXt writer: set default layout based on `margin-left`, etc.-    This sets up `\setuplayout` based on the variables `margin-left`,-    `margin-right`, `margin-bottom`, and `margin-top`, if no layout-    is given.--  * Docx writer:  better handling of PDF images.  Previously we tried-    to get the image size from the image even if an explicit size was-    specified.  Since we still can't get image size for PDFs, this made-    it impossible to use PDF images in docx.  Now we don't try to get-    the image size when a size is already explicitly specified.--  * Markdown writer:  use raw HTML for link/image attributes when-    the `link_attributes` extension is unset and `raw_html` is set (#2554).--  * MediaWiki reader: interpret markup inside `<tt>`, `<code>` (#2607).--  * LaTeX reader:--    + Improved smart quote parsing (#2555). This fixes redering of-      unmatched quotes.-    + Use curly quotes for unmatched ` (#2555).-    + Allow blank space between braced arguments of commands (#2592).--  * Markdown reader:--    + Improved pipe table relative widths.  Previously pipe table-      columns got relative widths (based on the header underscore lines)-      when the source of one of the rows was greater in width than the-      column width.  This gave bad results in some cases where much of-      the width of the row was due to nonprinting material (e.g. link-      URLs).  Now pandoc only looks at printable width (the width of a-      plain string version of the source), which should give better results.-      Thanks to John Muccigrosso for bringing up the issue.-    + Fixed parsing bug with macros.  Previously macro definitions in-      indented code blocks were being parsed as macro definitions, not code.--  * Textile reader:  skip over attribute in image source (#2515).-    We don't have a place yet for styles or sizes on images, but-    we can skip the attributes rather than incorrectly taking them-    to be part of the filename.--  * Docx reader: Handle dummy list items (Jesse Rosenthal).-    These come up when people create a list item and then delete the-    bullet. It doesn't refer to any real list item, and we used to ignore-    it.--  * CommonMark reader/writer rewritten to use latest `cmark`.--  * Fixed Emoji character definitions (#2523).  There were many bugs in the-    definitions.--  * `Text.Pandoc.CSS`:--    + Added `pickStylesToKVs` function to extract multiple properties at-      once (API change, Mauro Bieg).-    + Parse CSS that doesn't contain the optional semicolon (Mauro Bieg).--  * `trypandoc`: sort drop-down lists.--  * Beamer template:--    + Made `\euro` conditional on presence of character.-      for xelatex and lualatex, as it is for pdflatex (Andrew Dunning).-    + Moved `header-includes` before setting of title (Thomas Hodgson),-      to match the LaTeX template (jgm/pandoc-templates#168).-    + Added `section-titles` variable (defaults to true)-      to enable/suppress section title pages in beamer-      slide shows (Thomas Hodgson).-    + Moved beamer themes after fonts, so that themes can-      change fonts.  (Previously the fonts set were being-      clobbered by lmodern.sty.) (Thomas Hodgson).--  * Beamer/LaTeX template changes (Thomas Hodgson):-    + Added `thanks` variable-    + Use `parskip.sty` when `indent` isn't set (fall back to using-      `setlength` as before if `parskip.sty` isn't available).-    + Use `biblio-style` with biblatex.-    + Added `biblatexoptions` variable.--  * LaTeX template changes:--    + Added `paper` after `$papersize$` variable in latex template.-      Thus you can say `papersize: a4` and the latex will contain-      `a4paper`.  This change may break some existing workflows; if-      you currently specify `a4paper`, you'll get `a4paperpaper` which-      is meaningless.  However, the change seems worth it, as it will-      make the `papersize` variable work uniformly across ConTeXt, LaTeX,-      and html->pdf via wkhtmltopdf.-    + Only pass options to color package if `colorlinks` is set-      (Andrew Dunning).-    + Make definition of `\euro` conditional in xelatex/lualatex,-      as it is already for pdflatex (Andrew Dunning).-    + Removed setting of `subject` in PDF metadata.-      This used to be set to the subtitle, but really the subtitle-      need not give the subject.  Also, `subtitle` can contain formatting,-      so we'd need, at least, a plain text version for this.-    + Moved `header-includes` before setting of `\title`, `\author`,-      etc.  This allows these macros to be redefined.-    + Use `\subtitle` command for `subtitle`, instead of tacking it-      on to the title as before.  We give a no-op fallback definition if it-      is not defined.  This change should produce much better results-      in classes that support `\subtitle`.  With the default article-      class, which does not define `\subtitle`, subtitles will no-      longer be printed unless the user defines `\subtitle` and-      redefines `\maketitle`.-    + Moved redefinitions of `\paragraph` and `\subparagraph` to-      before header-includes.--  * Context template:--    + Use `simplefonts` for font loading (Paolo Rodríguez).  This is-      needed for things to work on ConTeXt stable from TeXLive 2015.-    + Revert use of `\setuphead` in title block (Andrew Dunning,-      Rik Kabel).--  * Update LaTeX/ConTeXt link colour usage (Andrew Dunning).--  * Fixed man template so disabling hyphenation actually works.-    The command needs to come after .TH.--  * Added 'navigation' variable to beamer template (#2543).-    Valid values are `empty` (the default), `horizontal`, `vertical`,-    and `frame`.  Note that this changes the default behavior from-    `horizontal` to `empty`.  Closes #2543.--  * Added `toc` to HTML slide format templates (Andrew Dunning),-    so that `--toc` creates a contents slide.--  * Added `stack.full.yaml` to build `pandoc-citeproc` as well.--  * Allow pipe tables with no body rows (#2556).-    Previously this raised a runtime error.--  * Shared: Improved `fetchItem` so that `C:/Blah/Blah.jpg` isn't treated-    as URL.  The Haskell URI parsing routines will accept "C:" as a-    scheme, so we rule that out manually.  This helps with-    `--self-contained` and absolute Windows paths.--  * Define a `meta-json` variable for all writers (#2019).  This contains-    a JSON version of all the metadata, in the format selected for the-    writer.  So, for example, to get just the YAML metadata, you can run-    pandoc with the following custom template: `$meta-json$`.  The intent-    is to make it easier for static site generators and other tools to get-    at the metadata.--  * Document limitations of --self-contained (#2553).--  * Improved Citations section of README (#2551).  Added information-    about `link-citations` and a link to the pandoc-citeproc man page.--  * `ImageSize`: use `safeRead` instead of `readMaybe`, which isn't-    in base < 4.6.--  * Allow .adoc file extension for AsciiDoc (Andrew Dunning).--  * Improved implicit pandoc-citeproc inclusion.-    The filter pandoc-citeproc is automatically used when-    `--bibliography` is specified on the command line, unless-    `--natbib` or `--biblatex` is used.  However, previously this-    only worked if `--bibliography` was spelled out in full, and not-    if `--biblio` was used.--  * reveal.js: Interpret pauses correctly for all headers (#2530).-    Previously, when using headers below the slide level, pauses are left-    uninterpreted into pauses. In my opinion, unexpected behavior but-    intentional looking at the code.--  * Remove redundant `center` variable for reveal.js (Andrew Dunning).--  * Parsing: Add `extractIdClass`, modified type of `KeyTable` (Mauro-    Bieg, API change).--  * ImageSize:  Added functions for converting between image dimensions-    (Mauro Bieg).--  * Use lts-3.18 in stack.yaml.  This avoids Windows build-    issues with the HTTP library.--  * Bump version bounds for dependencies.--pandoc (1.15.2.1)--  * Added two missing test files, and `stack.yaml`, to-    `extra-source-files` so they're included in the source tarball.--  * reveal.js template: Fixed parallaxBackground options.-    `parallaxBackgroundHorizontal` and `parallaxBackgroundVertical`-    need integer values, not strings.  (Vaughn Iverson)--pandoc (1.15.2)--  * `pandoc my.md -t context -o my.pdf` will now create a PDF using-    ConTeXt rather than LaTeX (#2463).--  * Fixed omitted `url(...)` in CSS data-uri with `--self-contained` (#2489).--  * Added `emoji` Markdown extension, enabled by default in `markdown_github`-    (#2523).  Added `Ext_emoji` to `Extension` in `Text.Pandoc.Options`-    (API change).--  * `Text.Pandoc.Readers.HTML.parseTags`: Fixed over-eager raw HTML inline-    parsing (#2469).  Tightened up the inline HTML parser so it disallows-    TagWarnings.--  * Derive `Generic` instances for the types in `Text.Pandoc.Options`.--  * Org reader:--    + Fix paragraph/list interaction (Albert Krewinkel, #2464).-      Paragraphs can be followed by lists, even if there is no blank line-      between the two blocks.  However, this should only be true if the-      paragraph is not within a list, were the preceding block should be-      parsed as a plain instead of paragraph (to allow for compact lists).-      Thanks to @rgaiacs for bringing this up.-    + Allow toggling header args (Albert Krewinkel, #2269).-      Org-mode allows to skip the argument of a code block header argument if-      it's toggling a value.  Argument-less headers are now recognized,-      avoiding weird parsing errors.-    + Fix markup parsing in headers (Albert Krewinkel, #2504).-      Markup as the very first item in a header wasn't recognized.  This was-      caused by an incorrect parser state: positions at which inline markup-      can start need to be marked explicitly by changing the parser state.-      This wasn't done for headers.  The proper function to update the state-      is now called at the beginning of the header parser, fixing this issue.-    + Fix emphasis rules for smart parsing (Albert Krewinkel, #2513).-      Smart quotes, ellipses, and dashes should behave like normal quotes,-      single dashes, and dots with respect to text markup parsing.-    + Require whitespace around definition list markers (#2518).-      This rule was not checked before, resulting in bugs with footnotes-      and some link types.--  * Markdown reader:--    + Pipe tables with long lines now get relative cell widths (#2471).-      If a pipe table contains a line longer than the column width (as set by-      `--columns` or 80 by default), relative widths are computed based on the-      widths of the separator lines relative to the column width.  This should-      solve persistent problems with long pipe tables in LaTeX/PDF output, and-      give more flexibility for determining relative column widths in other-      formats, too.  For narrower pipe tables, column widths of 0 are used,-      telling pandoc not to specify widths explicitly in output formats that-      permit this.-    + Improved parser for `mmd_title_block`.  We now allow blank metadata-      fields.  These were explicitly disallowed before.-    + Citation keys can now contain `://`, so URLs and DOIs can be used-      as citation keys (jgm/pandoc-citeproc#166).--  * Beamer template:  fix incompatibility of section slides with natbib.-    Natbib (and presumably biblatex) bibliography commands create-    their own section.  Since these are in frame environments,-    we have an incompatibility with the `\AtBeginSection` macro-    which creates a special frame when a new section occurs.-    (We can't have a frame inside another frame.) This change disables-    `\AtBeginSection` inside bibliography slides.  Thinks to Yihui Xie for-    bringing the problem to my attention.  This supersedes #145.  See-    discussion there.--  * Textile reader:  don't do smart punctuation unless explicitly asked-    (#2480).  Note that although smart punctuation is part of the textile-    spec, it's not always wanted when converting from textile-    to, say, Markdown.  So it seems better to make this an option.--  * LaTeX reader: Handle `comment` environment (Arata Mizuki).-    The `comment` environment is handled in a similar way to the-    `verbatim` environment, except that its content is discarded.--  * Docx reader:  Follow relationships correctly in foot/endnotes (#2258,-    Jesse Rosenthal).  This fixes a problem with links in notes.--  * LaTeX and ConTeXt writers: support `lang` attribute on divs and spans-    (Mauro Bieg).  For LaTeX, also collect `lang` and `dir` attributes on-    spans and divs to set the `lang`, `otherlangs` and `dir` variables if-    they aren’t set already.  See #895.--  * LaTeX writer:--    + Use proper command for `\textarabic` (Mauro Bieg).-    + Added `de-CH-1901`, fixed `el-polyton` in `toPloyglossia` (Nick Bart).-    + Use `\hypertarget` and `\hyperlink` for links.  This works correctly-      to link to Div or Span elements.  We now don't bother defining `\label`-      for Div or Span elements.  Closes jgm/pandoc-citeproc#174.-    + Avoid footnotes in list of figures (#1506).-    + Properly handle footnotes in captions (#1506).-    + Add `\protect` to `\hyperlink` (#2490).  Thanks to Hadrien Mary.-    + Set `colorlinks` if `linkcolor`, `urlcolor`, `citecolor`, or-      `toccolor` is set (#2508).--  * Textile writer: support start number in ordered lists (#2465).--  * OpenDocument writer:  Allow customization of opendocument-    automatic styles.  Automatic styles can now be inserted in the-    template, which now provides the enclosing `<office:automatic-styles>`-    tags (#2520).--  * Docx writer:  insert space between footnote reference and note (#2527).-    This matches Word's default behavior.--  * EPUB writer:  don't download linked media when `data-external` attribute-    set (#2473).  By default pandoc downloads all linked media and includes it-    in the EPUB container.  This can be disabled by setting `data-external` on-    the tags linking to media that should not be downloaded.  Example:--        <audio controls="1">-          <source src="http://example.com/music/toccata.mp3"-                  data-external="1" type="audio/mpeg">-          </source>-        </audio>--  * HTML writer:  use width on whole table if col widths sum to < 100%.-    Otherwise some browsers display the table with the columns-    separated far apart.--  * AsciiDoc template:  Fix `author` and `date`; add `keywords`,-    `abstract` (Andrew Dunning).--  * HTML-based templates (Andrew Dunning):--    + Use en dash instead of hyphen between title prefix and title.-    + Add `keywords` to metadata.-    + Add `lang`, `dir`, `quotes` where missing.-    + Always make author and date display conditional.-    + Updated dzslides template from source.--  * Man template: make "generated by" comment conditional.--  * LaTeX, Beamer templates:--    + Add `babel-otherlangs` for language divs/spans; `babel-newcommands`,-      filled by commands that make babel understand the polyglossia-style-      language directives (Mauro Bieg, #137).-    + Improved formatting of conditionals; `$for$` is always provided to allow-      multiple options (Andrew Dunning, #141).-    + Use `Ligatures=TeX` rather than `Mapping=tex-text` with `fontspec`-      to improve support for LuaTeX (Andrew Dunning, #135).-    + Revise `hyperref` usage (Andrew Dunning, #139, #141):-        - use same options for all LaTeX engines;-        - add `subtitle` and `keywords` to PDF metadata;-        - do not override `hyperref` link coloring without user input, effectively making-          the `hidelinks` option the default (removed as a separate variable);-        - link colors can be enabled (using a slightly darker version of the old-          defaults) using a new `colorlinks` variable, automatically used by-          the LaTeX writer when custom colors are specified;-        - `pdfborder={0 0 0}` is automatically set by `hyperref` with-          `colorlinks`, and is only applied if `colorlinks` is disabled.--  * ConTeXt template (Andrew Dunning):--    + New variables for controlling styles: `linkstyle`, `linkcolor`,-      `linkcontrastcolor`, `layout`, `pagenumbering`, `whitespace`, `indenting`,-      `interlinespace`, `headertext`, `footertext`, `mainfont`, `sansfont`,-      `monofont`, `mathfont`, `fontsize`.-    + Default template no longer supports MkII.-    + Improve writing of title block (suppressing numbering of first page).-    + Add `title` `subtitle`, `author`, `date`, `keywords` to PDF metadata.-    + Support `subtitle`, `abstract`.-    + Support list of figures (`lof`), list of tables (`lot`).-    + Disable link styling by default.-    + Define styles for all section types.-    + Enable microtype.-    + Improved formatting of conditionals.--  * Beamer template:  added code to prevent slide breaks inside paragraphs-    (#2422, thanks to Nick Bart).  This will matter, in practice, only when-    `allowframebreaks` is used.  It is especially helpful for bibliography-    slides.--  * OpenDocument template:  Add `<office:automatic-styles>` tag around-    automatic styles.  The writer now longer provides this (see #2520).--  * Restored Text.Pandoc.Compat.Monoid.--  * Do not export (<>) from custom Prelude.  The Prelude now matches-    base 4.8 Prelude's API.--  * Don't use custom prelude with ghc 7.10.  Use the custom prelude-    only for earlier versions.  This change makes `stack ghci` and-    `cabal repl` work (#2503), at least with ghc 7.10.--  * Changed § to % in operators from Odt.Arrows.Utils (#2457).-    This prevents problems building haddocks with "C" locale.--  * Change default for old-locale flag to False.--  * Use stack in deb, osx, and Windows package generators.--  * Added Vagrantfile for building deb in vm.-    This should help in automating binary package creation.  'make package'-    will make the package.  'make package COMMIT=blah' will make the package-    from commit blah.--  * README:--    + Consistent capitalization for pandoc and Markdown.-    + Fixed `auto_identifiers` examples (Benoit Schweblin).-    + Improved documentation of template variables (Andrew Dunning).--pandoc (1.15.1.1)--  * `Text.Pandoc.Data`:  store paths in dataFiles using posix separators.-    This way we have uniform separators, whether on Windows or Linux.-    This should solve a problem where on some Windows versions-    the data files weren't being found (#2459).--pandoc (1.15.1)--  * `pandocVersion` is now defined in `Text.Pandoc.Shared`-    and reexported from `Text.Pandoc` (Alex Vong).  This allows-    writers to access it.  (Alex Vong) (API change)--  * For `markdown_mmd`, add: `implicit_figures`, `superscripts`,-    `subscripts` (#2401).--  * Added `odt` as input format (Martin Linnemann).  Added new module-    `Text.Pandoc.Reader.ODT` (API change). Fully implemented features:-    Paragraphs, Headers, Basic styling, Unordered lists, Ordered lists,-    External Links, Internal Links, Footnotes, Endnotes, Blockquotes.-    Partly implemented features: Citations, Tables.--  * Markdown Reader:--    + Add basic tests for each header style (Ophir Lifshitz).-    + Add implicit header ref tests for headers with spaces (Ophir Lifshitz).-    + Skip spaces in headers (Ophir Lifshitz).-    + Handle 'id' and 'class' in parsing key/value attributes (#2396).-      `# Header {id="myid" class="foo bar"}`-      is now equivalent to `# Header {#myid .foo .bar}`.-    + Use '=' instead of '#' for atx-style headers in markdown+lhs.-      (Kristof Bastiaensen)-    + Pipe tables: allow indented columns.  Previously the left-hand column-      could not start with 4 or more spaces indent.  This was inconvenient-      for right-aligned left columns.  Note that the first (header column)-      must still have 3 or fewer spaces indentation, or the table will be-      treated as an indented code  block.-    + Fix regression:  allow HTML comments containing `--`.-      Technically this isn't allowed in an HTML comment, but-      we've always allowed it, and so do most other implementations.-      It is handy if e.g. you want to put command line arguments-      in HTML comments.--  * LaTeX reader:--    + Don't eat excess whitespace after macros with only optional-      arguments (#2446).-    + Support longtable (#2411).-    + Implement `\Cite` (#2335).-    + Support abstract environment.  The abstract populates an-      `abstract` metadata field.-    + Properly handle booktabs lines.  Lines aren't part of the-      pandoc table model, so we just ignore them (#2307).--  * HTML reader:--    + Handle type attribute on ol, e.g. `<ol type="i">` (#2313).-    + Updated for new automatic header attributes.-    + Add auto identifiers if not present on headers.  This makes-      TOC linking work properly.-    + Detect `font-variant` with `pickStyleAttrProps` (Ophir Lifshitz).-    + Test `<ol>` type, class, and inline list-style(-type) CSS-      (Ophir Lifshitz).-    + Better handling of "section" elements (#2438).  Previously-      `<section>` tags were just parsed as raw HTML blocks.  With-      this change, section elements are parsed as Div elements with-      the class "section".--  * MediaWiki reader:  handle unquoted table attributes (#2355).--  * DocBook reader:--    + Added proper support for DocBook `xref` elements (Frerich Raabe).-      Added `dbContent` field to reader state, so we can lookup-      cross refs.-    + Handle `informalexample` (#2319).--  * Docx Reader:--    + Create special punctuation test (Ophir Lifshitz).-    + Parse soft, no-break hyphen elements (Ophir Lifshitz).-    + Updated headers test (Ophir Lifshitz). Replaced `styles.xml`-      in `headers.docx` with pandoc's current `styles.xml`, which-      contains styles for Heading 1 through 6. Added Heading 4-      through 7 to the test document. Note that Heading 7 is not-      parsed as a Heading because there is no Heading 7 style.--  * RST reader:  better handling of indirect roles.-    Previously the parser failed on this kind of case--        .. role:: indirect(code)--        .. role:: py(indirect)-           :language: python--        :py:`hi`--    Now it correctly recognizes `:py:` as a code role.--  * Org reader:--    + Add auto identifiers if not present on headers-      (#2354, Juliusz Gonera).-    + Allow verse blocks to contain empty lines (#2402,-      Albert Krewinkel).--  * EPUB reader:  stop mangling external URLs (#2284).--  * RST writer:--    + Don't insert `\ ` when complex expression in matched pairs.-      E.g. `` [:sup:`3`] `` is okay; you don't need `` [:sup:`3`\ ] ``.-    + Ensure that `\ ` is inserted when needed before Cite and Span-      elements that begin with a "complex" element (jgm/pandoc-citeproc#157).-    + Normalize headers only in "standalone" mode (#2394).--  * Haddock writer: escape `*` and `^` (G. Bataille).--  * Markdown writer:--    + In TOC, add links to headers (#829).-    + Use unicode super/subscripts for digits in plain output-      (when the `superscripts` and `subscripts` extensions are-      not enabled).--  * Docx writer:--    + Moved invalid character stripping to `formattedString`.-      This avoids an inefficient generic traversal (#2356).-    + Use user data directory for `reference.docx` archive.-      This allows the test suite to work without installing pandoc first.-      It also brings the docx writer in line with the odt writer.-    + Tests:  docx writer tests now use `../data` for data directory.-      This allows tests to be run without installing first.-    + Tests: Use real jpg (not empty) for docx tests to avoid warning.--  * LaTeX writer:--    + Fixed detection of 'chapters' from template.-      If a documentclass isn't specified in metadata, but the-      template has a hardwired bookish documentclass, act as if-      `--chapters` was used.  This was the default in earlier-      versions, but it has been broken for a little while.-    + Correctly recognize book documentclass in metadata (#2395).-    + Set language-related variables automatically, depending-      on the value of the `lang` field, which is now always-      assumed to be in BCP47 format (Mauro Bieg, #1614, #2437).-    + Add `\protect` to `\hyperdef` in inline context.  This way we-      don't get an error when this is used as a moveable argument (#2136).-    + Support all frame attributes in Beamer.-    + Percent-encode more special characters in URLs (#1640, #2377).-      The special characters are '<','>','|','"','{','}','[',']','^', '`'.--  * HTML writer:--    + Update KaTeX JS and CSS versions (Emily Eisenberg).-    + For dzslides, add `role="note"` for speaker notes (#1693).-    + Percent-encode more special characters in URLs (#1640, #2377).-      The special characters are '<','>','|','"','{','}','[',']','^', '`'.-    + Render Div with class `section` as `<section>` in HTML5.--  * EPUB writer:--    + In TOC, replace literal `<br/>` with space (#2105).-    + With `--webtex`, include image file rather than `data:` URI (#2363).--  * Native writer: format Div properly, with blocks separated.--  * Support bidirectional text output with XeLaTeX, ConTeXt and HTML-    (#2191, Mauro Bieg).--  * Reference Docx:--    + Add missing Header 6 style (steel blue) (Ophir Lifshitz).-    + Correct `outlineLvl` for Header styles (Ophir Lifshitz).--  * Templates--    + Beamer:  Add `innertheme`, `outertheme` variables-      (Guilhem Bonnefille, #121). Add space after colon in figure caption.-      Integrate recent font and language updates from LaTeX template;-      allow use of `mainfont` variable for changing the slide text-      in XeTeX and LuaTeX (Andrew Dunning, #131).-    + LaTeX:  Add `mainfontoptions`, `sansfontoptions`,-      `monofontoptions`, `mathfontoptions`, `fontfamilyoptions`-      (Andrew Dunning, #122).  Support handling of bidirectional-      text (Mauro Bieg, #120). Improve reliability of superscripts/subscripts-      under XeTeX and prevent letters and numbers from appearing on a-      different baseline by removing use of the `realscripts` package-      (via `xltxtra`).  To restore use of OpenType characters for these-      features under XeTeX or LuaTeX, add `\usepackage{realscripts}` to-      `header-includes` (Andrew Dunning, #130).  Remove redundant-      reference to `xunicode` (Andrew Dunning, #130).  Add `fontenc`,-      `indent`, `subparagraph` variables (Andrew Dunning).-      Allow use of `hidelinks` variable for `hyperref` package (Hugo Roy,-      #113).  Prevent package clash with `tufte-latex` and other classes that-      include `hyperref` or `color` (Xavier Olive, #115).-    + ConTeXt:  Support handling of bidirectional text (Mauro Bieg, #120).-    + LaTeX and ConTeXt: Use more specific language variables.-      Instead of directly using `lang`, we now use `babel-lang` and-      `polyglossia-lang` and `context-lang`.  These variables are set by-      the writers to the necessary values, based on the `lang` variable-      (which now always takes a value in BCP47 format). (Mauro Bieg, #114,-      #129).-    + HTML:  Support handling of bidirectional text (Mauro Bieg, #120).-      Move HTML5 shiv after CSS and fix URL (Andrew Dunning).-      Add dir attribute in html5 (Andrew Dunning).-    + reveal.js: Add `controls`, `progress` variables (Grégoire Pineau, #127).-      Add `width`, `height` variables (Andrew Dunning).  Update template-      from 3.1 source (Andrew Dunning).  All configuration options are now-      available as variables, but are only be included if set (reveal.js-      uses defaults otherwise).-    + man: Added comment stating that the page is autogenerated by pandoc,-      giving version.  Added `adjusting` and `hyphenate` variables-      (Alex Vong, #123).--  * epub.css: added selectors for nested emphasis (Pablo Rodriguez).--  * MediaBag:  ensure that `/` is always used as path separator.--  * `sample.lua`: define `CaptionedImage`, add newline at end (#2393).--  * Added `--bash-completion` option.  This generates a bash completion-    script.  To use: `eval "$(pandoc --bash-completion)"`.--  * Text.Pandoc.Error: Define Typeable and Exception instances-    for PandocError (#2386).--  * Text.Pandoc.Parsing: `toKey`: strip off outer brackets.-    This makes keys with extra space at the beginning and end-    work:  e.g.--        [foo]: bar--        [ foo ]--    will now be a link to bar (it wasn't before).--  * Text.Pandoc: disable `auto_identifiers` for epub.-    The epub writer inserts its own auto identifiers;-    this is more complex due to splitting into "chapter" files.--  * Renamed Text.Pandoc.Compat.Locale -> Text.Pandoc.Compat.Time.-    It now reexports Data.Time.--  * Use custom Prelude to avoid compiler warnings.--    + The (non-exported) prelude is in prelude/Prelude.hs.-    + It exports Monoid and Applicative, like base 4.8 prelude,-      but works with older base versions.-    + It exports (<>) for mappend.-    + It hides 'catch' on older base versions.--  * Added a `stack.ymal` and stack install instructions to INSTALL.--  * Clarified what is "out of scope" in README and CONTRIBUTING.md.--  * Added note to CONTRIBUTING.md about ghc versions and travis.--  * Clarify docs on block quotes.  The space after `>` is optional (#2346).--  * Removed obsolete reference to default.csl (#2372).--  * List all styles in manual for `--reference-docx` (Chris Black)--  * Don't capitalize header links in man page.--  * Added section on repl to CONTRIBUTING.md.--  * README:  Added space after backslash in image example (#2329).--  * Document details of citation locator terms (Nick Bart).--  * Fixed some internal links in README (#2309).--  * Improve CSL documentation, variables documentations,-    links, and cross-references in README. (Andrew Dunning)--  * Fix build failure with `--flags=-https` (Sergei Trofimovich).--  * Use `newManager` instead of `withManager` in recent `http-client`.-    This avoids a deprecation warning.--  * Allow building with latest versions of http-types,-    HUnit, criterion, syb, aeson.--  * Updated benchmark program for new criterion API.--  * Setup.hs: rewrite so as not to use process, directory, filepath.-    Using anything outside base is dangerous, since older-    versions of ghc may link against two different versions.--  * Added appveyor (Windows continuous integration) builds.--  * New `.travis.yml`.  Autgenerated using `make_travis_yml.hs`.-    This script has been modified in a few ways, e.g. to add `GHCOPTS`.-    `make .travis.yml` regenerates it based on the tested-with-    field of the cabal file.--pandoc (1.15.0.6)--  * `--self-contained`:  Fixed overaggressive CSS minimization (#2301, 2286).-    Previously `--self-contained` wiped out all spaces in CSS,-    including semantically significant spaces.  This was a regression-    from 1.14.x.--  * Markdown reader: don't allow bare URI links or autolinks in link-    label (#2300).  Added test cases.--  * `Text.Pandoc.Parsing`, `uri`: Improved bare autolink detection (#2299).-    Previously we disallowed `-` at the end of an autolink,-    and disallowed the combination `=-`.  This commit liberalizes the-    rules for allowing punctuation in a bare URI, and adds test cases.-    One potential drawback is that you can no longer put a bare-    URI in em dashes like this:-    `this uri---http://example.com---is an example.`-    But in this respect we now match github's treatment of bare URIs.--  * HTML writer:  support speaker notes in dzslides.-    With this change `<div class="notes">` and also `<div class="notes"-    role="note">` will be output if `-t dzslides` is used. So we can-    have speaker notes in dzslides too.  Thanks to maybegeek.--  * Updated dzslides template.--  * Improved documentation of options to print system default files (#2298).-    `--print-default-data-file` and `--print-default-template`.--  * DokuWiki writer: use `$..$` for Math instead of `<math>..</math>`-    (Tiziano Müller).  MathJax seems currently to be the only maintained-    math rendering extension for DokuWiki.--  * `Text.Pandoc.Shared`: Changed `hierarchicalize` so it treats references-    div as top-level header (#2294).  This fixes a bug with `--section-divs`,-    where the final references section added by pandoc-citeproc, enclosed in-    its own div, got nested in the div for the section previous to it.--  * Allow vector 0.11.--  * Require cmark > 0.4.--pandoc (1.15.0.5)--  * HTML writer: Fixed email javascript obfuscation with `mailto:`-    URLs (#2280).  This fixes a potential security issue.  Because-    single quotes weren't being escaped in the link portion, a-    specially crafted email address could allow javascript code injection.--  * Markdown/HTML readers:  Avoid parsing partial URLs like-    `<www.pandoc.org/blah#foo>` as HTML tags (#2277).--  * RST reader:  allow inline formatting in definition list field-    names (Lars-Dominik Braun).--  * PDF:  Make sure `--latex-engine-opt` goes before the filename-    on the command line.  LaTeX needs the argument to come after-    the options (#1779).--  * CommonMark writer: fixed tags used for super/subscript.--  * ConTeXt template:  activate hanging indent for definition lists-    (Mauro Bieg).--  * Make cabal require `hsb2hs` >= 0.3.1 if `embed_data_files` specified.-    This is done by adding `hookedPrograms` in `Setup.hs`, which allows us-    to include `hsb2hs` in Build-Tools in cabal.--  * Improved Windows installer (thanks to nkalvi).--    + When per-machine installation is chosen, the system path-      is updated instead of the user's.-    + An appropriate default is used for per-machine installation-      directory.-    + Admin privileges are no longer required for a per-user install--  * Travis:  unpack sdist for build to catch packaging bugs.--  * Improved documentation on where user templates go (#2272).--pandoc (1.15.0.4)--  * Added pandoc.1 man page to the repository.  It is no longer-    built as part of the cabal build process. (This proved too-    fragile.)  pandoc.1 can be regenerated (`make man/pandoc.1`)-    when `README` is changed.--  * Copying of the man page now respects `--destdir` (#2262).--  * Improved error messages for filters.  User is now informed if-    the filter requires an interpreter that isn't found in the path,-    or if the filter returns an error status.--pandoc (1.15.0.3)--  * Ensure target directory is created when installing man page.--pandoc (1.15.0.2)--  * Added files needed for building man page to Extra-Source-Files.--pandoc (1.15.0.1)--  * Man page is now built and installed as part of the cabal build-    process. Removed Makefile target for man page.--pandoc (1.15)--  * Man page changes:--    + Removed `--man1`, `--man5` options (breaking change).-    + Removed `Text.Pandoc.ManPages` module (breaking API change).-    + Makefile target for `man/man1/pandoc.1`.  This uses pandoc to-      create the man page from README using a custom template and filters.-    + Added `man/` directory with template and filters needed to build-      man page.-    + We no longer have two man pages: `pandoc.1` and `pandoc_markdown.5`.-      Now there is just pandoc.1, which has all the content from README.-      This change was needed because of the extensive cross-references-      between parts of the README.-    + Removed old `data/pandoc.1.template` and-      `data/pandoc_markdown.5.template`.--  * OpenDocument writer: Do not add a carriage return after a hard-    line break (Michael Chladek).--  * ConTeXt writer:--    + use `\goto` for internal links.-    + Added a `%` at end for `\reference` to avoid spurious space.--  * Ignore sandbox on 'make quick'--pandoc (1.14.1)--  * Added `--man1` and `--man5` options to pandoc, allowing pandoc-    to generate its own man pages.  Man pages are no longer automatically-    generated in the build process (the process for this was too complex-    and prone to failure, #2190).  The `make-pandoc-man-pages` executable-    has been removed.  The `man/` directory has been removed, and man page-    templates have been moved to `data/`.  NOTE TO PACKAGERS:  You will no-    longer find pandoc's man pages in `man/`, but you can generate them using-    `pandoc --man1 > pandoc.1` and `pandoc --man5 > pandoc_markdown.5`.--  * Added new unexported module:  `Text.Pandoc.ManPages`.--  * `README` now acts like a data file (even though it isn't in-    `data/`).  So, for example, `pandoc --print-default-data-file README`-    will produce the README.)  This change was required for the `--man1`-    and `--man5` options, since the man pages are produced from the-    README, but it may be useful for other purposes as well.--  * Allow `reference.docx` and `reference.odt` to be used with-    `--print-default-data-file` and to shadow defaults if placed in-    the user data directory.  Note that as of 1.14, we no longer-    include these files as data files; instead, we include their-    components.  This change causes pandoc to behave as if it has-    these data files; they are constructed on demand when needed-    using `getDefaultReferenceDocx` and `getDefaultReferenceODT`.--  * Fixed regression in CSS parsing with `--self-contained` (#2224).-    Pandoc 1.14.0.x used css-text to parse the CSS, but its parser-    silently drops big sections of CSS.  This commit replaces the-    use of css-text with a small but principled CSS preprocessor,-    which removes whitespace and comments and replaces `url()` with-    base 64 data when possible.--  * Use `https://` instead of `//` for MathJax and KaTeX CDN URLs (#1920).-    This will allow math to work when pages are being viewed locally.--  * `Text.Pandoc.Options`:  Export `plainExtensions`.-    These are the extensions used in `plain` output.--  * LaTeX reader: Don't parse `_` and `^` as sub/superscript outside of-    math mode; treat them as regular inline text.  Normally these will-    cause an error in LaTeX, but there are contexts (e.g. `alltt`-    environments) where they are allowed.--  * HTML reader:  allow `<body>` to close `<head>`.--  * DocBook reader: support `mediaobject`s and `figures` (#2184, Mauro Bieg).--  * RST reader: Fix reference names with special characters-    (Lars-Dominik Braun).--  * Textile writer:  escape `+` and `-` as entities (#2225).--  * DokuWiki writer: Use proper `<code>` tags for code blocks (#2213).--  * Plain writer:  don't use symbols for super/subscript (#2237).-    Simplified code by using `plainExtensions`.--  * InDesign writer: Properly escape URLs containing more than one-    colon character (gohai).--  * Docx writer: Make sure we use dist version of `reference.docx`-    (and not the user's version) for certain settings.  Taking some-    settings values from a user-supplied reference.docx can lead to-    corruption.  This fixes a regression from the last release (#2249).--  * `Text.Pandoc.Shared`: exports `getDefaultReferenceDocx` and-    `getDefaultReferenceODT` (API change).  These functions have been-    removed from the Docx and ODT writers.--  * LaTeX template (Xavier Olive):-    + Added `CJKmainfont` and `CJKoptions` variables.-    + Allow dvipsnames (e.g. `MidnightBlue`) for colors (Xavier Olive).--  * Epub templates:  use `author.role`, not `author.type`.--  * Bump cmark version to >= 0.3.4.--  * Improved Windows installer (#2205, thanks to nkalvi).-    Users can now select a per-user or systemwide install, and can set-    the installation path.  At the end of installation, the install location-    is given.  The install location is also now given in the list of-    installed programs in Control Panel.  Cleaner WiX syntax is used for-    setting the path.--  * Added `download_stats` target to Makefile.--pandoc (1.14.0.4)--  * Added missing commonmark template.--  * Improved try pandoc (moved button, show raw command).--pandoc (1.14.0.3)--  * Allow compilation with syb 0.5.*.--  * Custom writer:  fixed some compiler warnings for ghc < 7.10.--pandoc (1.14.0.2)--  * Allow building with hslua 0.4.--pandoc (1.14.0.1)--  * Fixed problem with building of `reference.docx` and `reference.odt`-    when the `embed_data_files` flag is used.  Instead of having a phase-    of the build where `reference.docx` and `reference.odt` are created-    from their constituent data files, we now construct these archives-    from their constituents when a `docx` or `odt` is built.  The-    constituent files have been moved from `extra-source-files` to-    `data-files`, and `reference.docx` and `reference.odt` have been-    removed. Users can create their own `reference.docx` or-    `reference.odt` by using pandoc to create a simple `docx` or `odt`.-    `make-reference-files.hs` has been removed, simplifying the build-    process (#2187)--  * Don't include generated man pages in extra-source-files (#2189).--  * Bumped upper bound for aeson.--  * ConTeXt writer:  create internal link anchors for Div elements with-    identifiers.  (This is needed for linked citations to work.)--pandoc (1.14)--  [new features]--  * Added `commonmark` as input and output format.--  * Added `--verbose` flag for debugging output in PDF production (#1840,-    #1653).--  * Allow wildcards in `--epub-embed-font` arguments (#1939).--  * Added `--latex-engine-opt` option (#969, #1779, Sumit Sahrawat).--  * Added `shortcut_reference_links` extension (Konstantin Zudov, #1977).-    This is enabled by default for those markdown flavors that-    support reading shortcut reference links, namely: `markdown`,-    `markdown_strict`, `markdown_github`, `markdown_php`.-    If the extension is enabled, the reader parses shortcut reference-    links like `[foo]`, and the writer creates such links unless doing-    so would cause problems.  Users of markdown flavors that support-    shortcut reference links should not notice a difference in reading-    markdown, but the markdown pandoc produces may differ.-    If shortcut links are not desired, the extension can be disabled-    in the normal way.--  [behavior changes]--  * `--toc` is now supported for `docx` output (#458, Nikolay Yakimov).-    A "dirty" TOC is created at the beginning of document.-    It can be regenerated after the document has been opened.--  * An implicit `--filter pandoc-citeproc` is now triggered only when the-    `--bibliography` option is used, and not when the `bibliography`-    field in metadata is specified (#1849).--  * Markdown reader:--    + Reference links with `implicit_header_references` are no longer-      case-sensitive (#1606).-    + Definition lists no longer require indentation for first line (#2087).-      Previously the body of the definition (after the `:` or `~` marker)-      needed to be in column 4.  This commit relaxes that requirement,-      to better match the behavior of PHP Markdown Extra.  So, now-      this is a valid definition list:--            foo-            : bar-    + Resolve a potentially ambiguity with table captions:--            foo--              : bar--              ------              table-              -------      Is "bar" a definition, or the caption for the table?  We'll count-      it as a caption for the table.-    + Disallow headerless pipe tables (#1996), to conform to GFM and PHP-      Markdown Extra.  Note:  If you have been using headerless pipe tables,-      this change may cause existing tables to break.-    + Allow pipe tables with header but no body (#2017).-    + Allow a digit as first character of a citation key (Matthias Troffaes).-      See https://github.com/jgm/pandoc-citeproc/issues/97--  * LaTeX reader:--    + Don't limit includes to `.tex` extension (#1882).-      If the extension is not `.tex`, it must be given explicitly in-      the `\input` or `\include`.--  * Docx reader:--    + Allow numbering in the style file.  This allows inherited styles-      with numbering (lists) (Jesse Rosenthal).--  * Org reader:--    + Support smart punctuation (Craig Bosma).-    + Drop trees with a :noexport: tag (Albert Krewinkel). Trees having a-      `:noexport:` tag set are not exported.  This mirrors org-mode.-    + Put header tags into empty spans (Albert Krewinkel, #2160).-      Org mode allows headers to be tagged: `* Headline  :TAG1:TAG2`.-      Instead of being interpreted as part of the headline, the tags are now-      put into the attributes of empty spans.  Spans without textual content-      won't be visible by default, but they are detectable by filters.  They-      can also be styled using CSS when written as HTML.-    + Generalize code block result parsing (Albert Krewinkel).-      Previously, only code blocks were recognized as result blocks;-      now, any kind of block can be the result.--  * Append newline to the LineBreak in Dokuwiki, HTML, EPUB,-    LaTeX, MediaWiki, OpenDocument, Texinfo writers (#1924, Tim Lin).--  * HTML writer:--    + Add "inline" or "display" class to math spans (#1914).-      This allows inline and display math to be styled differently.-    + Include raw latex blocks if `--mathjax` specified (#1938).-    + Require highlighting-kate >= 0.5.14 (#1903).-      This ensures that all code blocks will be wrapped in a `div`-      with class `sourceCode`.  Also, the default highlighting CSS-      now adds `div.sourceCode { x-overflow: auto; }`, which means-      that code blocks (even with line numbers) will acquire a scroll-      bar on screens too small to display them (e.g. mobile phones).-      See also jgm/highlighting-kate#65.--  * LaTeX writer:--    + Use a declaration for tight lists (Jose Luis Duran, Joseph-      Harriott). Previously, pandoc hard-coded some commands to make-      tight lists in LaTeX.  Now we use a custom command instead,-      allowing the styling to be changed in a macro in the header.-      (Note:  existing templates may need to be modified to include-      the definition of this macro.  See the current template.)-    + Beamer output: if the header introducing a slide has the-      class `fragile`, add the `[fragile]` option to the slide (#2119).--  * MediaWiki writer:--    + Use `File:` instead of the deprecated `Image:` for images and-      other media files (Greg Rundlett).--  * DocBook writer:--    + Render a `Div (id,_,_) [Para _]` element as a `para` element-      with an `id` attribute.  This makes links to citations work in-      DocBook with pandoc-citeproc.--  * RST writer:--    + Normalize headings to sequential levels (Nikolay Yakimov).-      This is pretty much required by docutils.-    + Treat headings in block quotes, etc as rubrics (Nikolay Yakimov).-    + Better handling of raw latex inline (#1961).  We use-      `` :raw-latex:`...` `` and add a definition for this role to-      the template.--  * EPUB writer:--    + Remove `linear=no` from cover `itemref` (#1609).-    + Don't use `sup` element for epub footnotes (#1995).-      Instead, just use an a element with class `footnoteRef`.-      This allows more styling options, and provides better results-      in some readers (e.g. iBooks, where anything inside the a-      tag breaks popup footnotes).-    + Take TOC title from `toc-title` metadata field.--  * Docx writer:--    + Implemented `FirstParagraph` style (Jesse Rosenthal).-      Following the ODT writer, we add the `FirstParagraph` style to the-      first text paragraph following an image, blockquote, table, heading,-      or beginning of document.  This allows it to be styled differently.-      The default is for it to be the same as `Normal`.-    + Added `BodyText` style (Jesse Rosenthal).-      We apply a `BodyText` style to all unstyled paragraphs. This is,-      essentially, the same as `Normal`, except that since not everything-      inherits from `BodyText` (the metadata won't, for example, or-      the headers or footnote numbers), we can change the text in the body-      without having to make exceptions for everything.  If we do want to-      change *everything*, we can still do it through `Normal`.-    + Altered `Blockquote` style slightly (Jesse Rosenthal).-      Since `BlockQuote` derives from `BodyText`, we just want to specify-      by default that it won't indent, regardless of what `BodyText` does.-      Note that this will not produce any visible difference in the default-      configuration.-    + Take TOC title from `toc-title` metadata field (Nikolay Yakimov).-    + Added a style to figure images (Nikolay Yakimov).-      Figures with empty captions use style `Figure`.-      Figures with nonempty captions use style `Figure with Caption`, which-      is based on `Figure`, and additionally has `keepNext` set.--  * ODT writer:--    + Added figure captions (Nikolay Yakimov). The following styles are-      used for figures:-      `Figure` -- for figure with empty caption),-      `FigureWithCaption` (based on `Figure`) -- for figure with caption,-      `FigureCaption` (based on `Caption`) -- for figure captions.-      Also, `TableCaption` (based on `Caption`) is used for table captions.--  [API changes]--  * New `Text.Pandoc.Error` module with `PandocError` type-    (Matthew Pickering).--  * All readers now return `Either PandocError Pandoc` instead of `Pandoc`-    (Matthew Pickering).  This allows better handling of errors.--  * Added `Text.Pandoc.Writers.CommonMark`, exporting `writeCommonMark`.--  * Added `Text.Pandoc.Readers.CommonMark`, exporting `readCommonMark`.--  * Derive `Data` and `Typeable` instances for `MediaBag`, `Extension`,-    `ReaderOptions`, `EPUBVersion`, `CiteMethod`, `ObfuscationMethod`,-    `HTMLSlideVariant`, `TrackChanges`, `WriterOptions` (Shabbaz-    Youssefi).--  * New `Ext_shortcut_reference_links` constructor for `Extension`-    (Konstantin Zudov).--  [bug fixes]--  * Markdown reader:--    + Allow smart `'` after inline math (#1909, Nikolay Yakimov).-    + Check for tex macros after indented code (#1973).-    + Rewrote `charsInBalancedBrackets` for efficiency.-    + Make sure a closing `</div>` doesn't get included in a-      definition list item (#2127).-    + Don't parse bracketed text as citation if it might be a link,-      image, or footnote (Nikolay Yakimov).-    + Require space after key in mmd title block (#2026, Nikolay-      Yakimov).  Require space after key-value delimiter colon in mmd title-      block.-    + Require nonempty value in mmd title block (Nikolay Yakimov).-    + Disable all metadata block extensions when parsing-      metadata field values (#2026, Nikolay Yakimov).  Otherwise we-      could get a mmd title block inside YAML metadata, for example.--  * HTML reader:--    + Improve self-closing tag detection in `htmlInBalanced` (#2146).-    + Handle tables with `<th>` in body rows (#1859, Mauro Bieg).-    + Fixed `htmlTag` (#1820).  If the tag parses as a comment, we check-      to see if the input starts with `<!--`. If not, it's bogus comment-      mode and we fail `htmlTag`.-    + Handle `base` tag; if it has an `href` value, this is added to-      all relative URLs in links and images.--  * DocBook reader:--    + Look inside "info" elements for section titles (#1931).--  * Docx reader:--    + Parse images in deprecated vml format (Jesse Rosenthal).-    + Allow sub/superscript verbatims (Jesse Rosenthal).-      Verbatim usually shuts off all other run styles, but we don't want it-      to shut off sub/superscript.--  * LaTeX reader:--    + Handle `tabular*` environment (#1850).-      Note that the table width is not actually parsed or taken into-      account, but pandoc no longer chokes on it.-    + Ignore options in `\lstinline` rather than raising error (#1997).-    + Add some test cases for simple tables (Mathias Schenner).-    + Handle valign argument in tables (Mathias Schenner) (currently-      we just ignore this).-    + Allow non-empty colsep in tables (Mathias Schenner).-      The `tabular` environment allows non-empty column separators-      with the "@{...}" syntax. Previously, pandoc would fail to-      parse tables if a non-empty colsep was present. With this-      commit, these separators are still ignored, but the table gets-      parsed. A test case is included.-    + Recognize `\newpage` as a block command.-    + Allow block content in \title{} (#2001).-    + Check for block-level newcommand aliases in blockCommand (Nikolay-      Yakimov).-    + Guard against paragraph starting with inline macro (Nikolay Yakimov).-    + Properly gobble spaces after `\\` (#2007).--  * Textile reader:--    +  Handle newlines in table cells, and empty cells (#1919).--  * Org reader:--    + Allow image links with non-image targets (Hans-Peter Deifel).-      This matches behavior of Org-Mode for links like-      `[[http://example.com][https://www.haskell.org/static/img/logo.png]]`.--  * Docbook writer:--    + Don't print empty id attributes (thanks to Steve Horne).--  * HTML writer:--    + Fixed list-style-type for numbered example lists.-      Should be "decimal," not "example" (#1902).-    + Do not omit missing `alt` attribute on `img` tag (#1131,-      Konstantin Zudov).-    + Allow multiple colgroups in table (#2122).-    + In revealjs, ensure that lists in speaker notes don't add "fragment"-      classes, which can cause additional keypresses to be needed to-      advance a slide (#1394).--  * LaTeX writer:--    + Don't escape `$` in URL (#1913).-    + Don't use listings in headers (Matthew Pickering, #1963).-    + Recognize book documentclass if set in metadata (#1971).-      This sets `--chapters` implicitly if the documentclass in metadata-      is a book documentclass.  Previously this was done only if a book-      documentclass was set in a variable.-    + Add a `\label` in `\hyperdef` for Div, Span (or links don't work).-    + Make `mainlang` work when `lang` is in metadata (#2174).--  * Texinfo writer:--    + Fix wrapping by using breakable spaces (Tim Lin).--  * RST writer:--    + Fixed toc depth in RST writer.  Previously the depth was being-      rendered as a floating point number with a decimal point.--  * Markdown writer:--    + Improved escaping (#2086).  `<` should not be escaped as `\<`, for-      compatibility with original Markdown.  We now escape `<` and `>`-      with entities.  Also, we now backslash-escape square brackets.-    + Avoid introducing spurious list items through wrapping (#1946).-    + Don't emit span tags if plain or raw HTML disabled.--  * MediaWiki writer:--    + Convert spaces to underscores in wikilink URL (#1982), like MediaWiki.--  * AsciiDoc writer:--    + Insert some needed blank lines (#1860).-    + Avoid wrapping after list marker (#1858).--  * EPUB writer:--    + Properly handle internal links to IDs in spans, divs (#1884).-    + Use plain writer for metadata dc: fields (#2121).-      This gives better results when we have, e.g. multiple paragraphs.-      Note that tags aren't allowed in these fields.-    + Properly handle image links without an extension (#1855).-    + Improved chapter splitting and internal link rewriting (#1887,-      #2162, #2163).  This will ensure that internal links work and-      that the references section produced by pandoc-citeproc is-      in its own chapter.-    + Fixed handling of svg images (#2183).--  * ICML writer:--    + Better handling of raw blocks and inlines (#1951).-      Previously these were always escaped and printed verbatim.-      Now they are ignored unless the format is `icml`, in which-      case they are passed through unescaped.-    + Fixed image URIs in ICML output (gohai).--  * Custom writer:--    + Raise error if loadstring returns an error status.-    + Raise `PandocLuaException` instead of using 'error'.-      Eventually we'll change the return type so that no exception-      is involved, but at least this can be trapped.-    + Use UTF-8 aware bytestring conversion.-    + Set foreign encoding to UTF-8 (Nikolay Yakimov, #2101, #1634).-      Also factored out ByteString, since it's only used as an intermediate-      representation.--  * Docx writer:--    + Copy hyphenation settings from reference.docx (Nikolay Yakimov).-    + Filter out illegal XML characters (#1992, Matthew Pickering).-    + Added `noProof` to docx syntax highlighting `SourceCode` style.-    + Added footnotes id -1 and 0 (Jesse Rosenthal).-      Word uses, by default, footnotes with id -1 and 0 for separators. If a-      user modifies `reference.docx`, they will end up with a `settings.xml`-      file that references these footnotes, but no such footnotes in the-      document. This will produce a corruption error. Here we add these to the-      document and `settings.xml` file, so future modifications won't break-      the file.-    + Handle lists correctly inside table cells (Jesse Rosenthal).-      Previously we didn't transform lists inside table cells.-    + Set firstRow information in tables (Nikolay Yakimov).-    + Don't replace `SourceCode` style in `reference.docx` if it is defined-      there (Nikolay Yakimov, #1872).  If `--no-highlight` specified, remove-      any `SourceCode` and `*Tok` styles in `reference.docx`.-    + Attempt to match international style names (#1607, Nikolay Yakimov).-    + Set these styles as custom (Nikolay Yakimov): `Author`, `Abstract`,-      `Compact`, `Image Caption`, `Table Caption`, `Definition Term`,-      `Definition`, `First Paragraph`.-    + Rename these styles to correspond with Word `Normal.dotm` (Nikolay-      Yakimov): `Block Quote -> Block Text`, `Link -> Hyperlink`,-      `Footnote Ref -> Footnote Reference`.-    + Added `Caption` style (Nikolay Yakimov).-    + Changed these styles' inheritance (Nikolay Yakimov):-      `Image Caption <- Caption`, `Table Caption <- Caption`.-    + Remove `SourceCode` style from `reference.docx` (#1872).-      This is added automatically by the docx writer.-    + Added toc heading style to `reference.docx` (Nikolay Yakimov).--  * `Text.Pandoc.PDF`--    + Don't suggest "Try xelatex" if xelatex already in use (Mauro Bieg,-      #1832).-    + More comprehensible errors on image conversion (#2067).-      EPS can't be supported without shelling out to something like-      ImageMagick, but at least we can avoid mysterious error messages.--  * `Text.Pandoc.Shared`:--    + Make safeRead safe (#1801, Matthew Pickering).-    + Added `mapLeft`, `hush` (Matthew Pickering).--  * `Text.Pandoc.Pretty`:--    + Remove partial function (Matthew Pickering).--  * `Text.Pandoc.SelfContained`:--    + Add `;charset=utf-8` to script mime type if missing (#1842).-    + Improved building of data URIs (#1940).  Now base64 is used except-      for `text/*` mime types.-    + `cssURLs` no longer tries to fetch fragment URLs (#2121).-    + Properly handle data URIs in css urls (#2129).-      Use a proper CSS parser (adds dependency on `text-css`).--  * `Text.Pandoc.UTF8`:--    + Better handling of bare CRs in input files (#2132).-      Previously we just stripped them out; now we convert-      other line ending styles to LF line endings.--  * `Text.Pandoc.ImageSize`:--    + Fixed some exif header parsing bugs (#1834).-    + Make imageSize return an Either, not a Maybe (#1834).-      Use `runGetOrFail` (with `binary >= 0.7`) to return `Left` on-      parse failure (rather than `error`).-    + Improved warnings when image size can't be determined.-    + Removed error landmines (Matthew Pickering).--  * Added woff2 to MIME types (Alfred Wechselberger).--  * pandoc:  When a binary input format is used, warn that file-    arguments past the first one are being ignored (Matthew Pickering).--  [template changes]--  * LaTeX template:--    + Degrade gracefully if `\paragraph` not defined.-    + Include `grffile` together with `graphicx` (#2074).-      This properly handles filenames containing spaces and dots.-    + Redefine `\paragraph`, `\subparagraph`...  to behave more-      like section headers (#1658).-    + Import hyperref before polyglossia to avoid an error with xelatex,-      "please load package hyperref before bidi package" (Nick Bart).-    + Added `toccolor` variable to control link color in toc (Kaixhin).--  * LaTeX, Beamer templates:--    + Provide `\tightlist`, which is now used by the LaTeX writer.-    + Use polyglossia in beamer (#85).-    + Use `bibliography` instead of `biblio-files`-      (#1661).  Also use `\addbibresource` instead of `\bibliography` for-      biblatex.-    + Added `setotherlanguages` in polyglossia. This uses an `otherlang`-      variable that is derived from a comma-separated list in `lang`;-      the last language is `mainlang` and the others are `otherlang`.--  * EPUB templates:--    + Use `div`, not `p`, for "rights" on title page.-    + Added header-includes, include-before, include-after (#1987).--  * OpenDocument template:--    + Use `text:p` instead of `text:h` for title.-      Using `text:h` causes problems with numbering.  Closes #2059.-      Thanks to @nkalvi for diagnosing this.--  * reveal.js template:--    + Link to non-minified css, js.  The minified versions no longer-      ship with the library.-    + Correctly include style CSS (#1949).-    + New configurable options options: `center`, `maxScale`, `slideNuber`-      (Dmitry Smirnov, pandoc-templates#89).-    + Moved custom CSS after theme.  This allows custom CSS to modify-      themes, instead of being replaced by them.-    + Allow `center` to be set to false.--  [under the hood improvements]--  * Removed pre-built `reference.docx` and `reference.odt` (Nikolay-    Yakimov).  Instead the repository now includes the component text files,-    and the zipped binaries are built from these using a helper-    program, `make-reference-files`.  This should make maintenance of-    these components easier going forward.--  * `Text.Pandoc.Parsing`:--    + Added new `<+?>` combinator (Nikolay Yakimov).-    + Added `stateHeaderKeys` to `ParserState`.--  * `make_deb.sh` fixes:--    + Detect architecture.-    + Add Installed-Size to debian package control file (#1900).-    + Use `fakeroot` to get permissions right.-    + Use `mkdir` and `cp` instead of `install`.-    + Set permissions of directories to 755.-    + Install in `/usr` rather than `/usr/local`.-    + Compress man pages.-    + Combine copyright files for `pandoc`, `pandoc-citeproc`.--  * Added `Text.Pandoc.Compat.Locale` and `old-locale` flag-    to assist with transition to `time` 1.5.--  * Updated CONTRIBUTING.md with information about issue tags (Matthew-    Pickering).--  * Updated travis installs to the new sudo-less syntax (Tim Lin).--  * Updated dependency version bounds.--  * EPUB tests:  don't use `joinPath`, which varies across platforms.-    Instead, use a forward-slash to join paths, regardless of the-    platform. This matches the way `MediaBag` now works.--  * Clarify JSON input and output in usage message (Caleb McDaniel).--  * Improved INSTALL instructions.--  * Always build man pages.  Removed make-pandoc-man-pages flag.--  * Makefile:  removed man target, now that we generate man pages by default.--  * README:--    + Fixed typos (J. Lewis Muir).-    + Added documentation on backtick_code_blocks (#2135, Nikolay Yakimov).-    + Added note on in-field markup in biblio databases (Nick Bart).-    + Fixed misleading example of raw HTML block.-    + Various minor formatting and consistency fixes for the program-      options (Andreas Lööw).-    + Made definition lists for options all "loose" for consistency.-    + Added YAML biblio format to table, and note on `pandoc-citeproc`'s-      `--bib2json` and `--bib2yaml` options (Nick Bart).-    + Removed obsolete reference to `mods2yaml` (Nick Bart).-    + Added section on syntax highlighting.-    + Documented `toccolor` variable.--pandoc (1.13.2.1)--  * Updated to build with ghc 7.10.1.--  * Bumped package upper bounds for filepath, blaze-html,-    blaze-markup.--pandoc (1.13.2)--  * TWiki Reader: add new twiki reader (API change, Alexander Sulfrian).--  * Markdown reader:--    + Better handling of paragraph in div (#1591).-      Previously text that ended a div would be parsed as Plain-      unless there was a blank line before the closing div tag.-    + Don't treat a citation as a reference link label (#1763).-    + Fix autolinks with following punctuation (#1811).-      The price of this is that autolinked bare URIs can no longer-      contain `>` characters, but this is not a big issue.-    + Fix `Ext_lists_without_preceding_blankline` bug (#1636, Artyom).-    + Allow `startnum` to work without `fancy_lists`. Formerly-      `pandoc -f markdown-fancy_lists+startnum` did not work properly.--  * RST reader (all Daniel Bergey):--    + Parse quoted literal blocks (#65).  RST quoted literal blocks are-      the same as indented literal blocks (which pandoc already supports)-      except that the quote character is preserved in each line.-    + Parse RST class directives. The class directive accepts one or more-      class names, and creates a Div value with those classes.  If the-      directive has an indented body, the body is parsed as the children of-      the Div.  If not, the first block following the directive is made a-      child of the Div. This differs from the behavior of rst2xml, which-      does not create a Div element.  Instead, the specified classes are-      applied to each child of the directive.  However, most Pandoc Block-      constructors to not take an Attr argument, so we can't duplicate this-      behavior.-    + Warn about skipped directives.-    + Literal role now produces Code. Code role should have "code" class.-    + Improved support for custom roles--        - Added `sourceCode` to classes for `:code:` role, and anything-          inheriting from it.-        - Add the name of the custom role to classes if the Inline-          constructor supports Attr.-        - If the custom role directive does not specify a parent role,-          inherit from the `:span:` role.--      This differs somewhat from the `rst2xml.py` behavior.  If a custom-      role inherits from another custom role, Pandoc will attach both-      roles' names as classes.  `rst2xml.py` will only use the class of-      the directly invoked role (though in the case of inheriting from a-      `:code:` role with a `:language:` defined, it will also provide the-      inherited language as a class).-    + Warn about ignored fields in role directives.--  * LaTeX reader:--    + Parse label after caption into a span instead of-     inserting an additional paragraph of bracketed text (#1747).-    + Parse math environments as inline when possible (#1821).-    + Better handling of `\noindent` and `\greektext` (#1783).-    + Handle `\texorpdfstring` more gracefully.-    + Handle `\cref` and `\sep` (Wikiwide).-    + Support `\smartcite` and `\Smartcite` from biblatex.--  * HTML reader:--    + Retain display type of MathML output (#1719, Matthew Pickering).-    + Recognise `<br>` tags inside `<pre>` blocks (#1620, Matthew Pickering).-    + Make `embed` tag either block or inline (#1756).--  * DocBook reader:--    + Handle `keycombo`, `keycap` (#1815).-    + Get string content in inner tags for literal elements (#1816).-    + Handle `menuchoice` elements better, with a `>` between (#1817).-    + Include `id` on section headers (#1818).-    + Document/test "type" as implemented (Brian O'Sullivan).-    + Add support for calloutlist and callout (Brian O'Sullivan).-      We treat a calloutlist as a bulleted list. This works well in practice.-    + Add support for `classname` (Bryan O'Sullivan).--  * Docx reader:--    + Fix window path for image lookup (Jesse Rosenthal).-      Don't use os-sensitive "combine", since we always want the paths in our-      zip-archive to use forward-slashes.-    + Single-item headers in ordered lists are headers (Jesse Rosenthal).-      When users number their headers, Word understands that as a single item-      enumerated list. We make the assumption that such a list is, in fact,-      a header.-    + Rewrite rewriteLink to work with new headers (Jesse Rosenthal).-      There could be new top-level headers after making lists, so we have to-      rewrite links after that.-    + Use polyglot header list (Jesse Rosenthal).-      We're just keeping a list of header formats that different languages-      use as their default styles. At the moment, we have English, German,-      Danish, and French. We can continue to add to this.-      This is simpler than parsing the styles file, and perhaps less-      error-prone, since there seems to be some variations, even within a-      language, of how a style file will define headers.-    + Remove header class properly in other langs (Jesse Rosenthal).-      When we encounter one of the polyglot header styles, we want to remove-      that from the par styles after we convert to a header. To do that, we-      have to keep track of the style name, and remove it appropriately.-    + Account for external link URLs with anchors. Previously, if a URL-      had an anchor, the reader would incorrectly identify it as an-      internal link and return only the anchor as URL. (Caleb McDaniel)-    + Fix for Issue #1692 (i18n styles) (Nikolay Yakimov).--  * Org reader:--    + Added state changing blanklines (Jesse Rosenthal).-      This allows us to emphasize at the beginning of a new paragraph (or, in-      general, after blank lines).-    + Fixed bug with bulleted lists:--        - a-        - b-        * c--      was being parsed as a list, even though an unindented `*`-      should make a heading.  See-      <http://orgmode.org/manual/Plain-lists.html#fn-1>.-    + Org reader: absolute, relative paths in link (#1741, Albert-      Krewinkel). The org reader was too restrictive when parsing links;-      some relative links and links to files given as absolute paths-      were not recognized correctly.-    + Org reader:  allow empty links (jgm/gitit#471, Albert Krewinkel).-      This is important for use in gitit, which uses empty links-      for wikilinks.-    + Respect indent when parsing Org bullet lists (#1650, Timothy-      Humphries).  Fixes issue with top-level bullet list parsing.-    + Fix indent issue for definition lists (Timothy Humphries,-      see #1650, #1698, #1680).-    + Parse multi-inline terms correctly in definition list (#1649,-      Matthew Pickering).-    + Fix rules for emphasis recognition (Albert Krewinkel).-      Things like `/hello,/` or `/hi'/` were falsy recognized as emphasised-      strings.  This is wrong, as `,` and `'` are forbidden border chars and-      may not occur on the inner border of emphasized text.-    + Drop COMMENT document trees (Albert Krewinkel).-      Document trees under a header starting with the word `COMMENT` are-      comment trees and should not be exported.  Those trees are dropped-      silently (#1678).-    + Properly handle links to `file:target` (Albert Krewinkel).-      Org links like `[[file:target][title]]` were not handled correctly,-      parsing the link target verbatim.  The org reader is changed such that-      the leading `file:` is dropped from the link target (see #756, #1812).-    + Parse LaTeX-style MathML entities (#1657, Albert Krewinkel).-      Org supports special symbols which can be included using LaTeX syntax,-      but are actually MathML entities.  Examples for this are-      `\nbsp` (non-breaking space), `\Aacute` (the letter A with accent acute)-      or `\copy` (the copyright sign ©)--  * EPUB reader:--    + URI handling improvements. Now we outsource most of the work to-      `fetchItem'`. Also, do not include queries in file extensions (#1671).--  * LaTeX writer:--    + Use `\texorpdfstring` for section captions when needed (Vaclav Zeman).-    + Handle consecutive linebreaks (#1733).-    + Protect graphics in headers (Jesse Rosenthal).-      Graphics in `\section`/`\subsection` etc titles need to be `\protect`ed.-    + Put `~` before header in list item text (Jesse Rosenthal).-      Because of the built-in line skip, LaTeX can't handle a section header-      as the first element in a list item.-    + Avoid using reserved characters as `\lstinline` delimiters (#1595).-    + Better handling of display math in simple tables (#1754).-      We convert display math to inline math in simple tables,-      since LaTeX can't deal with display math in simple tables.-    + Escape spaces in code (#1694, Bjorn Buckwalter).--  * MediaWiki writer:--    + Fixed links with URL = text. Previously these were rendered as bare-      words, even if the URL was not an absolute URL (#1825).--  * ICML writer:--    + Don't force all citations into footnotes.--  * RTF writer:--    + Add blankline at end of output (#1732, Matthew Pickering).--  * RST writer:--    + Ensure blank line after figure.-    + Avoid exces whitespace after last list item (#1777).-    + Wrap line blocks with spaces before continuations (#1656).-    + Fixed double-rendering of footnotes in RST tables (#1769).--  * DokuWiki writer:--    + Better handling of block quotes. This change ensures that-      multiple paragraph blockquotes are rendered using native `>`-      rather than as HTML (#1738).-    + Fix external images (#1739). Preface relative links with ":",-      absolute URIs without. (Timothy Humphries)--  * HTML writer:--    + Use protocol-relative URL for mathjax.-    + Put newline btw img and caption paragraph.-    + MathML now outputted with tex annotation (#1635, Matthew Pickering).-    + Add support for KaTeX HTML math (#1626, Matthew Pickering).-      This adds `KaTeX` to `HTMLMathMethod` (API change).-    + Don't double render when `email-obfuscation=none` (#1625, Matthew-      Pickering).-    + Make header attributes work outside top level (#1711).-      Previously they only appeared on top level header elements.-      Now they work e.g. in blockquotes.--  * ODT writer:--    + Correctly handle images without extensions (#1729).-    + Strip querystring in ODT write (#1682, Todd Sifleet).--  * FB2 writer:--    + Add newline to output.--  * EPUB writer:--    + Don't add `sourceURL` to absolute URIs (#1669).-    + Don't use unsupported `opf:title-type` for epub2.-    + Include "landmarks" section in nav document for epub3 (#1757).-    + Removed playOrder from navpoint elements in ncx file (#1760).-      These aren't required, and they make manual modification of epubs-      difficult.-    + Extract title even from structured title.-    + Don't include nav node in spine unless `--toc` was requested.-      Previously we included it in the spine with `linear="no"`, leading-      to odd results in some readers (#1593).-    + Fixed absolute URI detection (#1672).-    + Correctly resolve relative URIs (#1671).-    + Use regular page template for `nav.xhtml`, including doctype (#1759).--  * Docx writer:--    + Put docx table captions above tables (#1641, Nikolay Yakimov).-    + Get the page width from the reference docx file, and use-      it to scale images that are too large to fit (Grégory Bataille).-    + Partial fix for #1607 (Nikolay Yakimov). International heading styles-      are inferred based on `<w:name val="heading #">` fallback, if there-      are no en-US "Heading#" styles-    + Look in user data dir for archive `reference.docx`.-    + Renumber header and footer relationships to avoid collisions (Jesse-      Rosenthal). We previously took the old relationship names of the-      headers and footer in secptr. That led to collisions. We now make-      a map of availabl names in the relationships file, and then rename-     in secptr.--  * ConTeXt writer:--    + Add function toLabel (Mark Szepieniec).-      This function can be used to sanitize reference labels so that-      they do not contain any of the illegal characters \#[]",{}%()|= .-      Currently only Links have their labels sanitized, because they-      are the only Elements that use passed labels.--  * `Text.Pandoc.Shared`:--    + Moved import of `toChunks` outside of CPP conditional (#1590).-    + Fix `inDirectory` to reset to the original directory in case-      an exception occurs (Freiric Barral).--  * Templates:--    + LaTeX template: load polyglossia before bibtex (jgm/pandoc-templates#70).-      Thanks to bluebirch.-    + LaTeX template: Added `\VerbatimFootnotes` if there is verbatim in notes-      (#1616).-    + LaTeX template:  Add shorthands=off to babel options (#1648).-    + EPUB, EPUB3 templates: Added `id="cover"` to body of cover page.-      This aids styling, making it possible for example to set 0 margins-      on the title page (#1758).-    + EPUB, EPUB3 templates:  Handle structured metadata on titlepage.-      Previously we just expected 'title', 'subtitle', 'author', 'date'.-      Now we still support those, but also support the format recommended-      for epub metadata in the pandoc README:--            ----            title:-            - type: main-              text: My Book-            - type: subtitle-              text: An investigation of metadata-            creator:-            - role: author-              text: John Smith-            - role: editor-              text: Sarah Jones-            identifier:-            - scheme: DOI-              text: doi:10.234234.234/33-            publisher:  My Press-            rights:  (c) 2007 John Smith, CC BY-NC-            ...--  * `Text.Pandoc.Templates.getDefaultTemplate`:-    don't fail when called with "fb2" (#1660).--  * `Text.Pandoc.Parsing`:--    + Fixed `inlineMath` so it handles `\text{..}` containing `$`.-      For example: `$x = \text{the $n$th root of $y$}` (#1677).-    + Change `parseFromString` to fail if not all input is consumed.-      (Matthew Pickering)-    + Moved `addWarning` from Markdown reader to `Parsing`, so it can be-      used by more readers (API change, Daniel Bergey).--  * `Text.Pandoc.Pretty`:--    +  Improve performance of `realLength` (Matthew Pickering).-    +  Make CR + BLANKLINE = BLANKLINE. This fixes an extra blank line we-       were getting at the end of markdown fragments (as well as rst, org,-       etc.) (#1705).--  * `Text.Pandoc.MIME`:--    + Add mime type for WebVTT (Jason Ronallo).-    + Changed mime type for `otf` to `application/vnd.ms-opentype` (#1761).-      This is needed for epub3 validation.--  * `Text.Pandoc.MediaBag`:--    + Fix Windows specific path problems (#1597).--  * `Text.Pandoc.Shared`:--    + Make `collapseFilePath` OS-agnostic (Matthew Pickering).--  * Link the test suite using `-threaded`.-    This allows the test suite to be run using `+RTS -N`.--  * Added `network` dependency under `network-uri` flag in test section.--  * Give better error messages when someone tries to convert from-    pdf, doc, odt (#1683).--  * Added `track` to list of tags treated by `--self-contained` (#1664).--pandoc (1.13.1)--  * Fixed `--self-contained` with Windows paths (#1558).-    Previously `C:\foo.js` was being wrongly interpreted as a URI.--  * HTML reader:  improved handling of tags that can be block or inline.-    Previously a section like this would be enclosed in a paragraph,-    with RawInline for the video tags (since video is a tag that can-    be either block or inline):--        <video controls="controls">-           <source src="../videos/test.mp4" type="video/mp4" />-           <source src="../videos/test.webm" type="video/webm" />-           <p>-              The videos can not be played back on your system.<br/>-              Try viewing on Youtube (requires Internet connection):-              <a href="http://youtu.be/etE5urBps_w">Relative Velocity on-        Youtube</a>.-           </p>-        </video>--    This change will cause the video and source tags to be parsed-    as RawBlock instead, giving better output.-    The general change is this:  when we're parsing a "plain" sequence-    of inlines, we don't parse anything that COULD be a block-level tag.--  * Docx reader:--    + Be sensitive to user styles.  Note that "Hyperlink" is-      "blacklisted," as we don't want the default underline styling to be-      inherited by all links by default (Jesse Rosenthal).-    + Read single paragraph in table cell as `Plain` (Jesse Rosenthal).-      This makes to docx reader's native output fit with the way the markdown-      reader understands its markdown output.--  * Textile writer:  Extended the range of cases where native textile-    tables will be used (as opposed to raw HTML):  we now handle any-    alignment type, but only for simple tables with no captions.--  * Txt2Tags reader:--    + Header is now parsed only if standalone flag is set (Matthew Pickering).-    + The header is now parsed as meta information. The first line is the-      `title`, the second is the `author` and third line is the `date`-      (Matthew Pickering).-    + Corrected formatting of `%%mtime` macro (Matthew Pickering).-    + Fixed crash when reading from stdin.--  * EPUB writer:  Don't use page-progression-direction in EPUB2, which-    doesn't support it.  Also, if page-progression-direction not specified-    in metadata, don't include the attribute even in EPUB3; not including it-    is the same as including it with the value "default", as we did before.-    (#1550)--  * Org writer: Accept example lines with indentation at the beginning-    (Calvin Beck).--  * DokuWiki writer:--    + Refactor to use Reader monad (Matthew Pickering).-    + Avoid using raw HTML in table cells; instead, use `\\`-      instead of newlines (Jesse Rosenthal).-    + Properly handle HTML table cell alignments, and use spacing-      to make the tables look prettier (#1566).--  * Docx writer:--    + Bibliography entries get `Bibliography` style (#1559).-    + Implement change tracking (Jesse Rosenthal).--  * LaTeX writer:--    + Fixed a bug that caused a table caption to repeat across all pages-      (Jose Luis Duran).-    + Improved vertical spacing in tables and made it customizable using-      standard lengths set by booktab.  See-      <https://groups.google.com/forum/#!msg/pandoc-discuss/qMu6_5lYy0o/ZAU7lzAIKw0J>-      (Jose Luis Duran).-    + Added `\strut` to fix spacing in multiline tables (Jose Luis Duran).-    + Use `\tabularnewline` instead of `\\` in table cells (Jose Luis Duran).-    + Made horizontal rules more flexible (Jose Luis Duran).--  * Text.Pandoc.MIME:--    + Added `MimeType` (type synonym for `String`) and `getMimeTypeDef`.-      Code cleanups (Artyom Kazak).--  * Templates:--    + LaTeX template: disable microtype protrusion for typewriter font (#1549,-      thanks lemzwerg).--  * Improved OSX build procedure.--  * Added `network-uri` flag, to deal with split of `network-uri` from-    `network`.--  * Fix build dependencies for the `trypandoc` flag, so that they are-    ignored if `trypandoc` flag is set to False (Gabor Pali).--  * Updated README to remove outdated claim that `--self-contained`-    looks in the user data directory for missing files.--pandoc (1.13.0.1)--  * Docx writer:--    + Fixed regression which bungled list numbering (#1544), causing-      all lists to appear as basic ordered lists.-    + Include row width in table rows (Christoffer Ackelman, Viktor Kronvall).-      Added a property to all table rows where the sum of column widths-      is specified in pct (fraction of 5000).  This helps persuade Word-      to lay out the table with the widths we specify.--  * Fixed a bug in Windows 8 which caused pandoc not to find the-    `pandoc-citeproc` filter (#1542).--  * Docx reader: miscellaneous under-the-hood improvements (Jesse Rosenthal).-    Most significantly, the reader now uses Builder, leading to some-    performance improvements.--  * HTML reader:  Parse appropriately styled span as SmallCaps.--  * Markdown writer: don't escape `$`, `^`, `~` when `tex_math_dollars`,-    `superscript`, and `subscript` extensions, respectively, are-    deactivated (#1127).--  * Added `trypandoc` flag to build CGI executable used in the online-    demo.--  * Makefile:  Added 'quick', 'osxpkg' targets.--  * Updated README in templates to indicate templates license.-    The templates are dual-licensed, BSD3 and GPL2+.--pandoc (1.13)--  [new features]--  * Added `docx` as an input format (Jesse Rosenthal).  The docx-    reader includes conversion of native Word equations to pandoc-    LaTeX `Math` elements.  Metadata is taken from paragraphs at the-    beginning of the document with styles `Author`, `Title`, `Subtitle`,-    `Date`, and `Abstract`.--  * Added `epub` as an input format (Matthew Pickering).  The epub-    reader includes conversion of MathML to pandoc LaTeX `Math`-    elements.--  * Added `t2t` (Txt2Tags) as an input format (Matthew Pickering).-    Txt2tags is a lightweight markup format described at-    <http://txt2tags.org/>.--  * Added `dokuwiki` as an output format (Clare Macrae).--  * Added `haddock` as an output format.--  * Added `--extract-media` option to extract media contained in a zip-    container (docx or epub) while adjusting image paths to point to the-    extracted images.--  * Added a new markdown extension, `compact_definition_lists`, that-    restores the syntax for definition lists of pandoc 1.12.x, allowing-    tight definition lists with no blank space between items, and-    disallowing lazy wrapping.  (See below under behavior changes.)--  * Added an extension `epub_html_exts` for parsing HTML in EPUBs.--  * Added extensions `native_spans` and `native_divs` to activate-    parsing of material in HTML span or div tags as Pandoc Span-    inlines or Div blocks.--  * `--trace` now works with the Markdown, HTML, Haddock, EPUB,-    Textile, and MediaWiki readers.  This is an option intended-    for debugging parsing problems; ordinary users should not need-    to use it.--  [behavior changes]--  * Changed behavior of the `markdown_attribute` extension, to bring-    it in line with PHP markdown extra and multimarkdown.  Setting-    `markdown="1"` on an outer tag affects all contained tags,-    recursively, until it is reversed with `markdown="0"` (#1378).--  * Revised markdown definition list syntax (#1429).  Both the reader-    and writer are affected.  This change brings pandoc's definition list-    syntax into alignment with that used in PHP markdown extra and-    multimarkdown (with the exception that pandoc is more flexible about-    the definition markers, allowing tildes as well as colons).  Lazily-    wrapped definitions are now allowed.  Blank space is required-    between list items.  The space before a definition is used to determine-    whether it is a paragraph or a "plain" element.  **WARNING: This change-    may break existing documents!**  Either check your documents for-    definition lists without blank space between items, or use-    `markdown+compact_definition_lists` for the old behavior.--  * `.numberLines` now works in fenced code blocks even if no language-    is given (#1287, jgm/highlighting-kate#40).--  * Improvements to `--filter`:--    + Don't search PATH for a filter with an explicit path.-      This fixed a bug wherein `--filter ./caps.py` would run `caps.py` from-      the system path, even if there was a `caps.py` in the working directory.-    + Respect shebang if filter is executable (#1389).-    + Don't print misleading error message.-      Previously pandoc would say that a filter was not found,-      even in a case where the filter had a syntax error.--  * HTML reader:--    + Parse `div` and `span` elements even without `--parse-raw`,-      provided `native_divs` and `native_spans` extensions are set.-      Motivation:  these now generate native pandoc Div and Span-      elements, not raw HTML.-    + Parse EPUB-specific elements if the `epub_html_exts`-      extension is enabled.  These include `switch`, `footnote`,-      `rearnote`, `noteref`.--  * Org reader:--    + Support for inline LaTeX.  Inline LaTeX is now accepted and parsed by the-      org-mode reader.  Both math symbols (like `\tau`) and LaTeX commands (like-      `\cite{Coffee}`), can be used without any further escaping (Albert-      Krewinkel).--  * Textile reader and writer:--    + The `raw_tex` extension is no longer set by default.  You can-      enable it with `textile+raw_tex`.--  * DocBook reader:--    + Support `equation`, `informalequation`, `inlineequation` elements with-      `mml:math` content.  This is converted into LaTeX and put into a Pandoc-      Math inline.--  * Revised `plain` output, largely following the style of Project-    Gutenberg:--    + Emphasis is rendered with `_underscores_`, strong emphasis-      with ALL CAPS.-    + Headings are rendered differently, with space to set them off,-      not with setext style underlines. Level 1 headers are ALL CAPS.-    + Math is rendered using unicode when possible, but without the-      distracting emphasis markers around variables.-    + Footnotes use a regular `[n]` style.--  * Markdown writer:--    + Horizontal rules are now a line across the whole page.-    + Prettier pipe tables.  Columns are now aligned  (#1323).-    + Respect the `raw_html` extension.  `pandoc -t markdown-raw_html`-      no longer emits any raw HTML, including span and div tags-      generated by Span and Div elements.-    + Use span with style for `SmallCaps` (#1360).--  * HTML writer:--    + Autolinks now have class `uri`, and email autolinks have class-      `email`, so they can be styled.--  * Docx writer:--    + Document formatting is carried over from `reference.docx`.-      This includes margins, page size, page orientation, header,-      and footer, including images in headers and footers.-    + Include abstract (if present) with `Abstract` style (#1451).-    + Include subtitle (if present) with `Subtitle` style, rather-      than tacking it on to the title (#1451).--  * Org writer:--    + Write empty span elements with an id attribute as org anchors.-      For example `Span ("uid",[],[]) []` becomes `<<uid>>`.--  * LaTeX writer:--    + Put table captions above tables, to match the conventional-      standard.  (Previously they appeared below tables.)-    + Use `\(..\)` instead of `$..$` for inline math (#1464).-    + Use `\nolinkurl` in email autolinks.  This allows them to be styled-      using `\urlstyle{tt}`.  Thanks to Ulrike Fischer for the solution.-    + Use `\textquotesingle` for `'` in inline code.  Otherwise we get-      curly quotes in the PDF output (#1364).-    + Use `\footnote<.>{..}` for notes in beamer, so that footnotes-      do not appear before the overlays in which their markers appear-      (#1525).-    + Don't produce a `\label{..}` for a Div or Span element.  Do produce-      a `\hyperdef{..}` (#1519).--  * EPUB writer:--    + If the metadata includes `page-progression-direction` (which can be-      `ltr` or `rtl`, the `page-progression-direction` attribute will-      be set in the EPUB spine (#1455).--  * Custom lua writers:--    + Custom writers now work with `--template`.-    + Removed HTML header scaffolding from `sample.lua`.-    + Made citation information available in lua writers.--  * `--normalize` and `Text.Pandoc.Shared.normalize` now consolidate-    adjacent `RawBlock`s when possible.--  [API changes]--  * Added `Text.Pandoc.Readers.Docx`, exporting `readDocx` (Jesse Rosenthal).--  * Added `Text.Pandoc.Readers.EPUB`, exporting `readEPUB` (Matthew-    Pickering).--  * Added `Text.Pandoc.Readers.Txt2Tags`, exporting `readTxt2Tags` (Matthew-    Pickering).--  * Added `Text.Pandoc.Writers.DokuWiki`, exporting `writeDokuWiki`-    (Clare Macrae).--  * Added `Text.Pandoc.Writers.Haddock`, exporting `writeHaddock`.--  * Added `Text.Pandoc.MediaBag`, exporting `MediaBag`, `lookupMedia`,-    `insertMedia`, `mediaDirectory`, `extractMediaBag`.  The docx and epub-    readers return a pair of a `Pandoc` document and a `MediaBag` with-    the media resources they contain.  This can be extracted using-    `--extract-media`.  Writers that incorporate media (PDF, Docx,-    ODT, EPUB, RTF, or HTML formats with `--self-contained`) will look-    for resources in the `MediaBag` generated by the reader, in addition to-    the file system or web.--  * `Text.Pandoc.Readers.TexMath`: Removed deprecated `readTeXMath`.-    Renamed `readTeXMath'` to `texMathToInlines`.--  * `Text.Pandoc`: Added `Reader` data type (Matthew Pickering).-    `readers` now associates names of readers with `Reader`-     structures.  This allows inclusion of readers, like the docx-     reader, that take binary rather than textual input.--  * `Text.Pandoc.Shared`:--    + Added `capitalize` (Artyom Kazak), and replaced uses of-      `map toUpper` (which give bad results for many languages).-    + Added `collapseFilePath`, which removes intermediate `.` and-      `..` from a path (Matthew Pickering).-    + Added `fetchItem'`, which works like `fetchItem` but searches-      a `MediaBag` before looking on the net or file system.-    + Added `withTempDir`.-    + Added `removeFormatting`.-    + Added `extractSpaces` (from HTML reader) and generalized its type-      so that it can be used by the docx reader (Matthew Pickering).-    + Added `ordNub`.-    + Added `normalizeInlines`, `normalizeBlocks`.-    + `normalize` is now `Pandoc -> Pandoc` instead of-      `Data a :: a -> a`.  Some users may need to change their uses of-      `normalize` to the newly exported `normalizeInlines` or-      `normalizeBlocks`.--  * `Text.Pandoc.Options`:--    + Added `writerMediaBag` to `WriterOptions`.-    + Removed deprecated and no longer used `readerStrict` in-      `ReaderOptions`.  This is handled by `readerExtensions` now.-    + Added `Ext_compact_definition_lists`.-    + Added `Ext_epub_html_exts`.-    + Added `Ext_native_divs` and `Ext_native_spans`.-      This allows users to turn off the default pandoc behavior of-      parsing contents of div and span tags in markdown and HTML-      as native pandoc Div blocks and Span inlines.--  * `Text.Pandoc.Parsing`:--    + Generalized `readWith` to `readWithM` (Matthew Pickering).-    + Export `runParserT` and `Stream` (Matthew Pickering).-    + Added `HasQuoteContext` type class (Matthew Pickering).-    + Generalized types of `mathInline`, `smartPunctuation`, `quoted`,-      `singleQuoted`, `doubleQuoted`, `failIfInQuoteContext`,-      `applyMacros` (Matthew Pickering).-    + Added custom `token` (Matthew Pickering).-    + Added `stateInHtmlBlock` to `ParserState`.  This is used to keep-      track of the ending tag we're waiting for when we're parsing inside-      HTML block tags.-    + Added `stateMarkdownAttribute` to `ParserState`. This is used-      to keep track of whether the markdown attribute has been set in-      an enclosing tag.-    + Generalized type of `registerHeader`, using new type classes-      `HasReaderOptions`, `HasIdentifierList`, `HasHeaderMap` (Matthew-      Pickering).  These allow certain common functions to be reused-      even in parsers that use custom state (instead of `ParserState`),-      such as the MediaWiki reader.-    + Moved `inlineMath`, `displayMath` from Markdown reader to Parsing,-      and generalized their types (Matthew Pickering).--  * `Text.Pandoc.Pretty`:--    + Added `nestle`.-    + Added `blanklines`, which guarantees a certain number of blank lines-      (and no more).--  [bug fixes]--  * Markdown reader:--    + Fixed parsing of indented code in list items.  Indented code-      at the beginning of a list item must be indented eight spaces-      from the margin (or edge of the container), or four spaces-      from the list marker, whichever is greater.-    + Fixed small bug in HTML parsing with `markdown_attribute`, which-      caused incorrect tag nesting for input like-      `<aside markdown="1">*hi*</aside>`.-    + Fixed regression with intraword underscores (#1121).-    + Improved parsing of inline links containing quote characters (#1534).-    + Slight rewrite of `enclosure`/`emphOrStrong` code.-    + Revamped raw HTML block parsing in markdown (#1330).-      We no longer include trailing spaces and newlines in the-      raw blocks.  We look for closing tags for elements (but without-      backtracking).  Each block-level tag is its own `RawBlock`;-      we no longer try to consolidate them (though `--normalize` will do so).-    + Combine consecutive latex environments.  This helps when you have-      two minipages which can't have blank lines between them (#690, #1196).-    + Support smallcaps through span.-      `<span style="font-variant:small-caps;">foo</span>` will be-      parsed as a `SmallCaps` inline, and will work in all output-      formats that support small caps (#1360).-    + Prevent spurious line breaks after list items (#1137).  When the-      `hard_line_breaks` option was specified, pandoc would formerly-      produce a spurious line break after a tight list item.-    + Fixed table parsing bug (#1333).-    + Handle `c++` and `objective-c` as language identifiers in-      github-style fenced blocks (#1318).-    + Inline math must have nonspace before final `$` (#1313).--  * LaTeX reader:--    + Handle comments at the end of tables.  This resolves the issue-      illustrated in <http://stackoverflow.com/questions/24009489>.-    + Correctly handle table rows with too few cells.  LaTeX seems to-      treat them as if they have empty cells at the end  (#241).-    + Handle leading/trailing spaces in `\emph` better.-      `\emph{ hi }` gets parsed as `[Space, Emph [Str "hi"], Space]`-      so that we don't get things like `* hi *` in markdown output.-      Also applies to `\textbf` and some other constructions (#1146).-    + Don't assume preamble doesn't contain environments (#1338).-    + Allow (and discard) optional argument for `\caption` (James Aspnes).--  * HTML reader:--    + Fixed major parsing problem with HTML tables.  Table cells were-      being combined into one cell (#1341).-    + Fixed performance issue with malformed HTML tables.-      We let a `</table>` tag close an open `<tr>` or `<td>` (#1167).-    + Allow space between `<col>` and `</col>`.-    + Added `audio` and `source` in `eitherBlockOrInline`.-    + Moved `video`, `svg`, `progress`, `script`, `noscript`, `svg` from-      `blockTags` to `eitherBlockOrInline`.-    + `map` and `object` were mistakenly in both lists; they have been removed-      from `blockTags`.-    + Ignore `DOCTYPE` and `xml` declarations.--  * MediaWiki reader:--    + Don't parse backslash escapes inside `<source>` (#1445).-    + Tightened up template parsing.-      The opening `{{` must be followed by an alphanumeric or `:`.-      This prevents the exponential slowdown in #1033.-    + Support "Bild" for images.--  * DocBook reader:--    + Better handle elements inside code environments.  Pandoc's document-      model does not allow structure inside code blocks, but at least this way-      we preserve the text (#1449).-    + Support `<?asciidoc-br?>` (#1236).--  * Textile reader:--    + Fixed list parsing. Lists can now start without an intervening-      blank line (#1513).-    + HTML block-level tags that do not start a line are parsed as-      inline HTML and do not interrupt paragraphs (as in RedCloth).--  * Org reader:--    + Make tildes create inline code (#1345).  Also relabeled `code` and-      `verbatim` parsers to accord with the org-mode manual.-    + Respect `:exports` header argument in code blocks (Craig Bosma).-    + Fixed tight lists with sublists (#1437).--  * EPUB writer:--    + Avoid excess whitespace in `nav.xhtml`.  This should improve-      TOC view in iBooks (#1392).-    + Fixed regression on cover image.-      In 1.12.4 and 1.12.4.2, the cover image would not appear properly,-      because the metadata id was not correct.  Now we derive the id from the-      actual cover image filename, which we preserve rather than using-      "cover-image."-    + Keep newlines between block elements.  This allows-      easier diff-ability (#1424).-    + Use `stringify` instead of custom `plainify`.-    + Use `renderTags'` for all tag rendering.  This properly handles tags-      that should be self-closing.  Previously `<hr/>` would appear in EPUB-      output as `<hr></hr>` (#1420).-    + Better handle HTML media tags.-    + Handle multiple dates with OPF `event` attributes.  Note: in EPUB3 we-      can have only one dc:date, so only the first one is used.--  * LaTeX writer:--    + Correctly handle figures in notes.  Notes can't contain figures in-      LaTeX, so we fake it to avoid an error  (#1053).-    + Fixed strikeout + highlighted code (#1294).-      Previously strikeout highlighted code caused an error.--  * ConTeXt writer:--    + Improved detection of autolinks with URLs containing escapes.--  * RTF writer:--    + Improved image embedding: `fetchItem'` is now used to get the-      images, and calculated image sizes are indicated in the RTF.-    + Avoid extra paragraph tags in metadata (#1421).--  * HTML writer:--    + Deactivate "incremental" inside slide speaker notes (#1394).-    + Don't include empty items in the table of contents for-      slide shows.  (These would result from creating a slide-      using a horizontal rule.)--  * MediaWiki writer:--    + Minor renaming of `st` prefixed names.--  * AsciiDoc writer:--    + Double up emphasis and strong emphasis markers in intraword-      contexts, as required by asciidoc (#1441).--  * Markdown writer:--    + Avoid wrapping that might start a list, blockquote, or header (#1013).-    + Use Span instead of (hackish) `SmallCaps` in `plainify`.-    + Don't use braced attributes for fenced code (#1416).-      If `Ext_fenced_code_attributes` is not set, the first class-      attribute will be printed after the opening fence as a bare word.-    + Separate adjacent lists of the same kind with an HTML comment (#1458).--  * PDF writer:--    + Fixed treatment of data uris for images (#1062).--  * Docx writer:--    + Use Compact style for empty table cells (#1353).-      Otherwise we get overly tall lines when there are empty-      table cells and the other cells are compact.-    + Create overrides per-image for `media/` in reference docx.-      This should be somewhat more robust and cover more types of images.-    + Improved `entryFromArchive` to avoid an unneeded parse.-    + Section numbering carries over from reference.docx (#1305).-    + Simplified `abstractNumId` numbering.  Instead of sequential numbering,-      we assign numbers based on the list marker styles.--  * `Text.Pandoc.Options`:--    + Removed `Ext_fenced_code_attributes` from `markdown_github`-      extensions.--  * `Text.Pandoc.ImageSize`:--    + Use default instead of failing if image size not found-      in exif header (#1358).-    + ignore unknown exif header tag rather than crashing.-      Some images seem to have tag type of 256, which was causing-      a runtime error.--  * `Text.Pandoc.Shared`:--    + `fetchItem`:  unescape URI encoding before reading local file (#1427).-    + `fetchItem`:  strip a fragment like `?#iefix` from the extension before-      doing mime lookup, to improve mime type guessing.-    + Improved logic of `fetchItem`:  absolute URIs are fetched from the net;-      other things are treated as relative URIs if `sourceURL` is `Just _`,-      otherwise as file paths on the local file system.-    + `fetchItem` now properly handles links without a protocol (#1477).-    + `fetchItem` now escapes characters not allowed in URIs before trying-      to parse the URIs.-    + Fixed runtime error with `compactify'DL` on certain lists (#1452).--  * `pandoc.hs`: Don't strip path off of `writerSourceURL`: the path is-    needed to resolve relative URLs when we fetch resources (#750).--  * `Text.Pandoc.Parsing`--    + Simplified `dash` and `ellipsis` (#1419).-    + Removed `(>>~)` in favor of the equivalent `(<*)` (Matthew Pickering).-    + Generalized functions to use `ParsecT` (Matthew Pickering).-    + Added `isbn` and `pmid` to list of recognized schemes (Matthew-      Pickering).--  [template changes]--  * Added haddock template.-  * EPUB3:  Added `type` attribute to `link` tags.  They are supposed to-    be "advisory" in HTML5, but kindlegen seems to require them.-  * EPUB3:  Put title page in section with `epub:type="titlepage"`.-  * LaTeX: Made `\subtitle` work properly (#1327).-  * LaTeX/Beamer: remove conditional around date (#1321).-  * LaTeX:  Added `lot` and `lof` variables, which can be set to-    get `\listoftables` and `\listoffigures` (#1407).  Note that-    these variables can be set at the command line with `-Vlot -Vlof`-    or in YAML metadata.--  [under the hood improvements]--  * Rewrote normalize for efficiency (#1385).--  * Rewrote Haddock reader to use `haddock-library` (#1346).--    + This brings pandoc's rendering of haddock markup in line-      with the new haddock.-    + Fixed line breaks in `@` code blocks.-    + alex and happy are no longer build-depends.--  * Added `Text.Pandoc.Compat.Directory` to allow building against-    different versions of the `directory` library.--  + Added `Text.Pandoc.Compat.Except` to allow building against-    different versions of `mtl`.--  * Code cleanup in some writers, using Reader monad to avoid-    passing options parameter around (Matej Kollar).--  * Improved readability in `pandoc.hs`.--  * Miscellaneous code cleanups (Artyom Kazak).--  * Avoid `import Prelude hiding (catch)` (#1309, thanks to Michael-    Thompson).--  * Changed `http-conduit` flag to `https`.  Depend on `http-client`-    and `http-client-tls` instead of `http-conduit`.  (Note:  pandoc still-    depends on `conduit` via `yaml`.)--  * Require `highlighting-kate >= 0.5.8.5` (#1271, #1317, Debian #753299).-    This change to highlighting-kate means that PHP fragments no longer need-    to start with `<?php`.  It also fixes a serious bug causing failures with-    ocaml and fsharp.--  * Require latest `texmath`.  This fixes `\tilde{E}` and allows-    `\left` to be used with `]`, `)` etc. (#1319), among many other-    improvements.--  * Require latest `zip-archive`.  This has fixes for unicode path names.--  * Added tests for plain writer.--  * `Text.Pandoc.Templates`:--    + Fail informatively on template syntax errors.-      With the move from parsec to attoparsec, we lost good error-      reporting.  In fact, since we weren't testing for end of input,-      malformed templates would fail silently.  Here we revert back to-      Parsec for better error messages.-    + Use `ordNub` (#1022).--  * Benchmarks:--    + Made benchmarks compile again (Artyom Kazak).-    + Fixed so that the failure of one benchmark does not prevent others-      from running (Artyom Kazak).-    + Use `nfIO` instead of the `getLength` trick to force full evaluation.-    + Changed benchmark to use only the test suite, so that benchmarks-      run more quickly.--  * Windows build script:--    + Add `-windows` to file name.-    + Use one install command for pandoc, pandoc-citeproc.-    + Force install of pandoc-citeproc.--  * `make_osx_package`:  Call zip file `pandoc-VERSION-osx.zip`.-    The zip should not be named `SOMETHING.pkg.zip`, or OSX finder-    will extract it into a folder named `SOMETHING.pkg`, which it-    will interpret as a defective package (#1308).--  * `README`:--    + Made headers for all extensions so they have IDs and can be-      linked to (Beni Cherniavsky-Paskin).-    + Fixed typos (Phillip Alday).-    + Fixed documentation of attributes (#1315).-    + Clarified documentation on small caps (#1360).-    + Better documentation for `fenced_code_attributes` extension-      (Caleb McDaniel).-    + Documented fact that you can put YAML metadata in a separate file-      (#1412).---pandoc (1.12.4.2)--  * Require highlighting-kate >= 0.5.8.  Fixes a performance regression.--  * Shared:  `addMetaValue` now behaves slightly differently:-    if both the new and old values are lists, it concatenates their-    contents to form a new list.--  * LaTeX reader:--    + Set `bibliography` in metadata from `\bibliography` or-      `\addbibresource` command.-    + Don't error on `%foo` with no trailing newline.--  * Org reader:--    + Support code block headers (`#+BEGIN_SRC ...`) (Albert Krewinkel).-    + Fix parsing of blank lines within blocks (Albert Krewinkel).-    + Support pandoc citation extension (Albert Krewinkel).  This can-      be turned off by specifying `org-citations` as the input format.--  * Markdown reader:--    + `citeKey` moved to `Text.Pandoc.Parsing` so it can be used by-      other readers (Albert Krewinkel).--  * `Text.Pandoc.Parsing`:--    + Added `citeKey` (see above).-    + Added `HasLastStrPosition` type class and `updateLastStrPos`-      and `notAfterString` functions.--  * Updated copyright notices (Albert Krewinkel).--  * Added default.icml to data files so it installs with the package.--  * OSX package:--    + The binary is now built with options to ensure that it can be-      used with OSX 10.6+.-    + Moved OSX package materials to osx directory.-    + Added OSX package uninstall script, included in the zip container-      (thanks to Daniel T. Staal).--pandoc (1.12.4)--  * Made it possible to run filters that aren't executable (#1096).-    Pandoc first tries to find the executable (searching the path-    if path isn't given).  If it fails, but the file exists and has-    a `.py`, `.pl`, `.rb`, `.hs`, or `.php` extension, pandoc runs the filter-    using the appropriate interpreter.  This should make it easier to-    use filters on Windows, and make it more convenient for everyone.--  * Added Emacs org-mode reader (Albert Krewinkel).--  * Added InDesign ICML Writer (Mauro Bieg).--  * MediaWiki reader:--    + Accept image links in more languages (Jaime Marquínez Ferrándiz).-    + Fixed bug in certain nested lists (#1213).  If a level 2 list was-      followed by a level 1 list, the first item of the level 1 list-      would be lost.-    + Handle table rows containing just an HTML comment (#1230).--  * LaTeX reader:--    + Give better location information on errors, pointing to line-      numbers within included files (#1274).-    + LaTeX reader:  Better handling of `table` environment (#1204).-      Positioning options no longer rendered verbatim.-    + Better handling of figure and table with caption (#1204).-    + Handle `@{}` and `p{length}` in tabular.  The length is not actually-      recorded, but at least we get a table (#1180).-    + Properly handle `\nocite`.  It now adds a `nocite` metadata-      field.  Citations there will appear in the bibliography but not-      in the text (unless you explicitly put a `$nocite$` variable-      in your template).--  * Markdown reader:--    + Ensure that whole numbers in YAML metadata are rendered without-      decimal points.  (This became necessary with changes to aeson-      and yaml libraries.  aeson >= 0.7 and yaml >= 0.8.8.2 are now required.)-    + Fixed regression on line breaks in strict mode (#1203).-    + Small efficiency improvements.-    + Improved parsing of nested `div`s.  Formerly a closing `div` tag-      would be missed if it came right after other block-level tags.-    + Avoid backtracking when closing `</div>` not found.-    + Fixed bug in reference link parsing in `markdown_mmd`.-    + Fixed a bug in list parsing (#1154).  When reading a raw list-      item, we now strip off up to 4 spaces.-    + Fixed parsing of empty reference link definitions (#1186).-    + Made one-column pipe tables work (#1218).--  * Textile reader:--    + Better support for attributes.  Instead of being ignored, attributes-      are now parsed and included in Span inlines.  The output will be a bit-      different from stock textile: e.g. for `*(foo)hi*`, we'll get-      `<em><span class="foo">hi</span></em>` instead of-      `<em class="foo">hi</em>`.  But at least the data is not lost.-    + Improved treatment of HTML spans (%) (#1115).-    + Improved link parsing.  In particular we now pick up on attributes.-      Since pandoc links can't have attributes, we enclose the whole link in-      a span if there are attributes (#1008).-    + Implemented correct parsing rules for inline markup (#1175, Matthew-      Pickering).-    + Use Builder (Matthew Pickering).-    + Fixed list parsing bug (#1500).-    + Don't allow inline formatting to extend over newlines.-      This matches the behavior of RedCarpet, avoids some ugly bugs,-      and improves performance.--  * DocBook reader:--    + Better treatment of `formalpara`.  We now emit the title (if present)-      as a separate paragraph with boldface text (#1215).-    + Set metadata `author` not `authors`.-    + Added recognition of `authorgroup` and `releaseinfo` elements (#1214,-      Matthew Pickering).-    + Converted current meta information parsing in DocBook to a more-      extensible version which is aware of the more recent meta-      representation (Matthew Pickering).--  * HTML reader:--    + Require tagsoup 0.13.1, to fix a bug with parsing of script tags-      (#1248).-    + Treat processing instructions & declarations as block.  Previously-      these were treated as inline, and included in paragraph tags in HTML-      or DocBook output, which is generally not what is wanted (#1233).-    + Updated `closes` with rules from HTML5 spec.-    + Use Builder (Matthew Pickering, #1162).--  * RST reader:--    + Remove duplicate `http` in PEP links (Albert Krewinkel).-    + Make rst figures true figures (#1168, CasperVector)-    + Enhanced Pandoc's support for rST roles (Merijn Verstaaten).-      rST parser now supports: all built-in rST roles, new role definition,-      role inheritance, though with some limitations.-    + Use `author` rather than `authors` in metadata.-    + Better handling of directives.  We now correctly handle field-      lists that are indented more than three spaces.  We treat an-      `aafig` directive as a code block with attributes, so it can be-      processed in a filter (#1212).--  * LaTeX writer:--    + Mark span contents with label if span has an ID (Albert Krewinkel).-    + Made `--toc-depth` work well with books in latex/pdf output (#1210).-    + Handle line breaks in simple table cells (#1217).-    + Workaround for level 4-5 headers in quotes.  These previously produced-      invalid LaTeX: `\paragraph` or `\subparagraph` in a `quote` environment.-      This adds an `mbox{}` in these contexts to work around the problem.-      See <http://tex.stackexchange.com/a/169833/22451> (#1221).-    + Use `\/` to avoid en-dash ligature instead of `-{}-` (Vaclav Zeman).-      This is to fix LuaLaTeX output. The `-{}-` sequence does not avoid the-      ligature with LuaLaTeX but `\/` does.-    + Fixed string escaping in `hyperref` and `hyperdef` (#1130).--  * ConTeXt writer:  Improved autolinks (#1270).--  * DocBook writer:--    + Improve handling of hard line breaks in Docbook writer-      (Neil Mayhew).  Use a `<literallayout>` for the entire paragraph, not-      just for the newline character.-    + Don't let line breaks inside footnotes influence the enclosing-      paragraph (Neil Mayhew).-    + Distinguish tight and loose lists in DocBook output, using-      `spacing="compact"` (Neil Mayhew, #1250).--  * Docx writer:  When needed files are not present in the user's-    `reference.docx`, fall back on the versions in the `reference.docx`-    in pandoc's data files. This fixes a bug that occurs when a-    `reference.docx` saved by LibreOffice is used. (#1185)--  * EPUB writer:--    + Include extension in epub ids.  This fixes a problem with duplicate-      extensions for fonts and images with the same base name but different-      extensions (#1254).-    + Handle files linked in raw `img` tags (#1170).-    + Handle media in `audio` source tags (#1170).-      Note that we now use a `media` directory rather than `images`.-    + Incorporate files linked in `video` tags (#1170).  `src` and `poster`-      will both be incorporated into `content.opf` and the epub container.--  * HTML writer:--    + Add colgroup around col tags (#877).  Also affects EPUB writer.-    + Fixed bug with unnumbered section headings.  Unnumbered section-      headings (with class `unnumbered`) were getting numbers.-    + Improved detection of image links. Previously image links with-      queries were not recognized, causing `<embed>` to be used instead-      of `<img>`.--  * Man writer:  Ensure that terms in definition lists aren't line wrapped-    (#1195).--  * Markdown writer:--    + Use proper escapes to avoid unwanted lists (#980).  Previously we used-      0-width spaces, an ugly hack.-    + Use longer backtick fences if needed (#1206).  If the content contains a-      backtick fence and there are attributes, make sure longer fences are-      used to delimit the code.  Note:  This works well in pandoc, but github-      markdown is more limited, and will interpret the first string of three-      or more backticks as ending the code block.--  * RST writer:  Avoid stack overflow with certain tables (#1197).--  * RTF writer:  Fixed table cells containing paragraphs.--  * Custom writer:--    + Correctly handle UTF-8 in custom lua scripts (#1189).-    + Fix bugs with lua scripts with mixed-case filenames and-      paths containing `+` or `-` (#1267).  Note that `getWriter`-      in `Text.Pandoc` no longer returns a custom writer on input-      `foo.lua`.--  * AsciiDoc writer:  Handle multiblock and empty table cells-    (#1245, #1246).  Added tests.--  * `Text.Pandoc.Options`: Added `readerTrace` to `ReaderOptions`--  * `Text.Pandoc.Shared`:--    + Added `compactify'DL` (formerly in markdown reader) (Albert Krewinkel).-    + Fixed bug in `toRomanNumeral`:  numbers ending with '9' would-      be rendered as Roman numerals ending with 'IXIV' (#1249).  Thanks to-      Jesse Rosenthal.-    + `openURL`: set proxy with value of http_proxy env variable (#1211).-      Note:  proxies with non-root paths are not supported, due to-      limitations in `http-conduit`.--  * `Text.Pandoc.PDF`:--    + Ensure that temp directories deleted on Windows (#1192).  The PDF is-      now read as a strict bytestring, ensuring that process ownership will-      be terminated, so the temp directory can be deleted.-    + Use `/` as path separators in a few places, even on Windows.-      This seems to be necessary for texlive (#1151, thanks to Tim Lin).-    + Use `;` for `TEXINPUTS` separator on Windows (#1151).-    + Changes to error reporting, to handle non-UTF8 error output.--  * `Text.Pandoc.Templates`:--    + Removed unneeded datatype context (Merijn Verstraaten).--    + YAML objects resolve to "true" in conditionals (#1133).-      Note:  If `address` is a YAML object and you just have `$address$`-      in your template, the word `true` will appear, which may be-      unexpected.  (Previously nothing would appear.)--  * `Text.Pandoc.SelfContained`:--    + `mkSelfContained` now takes just two arguments, `WriterOptions` and-      the string.-    * It no longer looks in data files.  This only made sense when we-      had copies of slidy and S5 code there.-    * `fetchItem'` is used instead of the nearly duplicate `getItem`.-    + Handle `poster` attribute in `video` tags (#1188).--  * `Text.Pandoc.Parsing`:--    + Made `F` an instance of Applicative (#1138).-    + Added `stateCaption`.-    + Added `HasMacros`, simplified other typeclasses.-      Removed `updateHeaderMap`, `setHeaderMap`, `getHeaderMap`,-      `updateIdentifierList`, `setIdentifierList`, `getIdentifierList`.-    + Changed the smart punctuation parser to return `Inlines`-      rather than `Inline` (Matthew Pickering).-    + Changed `HasReaderOptions`, `HasHeaderMap`, `HasIdentifierList`-      from typeclasses of monads to typeclasses of states.  This simplifies-      the instance definitions and provides more flexibility.  Generalized-      type of `getOption` and added a default definition.  Removed-      `askReaderOption`.  Added `extractReaderOption`.  Added-      `extractHeaderMap` and `updateHeaderMap` in `HasHeaderMap`.-      Gave default definitions for `getHeaderMap`, `putHeaderMap`,-      `modifyHeaderMap`.  Added `extractIdentifierList` and-      `updateIdentifierList` in `HasIdentifierList`.  Gave defaults-      for `getIdentifierList`, `putIdentifierList`, and-      `modifyIdentifierList`.  The ultimate goal here is to allow different-      parsers to use their own, tailored parser states (instead of-      `ParserState`) while still using shared functions.--  * Template changes:--    + LaTeX template: Use `fontenc` package only with `pdflatex` (#1164).-    + LaTeX template:  Add `linestretch` and `fontfamily` variables.-    + LaTeX template:  Conditionalize author and date commands.-    + Beamer template: Consistent styles for figure and table captions-      (aaronwolen).-    + LaTeX and beamer template:  Adjust widths correctly for oversized-      images.  Use `\setkeys{Gin}{}` to set appropriate defaults for-      `\includegraphics` (Yihui Xie, Garrick Aden-Buie).  Load-      `upquote` only after `fontenc` (Yihui Xie).-    + Beamer template: Added caption package (#1200).-    + Beamer template:  changes for better unicode handling (KarolS).-    + DocBook template:  use `authorgroup` if there are authors.-    + revealjs template: Move `include-after` to end (certainlyakey).-    + revealjs template: Fixed PDF print function (#1220, kevinkenan).--  * Bumped version bounds of dependencies.--  * Added a `--trace` command line option, for debugging backtracking-    bugs.  So far this only works with the markdown reader.--  * MathMLinHTML:  Fixed deprecation warning (#362, gwern, Albert Krewinkel).--  * Updated travis script to test with multiple GHC versions.--  * Force failure of a Travis build if GHC produces warnings (Albert-    Krewinkel).--  * Add `.editorconfig` (Albert Krewinkel).-    See <http://editorconfig.org/> for details.--  * Give more useful error message if '-t pdf' is specified (#1155).--  * Added `Cite`, `SmallCaps` to `Arbitrary` instance (#1269).--  * Allow `html4` as a synonym of `html` as a reader (it already works-    as a writer).--  * README:--    + Added an explanation of how to use YAML metadata to-      force items to appear in the bibliography without citations in-      the text (like LaTeX `\nocite`).-    + Added note to `--bibtex/--natbib`: not for use in making PDF-      (#1194, thanks to nahoj).-    + Added explanatory notes about `--natbib` and `--biblatex`.-    + Added specification of legal syntax for citation keys.-    + Fixed variable defaults documentation (Albert Krewinkel).--  * Removed copyright statements for files that have been removed-    (Albert Krewinkel).--  * Moved some doc files from `data-files` to `extra-source-files` (#1123).-    They aren't needed at runtime.  We keep README and COPYRIGHT in data-    to ensure that they'll be available on all systems on which pandoc-    is installed.--  * Use cabal sandboxes in Windows build script.--pandoc (1.12.3.3)--  * To changes to source; recompiled tarball with latest alex and-    happy, so they will work with GHC 7.8.--pandoc (1.12.3.2)--  * Bumped version bounds for blaze-html, blaze-markup.--  * ImageSize:  Avoid use of lookAhead, which is not in binary >= 0.6-    (#1124).--  * Fixed mediawiki ordered list parsing (#1122).--  * HTML reader:  Fixed bug reading inline math with `$$` (#225).--  * Added support for LaTeX style literate Haskell code blocks in rST-    (Merijn Verstraaten).--pandoc (1.12.3.1)--  * Relaxed version constraint on binary, allowing the use of binary 0.5.--pandoc (1.12.3)--  * The `--bibliography` option now sets the `biblio-files` variable.-    So, if you're using `--natbib` or `--biblatex`, you can just use-    `--bibliography=foo.bib` instead of `-V bibliofiles=foo`.--  * Don't run pandoc-citeproc filter if `--bibliography` is-    used together with `--natbib` or `--biblatex` (Florian Eitel).--  * Template changes:--    + Updated beamer template to include booktabs.-    + Added `abstract` variable to LaTeX template.-    + Put `header-includes` after `title` in LaTeX template (#908).-    + Allow use of `\includegraphics[size]` in beamer.-      This just required porting a macro definition from the default-      LaTeX template to the default beamer template.--  * `reference.docx`:  Include `FootnoteText` style.-    Otherwise Word ignores the style, even when specified in the `pPr`.-    (#901)--  * `reference.odt`:  Tidied `styles.xml`.--  * Relaxed version bounds for dependencies.--  * Added `withSocketsDo` around http conduit code in `openURL`,-    so it works on Windows (#1080).--  * Added `Cite` function to `sample.lua`.--  * Markdown reader:--    + Fixed regression in title blocks (#1089).-      If author field was empty, date was being ignored.-    + Allow backslash-newline hard line breaks in grid and-      multiline table cells.-    + Citation keys may now start with underscores, and may contain-      underscores adjacent to internal punctuation.--  * LaTeX reader:--    + Add support for `Verb` macro (jrnold) (#1090).-    + Support babel-style quoting: `` "`..."' ``.--  * Properly handle script blocks in strict mode.  (That is,-    `markdown-markdown_in_html_blocks`.) Previously a spurious-    `<p>` tag was being added (#1093).--  * Docbook reader: Avoid failure if `tbody` contains no `tr` or `row`-    elements.--  * LaTeX writer:--    + Factored out function for table cell creation.-    + Better treatment of footnotes in tables.-      Notes now appear in the regular sequence, rather than in the-      table cell.  (This was a regression in 1.10.)--  * HTML reader: Parse name/content pairs from meta tags as metadata.-    Closes #1106.--  * Moved `fixDisplayMath` from Docx writer to `Writer.Shared`.--  * OpenDocument writer:  Fixed `RawInline`, `RawBlock` so they don't escape.--  * ODT writer:  Use mathml for proper rendering of formulas.-    Note:  LibreOffice's support for this seems a bit buggy.  But-    it should be better than what we had before.--  * RST writer: Ensure no blank line after def in definition list (#992).--  * Markdown writer: Don't use tilde code blocks with braced attributes in-    `markdown_github` output.  A consequence of this change is that the-    backtick form will be preferred in general if both are enabled.  That-    is good, as it is much more widespread than the tilde form.  (#1084)--  * Docx writer:  Fixed problem with some modified reference docx files.-    Include `word/_rels/settings.xml.rels` if it exists, as well as other-    `rels` files besides the ones pandoc generates explicitly.--  * HTML writer:--    + With `--toc`, headers no longer link to themselves (#1081).-    + Omit footnotes from TOC entries.  Otherwise we get doubled-      footnotes when headers have notes!--  * EPUB writer:--    + Avoid duplicate notes when headings contain notes.-      This arose because the headings are copied into the metadata-      "title" field, and the note gets rendered twice.  We strip the-      note now before putting the heading in "title".-    + Strip out footnotes from toc entries.-    + Fixed bug with `--epub-stylesheet`.  Now the contents of-      `writerEpubStylesheet` (set by `--epub-stylesheet`)-      should again work, and take precedence over a stylesheet specified-      in the metadata.--  * `Text.Pandoc.MIME`: Added `wmf`, `emf`.--  * `Text.Pandoc.Shared`:  `fetchItem` now handles image URLs beginning-    with `//`.--  * `Text.Pandoc.ImageSize`:  Parse EXIF format JPEGs.  Previously-    we could only get size information for JFIF format, which led-    to squished images in Word documents. Closes #976.--  * Removed old `MarkdownTest_1.0.3` directory (#1104).--pandoc (1.12.2.1)--  * Markdown reader:  Fixed regression in list parser, involving-    continuation lines containing raw HTML (or even verbatim raw HTML).--pandoc (1.12.2)--  * Metadata may now be included in YAML blocks in a markdown document.-    For example,--        ----        title:-        - type: main-          text: My Book-        - type: subtitle-          text: An investigation of metadata-        creator:-        - role: author-          text: John Smith-        - role: editor-          text: Sarah Jones-        identifier:-        - scheme: DOI-          text: doi:10.234234.234/33-        publisher:  My Press-        rights:  (c) 2007 John Smith, CC BY-NC-        cover-image: img/mypic.jpg-        ...--    Metadata may still be provided using `--epub-metadata`; it will-    be merged with the metadata in YAML blocks.--  * EPUB writer:--    + `meta` tags are now used instead of `opf` attributes for EPUB3.-    + Insert "svg" property as needed in opf (EPUB 3).-    + Simplify `imageTypeOf` using `getMimeType`.-    + Add properties attribute to `cover-image` item for EPUB 3.-    + Don't include node for `cover.xhtml` if no cover!-    + Ensure that same identifier is used throughout (#1044).-      If an identifier is given in metadata, we use that; otherwise-      we generate a random uuid.-    + Add cover reference to guide element (EPUB 2) (Shaun Attfield).-      Fixes an issue with Calibre putting the cover at the end of the book-      if the spine has `linear="no"`.  Apparently this is best practice-      for other converters as well:-      <http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.6>.-    + Allow `stylesheet` in metadata.  The value is a path to the stylesheet.-    + Allow partial dates:  `YYYY`, `YYYY-MM`.--  * Markdown writer:  Fix rendering of tight sublists (#1050).-    Previously a spurious blank line was included after a tight sublist.--  * ODT writer:  Add `draw:name` attribute to `draw:frame` elements (#1069).-    This is reported to be necessary to avoid an error from recent-    versions of Libre Office when files contain more than one image-    Thanks to wmanley for reporting and diagnosing the problem.--  * ConTeXt writer:  Don't hardcode figure/table placement and numbering.-    Instead, let this be set in the template, using `\setupfloat`.-    Thanks to on4aa and Aditya Mahajan for the suggestion (#1067).--  * Implemented CSL flipflopping spans in DOCX, LaTeX, and HTML writers.--  * Fixed bug with markdown intraword emphasis.  Closes #1066.--  * Docbook writer:  Hierarchicalize block content in metadata.-    Previously headers just disappeared from block-level metadata-    when it was used in templates.  Now we apply the 'hierarchicalize'-    transformation.  Note that a block headed by a level-2 header will-    turn into a `<sect1>` element.--  * OpenDocument writer:  Skip raw HTML (#1035).-    Previously it was erroneously included as verbatim text.--  * HTML/EPUB writer, footnotes:  Put `<sup>` tag inside `<a>` tags.-    This allows better control of formatting, since the `<a>`-    tags have a distinguishing class (#1049).--  * Docx writer:--    + Use mime type info returned by fetchItem.-    + Fixed core metadata (#1046).-      Don't create empty date nodes if no date given.-      Don't create multiple `dc:creator` nodes; instead separate by-      semicolons.-    + Fix URL for core-properties in `_rels/.rels` (#1046).--  * Plain writer: don't print `<span>` tags.--  * LaTeX writer:--    + Fix definition lists with internal links in terms (#1032).-      This fix puts braces around a term that contains an internal-      link, to avoid problems with square brackets.-    + Properly escape pdftitle, pdfauthor (#1059).-    + Use booktabs package for tables (thanks to Jose Luis Duran).--  * Updated beamer template.  Now references should work properly-    (in a slide) when `--biblatex` or `--natbib` is used.--  * LaTeX reader:--    + Parse contents of curly quotes or matched `"` as quotes.-    + Support `\textnormal` as span with class `nodecor`.-      This is needed for pandoc-citeproc.-    + Improved citation parsing.  This fixes a run-time error that occurred-      with `\citet{}` (empty list of keys).  It also ensures that empty keys-      don't get produced.--  * MediaWiki reader:  Add automatic header identifiers.--  * HTML reader:--    + Use pandoc `Div` and `Span` for raw `<div>`, `<span>` when-      `--parse-raw`.-    + Recognize `svg` tags as block level content (thanks to MinRK).-    + Parse LaTeX math if appropriate options are set.--  * Markdown reader:--    + Yaml block must start immediately after `---`.  If there's a blank-      line after `---`, we interpreted it as a horizontal rule.-    + Correctly handle empty bullet list items.-    + Stop parsing "list lines" when we hit a block tag.-      This fixes exponential slowdown in certain input, e.g.-      a series of lists followed by `</div>`.--  * Slides:  Preserve `<div class="references">` in references slide.--  * `Text.Pandoc.Writer.Shared`:--    + Fixed bug in `tagWithAttrs`.  A space was omitted before key-value-      attributes, leading to invalid HTML.-    + `normalizeDate`: Allow dates with year only (thanks to Shaun Attfield).-    + Fixed bug in `openURL` with `data:` URIs.  Previously the base-64-      encoded bytestring was returned.  We now decode it so it's a proper-      image!--  * DocBook reader:  Handle numerical attributes starting with decimal.-    Also use `safeRead` instead of `read`.--  * `Text.Pandoc.Readers.TexMath`: Export `readTeXMath'`, which attends-    to display/inline.  Deprecate `readTeXMath`, and use `readTeXMath'`-    in all the writers.  Require `texmath >= 0.6.5.2`.--  * `Text.Pandoc.MIME`:--    + Add entry for `jfif`.-    + In looking up extensions, drop the encoding info.-      E.g. for 'image/jpg;base64' we should lookup 'image/jpg'.--  * Templates:  Changed how array variables are resolved.  Previously if-    `foo` is an array (which might be because multiple values were set on-    the command line), `$foo$` would resolve to the concatenation of the-    elements of foo.  This is rarely useful behavior.  It has been changed-    so that the first value is rendered.  Of course, you can still iterate-    over the values using `$for(foo)$`.  This has the result that you can-    override earlier settings using `-V` by putting new values later on the-    command line, which is useful for many purposes.--  * `Text.Pandoc`:  Don't default to `pandocExtensions` for all writers.--  * Allow "epub2" as synonym for "epub", "html4" for "html".--  * Don't look for slidy files in data files with `--self-contained`.--  * Allow `https:` command line arguments to be downloaded.--  * Fixed `make_osx_package.sh` so data files embedded in `pandoc-citeproc`.--pandoc (1.12.1)--  * `Text.Pandoc.Definition`:  Changed default JSON serialization format.-    Instead of `{"Str": "foo"}`, for example, we now have `{"t": "Str",-    "c": "foo"}`.  This new format is easier to work with outside of Haskell.-    Incidentally, "t" stands for "tag", "c" for "contents".--  * MediaWiki reader: Trim contents of `<math>` tags, to avoid problems-    when converting to markdown (#1027).--  * LaTeX reader:--    + Ensure that preamble doesn't contribute to the text of-      the document.-    + Fixed character escaping in \url{}.  Previously `\~` wasn't handled-      properly, among others.-    + Parse `{groups}` as `Span`.  This is needed for accurate conversion of-      bibtex titles, since we need to know what was protected from-      titlecase conversions.--  * LaTeX writer:--    + Specially escape non-ascii characters in labels.-      Otherwise we can get compile errors and other bugs when-      compiled with pdflatex (#1007).  Thanks to begemotv2718 for the fix.-    + Add link anchors for code blocks with identifiers (#1025).--  * Throughout the code, use `isURI` instead of `isAbsoluteURI`.-    It allows fragments identifiers.--  * Slide formats:--    + A Div element with class "notes" is treated as speaker-      notes.  Currently beamer goes to `\note{}`, revealjs to-      `<aside class="notes">`, and the notes are simply suppressed in-      other formats  (#925).-    + Fixed `. . .` (pause) on HTML slide formats.  Closes #1029.-      The old version caused a pause to be inserted before the first-      material on a slide. This has been fixed.-    + Removed data files for s5, slideous, slidy.-      Users of s5 and slideous will have to download the needed-      files, as has been documented for some time in the README.-      By default, slidy code will be sought on the web, as before.--  * HTML writer: Insert command to typeset mathjax only in slideous output-    (#966, #1012).--  * RST writer:  Skip spaces after display math.  Otherwise we get indentation-    problems, and part of the next paragraph may be rendered as part of the-    math.--  * OpenDocument writer:  Fix formatting of strikeout code (#995),-    thanks to wilx.  don't use `font-face-decls` variable.--  * Fixed test suite so it works with cabal sandboxes.--pandoc (1.12.0.2)--  * Removed `stringable` dependency.--pandoc (1.12.0.1)--  * Allow `--metadata` to be repeated for the same key to form a list.-    This also has the effect that `--bibliography` can be repeated,-    as before.--  * Handle boolean values in `--metadata`.  Note that anything not parseable-    as a YAML boolean or string is treated as a literal string.-    You can get a string value with "yes", or any of the strings interpretable-    as booleans, by quoting it:--        -M boolvalue=yes -M stringvalue='"yes"'--  * LaTeX writer: Don't print references if `--natbib` or `--biblatex`-    option used.--  * DOCX writer: Add `settings.xml` to the zip container.  Fixes a bug-    in which docx files could not be read by some versions of Word-    and LibreOffice (#990).--  * Fixed a regression involving slide shows with bibliographies.-    The Div container around references messed up the procedure for carving-    a document into slides.  So we now remove the surrounding Div in-    `prepSlides`.--  * More informative error message when a filter is not found in path.--  * Depend on pandoc-types 1.12.1.  This provide `ToJSONFilter`-    instances for `Data a => a -> [a]` and `Data a => a -> IO [a]`.--  * Don't use unicode_collation in building OSX package:-    it adds something like 50MB of dependencies to the package.--  * Declare alex and happy as build-tools (#986).--pandoc (1.12)--  [new features]--  * Much more flexible metadata, including arbitrary fields and structured-    values.  Metadata can be specified flexibly in pandoc markdown using-    YAML metadata blocks, which may occur anywhere in the document:--        ----        title: Here is my title.-        abstract: |-          This is the abstract.--          1. It can contain-          2. block content-             and *inline markup*--        tags: [cat, dog, animal]-        ...--    Metadata fields automatically populate template variables.--  * Added `opml` (OPML) as input and output format.  The `_note` attribute,-    used in OmniOutliner and supported by multimarkdown, is supported.-    We treat the contents as markdown blocks under a section header.--  * Added `haddock` (Haddock markup) as input format (David Lazar).--  * Added `revealjs` output format, for reveal.js HTML 5 slide shows.-    (Thanks to Jamie F. Olson for the initial patch.)-    Nested vertical stacks are used for hierarchical structure.-    Results for more than one level of nesting may be odd.--  * Custom writers can now be written in lua.--        pandoc -t data/sample.lua--    will load the script sample.lua and use it as a custom writer.-    (For a sample, do `pandoc --print-default-data-file sample.lua`.)-    Note that pandoc embeds a lua interpreter, so lua need not be-    installed separately.--  * New `--filter/-F` option to make it easier to run "filters"-    (Pandoc AST transformations that operate on JSON serializations).-    Filters are always passed the name of the output format, so their-    behavior can be tailored to it.  The repository-    <https://github.com/jgm/pandocfilters> contains-    a python module for writing pandoc filters in python, with-    a number of examples.--  * Added `--metadata/-M` option.-    This is like `--variable/-V`, but actually adds to metadata, not-    just variables.--  * Added `--print-default-data-file` option, which allows printing-    of any of pandoc's data files. (For example,-    `pandoc --print-default-data-file reference.odt` will print-    `reference.odt`.)--  * Added syntax for "pauses" in slide shows:--        This gives--        . . .--        me pause.--  * New markdown extensions:--    + `ignore_line_breaks`:  causes intra-paragraph line breaks to be ignored,-      rather than being treated as hard line breaks or spaces.  This is useful-      for some East Asian languages, where spaces aren't used between words,-      but text is separated into lines for readability.-    + `yaml_metadata_block`:  Parse YAML metadata blocks.  (Default.)-    + `ascii_identifiers`: This will force `auto_identifiers` to use ASCII-       only. (Default for `markdown_github`.) (#807)-    + `lists_without_preceding_blankline`:  Allow lists to start without-      preceding blank space.  (Default for `markdown_github`.) (#972)--  [behavior changes]--  * `--toc-level` no longer implies `--toc`.-    Reason: EPUB users who don't want a visible TOC may still want-    to set the TOC level for in the book navigation.--  * `--help` now prints in and out formats in alphabetical order, and-    says something about PDF output (#720).--  * `--self-contained` now returns less verbose output (telling you-    which URLs it is fetching, but not giving the full header).  In-    addition, there are better error messages when fetching a URL fails.--  * Citation support is no longer baked in to core pandoc. Users who-    need citations will need to install and use a separate filter-    (`--filter pandoc-citeproc`).  This filter will take `bibliography`,-    `csl`, and `citation-abbreviations` from the metadata, though it-    may still be specified on the command line as before.--  * A `Cite` element is now created in parsing markdown whether or not-    there is a matching reference.--  * The `pandoc-citeproc` script will put the bibliography at the-    end of the document, as before.  However, it will be put inside a `Div`-    element with class "references", allowing users some control-    over the styling of references.  A final header, if any, will-    be included in the `Div`.--  * The markdown writer will not print a bibliography if the-    `citations` extension is enabled.  (If the citations are formatted-    as markdown citations, it is redundant to have a bibliography,-    since one will be generated automatically.)--  * Previously we used to store the directory of the first input file,-    even if it was local, and used this as a base directory for finding-    images in ODT, EPUB, Docx, and PDF.  This has been confusing to many-    users.  So we now look for images relative to the current-    working directory, even if the first file argument is in another-    directory.   Note that this change may break some existing workflows.-    If you have been assuming that relative links will be interpreted-    relative to the directory of the first file argument, you'll need-    to make that the current directory before running pandoc. (#942)--  * Better error reporting in some readers, due to changes in `readWith`:-    the line in which the error occurred is printed, with a caret pointing-    to the column.--  * All slide formats now support incremental slide view for definition lists.--  * Parse `\(..\)` and `\[..\]` as math in MediaWiki reader.-    Parse `:<math>...</math>` as display math.  These notations are used with-    the MathJax MediaWiki extension.--  * All writers: template variables are set automatically from metadata-    fields.  However, variables specified on the command line with-    `--variable` will completely shadow metadata fields.--  * If `--variable` is used to set many variables with the same name,-    a list is created.--  * Man writer:  The `title`, `section`, `header`, and `footer` can now-    all be set individually in metadata.  The `description` variable has been-    removed.  Quotes have been added so that spaces are allowed in the-    title.  If you have a title that begins--        COMMAND(1) footer here | header here--    pandoc will still parse it into a title, section, header, and-    footer.  But you can also specify these elements explicitly (#885).--  * Markdown reader--    + Added support for YAML metadata blocks, which can come anywhere-      in the document (not just at the beginning).  A document can contain-      multiple YAML metadata blocks.-    + HTML span and div tags are parsed as pandoc Span and Div elements.--  * Markdown writer--    + Allow simple tables to be printed as grid tables,-      if other table options are disabled.  This means you can do-      `pandoc -t markdown-pipe_tables-simple_tables-multiline_tables`-      and all tables will render as grid tables.-    + Support YAML title block (render fields in alphabetical order-      to make output predictable).--  [API changes]--  * `Meta` in `Text.Pandoc.Definition` has been changed to allow-    structured metadata.  (Note:  existing code that pattern-matches-    on `Meta` will have to be revised.)  Metadata can now contain-    indefinitely many fields, with content that can be a string,-    a Boolean, a list of `Inline` elements, a list of `Block`-    elements, or a map or list of these.--  * A new generic block container (`Div`) has been added to `Block`,-    and a generic inline container (`Span`) has been added to `Inline`.-    These can take attributes.  They will render in HTML, Textile,-    MediaWiki, Org, RST and and Markdown (with `markdown_in_html`-    extension) as HTML `<div>` and `<span>` elements; in other formats-    they will simply pass through their contents.  But they can be-    targeted by scripts.--  * `Format` is now a newtype, not an alias for String.-    Equality comparisons are case-insensitive.--  * Added `Text.Pandoc.Walk`, which exports hand-written tree-walking-    functions that are much faster than the SYB functions from-    `Text.Pandoc.Generic`.  These functions are now used where possible-    in pandoc's code.  (`Tests.Walk` verifies that `walk` and `query`-    match the generic traversals `bottomUp` and `queryWith`.)--  * Added `Text.Pandoc.JSON`, which provides `ToJSON` and `FromJSON`-    instances for the basic pandoc types. They use GHC generics and-    should be faster than the old JSON serialization using-    `Data.Aeson.Generic`.--  * Added `Text.Pandoc.Process`, exporting `pipeProcess`.-    This is a souped-up version of `readProcessWithErrorcode` that-    uses lazy bytestrings instead of strings and allows setting-    environment variables.  (Used in `Text.Pandoc.PDF`.)--  * New module `Text.Pandoc.Readers.OPML`.--  * New module `Text.Pandoc.Writers.OPML`.--  * New module `Text.Pandoc.Readers.Haddock` (David Lazar).-    This is based on Haddock's own lexer/parser.--  * New module `Text.Pandoc.Writers.Custom`.--  * In `Text.Pandoc.Shared`, `openURL` and `fetchItem` now return an-    Either, for better error handling.--  * Made `stringify` polymorphic in `Text.Pandoc.Shared`.--  * Removed `stripTags` from `Text.Pandoc.XML`.--  * `Text.Pandoc.Templates`:--    + Simplified `Template` type to a newtype.-    + Removed `Empty`.-    + Changed type of `renderTemplate`: it now takes a JSON context-      and a compiled template.-    + Export `compileTemplate`.-    + Export `renderTemplate'` that takes a string instead of a compiled-      template.-    + Export `varListToJSON`.--  * `Text.Pandoc.PDF` exports `makePDF` instead of `tex2pdf`.-    The signature of `makePDF` has changed and now contains-    an additional argument for pdf engine options.--  * `Text.Pandoc`:--    + Made `toJsonFilter` an alias for `toJSONFilter` from `Text.Pandoc.JSON`.-    + Removed `ToJsonFilter` typeclass.  `ToJSONFilter` from-      `Text.Pandoc.JSON` should be used instead.  (Compiling against-      pandoc-types instead of pandoc will also produce smaller executables.)-    * Removed the deprecated `jsonFilter` function.-    + Added `readJSON`, `writeJSON` to the API (#817).--  * `Text.Pandoc.Options`:--    + Added `Ext_lists_without_preceding_blankline`,-      `Ext_ascii_identifiers`, `Ext_ignore_line_breaks`,-      `Ext_yaml_metadataBlock` to `Extension`.-    + Changed `writerSourceDirectory` to `writerSourceURL` and changed the-      type to a `Maybe`.  `writerSourceURL` is set to 'Just url' when the-      first command-line argument is an absolute URL.  (So, relative links-      will be resolved in relation to the first page.)  Otherwise, 'Nothing'.-    + All bibliography-related fields have been removed from-      `ReaderOptions` and `WriterOptions`: `writerBiblioFiles`,-      `readerReferences`, `readerCitationStyle`.-    + Removed `writerPdfArgs` from `WriterOptions`.  These are now-      passed in as a parameter to `makePDF`.--  * The `Text.Pandoc.Biblio` module has been removed.  Users of the-    pandoc library who want citation support will need to use-    `Text.CSL.Pandoc` from `pandoc-citeproc`.---  [bug fixes]--  * In markdown, don't autolink a bare URI that is followed by `</a>`-    (#937).--  * `Text.Pandoc.Shared`--    + `openURL` now follows redirects (#701), properly handles `data:`-      URIs, and prints diagnostic output to stderr rather than stdout.-    + `readDefaultDataFile`: normalize the paths.  This fixes bugs in-      `--self-contained` on pandoc compiled with `embed_data_files` (#833).-    + Fixed `readDefaultDataFile` so it works on Windows.-    + Better error messages for `readDefaultDataFile`.  Instead of-      listing the last path tried, which can confuse people who are-      using `--self-contained`, so now we just list the data file name.-    + URL-escape pipe characters.  Even though these are legal, `Network.URI`-      doesn't regard them as legal in URLs.  So we escape them first (#535).--  * Mathjax in HTML slide shows:  include explicit "Typeset" call.-    This seems to be needed for some formats (e.g. slideous) and won't-    hurt in others (#966).--  * `Text.Pandoc.PDF`--    + On Windows, create temdir in working directory, since the system-      temp directory path may contain tildes, which can cause-      problems in LaTeX (#777).-    + Put temporary output directory in `TEXINPUTS` (see #917).-    + `makePDF` tries to download images that are not found locally,-      if the first argument is a URL (#917).-    + If compiling with `pdflatex` yields an encoding error, offer-      the suggestion to use `--latex-engine=xelatex`.--  * Produce automatic header identifiers in parsing textile, RST,-    and LaTeX, unless `auto_identifiers` extension is disabled (#967).--  * `Text.Pandoc.SelfContained`:  Strip off fragment, query of relative URL-     before treating as a filename.  This fixes `--self-contained` when used-     with CSS files that include web fonts using the method described here:-      <http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/>-      (#739).  Handle `src` in `embed`, `audio`, `source`, `input` tags.--  * `Text.Pandoc.Parsing`: `uri` parser no longer treats punctuation before-    percent-encoding, or a `+` character, as final punctuation.--  * `Text.Pandoc.ImageSize`:  Handle EPS (#903).  This change will make-    EPS images properly sized on conversion to Word.--  * Slidy:  Use slidy.js rather than slidy.js.gz.-    Reason:  some browsers have trouble with the gzipped js file,-    at least on the local file system (#795).--  * Markdown reader--    + Properly handle blank line at beginning of input (#882).-    + Fixed bug in unmatched reference links.  The input-      `[*infile*] [*outfile*]` was getting improperly parsed:-      "infile" was emphasized, but "*outfile*" was literal (#883).-    + Allow internal `+` in citation identifiers (#856).-    + Allow `.` or `)` after `#` in ATX headers if no `fancy_lists`.-    + Do not generate blank title, author, or date metadata elements.-      Leave these out entirely if they aren't present.-    + Allow backtick code blocks not to be preceded by blank line (#975).--  * Textile reader:--    + Correctly handle entities.-    + Improved handling of `<pre>` blocks (#927). Remove internal HTML tags-      in code blocks, rather than printing them verbatim. Parse attributes-      on `<pre>` tag for code blocks.--  * HTML reader: Handle non-simple tables (#893).  Column widths are read from-    `col` tags if present, otherwise divided equally.--  * LaTeX reader--    + Support alltt environment (#892).-    + Support `\textasciitilde`, `\textasciicircum` (#810).-    + Treat `\textsl` as emphasized text reader (#850).-    + Skip positional options after `\begin{figure}`.-    + Support `\v{}` for hacek (#926).-    + Don't add spurious ", " to citation suffixes.-      This is added when needed in pandoc-citeproc.-    + Allow spaces in alignment spec in tables, e.g. `{ l r c }`.-    + Improved support for accented characters (thanks to Scott Morrison).-    + Parse label after section command and set id (#951).--  * RST reader:--    + Don't insert paragraphs where docutils doesn't.-      `rst2html` doesn't add `<p>` tags to list items (even when they are-      separated by blank lines) unless there are multiple paragraphs in the-      list.  This commit changes the RST reader to conform more closely to-      what docutils does (#880).-    + Improved metadata.  Treat initial field list as metadata when-      standalone specified.  Previously ALL fields "title", "author",-      "date" in field lists were treated as metadata, even if not at-      the beginning.  Use `subtitle` metadata field for subtitle.-    + Fixed 'authors' metadata parsing in reST.  Semicolons separate-      different authors.--  * MediaWiki reader--    + Allow space before table rows.-    + Fixed regression for `<ref>URL</ref>`.-      `<` is no longer allowed in URLs, according to the uri parser-      in `Text.Pandoc.Parsing`.  Added a test case.-    + Correctly handle indented preformatted text without preceding-      or following blank line.-    + Fixed `|` links inside table cells.  Improved attribute parsing.-    + Skip attributes on table rows.  Previously we just crashed if-      rows had attributes, now we ignore them.-    + Ignore attributes on headers.-    + Allow `Image:` for images (#971).-    + Parse an image with caption in a paragraph by itself as a figure.--  * LaTeX writer--    + Don't use ligatures in escaping inline code.-    + Fixed footnote numbers in LaTeX/PDF tables.  This fixes a bug-      wherein notes were numbered incorrectly in tables (#827).-    + Always create labels for sections.  Previously the labels were only-      created when there were links to the section in the document (#871).-    + Stop escaping `|` in LaTeX math.-      This caused problems with array environments (#891).-    + Change `\` to `/` in paths.  `/` works even on Windows in LaTeX.-      `\` will cause major problems if unescaped.-    + Write id for code block to label attribute in LaTeX when listings-      is used (thanks to Florian Eitel).-    + Scale LaTeX tables so they don't exceed columnwidth.-    + Avoid problem with footnotes in unnumbered headers (#940).--  * Beamer writer: when creating beamer slides, add `allowframebreaks` option-      to the slide if it is one of the header classes.  It is recommended-      that your bibliography slide have this attribute:--        # References {.allowframebreaks}--    This causes multiple slides to be created if necessary, depending-    on the length of the bibliography.--  * ConTeXt writer: Properly handle tables without captions.  The old output-    only worked in MkII. This should work in MkIV as well (#837).--  * MediaWiki writer: Use native mediawiki tables instead of HTML (#720).--  * HTML writer:--    + Fixed `--no-highlight` (Alexander Kondratskiy).-    + Don't convert to lowercase in email obfuscation (#839).-    + Ensure proper escaping in `<title>` and `<meta>` fields.--  * AsciiDoc writer:--    + Support `--atx-headers` (Max Rydahl Andersen).-    + Don't print empty identifier blocks `([[]])` on headers (Max-      Rydahl Andersen).--  * ODT writer:--    + Fixing wrong numbered-list indentation in open document format-      (Alexander Kondratskiy) (#369).-    + `reference.odt`: Added pandoc as "generator" in `meta.xml`.-    + Minor changes for ODF 1.2 conformance (#939). We leave the-      nonconforming `contextual-spacing` attribute, which is provided by-      LibreOffice itself and seems well supported.--  * Docx writer:--    + Fixed rendering of display math in lists.-      In 1.11 and 1.11.1, display math in lists rendered as a new list-      item.  Now it always appears centered, just as outside of lists,-      and in proper display math style, no matter how far indented the-      containing list item is (#784).-    + Use `w:br` with `w:type` `textWrapping` for linebreaks.-      Previously we used `w:cr` (#873).-    + Use Compact style for Plain block elements, to-      differentiate between tight and loose lists (#775).-    + Ignore most components of `reference.docx`.-      We take the `word/styles.xml`, `docProps/app.xml`,-      `word/theme/theme1.xml`, and `word/fontTable.xml` from-      `reference.docx`, ignoring everything else.  This should help-      with the corruption problems caused when different versions of-      Word resave the reference.docx and reorganize things.-    +  Made `--no-highlight` work properly.--  * EPUB writer--    + Don't add `dc:creator` tags if present in EPUB metadata.-    + Add `id="toc-title"` to `h1` in `nav.xhtml` (#799).-    + Don't put blank title page in reading sequence.-      Set `linear="no"` if no title block.  Addresses #797.-    + Download webtex images and include as data URLs.-      This allows you to use `--webtex` in creating EPUBs.-      Math with `--webtex` is automatically made self-contained.-    + In `data/epub.css`, removed highlighting styles (which-      are no longer needed, since styles are added by the HTML-      writer according to `--highlighting-style`).  Simplified-      margin fields.-    + If resource not found, skip it, as in Docx writer (#916).--  * RTF writer:--    + Properly handle characters above the 0000-FFFF range.-      Uses surrogate pairs.  Thanks to Hiromi Ishii for the patch.-    + Fixed regression with RTF table of contents.-    + Only autolink absolute URIs.  This fixes a regression, #830.--  * Markdown writer:--    + Only autolink absolute URIs.  This fixes a regression, #830.-    + Don't wrap attributes in fenced code blocks.-    + Write full metadata in MMD style title blocks.-    + Put multiple authors on separate lines in pandoc titleblock.-      Also, don't wrap long author entries, as new lines get treated-      as new authors.--  * `Text.Pandoc.Templates`:--    + Fixed bug retrieving default template for markdown variants.-    + Templates can now contain "record lookups" in variables;-      for example, `author.institution` will retrieve the `institution`-      field of the `author` variable.-    + More consistent behavior of `$for$`.  When `foo` is not a list,-      `$for(foo)$...$endfor$` should behave like $if(foo)$...$endif$.-      So if `foo` resolves to "", no output should be produced.-      See pandoc-templates#39.--  * Citation processing improvements (now part of pandoc-citeproc):--    + Fixed `endWithPunct` The new version correctly sees a sentence-      ending in '.)' as ending with punctuation.  This fixes a bug which-      led such sentences to receive an extra period at the end: '.).'.-      Thanks to Steve Petersen for reporting.-    + Don't interfere with Notes that aren't citation notes.-      This fixes a bug in which notes not generated from citations were-      being altered (e.g. first letter capitalized) (#898).-    + Only capitalize footnote citations when they have a prefix.-    + Changes in suffix parsing.  A suffix beginning with a digit gets 'p'-      inserted before it before passing to citeproc-hs, so that bare numbers-      are treated as page numbers by default.  A suffix not beginning with-      punctuation has a space added at the beginning (rather than a comma and-      space, as was done before for not-author-in-text citations).-      The result is that `\citep[23]{item1}` in LaTeX will be interpreted-      properly, with '23' treated as a locator of type 'page'.-    + Many improvements to citation rendering, due to fixes in citeproc-hs-      (thanks to Andrea Rossato).-    + Warnings are issued for undefined citations, which are rendered-      as `???`.-    + Fixed hanging behavior when locale files cannot be found.--  [template changes]--  * DocBook:  Use DocBook 4.5 doctype.--  * Org: '#+TITLE:' is inserted before the title.-    Previously the writer did this.--  * LaTeX:  Changes to make mathfont work with xelatex.-    We need the mathspec library, not just fontspec, for this.-    We also need to set options for setmathfont (#734).--  * LaTeX: Use `tex-ansi` mapping for `monofont`.-    This ensures that straight quotes appear as straight, rather than-    being treated as curly.  See #889.--  * Made `\includegraphics` more flexible in LaTeX template.-    Now it can be used with options, if needed.  Thanks to Bernhard Weichel.--  * LaTeX/Beamer: Added `classoption` variable.-    This is intended for class options like `oneside`; it may-    be repeated with different options.  (Thanks to Oliver Matthews.)--  * Beamer: Added `fonttheme` variable.  (Thanks to Luis Osa.)--  * LaTeX: Added `biblio-style` variable (#920).--  * DZSlides: title attribute on title section.--  * HTML5: add meta tag to allow scaling by user (Erik Evenson)--  [under-the-hood improvements]--  * Markdown reader:Improved strong/emph parsing, using the strategy of-    <https://github.com/jgm/Markdown>.  The new parsing algorithm requires-    no backtracking, and no keeping track of nesting levels.  It will give-    different results in some edge cases, but these should not affect normal-    uses.--  * Added `Text.Pandoc.Compat.Monoid`.-    This allows pandoc to compile with `base` < 4.5, where `Data.Monoid`-    doesn't export `<>`.  Thanks to Dirk Ullirch for the patch.--  * Added `Text.Pandoc.Compat.TagSoupEntity`.-    This allows pandoc to compile with `tagsoup` 0.13.x.-    Thanks to Dirk Ullrich for the patch.--  * Most of `Text.Pandoc.Readers.TeXMath` has been moved to the-    `texmath` module (0.6.4).  (This allows `pandoc-citeproc` to-    handle simple math in bibliography fields.)--  * Added `Text.Pandoc.Writers.Shared` for shared functions used-    only in writers.  `metaToJSON` is used in writers to create a-    JSON object for use in the templates from the pandoc metadata-    and variables.  `getField`, `setField`, and `defField` are-    for working with JSON template contexts.--  * Added `Text.Pandoc.Asciify` utility module.-    This exports functions to create ASCII-only versions of identifiers.--  * `Text.Pandoc.Parsing`--    + Generalized state type on `readWith` (API change).-    + Specialize readWith to `String` input. (API change).-    + In `ParserState`, replace `stateTitle`, `stateAuthors`, `stateDate`-      with `stateMeta` and `stateMeta'`.--  * `Text.Pandoc.UTF8`: use strict bytestrings in reading.  The use of lazy-     bytestrings seemed to cause problems using pandoc on 64-bit Windows-     7/8 (#874).--  * Factored out `registerHeader` from markdown reader, added to-    `Text.Pandoc.Parsing`.--  * Removed `blaze_html_0_5` flag, require `blaze-html` >= 0.5.-    Reason:  < 0.5 does not provide a monoid instance for Attribute,-    which is now needed by the HTML writer (#803).--  * Added `http-conduit` flag, which allows fetching https resources.-    It also brings in a large number of dependencies (`http-conduit`-    and its dependencies), which is why for now it is an optional flag-    (#820).--  * Added CONTRIBUTING.md.--  * Improved INSTALL instructions.--  * `make-windows-installer.bat`: Removed explicit paths for executables.--  * `aeson` is now used instead of `json` for JSON.--  * Set default stack size to 16M.  This is needed for some large-    conversions, esp. if pandoc is compiled with 64-bit ghc.--  * Various small documentation improvements.-    Thanks to achalddave and drothlis for patches.--  * Removed comment that chokes recent versions of CPP (#933).--  * Removed support for GHC version < 7.2, since pandoc-types now-    requires at least GHC 7.2 for GHC generics.---pandoc (1.11.1)--  * Markdown reader:--    + Fixed regression in which parentheses were lost in link URLs.-      Added tests.  Closes #786.-    + Better handling of unmatched double quotes in `--smart` mode.-      These occur frequently in fiction, since it is customary not to-      close quotes in dialogue if the speaker does not change between-      paragraphs.  The unmatched quotes now get turned into literal-      left double quotes. (No `Quoted` inline is generated, however.)-      Closes #99 (again).--  * HTML writer: Fixed numbering mismatch between TOC and sections.-    `--number-offset` now affects TOC numbering as well-    as section numbering, as it should have all along.  Closes #789.--  * Markdown writer: Reverted 1.11 change that caused citations to be rendered-    as markdown citations, even if `--bibliography` was specified, unless-    `citation` extension is disabled.  Now, formatted citations are always-    printed if `--bibliography` was specified.  If you want to reformat-    markdown keeping pandoc markdown citations intact, don't use-    `--bibliography`.  Note that citations parsed from LaTeX documents will-    be rendered as pandoc markdown citations when `--bibliography` is not-    specified.--  * ODT writer: Fixed regression leading to corrupt ODTs.-    This was due to a change in the `Show` instance for-    `Text.Pandoc.Pretty.Doc`.  Closes #780.--  * Fixed spacing bugs involving code block attributes in-    RST reader and Markdown writer. Closes #763.--  * Windows package:  Various improvements due to Fyodor Sheremetyev.--    + Automatically set installation path (Program Files or Local App Data).-    + Set system PATH environment variable when installing for all users.-    + Pandoc can installed for all users using the following command.-      `msiexec /i pandoc-1.11.msi ALLUSERS=1`.--  * Bumped QuickCheck version bound.--pandoc (1.11)--  * Added `--number-offset` option.  (See README for description.)--  * Added `--default-image-extension` option.  (See README for description.)--  * `--number-sections` behavior change: headers with class `unnumbered`-    will not be numbered.--  * `--version` now reports the default data directory.--  * `Text.Pandoc.Parsing` is no longer exposed. (API change.)--  * `Text.Pandoc.Highlighting` is no longer exposed. (API change.)--  * `Text.Pandoc.Shared`:  Changed type of `Element`.  `Sec` now includes-    a field for `Attr` rather than just `String`.  (API change.)--  * Added `markdown_github` as input format.  This was an accidental-    omission in 1.10.--  * Added `readerDefaultImageExtension` field to `ReaderOptions`.  (API-    change.)--  * Added `writerNumberOffset` field in `WriterOptions`. (API change.)--  * Beamer template:--    + Fixed captions with longtable.  Thanks to Joost Kremers.-    + Provide `\Oldincludegraphics` as in LaTeX template (Benjamin Bannier).--  * LaTeX template:--    + Load microtype after fonts.  Microtype needs to know-      what fonts are being used.  Thanks to dfc for the patch.-    + Set `secnumdepth` to 5 if `--number-sections` specified.-      This yields behavior equivalent to the other writers, numbering-      level 4 and 5 headers too.  Closes #753.--  * HTML reader:--    + Handle `<colgroup>` tag.-    + Preserve all header attributes.--  * LaTeX reader:--    + Parse `\hrule` as `HorizontalRule`.  Closes #746.-    + Parse starred variants of `\section` etc. as headers with-      attribute `unnumbered`.-    + Read optional attributes in `lstlisting` and `Verbatim` environments.-      We convert these to pandoc standard names, e.g. `numberLines`-      for `numbers=left`, `startFrom=100` from `firstnumber=100`.-    + Handle language attribute for lstlistings.-    + Better support for Verbatim and minted environments.  Closes #763.--  * Markdown reader:--    + `-` in an attribute context = `.unnumbered`.  The point of this-      is to provide a way to specify unnumbered headers in non-English-      documents.-    + Fixed bug parsing key/value attributes.  Parsing failed if you-      had an unquoted attribute immediately before the final '}'.-    + Make backslash escape work in attributes.-    + Fix title block parsing.  Now if `mmd_title_blocks` is specified,-      pandoc will parse a MMD title block if it sees one, even if-      `pandoc_title_blocks` is enabled.-    + Refactoring: `litChar` now includes entities, so we don't need-      to use `fromEntities` e.g. on titles.-    + Allow spaces around borders in pipe tables.  Closes #772.-    + Allow all punctuation in angle-bracket autolinks.  Previously-      things like `----` were disallowed, because the uri parser-      treated them as trailing punctuation.  Closes #768.-    + Make `implicit_header_references` work properly when-      headers are given explicit identifiers.-    + Check for tables before line blocks.  Otherwise some pipe-      tables get treated as line blocks.-    + Allow `&` in emails (for entities).-    + Properly handle entities in titles and links.  A markdown link-      `<http://g&ouml;ogle.com>` should be a link to `http://göogle.com`.-      Closes #723.--  * Textile reader:--    + Handle attributes on headers.--  * LaTeX reader:--    + Add `fig:` as title for images with captions.-      This is needed for them to be rendered as figures.  Closes #766.-    + Never emit an empty paragraph.  See #761.-    + Handle `\caption` for images in figures.  Closes #766.-    + Parse `\section*`, etc. as unnumbered sections.--  * HTML writer:--    + Support header attributes.  The attributes go on-      the enclosing `section` or `div` tag if `--section-divs` is specified.-    + Fixed a regression (only now noticed) in html+lhs output.-      Previously the bird tracks were being omitted.--  * LaTeX writer:--    + Omit lists with no items to avoid LaTeX errors.-    + Support line numbering with `--listings`.-      If `numberLines` class is present, we add `numbers=left`;-      if `startFrom` is present, we add `firstnumber=`. (#763)--  * ConTeXt writer:--    + Removed `\placecontent`.  This produced a duplicate toc,-      in conjunction with `\placelist`.-    + Use `\title`, `\subject` etc. for headers with-      `unnumbered` class.--  * Textile writer:--    + Support header attributes.--  * Markdown writer:--    + Use grid tables when needed, and if enabled.  Closes #740.-    + Render citations as pandoc-markdown citations.-      Previously citations were rendered as citeproc-formatted citations-      by default.  Now we render them as pandoc citations, e.g. `[@item1]`,-      unless the `citations` extension is disabled.-      If you still want formatted citations in your markdown output,-      use `pandoc -t markdown-citations`.--  * RST writer:--    + Support `:number-lines:` in code blocks.--  * Docx writer:--    + Better treatment of display math.  Display math inside a-      paragraph is now put in a separate paragraph, so it will render-      properly (centered and without extra blank lines around it).-      Partially addresses #742.-    + Content types and document rels xml files are now created from-      scratch, rather than being taken over from `reference.docx`.-      This fixes problems that arise when you edit the `reference.docx`-      with Word.-    + We also now encode mime types for each individual image rather-      than using defaults.  This should allow us to handle a wider-      range of image types (including PDF).   Closes #414.-    + Changed style names in `reference docx`.-      `FootnoteReference` -> `FootnoteRef`, `Hyperlink` -> `Link`.-      The old names got changed by Word when the `reference.docx` was-      edited.  Closes #414.--  * EPUB writer:--    + Fix section numbering.  Previously the numbering restarted from 1-      in each chapter (with `--number-sections`), though the numbers in-      the table of contents were correct.-    + Headers with "unnumbered" attribute are not numbered.  (Nor do they-      cause an increment in running numbering.) Section numbers now work-      properly, even when there is material before the first numbered section.-    + Include HTML TOC, even in epub2.  The TOC is included in `<spine>`,-      but `linear` is set to `no` unless the `--toc` option is specified.-      Include `<guide>` element in OPF.  This should allow the TOC to-      be usable in Kindles when converted with kindlegen. Closes #773.--  * `Text.Pandoc.Parsing`: Optimized `oneOfStringsCI`.-    This dramatically reduces the speed penalty that comes from enabling the-    `autolink_bare_uris` extension.  The penalty is still substantial (in one-    test, from 0.33s to 0.44s), but nowhere near what it used to be.-    The RST reader is also much faster now, as it autodetects URIs.--  * `Text.Pandoc.Shared`:  `hierarchicalize` will not number section-    with class "unnumbered".  Unnumbered sections get `[]` for their-    section number.--  * `Text.Pandoc.Pretty`:--    + Fixed `chomp` so it works inside `Prefixed` elements.-    + Changed `Show` instance so it is better for debugging.--  * `Text.Pandoc.ImageSize`:  Added `Pdf` to `ImageType`.--  * `Text.Pandoc.UTF8`:  Strip off BOM if present.  Closes #743.--  * Windows installer improvements:--    + The installer is now signed with a certificate (thanks to-      Fyodor Sheremetyev).-    + WiX is used instead of InnoSetup.  The installer is now a-      standard msi file.-    + The version number is now auto-detected, and need not be-      updated separately.--  * OSX installer improvements:--    + The package and pandoc executable are now signed with a-      certificate (thanks to Fyodor Sheremetyev).-    + RTF version of license is used.-    + Use full path for sysctl in `InstallationCheck` script (jonahbull).-      Closes #580.--  * Converted COPYING to markdown.--  * pandoc.cabal:  Require latest versions of highlighting-kate,-    texmath, citeproc-hs, zip-archive.--pandoc (1.10.1)--  * Markdown reader:  various optimizations, leading to a-    significant performance boost.--  * RST reader:  Allow anonymous form of inline links:-    `` `hello <url>`__ `` Closes #724.--  * Mediawiki reader: Don't require newlines after tables.-    Thanks to jrunningen for the patch. Closes #733.--  * Fixed LaTeX macro parsing.  Now LaTeX macro definitions are preserved-    when output is LaTeX, and applied when it is another format.-    Partially addresses #730.--  * Markdown and RST readers:  Added parser to `block` that skips blank-    lines.  This fixes a subtle regression involving grid tables with-    empty cells.  Also added test for grid table with empty cells.-    Closes #732.--  * RST writer:  Use `.. code:: language` for code blocks with language.-    Closes #721.--  * DocBook writer:  Fixed output for hard line breaks, adding a newline-    between `<literallayout>` tags.--  * Markdown writer:  Use an autolink when link text matches url.-    Previously we also checked for a null title, but this-    test fails for links produced by citeproc-hs in bibliographies.-    So, if the link has a title, it will be lost on conversion-    to an autolink, but that seems okay.--  * Markdown writer:  Set title, author, date variables as before.-    These are no longer used in the default template, since we use-    titleblock, but we set them anyway for those who use custom templates.--  * LaTeX writer:  Avoid extra space at start/end of table cell.-    Thanks to Nick Bart for the suggestion of using @{}.--  * `Text.Pandoc.Parsing`:--    + More efficient version of `anyLine`.-    + Type of `macro` has changed; the parser now returns `Blocks`-      instead of `Block`.--  * Relaxed old-time version bound, allowing 1.0.*.--  * Removed obsolete `hsmarkdown` script.  Those who need `hsmarkdown`-    should create a symlink as described in the README.--pandoc (1.10.0.5)--  * Markdown reader: Try `lhsCodeBlock` before `rawTeXBlock`.  Otherwise-    `\begin{code}...\end{code}` isn't handled properly in markdown+lhs.-    Thanks to Daniel Miot for noticing the bug and suggesting the fix.--  * Markdown reader: Fixed bug with headerless grid tables.-    The 1.10 code assumed that each table header cell contains exactly one-    block. That failed for headerless tables (0) and also for tables with-    multiple blocks in a header cell.  The code is fixed and tests provided.-    Thanks to Andrew Lee for pointing out the bug.--  * Markdown reader: Fixed regressions in fenced code blocks. Closes #722.--    + Tilde code fences can again take a bare language string-      (`~~~ haskell`), not just curly-bracketed attributes-      (`~~~ {.haskell}`).-    + Backtick code blocks can take the curly-bracketed attributes.-    + Backtick code blocks don't *require* a language.-    + Consolidated code for the two kinds of fenced code blocks.--  * LaTeX template: Use `\urlstyle{same}` to avoid monospace URLs.--  * Markdown writer: Use proportional font for email autolinks with-    obfuscation.  Closes #714.--  * Corrected name of `blank_before_blockquote` in README.  Closes #718.--  * `Text.Pandoc.Shared`: Fixed bug in `uri` parser.-    The bug prevented an autolink at the end of a string (e.g.-    at the end of a line block line) from counting as a link.  Closes #711.--  * Use the `hsb2hs` preprocessor instead of TH for embed_data_files.-    This should work on Windows, unlike the TH solution with-    file-embed.--  * Eliminated use of TH in test suite.--  * Added `Text.Pandoc.Data` (non-exported) to hold the association-    list of embedded data files, if the `embed_data_files` flag is selected.-    This isolates the code that needs special treatment with file-embed or-    `hsb2hs`.--  * Changes to `make-windows-installer.bat`.--    + Exit batch file if any of the cabal-dev installs fail.-    + There's no longer any need to reinstall `highlighting-kate`.-    + Don't start with a `cabal update`; leave that to the user.-    + Force reinstall of pandoc.--  * Fixed EPUB writer so it builds with blaze-html 0.4.x. Thanks to-    Jens Petersen.--pandoc (1.10.0.4)--  * Fixed bug with escaped % in LaTeX reader. Closes #710.--pandoc (1.10.0.3)--  * Added further missing fb2 tests to cabal file.--pandoc (1.10.0.2)--  * Added fb2 tests to cabal file's extra-source-files.--pandoc (1.10.0.1)--  * Bump version bounds on test-framework packages.--pandoc (1.10)--  [new features]--  * New input formats:  `mediawiki` (MediaWiki markup).--  * New output formats:  `epub3` (EPUB v3 with MathML),-    `fb2` (FictionBook2 ebooks).--  * New `--toc-depth` option, specifying how many levels of-    headers to include in a table of contents.--  * New `--epub-chapter-level` option, specifying the header-    level at which to divide EPUBs into separate files.-    Note that this normally affects only performance, not the-    visual presentation of the EPUB in a reader.--  * Removed the `--strict` option.  Instead of using `--strict`,-    one can now use the format name `markdown_strict` for either input-    or output.  This gives more fine-grained control that `--strict`-    did, allowing one to convert from pandoc's markdown to strict-    markdown or vice versa.--  * It is now possible to enable or disable specific syntax-    extensions by appending them (with `+` or `-`) to the writer-    or reader name.  For example,--        pandoc -f markdown-footnotes+hard_line_breaks--    disables footnotes and enables treating newlines as hard-    line breaks.  The literate Haskell extensions are now implemented-    this way as well, using either `+lhs` or `+literate_haskell`.-    For a list of extension names, see the README under-    "Pandoc's Markdown."--  * The following aliases have been introduced for specific-    combinations of markdown extensions:  `markdown_phpextra`,-    `markdown_github`, `markdown_mmd`, `markdown_strict`.  These aliases-    work just like regular reader and writer names, and can be modified-    with extension modifiers as described above. (Note that conversion-    from one markdown dialect to another does not work perfectly,-    because there are differences in markdown parsers besides-    just the extensions, and because pandoc's internal document model is-    not rich enough to capture all of the extensions.)--  * New `--html-q-tags` option.  The previous default was to use `<q>`-    tags for smart quotes in HTML5.  But `<q>` tags are also valid HTML4.-    Moreover, they are not a robust way of typesetting quotes, since-    some user agents don't support them, and some CSS resets (e.g.-    bootstrap) prevent pandoc's quotes CSS from working properly.-    We now just insert literal quote characters by default in both-    `html` and `html5` output, but this option is provided for-    those who still want `<q>` tags.--  * The markdown reader now prints warnings (to stderr) about-    duplicate link and note references.  Closes #375.--  * Markdown syntax extensions:--    + Added pipe tables.  Thanks to François Gannaz for the initial patch.-      These conform to PHP Markdown Extra's pipe table syntax. A subset-      of org-mode table syntax is also supported, which means that you can-      use org-mode's nice table editor to create tables.--    + Added support for RST-style line blocks. These are-      useful for verse and addresses.--    + Attributes can now be specified for headers, using the same-      syntax as in code blocks.  (However, currently only the-      identifier has any effect in most writers.)  For example,--            # My header {#foo}--            See [the header above](#foo).--    + Pandoc will now act as if link references have been defined-      for all headers without explicit identifiers.-      So, you can do this:--            # My header--            Link to [My header].-            Another link to [it][My header].--      Closes #691.--  * LaTeX reader:--    + Command macros now work everywhere, including non-math.-      Environment macros still not supported.-    + `\input` now works, as well as `\include`.  TEXINPUTS is used.-      Pandoc looks recursively into included files for more included files.--  [behavior changes]--  * The Markdown reader no longer puts the text of autolinks in a-    `Code` inline.  This means that autolinks will no longer appear-    in a monospace font.--  * The character `/` can now appear in markdown citation keys.--  * HTML blocks in strict_markdown are no longer required to begin-    at the left margin.  Technically this is required, according to-    the markdown syntax document, but `Markdown.pl` and other markdown-    processors are more liberal.--  * The `-V` option has been changed so that if there are duplicate-    variables, those specified later on the command line take precedence.--  * Tight lists now work in LaTeX and ConTeXt output.--  * The LaTeX writer no longer relien on the `enumerate` package.-    Instead, it uses standard LaTeX commands to change the list numbering-    style.--  * The LaTeX writer now uses `longtable` instead of `ctable`. This allows-    tables to be split over page boundaries.--  * The RST writer now uses a line block to render paragraphs containing-    linebreaks (which previously weren't supported at all).--  * The markdown writer now applies the `--id-prefix` to footnote IDs.-    Closes #614.--  * The plain writer no longer uses backslash-escaped line breaks-    (which are not very "plain").--  * `Text.Pandoc.UTF8`: Better error message for invalid UTF8.-    Read bytestring and use `Text`'s decodeUtf8 instead of using-    `System.IO.hGetContents`.  This way you get a message saying-    "invalid UTF-8 stream" instead of "invalid byte sequence."-    You are also told which byte caused the problem.--  * Docx, ODT, and EPUB writers now download images specified by a URL-    instead of skipping them or raising an error.--  * EPUB writer:--    + The default CSS now left-aligns headers by default, instead of-      centering.  This is more consistent with the rest of the writers.-    + A proper multi-level table of contents is now used in `toc.ncx`.-      There is no longer a subsidiary table of contents at the beginning-      of each chapter.-    + Code highlighting now works by default.-    + Section divs are used by default for better semantic markup.-    + The title is used instead of "Title Page" in the table of contents.-      Otherwise we have a hard-coded English string, which looks-      strange in ebooks written in other languages.  Closes #572.--  * HTML writer:--    + Put mathjax in span with class "math".  Closes #562.-    + Put citations in a span with class "citation." In HTML5, also include-      a `data-cite` attribute with a space-separated list of citation-      keys.--  * `Text.Pandoc.UTF8`:  use universalNewlineMode in reading.-    This treats both `\r\n` and `\n` as `\n` on input, no matter-    what platform we're running on.--  * Citation processing is now done in the Markdown and LaTeX-    readers, not in `pandoc.hs`.  This makes it easier for library users-    to use citations.--  [template changes]--  * HTML: Added css to template to preserve spaces in `<code>` tags.-    Thanks to Dirk Laurie.--  * Beamer:  Remove English-centric strings in section pages.-    Section pages used to have "Section" and a number as well as the-    section title. Now they just have the title.  Similarly for part-    and subsection.  Closes #566.--  * LaTeX, ConTeXt: Added papersize variable.--  * LaTeX, Beamer templates: Use longtable instead of ctable.--  * LaTeX, Beamer templates: Don't require 'float' package for tables.-    We don't actually seem to use the '[H]' option.--  * LaTeX:  Use `upquote` package if it is available.  This fixes-    straight quotes in verbatim environments.--  * Markdown, plain: Fixed titleblock so it is just a single string.-    Previously separate title, author, and date variables were used,-    but this didn't allow different kinds of title blocks.--  * EPUB:--    + Rationalized templates.  Previously there were three different-      templates involved in epub production. There is now just one-      template, `default.epub` or `default.epub3`. It can now be-      overridden using `--template`, just like other templates.-      The titlepage is now folded into the default template.-      A `titlepage` variable selects it.-    + UTF-8, lang tag, meta tags, title element.--  * Added scale-to-width feature to beamer template--  [API changes]--  * `Text.Pandoc.Definition`: Added `Attr` field to `Header`.-    Previously header identifiers were autogenerated by the writers.-    Now they are added in the readers (either automatically or explicitly).--  * `Text.Pandoc.Builder`:--    + `Inlines` and `Blocks` are now synonyms for `Many Inline` and-      `Many Block`.  `Many` is a newtype wrapper around `Seq`, with-      custom Monoid instances for `Many Inline` and `Many Block.  This-      allows `Many` to be made an instance of `Foldable` and `Traversable`.-    + The old `Listable` class has been removed.-    + The module now exports `isNull`, `toList`, `fromList`.-    + The old `Read` and `Show` instances have been removed; derived-      instances are now used.-    + Added `headerWith`.--  * The readers now take a `ReaderOptions` rather than a `ParserState`-    as a parameter.  Indeed, not all parsers use the `ParserState` type;-    some have a custom state.  The motivation for this change was to separate-    user-specifiable options from the accounting functions of parser state.--  * New module `Text.Pandoc.Options`.  This includes the `WriterOptions`-    formerly in `Text.Pandoc.Shared`, and its associated-    data types.  It also includes a new type `ReaderOptions`, which-    contains many options formerly in `ParserState`, and its associated-    data types:--    + `ParserState.stateParseRaw` -> `ReaderOptions.readerParseRaw`.-    + `ParserState.stateColumns` -> `ReaderOptions.readerColumns`.-    + `ParserState.stateTabStop` -> `ReaderOptions.readerTabStop`.-    + `ParserState.stateOldDashes` -> `ReaderOptions.readerOldDashes`.-    + `ParserState.stateLiterateHaskell` -> `ReaderOptions.readerLiterateHaskell`.-    + `ParserState.stateCitations` -> `ReaderOptions.readerReferences`.-    + `ParserState.stateApplyMacros` -> `ReaderOptions.readerApplyMacros`.-    + `ParserState.stateIndentedCodeClasses` ->-      `ReaderOptions.readerIndentedCodeClasses`.-    + Added `ReaderOptions.readerCitationStyle`.--  * `WriterOptions` now includes `writerEpubVersion`, `writerEpubChapterLevel`,-    `writerEpubStylesheet`, `writerEpubFonts`, `writerReferenceODT`,-    `writerReferenceDocx`, and `writerTOCDepth`.  `writerEPUBMetadata` has-    been renamed `writerEpubMetadata` for consistency.--  * Changed signatures of `writeODT`, `writeDocx`, `writeEPUB`, since they no-    longer stylesheet, fonts, reference files as separate parameters.--  * Removed `writerLiterateHaskell` from `WriterOptions`, and-    `readerLiterateHaskell` from `ReaderOptions`.  LHS is now handled-    by an extension (`Ext_literate_haskell`).--  * Removed deprecated `writerXeTeX`.--  * Removed `writerStrict` from `WriterOptions`.  Added `writerExtensions`.-    Strict is now handled through extensions.--  * `Text.Pandoc.Options` exports `pandocExtensions`, `strictExtensions`,-    `phpMarkdownExtraExtensions`, `githubMarkdownExtensions`,-    and `multimarkdownExtensions`, as well as the `Extensions` type.--  * New `Text.Pandoc.Readers.MediaWiki` module, exporting-    `readMediaWiki`.--  * New `Text.Pandoc.Writers.FB2` module, exporting `writeFB2`-    (thanks to Sergey Astanin).--  * `Text.Pandoc`:--    + Added `getReader`, `getWriter` to `Text.Pandoc`.-    + `writers` is now an association list `(String, Writer)`.-      A `Writer` can be a `PureStringWriter`, an `IOStringWriter`, or-      an `IOByteStringWriter`.  ALL writers are now in the 'writers'-      list, including the binary writers and FB2 writer.  This allows-      code in `pandoc.hs` to be simplified.-    + Changed type of `readers`, so all readers are in IO.-      Users who want pure readers can still get them form the reader-      modules; this just affects the function `getReader` that looks up-      a reader based on the format name.  The point of this change is to-      make it possible to print warnings from the parser.--  * `Text.Pandoc.Parsing`:--    + `Text.Parsec` now exports all Parsec functions used in pandoc code.-      No other module directly imports Parsec.  This will make it easier-      to change the parsing backend in the future, if we want to.-    + `Text.Parsec` is used instead of `Text.ParserCombinators.Parsec`.-    + Export the type synonym `Parser`.-    + Export `widthsFromIndices`, `NoteTable'`, `KeyTable'`, `Key'`, `toKey'`,-     `withQuoteContext`, `singleQuoteStart`, `singleQuoteEnd`,-     `doubleQuoteStart`, `doubleQuoteEnd`, `ellipses`, `apostrophe`,-     `dash`, `nested`, `F(..)`, `askF`, `asksF`, `runF`, `lineBlockLines`.-    + `ParserState` is no longer an instance of `Show`.-    + Added `stateSubstitutions` and `stateWarnings` to `ParserState`.-    + Generalized type of `withQuoteContext`.-    + Added `guardEnabled`, `guardDisabled`, `getOption`.-    + Removed `failIfStrict`.-    + `lookupKeySrc` and `fromKey` are no longer exported.--  * `Data.Default` instances are now provided for `ReaderOptions`,-    `WriterOptions`, and `ParserState`.  `Text.Pandoc` re-exports `def`.-    Now you can use `def` (which is re-exported by `Text.Pandoc`) instead-    of `defaultWriterOptions` (which is still defined).  Closes #546.--  * `Text.Pandoc.Shared`:--    + Added `safeRead`.-    + Renamed `removedLeadingTrailingSpace` to `trim`,-      `removeLeadingSpace` to `triml`, and `removeTrailingSpace` to `trimr`.-    + Count `\r` as space in `trim` functions.-    + Moved `renderTags'` from HTML reader and `Text.Pandoc.SelfContained`-      to `Shared`.-    + Removed `failUnlessLHS`.-    + Export `compactify'`, formerly in Markdown reader.-    + Export `isTightList`.-    + Do not export `findDataFile`.-    + `readDataFile` now returns a strict ByteString.-    + Export `readDataFileUTF8` which returns a String, like the-      old `readDataFile`.-    + Export `fetchItem` and `openURL`.--  * `Text.Pandoc.ImageSize`: Use strict, not lazy bytestrings.-    Removed `readImageSize`.--  * `Text.Pandoc.UTF8`: Export `encodePath`, `decodePath`,-     `decodeArg`, `toString`, `fromString`, `toStringLazy`,-     `fromStringLazy`.--  * `Text.Pandoc.UTF8` is now an exposed module.--  * `Text.Pandoc.Biblio`:--    + csl parameter now a `String` rather than a `FilePath`.-    + Changed type of `processBiblio`.  It is no longer in the IO monad.-      It now takes a `Maybe Style` argument rather than parameters for CSL-      and abbrev filenames.  (`pandoc.hs` now calls the functions to parse-      the style file and add abbreviations.)--  * Markdown reader now exports `readMarkdownWithWarnings`.--  * `Text.Pandoc.RTF` now exports `writeRTFWithEmbeddedImages` instead of-    `rtfEmbedImage`.--  [bug fixes]--  * Make `--ascii` work properly with `--self-contained`.  Closes #568.--  * Markdown reader:--    + Fixed link parser to avoid exponential slowdowns.  Closes #620.-      Previously the parser would hang on input like this:--            [[[[[[[[[[[[[[[[[[hi--      We fixed this by making the link parser parser characters-      between balanced brackets (skipping brackets in inline code spans),-      then parsing the result as an inline list.  One change is that--            [hi *there]* bud](/url)--      is now no longer parsed as a link.  But in this respect pandoc behaved-      differently from most other implementations anyway, so that seems okay.--    + Look for raw html/latex blocks before tables.-      Otherwise the following gets parsed as a table:--            \begin{code}-            ---------------            -- My comment.-            \end{code}--      Closes #578.--  * RST reader:--    + Added support for `:target:` on `.. image::` blocks-      and substitutions.-    + Field list fixes:--        - Fixed field lists items with body beginning after a new line-          (Denis Laxalde).-        - Allow any char but ':' in names of field lists in RST reader-          (Denis Laxalde).-        - Don't allow line breaks in field names.-        - Require whitespace after field list field names.-        - Don't create empty definition list for metadata field lists.-          Previously a field list consisting only of metadata fields (author,-          title, date) would be parsed as an empty DefinitionList, which is-          not legal in LaTeX and not needed in any format.--    + Don't recognize inline-markup starts inside words.-      For example, `2*2 = 4*1` should not contain an emphasized-      section.  Added test case for "Literal symbols".  Closes #569.-    + Allow dashes as separator in simple tables.  Closes #555.-    + Added support for `container`, `compound`, `epigraph`,-      `rubric`, `highlights`, `pull-quote`.-    + Added support for `.. code::`.-    + Made directive labels case-insensitive.-    + Removed requirement that directives begin at left margin.-      This was (correctly) not in earlier releases; docutils doesn't-      make the requirement.-    + Added support for `replace::` and `unicode::` substitutions.-    + Ignore unknown interpreted roles.-    + Renamed image parser to `subst`, since it now handles all-      substitution references.--  * Textile reader:--    + Allow newlines before pipes in table.  Closes #654.-    + Fixed bug with list items containing line breaks.-      Now pandoc correctly handles hard line breaks inside list items.-      Previously they broke list parsing.-    + Implemented comment blocks.-    + Fixed bug affected words ending in hyphen.-    + Properly handle links with surrounding brackets.-      Square brackets need to be used when the link isn't surrounded by-      spaces or punctuation, or when the URL ending may be ambiguous.-      Closes #564.-    + Removed nullBlock.  Better to know about parsing problems than-      to skip stuff when we get stuck.-    + Allow ID attributes on headers.-    + Textile reader:  Avoid parsing dashes as strikeout.-      Previously the input--            text---            text---            text---            text----      would be parsed with strikeouts rather than dashes. This fixes-      the problem by requiring that a strikeout delimiting - not be-      followed by a -.  Closes #631.-    + Expanded list of `stringBreakers`.-      This fixes a bug on input like "(_hello_)" which should-      be a parenthesized emphasized "hello".-      The new list is taken from the PHP source of textile 2.4.-    + Fixed autolinks.  Previously the textile reader and writer-      incorrectly implented RST-style autolinks for URLs and email-      addresses.  This has been fixed.  Now an autolink is done this way:-      `"$":http://myurl.com`.-    + Fixed footnotes bug in textile.  This affected notes occurring-      before punctuation, e.g. `foo[1].`.  Closes #518.--  * LaTeX reader:--    + Better handling of citation commands.-    + Better handling of `\noindent`.-    + Added a 'try' in rawLaTeXBlock, so we can handle `\begin` without `{`.-      Closes #622.-    + Made `rawLaTeXInline` try to parse block commands as well.  This-      is usually what we want, given how `rawLaTeXInline` is used in-      the markdown and textile readers.  If a block-level LaTeX command-      is used in the middle of a paragraph (e.g. `\subtitle` inside a title),-      we can treat it as raw inline LaTeX.-    + Handle \slash command.  Closes #605.-    + Basic `\enquote` support.-    + Fixed parsing of paragraphs beginning with a group.  Closes #606.-    + Use curly quotes for bare straight quotes.-    + Support obeylines environment.  Closes #604.-    + Guard against "begin", "end" in inlineCommand and-      blockCommand.-    + Better error messages for environments.  Now it should tell you that-      it was looking for \end{env}, instead of giving "unknown parse error."--  * HTML reader:--    + Added HTML 5 tags to list of block-level tags.-    + HTML reader: Fixed bug in `htmlBalanced`, which-      caused hangs in parsing certain markdown input using-      strict mode.-    + Parse `<q>` as `Quoted DoubleQuote`.-    + Handle nested `<q>` tags properly.-    + Modified `htmlTag` for fewer false positives.-      A tag must start with `<` followed by `!`,`?`, `/`, or a letter.-      This makes it more useful in the wikimedia and markdown parsers.--  * DocBook reader: Support title in "figure" element.  Closes #650.--  * MediaWiki writer:--    + Remove newline after `<br/>` in translation of `LineBreak`-      There's no particular need for a newline (other than making the-      generated MediaWiki source look nice to a human), and in fact-      sometimes it is incorrect: in particular, inside an enumeration, list-      items cannot have embedded newline characters. (Brent Yorgey)-    + Use `<code>` not `<tt>` for Code.--  * Man writer: Escape `-` as `\-`.-    Unescaped `-`'s become hyphens, while `\-`'s are left as ascii minus-    signs.  That is preferable for use with command-line options.  See-    <http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html>.  Thanks-    to Andrea Bolognani for bringing the issue to our attention.--  * RST writer:--    + Improved line block output. Use nonbreaking spaces for-      initial indent (otherwise lost in HTML and LaTeX).-      Allow multiple paragraphs in a single line block.-      Allow soft breaks w continuations in line blocks.-    + Properly handle images with no alt text.  Closes #678.-    + Fixed bug with links with duplicate text.  We now (a) use anonymous-      links for links with inline URLs, and (b) use an inline link instead-      of a reference link if the reference link would require a label that-      has already been used for a different link.  Closes #511.-    + Fixed hyperlinked images. Closes #611. Use `:target:`-      field when you have a simple linked image.-    + Don't add `:align: center` to figures.--  * Texinfo writer:  Fixed internal cross-references.-    Now we insert anchors after each header, and use `@ref` instead of `@uref`-    for links.  Commas are now escaped as `@comma{}` only when needed;-    previously all commas were escaped.  (This change is needed, in part,-    because `@ref` commands must be followed by a real comma or period.) Also-    insert a blank line in from of `@verbatim` environments.--  * DocBook writer:--    + Made --id-prefix work in DocBook as well as HTML.-      Closes #607.-    + Don't include empty captions in figures.  Closes #581.--  * LaTeX writer:--    + Use `\hspace*` for nonbreaking space after line break,-      since `~` spaces after a line break are just ignored.-      Closes #687.-    + Don't escape `_` in URLs or hyperref identifiers.-    + Properly escape strings inside \url{}.  Closes #576.-    + Use `[fragile]` only for slides containing code rendered-      using listings. Closes #649.-    + Escape `|` as `\vert` in LaTeX math.  This avoids a clash with-      highlighting-kate's macros, which redefine `|` as a short verbatim-      delimiter.  Thanks to Björn Peemöller for raising this issue.-    + Use minipage rather than parbox for block containers in tables.-      This allows verbatim code to be included in grid tables.-      Closes #663.-    + Prevent paragraphs containing only linebreaks or spaces.--  * HTML writer:--    + Included `highlighting-css` for code spans, too.-      Previously it was only included if used in a code block.  Closes #653.-    + Improved line breaks with `<dd>` tags.  We now put a newline between-      `</dd>` and `<dd>` when there are multiple definitions.-    + Changed mathjax cdn url so it doesn't use https.  (This caused-      problems when used with `--self-contained`.) See #609.--  * EPUB writer:--    + `--number-sections` now works properly.-    + Don't strip meta and link elements in epub metadata.-      Patch from aberrancy. Closes #589.-    + Fixed a couple validation bugs.-    + Use ch001, ch002, etc. for chapter filenames.  This improves sorting-      of chapters in some readers, which apparently sort ch2 after ch10.-      Closes #610.--  * ODT writer: properly set title property (Arlo O'Keeffe).--  * Docx writer:--    + Fixed bug with nested lists.  Previously a list like--            1. one-                - a-                - b-            2. two--      would come out with a bullet instead of "2."-      Thanks to Russell Allen for reporting the bug.-    + Use `w:cr` in `w:r` instead of `w:br` for linebreaks.-      This seems to fix a problem viewing pandoc-generated-      docx files in LibreOffice.-    + Use integer ids for bookmarks.  Closes #626.-    + Added nsid to abstractNum elements.  This helps when merging-      word documents with numbered or bulleted lists.  Closes #627.-    + Use separate footnotes.xml for notes.-      This seems to help LibreOffice convert the file, even though-      it was valid docx before.  Closes #637.-    + Use rIdNN identifiers for r:embed in images.-    + Avoid reading image files again when we've already processed them.-    + Fixed typo in `referenc.docx` that prevented image captions from-      working. Thanks to Huashan Chen.--  * `Text.Pandoc.Parsing`:--    + Fixed bug in `withRaw`, which didn't correctly handle the case-      where nothing is parsed.-    + Made `emailAddress` parser more correct.  Now it is based on RFC 822,-      though it still doesn't implement quoted strings in email addresses.-    + Revised URI parser.  It now allows many more schemes, allows-      uppercase URIs, and better handles trailing punctuation and-      trailing slashes in bare URIs.  Added many tests.-    + Simplified and improved singleQuoteStart.  This makes `'s'`, `'l'`,-      etc. parse properly.  Formerly we had some English-centric heuristics,-      but they are no longer needed. Closes #698.--  * `Text.Pandoc.Pretty`:  Added wide punctuation range to `charWidth`.-    This fixes bug with Chinese commas in markdown and reST tables, and-    a bug that caused combining characters to be dropped.--  * `Text.Pandoc.MIME`: Added MIME types for .wof and .eot.  Closes #640.--  * `Text.Pandoc.Biblio`:--    + Run `mvPunc` and `deNote` on metadata too.-      This fixed a bug with notes on titles using footnote styles.-    + Fixed bug in fetching CSL files from CSL data directory.--  * `pandoc.hs`:  Give correct value to `writerSourceDirectory` when a URL-    is provided.  It should be the URL up to the path.--  * Fixed/simplified diff output for tests.-    Biblio: Make sure mvPunc and deNote run on metadata too.-    This fixed a bug with notes on titles using footnote styles.--  [under the hood improvements]--  * We no longer depend on `utf8-string`.  Instead we use functions-    defined in `Text.Pandoc.UTF8` that use `Data.Text`'s conversions.--  * Use `safeRead` instead of using `reads` directly (various modules).--  * "Implicit figures" (images alone in a paragraph) are now handled-    differently.  The markdown reader gives their titles the prefix `fig:`; the-    writers look for this before treating the image as a figure.  Though this-    is a bit of a hack, it has two advantages: (i) implicit figures can be-    limited to the markdown reader, and (ii) they can be deactivated by turning-    off the `implicit_figures` extension.--  * `catch` from `Control.Exception` is now used instead of the-    old Preface `catch`.--  * `Text.Pandoc.Shared`:  Improved algorithm for `normalizeSpaces`-    and `oneOfStrings` (which is now non-backtracking).--  * `Text.Pandoc.Biblio`: Remove workaround for `toCapital`.-    Now citeproc-hs is fixed upstream, so this is no longer needed.-    Closes #531.--  * Textile reader: Improved speed of `hyphenedWords`.-    This speeds up the textile  reader by about a factor of 4.--  * Use `Text.Pandoc.Builder` in RST reader, for more flexibility,-    better performance, and automatic normalization.--  * Major rewrite of markdown reader:--    + Use `Text.Pandoc.Builder` instead of lists.  This also-      means that everything is normalized automatically.-    + Move to a one-pass parsing strategy, returning values in the reader-      monad, which are then run (at the end of parsing) against the final-      parser state.--  * In HTML writer, we now use `toHtml` instead of pre-escaping.-    We work around the problem that blaze-html unnecessarily escapes `'`-    by pre-escaping just the `'` characters, instead of the whole string.-    If blaze-html later stops escaping `'` characters, we can simplify-    `strToHtml` to `toHtml`.  Closes #629.--  * Moved code for embedding images in RTFs from `pandoc.hs` to the-    RTF writer (which now exports `writeRTFWithEmbeddedImages`).--  * Moved citation processing from `pandoc.hs` into the readers.-    This makes things more convenient for library users.--  * The man pages are now built by an executable `make-pandoc-man-pages`,-    which has its own stanza in the cabal file so that dependencies can be-    handled by Cabal. Special treatment in `Setup.hs` ensures that this-    executable never gets installed; it is only used to create the man pages.--  * The cabal file has been modified so that the pandoc library is used-    in building the pandoc executable.  (This required moving `pandoc.hs`-    from `src` to `.`.)  This cuts compile time in half.--  * `-O2` is no longer used in building pandoc.  The performance improvement-    it yields is so slight that it is not worth it.  (Measured with-    benchmarks on ghc 7.4.)--  * The `executable` and `library` flags have been removed.--  * `-threaded` has been removed from ghc-options.--  * Version bounds of dependencies have been raised, and the-    `blaze_html_0_5` flag now defaults to True.  Pandoc now compiles on-    GHC 7.6.--  * We now require base >= 4.2.--  * Integrated the benchmark program into cabal.  One can now do:--        cabal configure --enable-benchmarks && cabal build-        cabal bench --benchmark-option='markdown' --benchmark-option='-s 20'--    The benchmark now uses README + testsuite, so benchmark results-    from older versions aren't comparable.--  * Integrated test suite with cabal.-    To run tests, configure with `--enable-tests`, then `cabal test`.-    You can specify particular tests using `--test-options='-t markdown'`.-    No output is shown unless tests fail.  The Haskell test modules-    have been moved from `src/` to `tests/`.--  * Moved all data files and templates to the `data/` subdirectory.--  * Added an `embed_data_files` cabal flag.  This causes all-    data files to be embedded in the binary, so that the binary-    is self-sufficient and can be relocated anywhere, copied on-    a USB key, etc.  The Windows installer now uses this.-    (Since we no longer have the option to build the executable-    without the library, this is the only way to get a relocatable-    binary on Windows.)--  * Removed pcre3.dll from windows package.-    It isn't needed unless highlighting-kate is compilled with the-    `pcre-light` flag. By default, regex-prce-builtin is used.---pandoc (1.9.4.2)--  * Don't encode/decode file paths if base >= 4.4.-    Prior to base 4.4, filepaths and command line arguments were treated-    as unencoded lists of bytes, not unicode strings, so we had to work-    around that by encoding and decoding them. This commit adds CPP-    checks for the base version that intelligibly enable encoding/decoding-    when needed. Fixes a bug with multilingual filenames when pandoc was-    compiled with ghc 7.4 (#540).--  * Don't generate an empty H1 after hrule slide breaks.-    We now use a slide-level header with contents `[Str "\0"]` to mark-    an hrule break.  This avoids creation of an empty H1 in these-    contexts.  Closes #484.--  * Docbook reader: Added support for "bold" emphasis.  Thanks to Mauro Bieg.--  * In make_osx_package.sh, ensure citeproc-hs is built with the-    embed_data_files flag.--  * MediaWiki writer: Avoid extra blank lines after sublists (Gavin Beatty).--  * ConTeXt writer: Don't escape `&`, `^`, `<`, `>`, `_`,-    simplified escapes for `}` and `{` to `\{` and `\}` (Aditya Mahajan).--  * Fixed handling of absolute URLs in CSS imports with `--self-contained`.-    Closes #535.--  * Added webm to mime types. Closes #543.--  * Added some missing exports and tests to the cabal file-    (Alexander V Vershilov).--  * Compile with `-rtsopts` and `-threaded` by default.--pandoc (1.9.4.1)--  * Markdown reader: Added `cf.` and `cp.` to list of likely abbreviations.--  * LaTeX template: Added `linkcolor`, `urlcolor` and `links-as-notes`-    variables.  Make TOC links black.--  * LaTeX template improvements.--    + Don't print date unless one is given explicitly in the document.-    + Simplified templates.-    + Use fontenc [T1] by default, and lmodern.-    + Use microtype if available.--  * Biblio:--    + Add comma to beginning of bare suffix, e.g. `@item1 [50]`.-      Motivation: `@item1 [50]` should be as close as possible to-      `[@item1, 50]`.-    + Added workaround for a bug in citeproc-hs 0.3.4 that causes footnotes-      beginning with a citation to be empty.  Closes #531.--  * Fixed documentation on mixed lists.  Closes #533.--pandoc (1.9.4)--  * Simplified `Text.Pandoc.Biblio` and fixed bugs with citations inside-    footnotes and captions.  We now handle note citations by inserting-    footnotes during initial citation processing, and doing a separate-    pass later to remove notes inside notes.--  * Added 'zenburn' highlight style from highlighting-kate.--  * Added Slideous writer. Slideous is an HTML + javascript slide show-    format, similar to Slidy, but works with IE 7. (Jonas Smedegaard)--  * LaTeX writer:--    + Ensure we don't have extra blank lines at ends of cells.-      This can cause LaTeX errors, as they are interpreted as new paragraphs.-    + More consistent interblock spacing.-    + Require highlighting-kate >= 0.5.1, for proper highlighted inline-      code in LaTeX.  Closes #527.-    + Ensure that a Verbatim at the end of a footnote is followed by-      a newline. (Fixes a regression in the previous version.)-    + In default template, use black for internal links and TOC.-      Added commented-out code to use footnotes for links, as would-      be suitable in print output.--  * Beamer writer:  When `--incremental` is used, lists inside-    a block quote should appear all at once.  (This makes Beamer-    output consistent with the HTML slide show formats.)--  * ConTeXt writer:--    + Escape `%` as `\letterpercent{}` not `\letterpercent `,-      to avoid gobbling spaces after the `%` sign.-    + Ensure space after `\stopformula`.--  * Markdown writer:--    + Use `:` form instead of `~` in definition lists, for better-      compatibility with other markdown implementations.-    + Don't wrap the term, because it breaks definition lists.-    + Use a nonzero space to prevent false recognition-      of list marker in ordered lists.  Closes #516.--  * Org writer: Add space before language name.  Closes #523.--  * Docx writer: Simplified bullet characters so they work properly-    with Word 2007. Closes #520.--  * LaTeX reader: Support `\centerline`.--  * RST reader:  handle figures.  Closes #522.--  * Textile reader: fix for `<notextile>` and `==`.  Closes #517.-    (Paul Rivier)--pandoc (1.9.3)--  * Fixed bug in `fromEntities`.  The previous version would turn-    `hi & low you know;` into `hi &`.--  * HTML reader:--    + Don't skip nonbreaking spaces.-      Previously a paragraph containing just `&nbsp;` would be rendered-      as an empty paragraph. Thanks to Paul Vorbach for pointing out the bug.-    + Support `<col>` and `<caption>` in tables. Closes #486.--  * Markdown reader:--    + Don't recognize references inside delimited code blocks.-    + Allow list items to begin with lists.--  * Added basic docbook reader (John MacFarlane and Mauro Bieg).--  * LaTeX reader:--    + Handle `\bgroup`, `\egroup`, `\begingroup`, `\endgroup`.-    + Control sequences can't be followed by a letter.-      This fixes a bug where `\begingroup` was parsed as `\begin`-      followed by `group`.-    + Parse 'dimension' arguments to unknown commands.  e.g. `\parindent0pt`-    + Make `\label` and `\ref` sensitive to `--parse-raw`.-      If `--parse-raw` is selected, these will be parsed as raw latex-      inlines, rather than bracketed text.-    + Don't crash on unknown block commands (like `\vspace{10pt}`)-      inside `\author`; just skip them.  Closes #505.--  * Textile reader:--    + Implemented literal escapes with `==` and `<notextile>`.  Closes #473.-    + Added support for LaTeX blocks and inlines (Paul Rivier).-    + Better conformance to RedCloth inline parsing (Paul Rivier).-    + Parse '+text+' as emphasized (should be underlined, but this-      is better than leaving literal plus characters in the output.--  * Docx writer: Fixed multi-paragraph list items.  Previously they each-    got a list marker.  Closes #457.--  * LaTeX writer:--    + Added `--no-tex-ligatures` option to avoid replacing-      quotation marks and dashes with TeX ligatures.-    + Use `fixltx2e` package to provide '\textsubscript'.-    + Improve spacing around LaTeX block environments:-      quote, verbatim, itemize, description, enumerate.-      Closes #502.-    + Use blue instead of pink for URL links in latex/pdf output.--  * ConTeXt writer: Fixed escaping of `%`.-    In text, `%` needs to be escaped as `\letterpercent`, not `\%`-    Inside URLs, `%` needs to be escaped as `\%`-    Thanks to jmarca and adityam for the fix.  Closes #492.--  * Texinfo writer:  Escape special characters in node titles.-    This fixes a problem pointed out by Joost Kremers.  Pandoc used-    to escape an '@' in a chapter title, but not in the corresponding-    node title, leading to invalid texinfo.--  * Fixed document encoding in texinfo template.-    Resolves Debian Bug #667816.--  * Markdown writer:--    + Don't force delimited code blocks to be flush left.-      Fixes bug with delimited code blocks inside lists etc.-    + Escape `<` and `$`.--  * LaTeX writer: Use `\hyperref[ident]{text}` for internal links.-    Previously we used `\href{\#ident}{text}`, which didn't work on-    all systems. Thanks to Dirk Laurie.--  * RST writer: Don't wrap link references.  Closes #487.--  * Updated to use latest versions of blaze-html, mtl.---pandoc (1.9.2)--  * LaTeX reader:--    + Made `lstlisting` work as a proper verbatim environment.-    + Fixed bug parsing LaTeX tables with one column.--  * LaTeX writer:--    + Use `{}` around `ctable` caption, so that formatting can be used.-    + Don't require eurosym package unless document has a €.--  * LaTeX template: Added variables for `geometry`, `romanfont`,-    `sansfont`, `mathfont`, `mainfont` so users can more easily-    customize fonts.--  * PDF writer:--    + Run latex engine at least two times, to ensure-      that PDFs will have hyperlinked bookmarks.-    + Added PDF metadata (title,author) in LaTeX standalone + PDF output.--  * Texinfo writer: retain directories in image paths.  (Peter Wang)--  * RST writer:  Better handling of inline formatting, in accord-    with docutils' "inline markup recognition rules" (though we don't-    implement the unicode rules fully). Now `hi*there*hi` gets-    rendered properly as `hi\ *there*\ hi`, and unnecessary-    `\ ` are avoided around `:math:`, `:sub:`, `:sup:`.--  * RST reader:--    + Parse `\ ` as null, not escaped space.-    + Allow `` :math:`...` `` even when not followed by blank-      or `\`.  This does not implement the complex rule docutils follows,-      but it should be good enough for most purposes.-    + Add support for the rST default-role directive. (Greg Maslov)--  * Text.Pandoc.Parsing: Added `stateRstDefaultRole` field to `ParserState`.-    (Greg Maslov)--  * Markdown reader: Properly handle citations nested in other inline-    elements.--  * Markdown writer:  don't replace empty alt in image with "image".--  * DZSlides:  Updated template.html and styles in default template.-    Removed bizarre CSS for `q` in dzslides template.--  * Avoid repeated `id` attribute in section and header in HTML slides.--  * README improvements:  new instructions on internal links,-    removed misleading note on reST math.--  * Build system:--    + Fixed Windows installer so that dzslides works.-    + Removed stripansi.sh.-    + Added .travis.yml for Travis continuous integration support..-    + Fixed upper bound for zlib (Sergei Trofimovich).-    + Fixed upper bound for test-framework.-    + Updated haddocks for haddock-2.10 (Sergei Trofimovich).--pandoc (1.9.1.2)--  * Added `beamer+lhs` as output format.--  * Don't escape `<` in `<style>` tags with `--self-contained`.-    This fixes a bug which prevented highlighting from working-    when using `--self-contained`.--  * PDF: run latex engine three times if `--toc` specified.-    This fixes page numbers in the table of contents.--  * Docx writer: Added TableNormal style to tables.--  * LaTeX math environment fixes. `aligned` is now used instead of-    the nonexistent `aligned*`. `multline` instead of the nonexistent-    `multiline`.--  * LaTeX writer: Use `\textasciitilde` for literal `~`.--  * HTML writer: Don't escape contents of EQ tags with --gladtex.-    This fixes a regression from 1.8.--  * Use `<q>` tags for Quoted items for HTML5 output.-    The quote style can be changed by modifying the template-    or including a css file. A default quote style is included.--  * LaTeX reader: Fixed accents (\~{a}, `\c{c}`).-    Correctly handle \^{}. Support "minted" as a LaTeX verbatim block.--  * Updated LaTeX template for better language support.-    Use `polyglossia` instead of `babel` with xetex.-    Set `lang` as documentclass option.-    `\setmainlanguage` will use the last of a comma-separated-    list of languages. Thanks to François Gannaz.--  * Fixed default LaTeX template so `\euro` and `€` work.  The-    `eurosym` package is needed if you are using pdflatex.--  * Fixed escaping of period in man writer (thanks to Michael Thompson).--  * Fixed list label positions in beamer.--  * Set `mainlang` variable in context writer.-    This parallels behavior of latex writer.  `mainlang` is the last-    of a comma-separated list of languages in lang.--  * EPUB language metadat: convert e.g. `en_US` from locale to `en-US`.--  * Changed `-V` so that you can specify a key without a value.-    Such keys get the value `true`.--  * Fixed permissions on installed man pages - thanks Magnus Therning.--  * Windows installer: require XP or higher.  The installer is-    now compiled on a Windows 7 machine, which fixes a problem-    using citation functions on Windows 7.--  * OSX package: Check for 64-bit Intel CPU before installing.--pandoc (1.9.1.1)--  * Better handling of raw latex environments in markdown.  Now--        \begin{equation}-        a_1-        \end{equation}--    turns into a raw latex block as expected.--  * Improvements to LaTeX reader:--    + Skip options after block commands.-    + Correctly handle `{\\}` in braced.-    + Added a needed 'try'.-    + Citations: add `, ` to suffix if it doesn't start with space or-      punctuation. Otherwise we get no space between the year and the-      suffix in author-date styles.--  * Added two needed data files for S5.  This fixes a problem with-    `pandoc -t s5 --self-contained`.  Also removed `slides.min.js`,-    which was no longer being used.--  * Fixed some minor problems in `reference.docx`:-    name on "Date" style, `xCs` instead of `xIs`.--  * Fixed a problem creating docx files using a reference docx-    modified using Word.  The problem seems to be that Word-    modifies `_rels/.rels`, changing the Type of the Relationship to-    `docProps/core.xml`. Pandoc now changes this back to the correct-    value if it has been altered, fixing the problem.--  * Fixed html5 template so it works properly with highlighting.--pandoc (1.9.1)--  * LaTeX reader:--    + Fixed regression in 1.9; properly handle escaped $ in latex math.-    + Put LaTeX verse environments in blockquotes.--  * Markdown reader:--    + Limit nesting of strong/emph.  This avoids exponential lookahead-      in parasitic cases, like `a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**`.-    + Improved attributes syntax (inn code blocks/spans):-      (1) Attributes can contain line breaks. (2) Values in key-value-      attributes can be surrounded by either double or single quotes, or-      left unquoted if they contain no spaces.--  * Don't wrap headers in markdown or RST writers.--  * Added `stateMaxNestingLevel` to `ParserState`.-    We set this to 6, so you can still have `Emph` inside `Emph`,-    just not indefinitely.--  * More efficient implementation of `nowrap` in `Text.Pandoc.Pretty`.--  * `Text.Pandoc.PDF`:  Only run latex twice if `\tableofcontents`-    is present.--  * Require highlighting-kate >= 0.5.0.2, texmath >= 0.6.0.2.--pandoc (1.9.0.5)--  * Changed cabal file so that build-depends for the test program-    are not required unless the tests flag is used.--  * LaTeX writer:  insert `{}` between adjacent hyphens so they don't-    form ligatures (dashes) in code spans.--pandoc (1.9.0.4)--  * Raised version bound on test-framework to avoid problems-    compiling tests on GHC 7.4.1.--  * LaTeX reader: Use raw LaTeX as fallback inline text for Cites,-    so citations don't just disappear unless you process with-    citeproc.  Ignore `\bibliographystyle`, `\nocite`.--  * Simplified tex2pdf; it will always run latex twice to-    resolve table of contents and hyperrefs.--pandoc (1.9.0.3)--  * Require Cabal >= 1.10.-  * Tweaked cabal file to meet Cabal 1.10 requirements.--pandoc (1.9.0.2)--  * Allow build with json 0.4 or 0.5.  Otherwise we can't build with-    ghc 6.12.--pandoc (1.9)--  [new features]--  * Added a Microsoft Word `docx` writer. The writer includes support-    for highlighted code and for math (which is converted from TeX to OMML,-    Office's native math markup language, using texmath's new OMML module).-    A new option `--reference-docx` allows the user to customize the-    styles.--  * Added an `asciidoc` writer (<http://www.methods.co.nz/asciidoc/>).--  * Better support for slide shows:--    + Added a `dzslides` writer. DZSlides is a lightweight HTML5/javascript-      slide show format due to Paul Rouget (<http://paulrouget.com/dzslides/>).--    + Added a LaTeX `beamer` writer. Beamer is a LaTeX package for creating-      slide presentations.--    + New, flexible rules for dividing documents into sections and slides-      (see the "Structuring the slide show" in the User's Guide).  These-      are backward-compatible with the old rules, but they allow slide-      shows to be organized into sections and subsections containing-      multiple slides.--    + A new `--slide-level` option allows users to override defaults-      and select a slide level below the first header level with content.--  * A new `--self-contained` option produces HTML output that does not-    depend on an internet connection or the presence of any external-    files. Linked images, CSS, and javascript is downloaded (or fetched-    locally) and encoded in `data:` URIs. This is useful for making portable-    `HTML slide shows. The --offline` option has been deprecated and is now-    `treated as a synonym or --self-contained`.--  * Support for PDF output:--    + Removed the old `markdown2pdf`.-    + `pandoc` can now create PDFs (assuming you have latex and a set of-      appropriate packages installed): just specify an output file with the-      `.pdf` extension.-    + A new option `--latex-engine` allows you to specify `pdflatex`,-      `xelatex`, or `lualatex` as the processor.--  * Highlighting changes:--    + Syntax highlighting is now a standard feature; the `highlighting`-      flag is no longer needed when compiling.-    + A new `--no-highlight` option allows highlighting to be disabled.-    + Highlighting now works in `docx`, `latex`, and `epub`, as well as-      `html`, `html5`, `dzslides`, `s5`, and `slidy`.-    + A new `--highlight-style` option selects between various highlighting-      color themes.--  * Internal links to sections now work in ConTeXt and LaTeX as well as HTML.--  * LaTeX `\include` and `\usepackage` commands are now processed,-    provided the files are in the working directory.--  * EPUB improvements:--    + Internal and external links now work in EPUB.-    + Raw HTML is allowed.-    + New `--epub-embed-font` option.-    + Customizable templates for EPUB pages offer more control over-      formatting: `epub-page.html`, `epub-coverimage.html`,-      `epub-titlepage.html`.--  * `--mathml` now works with DocBook.--  * Added support for math in RST reader and writer.  Inline math uses the-    `` :math:`...` `` construct.  Display math uses--        .. math:: ...--    or if the math is multiline,--        .. math::--           ...--    These constructions are now supported now by `rst2latex.py`.--  * GitHub syntax for fenced code blocks is supported in pandoc's-    markdown.  You can now write--        ```ruby-        x = 2-        ```--    instead of--        ~~~ {.ruby}-        x = 2-        ~~~~--  * Easier scripting:  a new `toJsonFilter` function makes it easier to-    write Haskell scripts to manipulate the Pandoc AST.--  [behavior changes]--  * Fixed parsing of consecutive lists in markdown.-    Pandoc previously behaved like Markdown.pl for consecutive-    lists of different styles. Thus, the following would be parsed-    as a single ordered list, rather than an ordered list followed-    by an unordered list:--        1. one-        2. two--        - one-        - two--    This change makes pandoc behave more sensibly, parsing this as-    two lists.  Any change in list type (ordered/unordered) or in-    list number style will trigger a new list. Thus, the following-    will also be parsed as two lists:--        1. one-        2. two--        a. one-        b. two--    Since we regard this as a bug in Markdown.pl, and not something-    anyone would ever rely on, we do not preserve the old behavior-    even when `--strict` is selected.--  * Dashes work differently with `--smart`: `---` is always em-dash,-    and `--` is always en-dash.  Pandoc no longer tries to guess when-    `-` should be en-dash.  *Note:* This may change how existing documents-    look when processed with pandoc. A new option, `--old-dashes`,-    is provided for legacy documents.--  * The markdown writer now uses setext headers for levels 1-2.-    The old behavior (ATX headers for all levels) can be restored-    using the new `--atx-headers` option.--  * Links are now allowed in markdown image captions.  They are also-    allowed in links, but will appear there as regular text. So,--        [link with [link](/url)](/url)--    will turn into--        <p><a href="/url">link with link</a></p>--  * Improved handling of citations using `citeproc-hs-0.3.4`.-    Added `--citation-abbreviations` option.--  * Citation keys can no longer end with a punctuation character.-    This means that `@item1.` will be parsed as a citation with key-    'item1', followed by a period, instead of a citation with key-    'item1.', as was the case previously.--  * In HTML output, citations are now put in a span with class `citation`.--  * The markdown reader now recognizes DocBook block and inline tags.-    It was always possible to include raw DocBook tags in a markdown-    document, but now pandoc will be able to distinguish block from-    inline tags and behave accordingly. Thus, for example,--        <sidebar>-        hello-        </sidebar>--    will not be wrapped in `<para>` tags.--  * The LaTeX parser has been completely rewritten; it is now much more-    accurate, robust, and extensible. However, there are two important-    changes in how it treats unknown LaTeX. (1) Previously, unknown-    environments became BlockQuote elements; now, they are treated-    as "transparent", so `\begin{unknown}xyz\end{unknown}` is the-    same as `xyz`.  (2) Previously, arguments of unknown commands-    were passed through with their braces; now the braces are stripped-    off.--  * `--smart` is no longer selected automatically with `man` output.--  * The deprecated `--xetex` option has been removed.--  * The `--html5`/`-5` option has been deprecated. Use `-t html5`-    instead. `html5` and `html5+lhs` are now separate output formats.--  * Single quotes are no longer escaped in HTML output.  They do not-    need to be escaped outside of attributes.--  * Pandoc will no longer transform leading newlines in code-    blocks to `<br/>` tags.--  * The ODT writer now sizes images appropriately, using the image-    size and DPI information embedded in the image.--  * `--standalone` is once again implicitly for a non-text output format-    (ODT, EPUB).  You can again do `pandoc test.txt -o test.odt`-    and get a standalone ODT file.--  * The Docbook writer now uses `<sect1>`, `<sect2>`, etc. instead of-    `<section>`.--  * The HTML writer now uses `<del>` for strikeout.--  * In HTML output with `--section-divs`, the classes `section` and-    `level[1,2,..6]` are put on the `div` tags so they can be styled.-    In HTML 5 output with `--section-divs`, the classes-    `level[1,2,...6]` are put on `section` tags.--  * EPUB writer changes:--    + The `lang` variable now sets the language-      in the metadata (if it is not set, we default to the locale).-    + EPUB:  UTF-8 is used rather than decimal entities.--  * Added `titleslide` class to title slide in S5 template.--  * In HTML, EPUB, and docx metadata, the date is normalized into-    YYYY-MM-DD format if possible. (This is required for validation.)--  * Attributes in highlighted code blocks are now preserved in HTML.-    The container element will have the classes, id, and key-value attributes-    you specified in the delimited code block. Previously these were stripped-    off.--  * The reference backlink in the HTML writer no longer has a special-    `footnoteBacklink` class.--  * The HTML template has been split into `html` and `html5` templates.--  * Author and date are treated more consistently in HTML templates.-    Authors are now `<h2>`, date `<h3>`.--  * URLs are hyphenated in the ConTeXt writer (B. Scott Michel).--  * In `Text.Pandoc.Builder`, `+++` has been replaced by `<>`.--  [bug fixes]--  * Better support for combining characters and East Asian wide characters-    in markdown and reST.--  * Better handling of single quotes with `--smart`.-    Previously `D'oh l'*aide*` would be parsed with left and right single-    quotes instead of apostrophes. This kind of error is now fixed.--  * Highlighting: Use `reads` instead of `read` for better error handling.-    Fixes crash on `startNum="abc"`.--  * Added blank comment after directives in rst template.--  * Unescape entities in citation `refId`. The `refId`s coming-    from citeproc contain XML numeric entities, and these don't match with the-    citation keys parsed by pandoc. Solution is to unescape them.--  * HTML reader: Fixed bug parsing tables with both thead and tbody.--  * Markdown reader:--    + Better handling of escapes in link URLs and titles.-    + Fixed backslash escapes in reference links.-    + Fixed bug in table/hrule parsing, by checking that the top-      line of a table is not followed by a blank line. This bug caused-      slowdowns on some files with hrules and tables, as pandoc tried to-      interpret the hrules as the tops of multiline tables.-    + Fixed bug in code block attribute parser. Previously the ID attribute-      got lost if it didn't come first. Now attributes can come in any order.--  * RST reader: allow footnotes followed by newline without space characters.--  * LaTeX reader:--    + Ignore empty groups {}, { }.-    + LaTeX reader: Handle \@.-    + LaTeX reader:  Don't crash on commands like `\itemsep`.-    + LaTeX reader:  Better handling of letter environments.--  * RST writer: Fixed bug involving empty table cells. isSimple was being-    calculated in a way that assumed there were no non-empty cells.--  * ConTeXt writer:--    + Made `--toc` work even without `--number-sections`.-    + Escape # in link URLs.-    + Use buffering for footnotes containing code blocks.-    + Changed 'descr' to 'description', fixed alignment.--  * LaTeX writer:--    + Escape euro character.-    + Don't escape ~ inside href{...}.-    + Escape # in href URLs.-    + Improved detection of book classes.  We now check the-      `documentclass` variable, and if that is not set, we look through-      the template itself.  Also, we have added the KOMA classes scrreprt-      and scrbook.  You can now make a book using-      `pandoc -V documentclass:book mybook.txt -o mybook.pdf`-    + LHS files now set the "listings" variable, so that the definition-      of the `code` environment will be included in the template.-    + Links are colored blue by default (this can be changed by-      modifying `hyperref` settings in the template).-    + Added `lang` variable to LaTeX template.--  * HTML writer:--    + Fixed bug in HTML template with html5 and mathml.-    + Don't use self-closing img, br, hr tags for HTML5.-    + Use `<section>` for footnotes if HTML5.-    + Update HTML templates to use Content-Style-Type meta tag.-    + Use separate variables for meta-date, meta-author.-      This makes footnotes work in author and date fields.-    + Use 'vertical-align:middle' in WebTeX math for better alignment.--  * S5/slidy writer:  Make footnotes appear on separate slide at end.--  * MIME: Added 'layout-cache' to getMimeType. This ensures that the-    META-INF/manifest.xml for ODT files will have everything it needs, so-    that ODT files modified by LibreOffice can be used as `--reference-odt`.--  * `Text.Pandoc.Templates`: Return empty string for json template.--  * `Text.Pandoc.Biblio`:--    + Expand citations recursively inside nested inlines.-    + Treat `\160` as space when parsing locator and suffix.-      This fixes a bug with "p. 33" when `--smart` is used. Previously-      the whole "p. 33" would be included in the suffix, with no locator.-    + Put whole author-in-text citation in a Cite.  Previously just the-      date and other info went in the Cite.-    + Don't add comma+space to prefix if it ends in punctuation.--  * Updated chicago-author-date.csl.  The old version did not work-    properly for edited volumes with no author.--  * EPUB writer:--    + Add date to EPUB titlepage and metadata.-    + Added TOC identifier in EPUB page template.-    + Don't generate superfluous file `cover-image.jpg`.--  [under the hood improvements]--  * Modified `make_osx_package.sh` to use cabal-dev.-    Items are no longer installed as root.-    Man pages are zipped and given proper permissions.--  * Modified windows installer generator to use cabal-dev.--  * Setup: Making man pages now works with cabal-dev (at least on OSX). In-    Setup.hs we now invoke 'runghc' in a way that points it to the correct-    package databases, instead of always falling back to the default user-    package db.--  * Updated to work with GHC 7.4.1.--  * Removed dependency on old-time.--  * Removed dependency on dlist.--  * New slidy directory for "self-contained."--  * TeXMath writer:  Use unicode thin spaces for thin spaces.--  * Markdown citations: don't strip off initial space in locator.--  [API changes]--  * Removed `Apostrophe`, `EmDash`, `EnDash`, and `Ellipses`-    from the native `Inline` type in pandoc-types.  Now we use `Str`-    elements with unicode.--  * Improvements to `Text.Pandoc.Builder`:--    + `Inlines` and `Blocks` are now newtypes (not synonyms for-      sequences).-    + Instances are defined for `IsString`, `Show`, `Read`, `Monoid`,-      and a new `Listable` class, which allows these to be manipulated-      to some extent like lists. Monoid append includes automatic-      normalization.-    + `+++` has been replaced by `<>` (mappend).--  * Use blaze-html instead of xhtml for HTML generation.-    This changes the type of `writeHtml`.--  * `Text.Pandoc.Shared`:--    + Added `warn` and `err`.-    + Removed `unescapeURI`, modified `escapeURI`.-      (See under [behavior changes], above.)--  * Changes in URI escaping:  Previously the readers escaped URIs by-    converting unicode characters to octets and then percent encoding.-    Now unicode characters are left as they are, and `escapeURI` only-    percent-encodes space characters.  This gives more readable-    URIs, and works well with modern user agents. URIs are no longer unescaped-    at all on conversion to `markdown`, `asciidoc`, `rst`, `org`.--  * New module `Text.Pandoc.SelfContained`.--  * New module `Text.Pandoc.Docx`.--  * New module `Text.Pandoc.PDF`.--  * Added `writerBeamer` to `WriterOptions`.--  * Added `normalizeDate` to `Text.Pandoc.Shared`.--  * Added `splitStringWithIndices` in `Text.Pandoc.Shared`.-    This is like `splitWithIndices`, but it is sensitive to distinctions-    between wide, combining, and regular characters.--  * `Text.Pandoc.Pretty`:--    + Added `chomp` combinator.-    + Added `beforeNonBreak` combinator.  This allows you to include-      something conditionally on it being before a nonblank.-      Used for RST inline math.-    + Added `charWidth` function. All characters marked W or F in the unicode-      spec EastAsianWidth.txt get width 2.-    + Added `realLength`, based on `charWidth`. `realLength` is now-      used in calculating offsets.--  * New module `Text.Pandoc.Slides`, for common functions for breaking-    a document into slides.--  * Removed `Text.Pandoc.S5`, which is no longer needed.--  * Removed `Text.Pandoc.CharacterReferences`.  Moved-    `characterReference` to `Text.Pandoc.Parsing`.-    `decodeCharacterReferences` is replaced by `fromEntities`-    in `Text.Pandoc.XML`.--  * Added `Text.Pandoc.ImageSize`.  This is intened for use-    in `docx` and `odt` writers, so the size and dpi of images-    can be calculated.--  * Removed `writerAscii` in `WriterOptions`.--  * Added `writerHighlight` to `WriterOptions`.--  * Added `DZSlides` to `HTMLSlideVariant`.--  * `writeEPUB` has a new argument for font files to embed.--  * Added `stateLastStrPos` to `ParserState`. This lets us keep track-    of whether we're parsing the position immediately after a regular-    (non-space, non-symbol) string, which is useful for distinguishing-    apostrophes from single quote starts.--  * `Text.Pandoc.Parsing`:--    + `escaped` now returns a `Char`.-    + Removed `charsInBalanced'`, added a character parser as-      a parameter of `charsInBalanced`.  This is needed for-      proper handling of escapes, etc.-    + Added `withRaw`.--  * Added `toEntities` to `Text.Pandoc.XML`.--  * `Text.Pandoc.Readers.LaTeX`:--    + Export `handleIncludes`.-    + Export `rawLaTeXBlock` instead of `rawLaTeXEnvironment'`.--  * Added `ToJsonFilter` class and `toJsonFilter` function to-    `Text.Pandoc`, deprecating the old `jsonFilter` function.--  * `Text.Pandoc.Highlighting`:--     + Removed `highlightHtml`, `defaultHighlightingCss`.-     + Export `formatLaTeXInline`, `formatLaTeXBlock`, and `highlight`, plus-       key functions from highlighting-kate.-     + Changed types of highlighting function.  `highlight` returns a-       `Maybe`, not an `Either`.--pandoc (1.8.2.1)--  * Relaxed cabal consntraints for test-framework (S. Trofimovich).--  * Relaxed cabal constraints for pandoc-types.--  * Adjusted Arbitrary instance to help avoid timeouts in tests.--  * Added `Tests.Writers.Markdown` to cabal file.--pandoc (1.8.2)--  * Added script to produce OS X package.--  * Made `templates` directory a git submodule.  This should make it-    easier for people to revise their custom templates when the default-    templates change.--  * Changed template naming scheme: `FORMAT.template` -> `default.FORMAT`.-    **Note:** If you have existing templates in `~/.pandoc/templates`, you-    must rename them to conform to the new scheme!--  * Fixed smart quotes bug, now handling `'...hi'` properly.--  * RST reader:--    + Partial support for labeled footnotes.-    + Improved accuracy of `simpleReferenceName` parser.--  * HTML reader:--    + Substitute correct unicode characters for-      characters in the 128..159 range, which are often found even in-      HTML that purports to be UTF-8.--  * LaTeX reader:  Handle `\subtitle` command (a subtitle is added-    to the title, after a colon and linebreak). Closes #280.--  * Leaner `reference.odt`.--  * Added unexported module `Text.Pandoc.MIME` for use in-    the ODT writer.--  * ODT writer:  Construct `manifest.xml` based on archive contents.-    This fixes a bug in ODTs containing images. Recent versions of-    LibreOffice would reject these as corrupt, because `manifest.xml`-    did not contain a reference to the image files.--  * LaTeX writer:--    + Make verbatim environments flush to avoid spurious-      blank lines.  Closes #277.-    + Use `\texttt` and escapes insntead of `\verb!...!`, which-      is too fragile (doesn't work in command arguments).-    + Use `\enquote{}` for quotes if the template includes-      the `csquotes` package. This provides better support for-      local quoting styles. (Thanks to Andreas Wagner for the idea.)--  * ConTeXt writer:  Make `\starttyping`/`\stoptyping` flush with-    margin, preventing spurious blank lines.--  * Slidy writer:--    + Use non-minimized version of `slidy.css` with `--offline`-      option, so users can more easily edit it.-    + Also fixed a bug in the CSS that prevented proper centering-      of title (now reported and fixed upstream).--  * S5 writer:--    + Replaced `s5/default/slides.js.{comment,packed}` with-      new compressed `s5/default/slides.min.js`.-    + Use `data:` protocol to embed S5 CSS in `<link>` tags,-      when `--offline` is specified. Using inline CSS didn't-      work with Chrome or Safari.  This fixes offline-      S5 on those browsers.--  * HTML writer:  Removed English title on footnote backlinks.-    This is incongrous in non-English documents.--  * Docbook writer:--    + Use CALS tables.  (Some older docbook software does not work-      well with XHTML tables.)  Closes #77.-    + Use `programlisting` tags (instead of `screen`) for code blocks.--  * `markdown2pdf`:--    + Calls latex with `-halt-on-error -interaction nonstopmode` instead-      of `-interaction=batchmode`, which essentially just ignored errors,-      leading to bad results. Better to know when something is wrong.-    + Fixed issues with non-UTF-8 output of `pdflatex`.-    + Better error reporting.--  * `--mathjax` now takes an optional URL argument. If it is not-    provided, pandoc links directly to the (secure) mathjax CDN,-    as now recommended (thanks to dsanson).--  * Deprecated `--xetex` option in `pandoc`.  It is no longer needed,-    since the LaTeX writer now produces a file that can be processed by-    `latex`, `pdflatex`, `lualatex`, or `xelatex`.--  * Introduced `--luatex` option to `markdown2pdf`. This causes `lualatex`-    to be used to create the PDF.--  * If a template specified with `--template` is not found, look for it-    in `datadir`.  Also, if no extension is provided, supply one based-    on the writer.  So now you can put your `special.latex` template in-    `~/.pandoc/templates`, and use it from any directory via-    `pandoc -t latex --template special`.--  * Default template improvements:--    + HTML:  Display author and date after title.-    + HTML:  Made table of contents more customizable.  The container-      for the TOC is now in the template, so users can insert a header-      or other styling. (Thanks to Bruce D'Arcus for the suggestion.)-    + HTML, Slidy, S5:  Enclose scripts in CDATA tags.-    + Slidy, S5: Added `s5-url` and `slidy-url` variables, instead of-      hard-coding.  If you want to put your slidy files in the slidy-      subdirectory, for example, you can do-      `pandoc -t slidy -V slidy-url=slidy -s`.-    + LaTeX: Use `\and` to separate authors in LaTeX documents (reader-      & writer).  Closes #279.-    + LaTeX: Use different `hyperref` options for `xetex`, fixing-      problems with unicode bookmarks (thanks to CircleCode).-    + LaTeX: Removed `ucs` package, use `utf8` rather than `utf8x`-      with `inputenc`.  This covers fewer characters but is more-      robust with other packages, and `ucs` is unmaintained.  Users-      who need better unicode support should use xelatex or lualatex.--pandoc (1.8.1.2)--  * Added `--epub-cover-image` option.--  * Documented `--biblatex` and `--natbib` options.--  * Allow `--section-divs` with slidy output.  Resolves Issue #296.--  * Disallow notes within notes in reST and markdown.-    These previously caused infinite looping and stack overflows.-    For example:--        [^1]--        [^1]: See [^1]--    Note references are allowed in reST notes, so this isn't a full-    implementation of reST. That can come later. For now we need to-    prevent the stack overflows.  Partially resolves Issue #297.--  * EPUB writer: Allow non-plain math methods.--  * Forbid ()s in citation item keys.  Resolves Issue #304: problems with-    `(@item1; @item2)` because the final paren was being parsed as part of-    the item key.--  * Changed URI parser so it doesn't include trailing punctuation.-    So, in RST, `http://google.com.` should be parsed as a link followed by a-    period. The parser is smart enough to recognize balanced parentheses, as-    often occur in wikipedia links: `http://foo.bar/baz_(bam)`.--  * Markdown+lhs reader: Require space after inverse bird tracks, so that-    HTML tags can be used freely at the left margin of a markdown+lhs document.-    Thanks to Conal Elliot for the suggestion.--  * Markdown reader:--    + Improved emph/strong parsing; fixes bug found by Perry Wagle.-    + Fixed bug in footnote order (reported by CircleCode).--  * RST reader:-      + Fixed bug in in field lists with multi-line items at the-        end of the list.-      + Added parentheses to RST `specialChars`, so-        `(http://google.com)` will be parsed as a link in parens.-        Resolves Issue #291.-      + Allow `|` followed by newline in RST line block.--  * LaTeX reader:-      + Support `\dots`.-      + Gobble option & space after linebreak `\\[10pt]`.--  * Textile reader:-      + Make it possible to have colons after links.  (qerub)-      + Make it possible to have colons after links.  (Christoffer Sawicki)--  * HTML reader:-      + Skip spaces after `<b>`, `<emph>`, etc.-      + Handle tbody, thead in simple tables.  Closes #274.-      + Implicit `Para`s instead of `Plains` in some contexts.--  * OpenDocument writer:  Use special `First paragraph` style for-    first paragraph after most non-paragraph blocks. This allows users to-    specify e.g. that only paragraphs after the first paragraph of a block are-    to be indented. Thanks to Andrea Rossato for the patch. Closes #20.--  * LaTeX writer:  use `deVerb` on table and picture captions.-    Otherwise LaTeX complains about `\verb` inside command argument.-    Thanks to bbanier for reporting the bug.--  * Markdown writer: Insert HTML comment btw list and indented code block.-    This prevents the code block from being interpreted as part of the list.--  * EPUB writer: Add a meta element specify the cover.-    Some EPUB e-readers, such as the Nook, require a meta element inside the-    OPF metadata block to ensure the cover image is properly displayed.-    (Kelsey Hightower)--  * HTML writer: Use embed tag for images with non-image extensions.-    (e.g.  PDFs).  Closes #264.--  * LaTeX writer: Improved tables.--      + More space between lines, top-align cells.-      + Use ctable package, which allows footnotes and-        provides additional options.-      + Made cell alignments work in multiline tables.-      + Closes #271, #272.--  * Un-URI-escape image filenames in LaTeX, ConTeXt, RTF, Texinfo.-    Also do this when copying image files into EPUBs and ODTs.-    Closes #263.--  * Changed to github issue tracker.--  * Added failing emph/strong markdown test case due to Perry Wagle.--  * Slidy improvements:-      + Updated to use Slidy2.-      + Fixed bug, unclosed div tag.-      + Added `duration` variable in template.-        Setting this activates the timer.-      + Use 'titlepage' instead of 'cover' for title div.--pandoc (1.8.1.1)--  * `markdown2pdf`:  Removed some debugging lines accidentally included-    in the 1.8.1 release. With those lines, the temp directory is created-    in the working directory, and it is not deleted.  This fix restores-    the original behavior.--pandoc (1.8.1)--  * Added `--ascii` option.  Currently supported only in HTML writer,-    which it causes to use numerical entities instead of UTF-8.--  * EPUB writer: `--toc` now works to provide a table of contents-    at the beginning of each chapter.--  * LaTeX writer:  Change figure defaults to `htbp`.-    This prevents "too many unprocessed floats."  Resolves-    Issue #285.--  * `Text.Pandoc.UTF8`:  Encode filenames even when using recent-    base.--  * `markdown2pdf`: Fixed filename encoding issues. With help from Paulo-    Tanimoto. Resolves Issue #286.--  * HTML writer: Put line breaks in section divs.--  * `Text.Pandoc.Shared`: Make `writerSectionDivs` default to False.--pandoc (1.8.0.3)--  * Fixed Source-repository stanza in cabal file.--pandoc (1.8.0.2)--  * HTML writer:--    + Stringify alt text instead of converting to HTML.-    + Break lines after block elements, not inside tags.-      HTML output now closely resembles that of tidy. Resolves Issue #134.--  * Markdown reader: Fixed bug in footnote block parser (pointed out-    by Jesse Rosenthal).  The problem arose when the blank line-    at the end of a footnote block contained indenting spaces.--  * Shared: Improved 'normalize' function so it normalizes Spaces too.-    In normal form, Space elements only occur to separate two non-Space-    elements.  So, we never have [Space], or [, ..., Space].--  * Tests:--    + Improved Arbitrary instance.-    + Added timeout for test instances.--  * README:--    + Added section on four-space rule for lists.  Resolves Issue #283.-    + Clarified optional arguments on math options.--  * markdown2pdf: Fixed bug with output file extensions.-    Previously `markdown2pdf test.txt -o test.en.pdf` would produce-    `test.pdf`, not `test.en.pdf`.  Thanks to Paolo Tanimoto for the fix.--pandoc (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.--  * Added `nonspaceChar` to `Text.Pandoc.Parsing`.--  * 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 ]--  * New EPUB and HTML Slidy writers. (Issue #122)--      - EPUB is a standard ebook format, used in Apple's iBooks for-        the iPad and iPhone, Barnes and Noble's nook reader, the Sony-        reader, and many other devices.-      - Slidy, like S5, is a system for producing HTML+javascript slide-        shows.--  * All input is assumed to be UTF-8, no matter what the locale and ghc-    version, and all output is UTF-8. This reverts to pre-1.5 behavior.-    Also, a BOM, if present, is stripped from the input.--  * Markdown now supports grid tables, whose cells can contain-    arbitrary block elements. (Issue #43)--  * Sequentially numbered example lists in markdown with `@` marker.--  * Markdown table captions can begin with a bare colon and no longer need-    to include the English word "table." Also, a caption can now occur-    either before or after the table. (Issue #227)--  * New command-line options:--      - `--epub-stylesheet` allows you to specify a CSS file that will-        be used to style your ebook.-      - `--epub-metadata` allows you to specify metadata for the ebook.-      - `--offline` causes the generated HTML slideshow to include all-        needed scripts and stylesheets.-      - `--webtex` causes TeX math to be converted to images using the-        Google Charts API (unless a different URL is specified).-      - `--section-divs` causes div tags to be added around each section-        in an HTML document. (Issue #230, 239)--  * Default behavior of S5 writer in standalone mode has changed:-    previously, it would include all needed scripts and stylesheets-    in the generated HTML; now, only links are included unless-    the `--offline` option is used.--  * Default behavior of HTML writer has changed. Between 1.2 and 1.5,-    pandoc would enclose sections in div tags with identifiers on the-    div tags, so that the sections can be manipulated in javascript.-    This caused undesirable interactions with raw HTML div tags. So,-    starting with 1.6, the default is to put the identifiers directly-    on the header tags, and not to include the divs.  The `--section-divs`-    option selects the 1.2-1.5 behavior.--  * API changes:--      - `HTMLMathMethod`: Added `WebTeX`, removed `MimeTeX`.-      - `WriterOptions`: Added `writerUserDataDir`, `writerSourceDirectory`,-        `writerEPUBMetadata` fields. Removed `writerIncludeBefore`,-        `writerIncludeAfter`.-      - Added `headerShift` to `Text.Pandoc.Shared`.-      - Moved parsing code and `ParserState` from `Text.Pandoc.Shared`-        to a new module, `Text.Pandoc.Parsing`.-      - Added `stateHasChapters` to `ParserState`.-      - Added `HTMLSlideVariant`.-      - Made `KeyTable` a map instead of an association list.-      - Added accessors for `Meta` fields (`docTitle`, `docAuthors`,-        `docDate`).-      - `Pandoc`, `Meta`, `Inline`, and `Block` have been given `Ord`-        instances.-      - Reference keys now have a type of their own (`Key`), with its-        own `Ord` instance for case-insensitive comparison.-      - Added `Text.Pandoc.Writers.EPUB`.-      - Added `Text.Pandoc.UUID`.-      - Removed `Text.Pandoc.ODT`, added `Text.Pandoc.Writers.ODT`.-        Removed `saveOpenDocumentAsODT`, added `writeODT`.-      - Added `Text.Pandoc.Writers.Native` and `writeNative`.-        Removed `prettyPandoc`.-      - Added `Text.Pandoc.UTF8` for portable UTF8 string IO.-      - Removed `Text.Pandoc.Writers.S5` and the `writeS5` function.-        Moved `s5Includes` to a new module, `Text.Pandoc.S5`.-        To write S5, you now use `writeHtml` with `writerSlideVariant`-        set to `S5Slides` or `SlidySlides`.--  * Template changes.  If you use custom templates, please update them,-    particularly if you use syntax highlighting with pandoc. The old HTML-    templates hardcoded highlighting CSS that will no longer work with-    the most recent version of highlighting-kate.--      - HTML template: avoid empty meta tag if no date.-      - HTML template: Use default highlighting CSS from highlighting-kate-        instead of hard-coding the CSS into the template.-      - HTML template: insert-before text goes before the title, and-        immediately after the <body> tag, as documented. (Issue #241)-      - Added slidy and s5 templates.-      - Added amssymb to preamble of latex template. (github Issue 1)--  * Removed excess newlines at the end of output. Note: because output-    will not contain an extra newline, you may need to make adjustments-    if you are inserting pandoc's output into a template.--  * In S5 and slidy, horizontal rules now cause a new slide, so you-    are no longer limited to one slide per section.--  * Improved handling of code in man writer. Inline code is now monospace,-    not bold, and code blocks now use .nf (no fill) and .IP (indented para).--  * HTML reader parses `<tt>` as Code. (Issue #247)--  * html+lhs output now contains bird tracks, even when compiled without-    highlighting support. (Issue #242)--  * Colons are now no longer allowed in autogenerated XML/HTML identifiers,-    since they have a special meaning in XML.--  * Code improvements in ODT writer.  Remote images are now replaced with-    their alt text rather than a broken link.--  * LaTeX reader improvements:--      - Made latex `\section`, `\chapter` parsers more forgiving of-        whitespace.-      - Parse `\chapter{}` in latex.-      - Changed `rawLaTeXInline` to accept `\section`, `\begin`, etc.-      - Use new `rawLaTeXInline'` in LaTeX reader, and export `rawLaTeXInline`-        for use in markdown reader.-      - Fixes bug wherein `\section{foo}` was not recognized as raw TeX-        in markdown document.--  * LaTeX writer:  images are automatically shrunk if they would extend-    beyond the page margin.--  * Plain, markdown, RST writers now use unicode for smart punctuation.--  * Man writer converts math to unicode when possible, as in other writers.--  * `markdown2pdf` can now recognize citeproc options.--  * Command-line arguments are converted to UTF-8. (Issue #234)--  * `Text.Pandoc.TeXMath` has been rewritten to use texmath's parser.-    This allows it to handle a wider range of formulas. Also, if a formula-    cannot be converted, it is left in raw TeX; formulas are no longer-    partially converted.--  * Unicode curly quotes are left alone when parsing smart quotes. (Issue-    #143)--  * Cabal file changes:--      - Removed parsec < 3 restriction.-      - Added 'threaded' flag for architectures where GHC lacks a threaded-        runtime.-      - Use 'threaded' only for markdown2pdf; it is not needed for pandoc.-      - Require highlighting-kate 0.2.7.--  * Use explicit imports from `Data.Generics`. Otherwise we have a-    conflict with the 'empty' symbol, introduced in syb >= 0.2. (Issue #237)--  * New data files:  slidy/slidy.min.js, slidy/slidy.min.css, epub.css.--pandoc (1.5.1.1)--  [ John MacFarlane ]--  * Fixed uniqueIdent in Shared so that header identifiers work as-   advertized in the README and are are valid XHTML names.--pandoc (1.5.1)--  [ John MacFarlane ]--  * Fixed treatment of unicode characters in URIs.-    + Shared now exports escapeURI and unescapeURI. These handle-      UTF8 encoding and decoding as well as URI escaping/unescaping.-    + Shared: uri and emailAddress now return a pair of the original-      parsed text and the escaped URI (in the latter case, with-      the mailto: prefix).-    + HTML reader: unsanitaryURI has been modified to allow unicode-      high characters in a URI.-    + Readers:  All link and image URIs are now escaped using-      escapeURI.-    + Markdown and RST writers:  unescapeURI is used so that URIs-      in these formats are human-readable.--  * Setup.hs: Don't assume that the build directory is "dist".-    Instead, get it from localBuildInfo.--  * OpenDocument writer: Use a Map for stTextStyleAttr.-    This avoids duplicates (and invalid xml). Resolves Issue #222.--pandoc (1.5.0.1)--  [ John MacFarlane ]--  * HTML writer: Fixed error in math writer (with MathML option)-    that caused an infinite loop for unparsable MathML.--pandoc (1.5)--  [ John MacFarlane ]--  * Added --mathml option.  When this is selected, pandoc will convert-    TeX math into MathML.-    + Added data/MathMLinHTML.js, which is included when no URL is-      provided for --mathml.  This allows MathML to be displayed (in-      better browsers) as text/html.-    + Removed Text.Pandoc.LaTeXMathML.  The module was no longer-      necessary; it was replaced by two lines in pandoc.hs.-    + Replaced LaTeXMathML.js.comment and LaTeXMathML.js.packed with a-      single combined file, LaTeXMathML.js.--  * Added --data-dir option.-    This specifies a user data directory. If not specified, will default-    to ~/.pandoc on unix or Application Data\pandoc on Windows.-    Files placed in the user data directory will override system default-    data files.--  * Added Maybe datadir parameter to readDataFile, saveOpenDocumentAsODT,-    latexMathMLScript, s5HeaderIncludes, and getDefaultTemplate. If-    Nothing, no user directory is searched for an override.--  * Added 'plain' output format. This is similar to markdown, but-    removes links, pictures, inline formatting, and most anything that-    looks even vaguely markupish. The function writePlain is exported by-    Text.Pandoc.Writers.Markdown, with which it shares most of its code.--  * Allow multi-line titles and authors in meta block.-    Titles may span multiple lines, provided continuation lines-    begin with a space character.  Separate authors may be put on-    multiple lines, provided each line after the first begins with-    a space character.  Each author must fit on one line. Multiple-    authors on a single line may still be separated by a semicolon.-    Based on a patch by Justin Bogner.--  * When given an absolute URI as parameter, pandoc will try to fetch-    the content via HTTP.  So you can do:-    'pandoc -r html -w markdown http://www.fsf.org'-    Adds dependency on HTTP.--  * Made HTML reader much more forgiving.-    + Incorporated idea (from HXT) that an element can be closed-      by an open tag for another element.-    + Javascript is partially parsed to make sure that a <script>-      section is not closed by a </script> in a comment or string.-    + More lenient non-quoted attribute values.-      Now we accept anything but a space character, quote, or <>.-      This helps in parsing e.g. www.google.com!-    + Bare & signs are now parsed as a string.  This is a common-      HTML mistake.-    + Skip a bare < in malformed HTML.--  * Removed html2markdown and hsmarkdown.-    + html2markdown is no longer needed, since you can now pass URI-      arguments to pandoc and directly convert web pages. (Note,-      however, that pandoc assumes the pages are UTF8. html2markdown-      made an attempt to guess the encoding and convert them.)-    + hsmarkdown is pointless -- a large executable that could be-      replaced by 'pandoc --strict'.--  * In most writers, an image in a paragraph by itself is now rendered-    as a figure, with the alt text as the caption. (Texinfo, HTML, RST,-    MediaWiki, Docbook, LaTeX, ConTeXt, HTML.) Other images are-    rendered inline.--  * Depend on extensible-exceptions.  This allows pandoc to be compiled-    on GHC 6.8.--  * Added --base-header-level option.  For example, --base-header-level=2-    will change level 1 headers to level 2, level 2 to level 3, etc.-    Closes Debian #563416.--  * Incomplete support for RST tables (simple and grid).-    Thanks to Eric Kow. Colspans and rowspans not yet supported.--  * Added accessors (docTitle, docAuthors, docDate) to Meta type.--  * MediaWiki writer:  format links with relative URLs as wikilinks.-    The new rule:  If the link target is an absolute URL, an external-    link is created. Otherwise, a wikilink is created.--  * Text.Pandoc.Shared: Export uniqueIdent, and don't allow tilde in-    identifier.  Note:  This may break links to sections that involve-    tildes.--  * Markdown(+lhs) reader:  handle "inverse bird tracks."-    Inverse bird tracks (<) are used for haskell example code that is not-    part of the literate Haskell program.  Resolves Issue #211.--  * LaTeX reader:-    + Recognize '\ ' (interword space).-    + Recognize nonbreaking space '~'.-    + Ignore \section, \pdfannot, \pdfstringdef.  Ignore alt title in-      section headers.  Don't treat \section as inline LaTeX.-      Resolves Issue #202.-    + LaTeX reader:  allow any special character to be escaped.-      Resolves Issue #221.-    + LaTeX reader: treat \paragraph and \subparagraph as level 4, 5-      headers.  Resolves Issue #207.--  * Use template variables for include-before/after.-    + These options now imply -s; previously they worked also in fragment-      mode.-    + Users can now adjust position of include-before and include-after-      text in the templates.-    + Default position of include-before moved back (as it was before 1.4)-      before table of contents.-    + Resolves Issue #217.--  * Don't print an empty table header: (all writers).-    Resolves Issue #210.--  * HTML, Docbook writer: Use tbody, thead, and cols in tables.--  * HTML writer: Don't include TOC div if table of contents is empty.--  * Markdown writer:  Fixed citations.-    Previously the markdown writer printed raw citation codes, e.g.-    [geach1970], rather than the expanded citations provided by-    citeproc, e.g. (Geach 1970). Now it prints the expanded citations.-    This means that the document produced can be processed as a markdown-    document without citeproc. Thanks to dsanson for reporting, and-    Andrea Rossato for the patch.--  * Improved and simplified title block in context template.-    Previously it caused an error if there was no title.-    This method should also be easier for users to customize.--  * Markdown reader:-    + Treat p., pp., sec., ch., as abbreviations in smart mode.-    + Disallow blank lines in inline code span.-    + Allow footnotes to be indented < 4 spaces.-      This fixes a regression.  A test case has been added.-    + Escape spaces in URLs as %20. Previously they were incorrectly-      escaped as +, which is appropriate only for the query part of-      a URL. Resolves Issue #220.-    + Require two spaces after capital letter + period for list item.-      Otherwise "E. coli" starts a list. This might change the semantics-      of some existing documents, since previously the two-space-      requirement was only enforced when the second word started-      with a capital letter. But it is consistent with the existing-      documentation and follows the principle of least surprise.-      Resolves Issue #212.--  * LaTeX template: redefine labelwidth when using enumerate package.-    Otherwise the list labels (numbers) often extend past the left-    margin, which looks bad.--  * Mediawiki writer: Don't print a "== Notes ==" header before-    references.  This is too English-centric. Writers can provide their-    own header at the end of the document.--  * Promoted mediawiki headers.  '= head =' is now level 1, '== head =='-    level 2, etc.  This seems to be correct; it's only by convention-    that wikipedia articles have level 2 headers at most.-    Patch due to Eric Kow.--  * RunTests.hs: Set LANG to a UTF-8 locale. Use 'pandoc --data-dir=' so-    data files don't need to have been installed. This removes the need to-    set HOME.--  * HTML reader:-    + Handle spaces before <html>.  Resolves Issue #216.-    + Be forgiving in parsing a bare list within a list.-      The following is not valid xhtml, but the intent is clear:-      <ol>-      <li>one</li>-      <ol><li>sub</li></ol>-      <li>two</li>-      </ol>-      We'll treat the <ol> as if it's in a <li>.  Resolves Issue #215.--  * Updated INSTALL instructions.  cabal method is now promoted.--  * Updated markdown2pdf man page. It no longer says all pandoc options-    are accepted.--  * README/man pages: Removed advice to pipe through tidy before HTML-    reader.  This is obsolete, now that we have a forgiving HTML parser.--  * LaTeX writer: set numbersections template variable, so-    the section numbering options work again.--  * Removed obsolete Makefile.--  * Website: renamed index.txt.in -> index.txt.--  * New batch file to make-windows-installer.-    + Removed old Makefile.windows-    + Added make-windows-installer.bat-    + Modified default installer name in pandoc-setup.iss--  * Removed freebsd and macports directories.-    They are no longer up to date.--  * Setup.hs:-    + Made man page building sensitive to build verbosity.-    + Improved detection of highlighting support in test hook.-    + Install wrapper scripts into cabal bin directory.-    + Also simplified installManpages.-    + Setup.hs: install manpages to mandir.  Code borrowed from darcs.--  * Changed default of writerXeTeX to False.--  * HTML writer: don't include empty UL if --toc but no sections.-    Resolves Issue #199.--  * LaTeX writer:--    + If book, report, or memoir documentclass, use \chapter{}-      for first-level headers. Otherwise use \section{}.-    + Removed stLink, link template variable. Reason: we now always-      include hyperref in the 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-      unicode=true on hyperref options.--  * markdown2pdf: always do at least two runs. hyperref bookmarks-    require this.--  * cabal file: Removed unneeded dependency on template-haskell.--  * Windows installer - fixed bug in data file locations.-    Resolves Issue #197.--  * Deprecated --custom-header in documentation.-    Removed old "Custom Headers" section in README.--pandoc (1.4)--  [ John MacFarlane ]--  * Pandoc will now compile with either GHC 6.10 or 6.12.-    + Don't use System.IO.UTF8 when compiling with 6.12-    + Use -fno-warn-unused-do-bind option when compiling with 6.12--  * Replaced old headers with templates.  Now users have much more-    control over the way documents appear in --standalone mode,-    and writer code is simplified.  Resolves Issues #59, 147.-    Every effort has been made to retain backwards compatibility.-    So, the --custom-header option should still work as before.--    + Added Text.Pandoc.Templates.  This provides functions for-      retrieving default templates and for rendering templates.-    + System templates (in the pandoc data directory) can be-      overridden by user templates in $HOME/.pandoc/templates.-    + Removed Text.Pandoc.DefaultHeaders.-    + Removed data/headers directory.-    + Added templates directory.-    + Added writerTemplate and writerVariables fields to WriterOptions.-    + Removed writerTitlePrefix, writerHeader fields from WriterOptions.-    + Changed --print-default-header to --print-default-template.-    + Added --template option.-    + Added -V/--variable option to set custom template variables.--  * Pandoc no longer requires Template Haskell.  Resolves Issue #186.--    + Removed need for TH in ODT module. Instead get reference.odt from-      data file at run time.-    + Removed TH dependency from S5 module. S5 module now exports-      s5HeaderIncludes, which pandoc.hs includes if writer is s5 and-      standalone.-    + Refactored LaTeXMathML not to use TH.--  * Meta is now Meta [Inline] [[Inline]] [Inline] rather than-    Meta [Inline] [String] String. Authors and date in Meta are now lists-    of Inline elements rather than raw strings. This means that they can-    be formatted and can include footnotes. NOTE: This may be a breaking-    change for those using pandoc as a library.--  * Added readDataFile to Text.Pandoc.Shared.  This retrieves-    a data file from the user pandoc data directory (~/.pandoc-    on unix), or, if not found there, from the system data-    directory ($CABALDIR/shared/pandoc-VERSION/). All data-    files, including templates, LaTeXMathML.js, s5 styles,-    and reference.odt, can be overridden by the user.--  * s5 files moved from data/ui/default to s5/default.--  * Use unicode instead of entities in HTML and XML output.  Resolves-    Issue #163.--  * Prettier HTML footnote references:  put anchor inside sup,-    instead of other way.  Resolves Issue #191. Thanks to-    infinity0x.--  * Added --xetex option to pandoc and markdown2pdf.-    If --xetex is specified, pandoc produces latex suitable for-    processing by xelatex, and markdown2pdf uses xelatex to create-    the PDF. Resolves Issue #185.--  * RTF writer: multiple authors now occupy multiple paragraphs rather-    than using a line break.--  * Man writer: now the "--after-body" will come after the "AUTHORS"-    section, whereas before it would come before it.  This is a-    slight break from backwards compatibility.--  * Added --reference-odt option, so users may customize the styles-    used in pandoc-generated ODT files.  Users may also place a-    default reference.odt in the ~\.pandoc directory.--  * ODT writer:-    + Indented and line-broke styles.xml so it can be modified more easily.-    + Omitted some unnecessary style declarations.-    + Don't wrap text in OpenDocument writer.  The tags are too long, making-      wrapping ugly and pointless.--  * LaTeX reader: use \\ to separate multiple authors.--  * Markdown reader: use ; as separator between authors.-    This allows you to use ',' within author names: e.g. "John Jones, Jr."--  * S5 writer: use linebreak to separate authors in title page.--  * RST reader: Allow :: before lhs code block. The RST spec requires the-    :: before verbatim blocks. This :: should not be treated as literal-    colons. Resolves Issue #189.--  * Documented pandoc 1.3's new definition list syntax in README.-    (An oversight in the last release.)--  * markdown2pdf.hs:-    + interpret ! in a log as an error line.-    + --toc now works properly.--  * Changes in RunTests.hs:-    + Use the Diff library rather than a local copy of Diff.hs.-      (This vastly increases performance.) This change means that 'cabal-      test' presupposes that the Diff library is installed.-    + Removed tests/Diff.hs from cabal file.-    + Changed RunTests to use local environment. We need at least HOME, so-      pandoc can find its data directory.--  * Updated windows installer to install data files in the app directory.--  * Windows installer now installs portable wrappers hsmarkdown and-    markdown2pdf.--pandoc (1.3)--  [ John MacFarlane ]--  * Added --id-prefix option (Issue #41). This adds a prefix to all-    automatically generated HTML identifiers, which helps prevent-    duplicate identifiers when you're generating a fragment (say a blog-    post).--  * Added --indented-code-classes option.  This specifies classes-    to use for indented code blocks.  (Patch due to buttock; Issue #87.)--  * --number-sections now affects HTML output as well as ConTeXt and LaTeX-    (Issue #150).--  * Improved syntax for markdown definition lists (Issue #24).-    Definition lists are now more compatible with PHP Markdown Extra.-    + You can have multiple definitions for a term (but still not-      multiple terms).-    + Multi-block definitions no longer need a column before each block-      (indeed, this will now cause multiple definitions).-    + The marker no longer needs to be flush with the left margin,-      but can be indented at or two spaces.  Also, ~ as well as :-      can be used as the marker (this suggestion due to David-      Wheeler.)-    + There can now be a blank line between the term and the-      definitions.--  * Better looking simple tables.  Resolves Issue #180.-    + Markdown reader: simple tables are now given column widths of 0.-    + Column width of 0 is interpreted as meaning: use default column width.-    + Writers now include explicit column width information only-      for multiline tables.  (Exception:  RTF writer, which requires-      column widths.  In this case, columns are given equal widths,-      adding up to the text width.)-    + Simple tables should now look better in most output formats.--  * Allow markdown tables without headers (Issue #50).-    The new syntax is described in README. Also allow optional line of-    dashes at bottom of simple tables.--  * Compensate for width of final table column (Issue #144).--  * Treat a backslash followed by a newline as a hard line break-    in markdown.  Resolves Issue #154.  This is a nice alternative-    to markdown's "invisible" way of indicating hardline breaks-    using lines that end with two spaces.--  * Improved performance of markdown reader by ~10% by eliminating the-    need for a separate parsing pass for notes. Raw notes are now stored-    on the first pass (which parses references), then parsed when the-    note is inserted into the AST. The stateNotes field in ParserState-    is now a list of [(String, String)] pairs instead of [(String,-    [Block])].--  * In markdown reader, treat 4 or more * or _ in a row as literal-    text.  (Trying to parse long strings of * or _ as strong or emph-    leads to exponential performance problems.)--  * Markdown reader: Use + rather than %20 for spaces in URLs.--  * Fixed htmlComment parser, adding a needed 'try'.--  * Don't print raw HTML in man output.--  * Allow . _ and ~ in header identifiers.--  * Specially mark code blocks that were "literate" in the input.-    They can then be treated differently in the writers.  This allows-    authors to distinguish bits of the literate program they are writing-    from source code examples, even if the examples are marked as-    Haskell for highlighting.  (Issue #174.)--  * Modified html+lhs output to use "haskell" highlighter instead-    of "literateHaskell". The highlighting module now adds bird tracks-    after highlighting (for HTML output), if the code block has the-    "literate" class.  This gives better results, because kate's-    haskell highlighter is much better than the literateHaskell-    highlighter.--  * Fixed handling of footnotes in titles (HTML) and headers (LaTeX).-    (Issue #137.)--  * Support for "..code-block" directive in RST reader. Not core-    RST, but used in Sphinx for code blocks annotated with syntax-    information. Thanks to Luke Plant for the patch.--  * Added "head" to list of block-level HTML tags. Resolves-    Issue #108.--  * Added stripTags to Text.Pandoc.XML.  This is used in the HTML writer.--  * Set utf-8 encoding in texinfo headers.--  * Docbook writer: add ids to sections.  Use link for internal links.-    (Issue #60.)--  * Blank lines after lists in MediaWiki writer.--  * Properly handle commented-out list items in markdown.-    Resolves Issue #142.  Example:--    - a-    <!---    - b-    -->-    - c--  * Changed heuristic in compactify. compactify has to decide whether a-    Para that ends a list is a Para intentionally, or just because of-    the blank lines at the end of every list. In the latter case the-    Para is turned to a Plain. The old heuristic was: change final Para-    to Plain iff the other items all end in Plain. This produces bad-    results when, for example, an item contains just a Plain and an HTML-    comment, as it does in the list above. The new heuristic: change-    final Para to Plain iff the other items don't contain a Para.--  * Added % as an rst underline character.  Resolves Issue #173.--  * Fix inline math parser so that \$ is allowed in math.-    Resolves Issue #169.--  * Translate \int (integral) into unicode when using unicode math-    method. Resolves Issue #177.--  * markdown2pdf.hs improvements:-    + Use System.IO.UTF8.-    + Print error messages on last attempt.-    + Do not create a backup when overwriting a PDF (Issue #166).-    + Accept --longopt=val options.-    + Added man/man1/markdown2pdf.1 to extra-tmp-files in cabal, so that-      it is properly cleaned.--  * Added haddock comments warning that readers assume \n line endings.--  * Updated COPYRIGHT file.--  * Makefile: Changed EXECSBASE so it doesn't pull in hsmarkdown &-    markdown2pdf. Otherwise strip tries to strip shell scripts when you-    install using 'make'.--  * Changed Makefile so it doesn't build Haskell wrappers.--  * Fixed Makefile so it doesn't try to build man pages in build-doc.--  * Install pcre3.dll in Windows install script; this allows us to-    package a version of pandoc with highlighting support.--pandoc (1.2.1)--  [ John MacFarlane ]--  * Fixed regression with --preserveTabs. Brought back optPreserveTabs.-    The trick of setting tabStop to 0 to mean "preserve tabs" had a bad-    side effect: strings of 0 spaces were interpreted as indentation.-    So, with --preserve-tabs, unindented paragraphs were treated as-    code. Resolves Issue #138.--  * HTML writer:  wrap sections in divs.  Resolves Issue #70.--    + hierarchicalize has been rationalized; it builds a hierarchical-      representation of the document from the headers, and simultaneously-      gives each section a unique identifier based on the heading title.-    + Identifiers are now attached to the divs rather than-      to the headers themselves.-    + Table of content backlinks go to the beginning of the table, rather-      than to the section reference that was clicked.-    + Code for constructing identifiers has been moved to Text.Pandoc.Shared-      from the HTML writer, since it is now consumed only by-      hierarchicalize.-    + In --strict mode, pandoc just prints bare headings, as before-      (unless --toc has been specified).-    + In s5 output, it does not wrap sections in divs, as that seems to-      confuse the s5 javascript.--  * Man writer: break lines at end of each sentence. groff expects this-    and treats '.' and '?' differently when followed by line ending as-    opposed to ordinary space. Also, don't escape periods. Instead, use-    zero-width character \& to avoid unwanted interpretation of periods-    at start of line. Resolves Issue #148.--  * Markdown writer:  Added '#' and '>' to list of characters to be-    escaped in markdown output.  Removed '<', as it is not an officially-    escapable character. This partially resolves Issue #96.--  * Make --smart the default for man output format. Otherwise we have-    trouble dividing lists of endlines into sentences.--  * DocBook writer: Use language attribute to indicate source language-    in code blocks.--  * RST reader:--    + Allow # to continue list, even if the list was started with an-      explicit marker. For example:--        A. my list-        #. continued--      Resolves Issue #140.-    + Allow continuation lines in line blocks. Also added test cases for-      line blocks for RST reader. Resolves Issue #149.-    + Allow explicit links with spaces in URL: `link <to this>`_--  * Improved LaTeX reader's coverage of math modes. Remove displaymath*-    (which is not in LaTeX) and recognize all the amsmath environments-    that are alternatives to eqnarray, namely equation, equation*,-    gather, gather*, gathered, multline, multline*, align, align*,-    alignat, alignat*, aligned, alignedat, split. Resolves Issue #103.-    Thanks to shreevatsa.public for the patch.--  * Markdown reader:--    + Allow -, _, :, . in markdown attribute names. These are legal in-      XML attribute names.-    + Use non-breaking spaces in abbreviations.-    + Markdown reader: improved efficiency of abbreviation parsing.-      Instead of a separate abbrev parser, we just check for-      abbreviations each time we parse a string. This gives a huge-      performance boost with -S. Resolves Issue #141.--  * Improved efficiency of shared parsers:  hexNum, htmlComment,-    whitespace, indentSpaces.--  * Export HTMLMathMethod in Text.Pandoc.--  * Export languagesByExtension in Text.Pandoc.Highlighting.--  * Added new Haskell version of markdown2pdf, due to-    Paulo Tanimoto.  This should be more portable than the old-    shell script.--  * Made 'pandoc -v' more explicit about compiler options.-    Resolves Issue #139.--  * pandoc.hs:  Made --strict compatible with --standalone, --toc.--  * Use Paths_pandoc to get version number, instead of hard-coding it-    into Text/Pandoc.hs.--pandoc (1.2)--  [ John MacFarlane ]--  * Added support for literate Haskell. lhs support is triggered by-    '+lhs' suffixes in formats. For example, 'latex+lhs' is literate-    Haskell LaTeX. '.lhs' files are treated by default as literate-    markdown.--    + Added stateLiterateHaskell to parser state.-    + Added parser for lhsCodeBlock to Markdown, RST, LaTeX readers.-    + Added parser for |inline lhs| to LaTeX reader.-    + Added writerLiterateHaskell to WriterOptions.-    + Added lhs support to Markdown, RST, LaTeX, HTML writers.-    + Added definition of code environment to LaTeX header.-    + Added tests (run only if highlighting support compiled in).-    + Documented lhs features in man page and README.--  * In Text.Pandoc.Definition, added processWith, processWithM,-    and queryWith, and deprecated processPandoc and queryPandoc-    for these more general functions.--  * Fixed bug in mediawiki writer:  improper closing tags in tables.-    Thanks to Benct Philip Jonsson for reporting the bug.--  * Added --email-obfuscation option.--    + Added writer option for email obfuscation.-    + Implemented email obfuscation options in HTML writer.-    + Added option to option parser.-    + Documented in README and pandoc man page.-    + Resolves Issue #97.--  * LaTeX writer: fixed bug with empty table cells.-    Resolves Issue #107.  Thanks to rodja.trappe for the patch.--  * Fixed bug with header spacing in Markdown and RST writers.-    A null header (Meta [] [] []) should not cause a blank line-    at the beginning of output.  But a blank line is needed between-    a non-null header and the main text.--  * Markdown reader: Relax spacing rules for $$ in display math. Now-    space and newlines are allowed after the opening $$ and before the-    closing $$. However, the display math cannot contain an entirely-    blank line. Resolves Issue #105.--  * Markdown reader: Gobble space after Plain blocks containing only-    raw html inline. Otherwise following header blocks are not parsed-    correctly, since the parser sees blank space before them. Resolves-    Issue #124.--  * Markdown reader: Allow " as well as '' to end a latex double-quote.--  * Conditionally depend on syb and base >= 4 if ghc >= 6.10.-    Resolves Issue #109.--  * Fixed problems in RST and markdown output due to bug in pretty-1.0.1.0--    + Added hang' function to Text.Pandoc.Shared; this will be used instead-      of hang, which doesn't work properly in pretty-1.0.1.0.  When pretty-      is upgraded, we can go back to hang.-      See  http://article.gmane.org/gmane.comp.lang.haskell.general/16687-    + Use hang' (and some different techniques) in RST and markdown writers.-      Some output is now a bit different.--  * Brought citeproc support up to date for citeproc-hs-0.2.-    (Patch by Andrea Rossato.)--  * Moved all haskell source to src subdirectory.  Renamed Main.hs to-    pandoc.hs.--  * Rewrote hsmarkdown in Haskell for portability (src/hsmarkdown.hs).-    For now, keeping the old shell script too.--  * Added TemplateHaskell to Extensions for executable, removed-    -threaded for library. Thanks to duncan.coutts for the bug report.-    Resolves Issue #121.--  * Moved some Extra-Source-Files to Data-Files.--  * Moved tabFilter to Shared.--  * In pandoc.hs, removed optPreserveTabs; instead, tabstop of 0 means-    preserve tabs.--  * Minor code cleanup based on hlint suggestions.--pandoc (1.1)--  [ John MacFarlane ]--  * Main.hs:--    + Changed date on copyright message in Main.hs.-    + Have the '-v' option print syntax highlighting languages-      separated by commas, and wrapped in lines, instead of in five-      columns as before.--  * Added --jsmath option.  Resolves Issue #68.--    + Added --jsmath option to Main.hs-    + Added JsMath to HTMLMathMethod in Text.Pandoc.Shared.-    + Handle math appropriately in HTML writer when JsMath selected.-    + Documented the option in README and man page.--  * Text.Pandoc.Shared:  Changed compactify to use a better heuristic-    for tight and loose lists. Final Para is changed to Plain if all-    other list items *end* with a Plain block. Addresses Issue #99.--  * HTML reader:--    + Added colons to protocols in unsanitaryURI. Closes Issue #88.-    + HTML reader: Don't interpret contents of <pre> blocks as markdown.-      Added rawVerbatimBlock parser.  Resolves Issue #94.--  * Markdown reader:--    + Allow URLs with spaces in them in links and references, but escape-      them as "%20".-    + Allow blank space at the end of horizontal rules.--  * RST reader: Modified 'unknownDirective' parser to handle comment-    blocks correctly, and added tests for comment blocks. Resolves Issue-    #86. Closes Debian Bug #500662.--  * HTML writer:--    + Include classes on tr elements in HTML output:-      "header", "odd", "even".  This allows tables to be styled with-      lines in alternating colors.  Resolves Issue #91.-    + Enclose all LaTeXMathML bits in <span class="LaTeX">.-      This prevents parts of the document that are not math from being-      interpreted as math by LaTeXMathML.js.--  * OpenDocument and ODT writers:  Added support for HorizontalRule elements,-    which were formerly ignored.  Resolves Issue #95.--  * Text.Pandoc.Shared:  Modified wrappedTeX to eliminate the line break-    between a footnote and immediately following nonspace characters in-    LaTeX and ConTeXt output. (This gets interpreted as a space, which-    is not desired in cases like `text^[note]---`.)  Resolves Issue #93.--  * Windows installer: Don't require admin privileges to run-    installer.  Modified pandoc-setup.iss, and changed modpath.iss to-    modify HKCU path if user lacks admin privileges.  Also fixed case-    where oldpath is empty (previously this led to the new path-    beginning with a semicolon).--  * Updated INSTALL instructions for Arch packages and OS X install using-    cabal-install.--  * Removed the (now unneeded) debian directory.-    Removed empty Codec and System directories.--  * Moved odt-styles/ to data/.  Removed unneeded variable in Makefile.--  * Modified Setup.hs so that the "test" target returns an error status-    when tests fail, and "build" returns a success status if-    the build succeeds.  Resolves Issue #100.--  * Added BUGS to files in tarball.---pandoc (1.0.0.1)--  [ John MacFarlane ]--  * Removed spurious reference to pdf output format from pandoc(1) man page.--pandoc (1.0)--  [ Andrea Rossato ]--  * Added new OpenDocument writer.--  * Added support for SmallCaps inline element.--  * Added support for integrating pandoc with citeproc-hs.--    + Added Cite element to definition and writers.-    + Added Text.Pandoc.Biblio module-    + Note: This support is included only if the 'citeproc'-      Cabal configuration flag is set.--  * Made Pandoc data structure an instance of Typeable.-    Added new processPandoc and queryPandoc functions, to query-    or transform matching elements in a Pandoc structure.--  [ Peter Wang ]--  * Added new Texinfo writer.--  [ John MacFarlane ]--  * Changes to Texinfo writer:--    + No space between paragraph and following @verbatim (provides more-      pleasing appearance in text formats)-    + Blank line consistently after list environments.-    + Removed deVerb.-    + Use @code instead of @verb for inline code (this solves the character-      escaping problem for texi2dvi and texi2pdf).-    + Added news of Texinfo writer to README.-    + Added Texinfo to list of formats in man page, and removed extra 'groff'.-    + Added texi & texinfo extensions to Main.hs, and fixed bug in determining-      default output extension.-    + Modified disallowedInNode in Texinfo writer to correct list of disallowed characters.--  * Added tests for OpenDocument writer.--  * Added ODT writer (using zip-archive library to package output of-    OpenDocument writer).  Added odt-styles directory with default ODT styles.--  * Added new mediawiki writer and tests.--  * Markdown reader: Added support for delimited code blocks, with optional-    syntax highlighting using highlighting-kate (if the 'highlighting'-    configuration option is selected).--    + Currently highlighting is supported only in the HTML writer.-    + Delimited code blocks can have attributes; using the language name as-      class triggers highlighting.-    + New Attributes parameter in CodeBlock structure.-    + --version now indicates whether syntax highlighting support is compiled-      in, and prints a list of supported languages--  * Removed debian directory. Pandoc is no longer a native debian package.--  * Changes to build process:  pandoc can now be built from the repository-    using Cabal.  No unix tools are needed (so, pandoc can be built on Windows-    without Cygwin).--    + Include shell scripts themselves in repo, rather than generating from wrappers.-      Removed wrappers directory and wrappers Makefile target.-    + Text/Pandoc/ASCIIMathML.hs, Text/Pandoc/DefaultHeaders.hs,-      and Text/Pandoc/Writers/S5.hs are no longer built in Makefile-      from templates in the templates/ directory. Instead, they use template-      haskell to read data at compile time from the relevant files in data/.-      Template haskell functions go in a new module, Text.Pandoc.TH.-    + man pages are now generated in Setup.hs hook, not by Makefile-    + Makefile 'tarball' target now calls Cabal's 'sdist'-    + Added "Extra-Source-Files" to pandoc.cabal, so sdist contains everything needed-    + Added "Build-Type" field to pandoc.cabal to avoid warning.-    + Added to "Extra-source-files" and "Extra-tmp-files" in pandoc.cabal,-      so 'sdist' and 'clean' will work properly.-    + Setup.hs now generates man pages in a postbuild hook.-    + Added dependency-checking to Setup.hs, so it only rebuilds things-      that need rebuilding.-    + Added 'library' and 'executable' configuration flags.-      Cabal can now be told to build just the library or just the executable.-    + CABALOPTS may now be specified with 'make' to pass Cabal configuration flags.-      For example:  CABALOPTS=-fhighlighting make--  * Rewrote test suite so it doesn't depend on perl or unix tools.--    + Replaced old runtests.pl with a Haskell script RunTests.hs.-    + Added Diff.hs module to be used by RunTests.hs instead of unix 'diff'.-    + Added test hook to Setup.hs, so tests may be run from cabal.-    + Changed Makefile's 'test' target to run tests via cabal.-    + Removed old generate.sh.-    + Since we no longer have 'sed' to filter out raw HTML sections-      from the docbook writer test, or raw LaTeX sections from the-      context writer test, we now just include these sections.-      They can be taken out if it is necessary to process the files.-    + Updated latex and context writer tests to remove extra spaces-      after '\\item'-    + Added a markdown table reader test.-    + Added markdown-reader-more.txt to test suite, for additional test cases-      for raw ConTeXt environments and more.--  * Compatibility fixes for CPP, Cabal, and haddock:--    + Use CPP in "Extensions" field in pandoc.cabal.-    + Removed use of backslash string continuations in source files.--  * Removed pandoc.cabal.ghc66.  We now require Cabal >= 1.2, GHC >= 6.8,-    base >= 3.--  * Require parsec < 3.-    The compatibility module in parsec 3.0.0 gives far worse performance than-    parsec 2.1.  Eventually pandoc will be upgraded to use the new bytestring-    version of parsec, and then we'll go to parsec 3.0.0.--  * Removed Text.Regex dependencies by rewriting using plain Haskell-    (Text.Pandoc.Writers.RTF, Text.Pandoc.Writers.HTML, Main.hs)--  * Moved Text.Pandoc.Writers.DefaultHeaders -> Text.Pandoc.DefaultHeaders.--  * Makefile:--    + Added 'configure' as dependency of 'uninstall-all'.-      (It uses the Cabal build program.)-    + Makefile:  only use --with-hc-pkg if GHC_PKG is defined.-      Note that Cabal will automatically choose the ghc-pkg appropriate-      for the compiler selected, so normally specifying GHC by itself-      is sufficient.--  * Removed Text.Pandoc.UTF8 module; instead, depend on utf8-string and use-    its IO and conversion functions.--  * Added -Wall to ghc-options in pandoc.cabal.  Cleaned up modules so that-    everything is -Wall clean.--    + Added pragma to HTML writer to avoid deprecation warning for use of "start" attribute.-    + Added pragma to Text/Pandoc/Shared.hs to get rid of "orphan instance" warnings.-      (These are caused by the Lift instance for ByteString.)--  * Changed the comment used to replace unsafe HTML if sanitize-html option-    selected.--  * Made -c/--css option repeatable on the command line (like -H, -A, -B).--  * Moved XML-formatting functions to new unexported module Text.Pandoc.XML.--  * Escape '\160' as "&#160;", not "&nbsp;" in XML.-    "nbsp" isn't a predefined XML entity.--  * Fixed bug in RST reader, which would choke on: "p. one\ntwo\n".-    Added some try's in ordered list parsers.--  * Man writer:  don't escape " as \".--  * Allow newline before URL in markdown link references.  Resolves Issue #81.-    Added tests for this issue in new "markdown-reader-more" tests.-    Changed RunTests.hs to run these tests.--  * Support for display math.  Resolves Issue #47.--    + Added a DisplayMath/InlineMath selector to Math inlines.-    + Markdown parser yields DisplayMath for $$...$$.-    + LaTeX parser yields DisplayMath when appropriate.  Removed-      mathBlock parsers, since the same effect is achieved by the math-      inline parsers, now that they handle display math.-    + Writers handle DisplayMath as appropriate for the format.-    + Modified tests accordingly; added new tests for display math.--  * Use LaTeXMathML instead of ASCIIMathML.  LaTeXMathML is closer-    to LaTeX in its display of math, and supports many non-math LaTeX environments.--    + Changed -m option to use LaTeXMathML rather than ASCIIMathML.-    + Modified HTML writer to print raw TeX when LaTeXMathML is-      being used instead of suppressing it.-    + Removed ASCIIMathML files from data/ and added LaTeXMathML.-    + Replaced ASCIIMathML with LaTeXMathML in source files.-    + Modified README and pandoc man page source.-    + Added --latexmathml option (kept --asciimathml as a synonym-      for backwards compatibility)--  * Markdown reader: Parse setext headers before atx headers.-    Test case:-       # hi-       ====-    parsed by Markdown.pl as an H1 header with contents "# hi".--  * Markdown reader: Treat "mixed" lists the same way as Markdown.pl does.-    The marker on the first list item determines the type of the whole-    list.  Thus, a list like-       1. one-       -  two-       *  three-    gets parsed as a single ordered list.  (Previous versions of pandoc-    treated this as an ordered list with an unordered sublist.)--  * Markdown smart typography:--    + Em dashes no longer eat surrounding whitespace.  Resolves Issue #69.-    + Use nonbreaking spaces after known abbreviations in markdown parser.-      Thus, for example, "Mr. Brown" comes out as "Mr.~Brown" in LaTeX, and does-      not produce a sentence-separating space.  Resolves Issue #75.--  * Markdown writer: Print unicode \160 literally, rather than as &nbsp;.--  * Treat '\ ' in (extended) markdown as nonbreaking space.-    Print nonbreaking space appropriately in each writer (e.g. ~ in LaTeX).--  * The '--sanitize-html' option now examines URIs in markdown links-    and images, and in HTML href and src attributes.  If the URI scheme-    is not on a whitelist of safe schemes, it is rejected.  The main point-    is to prevent cross-site scripting attacks using 'javascript:' URIs.-    See http://www.mail-archive.com/markdown-discuss@six.pairlist.net/msg01186.html-    and http://ha.ckers.org/xss.html.  Resolves Issue #62.--  * HTML writer:--    + Override Text.XHtml's stringToHtml function,-      so that characters below 0xff are not converted to numerical entity-      references. Also convert '\160' to "&nbsp;". This should aid readability-      and editability of the HTML source. It does presuppose that the HTML-      will be served as UTF-8.-    + In code blocks, change leading newlines to <br /> tags.-      (Some browsers ignore them.)  Resolves Issue #71.-      See http://six.pairlist.net/pipermail/markdown-discuss/2008-May/001297.html-    + Use style attributes rather than css classes for strikethrough-      and ordered list styles.  This works better when fragments, rather than-      standalone documents, are generated.--  * HTML reader: Count anything that isn't a known block (HTML) tag as an-    inline tag (rather than the other way around).  Added "html", "head", and-    "body" to list of block tags.  Resolves Issue #66, allowing-    <lj> to count as an inline tag.--  * RTF writer: Fixed bug.  Extra spaces were being printed after emphasized,-    boldface, and other inline elements.  Resolves Issue #64.--  * LaTeX reader:  improvements in raw LaTeX parsing.--    + "loose punctuation" (like {}) parsed as Space-    + Para elements must contain more than Str "" and Space elements-    + Added parser for "\ignore" command used in literate haskell.-    + Reworked unknownCommand and rawLaTeXInline: when not in "parse raw"-      mode, these parsers simply strip off the command part and allow-      the arguments to be parsed normally.  So, for example,-      \blorg{\emph{hi}} will be parsed as Emph "hi" rather than-      Str "{\\emph{hi}}".-    + Parse lhs "code" environments as verbatim.-      Refactored parsers for verbatim environments.-    + Removed specialEnvironment parser.-    + parse '{}', if present, after \textless, \textgreater,-      \textbar, \textbackslash, \ldots.-    + Parse unescaped special characters verbatim rather than-      changing them to spaces.  This way arguments of unknown-      commands will appear in braces.--  * Parse raw ConTeXt environments as TeX in markdown reader.-    Resolves Issue #73.--  * Moved BlockWrapper and wrappedBlocksToDoc from ConTeXt writer to Shared.--  * Made some structural changes to parsing of raw LaTeX environments.-    Previously there was a special block parser for LaTeX environments.-    It returned a Para element containing the raw TeX inline. This has-    been removed, and the raw LaTeX environment parser is now used in the-    rawLaTeXInline parser. The effect is exactly the same, except that we-    can now handle consecutive LaTeX and ConTeXt environments not separated-    by spaces.  This new flexibility is required by the example in-    Issue #73:--        \placeformula \startformula-             L_{1} = L_{2}-        \stopformula--    API change: The LaTeX reader now exports rawLaTeXEnvironment' (which-    returns a string) rather than rawLaTeXEnvironment (which returns a block-    element). This is more likely to be useful in other applications.--  * Use \textsubscr instead of \textsubscript for LaTeX subscript macro.-    \textsubscript conflicts with a definition in the memoir class.-    Resolves Issue #65.--  * Removed unneeded space after "\\item" in LaTeX and ConTeXt output.--  * Added amsmath package to default LaTeX header. Resolves Issue #48.--  * Added \setupitemize[autointro] to ConTeXt header, to prevent orphaned-    list introduction lines.--  * Changed Float to Double in definition of Table element.-    (Double is more efficient in GHC.)--  * Fixed bug in Markdown parser:  regular $s triggering math mode.-    For example:  "shoes ($20) and socks ($5)."-    The fix consists in two new restrictions:--    + the $ that ends a math span may not be directly followed by a digit.-    + no blank lines may be included within a math span.--    Thanks to Joseph Reagle for noticing the bug.--  * Use Data.List's 'intercalate' instead of custom 'joinWithSep'.-    Removed 'joinWithSep' from Text.Pandoc.Shared.--  * Updated README and man pages.  Acknowledge contributors in README.-    Added paragraph to README about producing S5 with separate CSS/javascript.--  * Updated INSTALL to reflect new build system (including configuration-    options) and document new dependencies.  Added note to INSTALL that-    Cabal >= 1.2 is required for build.  Resolves Issue #74.--  * Fixed some haddock documentation errors.--  * Small fix to markdown2pdf man page: only input needs to be piped through iconv.--pandoc (0.46) unstable; urgency=low--  [ John MacFarlane ]--  * Made -H, -A, and -B options cumulative: if they are specified-    multiple times, multiple files will be included.--  * Added optional HTML sanitization using a whitelist.-    When this option is specified (--sanitize-html on the command line),-    unsafe HTML tags will be replaced by HTML comments, and unsafe HTML-    attributes will be removed.  This option should be especially useful-    for those who want to use pandoc libraries in web applications, where-    users will provide the input.--    + Main.hs:  Added --sanitize-html option.--    + Text.Pandoc.Shared:  Added stateSanitizeHTML to ParserState.--    + Text.Pandoc.Readers.HTML:-      - Added whitelists of sanitaryTags and sanitaryAttributes.-      - Added parsers to check these lists (and state) to see if a given-        tag or attribute should be counted unsafe.-      - Modified anyHtmlTag and anyHtmlEndTag to replace unsafe tags-        with comments.-      - Modified htmlAttribute to remove unsafe attributes.-      - Modified htmlScript and htmlStyle to remove these elements if-        unsafe.--    + Modified README and man pages to document new option.--  * Improved handling of email addresses in markdown and reStructuredText.-    Consolidated uri and email address parsers.  (Resolves Issue #37.)--    + New emailAddress and uri parsers in Text.Pandoc.Shared.-      - uri parser uses parseURI from Network.URI.-      - emailAddress parser properly handles email addresses with periods-        in them.--    + Removed uri and emailAddress parsers from Text.Pandoc.Readers.RST-      and Text.Pandoc.Readers.Markdown.--  * Markdown reader:--    + Fixed emph parser so that "*hi **there***" is parsed as a Strong-      nested in an Emph. (A '*' is only recognized as the end of the-      emphasis if it's not the beginning of a strong emphasis.)--    + Moved blockQuote parser before list parsers for performance.--    + Modified 'source' parser to allow backslash-escapes in URLs.-      So, for example, [my](/url\(1\)) yields a link to /url(1).-      Resolves Issue #34.--    + Disallowed links within links. (Resolves Issue #35.)-      - Replaced inlinesInBalanced with inlinesInBalancedBrackets, which-        instead of hard-coding the inline parser takes an inline parser-        as a parameter.-      - Modified reference and inlineNote to use inlinesInBalancedBrackets.-      - Removed unneeded inlineString function.-      - Added inlineNonLink parser, which is now used in the definition of-        reference.-      - Added inlineParsers list and redefined inline and inlineNonLink parsers-        in terms of it.-      - Added failIfLink parser.--    + Better handling of parentheses in URLs and quotation marks in titles.-      - 'source' parser first tries to parse URL with balanced parentheses;-        if that doesn't work, it tries to parse everything beginning with-        '(' and ending with ')'.-      - source parser now uses an auxiliary function source'.-      - linkTitle parser simplified and improved, under assumption that it-        will be called in context of source'.--    + Make 'block' conditional on strictness state, instead of using-      failIfStrict in block parsers. Use a different ordering of parsers-      in strict mode (raw HTML block before paragraph) for performance.-      In non-strict mode use rawHtmlBlocks instead of htmlBlock.-      Simplified htmlBlock, since we know it's only called in strict-      mode.--    + Improved handling of raw HTML.  (Resolves Issue #36.)-      - Tags that can be either block or inline (e.g. <ins>) should-        be treated as block when appropriate and as inline when-        appropriate. Thus, for example,-        <ins>hi</ins>-        should be treated as a paragraph with inline <ins> tags, while-        <ins>-        hi-        </ins>-        should be treated as a paragraph within <ins> tags.-      - Moved htmlBlock after para in list of block parsers.  This ensures-        that tags that can be either block or inline get parsed as inline-        when appropriate.-      - Modified rawHtmlInline' so that block elements aren't treated as-        inline.-      - Modified para parser so that paragraphs containing only HTML tags and-        blank space are not allowed.  Treat these as raw HTML blocks instead.--    + Fixed bug wherein HTML preceding a code block could cause it to-      be parsed as a paragraph.  The problem is that the HTML parser-      used to eat all blank space after an HTML block, including the-      indentation of the code block.  (Resolves Issue #39.)-      - In Text.Pandoc.Readers.HTML, removed parsing of following space-        from rawHtmlBlock.-      - In Text.Pandoc.Readers.Markdown, modified rawHtmlBlocks so that-        indentation is eaten *only* on the first line after the HTML-        block.  This means that in-        <div>-             foo-        <div>-        the foo won't be treated as a code block, but in-        <div>--            foo--        </div>-        it will.  This seems the right approach for least surprise.--  * RST reader:--    + Fixed bug in parsing explicit links (resolves Issue #44).-      The problem was that we were looking for inlines until a '<' character-      signaled the start of the URL; so, if you hit a reference-style link,-      it would keep looking til the end of the document.  Fix:  change-      inline => (notFollowedBy (char '`') >> inline).  Note that this won't-      allow code inlines in links, but these aren't allowed in resT anyway.--    + Cleaned up parsing of reference names in key blocks and links.-      Allow nonquoted reference links to contain isolated '.', '-', '_', so-      so that strings like 'a_b_' count as links.--    + Removed unnecessary check for following link in str.-      This is unnecessary now that link is above str in the definition of-      'inline'.--  * HTML reader:--    + Modified rawHtmlBlock so it parses </html> and </body> tags.-      This allows these tags to be handled correctly in Markdown.-      HTML reader now uses rawHtmlBlock', which excludes </html> and </body>,-      since these are handled in parseHtml.  (Resolves Issue #38.)--    + Fixed bug (emph parser was looking for `<IT>` tag, not `<I>`).--    + Don't interpret contents of style tags as markdown.-      (Resolves Issue #40.)-      - Added htmlStyle, analogous to htmlScript.-      - Use htmlStyle in htmlBlockElement and rawHtmlInline.-      - Moved "script" from the list of tags that can be either block or-        inline to the list of block tags.--    + Modified rawHtmlBlock to use anyHtmlBlockTag instead of anyHtmlTag-      and anyHtmlEndTag.  This fixes a bug in markdown parsing, where-      inline tags would be included in raw HTML blocks.--    + Modified anyHtmlBlockTag to test for (not inline) rather than-      directly for block.  This allows us to handle e.g. docbook in-      the markdown reader.--  * LaTeX reader:  Properly recognize --parse-raw in rawLaTeXInline.-    Updated LaTeX reader test to use --parse-raw.--  * HTML writer:--    + Modified rules for automatic HTML header identifiers to-      ensure that identifiers begin with an alphabetic character.-      The new rules are described in README.  (Resolves Issue #33.)--    + Changed handling of titles in HTML writer so you don't get-      "titleprefix - " followed by nothing.--  * ConTeXt writer: Use wrappers around Doc elements to ensure proper-    spacing.  Each block element is wrapped with either Pad or Reg.-    Pad'ed elements are guaranteed to have a blank line in between.--  * RST writer:--    + Refactored RST writer to use a record instead of a tuple for state,-      and to include options in state so it doesn't need to be passed as-      a parameter.--    + Use an interpreted text role to render math in restructuredText.-      See http://www.american.edu/econ/itex2mml/mathhack.rst for the-      strategy.--  [ Recai Oktaş ]--  * Debian packaging changes:--    + Remove the empty 'include' directory in -dev package, which lintian-      complains about.-    + Bump Standarts-Version to 3.7.3.-    + Use new 'Homepage:' field to specify the upstream URL on suggestion of-      lintian.-- -- Recai Oktaş <roktas@debian.org>  Tue, 08 Jan 2008 05:13:31 +0200--pandoc (0.45) unstable; urgency=low--  [ John MacFarlane ]--  * Simplified parsing of reference keys and notes in markdown and RST-    readers: The Reference data structure from Text.Pandoc.Shared is no-    longer needed, since referenceKey and noteBlock parses return strings-    (as many blank lines as were occupied by the key or note) and update-    state themselves.  getPosition and setPosition are now used to ensure-    that error messages will give the correct line number. This yields-    cleaner (and slightly faster) code, with more accurate parsing error-    messages.--  * Added new Math inline element:--    + Markdown and LaTeX readers now convert TeX math into Math elements,-      not TeX.-    + This allows math to be treated differently from raw TeX in output.-      TeX elements are no longer printed in output formats other than-      Markdown, LaTeX, and ConTeXt.  But Math elements are always printed.--  * New default handling of math in writers:--    + New module Text.Pandoc.Readers.TeXMath exports readTeXMath, which-      parses raw TeX math and outputs a string of Pandoc inlines that-      tries to render it as far as possible using unicode characters,-      lapsing into literal TeX when needed.-    + readTeXMath is now used for default HTML output in HTML, S5, RTF,-      and Docbook, if no other method for displaying math in HTML is-      specified.  Enclosing $'s are no longer printed by default.-    + By default, math is put inside `<span class="math">`. This way it can be-      distinguished from the surrounding text, e.g. put in a different-      font.--  * New --gladtex and --mimetex options for display of math in HTML:--    + If --gladtex is specified, math is output between `<eq>` tags, so-      it can be processed by gladTeX.-    + If --mimetex is specified, math is put in `<img>` tags with a link-      to the mimetex CGI script (or any other script that takes TeX math-      as input and outputs an image).  The URL of the script may be-      specified, but defaults to /cgi-bin/mimetex.cgi.-    + HTMLMathMethod structure in WriterOptions keeps track of how to-      display math in HTML output.-    + Updated README with a description of the four options for displaying-      math in HTML.--  * HTML reader:--    + Fixed bug: parser for minimized attributes should not swallow-      trailing spaces.-    + Simplified HTML attribute parsing.-    + Changed parsing of code blocks in HTML reader:  `<code>` tag is no-      longer needed. `<pre>` suffices. All HTML tags in the code block-      (e.g. for syntax highlighting) are skipped, because they are not-      portable to other output formats. A `<code>...</code>` block not-      surrounded by `<pre>` now counts as inline HTML, not a code block.-    + Remove just one leading and one trailing newline from contents of-      `<pre>...</pre>` in codeBlock parser.--  * Markdown reader:--    + Removed support for box-style block quotes.-    + Require space before title in links and references.-      This fixes a bug in parsing URLs like http://silly/url(withparen).-    + Improved and simplified setextHeader parser.-    + Fixed logic in smart quote parsing, adding some needed 'try'-      statements.-    + Fixed smart quote parsing so that unicode characters 8216 and 8217-      are recognized as single quotes, and 8220 and 8221 as double quotes.--  * RST reader:--    + Fixed bug in parsing of code blocks. Previously a full tab indent-      was required, but RST allows code to be indented any amount.-      Resolves Issue #27.-    + Allow field lists to be indented.-    + Parse the contents of field lists instead of treating as a raw string.-    + Represent field lists as definition lists instead of blockquotes.-    + Fixed bug in which metadata would be overridden if the document-      contained multiple field lists.-    + Parse fields associated with '.. image::' blocks, and use 'alt'-      field, if given, for image alt and title attributes.--  * LaTeX reader:--    + Modified specialChar so that '"' characters are parsed.-    + Fixed a bug in parsing of \[ \] math blocks (thanks to Mark Kalderon).--  * HTML writer:--    + Changes in handling of math (see above).-    + Don't produce HTML for table of contents if there are-      no headers. (This would be an empty list, which is invalid XHTML.)--  * Markdown writer:--    + Don't print title attribute if title is empty. (This differs from-      the behavior of Markdown.pl, and agrees with PHP Markdown. But John-      Gruber has indicated that he prefers this behavior.) Adjusted test-      suite accordingly.-    + Fixed incorrect line wrapping in paragraphs including hard line-      breaks. Resolves Issue #25.-    + Fixed bug in markdown writer:  If an ordered list item began with-      a marker greater than 3 characters in width, and the item took more-      than one line, it would appear on the line after the list marker,-      e.g.:--          (12)-              My list item.-              Multiline.--      Now it works as follows:--          (12) My list item.-              Multiline.--  * RST writer--    + Fixed bug in RST writer's handling of ordered lists. Previously,-      list items with multiple lines would not always line up with-      single-line list items. Now, list items are nested the length of-      the list marker + 1. This looks better and ensures that list items-      all line up. (Note that list markers are padded to the length of-      the longest list marker in the series.)-    + Use 3-space indent for unordered lists.-    + If label for a link reference contains a colon, surround it by `-      signs so it won't be interpreted as the end of the link label.--  * LaTeX writer:--    + Cleaner output for footnotes. Footnotes now always begin on a new-      line, and the final } is on a line by itself only when it needs to-      be (i.e. only when the note ends with a Verbatim environment).-    + Added writer options to state, so state doesn't need to be passed as-      a parameter.-    + Text wrapping now provided, using wrapTeXIfNeeded.--  * ConTeXt writer:  many improvements for more idiomatic ConTeXt output-    (thanks to Idris Samawi Hamid for suggestions).--    + PrettyPrint module now used for output.-    + Writer options are now in state, so they don't have to be passed as-      a parameter.-    + Text wrapping now provided, using wrapTeXIfNeeded.-    + Better treatment of footnotes:  footnotes are always on lines by-      themselves, and the final } is on a line by itself only when-      it needs to be (after \stoptyping).-    + Use \subject, \subsubject, ... or \section, \subsection, ... for headings,-      depending on whether --number-sections option is selected.-    + Extra blank line inserted after \stopitemize-    + Use new, "official" definition of blockquote environment. Also, use-      blank line after \startblockquote to balance blank line at the end.-    + Both itemized and enumerated lists are now generated using-      \start-stopitemize, with appropriate options. Removed definitions-      of ltxenum and ltxitem, which are no longer needed. Provided-      defaults for itemized lists in the preamble. State keeps track of-      ordered list level, so that when default numbering is specified,-      the appropriate scheme can be used.-    + Changed \useurl to \useURL.-    + Changed link color from red to blue.-    + Use \subsubsubsubsection etc., since these are supported-      (up to at least sub x 5).--  * Text.Pandoc.Shared:--    + Save and restore position in parseFromString, so that accurate-      error messages can be given.-    + Improved efficiency of romanNumeral parser.-    + Added wrappedTeX and wrapTeXIfNeeded functions.  These ensure-      that footnotes occur on lines by themselves (to make them-      easier to see and move) and do not screw up line wrapping.--  * Text.Pandoc.UTF8:  modified fromUTF8 to strip out the BOM-    if present.  Windows Notepad and other applications insert a-    BOM at the beginning of a UTF8 file.--  * Main.hs (tabFilter): Treat '\r' at end of line as newline (in-    addition to "\r\n" and '\n').--  * Added a writer option for wrapped text and a command-line option-    '--no-wrap', which disables text wrapping and minimizes whitespace-    in HTML. (Resolves Issue #26.)--    + Added support for '--no-wrap' to Main.hs.-    + Added wrapIfNeeded function to Text.Pandoc.Shared.-    + Use wrapIfNeeded instead of wrapped in the RST, Man, Docbook, and-      Markdown writers.-    + Added render and renderFragment helpers to HTML writer.--  * Modified html2markdown to run tidy only if the HTML cannot be-    parsed. Previously html2markdown piped all input through tidy-    before passing it to pandoc. This caused problems on certain pages-    (e.g. http://daringfireball.com/markdown) which have well-formed-    XHTML that causes tidy to choke. The solution is to pipe through-    tidy only if pandoc cannot parse the input by itself. This means-    that a temp file is now always used, even when input comes from a-    local file or standard input.--  * Removed 'version' constant from Main.hs; added 'pandocVersion' to-    Text.Pandoc library.--  * pandoc.cabal:--    + Modified to work with GHC 6.8 and Cabal configurations. (For GHC-      6.8, pretty and containers must be added to Build-Depends, and it-      is desirable to use the -O2 compiler option.)  Cabal configurations-      allows one to select options depending on the compiler version.-      For GHC 6.6, the splitBase option can be disabled.-    + pandoc.cabal.ghc66 is provided for users with older versions of-      Cabal, which do not support configurations.-    + Use Ghc-Prof-Options to ensure that '-auto-all' is used when-      '--enable-(executable|library)-profiling' is specified. Updated-      PROFILING instructions accordingly.--  * Makefile:--    + Makefile now checks GHC version. If GHC is 6.6, pandoc.cabal.ghc66-      is copied to pandoc.cabal, and the old pandoc.cabal is copied-      to pandoc.cabal.orig. Otherwise, pandoc.cabal is copied to-      pandoc.cabal.orig but otherwise unmodified. This way, the Makefile-      will work properly with either GHC 6.6 or 6.8.-    + Changed BUILDCONF to point to dist/setup-config, not .setup-config.-      This is where current versions of Cabal put it.-    + Added $(BUILDCMD) target, so setup doesn't get compiled every time.-    + Removed dependency of templates on ./templates, which is circular-      now that templates is a subdirectory of the top-level.--  * MacPorts Portfile:--    + Modified to install the pandoc library in addition to programs.-    + Installation must be done manually rather than using Makefile's-      install-all.-    + Note that the library must be registered in the activate phase,-      after the library files have been copied out of the destroot.-      Cabal generates a 'register.sh' script that will do this.--  * debian/control: Added libghc6-network-dev, libghc6-xhtml-dev, and-    libghc6-mtl-dev as dependencies for libghc6-pandoc-dev.-    Closes: #445235--  * debian/rules:  Converted to UTF-8.--  * Changed pandoc home page to http://johnmacfarlane.net/pandoc/.--  * Updated ASCIIMathML.js to latest version.--  * Directory structure:--    + Moved everything from src into the top-level directory.-    + Changed references to source directory in Makefile and-      pandoc.cabal.*.-    + Moved ASCIIMathML.js, headers, and ui into templates directory.-    + Modified fillTemplates.pl to reflect new paths.--  [ Recai Oktaş ]--  * Makefile: Fixed the issue of having two copies of the library-    documentation under some usage scenarios.--  * Replaced 'ghc' with '$(GHC)' in Makefile, and made GHC-    and GHC_PKG configurable through the environment, to support-    unusual ghc installations.  For example:-    GHC=/opt/ghc/bin/ghc GHC_PKG=/opt/ghc/bin/ghc-pkg make-- -- Recai Oktaş <roktas@debian.org>  Sun, 07 Oct 2007 20:51:43 +0300--pandoc (0.44) unstable; urgency=low--  [ John MacFarlane ]--  * Fixed bug in HTML writer:  when --toc was used, anchors were put around-    headers, which is invalid XHTML (block content within inline element).-    Now the anchors are put inside the header tags.  Resolves Issue #23.--  * Added xmlns attribute to html element in html writer tests.-    This attribute is added by more recent versions of the-    xhtml library (>= 3000), and is required for valid XHTML.--  [ Recai Oktaş ]--  * On configure, compile 'Setup.hs' to 'setup' and use 'setup' as the build-    command instead of 'runhaskell', which, on some platforms (such as s390,-    alpha, m68k), throws the following error:--        runhaskell Setup.hs configure --prefix=/usr-        ghc-6.6.1: not built for interactive use--    This causes a serious FTBFS bug.  Closes: #440668.-- -- Recai Oktaş <roktas@debian.org>  Mon, 03 Sep 2007 18:24:02 +0300--pandoc (0.43) unstable; urgency=low--  [ John MacFarlane ]--  * The focus of this release is performance.  The markdown parser-    is about five times faster than in 0.42, based on benchmarks-    with the TextMate manual.--  * Main.hs: Replaced CRFilter and tabFilter with single function-    tabFilter, which operates on the whole string rather than breaking-    it into lines, and handles dos-style line-endings as well as tabs.--  * Added separate LaTeX reader and native reader tests; removed-    round-trip tests.--  * Text.Pandoc.Shared:--    + Removed tabsToSpaces and tabsInLine (they were used only in Main.hs.)-    + General code cleanup (to elimante warnings when compiling with -Wall.)-    + Added 'wrapped' function, which helps wrap text into paragraphs,-      using the prettyprinting library.-    + Rewrote charsInBalanced and charsInBalanced'.-        - Documented restriction: open and close must be distinct characters.-        - Rearranged options for greater efficiency.-        - Bug fix: Changed inner call to charsInBalanced inside-          charsInBalanced' to charsInBalanced'.-    + anyLine now requires that the line end with a newline (not eof).-      This is a harmless assumption, since we always add newlines to the-      end of a block before parsing with anyLine, and it yields a 10% speed-      boost.-    + Removed unnecessary 'try' in anyLine.-    + Removed unneeded 'try' from romanNumeral parser.-    + Use notFollowedBy instead of notFollowedBy' in charsInBalanced.-    + Removed unneeded 'try' in parseFromString.-    + Removed unneeded 'try' from stringAnyCase.  (Now it behaves-      like 'string'.)-    + Changed definition of 'enclosed' in Text.Pandoc.Shared so that-      'try' is not automatically applied to the 'end' parser. Added-      'try' in calls to 'enclosed' where needed. Slight speed increase.--  * Writers:--    + Replaced individual wrapping routines in RST, Man, and Markdown-      writers with 'wrapped' from Text.Pandoc.Shared.-    + Rewrote LaTeX writer to use the prettyprinting library,-      so we get word wrapping, etc.-    + Modified latex writer tests for new latex writer using prettyprinter.-    + Fixed bug in LaTeX writer: autolinks would not cause-      '\usepackage{url}' to be put in the document header. Also, changes-      to state in enumerated list items would be overwritten.-    + In Markdown writer, escape paragraphs that begin with ordered list-      markers, so they don't get interpreted as ordered lists.--  * Text.Pandoc.Reades.LaTeX:--    + Fixed bug in LaTeX reader, which wrongly assumed that the roman-      numeral after "enum" in "setcounter" would consist entirely of-      "i"s. 'enumiv' is legitimate.-    + LaTeX command and environment names can't contain numbers.-    + Rearranged order of parsers in inline for slight speed improvement.-    + Added '`' to special characters and 'unescapedChar'.--  * Text.Pandoc.Readers.RST:--    + Removed unneeded try's in RST reader; also minor code cleanup.-    + Removed tabchar.-    + Rearranged parsers in inline (doubled speed).--  * Text.Pandoc.Readers.Markdown:--    + Skip notes parsing if running in strict mode. (This yields a nice-      speed improvement in strict mode.)-    + Simplify autolink parsing code, using Network.URI to test for-      URIs. Added dependency on network library to debian/control and-      pandoc.cabal.-    + More perspicuous definition of nonindentSpaces.-    + Removed unneeded 'try' in 'rawLine'.-    + Combined linebreak and whitespace into a new whitespace parser, to-      avoid unnecessary reparsing of space characters.-    + Removed unnecessary 'try' in 'codeBlock', 'ellipses', 'noteMarker',-      'multilineRow', 'dashedLine', 'rawHtmlBlocks'.-    + Use lookAhead in parsers for setext headers and definition lists-      to see if the next line begins appropriately; if not, don't waste-      any more time parsing.-    + Don't require blank lines after code block. (It's sufficient to-      end code block with a nonindented line.)-    + Changed definition of 'emph': italics with '_' must not-      be followed by an alphanumeric character. This is to help-      prevent interpretation of e.g. `[LC_TYPE]: my_type` as-      `[LC<em>TYPE]:my</em>type`.-    + Improved Markdown.pl-compatibility in referenceLink: the two parts-      of a reference-style link may be separated by one space, but not-      more... [a] [link], [not]    [a link].-    + Fixed markdown inline code parsing so it better accords with-      Markdown.pl: the marker for the end of the code section is a clump-      of the same number of `'s with which the section began, followed-      by a non-` character. So, for example,-         ` h ``` i ` -> `<code>h ``` i</code>`.-    + Split 'title' into 'linkTitle' and 'referenceTitle', since the-      rules are slightly different.-    + Rewrote 'para' for greater efficiency.-    + Rewrote link parsers for greater efficiency.-    + Removed redundant 'referenceLink' in definition of inline (it's-      already in 'link').-    + Refactored escapeChar so it doesn't need 'try'.-    + Refactored hrule for performance in Markdown reader.-    + More intelligent rearranging of 'inline' so that most frequently-      used parsers are tried first.-    + Removed tabchar parser, as whitespace handles tabs anyway.--  * Text.Pandoc.CharacterReferences:--    + Refactored.-    + Removed unnecessary 'try's for a speed improvement.-    + Removed unnecessary '&' and ';' from the entity table.--  * Build process:--    + Makefile: Get VERSION from cabal file, not Main.hs.-    + Modified MacPorts Portfile:-        - Depend on haddock-        - Build and install libraries and library documentation in-          addition to pandoc executable-        - Added template item for md5 sum in Portfile.in.-        - Incorporated changes from MacPorts repository (r28278).-    + FreeBSD port:  Don't try to generate distinfo in Makefile.-      It can be made using 'make makesum' in FreeBSD.-    + Make both freebsd and macports targets depend on tarball.--  * Website and documentation:--    + Updated INSTALL instructions.-    + Added pandocwiki demo to website.-    + Removed local references to Portfile, since pandoc is now in the-      MacPorts repository.-- -- Recai Oktaş <roktas@debian.org>  Sun, 02 Sep 2007 15:50:11 +0300--pandoc (0.42) unstable; urgency=low--  [ John MacFarlane ]--  * Main.hs: Use utf8 conversion on the extra files loaded with-    the -H, -C, -B, and -A options.  This fixes problems with unicode-    characters in these files.--  * Exposed Text.Pandoc.ASCIIMathML, since it is imported in-    Text.Pandoc.Readers.HTML and without it we get a linking error when-    using the library.--  * Markdown reader:--    + Added new rule for enhanced markdown ordered lists: if the list-      marker is a capital letter followed by a period (including a-      single-letter capital roman numeral), then it must be followed by-      at least two spaces. The point of this is to avoid accidentally-      treating people's initials as list markers: a paragraph might begin,-      "B. Russell was an English philosopher," and this shouldn't be-      treated as a list.  Documented change in README.-    + Blocks that start with "p. " and a digit are no longer treated-      as ordered lists (it's a page number).-    + Added a needed 'try' to listItem.-    + Removed check for a following setext header in endline.-      A full test is too inefficient (doubles benchmark time), and the-      substitute we had before is not 100% accurate.-    + Don't use Code elements for autolinks if --strict specified.--  * LaTeX writer:  When a footnote ends with a Verbatim environment, the-    close } of the footnote cannot occur on the same line or an error occurs.-    Fixed this by adding a newline before the closing } of every footnote.--  * HTML writer:-    + Removed incorrect "{}" around style information in HTML tables.-      Column widths now work properly in HTML.-    + If --strict option is specified (and --toc is not), don't include-      identifiers in headers, for better Markdown compatibility.--  * Build process:--    + Separated $(web_dest) and website targets.-    + In website, index.txt is now constructed from template index.txt.in.-    + Added freebsd target to Markefile. This creates the freebsd Makefile-      from Makefile.in, and creates distinfo.  Removed Makefile and distinfo-      from the repository.-    + Added macport target to Makefile. Portfile is built from template-      Portfile.in.-    + Removed OSX package targets.  (Too many difficulties involving-      dependencies on dynamic libraries.)-    + More complete INSTALL instructions for all architectures.--  * Website:-    + Added a programming demo, pandocwiki.--  [ Recai Oktaş ]--  * Do not forget to close pandoc's ITP.  Closes: #391666-- -- Recai Oktaş <roktas@debian.org>  Sun, 26 Aug 2007 22:51:32 +0300--pandoc (0.41) unstable; urgency=low--  [ John MacFarlane ]--  * Fixed bugs in HTML reader:-    + Skip material at end *only if* `</html>` is present (previously,-      only part of the document would be parsed if an error was-      found; now a proper error message is given).-    + Added new constant eitherBlockOrInline with elements that may-      count either as block-level or as inline. Modified isInline and-      isBlock to take this into account.-    + Modified rawHtmlBlock to accept any tag (even an inline tag):-      this is innocuous, because rawHtmlBlock is tried only if a regular-      inline element can't be parsed.-    + Added a necessary 'try' in definition of 'para'.--  * Fixed bug in markdown ordered list parsing.  The problem was that-    anyOrderedListStart did not check for a space following the-    ordered list marker.  So in 'A.B. 2007' the parser would be-    expecting a list item, but would not find one, causing an error.-    Fixed a similar bug in the RST reader.  Resolves Issue #22.--  * Refactored RST and Markdown readers using parseFromString.--  * LaTeX reader will now skip anything after \end{document}.--  * Fixed blockquote output in markdown writer: previously, block-    quotes in indented contexts would be indented only in the first-    line.--  * Added note to INSTALL about variations in versions of the xhtml-    library that can lead to failed tests (thanks to Leif LeBaron).-- -- Recai Oktaş <roktas@debian.org>  Sun, 19 Aug 2007 23:26:07 +0300--pandoc (0.4) unstable; urgency=low--  [ John MacFarlane ]--  * Added two new output formats: groff man pages and ConTeXt. By-    default, output files with extensions ".ctx" and ".context" are-    assumed to be ConTeXt, and output files with single-digit extensions-    are assumed to be man pages.--  * Enhanced ordered lists (documented in README, under Lists):-    + The OrderedList block element now stores information about-      list number style, list number delimiter, and starting number.-    + The readers parse this information when possible.-    + The writers use this information to style ordered lists.-    + The enhancement can be disabled using the --strict option.--  * Added support for tables (with a new Table block element). Two kinds-    of tables are supported: a simple table with one-line rows, and a-    more complex variety with multiline rows. All output formats are-    supported, but only markdown tables are parsed at the moment. The-    syntax is documented in README.--  * Added support for definition lists (with a new DefinitionList block-    element). All output and input formats are supported. The syntax is-    documented in README.--  * Added support for superscripts and subscripts (with new Superscript-    and Subscript inline elements).  All input and output-    formats.  The syntax is documented in README.--  * Added support for strikeout (with a new Strikeout inline element).-    All input and output formats are supported. Thanks to Bradley Kuhn,-    who contributed a patch. The syntax is documented in README. Resolves-    Issue #18.--  * Added a --toc|--table-of-contents option.  This causes an automatically-    generated table of contents (or an instruction that creates one) to-    be inserted at the beginning of the document. Not supported in S5,-    DocBook, or man page writers.--  * Modified the -m|--asciimathml option:--    + If an optional URL argument is provided, a link is inserted-      instead of the contents of the ASCIIMathML.js script.-    + Nothing is inserted unless the document actually contains-      LaTeX math.--  * Removed Blank block element as unnecessary.--  * Removed Key and Note blocks from the Pandoc data structure. All-    links are now stored as explicit links, and note contents are-    stored with the (inline) notes.--    + All link Targets are now explicit (URL, title) pairs; there-      is no longer a 'Ref' target.-    + Markdown and RST parsers now need to extract data from key and-      note blocks and insert them into the relevant inline elements.-      Other parsers have been simplified, since there is no longer any need-      to construct separate key and note blocks.-    + Markdown, RST, and HTML writers need to construct lists of-      notes; Markdown and RST writers need to construct lists of link-      references (when the --reference-links option is specified); and-      the RST writer needs to construct a list of image substitution-      references. All writers have been rewritten to use the State monad-      when state is required.-    + Several functions (generateReference, keyTable,-      replaceReferenceLinks, replaceRefLinksBlockList, and some auxiliaries-      used by them) have been removed from Text.Pandoc.Shared, since-      they are no longer needed. New functions and data structures-      (Reference, isNoteBlock, isKeyBlock, isLineClump) have been-      added. The functions inTags, selfClosingTag, inTagsSimple, and-      inTagsIndented have been moved to the DocBook writer, since that-      is now the only module that uses them. NoteTable is now exported-      in Text.Pandoc.Shared.-    + Added stateKeys and stateNotes to ParserState; removed stateKeyBlocks,-      stateKeysUsed, stateNoteBlocks, stateNoteIdentifiers, stateInlineLinks.-    + Added writerNotes and writerReferenceLinks to WriterOptions.--  * Added Text.Pandoc module that exports basic readers, writers,-    definitions, and utility functions. This should export everything-    needed for most uses of Pandoc libraries. The haddock documentation-    includes a short example program.--  * Text.Pandoc.ASCIIMathML is no longer an exported module.--  * Added Text.Pandoc.Blocks module to help in printing markdown-    and RST tables.  This module provides functions for working with-    fixed-width blocks of text--e.g., placing them side by side, as-    in a table row.--  * Refactored to avoid reliance on Haskell's Text.Regex library, which-    (a) is slow, and (b) does not properly handle unicode.  This fixed-    some strange bugs, e.g. in parsing S-cedilla, and improved performance.--    + Replaced 'gsub' with a general list function  'substitute'-      that does not rely on Text.Regex.-    + Rewrote extractTagType in HTML reader so that it doesn't use-      regexs.-    + In Markdown reader, replaced email regex test with a custom email-      autolink parser (autoLinkEmail). Also replaced selfClosingTag regex-      with a custom function isSelfClosingTag.-    + Modified Docbook writer so that it doesn't rely on Text.Regex for-      detecting 'mailto' links.-    + Removed escapePreservingRegex and reamped entity-handling-      functions in Text.Pandoc.Shared and Text.Pandoc.CharacterReferences to-      avoid reliance on Text.Regex (see below on character reference-      handling changes).--  * Renamed Text.Pandoc.Entities as Text.Pandoc.CharacterReferences.--  * Changed handling of XML entities.  Entities are now parsed (and unicode-    characters returned) in the Markdown and HTML readers, rather than being-    handled in the writers.  In HTML and Docbook writers, UTF-8 is now used-    instead of entities for characters above 128.  This makes the HTML and-    DocBook output much more readable and more easily editable.--    + Removed sgmlHexEntity, sgmlDecimalEntity, sgmlNamedEntity, and-      sgmlCharacterEntity regexes from Text.Pandoc.Shared.-    + Renamed escapeSGMLChar to escapeCharForXML.  Added escapeStringForXML.-      Moved both functions to Text.Pandoc.Writers.Docbook.-    + Added characterReference parser to Text.Pandoc.CharacterReferences.-      This parses a string and return a unicode character.-    + Rewrote decodeCharacterReferences to use the new parser instead of-      Text.Regex.-    + Added new charRef parser for Markdown and HTML, which replaces the-      old 'entity' parser. Added '&' as a special character in Markdown reader.-    + Modified HTML and Markdown readers to call decodeEntities on all raw-      strings (e.g. authors, dates, link titles), to ensure that no-      unprocessed entities are included in the native representation of-      the document.  (In the HTML reader, most of this work is done by a-      change in extractAttributeName.)-    + In XML and Markdown output, escape unicode nonbreaking space as '&nbsp;',-      since a unicode non-breaking space is impossible to distinguish visually-      from a regular space.  (Resolves Issue #3.)-    + Removed encodeEntitiesNumerical.-    + Use Data.Map for entityTable and (new) reverseEntityTable, for a-      slight performance boost over the old association list.-    + Removed unneeded decodeEntities from 'str' parser in HTML and-      Markdown readers.--  * Text.Pandoc.UTF8:  Renamed encodeUTF8 to toUTF8, decodeUTF8 to-    fromUTF8, for clarity.--  * Replaced old haskell98 module names replaced by hierarchical module-    names, e.g. List by Data.List.  Removed haskell98 from dependencies-    in pandoc.cabal, and added mtl (needed for state monad). Substituted-    xhtml for html.--  * Refactored and cleaned up character escaping in writers, using-    backslashEscapes and escapeStringUsing functions.--  * Instead of adding "\n\n" to the end of an input string in Main.hs,-    this is now done in the readers. This makes the libraries behave-    the way you'd expect from the pandoc program. Resolves Issue #10.--  * URLs and email addresses in autolinks are now typeset as Code.--  * In Main.hs, changed putStr to putStrLn -- mainly because MacOS X-    doesn't display the whole output unless there's a line ending.--  * Major code cleanup in all modules, for greater consistency, concision,-    and readability.--  * HTML reader:--    + Fixed several bugs (extractTagType, attribute parsing).-    + Remove Null blocks in lists of blocks when possible.-    + Allow HTML comments as raw HTML inline.--  * Markdown reader:--    + Ordered list items may no longer begin with uppercase letters, or-      letters greater than 'n'.  (This prevents first initials and page-      reference, e.g. 'p. 400', from being parsed as beginning lists.)-      Also, numbers beginning list items may no longer end with ')',-      which is now allowed only after letters.  Note: These changes-      may cause documents to be parsed differently. Users should take-      care in upgrading.-    + Changed autoLink parsing to conform better to Markdown.pl's-      behavior. `<google.com>` is not treated as a link, but-      `<http://google.com>`, `<ftp://google.com>`, and-      `<mailto:google@google.com>` are.-    + Cleaned up handling of embedded quotes in link titles.  Now these are-      stored as a '"' character, not as '&quot;'.-    + Use lookAhead parser for the 'first pass' (looking for reference keys),-      instead of parsing normally, then using setInput to reset input.  This-      yields a slight performance boost.-    + Fixed several bugs in smart quote recognition.-    + Fixed bug in indentSpaces (which didn't properly handle-      cases with mixed spaces and tabs).-    + Consolidated 'text', 'special', and 'inline' into 'inline'.-    + Fixed bug which allowed URL and title to be separated by multiple blank-      lines in links and reference keys.  They can be on separate lines but-      can't have blank lines between them.-    + Correctly handle bracketed text inside inline footnotes and links,using-      new function inlinesInBalanced.  Resolves Issue #14.-    + Fixed bug in footnotes: links in footnotes were not being-      processed. Solution: three-stage parse. First, get all the-      reference keys and add information to state. Next, get all the-      notes and add information to state. (Reference keys may be needed-      at this stage.) Finally, parse everything else.-    + Replaced named constants like 'emphStart' with literals.-    + Removed an extra occurrence of escapedChar in definition of inline.--  * RST reader:--    + Allow the URI in a RST hyperlink target to start on the line-      after the reference key.-    + Added 'try' in front of 'string', where needed, or used a different-      parser.  This fixes a bug where ````` would not be correctly parsed as-      a verbatim `.-    + Fixed slow performance in parsing inline literals in RST reader.  The-      problem was that ``#`` was seen by 'inline' as a potential link or image.-      Fix:  inserted 'notFollowedBy (char '`')' in link parsers.-      Resolves Issue #8.-    + Use lookAhead instead of getInput/setInput in RST reader.  Removed-      unneeded getState call, since lookAhead automatically saves and-      restores the parser state.-    + Allow hyperlink target URIs to be split over multiple lines, and-      to start on the line after the reference. Resolves Issue #7.-    + Fixed handling of autolinks.--  * LaTeX reader:--    + Replaced 'choice [(try (string ...), ...]' idiom with 'oneOfStrings',-      for clarity.-    + Added clauses for tilde and caret. Tilde is \ensuremath{\sim}, and-      caret is \^{}, not \^ as before.-    + Added parsing for \url.-    + Parse \texttt{} as code, provided there's nothing fancy inside.--  * HTML writer:--    + Modified HTML writer to use the Text.XHtml library. This results-      in cleaner, faster code, and it makes it easier to use Pandoc in-      other projects, like wikis, which use Text.XHtml. Two functions are-      now provided, writeHtml and writeHtmlString: the former outputs an-      Html structure, the latter a rendered string. The S5 writer is also-      changed, in parallel ways (writeS5, writeS5String).-    + The Html header is now written programmatically, so it has been-      removed from the 'headers' directory. The S5 header is still-      needed, but the doctype and some of the meta declarations have-      been removed, since they are written programmatically. This change-      introduces a new dependency on the xhtml package.-    + Fixed two bugs in email obfuscation involving improper escaping-      of '&' in the `<noscript>` section and in `--strict` mode. Resolves-      Issue #9.-    + Fixed another bug in email obfuscation: If the text to be obfuscated-      contains an entity, this needs to be decoded before obfuscation.-      Thanks to thsutton for the patch. Resolves Issue #15.-    + Changed the way the backlink is displayed in HTML footnotes.-      Instead of appearing on a line by itself, it now generally-      appears on the last line of the note.  (Exception:  when the-      note does not end with a Plain or Para block.) This saves space-      and looks better.-    + Added automatic unique identifiers to headers:-      - The identifier is derived from the header via a scheme-        documented in README.-      - WriterState now includes a list of header identifiers and a table-        of contents in addition to notes.-      - The function uniqueIdentifiers creates a list of unique identifiers-        from a list of inline lists (e.g. headers).-      - This list is part of WriterState and gets consumed by blockToHtml-        each time a header is encountered.-    + Include CSS for .strikethrough class in header only if strikethrough-      text appears in the document.-    + If the 'strict' option is specified, elements that do not appear in-      standard markdown (like definition lists) are passed through as-      raw HTML.-    + Simplified treatment of autolinks, using pattern matching instead of-      conditionals.--  * Markdown writer:--    + Links in markdown output are now printed as inline links by default,-      rather than reference links.  A --reference-links option has been added-      that forces links to be printed as reference links.  Resolves Issue #4.-    + Use autolinks when possible.  Instead of `[site.com](site.com)`,-      use `<site.com>`.--  * LaTeX writer:--    + Rewrote to use the State monad. The preamble now includes only those-      packages that are actually required, given the document's content.-      Thus, for example, if strikeout is not used, ulem is not required.-      Modified LaTeXHeader accordingly.-    + Modified LaTeX writer to insert '\,' between consecutive quotes.-    + Removed unused function tableRowColumnWidths.-    + Simplified code for escaping special characters.-    + Leave extra blank line after \maketitle.-    + Include empty '\author{}' when no author specified to avoid LaTeX-      errors.-    + Include fancyvrb code in header only if needed -- that is, only-      if there is actually code in a footnote.-    + Use \url{} for autolinks.-    + Include [mathletters] option in ucs package, so that basic unicode-      Greek letters will work correctly.--  * RST writer:  Force blank line before lists, so that sublists will-    be handled correctly.--  * Docbook writer:  Fixed a bug:  email links with text, like-    [foo](me@bar.baz), were being incorrectly treated as autolinks.--  * Removed Text.ParserCombinators.Pandoc and moved all its functions to-    Text.Pandoc.Shared.--  * Text.Pandoc.Shared:--    + Added defaultWriterOptions.-    + Added writerTableOfContents to WriterOptions.-    + Added writerIgnoreNotes option to WriterOptions.  This is needed-      for processing header blocks for a table of contents, since notes on-      headers should not appear in the TOC.-    + Added prettyprinting for native Table format.-    + Removed some unneeded imports.-    + Moved escape and nullBlock parsers from-      Text.ParserCombinators.Pandoc, since the latter is for-      general-purpose parsers that don't depend on Text.Pandoc.Definition.-    + Moved isHeaderBlock from Text.Pandoc.Writers.HTML.-    + Moved Element, headerAtLeast, and hierarchicalize from Docbook-      writer, because HTML writer now uses these in constructing a table-      of contents.-    + Added clauses for new inline elements (Strikeout, Superscript,-      Subscript) to refsMatch.-    + Removed backslashEscape; added new functions escapeStringUsing and-      backslashEscapes.-    + Moved failIfStrict from markdown reader, since it is now used also-      by the HTML reader.-    + Added a 'try' to the definition of indentSpaces.-    + In definition of 'reference', added check to make sure it's not a note-      reference.-    + Added functions: camelCaseToHyphenated, toRomanNumeral,-      anyOrderedListMarker, orderedListmarker, orderedListMarkers,-      charsInBalanced', withHorizDisplacement, romanNumeral-    + Fixed a bug in the anyLine parser. Previously it would parse an empty-      string "", but it should fail on an empty string, or we get an error-      when it is used inside "many" combinators.-    + Removed followedBy' parser, replacing it with the lookAhead parser from-      Parsec.-    + Added some needed 'try's before multicharacter parsers, especially in-      'option' contexts.-    + Removed the 'try' from the 'end' parser in 'enclosed', so that-      'enclosed' behaves like 'option', 'manyTill', etc.-    + Added lineClump parser, which parses a raw line block up to and-      including any following blank lines.-    + Renamed parseFromStr to parseFromString.-    + Added a 'try' to the 'end' parser in 'enclosed'.  This makes errors in-      the use of 'enclosed' less likely. Removed some now-unnecessary 'try's-      in calling code.-    + Removed unneeded 'try' in blanklines.-    + Removed endsWith function and rewrote calling functions to use-      isSuffixOf instead.-    + Added >>~ combinator.-    + Fixed bug in normalizeSpaces:  Space:Str "":Space should compress to-      Space.--  * Refactored runtests.pl; added separate tests for tables.--  * Shell scripts:--    + Added -asxhtml flag to tidy in html2markdown. This will-      perhaps help the parser, which expects closing tags.-    + Modified markdown2pdf to run pdflatex a second time if --toc or-      --table-of-contents was specified; otherwise the table of-      contents won't appear.-    + Modified markdown2pdf to print a helpful message if the 'ulem'-      LaTeX package is required and not found.--  * Changes to build process:--    + Dropped support for compilation with GHC 6.4.  GHC 6.6 or higher-      is now required.-    + Removed cabalize and Pandoc.cabal.in. The repository now contains-      pandoc.cabal itself.-    + Pandoc.cabal has been changed to pandoc.cabal, because HackageDB-      likes the cabal file to have the same name as the tarball.-    + Expanded and revised the package description in pandoc.cabal.-      Revised the package synopsis.-    + The tarball built by 'make tarball' now contains files built from-      templates (including man pages and shell scripts), so pandoc can-      be built directly using Cabal tools, without preprocessing.-    + Executable binaries are now stripped before installing.-    + Man pages are now generated from markdown sources, using pandoc's-      man page writer.-    + Use HTML version of README (instead of RTF) in Mac OS X installer.-    + Instead of testing for the existence of a pandoc symlink in build-exec,-      use ln -f.--  * Documentation:--    + Updated README and man pages with information on new features.-    + Updated INSTALL instructions with some useful clarifications and-      links.-    + Updated web content.--  * Added FreeBSD port.--  [ Recai Oktaş ]--  * debian/control:--    + Changed pandoc's Build-Depends to include libghc6-mtl-dev and-      libghc6-xhtml-dev.  Removed libghc6-html-dev.-    + Suggest texlive-latex-recommended | tetex-extra instead of-      tetex-bin.  This brings in fancyvrb and unicode support.-- -- Recai Oktaş <roktas@debian.org>  Tue, 16 Jan 2007 00:37:21 +0200--pandoc (0.3) unstable; urgency=low--  [ John MacFarlane ]--  * Changes in pandoc options:--    + Allow options to follow or precede arguments.-    + Changed '--smartypants' to '--smart' and adjusted symbols accordingly.-    + Added '--strict' option.-    + Added '-o/--output' option.-    + Added '--dump-args' and '--ignore-args' options (for use in wrappers).-    + Modified '-v' and '-h' output to go to STDERR, not STDOUT, and return-      error conditions.  This is helpful for writing wrappers.-    + Added copyright message to '-v' output, modeled after FSF messages.-    + Reformatted usage message so that it doesn't wrap illegibly.-    + Removed extra blanks after '-h' and '-D' output.--  * Added docbook writer.--  * Added implicit setting of default input and output format based-    on input and output filename extensions.  These defaults are-    overridden if explicit input and output formats are specified using-    '-t', '-f', '-r', or '-w' options.  Documented in pandoc(1) man page-    and README.--  * Allow ordered list items to begin with (single) letters, as well-    as numbers.  The list item marker may now be terminated either by-    '.' or by ')'.  This extension to standard markdown is documented-    in README.--  * Revised footnote syntax.  (See README for full details.)  The-    '[^1]' format now standard in markdown extensions is supported,-    as are inline footnotes with this syntax: `^[My note.]`.-    The earlier footnote syntax `^(1)` is no longer supported.--  * Improved HTML representation of footnotes.  All footnotes-    are now auto-numbered and appear in an ordered list at the-    end of the HTML document.  Since the default appearance is now-    acceptable, the old footnote styles have been removed from the-    HTML header.--  * Bug fixes:--    + Fixed a serious bug in the markdown, LaTeX, and RST readers.-      These readers ran 'runParser' on processed chunks of text to handle-      embedded block lists in lists and quotation blocks.  But then-      any changes made to the parser state in these chunks was lost,-      as the state is local to the parser.  So, for example, footnotes-      didn't work in quotes or list items.  The fix:  instead of calling-      runParser on some raw text, use setInput to make it the input, then-      parse it, then use setInput to restore the input to what it was-      before.  This is shorter and more elegant, and it fixes the problem.-    + Fixed bug in notFollowedBy' combinator (adding 'try' before-      'parser').  Adjusted code that uses this combinator accordingly.-    + Fixed bug in RTF writer that caused improper indentation on-      footnotes occurring in indented blocks like lists.-    + Fixed parsing of metadata in LaTeX reader.  Now the title, author,-      and date are parsed correctly.  Everything else in the preamble-      is skipped.-    + Modified escapedChar in LaTeX reader to allow a '\' at the end of a-      line to count as escaped whitespace.-    + Modified LaTeX reader to produce inline links rather than reference-      links.  Otherwise, links in footnotes aren't handled properly.-    + Fixed handling of titles in links in Markdown reader, so that-      embedded quotation marks are now handled properly.-    + Fixed Markdown reader's handling of embedded brackets in links.-    + Fixed Markdown reader so that it only parses bracketed material-      as a reference link if there is actually a corresponding key.-    + Revised inline code parsing in Markdown reader to conform to-      markdown standard.  Now any number of `s can begin inline code,-      which will end with the same number of `s.  For example, to-      have two backticks as code, write ``` `` ```.  Modified Markdown-      writer accordingly.-    + Fixed bug in text-wrapping routine in Markdown and RST writers.-      Now LineBreaks no longer cause wrapping problems.-    + Supported hexadecimal numerical entity references as well as-      decimal ones.-    + Fixed bug in Markdown reader's handling of underscores and other-      inline formatting markers inside reference labels:  for example,-      in '[A_B]: /url/a_b', the material between underscores was being-      parsed as emphasized inlines.-    + Changed Markdown reader's handling of backslash escapes so that-      only non-alphanumeric characters can be escaped.  Strict mode-      follows Markdown.pl in only allowing a select group of punctuation-      characters to be escaped.-    + Modified HTML reader to skip a newline following a `<br>` tag.-      Otherwise the newline will be treated as a space at the beginning-      of the next line.--  * Made handling of code blocks more consistent.  Previously, some-    readers allowed trailing newlines, while others stripped them.-    Now, all readers strip trailing newlines in code blocks. Writers-    insert a newline at the end of code blocks as needed.--  * Modified readers to make spacing at the end of output more consistent.--  * Minor improvements to LaTeX reader:--    + '\thanks' now treated like a footnote.-    + Simplified parsing of LaTeX command arguments and options.-      commandArgs now returns a list of arguments OR options (in-      whatever order they appear).  The brackets are included, and-      a new stripFirstAndLast function is provided to strip them off-      when needed.  This fixes a problem in dealing with \newcommand-      and \newenvironment.--  * Revised RTF writer:--    + Default font is now Helvetica.-    + An '\f0' is added to each '\pard', so that font resizing works-      correctly.--  * Moved handling of "smart typography" from the writers to the Markdown-    and LaTeX readers.  This allows great simplification of the writers-    and more accurate smart quotes, dashes, and ellipses.  DocBook can-    now use `<quote>`.  The '--smart' option now toggles an option in-    the parser state rather than a writer option.  Several new kinds-    of inline elements have been added: Quoted, Ellipses, Apostrophe,-    EmDash, EnDash.--  * Changes in HTML writer:--    + Include title block in header even when title is null.-    + Made javascript obfuscation of emails even more obfuscatory,-      by combining it with entity obfuscation.--  * Changed default ASCIIMathML text color to black.--  * Test suite:--    + Added --strip-trailing-cr option to diff in runtests.pl, for-      compatibility with Windows.-    + Added regression tests with footnotes in quote blocks and lists.--  * Makefile changes:--    + osx-pkg target creates a Mac OS X package (directory). New osx-      directory contains files needed for construction of the package.-    + osx-dmg target creates a compressed disk image containing the package.-    + win-pkg target creates Windows binary package.-    + tarball target creates distribution source tarball.-    + website target generates pandoc's website automatically, including-      demos.  New 'web' directory contains files needed for construction-      of the website (which will be created as the 'pandoc' subdirectory-      of 'web').-    + Makefile checks to see if we're running Windows/Cygwin; if so,-      a '.exe' extension is added to each executable in EXECS.--  * Removed all wrappers except markdown2pdf and html2markdown.--  * Added new wrapper hsmarkdown, to be used as a drop-in replacement-    for Markdown.pl.  hsmarkdown calls pandoc with the '--strict'-    option and disables other options.--  * Added code to html2markdown that tries to determine the character-    encoding of an HTML file, by parsing the "Content-type" meta tag.--    + If the encoding can't be determined, then if the content is local,-      the local encoding is used; if it comes from a URL, UTF-8 is used-      by default.-    + If input is from STDIN, don't try to determine character encoding.-    + Encoding can be specified explicitly using '-e' option.--  * Improved warning messages in wrappers:--    + Print warning if iconv not available-    + More user-friendly error messages in markdown2pdf, when-      pdflatex fails.--  * Code cleanup:--    + Renamed 'Text/Pandoc/HtmlEntities' module to-      'Text/Pandoc/Entities'. Also changed function names so as-      not to be HTML-specific.-    + Refactored SGML string escaping functions from HTML and Docbook-      writers into Text/Pandoc/Shared.  (escapeSGML, stringToSGML)-    + Removed 'BlockQuoteContext' from ParserContext, as it isn't-      used anywhere.-    + Removed splitBySpace and replaced it with a general, polymorphic-      splitBy function.-    + Refactored LaTeX reader for clarity (added isArg function).-    + Converted some CR's to LF's in src/ui/default/print.css.-    + Added license text to top of source files.-    + Added module data for haddock to source files.-    + Reformatted code for consistency.--  * Rewrote documentation and man pages.  Split README into INSTALL-    and README.--  * Split LICENSE into COPYING and COPYRIGHT.--  * Removed TODO, since we now maintain ToDo on the wiki.--  * Made COPYRIGHT in top level a symlink to debian/copyright, to avoid-    duplication.--  [ Recai Oktaş ]--  * Revamped build process to conform to debian standards and created-    a proper debian package.  Closes: #391666.--  * Modified build process to support GHC 6.6.--    + The package can still be compiled using GHC 6.4.2, though because-      of dependencies the "make deb" target works only with GHC 6.6+.-    + The script 'cabalize' is used to create an appropriate-      'Pandoc.cabal' from 'Pandoc.cabal.in', depending on the GHC and-      Cabal versions.--  * Refactored template processing (fillTemplates.pl).--  * Modified wrapper scripts to make them more robust and portable.-    To avoid code duplication and ensure consistency, wrappers are-    generated via a templating system from templates in src/wrappers.--    + Wrappers now accept multiple filenames, when appropriate.-    + Spaces and tabs allowed in filenames.-    + getopts shell builtin is used for portable option parsing.-    + Improved html2markdown's web grabber code, making it more robust,-      configurable and verbose.  Added '-e', '-g' options.-- -- Recai Oktaş <roktas@debian.org>  Fri, 05 Jan 2007 09:41:19 +0200--pandoc (0.2) unstable; urgency=low--  * Fixed unicode/utf-8 translation-- -- John MacFarlane <jgm@berkeley.edu>  Mon,  14 Aug 2006 00:00:00 -0400--pandoc (0.1) unstable; urgency=low--  * Initial creation of debian package-- -- John MacFarlane <jgm@berkeley.edu>  Mon,  14 Aug 2006 00:00:00 -0400
+ changelog.md view
@@ -0,0 +1,16720 @@+# Revision history for pandoc++## pandoc 2.8 (2019-11-22)++  * Improvements in templates system (from doctemplates):++    + Pandoc templates now support a number of new features that+      have been added in doctemplates: notably, `elseif`, `it`,+      partials, filters, and syntax to control nesting and reflowing of+      text.  These changes make pandoc more suitable out of the+      box for generating plain-text documents from data in YAML+      metadata.  It can create enumerated lists and even tabular+      structures.+    + We now used templates parameterized on doclayout Doc types.+      The main impact of this change is better reflowing of+      content interpolated into templates.  Previously,+      interpolated variables were rendered independently and+      intepolated as strings, which could lead to overly long+      lines. Now the templates interpolated as Doc values which+      may include breaking spaces, and reflowing occurs after+      template interpolation rather than before.+    + Remove code from the LaTeX, Docbook, and JATS writers that+      looked in the template for strings to determine whether it+      is a book or an article, or whether csquotes is used. This+      was always kludgy and unreliable.+    + Change template code to use new API for doctemplates.++  * Add `--defaults`/`-d` option.  This adds the ability to specify+    a collection of default values for options in a YAML file. For+    example, one might define a set of defaults for letters,+    and then do `pandoc -d letter myletter.md -o myletter.pdf`.+    See the documentation of this feature in MANUAL.txt.++  * Raise error on unsupported extensions (#4338).++  * The `--list-extensions[=FORMAT]` option now lists only+    extensions that affect the given FORMAT.++  * Add `-L` option as shortcut for `--lua-filter`.++  * Add `--shift-heading-level-by` option and deprecate+    `--base-heading-level` (#5615). The new option does+   everything the old one does, but also allows negative shifts.+   It also promotes the document metadata (if not null) to a+   level-1 heading with a +1 shift, and demotes an initial+   level-1 heading to document metadata with a -1 shift. This+   supports converting documents that use an initial level-1+   heading for the document title.++  * Allow `--metadata-file` to be used repeatedly to include+    multiple metadata files (Owen McGrath, #5702). Values in+    files specified first will be overridden by those in later+    files.++  * `--ascii` now uses numerical hex character references (#5718).++  * Allow PDF output to stdout (#5751).  PDF output now behaves like other+    binary formats: it will not be output to the terminal, but can be+    sent to stdout using either `-o -` or a pipe.  The intermediate format+    will be determined based on the setting of `--pdf-engine`.++  * Make some writers sensitive to 'unlisted' class on headings (#1762).+    If this is present on a heading with the 'unnumbered' class,+    the heading won't appear in the TOC.  This class has no+    effect if 'unnumbered' is not also specified.  This affects HTML-based+    writers (including slide shows and EPUB), LateX (including beamer), RTF,+    and PowerPoint.  Other writers do not yet support `unlisted`.++  * Fix `gfm_auto_identifiers` behavior with emojis (#5813).  Note that+    we also now use emoji names for emojis when `ascii_identifiers`+    is enabled.++  * When `--ipynb-output` is used with the default "best" format, strip+    ANSI escape codes for non-ipynb output (#5633).  These cause problems+    in many formats, including LaTeX.++  * Don't look for template files remotely for remote input (#5579).+    Previously pandoc would look for the template at a remote URL when a+    URL was used for the input file, instead of taking it from the+    data directory.++  * Allow combining `-Vheader-includes` and `--include-in-header` (#5904).+    Previously `header-includes` set as a variable would be+    clobbered by material included using `--include-in-header`.++  * Change merge behavior for metadata.  Previously, if a document+    contained two YAML metadata blocks that set the same field, the+    conflict would be resolved in favor of the first. Now it is resolved+    in favor of the second (due to a change in pandoc-types).+    This makes the behavior more uniform with other things in pandoc+    (such as reference links and `--metadata-file`).++  * Don't add a newline to fragment output if there's already one.++  * Change exit codes and document in MANUAL.txt:++    + `PandocAppError` was 1, is now 4+    + `PandocOptionError` was 2, is now 6+    + `PandocMakePDFError` was 65, is now 66++  * Switch to new pandoc-types and use Text instead of String [API change].+    (Christian Despres, #5884).++  * HTML reader:++    + Better handling of `<q>` with cite attribute (#5798, Ole Martin Ruud).+      If a `<q>` tag has a `cite` attribute, we interpret it as a Quoted+      element with an inner Span.+    + Add support for HTML `<samp>` element (#5792, Amogh Rathore).+      The `<samp>` element is parsed as Code with class `sample`.+    + Add support for HTML `<var>` element (#5799, Amogh Rathore).+      The `<var>` element is parsed as Code with class `variable`.+    + Add support for `<mark>` elements (Florian B, #5797).  Parse+      `<mark>` elements from HTML as Spans with class `mark`.+    + Add support for `<kbd>` elements, parsing them as Span with class+      `kbd` (Daniele D'Orazio, #5796).+    + Add support for `<dfn>`, parsing this as a Span with class `dfn`+      (#5882, Florian Beeres).+++  * RST reader:++    + Keep `name` property in `imgAttr` (Brian Leung, #5619).+    + Fixed parsing of indented blocks (#5753).  We were requiring+      consistent indentation, but this isn't required by RST.+    + Use title, not admonition-title, for admonition title.+      This puts RST reader into alignment with docbook reader.+    + Don't strip final underscore from absolute URI (#5763).+    + Avoid spurious warning when resolving links to internal anchors+      ending with `_` (#5763).++  * Org reader:++    + Accept `ATTR_LATEX` in block attributes (Albert Krewinkel, #5648).+      Attributes for LaTeX output are accepted as valid block attributes;+      however, their values are ignored.+    + Modify handling of example blocks (Brian Leung, #5717).+    + Allow the `-i` switch to ignore leading spaces (Brian Leung).+    + Handle awkwardly-aligned code blocks within lists (Brian Leung).+      Code blocks in Org lists must have their `#+BEGIN_` aligned in a+      reasonable way, but their other components can be+      positioned otherwise.+    + Fix parsing of empty comment lines (#5856, Albert Krewinkel).+      Comment lines in Org-mode can be completely empty.++  * Muse reader (Alexander Krotov):++    + Add RTL support (#5551).+    + Do not allow closing asterisks to be followed by `*`.+    + Do not split series of asterisks into symbols and emphasis (#5821).+    + Do not terminate emphasis on `*` not followed by space.++  * DokuWiki reader:++    + Parse markup inside monospace ('') (#5916, Alexander Krotov).++  * Docx reader:++    + Move style-parsing-specific code to a new unexported module,+      Text.Pandoc.Readers.Docx.Parse.Styles (Nikolay Yakimov).+    + Move StyleMap to docx writer (Nikolay Yakimov).+    + Only use LTR when it is overriding BiDi setting (#5723, Jesse+      Rosenthal).  The left-to-right direction setting in docx is used+      in the spec only for overriding an explicit right-to-left setting.+      We only process it when it happens in a paragraph set with BiDi.+      This is especially important for docs exported from Google Docs,+      which explicitly (and unnecessarily) set `rtl=0` for every paragraph.+    + Fix list number resumption for sublists (#4324).+      The first list item of a sublist should not resume numbering+      from the number of the last sublist item of the same level,+      if that sublist was a sublist of a different list item.++  * Docbook reader:++    + Richer parse for admonitions (Michael Peyton Jones, #1234).+      Instead of parsing admonitions as blockquotes, we now parse+      them as Divs with an appropriate class. We also handle titles+      for admonitions as a nested Div with the "title" class.+    + Fix nesting of chapters and sections (#5864, Florian Klink,+      Félix Baylac-Jacqué).+    + Fix bug with entities in mathphrase element (#5885).++  * MediaWiki reader:++    + Skip optional `{{table}}` template (#5757).++  * LaTeX reader:++    + Fix dollar-math parsing to ensure that space is left between a+      control sequence and a following letter (#5836).+    + In `untokenize`, ensure space between control sequence+      and following letter (#5836).+    + Don't omit macro definitions defined in the preamble.+      These were formerly omitted (though they still affected macro+      resolution if `latex_macros` was set).  Now they are included in+      the document body.+    + Parse macro definitions as raw LaTeX when `latex_macros` is+      disabled.  (When `latex_macros` is enabled, we omit them, since+      pandoc is applying the macros itself.)+    + Fix a hang/memory leak in certain circumstances (#5845).+    + Text.Pandoc.Readers.LaTeX.Parsing: add `[Tok]` parameter to+      `rawLaTeXParser`.  This allows us to repeat retokenizing+      unnecessarily in e.g. `rawLaTeXBlock`.+    + Add KOMA-Script metadata commands (#5910, Andrew Dunning).+      Add all titling commands to existing definition for `\dedication`.+    + Parse `\micro` siunitx unit command (#5921, Jose Luis Duran).++  * Markdown writer:++    + Ensure proper nesting when we have long ordered list markers (#5705).+    + Make `plain` output plainer (#5741).  Previously we used the following+      Project Gutenberg conventions for plain output: extra space before and+      after level 1 and 2 headings, all-caps for strong emphasis,+      underscores surrounding regular emphasis. Now these+      conventions are used only when the `gutenberg` extension is+      enabled. By default, Strong and Emph are rendered without+      special formatting, and headings are rendered without+      special formatting, and with only one blank line following.+      To restore the former behavior, use `-t plain+gutenberg`.+    + Prefer using raw_attribute when enabled (#4311).+      The `raw_attribute` will be used to mark raw bits, even HTML+      and LaTeX, and even when `raw_html` and `raw_tex` are+      enabled, as they are by default. To get the old behavior,+      disable `raw_attribute` in the writer.+    + Prefer `pipe_tables` to raw HTML even when we must+      lose width information (#2608, #4497).+    + Improve escaping in list items (#5918).++  * AsciiDoc writer:++    + Don't include `+` in code blocks for regular asciidoc.+      This is asciidoctor-specific.+    + Handle admonitions (#5690).++  * LaTeX writer:++    + Add thin space when needed in LaTeX quote ligatures (#5684).+    + Use `\hspace{0pt}` for 0-width space U+200B (#5756).+    + Use `cslreferences` environment for csl bibliographies.+      This allows bibliographies to receive special formatting.+      The template now contains definition of this environment (enabled+      only when CSL is used).  It also defines a `\cslhangindent` length.+      This is set to 2em by default when the bibliography style specifies+      a hanging indent.  To override the length, you can use e.g.+      `\setlength{\cslhangindent}{7em}` in header-includes.+      See jgm/pandoc-citeproc#410.+    + Strip off `{}` around locator for biblatex/natbib output (#5722).+    + Fix line breaks at start of paragraph (#3324).+      Previously we just omitted these. Now we render them+      using `\hfill\break` instead of `\\`.  This is a revision+      of a PR by @sabine (#5591) who should be credited with the idea.+    + We no longer look in the template or header-includes to see if a+      book or article documentclass is used, or to see whether the+      `csquotes` package is used. To use `csquotes` for LaTeX, set+      `csquotes` in your variables or metadata. To specify a book+      style, use the `documentclass` variable or+      `--top-level-division`.+    + Fix horizontal rule (#5801).  We change to use 0.5pt rather than+      `\linethickness`, which apparently only ever worked "by accident"+      and no longer works with recent updates to texlive.++  * ConTeXt writer:++    + Add option to include source files in ConTeXt PDFs (Tristan+      Stenner, #5578). The metadata field or variable+      (`includesource`) can be set to attach the source documents+      to the resulting PDF.+    + Customizable type of PDF/A for the ConTeXt writer (Karl+      Pettersson, #5608).  The `pdfa` variable may now be set in metadata.+      Also updated color profile settings in accordance with ConTeXt wiki,+      and made ICC profile and output intent for PDF/A customizable+      using `pdfaiccprofile` and `pdfaintent`.+    + Unit tests: adjust code property to avoid an irrelevant+      failure involving inline code with two consecutive newlines.+    + Set `csl-hanging-indent` variable if needed.+    + Use special environment for CSL references.+    + Use braces, not start/stop, for inline language tags.+      This prevents unwanted gobbling of spaces.++  * HTML writer:++    + Use numeric character references with `--ascii` (#5718).+      Previously we used named character references with html5 output.+      But these aren't valid XML, and we aim to produce html5 that is+      also valid XHTML (polyglot markup).  (This is also needed for epub3.)+    + Ensure that line numbers in code blocks get id-prefix (#5650).+    + Ensure TeX formulas are rendered correctly (Philip Pesca,+      #5658). The web service passed in to `--webtex` may render+      formulas using inline or display style by default.+      Prefixing formulas with the appropriate command ensures+      they are rendered correctly.+    + Render inline formulas correctly with `--webtex` (Philip+      Pesca, #5655). We add `\textstyle` to the beginning of the+      formula to ensure it will be rendered in inline style.+    + Pass through `aria-` attributes to HTML5 (#5642).+    + Render a Quoted element with an inner Span with+      `cite` attribute using a `<q>` tag (#5798, Ole Martin Ruud).+    + Render a Span with class `mark` using the `<mark>` element+      (Florian Beeres, #5797).+    + Render Span with class `dfn` using `<dfn>` element+      (Florian Beeres, #5882).+    + Render Span with class `kbd` using `<kbd>` element (Daniele+      D'Orazio, #5796).+    + Render Code with class `variable` using `<var>` element+      (Amogh Rathore, #5799).+    + Render Code with class `sample` using `<samp>` element+      (Amogh Rathore, #5799).++  * EPUB writer:++    + Improve splitting into chapters (#5761), using `makeSection`.+    + Avoid issuing warning multiple times when title not set (see #5760).+    + Use svg tag wrapper for cover image (#5638).  In addition, the+      code generating the image has been moved to the template, to make it+      more customizable. NOTE: Those who use custom EPUB+      templates will need to adjust their templates, adding the+      code to generate the cover image. (Previously this was just+      inserted into 'body'.)+    + Improve toChapters, making it work better if there are Divs+      around sections.+    + Add support for EPUB2 covers (blmage, #3992).+    + Do not override existing "fileN" medias when writing to EPUB format+      (blmage, #4206).+    + Ensure that `lang` variable is set on all chapters (so that it+      will add an `xml:lang` attribute on the `html` element).++  * RST writer:++    + Removed remnants of `admonition-title`.+    + Fix handling of `:align:` on figures and images (#4420).+      When the image has the `align-right` (etc.) class, we now use+      an `:align:` attribute.+    + Improve spacing for tables with no width information (#5899).+      If a simple table would be too wide, we use a grid table.+    + Fix backslash escaping after strings (Albert Krewinkel, #5906).+      The check whether a complex inline element following a string must+      be escaped, now depends on the last character of the string instead+      of the first.+    + Ensure there's a blank line before tables (#5898).++  * Dokuwiki writer:++    + Handle mixed lists without HTML fallback (#5107).++  * XWiki writer:++    + Fix multiline table (Zihang Chen, #5683).++  * Muse writer:++    + Add RTL support (Alexander Krotov, #5551).++  * Man writer:++    + Suppress non-absolute link URLs (#5770).  Absolute URLs are+      still printed in parentheses following the link text, but relative+      URLs are suppressed (just as internal links starting with '#'+      always have been).+    + Improved definition list term output.  Now we boldface code but+      not other things. This matches the most common style in man pages+      (particularly option lists).++  * Ms writer:++    + Use `.LP` instead of `.PP` for line block (#5588).+    + Use boldface for definition terms in DefinitionLists.++  * JATS writer:++    + Do not emit empty `<fn-group>` (Mauro Bieg, #5595).+    + Update template to v1.1dtd (#5632, Arfon Smith).+    + Update `data/jats.csl` to avoid commas between editor+      name-part elements. (#5629)+    + Add `abstract` to template (Mauro Bieg).++  * TEI writer:++    + Don't strip hash from internal links (#5922).++  * Jira writer:++    + Remove escapeStringForJira for code blocks (Jan-Otto Kröpke).+    + Remove extraneous newline after single-line block quotes+      (#5858, Albert Krewinkel).+    + Improve escaping of special characters, using backslash escapes+      instead of HTML entities (#5858, Albert Krewinkel).++  * OpenDocument writer:++    + Avoid duplicate attributes (#4634). We use the innermost+      attribute in nested cases.+    + If `native_numbering` extension is set, use native OpenDocument+      enumeration for figures and tables (Nils Carlson).+    + Place caption before table (#5681, Dmitry Pogodin).++  * ODT writer:++    + Add a test for MathML formulas in ODT documents (blmage).+    + Improve the parsing of frames in ODT documents (blmage).++  * Docx writer:++    + Make handling of styles more robust in localized versions+      of Word (Nikolay Yakimov, #5523, #5052, #5074).  We now use+      style names, not ids, for assigning semantic meaning, since+      the ids can change depending on the locale. Style name+      comparisons are case-insensitive, since those are+      case-insensitive in Word. Since docx style names can have+      spaces in them, and pandoc-markdown classes can't, anywhere+      when style name is used as a class name, spaces are+      replaced with ASCII dashes `-`. Code styles, i.e. "Source+      Code" and "Verbatim Char" now honor style inheritance. Docx+      Reader now honours "Compact" style (used in+      Pandoc-generated docx). The side-effect is that "Compact"+      style no longer shows up in docx+styles output. Styles+      inherited from "Compact" will still show up.+    + Re-use Readers.Docx.Parse for StyleMap (#5766, Nikolay Yakimov).+    + Internal improvements and code simplification (Nikolay Yakimov).+    + Preserve built-in styles in DOCX with custom style (Ben Steinberg,+      #5670).  This change prevents custom styles on divs and spans+      from overriding styles on certain elements inside them, like+      headings, blockquotes, and links. On those elements, the+      "native" style is required for the element to display correctly.+      This change also allows nesting of custom styles; in order to do so,+      it removes the default "Compact" style applied to Plain blocks,+      except when inside a table.+    + Add `proofState` to list of elements carried over from+      settings.xml in the reference.docx (Krystof Beuermann, #5703).+    + Change order of `ilvl` and `numId` in `document.xml` (Agustín+      Martín Barbero, #5645). Also, make list para properties go first.+      This reordering of properties shouldn't be necessary but+      it seems Word Online does not understand the docx correctly otherwise.++  * PowerPoint writer:++    + Code formatting is now context dependent (Jeroen de Haas, #5573).+      This commit alters the way in which the Powerpoint writer treats+      inline code and code blocks. Inline code is now formatted at+      the same size as the surrounding text. Code blocks are now given+      a margin and font size according to their level.+      Furthermore this commit allows changing the font with which code is+      formatted via the `monofont` option.+    + Start numbering at appopriate numbers (Jesse Rosenthal, #5709).+      Starting numbers for ordered lists were previously ignored. Now+      we specify the number if it is something other than 1.++  * Text.Pandoc.Parsing:++    + Add `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`,+      `many1Till`, `manyUntil`, `mantyUntilChar`: these are like their+      unsuffixed counterparts but pack some or all of their output+      (Christian Despres, #5884).+    + Add `stateAllowLineBreaks` to `ParserState` [API change].+    + Fix inline parsing in grid table cells (#5708).+    + Change type of `setLastStrPos` so it takes a `Maybe SourcePos`+      rather than a `SourcePos` [API change].+    + Make `parseFromString'` and `gridTableWith` and+      `gridTableWith'` polymorphic in the parser state,+      constraining it with `HasLastStrPosition` [API change].+    + `parseFromString'`: reset `stateLastStrPos` to `Nothing` before parse.+    + Rename takeWhileP -> take1WhileP and clean it up.+      (It doesn't match the empty sequence.)++  * Text.Pandoc.PDF:++    + For PDFs via HTML, ensure temp file is deleted even if the pdf+      program is not found (#5720).+    + Better detection of a Cygwin environment (#5451).+    + Don't assume tex log file is UTF8-encoded (#5872).+      Fall back to latin1 if it can't be read as UTF-8.++  * Text.Pandoc.Extensions:++    + Export new function `getAllExtensions`, which returns the+      extensions that affect a given format (whether enabled by default+      or not) [API change].+    + Change type of `parseFormatSpec` from+      `Either ParseError (String, Extensions -> Extensions)`+      to `Either ParseError (String, [Extension], [Extension])`+      [API change].+    + Add `Ext_gutenberg` constructor to `Extension` [API change].+    + Add `Ext_native_numbering` constructor to `Extension` [API change]+      (Nils Carlson).++  * Text.Pandoc.Readers, Text.Pandoc.Writers:++    + Change type of `getReader` and `getWriter` so they return+      a value in the PandocMonad instance rather than an Either+      [API change].  Exceptions for unknown formats and unsupported+      extensions are now raised by these functions.++  * Text.Pandoc.App++    + Change `optMetadataFile` type from `Maybe FilePath` to `[FilePath]`+      (Owen McGrath, #5702) [API change].++  * Text.Pandoc.Logging:++    + Add `CouldNotDeduceFormat` constructor to `LogMessage` [API change].+      Issue this warning when we're falling back to markdown or+      html because we don't recognize the extension of the input or+      output files.+    + Clarify warning for missing title (#5760).+    + Add `UnusualConversion` constructor to `LogMessage` [API change]+      (Mauro Bieg, #5736).  Emit warning on `-f latex -o out.pdf`.++  * Lua filters:++    + Improve function documentation (Albert Krewkinkel).+    + Traverse nested blocks and inlines in correct order (Albert+      Krewinkel, #5667). Traversal methods are updated to use the new+      Walk module so that sequences with nested Inline (or Block) elements+      are traversed in the order in which they appear in the linearized+      document.+    + New unexported module `Text.Pandoc.Lua.Walk` (Albert Krewinkel).+      Lua filters must be able to traverse sequences of AST+      elements and to replace elements by splicing sequences back+      in their place. Special `Walkable` instances can be used for+      this; those are provided in a new module+      `Text.Pandoc.Lua.Walk`.+    + `Attr` values can now be given as normal Lua tables (Albert+      Krewinkel, #5744).  This can be used as a convenient alternative+      to constructing `Attr` values with `pandoc.Attr`. Identifiers+      are taken from the `id` field, classes must be given as+      space separated words in the `class` field. All remaining fields+      are included as attributes. With this change, the following lines+      now create equal elements:+      ```+      pandoc.Span('test', {id = 'test', class = 'a b', check = 1})+      pandoc.Span('test', pandoc.Attr('test', {'a','b'}, {check = 1}))+      ```+      This also works when using the *attr* setter:+      ```+      local span = pandoc.Span 'text'+      span.attr = {id = 'test', class = 'a b', check = 1}+      ```+      Furthermore, the *attributes* field of AST elements can now be a+      plain key-value table even when using the `attributes` accessor:+      ```+      local span = pandoc.Span 'test'+      span.attributes = {check = 1}   -- works as expected now+      ```+    + Export `make_sections`, remove `hierarchicalize`. Lua filters that+      use `hierarchicalize` will need to be rewritten to use+      `make_sections`.+    + Add a `clone()` method to all AST elements (Albert Krewinkel, #5568).+    + Fix Lua function names in pandoc.system (niszet). Change+      `get_current_directory` to `get_working_directory` and+      `with_temp_directory` to `with_temporary_directory`, to+      conform to the manual.++  * Text.Pandoc.Error:++    + Add constructors `PandocUnknownReaderError`,+      `PandocUnknownWriterError`, `PandocUnsupportedExtensionError`.+      [API change].+    + Better message for `PandocShouldNeverHappenError`.+    + Better message for `PandocTemplateError`.++  * Text.Pandoc.Emoji:++    + Update emoji list (#5666). Done using new `tools/emojis.hs`,+     which uses the list from the gem GitHub uses. Future updates+     can be done with this tool.++  * Text.Pandoc.PDF:++    + Pass value of `--dpi` to `rsvg-convert` when converting SVG to PDF+      in the process of creating a PDF (#5721).++  * Markdown reader:++    + Headers: don't parse content over newline boundary (#5714).+    + Handle inline code more eagerly within lists (Brian Leung, #5627).+    + Removed some needless lookaheads.+    + Don't parse footnote body unless extension enabled.+    + Fix small super/subscript issue (#5878).  Superscripts and subscripts+      cannot contain spaces, but newlines were previously allowed+      (unintentionally).  This led to bad interactions in some cases+      with footnotes.  With this change newlines are also not allowed inside+      super/subscripts.+    + Use `take1WhileP` for `str`, table row.  This yields a small but+      measurable performance improvement.+++  * LaTeX reader:++    + Fix parsing of optional arguments that contain braced text (#5740).+    + Don't try to parse includes if `raw_tex` is set (#5673).+      When the `raw_tex` extension is set, we just carry through+      `\usepackage`, `\input`, etc. verbatim as raw LaTeX.+    + Properly handle optional arguments for macros (#5682).+    + Fix `\\` in `\parbox` inside a table cell (#5711).+    + Improve `withRaw` so it can handle cases where the token string is+      modified by a parser (e.g. accent when it only takes part of a Word+      token) (#5686).  This fixes a bug that caused the ends of+      certain documents to be dropped.+    + Handle `\passthrough` macro used by latex writer (#5659).+    + Support tex `\tt` command (#5654).+    + Search for image with list of extensions like latex does, if an+      extension is not provided (#4933).+    + Handle `\looseness` command values better (#4439).+    + Add `mbox` and `hbox` handling (Vasily Alferov, #5586).+      When `+raw_tex` is enabled, these are passed through literally.+      Otherwise, they are handled in a way that emulates LaTeX's behavior.+    + Properly handle `\providecommand` and `\provideenvironment` (#5635).+      They are now ignored if the corresponding command or environment+      is already defined.+    + Support epigraph command in LaTeX Reader (oquechy, #3523).+    + Ensure that expanded macros in raw LaTeX  end with a space+      if the original did (#4442).+    + Treat `ly` environment from lilypond as verbatim (Urs Liska, #5671).+    + Add `tikzcd` to list of special environments (Eigil Rischel).+      This allows it to be processed by filters, in the same way that+      one can do for `tikzpicture`.++  * Roff reader:++    + Better support for `while`.+    + More improvements in parsing conditionals.+    + Fix problem parsing comments before macro.+    + Improve handling of groups.+    + Better parsing of groups (#5410).  We now allow groups+      where the closing `\\}` isn't at the beginning of a line.++  * Text.Pandoc.Shared:++    + Replace `Element` and `makeHierarchical` with `makeSections`.+      Now that we have Divs, we can use them to represent the+      structure of sections, and we don't need a special Element type.+      `makeSections` reorganizes a block list, adding Divs with class+      `section` around sections, and adding numbering if needed.+      This change also fixes some longstanding issues recognizing section+      structure when the document contains Divs (#3057, see also #997).+    + Remove `Element` type [API change]+    + Remove `makeHierarchicalize` [API change]+    + Add `makeSections` [API change]+    + Export `deLink` [API change]+    + Make `filterIpynbOutput` strip ANSI escapes from code in output+      for non-ipynb formats, when the default "best" option is used with+      `--ipynb-output` (#5633).+    + Fix `camelCaseToHyphenated` so it handles `ABCDef` better.+    + Improve `isTight` (#5857).  If a list has an empty item,+      this should not count against its being a tight list.+    + Export `htmlSpanLikeElements` [API change] (Daniele D'Orazio, #5796).+      This is a mapping of HTML span-like elements that are internally+      represented as a Span with a single class.+    + Change the implementation of `htmlSpanLikeElements` to retain+      classes and attributes (#5882, Florian Beeres).++  * Text.Pandoc.Slides: recognize content in Divs when determining+    slide level.++  * Text.Pandoc.SelfContained:++    + Omit content-type on type attribute for `<style>` (#5725).+      It doesn't seem to be valid for HTML5, and as a result Chrome+      ignores the style element.++  * Text.Pandoc.Pretty has been removed [API change].+    We now use the new external doclayout module instead.++  * Text.Pandoc.Writers.Shared:++    + Remove `metaToJSON`, `metaToJSON'` [API change].+    + Modify `addVariablesToContext`, `defField`, `setField`, `getField`,+     `resetField` to work with Context rather than JSON values. [API change]+    + Export new function `endsWithPlain` [API change].+    + Change `gridTables` so it does better at keeping the widths of+      columns (#4320) and does better at figuring out column widths+      when no widths are given (#5899).++  * Text.Pandoc.Options++    + Change type of `writerTemplate` to `Maybe Template` instead+      of `Maybe String`.+    + Change To/FromJSON instances for `HTMLMathMethod`, `CiteMethod`,+      `ObfuscationMethod`, `TrackChanges`, `WrapOption`,+      `TopLevelDivision`, `ReferenceLocation`, `HTMLSlideVariant` (#5790).+      In each case we use lowercase (or hyphenated lowercase) for+      constructors to line up more closely with command-line option+      values.  This is a breaking change for those who manually decode or+      encode JSON for these data types (e.g. for `ReaderOptions` or+      `WriterOptions`).++  * Text.Pandoc.Filters:++    + Add `FromYAML` instance for `Filter`.+    + `applyFilters`: Add and apply filters in order (not reversed)+      This changes `applyFilters` from Text.Pandoc.Filter so+      that it does a left fold rather than a right fold, applying+      the filters in the order listed.++  * Text.Pandoc.XML:++    + Change `toEntities` to emit numerical hex character references+      (#5718).++  * Text.Pandoc.Highlighting:++    + Add additional listings languages (Wandmalfarbe).++  * Text.Pandoc.MediaBag:++    + Some of the types using Strings were switched to use FilePath instead+      (Christian Despres, #5884).++  * Text.Pandoc.Templates:++    + Don't import/export `varListToJSON` [API change].  It is removed in+      doctemplates >= 0.3.+    + Change type of `renderTemplate'` [API change].  Return value is+      now Text rather than being polymorphic.  This makes room for+      upcoming removal of the `TemplateTarget` class from doctemplates.++  * Text.Pandoc.App.Opt [API changes]:++    + More convenient To/FromJSON instances.  Make the field names+      like `strip-empty-paragraphs` rather than `optStripEmptyParagraphs`.+      Anyone who is using JSON serialization of Opt will need to adjust+      things accordingly.+    + Change `optHighlightStyle` to a `Maybe String` instead of+      `Maybe Style`.  Do the parsing/loading of themes later, after+      option parsing.+    + Remove `optBaseHeaderLevel` from `Opt`.  We now just use+      `optShiftHeadingLevelBy`, to avoid redundancy.+    + Change `optShiftHeadingLevel` to `optShiftHeadingLevelBy` to+      match the option.+    + Custom FromJSON instance for `LineEnding`, so either `CRLF`+      or `crlf` will work.+    + Change `optVariables` from `[(String, String)]` to `Context Text`.+    + Change `optMetadata` to `Meta`, to allow structured values.+      The current behavior of the `--metadata` option stays the same.+    + Rename `optReader`, `optWriter` as `optFrom`, `optTo`.+    + Add `FromYAML` instances to `Opt` and to all subsidiary types.+    + Rename `optMetadataFile` to `optMetadataFiles`.+    + Rename `optPDFEngineArgs` to `optPDFEngineOpts`.+    + Rename `optWrapText` to `optWrap`.+    + Add `IpynbOutput` enumerated type: use this instead of+      a string for `optIpynbOutput`.+    + Change optInputFiles to a `Maybe [FilePath]` (#5888) [API change].+      `Nothing` means: nothing specified.+      `Just []` means: an empty list specified (e.g. in defaults).+    + List fields in Opt so they aren't reversed (#5881) [API change].+      Previously `optIncludeInHeader`, etc. were in reverse order.+    + The `sourcefile` variable is now always a list. It used to be+      sometimes a string, sometimes a list (when there was more than one).++  * Template changes:++    + default.latex: added code for `cslreferences` environment,+      to be used for pandoc-citeproc references. A `csl-hanging-indent`+      variable (set automatically if there is a `hanging-ident`+      class on the references Div) controls whether contents of this+      environment receive a hanging indent.+    + default.latex: Add `space` as default option for xeCJK, so that+      spaces between words are preserved (#5855, jeongminkim-islab).+      This is necessary for Korean.+    + default.latex: Remove include of `grffile` (#5848).+      This package used to be needed for proper handling of image filenames+      containing periods (in addition to the period before the extension).+      It no longer works with the latest LaTeX kernel and graphicx,+      so we have removed it. Future versions of graphicx will handle+      these filenames without the need for `grffile`.+    + default.context: add a saner default for page numbers.+      Previously they appeared centered at the top of the page;+      now we put them centered at the bottom, unless the `pagenumbering`+      variable is set.+    + default.context: define a start-stop-pair `cslreferences` to+      allow for hanging indents in the bibliography (#5875, Denis Maier).+    + default.ms: update defaults.  Use Palatino font, use slightly+      wider interparagraph space, don't indent paragraphs,+      and put page numbers on the bottom.  This brings ms output+      closer to default LaTeX output.+    + default.revealjs: add navigationMode (Mauro Bieg, #5657).+    + default.muse: handle multiple authors better.+    + docbook4, docbook5 templates: add indentation to body.+    + HTML-based templates: use `styles.html` partial to avoid+      code duplication.+    + HTML-based templates: change indentation of styles in template.++  * reference.docx (#5820):++    + Change Block Text (block quote) style so that the same font+      is used as in the body text, and the block text is indented+      left and right.+    + All headings now have a uniform color.+    + Level-1 headings no longer set `w:themeShade="B5"`.+    + Level-2 headings are now 14 point rather than 16 point.+    + Level-3 headings are now 12 point rather than 14 point.+    + Level-4 headings are italic rather than bold.++  * epub.css: Add CSS for hanging-indent div to support pandoc-citeproc's+   new hanging indents.++  * pandoc.cabal:++    + Repeat ghc-options in all stanzas.+    + Remove conditionals for ghc < 8 (Albert Krewinkel, #5693).+    + Compile with `-Wcpp-undef` and `-fhide-source-paths` when possible+      (Albert Krewinkel).+    + Add cabal.project to extra-source-files (Albert Krewinkel).+    + Add dependency on skylighting-core (#5729). Even though it shouldn't+      be needed, some tools require it.+    + Require latest pandoc-types, texmath, skylighting, haddock-library.+    + Ensure TemplateHaskell is added to other-extensions when it is+      used (Vanessa McHale, #5728).+    + Remove `derive_json_via_th` flag; always use TH.  This cuts down+      on code duplication and reduces the chance for errors.  See #4083.++  * Makefile:++    + Add ghci target.+    + Add ghcid target.+    + Remove references to obsolete flag (#5694).++  * Benchmarks: fix failure on ipynb.++  * Use MathJax 3 (zorkow).++  * KaTeX math: respect `classoption=fleqn` variable,+    bump KaTeX version to 0.11.1 (#5815, Mauro Bieg).++  * Fix redundant constraint compiler warnings (Pete Ryland, #5625).++  * Use throwError instead of fail when appropriate.++  * Use Prelude.fail to avoid ambiguity with fail from GHC.Base.++  * Add `diff-zip.sh` to tools (John MacFarlane, Agustín Martín Barbero).+    This is intended to make it easier to test differences in zip+    containers, like epub, docx, or odt.++  * Add `.gitattributes` (#5747).  This ensures that the golden files+    in `test/fb2/reader/` don't have newlines converted. This should fix+    a test failure on GitHub CI with Windows.++  * Reorder options in `--help`.++  * Revise code for HsYAML-0.2.0.0 (@vijayphoenix, #5704).++  * Remove blank line in code example in Haddocks (Leif Metcalf, #5679).++  * Fix trypandoc with `getReader`/`getWriter` changes.++  * Allow building pandoc with GHC 8.8.++  * linux tarball: add architecture `-amd64` to filename.+    Now it will be: `pandoc-VERSION-linux-ARCH.tar.gz`.++  * MANUAL.txt:++    + Add section for exit codes.+    + Document some pptx limitations in slide show section:+      No incremental display (#5689).  No pause with `. . .` (#5701).+    + reveal.js flags (Mauro Bieg, #5653).+    + Document addition of `data-` prefix to unknown attributes in HTML5.+    + Link to YAML spec (Mauro Bieg, #5687).+    + Fix capitalization of "Linux" (#5859, Marcus Stollsteimer).+    + Use a table for exit codes.+    + Put all template variable docs into one section.+    + Use ATX headers consistently.+    + Add fuller documentation of templates (#5779), including+      new template syntax, partials, etc.+    + Add documentation for the variable `hyperrefoptions` (Wandmalfarbe).+    + Clarify when macro definitions are passed as raw latex.+      In Markdown input, they are always passed through.  In LaTeX, only if+      `latex_macros` is disabled.+    + Clarify that `--dpi` provides a default and doesn't override+      dpi values specified in the images themselves (#5721).+    + Document how to use custom writers with `--standalone` (#5866).+    + Clarify `--preserve-tabs` default.++  * INSTALL.md:++    + Fix instructions for libicu.+    + Add Void Linux instructions (Volodymyr Kozachnyskyi).++  * CONTRIBUTING.md:++    + Add information on tests (Agustín Martín Barbero, #5652).+    + Add information about command test naming to CONTRIBUTING (Florian B).++  * Fix typos in changelog and comments (#5896, Brian Wignall).++  * doc/lua-filters.md:++    + Fix mistakes in mediabag module docs (#5851, Albert Krewinkel).+    + Improve metadata replacement example in lua-filters doc (#5851).+    + Mention which Lua version is shipped with pandoc (Albert Krewinkel,+      #5892).++## pandoc 2.7.3 (2019-06-11)++  * Add `jira` (Atlassian's Jira wiki markup) as output format (#2497,+    Albert Krewinkel).++  * Add `tex_math_dollars` to `multimarkdownExtensions` (#5512).+    This form is now supported in multimarkdown,+    in addition to `tex_math_double_backslash`.++  * Fix `--self-contained` so it works when output format has extensions.+    Previously if you used `--self-contained` with `html-smart` or+    `html+smart`, it wouldn't work.++  * Add template variable `curdir` with working directory+    from which pandoc is run (#5464).++  * Markdown reader: don't create implicit reference for empty header+    (#5549).++  * Muse reader: allow images inside link descriptions (Alexander Krotov).++  * HTML reader: epub related fixes.++    + With epub extensions, check for `epub:type` in addition to `type`.+    + Fix problem with noteref parsing which caused block-level+      content to be eaten with the noteref.+    + Rename `pAnyTag` to `pAny`.+    + Refactor note resolution.+    + Trim definition list terms (Alexander Krotov).++  * LaTeX reader:++    + Add braces when resolving `\DeclareMathOperator`+      (#5441).  These seem to be needed for xelatex but not pdflatex.+    + Allow newlines in `\mintinline`.+    + Pass through unknown listings language as class (#5540).+      Previously if the language was not in the list of languages supported+      by listings, it would not be added as a class, so highlighting+      would not be triggered.+    + `rawLaTeXInline`: Include trailing `{}`s in raw latex commands (#5439).+      This change affects the markdown reader and other readers that allow raw+      LaTeX.  Previously, trailing `{}` would be included for unknown+      commands, but not for known commands.  However, they are sometimes used+      to avoid a trailing space after the command.  The chances that a `{}`+      after a LaTeX command is not part of the command are very small.++  * MediaWiki reader: handle multiple attributes in table row (#5471,+    chinapedia).++  * Docx reader: Add support for `w:rtl` (#5545).  Elements with this+    property are put into Span inlines with `dir="rtl"`.++  * DocBook reader: Issue `IgnoredElement` warnings.++  * Org reader (Albert Krewinkel):++    + Fix planning elements in headers level 3 and higher+      (#5494).  Planning info is now always placed before+      the subtree contents.  Previously, the planning info was placed after+      the content if the header's subtree was converted to a list, which+      happens with headers of level 3 and higher per default.+    + Omit, but warn about unknown export options.  Unknown export+      options are properly ignored and omitted from the output.+    + Prefer plain symbols over math symbols (#5483).+      Symbols like `\alpha` are output plain and unemphasized, not as math.+    + Recognize emphasis after TODO/DONE keyword (#5484).++  * FB2 reader:++    + Skip unknown elements rather than throwing errors (#5560).+      Sometimes custom elements are used (e.g. `id` element+      inside `author`); previously the reader would halt with an error.+      Now it skips the element and issues an `IgnoredElement` warning.+    + Parse notes (#5493, Alexander Krotov).+    + Internal improvements (Alexander Krotov).++  * OpenDocument writer:  Roll back automatic figure/table numbering+    (#5474).  This was added in pandoc 2.7.2, but it makes it impossible+    to use pandoc-crossref. So this has been rolled back for now,+    until we find a good solution to make this behavior optional+    (or a creative way to let pandoc-crossref and this feature+    to coexist).++  * New module Text.Pandoc.Writers.Jira, exporting `writeJira` [API+    change] (Albert Krewinkel).++  * EPUB writer:++    + Don't include 'landmarks' if there aren't any.+      Previously we could get an empty ol element, which caused+      validation errors with epubcheck.+    + Ensure unique ids for styleesheets in content.opf (#5463).+    + Make stylesheet link compatible with kindlegen (#5466,+      Eric Schrijver).  Pandoc omitted `type="text/css"` from both+      `<style>` and `<rel="stylesheet">` elements in all templates, which+      is valid according to the spec. However, Amazon’s kindlegen software+      relies on this attribute on `<link>` elements when detecting+      stylesheets to include.++  * HTML writer:++    + Output video and audio elements depending on file+      extension of the image path (Mauro Bieg).+    + Emit empty alt tag in figures (#5518, Mauro Bieg).+      The same text is already in the <figcaption> and+      screen-readers would read it twice, see #4737.+    + Don't add variation selector if it's already there.+      This fixes round-trip failures.+    + Prevent gratuitous emojification on iOS (#5469).+      iOS chooses to render a number of Unicode entities, including '↩', as+      big colorful emoji.  This can be defeated by appending Unicode+      VARIATION SELECTOR-15'/'VARIATION SELECTOR-16'.  So we now append this+      character when escaping strings, for both '↩' and '↔'.  If other+      characters prove problematic, they can simply be added to+      `needsVariationSelector`.  + Add `class="heading"` to level 7+ Headers+      rendered as `<p>` elements (#5457).++  * RST writer: treat Span with no attributes as transparent (#5446).+    Previously an Emph inside a Span was being treated as+    nested markup and ignored.  With this patch, the Span+    is just ignored.++  * LaTeX writer:++    + Include inline code attributes with `--listings` (#5420).+    + Don't produce columns environment unless beamer (#5485).+    + Fix footnote in image caption.  Regression: the fix for #4683 broke+      this case.+    + Don't highlight code in headings (#5574).  This causes+      compilation errors.+    + Use `\mbox` to get proper behavior inside `\sout` (#5529).++  * EPUB writer: Fix document section assignments (#5546).+    For example, introduction should go in bodymatter, not frontmatter, and+    epigraph, conclusion, and afterward should go in bodymatter, not+    backmatter.  For the full list of assignments, see the manual.++  * Markdown writer:++    + Add backslashes to avoid unwanted interpretation of+      definition list terms as other kinds of block (#554).+    + Ensure the code fence is long enough (#5519).+      Previously too few backticks were used when the code block+      contained an indented line of backticks.  (Ditto tildes.)+    + Handle labels with integer names (Jesse Rosenthal, #5495).+      Previously if labels had integer names, it could produce a conflict+      with auto-labeled reference links. Now we test for a conflict and+      find the next available integer.  This involves adding a new state+      variable `stPrevRefs` to keep track of refs used in other document+      parts when using `--reference-location=block|section`++  * Textile writer: fix closing tag for math output (Albert Krewinkel).+    Opening and closing tag for math output match now.++  * Org writer: always indent src blocks content by 2 spaces (#5440, Albert+    Krewinkel).  Emacs always uses two spaces when indenting the content of+    src blocks, e.g., when exiting a `C-c '` edit-buffer. Pandoc used to+    indent contents by the space-equivalent of one tab, but now always uses+    two spaces, too.++  * Asciidoc writer:++    + Use `` `+...+` `` form for inline code.+      The old `` `a__b__c` `` yields emphasis inside code in asciidoc.+      To get a pure literal code span, use `` `+a__b__c+` ``.+    + Use proper smart quotes with asciidoctor (#5487).+      Asciidoctor has a different format for smart quotes.+    + Use doubled ## when necessary for spans (#5566).+    + Ensure correct nesting of strong/emph (#5565): strong+      must be the outer element.++  * JATS writer:++    + Wrap elements with p when needed (#5570).  The JATS spec restricts+      what elements can go inside `fn` and `list-item`.  So we wrap other+      elements inside `<p specific-use="wrapper">` when needed.+    + Properly handle footnotes (#5511) according to "best practice."+      (Group them at the end in `<fn-group>` and use `<xref>` elements+      to link them.)+    + Fix citations with PMID so they validate (#5481).  This includes+      an update to data/jats.csl.+    + Ensure validity of `<pub-date>` by parsing the date and+      extracting year, month, and day, as expected.  Also add an+      iso-8601-date attribute automatically.+    + Don't use `<break>` element for LineBreak. It is only+      allowed in a few special contexts, and not in `<p>` elements.+    + Don't make `<string-name>` a child of `<string>`, which is illegal.++  * FB2 writer:++    + Do not wrap note references into `<sup>` and brackets+      (Alexander Krotov).  Existing FB2 readers, such as FBReader, already+      display links with type="note" as a superscript.+    + Use genre metadata field (#5478).++  * Muse writer: do not escape empty line after `<br>` (Alexander Krotov).++  * Add unicode code point in "Missing character" warning (#5538).+    If the character isn't in the console font, the message is pretty useless,+    so we show the code point for anything non-ASCII.++  * Lua: add Version type to simplify comparisons (Albert Krewinkel).+    Version specifiers like `PANDOC_VERSION` and `PANDOC_API_VERSION` are+    turned into `Version` objects. The objects simplify version-appropriate+    comparisons while maintaining backward-compatibility.+    A function `pandoc.types.Version` is added as part of the newly+    introduced module `pandoc.types`, allowing users to create version+    objects in scripts.++  * pandoc lua module (Albert Krewinkel):++    - Fix deletion of nonexistent attributes (#5569).+    - Better tests for Attr and AttributeList.++  * pandoc.mediabag lua module (Albert Krewinkel):++    + Add function `delete` for deleting a single item.+    + Add function `empty` for removing all entries.+    + Add function `items` for iterating over mediabag.++  * Text.Pandoc.Class: Fix handling of `file:` URL scheme in+    `downloadOrRead` (#5517, Mauro Bieg).  Previously `file:/`+    URLs were handled wrongly and pandoc attempted to make HTTP+    requests, which failed.++  * Text.Pandoc.MIME: add `mediaCategory` [API change] (Mauro Bieg).++  * Text.Pandoc.Shared:++    + Add `onlySimpleTableCells` [API change]+      (Mauro Bieg) and use this to consolidate simple-table detection+      (#5524).  This fixes an inconsistency in the HTML reader, which did not+      treat tables with `<p>` inside cells as simple.+    + `metaToJSON`: treat digits starting with 0 as a string, not a number+      (#5479).  This fixes a regression in YAML metadata in pandoc 2.7.2.++  * Text.Pandoc.Logging: Add `IgnoredElement` constructor for+    `LogMessage`.  `SkippedConetnt` doesn't work for some XML-based+    readers which don't have access to parsec source positions.++  * Text.Pandoc.Asciify: Add Turkish undotted-i (#5433, Mauro Bieg).++  * Improve output of Lua tests (#5499, Albert Krewinkel).+    This makes use of tasty-lua, a package to write tests in Lua+    and integrate the results into Tasty output. Test output becomes+    more informative: individual tests and test groups become visible+    in test output. Failures are reported with helpful error messages.++  * Lua: add `pandoc.system` module (#5468, Albert Krewinkel).+    The `system` Lua module provides utility functions to interact with the+    operating- and file system. E.g.+    `print(pandoc.system.get_current_directory())`+    or+    ```lua+        pandoc.system.with_temporary_directory('tikz', function (dir)+          -- write and compile a TikZ file with pdflatex+        end)+    ```++  * LaTeX template: Add pdflang to hypersetup if lang is set (#5443).++  * beamer template: Fix using Beamer with geometry (#5505, Daniel Maslowski).+    Beamer already loads geometry, so we need to use the `\geometry`+    command to set geometry options.++  * EPUB2/3 templates: Move inline styles to default epub.css (#5466).+    NOTE: Those who use a custom CSS stylesheet with EPUB should+    add these lines:++        code{ white-space: pre-wrap; }+        span.smallcaps{ font-variant: small-caps; }+        span.underline{ text-decoration: underline; }+        q { quotes: "“" "”" "‘" "’"; }+        div.column{ display: inline-block; vertical-align: top; width: 50%; }++  * reveal.js template:++    + Updates for revealjs 3.8.0 (#5435, ebiim).+    + Remove reference to head.min.js (#5448, Winnie Hellmann).+      NOTE: users will need to update reveal.js to at least 3.8.0+      for their presentations generated with this version of pandoc+      to work correctly.++  * Text.Pandoc.PDF:++    + Replace `</>` with literal `/` (#5451).+      We use forward-slash for a directory separator in tmpDir,+      even on Windows (because that's what tex likes).  So we+      should not put a backslash between the tmpDir and the+      filename on Windows.  This is harmless enough in normal+      Windows setups, but it breaks on Cygwin.+      Thanks to @cc2x for noticing and diagnosing the problem.+    + Allow use of `-output-directory` in `--pdf-engine-opt` (#5462).+      This is currently possible with `mklatex` and `-outdir`, but+      was not yet possible with xelatex and `-output-directory`.+    + For PDF via ms/pdfroff, make TOC appear at beginning and in+      PDF bookmarks (#5553).  Previously the TOC appeared at the end+      of the document, and was not bookmarked.  To keep it at the end,+      add `--pdf-engine-opt=--no-toc-relocation` to your command line.++  * Fix broken links in documents (#5473, Shim Myeongseob).+    Also, use absolute links to pandoc.org when possible, so that+    the links can be followed by people viewing these documents+    on GitHub.++  * Improved sample lua tikz filter in lua-filters docs (#5445,+    Matthew Doty).  There are three changes:++    + It only processes elements which begin with `\begin{tikzpicture}`+    + It uses pdf2svg instead of imagemagick to preserve fidelity+    + The images produced have transparent backgrounds++  * MANUAL.txt:++    + Add note about `title-meta`, `author-meta`, `date-meta` (#5486).+    + Fix typo (#5489, Christian Krause).++  * add test/tables.xwiki to git and pandoc.cabal (#5498, Mauro Bieg).++  * Disable missing-home-modules warning in `stack.yaml`.+    Otherwise `stack ghci` fails.+++## pandoc 2.7.2 (2019-04-05)++  * Add XWiki writer (#1800, Derek Chen-Becker).+    Add `Text.Pandoc.Writers.XWiki`, exporting `writeXWiki` [API change].++  * Dokuwiki Reader: parse single curly brace (#5416, Mauro Bieg).++  * Vimwiki reader: improve handling of internal links (#5414).+    We no longer append `.html` to link targets, and we add a title+    `wikilink`.  This mirrors behavior of other wiki readers.  Generally+    the `.html` extension is not wanted.  It may be important for output+    to HTML in certain circumstances, but it can always be added using a+    filter that matches on links with title `wikilink`.++    If your workflow requires the current behavior, here is a lua filter+    that will add the `.html` extension:++    ```lua+    function Link(el)+      if el.title == 'wikilink' then+        el.target = el.target .. ".html"+      end+      return el+    end+    ```+  * ipynb reader:++    + Use format `ipynb` for raw cell where no format given.+    + Avoid introducing spurious `.0` on integers in metadata.++  * Markdown reader: fenced div takes priority over setext header.++  * HTML reader: read `data-foo` attribute into `foo` (#5392).+    The HTML writer adds the `data-` prefix for HTML5 for nonstandard+    attributes.  But the attributes are represented in the AST without+    the `data-` prefix, so we should strip this when reading HTML.++  * LaTeX reader: Improve autolink detection (#5340).++  * PowerPoint writer (Jesse Rosenthal):++    + Expand builtin reference doc to model all layouts.+      The previous built-in reference doc had only title and content+      layouts. Add in a section-header slide and a two-content slide, so+      users can more easily modify it to build their own templates.+    + Always open up in slide view.  When editing a+      template/reference-doc, the user might be in Master view, but when+      producing a slide show, it is assumed that slide view will be+      desired.+    + Remove `handoutsMasterList` from template presentation.xml+    + Fix numerous errors in templating (#5402). Previously, some templates+      produced by Office 365 (MacOS) would not render with `--reference-doc`+      correctly. We now apply correct shapes for content, and build+      shape trees correctly.+    + Make default placeholder type for template lookup.+    + Apply speaker notes to metadata slide if applicable.+    + Test for speaker notes after breaking header.+    + Correctly handle notes after section-title header.+      Previously, if notes came after a section-title header (ie, a level-1+      header in a slide-level=2 presentation), they would go on the next+      slide. This keeps them on the slide with the header.+    + Internal improvements.++  * ipynb writer:++    + Use format `ipynb` for raw cell where no format given.+      According to nbformat docs, this is supposed to render in every+      format.  We don't do that, but we at least preserve it as a raw+      block in markdown, so you can round-trip.+    + Consolidate adjacent raw blocks.  Sometimes pandoc creates two+      HTML blocks, e.g. one for the open tag and one for a close tag.+      If these aren't consolidated, only one will show up in output cell.+    + Fixed carry-over of nbformat from metadata.+    + Preserve `nbformat_minor` if it's given.  This helps with round-tripping.++  * LaTeX writer:++    + Avoid inadvertently creating ?` or !` ligatures (#5407).+      These are upside down ? and !, resp.+    + Fix footnotes in table caption and cells (#5367).  This fixes a+      bug wherein footnotes appeared in the wrong order, and with+      duplicate numbers, when in table captions and cells.+      We now use regular `\footnote` commands, even in the table+      caption and the minipages containing cells. Apparently+      longtable knows how to handle this.++  * HTML writer: Don't add data- prefix to RDFa attributes (#5403).++  * JATS writer: Ensure that plain strings go inside `<pub-id>` tag (#5397).++  * Markdown writer:++    + Better rendering of numbers (#5398).  If the number is integral,+      we render it as an integral not a float.+    + Proper rendering of empty map in YAML metadata (#5398).  Should+      be `{}`, not empty string.+    + Properly escape attributes in Markdown writer (#5369).+    + Be sure implicit figures work in list contexts (#5368).+      Previously they would sometimes not work: e.g., when they+      occurred in final paragraphs in lists that were originally+      parsed as Plain and converted later using PlainToPara.++  * Docx writer: Use `w:br` without attributes for line breaks (#5377).+    We previously added the attribute `type="textWrapping"`, but+    this causes problems on Word Online.++  * LaTeX template (Andrew Dunning):++    + Ensure correct heading/table order (#5365).  Improve workaround+      (#1658) for tables following headings.  The new solution works whether+      or not the `indent` variable is enabled.+    + Remove `subparagraph` variable. The default is now to use run-in+      style for level 4 and 5 headings (`\paragraph` and `\subparagraph`).+      To get the previous default behavior (where these were formatted as+      blocks, like `\subsubsection`), set the `block-headings` variable.+    + Add pandoc to PDF metadata (#5388).+    + Group graphics-related code (#5389).+    + Move `\setstretch` after front matter (#5179).  Ensures that+      `\maketitle`, `\tableofcontents`, and so forth are not affected by+      changes to line spacing.++  * Update data/jats.csl to avoid commas between name-part elements+    (#5397).++  * Add support for golang (`go`) with `--listings` (#5427).++  * Text.Pandoc.Shared - improve `metaToJSON` behavior with numbers.+    We now do a better job marshalling numbers from MetaString+    or MetaInlines into JSON Number.++  * Text.Pandoc.Writers.Shared: `metaValueToJSON`: use Number Values for+    integers.  Pandoc's MetaValue doesn't have a distinguished number type,+    so numbers are put in MetaStrings.  If the MetaString consists+    entirely of digits, we convert it to a Number.  We should probably+    consider adding a MetaNumber constructor to MetaValue, for better+    round-tripping with JSON etc.  This change aids round-tripping in+    ipynb metadata fields, like `toc_depth`.++  * Text.Pandoc.Class: `fetchItem`: don't treat UNC paths as+    protocol-relative URLs (#5127).  These are paths beginning `//?/UNC/...`.++  * Text.Pandoc.ImageSize: Improve `pdfSize` so it handles+    a wider range of PDFs (#4322, with help from Richard Davis).++  * Text.Pandoc.Pretty: avoid stack overflow by using strict sum (#5401).++  * Fix harmless error in file-scope code (#5422).++  * MANUAL.txt:++    + Improve 'header' and 'heading' usage (#5423, Andrew+      Dunning).  The term 'header' was being used where 'heading'+      is more appropriate.+    + Add paragraph on options affecting markdown in ipynb.++  * stack.yaml - remove -Wmissing-home-modules+    This seems to cause problems with stack ghci.  Remove RTS options.++  * Add ghc-options to cabal.project.++  * appveyor.yml - use ghc 8.6.4.  Fixes segfault issues on Windows (#5037).++  * linux build process: Remove clone of pandoc-citeproc (#5366).+    It wasn't being used; cabal.project specifies the version to use.++## pandoc 2.7.1 (2019-03-14)++  * Add tectonic as an option for --pdf-engine (#5345, Cormac Relf).+    Runs tectonic on STDIN instead of a temporary .tex file, so that it+    looks in the working directory for `\include` and `\input` like the rest+    of the engines.  Allows overriding the output directory+    args with `--pdf-engine-opt=--outdir --pdf-engine-opt="$DIR"`.++  * Allow `-o/--output` to be used with `--print-default-data-file`,+    `--print-highlighting-style`, `--print-default-template`.+    Note that `-o` must occur BEFORE the `--print*` command on the command+    line (this is documented, #5357).++  * LaTeX reader:++    + Support `\underline`, `\ul`, `\uline` (#5359, Paul+      Tilley).  These are parsed as a Span with class `underline`, as+      with other readers.+    + Ensure that `\Footcite` and `\Footcites` get put in a note.++  * ipynb reader:++    + Remove sensitivity to `raw_html`, `raw_tex` extensions.+      We now include every output format. Pruning is handled by+      `--ipynb-output`.+    + Better handling of cell metadata.  We now include even complex cell+      metadata in the Div's attributes (as JSON, in complex cases, or+      as plain strings in simple cases).++  * ipynb writer:++    + Recurse into native divs for output cell data (#5354).+    + Render cell metadata fields from div attributes.++  * Docx writer: avoid extra copy of abstractNum and num elements+    in numbering.xml.  This caused pandoc-produced docx files to+    be uneditable using Word Online (#5358).++  * Markdown writer: improve handling of raw blocks/inline.+    We now emit raw content using `raw_attribute` when no more+    direct method is available.  Use of `raw_attribute` can be+    forced by disabling `raw_html` and `raw_tex`.++  * LaTeX writer: Add classes for frontmatter support (#5353, Andrew Dunning)+    and remove frontmatter from `scrreprt`.++  * LaTeX template:++    + Improve readability (#5363, Andrew Dunning).+    + Robust section numbering removal (#5351, Andrew Dunning).+      Ensures that section numbering does not reappear with custom+      section levels.  See <https://tex.stackexchange.com/questions/473653/>.+    + Better handling of front/main/backmatter (#5348).+      In pandoc 2.7 we assumed that every class with chapters would accept+      `\frontmatter`, `\mainmatter`, and `\backmatter`.  This is not so (e.g.+      report does not).  So pandoc 2.7 breaks on report class by including an+      unsupported command.  Instead of the `book-class` variable, we use two+      variables, `has-chapters` and `has-frontmatter`, and set these+      intelligently in the writer.++  * Text.Pandoc.Shared: Improve `filterIpynbOutput`.  Ensure that+    images are prioritized over text. `best` should include everything+    for ipynb.++  * Tests.Old: specify `--data-dir=../data` to ensure tests can find+    data files even if they haven't been installed.  Remove old+    `pandoc_datadir` environment variable, which hasn't done anything for a+    long time.++  * MANUAL.txt: Add recommendation to use `raw_attribute` with ipynb (#5354).++  * Use cmark-gfm-hs 0.1.8 (note that 0.1.7 is buggy).++  * Use latest pandoc-citeproc, texmath.+++## pandoc 2.7 (2019-03-03)++  * Use XDG data directory for user data directory (#3582). Instead of+    `$HOME/.pandoc`, the default user data directory is now+    `$XDG_DATA_HOME/pandoc`, where `XDG_DATA_HOME` defaults to+    `$HOME/.local/share` but can be overridden by setting the+    environment variable. If this directory is missing, then+    `$HOME/.pandoc` is searched instead, for backwards compatibility.+    However, we recommend moving local pandoc data files from+    `$HOME/.pandoc` to `$HOME/.local/share/pandoc`. On Windows the+    default user data directory remains the same.++  * Slide show formats behavior change:  content under headers+    less than slide level is no longer ignored, but included in+    the title slide (for HTML slide shows) or in a slide after+    the title slide (for beamer).  This change makes possible+    2D reveal.js slideshows with content in the top slide on+    each stack (#4317, #5237).+ +  * Add command line option `--ipynb-output=all|none|best` (#5339).+    Output cells in ipynb notebooks often contain several different+    versions of an output, with different MIME types, e.g. an HTML+    table and a plain-text fallback.  Specifying `--ipynb-output=best`+    (the default) ensures that the best version for the output format+    is used.  `all` includes all versions, and `none` suppresses them+    all, leaving output cells empty.++  * `asciidoctor` is now an output format separate from `asciidoc`,+    to accommodate some minor implementation-specific differences+    (currently just in the treatment of display math).++  * Add `latexmk` as an option for `--pdf-engine` (#3195).+    Note that you can use `--pdf-engine-opt=-outdir=bar` to specify+    a persistent temp directory.++  * Markdown reader:++    + Improve tight/loose list handling (#5285). Previously the+      algorithm allowed list items with a mix of Para and Plain, which+      is never wanted.+    + Add newline when parsing blocks in YAML (#5271). Otherwise last+      block gets parsed as a Plain rather than a Para. This is a+      regression in pandoc 2.x. This patch restores pandoc 1.19+      behavior.+    + Make `yamlToMeta` respect extensions (#5272, Mauro Bieg).+      This adds a `ReaderOptions` parameter to `yamlToMeta` [API change].+    + Fix bug parsing fenced code blocks (#5304). Previously parsing+      would break if the code block contained a string of backticks of+      sufficient length followed by something other than end of line.++  * LaTeX reader: don't let `\egroup` match `{`. `braced` now actually+    requires nested braces. Otherwise some legitimate command and+    environment definitions can break.++  * Docx reader (Jesse Rosenthal):++    + Rename `getDocumentPath` as `getDocumentXmlPath`.+    + Use field notation for setting `ReaderEnv`.+    + Figure out `document.xml` path once at the beginning of parsing, and+      add it to the environment, so we can avoid repeated lookups.+    + Dynamically determine main document xml path (#5277).+      The desktop Word program places the main document file in+      `word/document.xml`, but the online word places it in+      `word/document2.xml`. This file path is actually stated in the root+      `_rels/.rels` file, in the `Relationship` element with an+      `http://../officedocument` type.+    + Fix paths in archive to prevent Windows failure (#5277).+      Some paths in archives are absolute (have an opening slash) which, for+      reasons unknown, produces a failure in the test suite on MS+      Windows. This fixes that by removing the leading slash if it exists.+    + Add comments to aid code readability.+    + Trim space inside the last inline (#5273).+    + Unwrap sdt elements in footnotes and comments (#5302).++  * Muse reader (Alexander Krotov):++    + Test that block level markup does not break `<verbatim>`.+    + Add secondary note support.++  * ipynb reader: handle images referring to attachments. Previously+    we didn't strip off the attachment: prefix, so even though the+    attachment was available in the mediabag, pandoc couldn't find it.++  * JATS reader:++    + Fix parsing of figures (#5321). This ensures that a figure+      containing a single image is parsed as a pandoc "implicit+      figure" (i.e., a Para with a single Image whose title attribute+      begins with `fig:`). More complex figures will still be parsed+      as divs.+    + Support `fig-group` block element (#5317).+    + Handle citations with multiple references (#5310). The `rid`+      attribute can have a space-separated list of ids.++  * AsciiDoc Writer: Add `writeAsciiDoctor` [API change, Tarik Graba].+    Handle display math appropriately for Asciidoctor.++  * JATS writer: wrap figure caption in `<p>` to fix validation (#5290,+    Mauro Bieg).++  * HTML writer:++    + Implement WAI-ARIA roles for (end)notes, citations, and+      bibliography (#4213). Note that doc-biblioref is only used when+      link-citations produces links, since it belongs on links.+    + Include content (including speaker notes) in title slides+      (#4317, #5237).++  * ipynb writer:++    + Ensure final newline.+    + Only include metadata under `jupyter` field.+    + Don't create attachments for images with absolute URIs,+      including data: URIs (#5303).+    + Keep plain text fallbacks in output even if a richer format is+      included (#5293). We don't know what output format will be needed.+      See the `--ipynb-output` command line option for a way to control+      what formats are included in the output.++  * Markdown writer: use `markdown="1"` when appropriate for Divs:+    when `native_divs` and `markdown_in_html_blocks` are disabled+    but `raw_html` and `markdown_attribute` are enabled.++  * LaTeX writer:++    + Use right fold for `escapeString`.  This is more elegant than+      the explicit recursive code we were using.+    + Avoid `{}` after control sequences when escaping.+      `\ldots{}.` doesn't behave as well as `\ldots.` with the latex+      ellipsis package.  This patch causes pandoc to avoid emitting+      the `{}` when it is not necessary.  Now `\ldots` and other+      control sequences used in escaping will be followed by either+      a `{}`, a space, or nothing, depending on context.+    + For beamer, include contents under headers superordinate to+      slidelevel (#4317). Currently we keep the fancy title slide, and+      add a new slide with the same title and whatever content was+      under the header.++  * Powerpoint writer (Jesse Rosenthal): support underlines.+    Use span with single class "underline" as in docx writer.++  * Muse writer: escape secondary notes (Alexander Krotov).++  * FB2 writer: add section identifiers support (#5229, John KetzerX).++  * Make `--fail-if-warnings` work for PDF output (#5343).++  * Lua filters (Albert Krewinkel):++    + Load module `pandoc` before calling `init.lua` (#5287). The file+      `init.lua` in pandoc's data directory is run as part of pandoc's+      Lua initialization process. Previously, the `pandoc` module was+      loaded in `init.lua`, and the structure for marshaling was+      set up after. This allowed simple patching of element+      marshaling, but made using `init.lua` more difficult. Now, all+      required modules are now loaded before calling `init.lua`. The+      file can be used entirely for user customization. Patching+      marshaling functions, while discouraged, is still possible via+      the `debug` module.+    + All Lua modules bundled with pandoc, i.e., `pandoc.List`,+      `pandoc.mediabag`, `pandoc.utils`, and `text` are re-exported from the+      `pandoc` module. They are assigned to the fields `List`, `mediabag`,+      `utils`, and `text`, respectively.++  * Text.Pandoc.Lua (Albert Krewinkel):+  +    + Split `StackInstances` into smaller Marshaling modules.+    + Get `CommonState` from Lua global. This allows more control over+      the common state from within Lua scripts.++  * LaTeX template:++    + Support the `subject` metadata variable (#5289, Pascal Wagler).+    + Add `\frontmatter`, `\mainmatter`, `\backmatter`+      for book classes (#5306).++  * epub3 template: Add titlepage class to section (#5269).++  * HTML5 template: Add ARIA role `doc-toc` for table of contents (#4213).++  * Make `--metadata-file` use selected extensions (#5279, #5272, Mauro Bieg).++  * Text.Pandoc.Shared:++    + Remove `withTempDir` [API change].+    + Add new exported function `defaultUserDataDirs` [API change].+    + Add `filterIpynbOutput` [API change].+    + `compactify`: Avoid lists with a mix of Plain and Para elements+      (#5285).++  * Text.Pandoc.Translations: reorder alphabetically and remove `Author`+    (#5334, Mauro Bieg).++  * Text.Pandoc.Extensions:++    + More carefully groom ipynb default extensions.+    + Add `all_symbols_escapable` to `githubMarkdownExtensions`.++  * Text.Pandoc.PDF:++    + Use system temp directory when possible (#1192). Previously we+      created temp dirs in the working directory, partly (a) because+      there were problems using the system temp directory on Windows,+      when their pathnames included tildes, and partly (b) because+      programs like `epstopdf.pl` would not be allowed to write to+      directories outside the working directory in restricted mode. We+      now (a) use the system temp dir except when the path includes+      tildes, and (b) set `TEXMFOUTPUT` when creating the PDF, so that+      subsidiary programs can use the system temp directory. This+      addresses problems that occurred when pandoc was used in a+      synced directory (such as Dropbox).+    + Change types of subsidiary functions to PandocIO, to allow+      warnings to be threaded through (#5343).++  * Text.Pandoc.MIME: add WebP (#5267, Mauro Bieg).++  * Tests: avoid calling `findPandoc` multiple times.++  * Old tests: remove need for temp files by using `pipeProcess`.++  * Added simple ipynb reader/writer tests (#5274).++  * Rearrange `--help` output in a more rational way, with common+    options at the beginning and options grouped by function (#5336).++  * trypandoc: Add JATS and other missing formats (Arfon Smith, #5291).++  * Add missing copyright notices and remove license boilerplate (#4592,+    Albert Krewinkel).++  * Use latest basement/foundation on 32bit windows.++  * Use latest skylighting (#5328). Custom syntax definitions no+    longer try to load `language.dtd`.++  * Require texmath 0.11.2.1++  * Use latest pandoc-citeproc (0.16.1.1).++  * MANUAL.txt:++    + Clarify variable substitution indentation in templates (#5338,+      Agustín Martín Barbero).+    + Reorder custom-styles section (#5324, Mauro Bieg).++## pandoc 2.6 (2019-01-30)++  * Support ipynb (Jupyter notebook) as input and output format.++    + Add `ipynb` as input and output format (extension `.ipynb`).+    + Added Text.Pandoc.Readers.Ipynb [API change].+    + Added Text.Pandoc.Writers.Ipynb [API change].+    + Add `PandocIpynbDecodingError` constructor to Text.Pandoc.Error.Error+      [API change].+    + Depend on ipynb library.+    + Note: there is no template for ipynb.++  * Add DokuWiki reader (#1792, Alexander Krotov).  This adds+    Text.Pandoc.Readers.DokuWiki [API change], and adds `dokuwiki`+    as an input format.++  * Implement task lists (#3051, Mauro Bieg). Added `task_lists`+    extension. Task lists are supported from markdown and gfm input.+    They should work, to some degree, in all output formats, though in+    most formats you'll get a bullet list with a unicode character for+    the box. In HTML, you get checkboxes and in LaTeX/PDF output, a+    box is used as the list marker. API changes:++    + Added constructor `Ext_task_lists` to `Extension`.+    + Added `taskListItemFromAscii` and `taskListItemToAscii` to+      Text.Pandoc.Shared.++  * Allow some command line options to take URL in addition to FILE.+    `--include-in-header`, `--include-before-body`, `--include-after-body`.++  * HTML reader:++    + Handle empty `start` attribute (see #5162).+    + Treat `textarea` as a verbatim environment (#5241) and preserve+      spacing.++  * RST reader:++    + Change treatment of `number-lines` directive (Brian Leung,+      #5207). Directives of this type without numeric inputs should+      not have a `startFrom` attribute; with a blank value, the+      writers can produce extra whitespace.+    + Removed superfluous `sourceCode` class on code blocks (#5047).+    + Handle `sourcecode` directive as synonynm for `code` (#5204).++  * Markdown reader:++    + Remove `sourceCode` class for literate Haskell code blocks+      (#5047). Reverse order of `literate` and `haskell` classes on+      code blocks when parsing literate Haskell, so `haskell` is+      first.+    + Treat `<textarea>` as a verbatim environment (#5241).++  * Org reader:++    + Handle `minlevel` option differently (#5190, Brian Leung).+      When `minlevel` exceeds the original minimum level observed in+      the file to be included, every heading should be shifted+      rightward.+    + Allow for case of `:minlevel == 0` (#5190).+    + Fix treatment of links to images (#5191, Albert Krewinkel).+      Links with descriptions which are pointing to images are no+      longer parsed as inline images, but as links.+    + Add support for #+SELECT_TAGS (Brian Leung).+    + Separate filtering logic from conversion function (Brian Leung).++  * TWiki reader: Fix performance issue with underscores (#3921).++  * MediaWiki reader: use `_` instead of `-` in auto-identifiers (#4731).+    We may not still be exactly matching mediawiki's algorithm.++  * LaTeX reader:++    + Remove `sourceCode` class for literate Haskell code blocks+      (#5047). Reverse order of `literate` and `haskell` classes on+      code blocks when parsing literate Haskell, so `haskell` is+      first.+    + Support `\DeclareMathOperator` (#5149).+    + Support `\inputminted` (#5103).+    + Support `\endinput` (#5233).+    + Allow includes with dots like `cc_by_4.0`.  Previously the `.0`+      was interpreted as a file extension, leading pandoc not to add+      `.tex` (and thus not to find the file).  The new behavior matches+      tex more closely.++  * Man reader:++    + Use `mapLeft` from Shared instead of defining own.++  * Docx reader (Jesse Rosenthal):++    + Handle level overrides (#5134).++  * Docx writer:++    + Support custom properties (#3024, #5252, Agustín Martín Barbero).+      Also supports additional core properties:  `subject`, `lang`,+      `category`, `description`.+    + Make Level into a real type, instead of an alias for a tuple+      (Jesse Rosenthal).++  * ICML writer (Mauro Bieg):++    + Support custom-styles (#5137, see #2106).+    + Support unnumbered headers (#5140).++  * Texinfo writer: Use header identifier for anchor if present (#4731).+    Previously we were overwriting an existing identifier with a new one.++  * Org writer: Preserve line-numbering for example and code blocks+    (Brian Leung).++  * Man/Ms writers: Don't escape `-` as `\-`. The `\-` gets rendered+    in HTML and PDF as a unicode minus sign.++  * Ms writer: Ensure we have a newline after .EN in disply math (#5251).++  * RST writer: Don't wrap simple table header lines (#5128).++  * Asciidoc writer: Shorter delimiters for tables, blockquotes+    (#4364). This matches asciidoctor reference docs.++  * Dokuwiki writer: Remove automatic `:` prefix before internal image+    links (#5183, Damien Clochard).  This prevented users from making+    relative image links.++ *  Zimwiki writer: remove automatic colon prefix before internal+    images (#5183, Damien Clochard).++  * MediaWiki writer: fix caption, use 'thumb' instead of 'frame'+    (#5105). Captions used to have the word 'caption' prepended; this+    has been removed. Also, 'thumb' is used instead of 'frame' to+    allow images to be resized.++  * reveal.js writer:++    + Ensure that we don't get > 2 levels of section nesting,+      even with slide level > 2 (#5168).+    + If slide level == N but there is no N-level header, make+      sure the next header with level > N gets treated as a slide+      and put in a section, rather than remaining loose (#5168).++  * Markdown writer:++    + Make `plain` RawBlocks pass through in `plain` output.+    + Include needed whitespace after HTML figure (#5121).+      We use HTML for a figure in markdown dialects that can't+      represent it natively.++  * Commonmark writer:++    + Fix handling of SoftBreak with `hard_line_breaks` (#5195).+    + Implement `--toc` (`writerTableOfContents`)+      in commonmark/gfm writers (#5172).++  * EPUB writer:++    + Ensure that picture transforms are done on metadata too.+    + Small fixes to `nav.xhtml`:+      Add 'landmarks' id attribute to the landmarks nav.+      Replace old default CSS removing numbers from ol.toc li+      with new rules that match `nav#toc ol, nav#landmarks ol`.+      We keep the `toc` class on `ol` for backwards compatibility.++  * LaTeX writer:++    + Make raw content marked `beamer` pass through in `beamer`+      output (pandoc/lua-filters#40).+    + Beamer: avoid duplicated `fragile` property in some cases+      (#5208).+    + Add `#` special characters for listings (#4939).+      This character needs special handling in `\lstinline`.++ *  RTF writer: use `toTableOfContents` from Shared to replace+    old duplicated code.++  * Pptx writer:++    + Support custom properties.  Also supports additional core+      properties: `subject`, `category`, `description` (#5252,+      Agustín Martín Barbero).+    + Use `toTableOfContents` from Shared to replace old duplicated code.++  * ODT writer (Augustín Martín Barbero):++    + Fix typo in custom properties (#2839).+    + Improve standard properties, including the following core+      properties: `generator` (Pandoc/VERSION), `description`, `subject`,+      `keywords`, `initial-creator` (from authors), `creation-date`+      (actual creation date) (#5252).++  * Custom writers:++    + Allow '-' in filenames for custom lua writers (#5187).+    + sample.lua: add `SingleQuoted`, `DoubleQuoted` (#5104).+    + sample.lua: Add a missing `>` (MichaWiedenmann).++  * reveal.js template:  Add `zoomKey` config (#4249).++  * HTML5 template: Remove unnecessary type="text/css" on style and+    link for HTML5 (#5146).++  * LaTeX template (Andrew Dunning, except where noted):++    + Prevent fontspec from scaling `mainfont` to match the default+      font, Latin Modern. A main font set to 12pt could+      previously appear between 11pt to 13pt depending on its design.+      To return to the earlier rendering, use `-V+      mainfontoptions="Scale=MatchLowercase"` (#5212, #5218).+    + Display monospaced fonts without TeX ligatures when using+      `--pdf-engine=lualatex`. It now matches the behaviour of other+      engines (#5212, #5218).+    + Remove the deprecated `romanfont` variable. The functionality of+      `mainfont` is identical (#5218).+    + Render `\subtitle` with the standard document classes.+      Previously, `subtitle` only appeared when using the KOMA-Script+      classes or Beamer (#5213, #5244).+    + Use Babel instead of Polyglossia for LuaLaTeX. This avoids+      several language selection problems, notably with retaining+      French spacing conventions when switching to a verbatim+      environment or another language; and in printing Greek text+      without hyphenation (#5193).+    + Use the [`xurl`](https://ctan.org/pkg/xurl) package if+      available, improving the appearance of URLs by allowing them to+      break at additional points (#5193).+    + Use [`bookmark`](https://ctan.org/pkg/bookmark) if available+      to correct heading levels in PDF bookmarks: see the [KOMA-Script+      3.26 release notes](https://komascript.de/release3.26) (#5193).+    + Require the [`xcolor`](https://ctan.org/pkg/xcolor) package to+      avoid a possible error when using additional packages alongside+      footnotes in tables (#5193, closes #4861).+    + Remove obsolete `fixltx2e` package, which has no functionality+      with TeX Live 2015 or later (#5193).+    + Allow multiple `fontfamilies.options` (#5193, closes #5194).+    + Restrict `institute` variable to Beamer (#5219).+    + Use [`footnotehyper`](https://ctan.org/pkg/footnotehyper)+      package if available to make footnotes in tables compatible+      with `hyperref` (#5234).+    + Number parts and chapters in book classes only if the+      `numbersections` variable is set, for consistency with other+      output formats. To return to the previous behaviour, use+      `-V numbersections -V secnumdepth=0` (#5235).+    + Reindent file (#5193).+    + Use built-in parskip handling with KOMA-Script classes (#5143, Enno).+    + Set default listings language for lua, assembler (#5227, John+      MacFarlane).  Otherwise we get an error when trying to compile code+      with lua or assembler code.  To change the default dialect+      (currenty 5.3 for lua and x86masm for assembler), you can use+      `--include-in-header` to inject something like+      `\lstset{defaultdialect=[5.2]Lua}`.++  * Text.Pandoc.Readers: Changed types of `readJSON`; it now runs+    in an instance of PandocMonad, like the other readers and+    writers.  [API change]++  * Text.Pandoc.Writers: Changed types of `writeJSON`; it now runs+    in an instance of PandocMonad, like the other readers and+    writers.  [API change] ++  * Text.Pandoc.Error: Added `PandocUTF8DecodingError` constructor+    for `PandocError`. [API change]++  * Text.Pandoc.Writers.Shared - add `toTableOfContents`. [API change]+    This is refactored out from the Markdown writer.+    It can be used in other writers to create a table of contents.++  * Improve error messages for UTF-8 decoding errors. Now we give+    the filename and byte offset (#4765).++  * Text.Pandoc.XML: Strip out illegal XML characters in+    `escapeXMLString` (#5119).++  * Text.Pandoc.Process: update `pipeProcess` (Albert Krewinkel).+    The implementation of `pipeProcess` was rewritten to fix sporadic+    failures caused by prematurely closed pipes.++  * Use `safeRead` instead of `read` everywhere in the code+    (John MacFarlane, Mauro Bieg, #5162, #5180).++  * Text.Pandoc.SelfContained: Decompress `.svgz` when+    converting to `data:` URI (#5163, Alexander Krotov).++  * Text.Pandoc.Parsing: Remove unused `HasHeaderMap`+    (#5175, Alexander Krotov). [API change]++  * Normalize Windows paths to account for change in ghc 8.6 (#5127).+    When pandoc is compiled with ghc 8.6, Windows paths are treated+    differently, and paths beginning `\\server` no longer work.+    This commit rewrites such patsh to `\\?\UNC\server` which works.+    The change operates at the level of argument parsing, so it+    only affects the command line program.++  * Simplify/fix reading of `--metadata` values on command line+    to avoid problems relating to hvr/HsYAML#7 (#5177).++  * data/pandoc.lua: auto-fix nested constructor arguments (Albert+    Krewinkel).  Incorrect types to pandoc element constructors are+    automatically converted to the correct types when possible. This was+    already done for most constructors, but conversions are now also done+    for nested types (like lists of lists).++  * Removed custom Setup.hs, use build-type: simple. The only thing we+    gained from the custom build was automatic installation of the man+    page when using 'cabal install'. But custom builds cause problems,+    e.g., with cross-compilation. Installation of the man page is+    better handled by packagers. Note to packagers (e.g. Debian): it+    may be necessary to add a step installing the man page with the+    next release.++  * Allow latest http-client, tasty, zip-archive, Glob.++  * Require skylighting >= 0.7.5, adding support for sml, J,+    typescript.++   * Tests:  Cleaned up `findPandoc` in `Tests.Helpers`, so it+     works well with cabal v2.++  * INSTALL.md:++    + Use button for installer links (John MacFarlane, Mauro Bieg,+      #5167).+    + Fix links and bump required stack version (max).+    + Improve installation notes on associated software (Andrew+      Dunning). Includes explanation of how to install related tools+      with package managers (since the method of installing+      `rsvg-convert` is not obvious).++  * doc/org.md: improve documentation of org features (Albert+    Krewinkel).++  * doc/lua-filters.md:  use 3rd level headers for module fields.++  * MANUAL:++    + Clarify automatic identifiers (#5201). We remove+      non-alphanumerics. This includes, e.g., emojis.+    + Fix example for Div with id (Geoffrey Ely).+    + Update list of LaTeX packages used.+    + Make it clear that `hard_line_breaks` works in `gfm` (see #5195).+    + Mention `raw_attribute` in documentation for `raw_html` and+      `raw_tex` (#5240, thanks to @eiro).+    + Clarify that `$sep$` must come right before `$endfor$` in templates+      (#5243, Lev Givon).+    + Document metadata support for docx, odt, pptx writers (Agustín+      Martín Barbero).+    + Reorganize template variables (#5249, Andrew Dunning).+      Add additional headings to categorize variables, and+      alphabetize when there is large number; add more examples.+    + Document `date-meta` template variable (#5260, Tristan Stenner).++  * trypandoc: Fix CSS and viewport.++## pandoc 2.5 (2018-11-27)++  * Text.Pandoc.App: split into several unexported submodules (Albert+    Krewinkel):  Text.Pandoc.App.FormatHeuristics,+    Text.Pandoc.App.Opt, Text.Pandoc.App.CommandLineOptions,+    Text.Pandoc.App.OutputSettings.  This is motivated partly by the+    desire to reduce recompilations when something is modified,+    since App previously depended on virtually every other module.++  * Text.Pandoc.Extensions++    + Semantically, `gfm_auto_identifiers` is now a modifier of+      `auto_identifiers`; for identifiers to be set, `auto_identifiers` must+      be turned on, and then the type of identifier produced depends on+      `gfm_auto_identifiers` and `ascii_identifiers` are set. Accordingly,+      `auto_identifiers` is now added to `githubMarkdownExtensions` (#5057).+    + Remove `ascii_identifiers` from `githubMarkdownExtensions`.+      GitHub doesn't seem to strip non-ascii characters any more.++  * Text.Pandoc.Lua.Module.Utils (Albert Krewinkel)++    + Test AST object equality via Haskell (#5092).  Equality of Lua+      objects representing pandoc AST elements is tested by unmarshalling+      the objects and comparing the result in Haskell.+      A new function `equals` which performs this test has been added to the+      `pandoc.utils` module.+    + Improve stringify.  Meta value strings (MetaString)+      and booleans (MetaBool) are now converted to the literal string and the+      lowercase boolean name, respectively. Previously, all values of these+      types were converted to the empty string.++  * Text.Pandoc.Parsing: Remove Functor and Applicative constraints where Monad+    already exists (Alexander Krotov).++  * Text.Pandoc.Pretty: Don't render BreakingSpace at end of line+    or beginning of line (#5050).++  * Text.Pandoc.Readers.Markdown++    + Fix parsing of citations, quotes, and underline emphasis+      after symbols.  Starting with pandoc 2.4, citations, quoted inlines,+      and underline emphasis were no longer recognized after certain+      symbols, like parentheses (#5099, #5053).+    + In pandoc 2.4, a soft break after an abbreviation would be+      relocated before it to allow for insertion of a nonbreaking+      space after the abbreviation. This behavior is here reverted.+      A soft break after an abbreviation will remain, and no nonbreaking+      space will be added. Those who care about this issue should take care not+      to end lines with an abbreviation, or to insert nonbreaking spaces+      manually.++  * Text.Pandoc.Readers.FB2: Do not throw error for unknown elements in+    `<body>` (Alexander Krotov).  Some libraries include custom elements+    in their FB2 files.++  * Text.Pandoc.Readers.HTML++    + Allow `tfoot` before body rows (#5079).+    + Parse `<small>` as a Span with class "small" (#5080).+    + Allow thead containing a row with `td` rather than `th` (#5014).++  * Text.Pandoc.Readers.LaTeX++    + Cleaned up handling of dimension arguments.  Allow decimal points,+      preceding space.+    + Don't allow arguments for verbatim, etc.+    + Allow space before bracketed options.+    + Allow optional arguments after `\\` in tables.+    + Improve parsing of `\tiny`, `\scriptsize`, etc.  Parse as raw,+      but know that these font changing commands take no arguments.++  * Text.Pandoc.Readers.Muse++    + Trim whitespace before parsing grid table cells (Alexander Krotov).+    + Add grid tables support (Alexander Krotov).++  * Text.Pandoc.Shared++    + For bibliography match Div with id `refs`, not class `references`.+      This was a mismatch between pandoc's docx, epub, latex, and markdown+      writers and the behavior of pandoc-citeproc, which actually looks for a+      div with id `refs` rather than one with class `references`.+    + Exactly match GitHub's identifier generating algorithm (#5057).+    + Add parameter for `Extensions` to `uniqueIdent` and+      `inlineListToIdentifier` (#5057).  [API change]+      This allows these functions to be sensitive to the settings of+      `Ext_gfm_auto_identifiers` and `Ext_ascii_identifiers`, and allows us to+      use `uniqueIdent` in the CommonMark reader, replacing custom code.  It+      also means that `gfm_auto_identifiers` can now be used in all formats.++  * Text.Pandoc.Writers.AsciiDoc++    + Use `.`+ as list markers to support nested ordered lists (#5087).+    + Support list number styles (#5089).+    + Render Spans using `[#id .class]#contents#` (#5080).++  * Text.Pandoc.Writers.CommonMark++    + Respect `--ascii` (#5043, quasicomputational).+    + Make sure `--ascii` affects quotes, super/subscript.++  * Text.Pandoc.Writers.Docx++    + Fix bookmarks to headers with long titles (#5091).+      Word has a 40 character limit for bookmark names.  In addition, bookmarks+      must begin with a letter.  Since pandoc's auto-generated identifiers may+      not respect these constraints, some internal links did not work.  With+      this change, pandoc uses a bookmark name based on the SHA1 hash of the+      identifier when the identifier isn't a legal bookmark name.+    + Add bookmarks to code blocks (Nikolay Yakimov).+    + Add bookmarks to images (Nikolay Yakimov).+    + Refactor common bookmark creation code into a function (Nikolay Yakimov).++  * Text.Pandoc.Writers.EPUB: Handle calibre metadata (#5098).+    Nodes of the form++          <meta name="calibre:series" content="Classics on War and Politics"/>++      are now included from an epub XML metadata file.  You can also include+      this information in your YAML metadata, like so:++          calibre:+           series: Classics on War and Policitics++      In addition, ibooks-specific metadata can now be included via an XML+      file. (Previously, it could only be included via YAML metadata, see+      #2693.)++  * Text.Pandoc.Writers.HTML: Use plain `"` instead of `&quot;` outside of+    attributes.++  * Text.Pandoc.Writers.ICML: Consolidate adjacent strings, inc. spaces.+    This avoids splitting up the output unnecessarily into separate elements.++  * Text.Pandoc.Writers.LaTeX: Don't emit `[<+->]` unless beamer output, even+    if `writerIncremental` is True (#5072).++  * Text.Pandoc.Writers.Muse (Alexander Krotov).++    + Output tables as grid tables if they have multi-line cells.+    + Indent simple tables only on the top level.+    + Output tables with one column as grid tables.+    + Add support for `--reference-location`.+    + Internal improvements.++  * Text.Pandoc.Writers.OpenDocument: Fix list indentation (Nils Carlson,+    #5095).  This was a regression in pandoc 2.4.++  * Text.Pandoc.Writers.RTF: Fix warnings for skipped raw inlines.++  * Text.Pandoc.Writers.Texinfo: Add blank line before `@menu` section (#5055).++  * Text.Pandoc.XML: in `toHtml5Entities`, prefer shorter entities+    when there are several choices for a particular character.++  * data/abbreviations++    + Add additional abbreviations (Andrew Dunning)+      Many of these borrowed from the Chicago Manual of Style 10.42,+      'Scholarly abbreviations'.++  * Templates++    + Asciidoc template:  add :lang: to title header is lang is set in+      metadata (#5088).++  * pandoc.cabal: Add cabal flag `derive_json_via_th` (Albert Krewinkel)+    Disabling the flag will cause derivation of ToJSON and FromJSON+    instances via GHC Generics instead of Template Haskell. The flag is+    enabled by default, as deriving via Generics can be slow (see #4083).++  * trypandoc:++    + Tweaked drop-down lists.+    + Put link to site in footer.+    + Preselect output format.+    + Update on change of in or out format.+    + Add man input format.++  * MANUAL.txt:++    + Fix outdated description of latex_macros extension.+    + Clarified placement of bibliography.+    + Added "A note on security."+    + Fix note on curly brace syntx for locators.+    + Document new explicit syntax for citeproc locators.+    + Remove confusing cross-links for some extensions.+    + Don't put pandoc in code ticks in heading.+    + Document that `--ascii` works for gfm and commonmark too.+    + Add `man` to `--from` options.++  * doc/customizing-pandoc.md: various improvements (Mauro Bieg).+++## pandoc 2.4 (2018-11-03)++### New features++  * New input format `man` (Yan Pashkovsky, John MacFarlane).++### Behavior changes++  * `--ascii` is now implemented in the writers, not in Text.Pandoc.App,+    via the new `writerPreferAscii` field in `WriterOptions`.+    Now the `write*` functions for Docbook, HTML, ICML, JATS, LaTeX,+    Ms, Markdown, and OPML are sensitive to `writerPreferAscii`.+    Previously the to-ascii translation was done in Text.Pandoc.App,+    and thus not available to those using the writer functions+    directly.++  * `--ascii` now works with Markdown output.  HTML5 character reference+    entities are used.++  * `--ascii` now works with LaTeX output. 100% ASCII output can't be+    guaranteed, but the writer will use commands like `\"{a}` and `\l`+    whenever possible, to avoid emitting a non-ASCII character.++  * For HTML5 output, `--ascii` now uses HTML5 character reference+    entities rather than numerical entities.++  * Improved detection of format based on extension (in Text.Pandoc.App).+    We now ensure that if someone tries to convert a file for a+    format that has a pandoc writer but not a reader, it won't just+    default to markdown.++  * Add viz. to abbreviations file (#5007, Nick Fleisher).++  * AsciiDoc writer:  always use single-line section headers,+    instead of the old underline style (#5038).  Previously the single-line+    style would be used if `--atx-headers` was specified, but+    now it is always used.++  * RST writer: Use simple tables when possible (#4750).++  * CommonMark (and gfm) writer: Add plain text fallbacks. (#4528,+    quasicomputational). Previously, the writer would unconditionally+    emit HTML output for subscripts, superscripts, strikeouts (if the+    strikeout extension is disabled) and small caps, even with+    `raw_html` disabled. Now there are plain-text (and, where+    possible, fancy Unicode) fallbacks for all of these corresponding+    (mostly) to the Markdown fallbacks, and the HTML output is only+    used when `raw_html` is enabled.++  * Powerpoint writer: support raw openxml (Jesse Rosenthal, #4976).+    This allows raw openxml blocks and inlines to be used in the pptx +    writer. Caveats: (1) It's up to the user to write+    well-formed openxml. The chances for corruption, especially with+    such a brittle format as pptx, is high. (2) Because of+    the tricky way that blocks map onto shapes, if you are using+    a raw block, it should be the only block on a slide+    (otherwise other text might end up overlapping it). (3) The+    pptx ooxml namespace abbreviations are different from the+    docx ooxml namespaces. Again, it's up to the user to get it+    right. Unzipped document and ooxml specification should be+    consulted.++  * With `--katex` in HTML formats, do not use the autorenderer (#4946).+    We no longer surround formulas with `\(..\)` or `\[..\]`. Instead,+    we tell katex to convert the contents of span elements with+    class "math". Since math has already been identified, this+    avoids wasted time parsing for LaTeX delimiters. Note, however,+    that this may yield unexpected results if you have span elements+    with class "math" that don't contain LaTeX math.+    Also, use latest version of KaTeX by default (0.9.0).++  * The man writer now produces ASCII-only output, using groff escapes,+    for portability.++  * ODT writer:++    + Add title, author and date to metadata; any remaining+      metadata fields are added as `meta:user-defined` tags.+    + Implement table caption numbering (#4949, Nils Carlson).+      Captioned tables are numbered and labeled with format "Table 1:+      caption", where "Table" is replaced by a translation, depending+      on the value of `lang` in metadata. Uncaptioned tables are not+      enumerated.+    + OpenDocument writer: Implement figure numbering in captions (#4944,+      Nils Carlson). Figure captions are now numbered 1, 2, 3, ...+      The format in the caption is "Figure 1: caption" and so on+      (where "Figure" is replaced by a translation, depending on the+      value of `lang` in the metadata). Captioned figures are numbered+      consecutively and uncaptioned figures are not enumerated. This+      is necessary in order for LibreOffice to generate an+      Illustration Index (Table of Figures) for included figures.++  * RST reader: Pass through fields in unknown directives as div attributes+    (#4715). Support `class` and `name` attributes for all directives.++  * Org reader: Add partial support for `#+EXCLUDE_TAGS` option. (#4284,+    Brian Leung). Headers with the corresponding tags should not+    appear in the output.++  * Log warnings about missing title attributes now include a+    suggestion about how to fix the problem (#4909).++  * Lua filter changes (Albert Krewinkel):++    + Report traceback when an error occurs. A proper Lua traceback is+      added if either loading of a file or execution of a filter+      function fails. This should be of help to authors of Lua filters+      who need to debug their code.++    + Allow access to pandoc state (#5015). Lua filters and custom+      writers now have read-only access to most fields of pandoc's+      internal state via the global variable `PANDOC_STATE`.++    + Push ListAttributes via constructor (Albert Krewinkel).+      This ensures that ListAttributes, as present in OrderedList elements,+      have additional accessors (viz. `start`, `style`, and `delimiter`).++    + Rename ReaderOptions fields, use snake_case. Snake case is used+      in most variable names, using camelCase for these fields was an+      oversight. A metatable is added to ensure that the old field+      names remain functional.++    + Iterate over AST element fields when using `pairs`. This makes+      it possible to iterate over all ield names of an AST element by+      using a generic `for` loop with pairs`:++          for field_name, field_content in pairs(element) do+          ... +          end++      Raw table fields of AST elements should be considered an+      implementation detail and might change in the future. Accessing+      element properties should always happen through the fields+      listed in the Lua filter docs.++      Note that the iterator currently excludes the `t`/`tag` field.++    + Ensure that MetaList elements behave like Lists. Methods usable+      on Lists can also be used on MetaList objects.++    + Fix MetaList constructor (Albert Krewinkel). Passing a MetaList+      object to the constructor `pandoc.MetaList` now returns the+      passed list as a MetaList. This is consistent with the+      constructor behavior when passed an (untagged) list.++  * Custom writers: Custom writers have access to the global variable+    `PANDOC_DOCUMENT`(Albert Krewinkel, #4957). The variable contains+    a userdata wrapper around the full pandoc AST and exposes two+    fields, `meta` and `blocks`. The field content is only+    marshaled on-demand, performance of scripts not accessing the+    fields remains unaffected.++### API changes++  * Text.Pandoc.Options: add `writerPreferAscii` to `WriterOptions`.++  * Text.Pandoc.Shared:++    + Export `splitSentences`. This was previously duplicated in the Man and+      Ms writers.+    + Add `ToString` typeclass (Alexander Krotov).++  * New exported module Text.Pandoc.Filter (Albert Krewinkel).++  * Text.Pandoc.Parsing++    + Generalize `gridTableWith` to any `Char` Stream (Alexander Krotov).+    + Generalize `readWithM` from `[Char]` to any `Char` Stream+      that is a `ToString` instance (Alexander Krotov).++  * New exposed module Text.Pandoc.Filter (Albert Krewinkel).++  * Text.Pandoc.XML: add `toHtml5Entities`.++  * New exported module Text.Pandoc.Readers.Man (Yan Pashkovsky, John+    MacFarlane).++  * Text.Pandoc.Writers.Shared++    + Add exported functions `toSuperscript` and+      `toSubscript` (quasicomputational, #4528).+    + Remove exported functions `metaValueToInlines`,+      `metaValueToString`. Add new exported functions+      `lookupMetaBool`, `lookupMetaBlocks`, `lookupMetaInlines`,+      `lookupMetaString`. Use these whenever possible for uniformity+      in writers (Mauro Bieg, #4907). (Note that+      removed function `metaValueToInlines` was in previous+      released versions.)+    + Add `metaValueToString`.++  * Text.Pandoc.Lua++    + Expose more useful internals (Albert Krewinkel):++      - `runFilterFile` to run a Lua filter from file;+      - data type `Global` and its constructors; and+      - `setGlobals` to add globals to a Lua environment.++      This module also contains `Pushable` and `Peekable` instances+      required to get pandoc's data types to and from Lua. Low-level+      Lua operation remain hidden in Text.Pandoc.Lua.++    + Rename `runPandocLua` to `runLua` (Albert Krewinkel).++    + Remove `runLuaFilter`, merging this into Text.Pandoc.Filter.Lua's+      `apply` (Albert Krewinkel).++### Bug fixes and under-the-hood improvements++  * Text.Pandoc.Parsing++    + Make `uri` accept any stream with Char tokens (Alexander Krotov).+    + Rewrite `uri` without `withRaw` (Alexander Krotov).+    + Generalize `parseFromString` and `parseFromString'` to any+      streams with Char token (Alexander Krotov)+    + Rewrite `nonspaceChar` using `noneOf` (Alexander Krotov)++  * Text.Pandoc.Shared: Reimplement `mapLeft` using `Bifunctor.first`+    (Alexander Krotov).++  * Text.Pandoc.Pretty: Simplify `Text.Pandoc.Pretty.offset`+    (Alexander Krotov).++  * Text.Pandoc.App++    + Work around HXT limitation for --syntax-definition with windows+      drive (#4836).+    + Always preserve tabs for man format. We need it for tables.+    + Split command line parsing code into a separate unexported+      module, Text.Pandoc.App.CommandLineOptions (Albert Krewinkel).++  * Text.Pandoc.Readers.Roff: new unexported module for tokenizing+    roff documents.++  * New unexported module Text.Pandoc.RoffChar, provided character+    escape tables for roff formats.++  * Text.Pandoc.Readers.HTML: Fix `htmlTag` and `isInlineTag` to+    accept processing instructions (#3123, regression since 2.0).++  * Text.Pandoc.Readers.JATS: Use `foldl'` instead of `maximum` to+    account for empty lists (Alexander Krotov).++  * Text.Pandoc.Readers.RST: Don't allow single-dash separator in+    headerless table (#4382).++  * Text.Pandoc.Readers.Org: Parse empty argument array in inline src+    blocks (Brian Leung).++  * Text.Pandoc.Readers.Vimwiki:++    + Get rid of `F`, `runF` and `stateMeta'` in favor of `stateMeta`+      (Alexander Krotov).+    + Parse `Text` without converting to `[Char]` (Alexander Krotov).++  * Text.Pandoc.Readers.Creole: Parse `Text` without converting to+    `[Char]` (Alexander Krotov).++  * Text.Pandoc.Readers.LaTeX++    + Allow space at end of math after `\` (#5010).+    + Add support for `nolinkurl` command (#4992, Brian Leung).+    + Simplified type on `doMacros'`.+    + Tokenize before pulling tokens, rather than after (#4408). This+      has some performance penalty but is more reliable.+    + Make macroDef polymorphic and allow in inline context.+      Otherwise we can't parse something like `\lowercase{\def\x{Foo}}`.+     I have actually seen tex like this in the wild.+    + Improved parsing of `\def`, `\let`. We now correctly parse:+      ```+      \def\bar{hello}+      \let\fooi\bar+      \def\fooii{\bar}+      \fooi +\fooii++      \def\bar{goodbye}+      \fooi +\fooii+      ```+    + Improve parsing of `\def` argspec.+    + Skip `\PackageError` commands (see #4408).+    + Fix bugs omitting raw tex (#4527). The default is `-raw_tex`,+      so no raw tex should result unless we explicitly say `+raw_tex`.+      Previously some raw commands did make it through.+    + Moved `isArgTok` to Text.Pandoc.Readers.LaTeX.Parsing.+    + Moved `babelLangToBCP`, `polyglossiaLangToBCP` to new module,+      Text.Pandoc.Readers.LaTeX.Lang (unexported).+    + Simplified accent code using unicode-transforms.+      New dependency on unicode-transforms package for normalization.+    + Allow verbatim blocks ending with blank lines (#4624).+    + Support `breq` math environments: `dmath`, `dgroup`, `darray`.+      This collects some of the general-purpose code from the LaTeX reader,+      with the aim of making the module smaller.++  * Text.Pandoc.Readers.Markdown++    + Fix awkward soft break movements before abbreviations (#4635).+    + Add updateStrPos in a couple places where needed.++  * Text.Pandoc.Readers.Docx: Trigger bold/italic with bCs, iCs+    (#4947). These are variants for "complex scripts" like Arabic+    and are now treated just like b, i (bold, italic).++  * Text.Pandoc.Readers.Muse (Alexander Krotov)++    + Try to parse lists before trying to parse table.+      This ensures that tables inside lists are parsed correctly.+    + Forbid whitespace after opening and before closing markup+      elements.+    + Parse page breaks.+    + Simplify `museToPandocTable` to get rid of partial functions.+    + Allow footnotes to start with empty line.+    + Make sure that the whole text is parsed.+    + Allow empty headers. Previously empty headers caused parser to+      terminate without parsing the rest of the document.+    + Allow examples to be indented with tabs.+    + Remove indentation from examples indicated by `{{{` and `}}}`.+    + Fix parsing of empty cells.+    + Various changes to internals.+    + Rewrite some parsers in applicative style.+    + Avoid tagsoup dependency.+    + Allow table caption to contain `+`.++  * Text.Pandoc.Writers.LaTeX++    + Add newline if math ends in a comment (#4880). This prevents the+      closing delimiter from being swalled up in the comment.+    + With `--listings`, don't pass through org-babel attributes (#4889).+    + With `--biblatex`, use `\autocite` when possible (#4960).+      `\autocites{a1}{a2}{a3}` will not collapse the entries. So, if+      we don't have prefixes and suffixes, we use instead+      `\autocite{a1,a2,a3}`.+    + Fix description lists contining highlighted code (#4662).++  * Text.Pandoc.Writers.Man++    + Don't wrap `.SH` and `.SS` lines (#5019).+    + Avoid unnecessary `.RS`/`.RE` pair in definition lists with+      one paragraph definitions.+    + Moved common groff functions to Text.Pandoc.Writers.Groff.+    * Fix strong/code combination on man (should be `\f[CB]` not+      `\f[BC]`, see #4973).+    + Man writer: use `\f[R]` instead of `\f[]` to reset font+      (Alexander Krotov, #4973).+    + Move `splitSentences` to Text.Pandoc.Shared.++  * Text.Pandoc.Writers.Docx++    + Add framework for custom properties (#3034). So far, we don't+      actually write any custom properties, but we have the+      infrastructure to add this.++    + Handle tables in table cells (#4953). Although this is not+      documented in the spec, some versions of Word require a `w:p`+      element inside every table cell. Thus, we add one when the+      contents of a cell do not already include one (e.g. when a table+      cell contains a table).++  * Text.Pandoc.Writers.AsciiDoc:  Prevent illegal nestings.+    Adjust header levels so that n+1 level headers are only+    found under n level headers, and the top level is 1.++  * Text.Pandoc.Writers.OpenDocument: Improve bullet/numbering+    alignment (#4385). This change eliminates the large gap we used+    to have between bullet and text, and also ensures that numbers+    in numbered lists will be right-aligned.++  * Text.Pandoc.Writers.ZimWiki++    + Number ordered list items sequentially, rather than always+      with 1 (#4962).+    + Remove extra indentation on lists (#4963).++  * Text.Pandoc.Writers.EPUB: Use metadata field `css` instead of+    `stylesheet` (Mauro Bieg, #4990).++  * Text.Pandoc.Writers.Markdown: Ensure blank between raw block and+    normal content (#4629). Otherwise a raw block can prevent a+    paragraph from being recognized as such.++  * Text.Pandoc.Writers.Ms++    + Removed old `escapeBar`. We don't need this now that we use+      `@` for math delim.+    + Moved common code to Text.Pandoc.Writers.Roff and to+      Text.Pandoc.RoffChar.+    + Move `splitSentences` to Text.Pandoc.Shared (to avoid duplication+      with the man writer).++   * Text.Pandoc.Writers.Muse (Alexander Krotov).++    + Add support for grid tables.+    + Fix Muse writer style.+    + Use `length` instead of `realLength` to calculate definition+      indentation. Muse parsers don't take character width into+      account when calculating indentation.+    + Do not insert newline before lists.+    + Use lightweight markup after `</em>` tag.++  * New unexported module Text.Pandoc.Writers.Roff, providing functions+    useful for all roff format writers (man, ms).++  * Text.Pandoc.Lua++    + Move globals handling to separate module Text.Pandoc.Lua.Global+      (Albert Krewinkel).++    + Lua filter internals: push Shared.Element as userdata (Albert+      Krewinkel). Hierarchical Elements were pushed to Lua as plain+      tables. This is simple, but has the disadvantage that marshaling+      is eager: all child elements will be marshaled as part of the+      object. Using a Lua userdata object instead allows lazy access+      to fields, causing content marshaling just (but also each time)+      when a field is accessed. Filters which do not traverse the full+      element contents tree become faster as a result.++### Default template changes++  * LaTeX template:++    + Add variable `hyperrefoptions` (#4925, Mathias Walter).+    + Add variable `romanfont`, `romanfontoptions` (#4665, OvidiusCicero).++  * AsciiDoc template: use single-line style for title.++  * revealjs template: Fix typo in the socket.io javascript plugin (#5006,+    Yoan Blanc).++  * Text.Pandoc.Lua.Util: add missing docstring to `defineHowTo`+    (Albert Krewinkel).++  * data/pandoc.lua: add datatype ListAttributes (Albert Krewinkel)++  * data/sample.lua: replace custom pipe function with pandoc.utils.pipe+    (Albert Krewinkel).++### Documentation improvements++  * INSTALL.md++    + Add chromeos install instructions (#4958) (Evan Pratten).+    + Add note about TinyTeX.++  * MANUAL.txt++    + Change `groff` -> `roff`.+    + Implement `--ascii` for Markdown writer.+    + Clarify LaTeX image dimensions output (Mauro Bieg).++  * doc/customizing-pandoc.md: added skeleton (Mauro Bieg, #3288).++  * doc/getting-started.md: Added title to test1.md to avoid warning.++  * doc/lua-filters.md: merge type references into main document,+    fix description of Code.text (Albert Krewinkel).++### Build infrastructure improvements++  * Makefile++    + Makefile: added quick-cabal, full-cabal targets.+    + Make .msi download targets insensitive to order of appveyor builds.++  * Update benchmarks for ghc 8.6.1.++   * pandoc.cabal:++    + Enable more compiler warnings (Albert Krewinkel).+    + Make base lower bound 4.8.+    + Bump upper bound for QuickCheck.+    + Bump upper bound for binary.+    + Updated version bounds for containers and haddock-library (#4974).+    + Added docx/docPropos/custom.xml to cabal data-files.+    + Require skylighting 0.7.4 (#4920).+    + New dependency on unicode-transforms package for normalization.++  * Improved .travis.yml testing and test with GHC 8.6.1 (Albert Krewinkel).++  * Added `tools/changelog-helper.sh`.++  * Added test/grofftest.sh for testing the man reader on real man pages.++## pandoc 2.3.1 (2018-09-28)++  * RST reader:++    + Parse RST inlines containing newlines (#4912, Francesco Occhipinti).+      This eliminates a regression introduced after pandoc 2.1.1, which+      caused inline constructions containing newlines not to be recognized.+    + Fix bug with internal link targets (#4919).  They were gobbling up+      indented content underneath.++  * Markdown reader: distinguish autolinks in the AST.  With this change,+    autolinks are parsed as Links with the `uri` class. (The same is true+    for bare links, if the `autolink_bare_uris` extension is enabled.)+    Email autolinks are parsed as Links with the `email` class.  This+    allows the distinction to be represented in the AST.++  * Org reader:++    + Force inline code blocks to honor export options (Brian Leung).+    + Parse empty argument array in inline src blocks (Brian Leung).++  * Muse reader (Alexander Krotov):++    + Added additional tests.+    + Do not allow code markup to be followed by digit.+    + Remove heading level limit.+    + Simplify `<literal>` tag parsers+    + Parse Text instead of String. Benchmark shows 7% improvement.+    + Get rid of HTML parser dependency.+    + Various code improvements.++  * ConTeXt writer: change `\` to `/` in Windows image paths (#4918).+    We do this in the LaTeX writer, and it avoids problems.+    Note that `/` works as a LaTeX path separator on Windows.++  * LaTeX writer:++    + Add support for multiprenote and multipostnote arguments+      with `--biblatex` (Brian Leung, #4930).  The multiprenotes occur before+      the first prefix of a multicite, and the multipostnotes follow the+      last suffix.+    + Fix a use of `last` that might take empty list.  If you ran with+      `--biblatex` and have an empty document (metadata but no blocks),+      pandoc would previously raise an error because of the use of+      `last` on an empty list.++  * RTF writer: Fix build failure with ghc-8.6.1 caused by missing+    MonadFail instance (Jonas Scholl).++  * ODT Writer: Improve table header row style handling (Nils Carlson).+    This changes the way styles for cells in the header row+    and normal rows are handled in ODT tables.+    Previously a new (but identical) style was generated for+    every table, specifying the style of the cells within the table.+    After this change there are two style definitions for table cells,+    one for the cells in the header row, one for all other cells.+    This doesn't change the actual styles, but makes post-processing+    changes to the table styles much simpler as it is no longer+    necessary to introduce new styles for header rows and there are+    now only two styles where there was previously one per table.++  * HTML writer:++    + Don't add `uri` class to presumed autolinks.  Formerly the `uri`+      class was added to autolinks by the HTML writer, but it had to+      guess what was an autolink and could not distinguish+      `[http://example.com](http://example.com)` from+      `<http://example.com>`.  It also incorrectly recognized+      `[pandoc](pandoc)` as an autolink.  Now the HTML writer+      simply passes through the `uri` attribute if it is present,+      but does not add anything.+    + Avoid adding extra section nestings for revealjs.+      Previously revealjs title slides at level (slidelevel - 1)+      were nested under an extra section element, even when+      the section contained no additional (vertical) content.+      That caused problems for some transition effects.+    + Omit unknown attributes in EPUB2 output.  For example,+      `epub:type` attributes should not be passed through,+      or the epub produced will not validate.++  * JATS writer: remove 'role' attribute on 'bold' and 'sc' elements (#4937).+    The JATS spec does not allow these.++  * Textile writer: don't represent `uri` class explicitly+    for autolinks (#4913).++  * Lua filters (Albert Krewinkel):++    + Cleanup filter execution code.+    + Better error on test failure.++  * HTML, Muse reader tests: reduce time taken by round-trip test.++  * Added cabal.project.++  * MANUAL: `epub:type` is only useful for epub3 (Maura Bieg).++  * Use hslua v1.0.0 (Albert Krewinkel).++  * Fix `translations/ru` to use modern Russian orthography+    (Ivan Trubach).++  * Build Windows binary using ghc 8.6.1 and cabal new-build. This+    fixes issues with segfaults in the 32-bit Windows binaries (#4283).++## pandoc 2.3 (2018-09-16)++  * Add `--metadata-file` option (Mauro Bieg, #1960), which allows+    users to specify metadata in a YAML file, regardless of the+    input format (#1960).++  * Text.Pandoc.Writers.Shared: export `isDisplayMath` (API change).++  * Text.Pandoc.Readers.Markdown: export `yamlToMeta` (API change,+    Mauro Bieg).++  * Text.Pandoc.Readers.LaTeX.Types:++    + New type `ArgSpec` (API change).+    + Second parameter of `Macro` constructor is now `[ArgSpec]` instead of+      `Int` (API change).++  * Markdown reader:++    + Use `tex` instead of `latex` for raw tex-ish content. We can't+      always tell if it's LaTeX, ConTeXt, or plain TeX. Better just to+      use `tex` always. Note that if `context` or `latex` specifically+      is desired, you can still force that in a markdown document by+      using the raw attribute. Note that this change may affect some+      filters, if they assume that raw tex parsed by the Markdown reader+      will be RawBlock (Format `latex`). In most cases it should be+      trivial to modify the filters to accept `tex` as well.+    + Refactor and reorganize YAML code (Mauro Bieg).+    + Make `example_lists` work for interrupted lists+      without `startnum` (#4908).++  * HTML reader:++    + Parse `<script type="math/tex` tags as math (#4877).+      These are used by MathJax in some configurations.+    + Extract spaces inside links instead of trimming them+      (Alexander Krotov, #4845).+    + Added round-trip tests (Alexander Krotov).+    + Make parsing sensitive to the `raw_tex` extension (#1126). This now+      allows raw LaTeX environments, `\ref`, and `\eqref` to be parsed+      (which is helpful for translation HTML documents using MathJaX).++  * Org reader (Albert Krewinkel):++    + Respect export option `p` for planning info.  Inclusion of planning info+      (`*DEADLINE*`, `*SCHEDULED*`, and `*CLOSED*`) can be controlled via the+      `p` export option: setting the option to `t` will add all planning+      information in a *Plain* block below the respective headline.+    + Org reader internals: don't rely on RecordWildCards and ViewPatterns+      ghc extensions.+    + Strip planning info from output.  Planning info is parsed, but not+      included in the output (as is the default with Emacs Org-mode, #4867).++  * LaTeX reader:++    + Handle parameter patterns for `\def` (#4768, #4771).+      For example:  `\def\foo#1[#2]{#1 and #2}`.+    + Allow `%` characters in URLs. This affects `\href` and `\url` (#4832).+    + Fixed parsing of `\texorpdfstring`. We were returning the wrong+      argument as the content.+    + Support `blockcquote`, `foreignblockquote`, `foreigncblockquote`,+      `hyphenblockquote`, `hyphencblockquote`, `enquote*`, `foreignquote`,+      `hyphenquote` from `csquotes` (#4848). Note that `foreignquote`+      will be parsed as a regular Quoted inline (not using the quotes+      appropriate to the foreign language).+    + Support more text-mode accents (#4652). Add support for `\|`, `\b`, `\G`,+      `\h`, `\d`, `\f`, `\r`, `\t`, `\U`, `\i`, `\j`, `\newtie`,+      `\textcircled`. Also fall back to combining characters when composed+      characters are not available.+    + Resolve `\ref` for figure numbers.+    + Support `mintinline` (#4365, Marc Schreiber).+    + Fix siunitx unit commands so they are only recognized in+      siunitx contexts (#4842). For example, `\l` outside of an+      siunitx context should be l-slash, not l (for liter).+    + Fix double `unnumbered` class (#4838). The `unnumbered` class+      was being included twice for starred sections.++  * RST reader: Don't skip link definitions after comments (#4860).++  * Muse reader (Alexander Krotov):++    + Close the `</quote>` in indented tag test.+      There is already a separate test for unclosed `</quote>`.+    + Autonumber sections in the correct order.  Parsing now stops+      at each section header to ensure the header is registered before+      parsing of the next section starts.+    + Move duplicate code into `headingStart` function.+    + Allow newline after opening `*` or `**`.+    + Don't allow digits after closing marker in lightweight markup+      This change makes reader more compatible with Emacs Muse.+    + Parse `<verse>` tag in one pass instead of using+      `parseFromString`. This change makes it possible to have+      verbatim `</verse>` tag inside verse.++  * ODT reader:  deal gracefully with missing `<office:font-face-decls/>`+    (#4336). This allows pandoc to parse ODT document produced by KDE's+    Calligra.++  * Muse writer (Alexander Krotov):++    + Output headers without asterisks if not on the top level.+    + Never wrap definition list terms.+    + Set `envInsideBlock = True` when rendering notes.+    + Use `""` instead of `[]` for empty String.+    + Check for whitespace in the beginning and end of Str's.+    + Escape `-`, `;` and `>` in the beginning of strings.+    + Escape list markers in the beginning of notes.+    + Normalize inline list before testing if tags should be used.+    + Use tags instead of lightweight markup for empty strings.+    + Use lightweight markup when possible.+    + Escape empty strings.  This guarantees that `conditionalEscapeString`+      never returns empty string.+    + Wrap conditionalEscapeString result into `Muse` type.+      This removes the need to pass `envInsideLinkDescription` to it.+    + Separate `shouldEscapeString` function.+    + Simplify inline list rendering.+    + Replace newlines in strings with spaces.++  * Docx writer:++    + Add MetaString case for abstract, subtitle (#4900, Mauro Bieg).+    + Properly handle display math in spans (#4826). This isn't a+      complete solution, since other nestings of display math may still+      cause problems, but it should work for what is by far the most+      common case.++  * HTML writer:++    + Always output `<dt>` element, even if it is empty (#4883,+      Alexander Krotov).+    + Don't prefix `epub:` attributes with `data-`.++  * Org writer: Don't escape literal `_`, `^` (#4882). Org doesn't+    recognize these escapes.++  * ODT writer: Fix percentage image scaling (#4881, Nils Carlson).+    Image scaling was broken when a width was set to a percentage.++  * EPUB writer: set `epub:type` on body element in each chapter,+    depending on the `epub:type` of the first section (#4823). This+    only affects epub3. See+    http://www.idpf.org/epub/profiles/edu/structure/#h.l0bzsloklt10++  * FB2 writer: put `coverpage` element between title and date rather than in+    `document-info` element (#4854).++  * Markdown writer: Escape `~` if strikeout extension enabled (#4840).++  * Haddock writer: Use proper format for latex math in haddock (#4571, Joe+    Hermaszewski). Inline math in `\(..\)`, display math in `\[..\]`,+    tex is now used. Previously we'd "fake it with unicode" and fall+    back to tex when that didn't work. But newer haddock versions+    support latex math.++  * TEI writer:++    + Ensure that title element is always present, even if empty (#4839).+    + Put author tags in the template, rather than adding them in+      the writer (#4839).++  * LaTeX writer/template: be sensitive to `filecolor` variable (#4822).+    `linkcolor` only affects internal links, and `urlcolor` only+    affects linked URLs.  For external links, the option to use is+    `filecolor`.++  * ConTeXt writer: output raw `tex` blocks as well as `context` (#969).++  * RST writer:++    + Use `.. raw:: latex` for `tex` content.+    + Use `.. container` for generic Divs, instead of raw HTML.+    + Render Divs with admonition classes as admonitions (#4833).+      Also omit Div with class `admonition-title`. These are generated+      by the RST reader and should be omitted on round-trip.++  * Text.Pandoc.PDF: fix message printed when rsvg-convert is not available+    (#4855, Antonio Terceiro).++  * HTML5 template: add the `title-block-header` identifier to the+    `header` element, to make it easier to style precisely (#4767,+    J. B. Rainsberger).++  * OpenDocument template: Remove unnecessary indenting of TOC title (#4798,+    José de Mattos Neto).++  * latex template: Add support for $toc-title$ to LaTeX (and PDF)+    (#4853, Wandmalfarbe).++  * TEI template: improve `publicationStmt`. Add support for+    `publisher`, `address`, `pubPlace`, and `date` variables.++  * beamer template: Support "toc-title" (#4835, Cyril Roelandt).++  * Text.Pandoc.Extensions: Fix haddock on `Ext_footnotes` (Chris Martin).++  * Lua: cleanup Lua utils, remove unused functions (Albert Krewinkel).++  * MANUAL.txt:++    + Clarify that `--biblatex/--natbib` don't work directly for PDF+      (#4904).+    + Document `epub:type` attribute (Mauro Bieg, #4901)+    + Clarify when `--resource-path` has an effect.+    + More detail on customization in syntax highlighting section.+    + Document encoding issue with `--listings` (#4871, Damien Clochard).+    + Remove docs on removed `--katex-stylesheet` (Mauro Bieg, #4862).+    + Use https for context wiki links (#4910).++  * CONTRIBUTING.md:++    + Link to lua-filters repository (#4874).+    + Fix mistake in REPL instructions for stack. (#4849, Brian Leung).++  * lua-filters.md: add links to filters, and to lua-filters repository+    (#4874).++  * INSTALL.md:++    + Indicate that cabal >= 2.0 is needed.+    + Added chocolatey installation method (#4844, Miodrag Milić).++  * Travis: exclude round-trip tests, except for nightly test which can fail.++  * Use latest texmath, pandoc-citeproc.++  * Use a patched version of foundation until+    https://github.com/haskell-foundation/foundation/pull/503+    is fixed.++  * Clean up appveyor build and Windows package creation.+    We now use 64-bit stack and ghc 8.4.3, lts-12 for the 64-bit build. The+    WiX-based msi is now 64-bit for 64-bit builds (fixing #4795).++  * Remove obsolete RELEASE-CHECKLIST.md.++  * Added additional compiler warnings in Makefile and CI builds.++## pandoc 2.2.3.2 (2018-08-07)++  * Markdown reader: Properly handle boolean values in YAML metadata (#4819).+    This fixes a regression in 2.2.3, which cause boolean values to+    be parsed as MetaInlines instead of MetaBool.++    We here record another undocumented (but desirable) change in 2.2.3:+    numerical metadata fields are now parsed as MetaInlines rather than+    MetaString.++## pandoc 2.2.3.1 (2018-08-06)++  * Markdown reader: Fix parsing of embedded mappings in YAML metadata+    (#4817).  This fixes a regression in 2.2.3 which caused embedded+    mappings (e.g. mappings in sequences) not to work in YAML metadata.++## pandoc 2.2.3 (2018-08-05)++  * RST reader: improve parsing of inline interpreted text roles (#4811).++    + Use a Span with class "title-reference" for the default+      title-reference role.+    + Use `B.text` to split up contents into `Space`s, `SoftBreak`s,+      and `Str`s for `title-reference`.+    + Use Code with class "interpreted-text" instead of Span and Str for+      unknown roles.  (The RST writer has also been modified to round-trip+      this properly.)+    + Disallow blank lines in interpreted text.+    + Backslash-escape now works in interpreted text.+    + Backticks followed by alphanumerics no longer end interpreted text.+    + Remove support for nested inlines (Francesco Occhipinti).+      RST does not allow nested emphasis, links, or other inline+      constructs.  This fixes several bugs (#4581, #4561, #4792).++  * Org reader: fix parsers relying on `parseFromString` (#4784, Albert+    Krewinkel).  Emphasis was not parsed when it followed directly after+    some block types (e.g., lists).++  * Markdown reader: Allow unquoted numbers and booleans as YAML mapping+    keys.  Previously in 2.2.2 you could not do+    ```+    ---+    0: bar+    ...+    ```+    but only+    ```+    ---+    '0': bar+    ...+    ```+    With this change, both forms work.++  * DocBook reader: metadata handling improvements.+    Now we properly parse title and subtitle elements that are direct+    children of book and article (as well as children of bookinfo,+    articleinfo, or info).  We also now use the `subtitle` metadata+    field for subtitles, rather than tacking the subtitle on to the+    title.++  * RST writer:++    + Allow images to be directly nested within links (#4810, Francesco+      Occhipinti).+    + Use `titleblock` instead of `title` variable for title block (#4803,+      Francesco Occhipinti).  `titleblock` contains a properly formatted+      title and subtitle (using top-level headers).  `title` and+      `subtitle` variables are still available and just contain the+      title and subtitle text.  Note that this change will require an+      update to custom rst templates.+    + Render Code with class "interpreted-text" as interpreted text role.++  * MediaWiki writer: Avoid extra blank line in tables with empty cells+    (#4794).  Note that the old output is semantically identical, but the+    new output looks better.++  * Lua Utils module: add function `blocks_to_inlines` (#4799, Albert+    Krewinkel).  Exposes a function converting which flattenes a list of+    blocks into a list of inlines. An example use case would be the+    conversion of Note elements into other inlines.++  * RST template:  use `titleblock` instead of `title`.  Users of+    custom RST templates will want to update this.++  * LaTeX template: Moved some beamer code in default.latex template.+    This change allows beamer themes to change the template and font (as+    Metropolis does) (#4450).++  * Better error message on `-t pdf -o out.pdf` (#1155, Mauro Bieg).++  * Added test case for #4669 to repository.++  * INSTALL.md: Fix broken link for cabal-install (#4806, ChanHoHo).++  * MANUAL.txt:++    + Add beamer info for slide backgrounds (#4802, John Muccigrosso).+    + Clarify when `csquotes` is used in LaTeX writer (#4514).+    + Add `commonmark` to list of output formats where `raw_tex` has an+      effect (see #4527).+++## pandoc 2.2.2.1 (2018-07-19)++  * Fix regression finding templates in user data directory (#4777).+    Under version 2.2.1 and prior pandoc found latex templates in the+    templates directory under the data directory, but this broke in 2.2.2.++  * Fix for bug in parsing `\input` in `rawLaTeXBlock` and+    `rawLaTeXInline` (#4781). (This primarily affects the markdown+    reader, and other readers that accept raw tex.)+    Starting in 2.2.2, everything after an `\input` (or `\include`)+    in a markdown file would be parsed as raw LaTeX.++  * MANUAL:++    + Clarify `gfm` vs `markdown_github` (#4783, Mauro Bieg).+    * Use `keywords` instead of `tags` in YAML metadata example (#4779).+      Unlike `tags`, `keywords` is used in some of the writers+      and default templates.++  * Add missing `rollingLinks` option to revealjs template (#4778,+    Igor Khorlo).++## pandoc 2.2.2 (2018-07-16)++  * Use HsYAML instead of yaml for translations and YAML metadata (#4747).+    yaml wraps a C library; HsYAML is pure Haskell.  Advances #4535.++    Note: HsYAML implements YAML 1.2, in which the valid true+    values are `true`, `True`, `TRUE`.  This means a change in+    the semantics of YAML metadata that could affect users:+    `y`, `yes`, and `on` no longer count as true values.++  * Fix regression: make `--pdf-engine` work with full paths (#4681, Mauro+    Bieg).++  * CommonMark reader: Handle `ascii_identifiers` extension (#4742,+    Anders Waldenborg).  Non-ascii characters were not stripped from+    identifiers even if the `ascii_identifiers` extension was+    enabled (which is is by default for gfm).++  * TikiWiki reader: Improve list parsing (#4722, Mauro Bieg).+    Remove trailing Space from list items.  Parse lists that have no space+    after marker.++  * LaTeX reader:++    + Treat `lilypond` as a verbatim environment (#4725).+    + Parse figure label into Image id (#4700, Mauro Bieg).+    + Beamer: Allow "noframenumbering" option (#4696, Raymond Ehlers).+    + Allow spaces around `\graphicspath` arguments (#4698).+    + Handle includes without surrounding blanklines (#4553).+      In addition, `\input` can now be used in an inline context,+      e.g. to provide part of a paragraph, as it can in LaTeX.+    + In `rawLaTeXBlock`, handle macros that resolve to a+      `\begin` or `\end` (#4667).+    + In `rawLaTeXBlock`, don't expand macros in macro definitions (#4653).+      Note that this only affected LaTeX in markdown.+    + Tighten up reading of beamer overlay specifications (#4669).+      Ideally we'd turn these on only when reading beamer, but currently+      beamer is not distinguished from latex as an input format.+      This commit also activates parsing of overlay specifications+      after commands in general (e.g. `\item`), since they can occur+      in many contexts in beamer.+    + Parse more siunitx unit commands (#4296, #4773).+    + Be more forgiving in key/value option parsing (#4761).++  * Markdown reader:++    + Allow empty code spans, e.g. `` ` ` ``.+    + Emojis are now wrapped in Spans with class `emoji` and+      attribute `data-emoji` (Anders Waldenborg, #4743).+      This allows the writer to handle them in a special way+      (e.g. using a special font, or just rendering the+      emoji name).++  * Muse reader (Alexander Krotov, except where indicated):++    + Get rid of non-exhaustive pattern match warning (Mauro Bieg).+    + Add support for floating images.+    + Add support for images with specified width.+    + Parse image URLs without "guard" and "takeExtension".+    + Split link and image parsing into separate functions.+    + Parse links starting with "URL:" explicitly instead of trying to strip+      "URL:" prefix after parsing.++  * Texinfo writer: Use `@sup` and `@sub` instead of custom macros (#4728,+    Alexander Krotov).++  * Markdown writer: Preserve `implicit_figures` with attributes, even if+    `implicit_attributes` is not set, by rendering in raw HTML (#4677).++  * Markdown and commonmark/github writers now respect the `emoji`+    extension.  So, `-f markdown+emoji -t markdown+emoji` now leaves+    `:smile:` as `:smile:` rather than converting it to a smile+    character.++  * Docx writer: Be sensitive to `toc` in YAML metadata (#4645).++  * ODT/OpenDocument writer: Make internal links work (#4358).+    This adds proper bookmarks to the headers with non-null IDs.++  * EPUB writer: Properly escape pagetitle.  Previously we weren't+    escaping `&` and other XML characters in the pagetitle, so a title+    containing a `&` would be invalid.++  * AsciiDoc Writer: Eescape square brackets at start of line (#4545,+    Mauro Bieg).++  * RST writer:++    + Don't treat 'example' as a syntax name (#4748).+      This fixes conversions from org with example blocks.+    + Support `--number-sections` via the `section-numbering`+      directive in standalone output.++  * reveal.js writer and template: reuse mathjax URL+    provided by the argument to `--mathjax` or the normal pandoc default,+    rather than a hard-coded one in the template (#4701).++  * LaTeX writer:++    + Properly handle footnotes in table captions (#4683).+      Refactored code from figure captions to use in both places.+    + In beamer output, fix single digit column percentage (#4690, Mauro+      Bieg).++  * FB2 writer (Alexander Krotov):++    + Convert Plain to Para in annotation (#2424).+    + Fix order of items in title-info (#2424).++  * Custom writer: fix error message on script failure (Albert Krewinkel).+    Error messages produced by Lua were not displayed by Pandoc.++  * Text.Pandoc.Emoji now exports `emojiToInline`, which returns a Span+    inline containing the emoji character and some attributes with metadata+    (class `emoji`, attribute `data-emoji` with emoji name).  (API change,+    Anders Waldenborg, #4743).++  * Text.Pandoc.PDF:++    + Revert fix for #4484 (only compress images on last run, #4755).+      This will mean some increase in the time it takes to+      produce an image-heavy PDF with xelatex, but it will+      make tables of contents correct, which is more important.+    + Fix logic error in `runTeXProgram`.  We were running the tex program+      one more time than requested.  This should speed up PDF production.++  * Allow `--template` to take a URL as argument.++  * Text.Pandoc.Highlighting: Add missing re-export of `breezeDark`+    highlighting style (#4687, Adrian Sieber, API change).++  * Clarify macOS install in INSTALL.md (#4661).  Make the binary package+    installer the recommended method, and note that on some older versions of+    macOS, homebrew installs from source and takes a lot of disk space+    (#4664, Ian).++  * MANUAL:++    + Clarify EPUB linked media (#4756, Mauro Bieg)+    + Update manual for "true" YAML values.  Now that we're using HsYAML and+      YAML 1.2, the valid true values are `true`, `True`, `TRUE`.  NOTE!+      `y`, `yes`, `on` no longer count as true values.+    + Document `-F` as alias for `--filter` (thanks to Gandalf Saxe).+    + Update manual on how math is rendered in LaTeX.+    + Add proxy description (#4131, Mauro Bieg).+    + Clarify that `--toc` requires `--standalone` (#4703).+    + Update citation styles link (#4699, wiefling).++  * In API docs, clarify how `Ext_east_asian_line_breaks` extension works+    (kaizshang91).  Note that it will not take effect when readers/writers+    are called as libraries (#4674).++  * Improved translations/fr (#4766, lux-lth).++  * Removed inadvertently added `.orig` files from repository (#4648).++  * Remove `network-uri` flag and use 'Network.Socket'.+    This removes a compiler warning.  There is no need for the old+    `network-uri` flag, since network 2.6 was released in 2014.++  * Add stack.lts10.yaml, stack.lts11.yaml.  use lts-12 in stack.yaml.++  * Bump upper bounds for dependent packages.++  * Exclude foundation 0.0.21 for ghc 7.10.  Otherwise cabal gets+    confused because of the way ghc 7.10 is excluded in foundation's+    cabal file.  This can be removed when haskell-foundation/foundation#500+    is fixed.++  * Require cabal-version >= 2.0.  This is needed for haddock-library.+++++## pandoc 2.2.1 (2018-05-10)++  * Restored and undeprecated gladtex for HTML math (#4607).++    + Added `GladTeX` constructor to `Text.Pandoc.Options.HTMLMathMethod`+      [API change, reverts removal in v2.2]+    + Restored and undeprecated `--gladtex` option, removed in v2.2.++  * LaTeX reader:  Handle `$` in `/text{..}` inside math (#4576).++  * Org reader: Fix image filename recognition (Albert Krewinkel).+    Use a function from the filepath library to check whether a string is a+    valid file name.  The custom validity checker that was used before gave+    wrong results (e.g. for absolute file paths on Windows,+    kawabata/ox-pandoc#52).++  * FB2 reader: Replace some errors with warnings (Alexander Krotov).++  * HTML writer:++    + Strip links from headers when creating TOC (#4340).+      Otherwise the TOC entries will not link to the sections.+    + Fix regression with tex math environments in HTML + MathJax (#4639).++  * Muse writer (Alexander Krotov): Add support for left-align and+    right-align classes (#4542).++  * Docx writer: Support underline (#4633).++  * Text.Pandoc.Parsing: Lookahead for non-whitespace after+    `singleQuoteStart` and `doubleQuoteStart` (#4637).++  * `test-pandoc-utils.lua`:  more robust testing on both windows+    and \*nix. Previously the pipe tests were only run if+    `\bin/false` and `/bin/sed` were present, which they aren't+    in default MacOS and Windows systems.  Fixed by using `tr`+    and `false`, which should always be in the path on a \*nix+    system, and `find` and `echo` for Windows.++  * Text.Pandoc.Shared: add `uriPathToPath`.+    This adjusts the path from a file: URI in a way that is sensitive+    to Windows/Linux differences.  Thus, on Windows,+    `/c:/foo` gets interpreted as `c:/foo`, but on Linux,+    `/c:/foo` gets interpreted as `/c:/foo`.  See #4613.++  * Use `uriPathToPath` with file: URIs (#4613).++  * Revert piping HTML to pdf-engine (Mauro Bieg, #4413).  Use a temp+    file as before.++  * Text.Pandoc.Class: Catch IO errors when writing media files+    and issue a warning, rather than an error (Francesco Occhipinti, #4559).++  * Don't lowercase custom writer filename (Alexander Krotov, #4610).++  * MANUAL (Mauro Bieg):++    + Clarify truthiness in template variables (#2281).+    + Clarify pipe table width calculation (#4520).++  * ConTeXt template: New Greek fallback typeface (Pablo Rodríguez, #4405).+    CMU Serif gives better typographic results than the previous+    Greek fallback DejaVu Serif.++  * Make HTML template polyglot (#4606, OvidiusCicero), by making+    `<link rel="stylesheet" href="$css$">` self-closing.++  * Use texmath 0.11, allowing better translation of non-ASCII+    characters in math (#4642).+++## pandoc 2.2 (2018-04-27)++  * New input format: `fb2` (FictionBook2) (Alexander Krotov).++  * Make `--ascii` work for all XML formats (ICML, OPML, JATS,...),+    and for `ms` and `man`.++  * Remove deprecated `--latexmathml`, `--gladtex`, `--mimetex`, `--jsmath`, `-m`,+    `--asciimathml` options.++  * New module Text.Pandoc.Readers.FB2, exporting readFB2 (Alexander+    Krotov, API change).++  * Markdown reader:++    + Allow empty key-value attributes, like `title=""` (#2944).+    + Handle table w/o following blank line in fenced div (#4560).+    + Remove "fallback" for `doubleQuote` parser.  Previously the+      parser tried to be efficient -- if no end double quote was found,+      it would just return the contents.  But this could backfire in a+      case `**this should "be bold**`, since the fallback would return+      the content `"be bold**` and the closing boldface delimiter+      would never be encountered.+    + Improve computation of the relative width of the last column in a+      multiline table, so we can round-trip tables without constantly+      shrinking the last column.++  * EPUB reader:++    + Fix images with space in file path (#4344).++  * LaTeX reader:++    + Properly resolve section numbers with `\ref` and chapters (#4529).+    + Parse sloppypar environment (#4517, Marc Schreiber).+    + Improve handling of raw LaTeX (for markdown etc.) (#4589, #4594).+      Previously there were some bugs in how macros were handled.+    + Support `\MakeUppercase`, `\MakeLowercase`, `\uppercase`,+      `\lowercase`, and also `\MakeTextUppercase` and+      `\MakeTextLowercase` from textcase (#4959).++  * Textile reader:++    + Fixed tables with no body rows (#4513).+      Previously these raised an exception.++  * Mediawiki reader:++    + Improve table parsing (#4508).  This fixes detection of table+      attributes and also handles `!` characters in cells.++  * DocBook reader:++    + Properly handle title in `section` element (#4526).+      Previously we just got `section_title` for `section` (though `sect1`,+      `sect2`, etc. were handled properly).+    + Read tex math as output by asciidoctor (#4569, Joe Hermaszewski).++  * Docx reader:++    + Combine adjacent CodeBlocks with the same attributes into+      a single CodeBlock.  This prevents a multiline codeblock in+      Word from being read as different paragraphs.++  * RST reader:++    + Allow < 3 spaces indent under directives (#4579).+    + Fix anonymous redirects with backticks (#4598).++  * Muse reader (Alexander Krotov):++    + Add support for Text::Amuse multiline headings.+    + Add `<math>` tag support.+    + Add support for `<biblio>` and `<play>` tags.+    + Allow links to have empty descriptions.+    + Require block `<literal>` tags to be on separate lines.+    + Allow `-` in anchors.+    + Allow verse to be indented.+    + Allow nested footnotes.+    + Internal improvements.++  * Muse writer (Alexander Krotov):++    + Escape `>` only at the beginning of a line.+    + Escape `]` in image title.+    + Escape `]` brackets in URLs as `%5D`.+    + Only escape brackets when necessary.+    + Escape ordered list markers.+    + Do not escape list markers unless preceded by space.+    + Escape strings starting with space.+    + Escape semicolons and markers after line break.+    + Escape `;` to avoid accidental comments.+    + Don't break headers, line blocks and tables with line breaks.+    + Correctly output empty headings.+    + Escape horizontal rule only if at the beginning of the line.+    + Escape definition list terms starting with list markers.+    + Place header IDs before header.+    + Improve span writing.+    + Do not join Spans in normalization.+    + Don't align ordered list items.+    + Remove key-value pairs from attributes before normalization.+    + Enable `--wrap=preserve` for all tests by default.+    + Reduced `<verbatim>` tags in output.+    + Internal changes.++  * RST writer:++    + Use more consistent indentation (#4563).  Previously we+      used an odd mix of 3- and 4-space indentation.  Now we use 3-space+      indentation, except for ordered lists, where indentation must+      depend on the width of the list marker.+    + Flatten nested inlines (#4368, Francesco Occhipinti).+      Nested inlines are not valid RST syntax, so we flatten them following+      some readability criteria discussed in #4368.++  * EPUB writer:++    + Ensure that `pagetitle` is always set, even when structured titles+      are used.  This prevents spurious warnings about empty title+      elements (#4486).++  * FB2 writer (Alexander Krotov):++    + Output links inline instead of producing notes.  Previously all links+      were turned into footnotes with unclickable URLs inside.+    + Allow emphasis and notes in titles.+    + Don't intersperse paragraph with empty lines.+    + Convert metadata value `abstract` to book annotation.+    + Use `<empty-line />` for `HorizontalRule` rather than `LineBreak`.+      FB2 does not have a way to represent line breaks inside paragraphs;+      previously we used `<empty-line />` elements, but these are not allowed+      inside paragraphs.++  * Powerpoint writer (Jesse Rosenthal):++    + Handle Quoted Inlines (#4532).+    + Simplify code with `ParseXml`.+    + Allow fallback options when looking for placeholder type.+    + Check reference-doc for all layouts.+    + Simplify speaker notes logic.+    + Change notes state to a simpler per-slide value.+    + Remove `Maybe` from `SpeakerNotes` in `Slide`. `mempty`+      means no speaker notes.+    + Add tests for improved speaker notes.+    + Handle speaker notes earlier in the conversion process.+    + Keep notes with related blocks (#4477).  Some blocks automatically+      split slides (imgs, tables, `column` divs). We assume that any+      speaker notes immediately following these are connected to these+      elements, and keep them with the related blocks, splitting after them.+    + Remove `docProps/thumbnail.jpeg` in data dir (Jesse Rosenthal, #4588).+      It contained a nonfree ICC color calibration profile and is not needed+      for production of a powerpoint document.++  * Markdown writer:++    + Include a blank line at the end of the row in a single-row multiline+      table, to prevent it from being interpreted as a simple table (#4578).++  * CommonMark writer:++    + Correctly ignore LaTeX raw blocks when `raw_tex` is not+      enabled (#4527, quasicomputational).++  * EPUB writer:++    + Add `epub:type="footnotes"` to notes section in EPUB3 (#4489).++  * LaTeX writer:++    + In beamer, don't use format specifier for default ordered lists+      (#4556).  This gives better results for styles that put ordered list+      markers in boxes or circles.+    + Update `\lstinline` delimiters (#4369, Tim Parenti).++  * Ms writer:++    + Use `\f[R]` rather than `\f[]` to reset font (#4552).+    + Use `\f[BI]` and `\f[CB]` in headers, instead of `\f[I]` and `\f[C]`,+      since the header font is automatically bold (#4552).+    + Use `\f[CB]` rather than `\f[BC]` for monospace bold (#4552).+    + Create pdf anchor for a Div with an identifier (#4515).+    + Escape `/` character in anchor ids (#4515).+    + Improve escaping for anchor ids: we now use _uNNN_ instead of uNNN+      to avoid ambiguity.++  * Man writer:++    + Don't escape U+2019 as `'` (#4550).++  * Text.Pandoc.Options:++    + Removed `JsMath`, `LaTeXMathML`, and `GladTeX` constructors from+    `Text.Pandoc.Options.HTMLMathMethod` [API change].++  * Text.Pandoc.Class:++    + `writeMedia`: unescape URI-escaping in file path.  This avoids+      writing things like `file%20one.png` to the file system.++  * Text.Pandoc.Parsing:++    + Fix `romanNumeral` parser (#4480).  We previously accepted 'DDC'+      as 1100.+    + `uri`: don't treat `*` characters at end as part of URI (#4561).++  * Text.Pandoc.MIME:++    + Use the alias `application/eps` for EPS (#2067).+      This will ensure that we retain the eps extension after reading the+      image into a mediabag and writing it again.++  * Text.Pandoc.PDF:++    + Use `withTempDir` in `html2pdf`.+    + With `xelatex`, don't compress images til the last run (#4484).+      This saves time for image-heavy documents.+    + Don't try to convert EPS files (#2067).  `pdflatex` converts them+      itself, and JuicyPixels can't do it.+    + For `pdflatex`, use a temp directory in the working directory.+      Otherwise we can have problems with the EPS conversion pdflatex+      tries to do, which can't operate on a file above the working+      directory without `--shell-escape`.++  * Changes to tests to accommodate changes in pandoc-types.+    In <https://github.com/jgm/pandoc-types/pull/36> we changed+    the table builder to pad cells.  This commit changes tests+    (and two readers) to accord with this behavior.++  * Set default extensions for `beamer` same as `latex`.++  * LaTeX template:++    + Add `beameroption` variable (#4359, Étienne Bersac).+    + Use `pgfpages` package; this is needed for notes on second+      screen in beamer (Étienne Bersac).+    + Add `background-image` variable (#4601, John Muccigrosso).++  * reveal.js template: Add `background-image` variable (#4600,+    John Muccigrosso).++  * ms template: Fix date.  Previously `.ND` was used, but this only+    works if you have a title page, which we don't.  Thanks to @teoric.++  * Removed pragmas for unused extensions (#4506, Anabra).++  * Fix bash completion for `--print-default-data-file` (#4549).+    Previously this looked in the filesystem, even if pandoc+    was compiled with `embed_data_files` (and sometimes it looked+    in a nonexistent build directory).  Now the bash completion+    script just includes a hard-coded list of data file names.++  * MANUAL:++    + Clarify template vs metadata variables (#4501, Mauro Bieg).+    + Fix raw content example (#4479, Mauro Bieg).+    + Specify that you use html for raw output in epub.+    + Add examples for raw docx blocks (#4472, Tristan Stenner).+      The documentation states that the target format name should match+      the output format, which isn't the case for `docx`/`openxml` and+      some others.+    + Don't say that `empty_paragraphs` affects markdown output (#4540).+    + Consolidate input/output format documentation (#4577, Mauro Bieg).++  * New README template. Take in/out formats from manual.++  * Fix example in lua-filters docs (#4459, HeirOfNorton).++  * Use the `-threaded` GHC flag when building benchmarks (#4587,+    Francesco Occhipinti).++  * Bump temporary upper bound to 1.4.++  * Use pandoc-citeproc 0.14.3.1.++  * Use texmath-0.10.1.2 (fixes escapes in math in ms, #4597).++  * Removed old lib directory.  This was used for something long ago,+    but plays no role now.++  * Removed unneeded data file `LaTeXMathML.js`.++  * Create 64- and 32-bit versions of Windows binary packages.++## pandoc 2.1.3 (2018-03-18)++  * Docx reader (Jesse Rosenthal):++    + Add tests for nested smart tags.+    + Parse nested smart tags.+    + Make unwrapSDT into a general `unwrap` function that can unwrap both+      nested SDT tags and smartTags. This makes the SmartTags constructor in+      the Docx type unnecessary, so we remove it (#4446).+    + Remove unused `docxWarnings` (Alexander Krotov).++  * RST reader: Allow unicode bullet characters (#4454).++  * Haddock reader:  Better table handling, using haddock-library's+    new table support, if compiled against a version that+    includes it.  Note that tables with col/rowspans will not+    translate well into Pandoc.++  * Muse reader (Alexander Krotov):++    + Various internal improvements.+    + Require closing tag to have the same indentation as opening.+    + Do not reparse blocks inside unclosed block tag (#4425).+    + Parse `<class>` tag (supported by Emacs Muse).+    + Do not produce empty Str element for unindented verse lines.++  * LaTeX reader:++    + Add support to parse unit string of `\SI` command (closes #4296,+      Marc Schreiber).++  * Haddock writer:  In the writer, we now render tables always as+    grid tables, since Haddock supports these.++  * DokuWiki writer: rewrite backSlashLineBreaks (#4445, Mauro Bieg).++  * Docx writer: Fixed formatting of `DefaultStyle` ordered lists in+    docx writer.  We want decimal for the top level, not lower roman.++  * RST writer:++    + Strip whitespace at beginning and ending of inline containers+      (#4327, Francesco Occhipinti).+    + Filter out empty inline containers (#4434).  There is nothing in+      RST that corresponds to e.g. `Emph []`, so we just ignore elements+      like this (Francesco Occhipinti).++  * Muse writer (Alexander Krotov):++    + Support spans with anchors.+    + Replace smallcaps with emphasis before normalization.+    + Output smallcaps as emphasis.+    + Expand Cite before list normalization.+    + Write empty inline lists as `<verbatim></verbatim>`.+    + Remove empty Str from the beginning of inline lists during normalization.+    + Escape "-" to avoid creating bullet lists.+    + Fix math expansion for more than one expression per paragraph.+    + Expand math before inline list normalization.++  * Dokuwiki writer: fix LineBreaks in Tables (#4313, Mauro Bieg).++  * Ms writer:++    + Asciify pdf anchors, since unicode anchors don't work (#4436).+      Internal links should be converted automatically, so this shouldn't+      affect users directly.+    + Don't escape hyphens as `\-`; that's for a minus sign (#4467).++  * Beamer writer: put hyperlink after `\begin{frame}` and not in the title+    (#4307).  If it's in the title, then we get a titlebar on slides with+    the `plain` attribute, when the id is non-null.  This fixes a regression+    in 2.0.++  * EPUB writer: Remove notes from TOC in nav.xhtml (#4453, Mauro Bieg).++  * JATS writer: Remove extraneous, significant whitespace (#4335,+    Nokome Bentley).++  * html2pdf: inject base tag with current working directory (#4413, Mauro+    Bieg).  This helps ensure that linked resources are included.++  * Add Semigroup instances for everything for which we defined a+    Monoid instance previously (API change):++    + Text.Pandoc.Class.FileTree.+    + Text.Pandoc.Translations.Translations.+    + Text.Pandoc.Extensions.Extensions.+    + Text.Pandoc.Readers.Odt.StyleReader.Styles.+    + Text.Pandoc.Pretty.Doc.+    + Text.Pandoc.MediaBag.MediaBag.++  * Add custom Prelude to give clean code for Monoid and Semigroup+    that works with ghc 7.10-8.4.  The custom Prelude (`prelude/Prelude`)+    is used for ghc versions < 8.4.  `NoImplicitPrelude` is used+    in all source files, and Prelude is explicitly imported+    (this is necessary for ghci to work properly with the custom prelude).++  * Text.Pandoc.Writers.Shared (Francesco Occhipinti):++    + Export `stripLeadingTrailingSpace`.+    + Don't wrap lines in grid tables when `--wrap=none` (#4320).+    + `gridTable`: Don't wrap lines in tables when `--wrap=none`.  Instead,+      expand cells, even if it results in cells that don't respect relative+      widths or surpass page column width.  This change affects RST,+      Markdown, and Haddock writers.++  * Raise error if someone tries to print docx, odt, etc. template (#4441).++  * LaTeX template: Provide `bidi` package's option using+    `\PassOptionsToPackage`  (#4357, Václav Haisman).  This avoid a+    clash when   `polyglossia` loads it first and then it is loaded again+    for XeLaTeX.++  * ConTeXt template: Added `pdfa` variable to generate PDF/A (#4294, Henri+    Menke).  Instructions on how to install the ICC profiles on ConTeXt+    standalone can be found in the wiki:+    <http://wiki.contextgarden.net/PDFX#ICC_profiles>.+    If the ICC profiles are not available the log will contain error+    messages.++  * Use latest pandoc-types, skylighting++  * Use latest pandoc-citeproc in binary package.++  * Bump upper bound for time, criterion, haddock-library, exceptions,+    http-types, aeson, haddock-library.++  * Bump upper bound tasty-quickcheck 0.10 (#4429, Felix Yan).++  * pandoc.cabal:  fix up other-extensions and language fields.+    Language is now consistently `Haskell2010`, and other-extensions+    is consistently `NoImplicitPrelude`. Everything else to be specified+    in the module header as needed.++  * Removed `old-locale` flag and Text.Pandoc.Compat.Time.+    This is no longer necessary since we no longer support ghc 7.8.++  * Make `weigh-pandoc` into a benchmark program.+    Remove `weigh-pandoc` flag.  `weigh-pandoc` is now built (and run)+    automatically when you build (and run) benchmarks.++  * MANUAL: add instructions for background images reveal.js (#4325, John+    Muccigrosso).++  * appveyor: use VS 2013 environment instead of VS 2015 for Windows builds.++## pandoc 2.1.2 (2018-03-02)++  * Markdown reader:++    + Fix parsing bug with nested fenced divs (#4281).  Previously we allowed+      "nonindent spaces" before the opening and closing `:::`, but this+      interfered with list parsing, so now we require the fences to be flush with+      the margin of the containing block.++  * Commonmark reader:++    + `raw_html` is now on by default.  It can be disabled explicitly+      using `-f commonmark-raw_html`.++  * Org reader (Albert Krewinkel):++    + Move citation tests to separate module.+    + Allow changing emphasis syntax (#4378).  The characters allowed before+      and after emphasis can be configured via `#+pandoc-emphasis-pre` and+      `#+pandoc-emphasis-post`, respectively. This allows to change which+      strings are recognized as emphasized text on a per-document or even+      per-paragraph basis.  Example:++          #+pandoc-emphasis-pre: "-\t ('\"{"+          #+pandoc-emphasis-post: "-\t\n .,:!?;'\")}["++  * LaTeX reader:++    + Fixed comments inside citations (#4374).+    + Fix regression in package options including underscore (#4424).+    + Make `--trace` work.+    + Fixed parsing of `tabular*` environment (#4279).++  * RST reader:++    + Fix regression in parsing of headers with trailing space (#4280).++  * Muse reader (Alexander Krotov):++    + Enable `<literal>` tags even if amuse extension is enabled.+      Amusewiki disables <literal> tags for security reasons.+      If user wants similar behavior in pandoc, RawBlocks and RawInlines+      can be removed or replaced with filters.+    + Remove space prefix from `<literal>` tag contents.+    + Do not consume whitespace while looking for closing end tag.+    + Convert alphabetical list markers to decimal in round-trip test.+      Alphabetical lists are an addition of Text::Amuse.+      They are not present in Emacs Muse and can be ambiguous+      when list starts with "i.", "c." etc.+    + Allow `<quote>` and other tags to be indented.+    + Allow single colon in definition list term.+    + Fix parsing of verse in lists.+    + Improved parsing efficiency.  Avoid `parseFromString`.+      Lists are parsed in linear instead of exponential time now.+    + Replace ParserState with MuseState.+    + Prioritize lists with roman numerals over alphabetical lists.+      This is to make sure "i." starts a roman numbered list,+      instead of a list with letter "i" (followed by "j", "k", ...").+    + Fix directive parsing.+    + Parse definition lists with multiple descriptions.+    + Parse next list item before parsing more item contents.+    + Fixed a bug: headers did not terminate lists.+    + Move indentation parsing from `definitionListItem` to `definitionList`.+    + Paragraph indentation does not indicate nested quote.+      Muse allows indentation to indicate quotation or alignment,+      but only on the top level, not within a <quote> or list.+    + Require that block tags are on separate lines.+      Text::Amuse already explicitly requires it anyway.+    + Fix matching of closing inline tags.+    + Various internal changes.+    + Fix parsing of nested definition lists.+    + Require only one space for nested definition list indentation.+    + Do not remove trailing whitespace from `<code>`.+    + Fix parsing of trailing whitespace.  Newline after whitespace now+      results in softbreak instead of space.++  * Docx reader (Jesse Rosenthal, except where noted):++    + Handle nested sdt tags (#4415).+    + Don't look up dependant run styles if `+styles` is enabled.+    + Move pandoc inline styling inside custom-style span.+    + Read custom styles (#1843).  This will read all paragraph and+      character classes as divs and spans, respectively. Dependent styles+      will still be resolved, but will be wrapped with appropriate style+      tags. It is controlled by the `+styles` extension (`-f docx+styles`).+      This can be used in conjunction with the `custom-style` feature in the+      docx writer for a pandoc-docx editing workflow. Users can convert from+      an input docx, reading the custom-styles, and then use that same input+      docx file as a reference-doc for producing an output docx file. Styles+      will be maintained across the conversion, even if pandoc doesn't+      understand them.+    + Small change to Fields hyperlink parser.  Previously, unquoted string+      required a space at the end of the line (and consumed it). Now we+      either take a space (and don't consume it), or end of input.+    + Pick table width from the longest row or header (Francesco Occhipinti,+      #4360).++  * Muse writer (Alexander Krotov):++    + Change verse markup: `> ` instead of `<verse>` tag.+    + Remove empty strings during inline normalization.+    + Don't indent nested definition lists.+    + Use unicode quotes for quoted text.+    + Write image width specified in percent in Text::Amuse mode.+    + Don't wrap displayMath into `<verse>`.+    + Escape nonbreaking space (`~~`).+    + Join code with different attributes during normalization.+    + Indent lists inside Div.+    + Support definitions with multiple descriptions.++  * Powerpoint writer (Jesse Rosenthal):++    + Use table styles This will use the default table style in the+      reference-doc file. As a result they will be easier when using+      in a template, and match the color scheme.+    + Remove empty slides.  Because of the way that slides were split, these+      could be accidentally produced by comments after images.  When animations+      are added, there will be a way to add an empty slide with either+      incremental lists or pauses.+    + Implement syntax highlighting.  Note that background colors can't+      be implemented in PowerPoint, so highlighting styles that require+      these will be incomplete.+    + New test framework for pptx.  We now compare the output of the+      Powerpoint writer with files that we know to (a) not be corrupt,+      and (b) to show the desired output behavior (details below).+    + Add `notesMaster` to `presentation.xml` if necessary.+    + Ignore links and (end)notes in speaker notes.+    + Output speaker notes.+    + Read speaker note templates conditionally.  If there are speaker+      notes in the presentation, we read in the notesMasters templates+      from the reference pptx file.+    + Fix deletion track changes (#4303, Jesse Rosenthal).++  * Markdown writer: properly escape @ to avoid capture as citation+    (#4366).++  * LaTeX writer:++    + Put hypertarget inside figure environment (#4388).+      This works around a problem with the endfloat package and+      makes pandoc's output compatible with it.+    + Fix image height with percentage (#4389).  This previously caused+      the image to be resized to a percentage of textwidth, rather than+      textheight.++  * ConTeXt writer (Henri Menke):++    + New section syntax and support `--section-divs` (#2609).+      `\section[my-header]{My Header}` ->+      `\section[title={My Header},reference={my-header}]`.+      The ConTeXt writer now supports the `--section-divs` option to+      write sections in the fenced style, with `\startsection` and+      `\stopsection`.+    + xtables: correct wrong usage of caption (Henri Menke).++  * Docx writer:++    + Fix image resizing with multiple images (#3930, Andrew Pritchard).+    + Use new golden framework (Jesse Rosenthal).+    + Make more deterministic to facilitate testing (Jesse Rosenthal).+      - `getUniqueId` now calls to the state to get an incremented digit,+        instead of calling to P.uniqueHash.+      - we always start the PRNG in mkNumbering/mkAbstractNum with the same+        seed (1848), so our randoms should be the same each time.+    + Fix ids in comment writing (Jesse Rosenthal).  Comments from+      `--track-changes=all` were producing corrupt docx, because the+      writer was trying to get id from the `(ID,_,_)` field of+      the attributes, and ignoring the "id" entry in the key-value pairs. We+      now check both.++  * Ms writer: Added papersize variable.++  * TEI writer:++    + Use `height` instead of `depth` for images (#4331).+    + Ensure that id prefix is always used.+    + Don't emit `role` attribute; that was a leftover from the+      Docbook writer.+    + Use 'xml:id', not 'id' attribute (#4371).++  * AsciiDoc writer:++    + Do not output implicit heading IDs (#4363, Alexander+      Krotov).  Convert to `asciidoc-auto_identifiers` for old behaviour.++  * RST writer:++    + Remove `blockToRST'` moving its logic into `fixBlocks`+      (Francesco Occhipinti).+    + Insert comment between lists and quotes (#4248, Francesco Occchipinti).++  * RST template: remove definition of 'math' role as raw.+    This used to be needed prior to v 0.8 of docutils, but+    now math support is built-in.++  * Slides: Use divs to set incremental/non-incremental (#4381,+    Jesse Rosenthal).  The old method (list inside blockquote) still+    works, but we are encouraging the use of divs with class+    `incremental` or `nonincremental`.++  * Text.Pandoc.ImageSize:++    + Make image size detection for PDFs more robust (#4322).+    + Determine image size for PDFs (#4322).+    + EMF Image size support (#4375, Andrew Pritchard).++  * Text.Pandoc.Extensions:++    + Add `Ext_styles` (Jesse Rosenthal, API change).  This will be used in+      the docx reader (defaulting to off) to read pargraph and character+      styles not understood by pandoc (as divs and spans, respectively).+    + Made `Ext_raw_html` default for `commonmark` format.++  * Text.Pandoc.Parsing:++    + Export `manyUntil` (Alexander Krotov, API change).+    + Export improved `sepBy1` (Alexander Krotov).+    + Export list marker parsers: `upperRoman`, `lowerRoman`,+      `decimal`, `lowerAlpha`, `upperAlpha` (Alexander Krotov, API change).++  * Tests/Lua: fix tests on windows (Albert Krewinkel).++  * Lua: register script name in global variable (#4393).  The name of the Lua+    script which is executed is made available in the global Lua variable+    `PANDOC_SCRIPT_FILE`, both for Lua filters and custom writers.++  * Tests: Abstract powerpoint tests out to OOXML tests (Jesse Rosenthal).+    There is very little pptx-specific in these tests, so we abstract out+    the basic testing function so it can be used for docx as well. This+    should allow us to catch some errors in the docx writer that slipped+    by the roundtrip testing.++  * Lua filters: store constructors in registry (Albert Krewinkel).  Lua+    functions used to construct AST element values are stored in the Lua+    registry for quicker access. Getting a value from the registry is much+    faster than getting a global value (partly to idiosyncrasies of hslua);+    this change results in a considerable performance boost.++  * Documentation:++    + `doc/org.md` Add draft of Org-mode documentation (Albert Krewinkel).+    + `doc/lua-filters.md`: document global vars set for filters+      (Albert Krewinkel).+    + INSTALL.md: mention Stack version. (#4343, Adam Brandizzi).+    + MANUAL: add documentation on custom styles (Jesse Rosenthal).+    + MANUAL.txt: Document incremental and nonincremental divs (Jesse+      Rosenthal).  Blockquoted lists are still described, but fenced divs are+      presented in preference.+    + MANUAL.txt: document header and footer variables (newmana).+    + MANUAL.txt: self-contained implies standalone (#4304, Daniel Lublin).+    + CONTRIBUTING.md: label was renamed. (#4310, Alexander Brandizzi).++  * Require tagsoup 0.14.3 (#4282), fixing HTML tokenization bug.++  * Use latest texmath.++  * Use latest pandoc-citeproc.++  * Allow exceptions 0.9.++  * Require aeson-pretty 0.8.5 (#4394).++  * Bump blaze-markup, blaze-html lower bounds to 0.8, 0.9 (#4334).++  * Update tagsoup to 0.14.6 (Alexander Krotov, #4282).++  * Removed ghc-prof-options.  As of cabal 1.24, sensible defaults are used.++  * Update default.nix to current nixpkgs-unstable for hslua-0.9.5 (#4348,+    jarlg).++## pandoc 2.1.1 (2018-01-18)++  * Markdown reader:++    + Don't coalesce adjacent raw LaTeX blocks if they are separated by a+      blank line.  See lierdakil/pandoc-crossref#160.+    + Improved `inlinesInBalancedBrackets` (#4272, jgm/pandoc-citeproc#315).+      The change both improves performance and fixes a regression whereby+      normal citations inside inline notes and figure captions were not+      parsed correctly.++  * RST reader:++    + Better handling for headers with an anchor (#4240).  Instead of creating a+      Div containing the header, we put the id directly on the header.+      This way header promotion will work properly.+    + Add aligned environment when needed in math (#4254).  `rst2latex.py`+      uses an `align*` environment for math in `.. math::` blocks, so this+      math may contain line breaks.  If it does, we put the math in an+      `aligned` environment to simulate `rst2latex.py`'s behavior.++  * HTML reader:++    + Fix col width parsing for percentages < 10% (#4262, n3fariox).++  * LaTeX reader:++    + Advance source position at end of stream.+    + Pass through macro defs in `rawLaTeXBlock` even if the `latex_macros`+      extension is set (#4246).  This reverts to earlier behavior and is+      probably safer on the whole, since some macros only modify things in+      included packages, which pandoc's macro expansion can't modify.+    + Fixed pos calculation in tokenizing escaped space.+    + Allow macro definitions inside macros (#4253).  Previously we went into+      an infinite loop with+      ```+      \newcommand{\noop}[1]{#1}+      \noop{\newcommand{\foo}[1]{#1}}+      \foo{hi}+      ```+    + Fix inconsistent column widths (#4238).  This fixes a bug whereby column+      widths for the body were different from widths for the header in some+      tables.++  * Docx reader (Jesse Rosenthal):++    + Parse hyperlinks in `instrText` tags (#3389, #4266).  This was a form of+      hyperlink found in older versions of word. The changes introduced for+      this, though, create a framework for parsing further fields in MS Word+      (see the spec, ECMA-376-1:2016, §17.16.5, for more on these fields).+      We introduce a new module, `Text.Pandoc.Readers.Docx.Fields` which+      contains a simple parsec parser. At the moment, only simple hyperlink+      fields are accepted, but that can be extended in the future.++  * Muse reader (Alexander Krotov):++    + Parse `~~` as non-breaking space in Text::Amuse mode.+    + Refactor list parsing.++  * Powerpoint writer (Jesse Rosenthal):++    + Change reference to `notesSlide` to `endNotesSlide`.+    + Move image sizing into `picProps`.+    + Improve table placement.+    + Make our own `_rels/.rels` file.+    + Import reference-doc images properly.+    + Move `Presentation.hs` out of `PandocMonad`.+    + Refactor into separate modules.  T.P.W.Powerpoint.Presentation+      defines the Presentation datatype and goes Pandoc->Presentation;+      T.P.W.Pandoc.Output goes Presentation->Archive.+      Text.Pandoc.Writers.Powerpoint a thin wrapper around the two modules.+    + Avoid overlapping blocks in column output.+    + Position images correctly in two-column layout.+    + Make content shape retrieval environment-aware.+    + Improve image handling.  We now determine image and caption placement+      by getting the dimensions of the content box in a given layout.+      This allows for images to be correctly sized and positioned in a+      different template.  Note that images without captions and headers are+      no longer full-screened. We can't do this dependably in different+      layouts, because we don't know where the header is (it could be to+      the side of the content, for example).+    + Read presentation size from reference file.  Our presentation size is+      now dependent on the reference/template file we use.+    + Handle (sub)headers above slidelevel correctly.  Above the slidelevel,+      subheaders will be printed in bold and given a bit of extra space+      before them. Note that at the moment, no distinction is made between+      levels of headers above the slide header, though that can be changed.+    + Check for required files.  Since we now import from reference/dist+      file by glob, we need to make sure that we're getting the files we+      need to make a non-corrupt Powerpoint. This performs that check.+    + Improve templating using `--reference-doc`.  Templating should work+      much more reliably now.+    + Include Notes slide in TOC.+    + Set notes slide header to slide-level.+    + Add table of contents.  This is triggered by the `--toc` flag. Note+      that in a long slide deck this risks overrunning the text box. The user+      can address this by setting `--toc-depth=1`.+    + Set notes slide number correctly.+    + Clean up adding metadata slide.  We want to count the slide numbers+      correctly if it's in there.+    + Add anchor links.  For anchor-type links (`[foo](#bar)`) we produce+      an anchor link. In powerpoint these are links to slides, so we keep+      track of a map relating anchors to the slides they occur on.+    + Make the slide number available to the blocks.  For anchors,+      block-processing functions need to know what slide number+      they're in. We make the `envCurSlideId` available to blocks.+    + Move `curSlideId` to environment.+    + Allow setting `toc-title` in metadata.+    + Link notes to endnotes slide.++  * Markdown writer:++    + Fix cell width calculation (#4265).  Previously we could get+      ever-lengthening cell widths when a table was run repeatedly through+      `pandoc -f markdown -t markdown`.++  * LaTeX writer:++    + Escape `&` in lstinline (Robert Schütz).++  * ConTeXt writer:++    + Use xtables instead of Tables (#4223, Henri Menke).+      Default to xtables for context output.  Natural Tables are used+      if the new `ntb` extension is set.++  * HTML writer:++     + Fixed footnote backlinks with `--id-prefix` (#4235).++  * `Text.Pandoc.Extensions`:  Added `Ext_ntb` constructor (API change,+    Henri Menke).++  * `Text.Pandoc.ImageSize`: add derived `Eq` instance to `Dimension`+    (Jesse Rosenthal, API change).++  * Lua filters (Albert Krewinkel):++    + Make `PANDOC_READER_OPTIONS` available.+      The options which were used to read the document are made available to+      Lua filters via the `PANDOC_READER_OPTIONS` global.+    + Add lua module `pandoc.utils.run_json_filter`, which runs a JSON filter+      on a Pandoc document.+    + Refactor filter-handling code into `Text.Pandoc.Filter.JSON`,+      `Text.Pandoc.Filter.Lua`, and `Text.Pandoc.Filter.Path`.+    + Improve error messages.  Provide more context about the task+      which caused an error.++  * data/pandoc.lua (Albert Krewinkel):++    + Accept singleton inline as a list.  Every constructor which accepts a+      list of inlines now also accepts a single inline element for+      convenience.+    + Accept single block as singleton list. Every constructor which accepts+      a list of blocks now also accepts a single block element for+      convenience.  Furthermore, strings are accepted as shorthand for+      `{pandoc.Str "text"}` in constructors.+    + Add attr, listAttributes accessors.  Elements with+      attributes got an additional `attr` accessor. Attributes were+      accessible only via the `identifier`, `classes`, and `attributes`,+      which was in conflict with the documentation, which indirectly states+      that such elements have the an `attr` property.+    + Drop `_VERSION`.  Having a `_VERSION` became superfluous, as this+      module is closely tied to the pandoc version, which is available via+      `PANDOC_VERSION`.+    + Fix access to Attr components.  Accessing an Attr value (e.g.,+      ` Attr().classes`) was broken; the more common case of accessing it via+      an Inline or Block element was unaffected by this.++  * Move `metaValueToInlines` to from Docx writer to+    `Text.Pandoc.Writers.Shared`, so it can be used by other writers+    (Jesse Rosenthal).++  * MANUAL.txt:++    + Clarify otherlangs in LaTeX (#4072).+    + Clarify `latex_macros` extension.+    + Recommend use of `raw_attribute` extension in header includes (#4253).++  * Allow latest QuickCheck, tasty, criterion.++  * Remove custom prelude and ghc 7.8 support.++  * Reduce compiler noise (exact paths for compiled modules).++## pandoc 2.1 (2018-01-07)++  * Allow filters and lua filters to be interspersed (#4196).  Previously+    we ran all lua filters before JSON filters.  Now we run filters in+    the order they are presented on the command line, whether lua or JSON.+    There are two incompatible API changes: The type of `applyFilters`+    has changed, and `applyLuaFilters` has been removed.  `Filter` is+    also now exported.++  * Use latest skylighting and omit the `missingIncludes` check, fixing+    a major performance regression in earlier releases of the 2.x series+    (#4226).  Behavior change: If you use a custom syntax definition that+    refers to a syntax you haven't loaded, pandoc will now complain when+    it is highlighting the text, rather than doing a check at the start.+    This change dramatically speeds up invocations of pandoc on short+    inputs.++  * Text.Pandoc.Class: make `FileTree` opaque (don't export+    `FileTree` constructor).  This forces users to interact with it using+    `insertInFileTree` and `getFileInfo`, which normalize file names.++  * Markdown reader:++    + Rewrite `inlinesInBalancedBrackets`.  The rewrite is much more+      direct, avoiding `parseFromString`.  And it performs significantly+      better; unfortunately, parsing time still increases exponentially+      (see #1735).+    + Avoid parsing raw tex unless `\` + letter seen.  This seems to+      help with the performance problem, #4216.++  * LaTeX reader: Simplified a check for raw tex command.++  * Muse reader (Alexander Krotov):++    + Enable round trip test (#4107).+    + Automatically translate `#cover` into `#cover-image`.+      Amusewiki uses #cover directive to specify cover image.++  * Docx reader (Jesse Rosenthal):++    + Allow for insertion/deletion of paragraphs (#3927).+      If the paragraph has a deleted or inserted paragraph break (depending+      on the track-changes setting) we hold onto it until the next+      paragraph. This takes care of accept and reject. For this we introduce+      a new state which holds the ils from the previous para if necessary.+      For `--track-changes=all`, we add an empty span with class+      `paragraph-insertion`/`paragraph-deletion` at the end of the paragraph+      prior to the break to be inserted or deleted.+    + Remove unused anchors (#3679).  Docx produces a lot of anchors with+      nothing pointing to them---we now remove these to produce cleaner+      output. Note that this has to occur at the end of the process+      because it has to follow link/anchor rewriting.+    + Read multiple children of `w:sdtContents`.+    + Combine adjacent anchors.  There isn't any reason to have numerous+      anchors in the same place, since we can't maintain docx's+      non-nesting overlapping. So we reduce to a single anchor.+    + Improved tests.++  * Muse writer (Alexander Krotov): don't escape URIs from AST++  * Docx writer:++    + Removed redundant subtitle in title (Sebastian Talmon).+    + `firstRow` table definition compatibility for Word 2016 (Sebastian+      Talmon).  Word 2016 seems to use a default value of "1" for table+      headers, if there is no firstRow definition (although a default+      value of 0 is documented), so all tables get the first Row formatted+      as header.  Setting the parameter to 0 if the table has no header+      row fixes this for Word 2016+    + Fix custom styles with spaces in the name (#3290).++  * Powerpoint writer (Jesse Rosenthal):++    + Ignore Notes div for parity with other slide outputs.+    + Set default slidelevel correctly.  We had previously defaulted to+      slideLevel 2. Now we use the correct behavior of defaulting to the+      highest level header followed by content. We change an expected test+      result to match this behavior.+    + Split blocks correctly for linked images.+    + Combine adjacent runs.+    + Make inline code inherit code size.  Previously (a) the code size+      wasn't set when we force size, and (b) the properties was set from+      the default, instead of inheriting.+    + Simplify `replaceNamedChildren` function.+    + Allow linked images.  The following markdown:+      `[![Image Title](image.jpg)](http://www.example.com)`+      will now produce a linked image in the resulting PowerPoint file.+    + Fix error with empty table cell.  We require an empty `<a:p>` tag,+      even if the cell contains no paragraphs---otherwise PowerPoint+      complains of corruption.+    + Implement two-column slides.  This uses the columns/column div+      format described in the pandoc manual. At the moment, only two+      columns (half the screen each) are allowed. Custom widths are not+      supported.+    + Added more tests.++  * OpenDocument/ODT writers: improved rendering of formulas (#4170, oltolm).++  * Lua filters (Albert Krewinkel):++    + `data/pandoc.lua`: drop 'pandoc-api-version' from Pandoc objects+    + The current pandoc-types version is made available to Lua programs in+      the global `PANDOC_API_VERSION`. It contains the version as a list of+      numbers.+    + The pandoc version available as a global `PANDOC_VERSION` (a list+      of numbers).+    + `data/pandoc.lua`: make `Attr` an `AstElement`.+    + `data/pandoc.lua`: make all types subtypes of `AstElement`.+      `Pandoc`, `Meta`, and `Citation` were just plain functions and did+      not set a metatable on the returned value, which made it difficult+      to amend objects of these types with new behavior. They are now+      subtypes of AstElement, meaning that all their objects can gain+      new features when a method is added to the behavior object+      (e.g., `pandoc.Pandoc.behavior`).+    + `data/pandoc.lua`: split type and behavior tables.  Clearly distinguish+      between a type and the behavioral properties of an instance of that+      type. The behavior of a type (and all its subtypes) can now be+      amended by adding methods to that types `behavior` object, without+      exposing the type objects internals.  E.g.:+      ```lua+      pandoc.Inline.behavior.frob = function () print'42' end+      local str = pandoc.Str'hello'+      str.frob() -- outputs '42'+      ```+    + `data/pandoc.lua`: fix Element inheritance.  Extending all elements+      of a given type (e.g., all inline elements) was difficult, as the+      table used to lookup unknown methods would be reset every time a+      new element of that type was created, preventing recursive property+      lookup. This is was changed in that all methods and attributes of+      supertypes are now available to their subtypes.+    + `data/pandoc.lua`: fix attribute names of Citation (#4222).  The+      fields were named like the Haskell fields, not like the documented,+      shorter version.  The names are changed to match the documentation+      and Citations are given a shared metatable to enable simple+      extensibility.+    + `data/pandoc.lua`: drop function `pandoc.global_filter`.+    + Bump `hslua` version to 0.9.5.  This version fixes a bug that made it+      difficult to handle failures while getting lists or a Map from Lua.+      A bug in pandoc, which made it necessary to always pass a tag when+      using MetaList or MetaBlock, is fixed as a result. Using the pandoc+      module's constructor functions for these values is now optional+      (if still recommended).+    + Stop exporting `pushPandocModule` (API change).  The introduction+      of `runPandocLua` renders direct use of this function obsolete.+    + Update generation of module docs for lua filters.+    + `Lua.Module.Utils`: make stringify work on `MetaValues` (John+      MacFarlane).  I'm sure this was intended in the first place,+      but currently only `Meta` is supported.++  * Improve benchmarks.++    + Set the default extensions properly.+    + Improve benchmark argument parsing.  You can now say+      `make bench BENCHARGS="markdown latex reader"` and both the+      markdown and latex readers will be benchmarked.++  * MANUAL.txt simplify and add more structure (Mauro Bieg).++  * Generate README.md from template and MANUAL.txt.+    `make README.md` will generate the README.md after changes+    to MANUAL.txt have been made.++  * Update copyright notices to include 2018 (Albert Krewinkel).++## pandoc 2.0.6 (2017-12-28)++  * Added `jats` as an input format.++    + Add Text.Pandoc.Readers.JATS, exporting `readJATS` (API+      change) (Hamish Mackenzie).+    + Improved citation handling in JATS reader.  JATS citations+      are now converted to pandoc citations, and JATS ref-lists+      are converted into a `references` field in metadata, suitable+      for use with pandoc-citeproc. Thus a JATS article with embedded+      bibliographic information can be processed with pandoc and+      pandoc-citeproc to produce a formatted bibliography.++  * Allow `--list-extensions` to take an optional FORMAT argument.+    This lists the extensions set by default for the selected FORMAT.+    The extensions are now alphabetized, and the `+` or `-`+    indicating the default setting comes before, rather than after,+    the extension.++  * Markdown reader:++    + Preserve original whitespace between blocks.+    + Recognize `\placeformula` as context.+    + Be pickier about table captions.  A caption starts with a `:` which+      can't be followed by punctuation.  Otherwise we can falsely interpret+      the start of a fenced div, or even a table header line like+      `:--:|:--:`, as a caption.+    + Always use four space rule for example lists.  It would be awkward+      to indent example list contents to the first non-space character after+      the label, since example list labels are often long.  Thanks to+      Bernhard Fisseni for the suggestion.+    + Improve raw tex parsing.  Note that the Markdown reader is also+      affected by the `latex_macros` extension changes described below+      under the LaTeX reader.++  * LaTeX reader:++    + `latex_macros` extension changes (#4179).  Don't pass through macro+      definitions themselves when `latex_macros` is set.  The macros+      have already been applied.  If `latex_macros` is enabled, then+      `rawLaTeXBlock` in Text.Pandoc.Readers.LaTeX will succeed in parsing+      a macro definition, and will update pandoc's internal macro map+      accordingly, but the empty string will be returned.+    + Export `tokenize`, `untokenize` (API change).+    + Use `applyMacros` in `rawLaTeXBlock`, `rawLaTeXInline`.+    + Refactored `inlineCommand`.+    + Fix bug in tokenizer.  Material following `^^` was+      dropped if it wasn't a character escape.  This only affected+      invalid LaTeX, so we didn't see it in the wild, but it appeared+      in a QuickCheck test failure.+    + Fix regression in LateX tokenization (#4159).  This mainly affects the+      Markdown reader when parsing raw LaTeX with escaped spaces.+    + Add tests of LaTeX tokenizer.+    + Support `\foreignlanguage` from babel.+    + Be more tolerant of `&` character (#4208).  This allows us to parse+      unknown tabular environments as raw LaTeX.++  * Muse reader (Alexander Krotov):++    + Parse anchors immediately after headings as IDs.+    + Require that note references does not start with 0.+    + Parse empty comments correctly.++  * Org reader (Albert Krewinkel):++    + Fix asterisks-related parsing error (#4180).+    + Support minlevel option for includes (#4154).  The level of headers+      in included files can be shifted to a higher level by specifying a+      minimum header level via the `:minlevel` parameter. E.g.+      `#+include: "tour.org" :minlevel 1` will shift the headers in+      tour.org such that the topmost headers become level 1 headers.+    + Break-up org reader test file into multiple modules.++  * OPML reader:++    + Enable raw HTML and other extensions by default for notes+      (#4164).  This fixes a regression in 2.0.  Note that extensions can+      now be individually disabled, e.g.  `-f opml-smart-raw_html`.++  * RST reader:++    + Allow empty list items (#4193).+    + More accurate parsing of references (#4156).  Previously we erroneously+      included the enclosing backticks in a reference ID (#4156).  This+      change also disables interpretation of syntax inside references, as+      in docutils.  So, there is no emphasis in `` `my *link*`_ ``.++  * Docx reader:++    + Continue lists after interruption (#4025, Jesse Rosenthal).+      Docx expects that lists will continue where they left off after an+      interruption and introduces a new id if a list is starting again. So+      we keep track of the state of lists and use them to define a "start"+      attribute, if necessary.+    + Add tests for structured document tags unwrapping (Jesse Rosenthal).+    + Preprocess Document body to unwrap `w:sdt` elements (Jesse Rosenthal,+      #4190).++  * Plain writer:++    + Don't linkify table of contents.++  * RST writer:++    + Fix anchors for headers (#4188).  We were missing an `_`.++  * PowerPoint writer (Jesse Rosenthal):++    + Treat lists inside BlockQuotes as lists.  We don't yet produce+      incremental lists in PowerPoint, but we should at least treat lists+      inside BlockQuotes as lists, for compatibility with other slide formats.+    + Add ability to force size.  This replaces the more specific+      `blockQuote runProp`, which only affected the size of blockquotes. We+      can use this for notes, etc.+    + Implement notes.  This currently prints all notes on a final slide.+      Note that at the moment, there is a danger of text overflowing the+      note slide, since there is no logic for adding further slides.+    + Implement basic definition list functionality to PowerPoint writer.+    + Don't look for default template file for Powerpoint (#4181).+    + Add pptx to isTextFormat list.  This is used to check standalone+      and not writing to the terminal.+    + Obey slide level option (Jesse Rosenthal).+    + Introduce tests.++  * Docx writer:++    + Ensure that `distArchive` is the one that comes with pandoc+      (#4182).  Previously a `reference.docx` in `~/.pandoc` (or the user data+      dir) would be used instead, and this could cause problems because a+      user-modified docx sometimes lacks vital sections that we count+      on the `distArchive` to supply.++  * Org writer:++    + Do not wrap "-" to avoid accidental bullet lists (Alexander Krotov).+    + Don't allow fn refs to wrap to beginning of line (#4171, with help from+      Alexander Krotov).  Otherwise they can be interpreted as footnote+      definitions.++  * Muse writer (Alexander Krotov):++    + Don't wrap note references to the next line (#4172).++  * HTML writer:++    + Use br elements in line blocks instead of relying on CSS+      (#4162).  HTML-based templates have had the custom CSS for+      `div.line-block` removed.  Those maintaining custom templates will want+      to remove this too.  We still enclose line blocks in a div with class+      `line-block`.++  * LaTeX writer:++    + Use `\renewcommand` for `\textlatin` with babel (#4161).+      This avoids a clash with a deprecated `\textlatin` command defined+      in Babel.+    + Allow fragile=singleslide attribute in beamer slides (#4169).+    + Use `\endhead` after `\toprule` in headerless tables (#4207).++  * FB2 writer:++    + Add cover image specified by `cover-image` meta (Alexander Krotov,+      #4195).++  * JATS writer (Hamish Mackenzie):++    + Support writing `<fig>` and `<table-wrap>` elements+      with `<title>` and `<caption>` inside them by using Divs with class set+      to one of `fig`, `table-wrap` or `caption` (Hamish Mackenzie).  The+      title is included as a Heading so the constraint on where Heading can+      occur is also relaxed.+    + Leave out empty alt attributes on links.+    + Deduplicate image mime type code.+    + Make `<p>` optional in `<td>` and `<th>` (#4178).+    + Self closing tags for empty xref (#4187).+    + Improve support for code language.++  * Custom writer:++    + Use init file to setup Lua interpreter (Albert Krewinkel).+      The same init file (`data/init`) that is used to setup the Lua+      interpreter for Lua filters is also used to setup the interpreter of+      custom writers.lua.+    + Define instances for newtype wrapper (Albert Krewinkel).  The custom+      writer used its own `ToLuaStack` instance definitions, which made+      it difficult to share code with Lua filters, as this could result+      in conflicting instances.  A `Stringify` wrapper is introduced to+      avoid this problem.+    + Added tests for custom writer.+    + Fixed definition lists and tables in `data/sample.lua`.++  * Fixed regression: when target is PDF, writer extensions were being+    ignored.  So, for example, `pandoc -t latex-smart -o file.pdf`+    did not work properly.++  * Lua modules (Albert Krewinkel):++    + Add `pandoc.utils` module, to hold utility functions.+    + Create a Haskell module Text.Pandoc.Lua.Module.Pandoc to+      define the `pandoc` lua module.+    + Make a Haskell module for each Lua module. Move definitions for the+      `pandoc.mediabag` modules to a separate Haskell module.+    + Move `sha1` from the main `pandoc` module to `pandoc.utils`.+    + Add function `pandoc.utils.hierarchicalize` (convert list of+      Pandoc blocks into (hierarchical) list of Elements).+    + Add function `pandoc.utils.normalize_date` (parses a date and+      converts it (if possible) to "YYYY-MM-DD" format).+    + Add function `pandoc.utils.to_roman_numeral` (allows conversion+      of numbers below 4000 into roman numerals).+    + Add function `pandoc.utils.stringify` (converts any AST element+      to a string with formatting removed).+    + `data/init.lua`: load `pandoc.utils` by default+    + Turn pipe, read into full Haskell functions.  The `pipe` and `read`+      utility functions are converted from hybrid lua/haskell functions+      into full Haskell functions. This avoids the need for intermediate+      `_pipe`/`_read` helper functions, which have dropped.+    + pandoc.lua: re-add missing MetaMap function.  This was a bug+      introduced in version 2.0.4.++  * Text.Pandoc.Class: Add `insertInFileTree` [API change].  This gives+    a pure way to insert an ersatz file into a `FileTree`.  In addition, we+    normalize paths both on insertion and on lookup.++  * Text.Pandoc.Shared: export `blocksToInlines'` (API change, Maura Bieg).++  * Text.Pandoc.MIME: Add opus to MIME type table as audio/ogg (#4198).++  * Text.Pandoc.Extensions:   Alphabetical order constructors for+    `Extension`.  This makes them appear in order in `--list-extensions`.++  * Allow lenient decoding of latex error logs, which are not always+    properly UTF8-encoded (#4200).++  * Update latex template to work with recent versions of beamer.+    The old template produced numbered sections with some recent+    versions of beamer.  Thanks to Thomas Hodgson.++  * Updated reference.docx (#4175).  Instead of just "Hello, world", the+    document now contains exemplars of most of the styles that have an+    effect on pandoc documents.  This makes it easier to see the effect+    of style changes.++  * Removed `default.theme` data file (#4096).  It is no longer needed now+    that we have `--print-highlight-style`.++  * Added `stack.lts9.yaml` for building with lts 9 and ghc 8.0.2.+    We still need this for the alpine static linux build, since+    we don't have ghc 8.2.2 for that yet.++  * Removed `stack.pkg.yaml`.  We only really need `stack.yaml`; we+    can put flag settings for pandoc-citeproc there.++  * Makefile: Add 'trypandoc' and 'pandoc-templates' targets to+    make releases easier.++  * MANUAL.txt:++    + Add note on what formats have `+smart` by default.+    + Use native syntax for custom-style (#4174, Mauro Bieg).+    + Introduce dedicated Extensions section, since some extensions+      affect formats other than markdown (Mauro Bieg, #4204).+    + Clarify default html output for `--section-divs` (Richard Edwards).++  * filters.md: say that Text.Pandoc.JSON comes form pandoc-types.+    Closes jgm/pandoc-website#16.++  * epub.md: Delete removed `-S` option from command (#4151, Georger Araújo).++## pandoc 2.0.5 (2017-12-12)++  * Fix a bug in 2.0.4, whereby pandoc could not read the theme files+    generated with `--print-highlight-style` (#4133).  Improve JSON+    serialization of styles.++  * Fix CSS issues involving line numbers (#4128).+    Highlighted code blocks are now enclosed in a div with class `sourceCode`.+    Highlighting CSS no longer sets a generic color for pre and code; we only+    set these for class `sourceCode`.++  * `--pdf-engine-opt`: fix bug where option order was reversed (#4137).++  * Add PowerPoint (pptx) writer (Jesse Rosenthal).+    It works following the standard Pandoc conventions for making other+    sorts of slides. Caveats:++    + Syntax highlighting is not yet implemented. (This is difficult+      because there are no character classes in Powerpoint.)+    + Footnotes and Definition lists are not yet implemented. (Notes will+      usually take the form of a final slide.+    + Image placement and auto-resizing has a few glitches.+    + Reference powerpoint files don't work dependably from the command+      line. This will be implemented, but at the moment users are advised+      to change themes from within Powerpoint.++  * Create shared Text.Pandoc.Writers.OOXML module (Jesse Rosenthal).+    This is for functions used by both Powerpoint and Docx writers.++  * Add default pptx data for Powerpoint writer (Jesse Rosenthal).++  * Add `empty_paragraphs` extension.++    + Deprecate `--strip-empty-paragraphs` option.  Instead we now+      use an `empty_paragraphs` extension that can be enabled on+      the reader or writer.  By default, disabled.+    + Add `Ext_empty_paragraphs` constructor to `Extension`.+    + Revert "Docx reader: don't strip out empty paragraphs."+      This reverts commit d6c58eb836f033a48955796de4d9ffb3b30e297b.+    + Implement `empty_paragraphs` extension in docx reader and writer,+      opendocument writer, html reader and writer.+    + Add tests for `empty_paragraphs` extension.++  * Markdown reader:++    + Don't parse native div as table caption (#4119).+    + Improved computation of column widths in pipe tables.+      Pipe tables with lines longer than the text width (as set+      by `--columns`) are now scaled to text width, with the relative+      widths of columns determined by the ratios between the+      header lines.  Previously we computed column widths using+      the ratio of header line lengths to column width, so that+      tables with narrow header lines were extremely thin, which+      was very rarely the desired result.++  * LaTeX reader: fix `\` before newline (#4134).  This should be a space,+    as long as it's not followed by a blank line. This has been fixed at the+    tokenizer level.++  * Muse reader (Alexander Krotov):++    + Add test for `#disable-tables` directive in Emacs mode.+    + Don't allow emphasis to be preceded by letter.+    + Add underline support in Emacs Muse mode..+    + Support multiline directives in Amusewiki mode++  * Man writer: omit internal links (#4136).  That is, just print the link+    text without the URL.++  * Markdown reader: accept processing instructions as raw HTML (#4125).++  * Lua filters (Albert Krewinkel):++    + Use script to initialize the interpreter.  The file `init.lua` is+      used to initialize the Lua interpreter which is used in Lua filters.+      This gives users the option to require libraries which they want to+      use in all of their filters, and to extend default modules.+    + Fix package loading for Lua 5.1.  The list of package searchers is+      named `package.loaders` in Lua 5.1 and LuaJIT, and `package.searchers`+      in Lua 5.2 and later.+    + Refactor lua module handling.  The integration with Lua's package/module+      system is improved: A pandoc-specific package searcher is prepended to+      the searchers in `package.searchers`. The modules `pandoc` and+      `pandoc.mediabag` can now be loaded via `require`.+    + Bump lower bound of hslua.  The release hslua 0.9.3 contains a new+      function which makes using Haskell functions as package loaders much+      easier.++  * reveal.js template:  add title-slide identifier to title slide (#4120).+    This allows it to be styled more easily.++  * LaTeX template: Added support for `pagestyle` variable (#4135,+    Thomas Hodgson)++  * Add `-threaded` to ghc-options for executable (#4130, fixes a build+    error on linux).+++## pandoc 2.0.4 (2017-12-03)++  * Add `--print-highlight-style` option.  This generates a JSON version+    of a highlighting style, which can be saved as a `.theme` file, modified,+    and used with `--highlight-style` (#4106, #4096).++  * Add `--strip-empty-paragraphs` option.  This works for any input format.+    It is primarily intended for use with docx and odt documents where+    empty paragraphs have been used for inter-paragraph spaces.++  * Support `--webtex` for `gfm` output.++  * Recognize `.muse` file extension.++  * Support beamer `\alert` in LaTeX reader. Closes #4091.++  * Docx reader: don't strip out empty paragraphs (#2252).+    Users who have a conversion pipeline from docx may want to consider adding+    `--strip-empty-paragraphs` to the command line.++  * Org reader (Albert Krewinkel): Allow empty list items (#4090).++  * Muse reader (Alexander Krotov):++    + Parse markup in definition list terms.+    + Allow definition to end with EOF.+    + Make code blocks round trip.+    + Drop common space prefix from list items.+    + Add partial round trip test.+    + Don't interpret XML entities.+    + Remove `nested`.+    + Parse `~~` as non-breaking space in Emacs mode.+    + Correctly remove indentation from notes.  Exactly one space is+      required and considered to be part of the marker.+    + Allow list items to be empty.+    + Add ordered list test.+    + Add more multiline definition tests.+    + Don't allow blockquotes within lists.+    + Fix reading of multiline definitions.+    + Add inline `<literal>` support.+    + Concatenate inlines of the same type++  * Docx writer: allow empty paragraphs (#2252).++  * CommonMark/gfm writer:++    + Use raw html for native divs/spans (#4113).  This allows a pandoc+      markdown native div or span to be rendered in gfm using raw html tags.+    + Implement `raw_html` and `raw_tex` extensions.  Note that `raw_html`+      is enabled by default for `gfm`, while `raw_tex` is disabled by default.++  * Muse writer (Alexander Krotov):++    + Test that inline math conversion result is normalized.+      Without normalization this test produced+      `<em>a</em><em>b</em><em>c</em>`.+    + Improve inline list normalization and move to writer.+    + Escape hash symbol.+    + Escape `----` to avoid accidental horizontal rules.+    + Escape only `</code>` inside code tag.+    + Additional `<verbatim>` is not needed as `<code>` is verbatim already.++  * LaTeX writer:++    + Allow specifying just width or height for image size.+      Previously both needed to be specified (unless the image was+      being resized to be smaller than its original size).+      If height but not width is specified, we now set width to+      textwidth. If width but not height is specified, we now set+      height to textheight.  Since we have `keepaspectratio`, this+      yields the desired result.+    + Escape `~` and `_` in code with `--listings` (#4111).++  * HTML writer: export `tagWithAttributes`.  This is a helper allowing+    other writers to create single HTML tags.++  * Let papersizes `a0`, `a1`, `a2`, ... be case-insensitive by+    converting the case as needed in LaTeX and ConTeXt writers.++  * Change `fixDisplayMath` from `Text.Pandoc.Writers.Shared`+    so that it no longer produces empty `Para`'s as an artifact.++  * `Text.Pandoc.Shared.blocksToInlines`:  rewrote using builder.+    This gives us automatic normalization, so we don't get+    for example two consecutive Spaces.++  * Include default CSS for 'underline' class in HTML-based templates.++  * revealjs template:  add `tex2jax` configuration for the+    math plugin.  With the next release of reveal.js, this will+    fix the problem of `$`s outside of math contexts being+    interpreted as math delimiters (#4027).++  * `pandoc.lua` module for use in lua filters (Albert Krewinkel):++    + Add basic lua List module (#4099, #4081).  The List module is+      automatically loaded, but not assigned to a global variable. It can be+      included in filters by calling `List = require 'List'`.  Lists of blocks,+      lists of inlines, and lists of classes are now given `List` as a metatable,+      making working with them more convenient.  E.g., it is now possible to+      concatenate lists of inlines using Lua's concatenation operator `..`+      (requires at least one of the operants to have `List` as a metatable):++          function Emph (emph)+            local s = {pandoc.Space(), pandoc.Str 'emphasized'}+            return pandoc.Span(emph.content .. s)+          end++      The `List` metatable is assigned to the tables which get passed to+      the constructors `MetaBlocks`, `MetaInline`, and `MetaList`. This+      enables the use of the resulting objects as lists.+    + `Lua/StackInstances`: push Pandoc and Meta via constructor.+      Pandoc and Meta elements are now pushed by calling the respective+      constructor functions of the pandoc Lua module. This makes serialization+      consistent with the way blocks and inlines are pushed to lua and allows+      to use List methods with the `blocks` value.+    + Add documentation for pandoc.List in `lua-filters.md`.++  * Use latest tagsoup.  This fixes a bug in parsing HTML tags with+    `&` (but not a valid entity) following them (#4094, #4088).++  * Use skylighting 0.4.4.1, fixing the color of unmarked code text+    when `numberLines` is used (#4103).++  * Make `normalizeDate` more forgiving (Mauro Bieg, #4101), not+    requiring a leading 0 on single-digit days.++  * Fix `--help` output for `--highlight-style` to include `FILE` (Mauro+    Bieg, #4095).++  * Clearer deprecation warning for `--latexmathml, --asciimathml, -m`.+    Previously we only mentioned `--latexmathml`, even if `-m` was+    used.++  * Changelog: fix description of lua filters in 2.0 release+    (Albert Krewinkel).  Lua filters were initially run *after* conventional+    (JSON) filters.  However, this was changed later to make it easier to deal+    with files in the mediabag. The changelog is updated to describe that+    feature of the 2.0 release correctly.++  * Change Generic JSON instances to TemplateHaskell (Jasper Van der Jeugt,+    #4085).  This reduces compile time and memory usage significantly.++  * `lua-filters.md`: Added tikz filter example.++  * Create alternative zip file for macOS binaries.++  * Create alternative zip file for Windows binaries.++  * Update INSTALL.md since we now provide zips for binaries.++  * Relax `http-types` dependency (Justus Sagemüller, #4084).++  * Add `epub.md`, `getting-started.md` to docs.  These used to live in+    the website repo.++  * Add `packages` target to Makefile.++  * Bump bounds for binary, http-types, tasty-hunit++## pandoc 2.0.3 (2017-11-20)++  * Lua filters: preload text module (Albert Krewinkel, #4077).+    The `text` module is preloaded in lua. The module contains some UTF-8+    aware string functions, implemented in Haskell.  The module is loaded on+    request only, e.g.:++        text = require 'text'+        function Str (s)+          s.text = text.upper(s.text)+          return s+        end++  * Allow table-like access to attributes in lua filters (Albert Krewinkel,+    #4071).  Attribute lists are represented as associative lists in Lua. Pure+    associative lists are awkward to work with. A metatable is attached to+    attribute lists, allowing to access and use the associative list as if+    the attributes were stored in as normal key-value pair in table.+    Note that this changes the way `pairs` works on attribute lists. Instead+    of producing integer keys and two-element tables, the resulting iterator+    function now returns the key and value of those pairs.  Use `ipairs` to+    get the old behavior.  Warning: the new iteration mechanism only works if+    pandoc has been compiled with Lua 5.2 or later (current default: 5.3).++  * Text.Pandoc.Parsing.uri:  allow `&` and `=` as word characters (#4068).+    This fixes a bug where pandoc would stop parsing a URI with an+    empty attribute:  for example, `&a=&b=` wolud stop at `a`.+    (The uri parser tries to guess which punctuation characters+    are part of the URI and which might be punctuation after it.)++  * Introduce `HasSyntaxExtensions` typeclass (Alexander Krotov, #4074).++    + Added new `HasSyntaxExtensions` typeclass for `ReaderOptions` and+      `WriterOptions`.+    + Reimplemented `isEnabled` function from `Options.hs` to accept both+      `ReaderOptions` and `WriterOptions`.+    + Replaced `enabled` from `CommonMark.hs` with new `isEnabled`.++  * Add `amuse` extension (Alexander Krotov) to enable Amuse wiki+    behavior for `muse`.  New `Ext_amuse` constructor for+    `Extension`. Note: this is switched on by default; for+    Emacs behavior, use `muse-amuse`.++  * Muse reader (Alexander Krotov):++    + Count only one space as part of list item marker.+    + Produce SoftBreaks on newlines. Now wrapping can be preserved+      with `--wrap=preserve`.+    + Add Text::Amuse footnote extensions.  Footnote end is indicated by+      indentation, so footnotes can be placed anywhere in the text,+      not just at the end of it.+    + Accept Emacs Muse definition lists when `-amuse`.+      Emacs Muse does not require indentation.++  * HTML reader:++    + Ensure we don't produce level 0 headers (#4076), even for chapter+      sections in epubs.  This causes problems because writers aren't set+      up to expect these.+    + Allow spaces after `\(` and before `\)` with `tex_math_single_backslash`.+      Previously `\( \frac{1}{a} < \frac{1}{b} \)` was not parsed as math in+      `markdown` or `html` `+tex_math_single_backslash`.++  * MANUAL: clarify that math extensions work with HTML.+    Clarify that `tex_math_dollars` and `tex_math_single_backslash`+    will work with HTML as well as Markdown.++  * Creole reader: Fix performance issue for longer lists (Sascha Wilde,+    #4067).++  * RST reader: better support for 'container' directive (#4066).+    Create a div, incorporate name attribute and classes.++  * LaTeX reader:++    + Support column specs like `*{2}{r}` (#4056).  This is equivalent to+      `rr`.  We now expand it like a macro.+    + Allow optional args for parbox (#4056).+    + Allow optional arguments on `\footnote` (#4062).++  * EPUB writer: Fixed path for cover image (#4069).  It was previously+    `media/media/imagename`, and should have been `media/imagename`.++  * Markdown writer: fix bug with doubled footnotes in grid tables+    (#4061).++  * LaTeX template:  include natbib/biblatex after polyglossia (#4073).+    Otherwise we seem to get an error; biblatex wants polyglossia+    language to be defined.++  * Added examples to lua filters documentation.+++## pandoc 2.0.2 (2017-11-12)++  * Deprecated ancient HTML math methods: `--latexmathml`, `--gladtex`,+    `--mimetex`, `--jsmath`.++  * Fixed URIs in `data/jats.csl`.  They were being rendered twice,+    leading to invalid XML in default JATS output with pandoc-citeproc.++  * `lua-filters.md`: use real-world man page filter as example.++  * Add lua filter functions `walk_inline` and `walk_block`+    in the pandoc module, to apply filters inside particular+    inline and block elements.++  * Refactored some code from `Text.Pandoc.Lua.PandocModule`+    into new internal module `Text.Pandoc.Lua.Filter`.++  * Markdown reader:++    + Allow fenced code blocks to be indented 1-3 spaces (#4011).+      This brings our handling of them into alignment with CommonMark's.+    + Fix YAML metadata with "chomp" (`|-`).  Previously if a+      YAML block under `|-` contained a blank line, pandoc would+      not parse it as metadata.++  * Removed `etc.` from abbreviations file.  Often `etc.` ends a+    sentence, and we want the period to be treated as a+    sentence-ending period.++  * Fix regression with `--metadata` (#4054).  Values specified with+    `--metadata` should replace a metadata value set in the document+    itself, rather than creating a list including a new value.++  * EPUB writer:++    + Fix EPUB OCF structure.  #3720 had been improperly implemented.+    + Fix modified paths for raw HTML tags (src, poster, etc.)+      (#4050, #4055). This had not been updated for the new EPUB+      container layout, with a separate text/ subdirectory.+    + Fix image paths with empty `--epub-subdirectory`.++  * Miscellaneous code cleanup (Alexander Krotov).++  * Use pandoc-types 1.17.3, which adds `Walkable` instances+    for `[Block] Block` and `[Inline] Inline`.++  * Remove obsolete `stack.full.yaml` (#4052).++  * Change to using pandoc-citeproc 0.12.1 in binary packages.++  * Consolidate math output method documentation (#4049, Mauro Bieg).++  * `MANUAL.txt`: fix header level of "Extension: emoji" (Albert Krewinkel).++  * Use lua filter to generate man page from `MANUAL.txt`, replacing old+    Haskell filters.  This is easier and faster.++  * Improved `INSTALL.md`.++  * Update commands to extract deb archive on Linux (#4043, Salim B).+++## pandoc 2.0.1.1 (2017-11-04)++  * Improved fix to #3989 (parsing of HTML tags containing+    `>` in an attribute or comment). The previous fix (in 2.0.1) only+    worked in certain cases.++  * FB2 writer (Alexander Krotov):++    + Add `unrecognised` genre to `<title-info>`+      (Alexander Krotov).  XML schema requires at least one genre.+    + Remove `<annotation>` from `<body>`.++  * CommonMark writer: fix strikethrough for `gfm` (#4038).++  * Use texmath 0.10, which adds support for a wider range of+    symbols and fixes default column alignments in MathML+    and OMML.++  * Highlighting fixes, using skylighting 0.4.3.2:++    + Fix invalid CSS.+    + Support `lineAnchors` (or `line-anchors`) in HTML code blocks.+    + Ensure that code lines don't get duplicate identifiers (#4031).+      The line identifiers are built using the code block's identifier+      as a prefix. If the code block has null identifier, we use+      `cb1`, `cb2`, etc.++  * Added a few abbreviations to `data/abbreviations`,+    and sorted the list (#3984, Wandmalfarbe).++  * Improved support for columns in HTML writer (#4028).++    + Remove `width` attribute from the `div`.+    + Remove space between `<div class="column">` elements,+      since this prevents columns whose widths sum to 100%+      (the space takes up space).+    + Move as much as possible of the CSS to the template.+    + Ensure that all the HTML-based templates (including epub)+      contain the CSS for columns.+    + Columns default to 50% width unless they are given a width+      attribute.  So if you want two equal-width columns, you+      can use a div with class `column` and no `width` attribute.++  * SelfContained: use `base64` for css links with media attribute (#4026).+    This fixes `--self-contained` with S5.++  * Improve `pandoc-template-mode.el` (Vaclav Haisman).++  * INSTALL.md: MacOS instructions needed xar -f (adam234).++  * MANUAL.txt:++    + Clarify that --setext-headers doesn't affect gfm output (#4035).+    + Clarify what is needed to open and close a div in `fenced_divs`+      (#4039, Tristano Ajmone).+    + Removed reference to `default.beamer` in docs (#4024).+      Also added mention of other templates affecting PDF output+      with different settings.+++## pandoc 2.0.1 (2017-10-31)++  * Fixed regression in parsing of HTML comments in markdown and other+    non-HTML formats (`Text.Pandoc.Readers.HTML.htmlTag`) (#4019).+    The parser stopped at the first `>` character, even if it wasn't+    the end of the comment.++  * Creole reader (Sascha Wilde):++    + Fix some minor typos and formatting.+    + Add additional test on nowiki-block after para.+    + Fix lists with trailing white space.++  * LaTeX reader: handle `%` comment right after command.+    For example, `\emph%`.++  * Markdown reader:  make sure fenced div closers work in lists.+    Previously the following failed:++        ::: {.class}+        1. one+        2. two+        :::++    and you needed a blank line before the closing `:::`.++  * Make `fenced_divs` affect the Markdown writer.  If `fenced_divs` is+    enabled, Divs will be rendered as fenced divs.++  * LaTeX/Beamer writer: support "blocks" inside columns and other Divs+    (#4016).++  * HTML Writer: consistently use dashed class-names (Mauro Bieg, #3556).+    Note: this change may require some changes in CSS rules.+    `footnoteRef` has become `footnote-ref`, `titleslide` has+    become `title-slide`, and `footnoteBack` has become `footnote-back`.++  * JATS writer: Properly pass through author metadata (#4020).++  * FB2 writer (Alexander Krotov):++    + Write blocks outside of `<p>` in definitions.+    + Make bullet lists consistent with ordered lists, repeating+      the marker for the outer list rather than indenting sublists,+      since indentation does not work in readers.+    + Add new style FB2 tests.++  * `Text.Pandoc.ImageSize`: Add `Millimeter` constructor to `Dimension`+    (#4012) [API change]. Now sizes given in 'mm' are no longer converted+    to 'cm'.++  * Revise documentation of small caps syntax (Andrew Dunning, #4013).++  * Fix broken reference links in manual (Andrew Dunning, #4014)++  * Fixed example of slide columns structure in changelog (#4015).+    Also documented this feature in MANUAL.txt.+++## pandoc 2.0.0.1 (2017-10-30)++  * EPUB writer:++    + Fixed filepaths for nonstandard epub-subdirectory values.+    + Ensure that epub2 is recognized as a non-text format,+      so that a template is used.+    + Don't include "prefix" attribute for ibooks for epub2.+      It doesn't validate.+    + Fix stylesheet paths; previously we had an incorrect+      stylesheet path for the cover page and nav page.++  * LaTeX reader:++    + Insert space when needed in macro expansion (#4007).+      Sometimes we need to insert a space after a control sequence+      to prevent it merging with a following letter.+    + Allow unbraced arguments for macros (#4007).+    + Allow body of macro definition to be unbraced (#4007).++  * Linux package build: ensure that pandoc-citeproc is statically linked.++  * trypandoc: add native, ms.+++## pandoc 2.0 (2017-10-29)++### New features++  * New output format `ms` (groff ms). Complete support, including+    tables, math, syntax highlighting, and PDF bookmarks. The writer uses+    texmath's new eqn writer to convert math to eqn format, so a ms file+    produced with this writer should be processed with `groff -ms -e` if+    it contains math.++  * New output format `jats` (Journal Article Tag Suite).  This is an XML+    format used in archiving and publishing articles.  Note that a+    URI-encoded CSL stylesheet (`data/jats.csl`) is added automatically+    unless a stylesheet is specified using `--css`.++  * New output format `gfm` (GitHub-flavored CommonMark) (#3841).+    This uses bindings to GitHub's fork of cmark, so it should parse+    gfm exactly as GitHub does (excepting certain postprocessing+    steps, involving notifications, emojis, etc.).  `markdown_github`+    has been deprecated in favor of `gfm`.++  * New output format `muse` (Emacs Muse) (Alexander Krotov, #3489).++  * New input format `gfm` (GitHub-flavored CommonMark) (#3841).+    This uses bindings to GitHub's fork of cmark.  `markdown_github`+    has been deprecated in favor of `gfm`.++  * New input format `muse` (Emacs Muse) reader (Alexander Krotov, #3620).++  * New input format `tikiwiki` (TikiWiki markup) (rlpowell, #3800).++  * New input format `vimwiki` (Vimwiki markup) (Yuchen Pei, #3705).+    Note that there is a new data file, `data/vimwiki.css`, which can+    be used to display the HTML produced by this reader and+    pandoc's HTML writer in the style of vimwiki's own HTML+    export.++  * New input format `creole` (Creole 1.0) (#3994, Sascha Wilde).++  * New syntax for Divs, with `fenced_divs` extension enabled by+    default (#168).  This gives an attractive, plain-text way to create+    containers for block-level content.++  * Added new syntax for including raw content in any output format,+    enabled by the `raw_attribute` extension (which is on by default+    for `markdown` and `multimarkdown`).  The syntax is the same as+    for fenced code blocks or code inlines, only with `{=FORMAT}` for+    attributes, where `FORMAT` is the name of the output format+    (e.g., `ms`, `html`).++  * Implement multicolumn support for slide formats (#1710).+    The structure expected is:++        :::::::::::::: {.columns}+        ::: {.column width="40%"}+        contents...+        :::+        ::: {.column width="60%"}+        contents...+        :::+        ::::::::::::::++    Support has been added for beamer and all HTML slide formats.++  * Allows line comments in templates, beginning with `$--` (#3806).+    (Requires doctemplates 0.2.1.)++  * Add `--eol=crlf|lf|native` flag and writer option to control line endings+    (Stefan Dresselhaus, #3663, #2097).++  * Add `--log` option to save log messages in JSON format to a file (#3392).++  * Add `--request-header` option, to set request headers when pandoc+    makes HTTP requests to fetch external resources. For example:+    `--request-header User-Agent:blah`.++  * Added lua filters (Albert Krewinkel, #3514).  The new `--lua-filter`+    option works like `--filter` but takes pathnames of special lua filters+    and uses the lua interpreter baked into pandoc, so that no external+    interpreter is needed.  Note that lua filters are all applied after+    regular filters, regardless of their position on the command line.+    For documentation of lua filters, see `doc/lua-filters.md`.++  * Set `PANDOC_READER_OPTIONS` in environment where filters are run.+    This contains a JSON representation of `ReaderOptions`, so filters+    can access it.++  * Support creation of pdf via groff `ms` and pdfroff.+    `pandoc -t ms -o output.pdf input.txt`.++  * Support for PDF generation via HTML and `weasyprint` or `prince`+    (Mauro Bieg, #3909).  `pandoc -t html5 -o output.pdf --pdf-engine=prince`.++  * Added `--epub-subdirectory` option (#3720).  This specifies the+    subdirectory in the OCF container that holds the EPUB specific content.+    We now put all EPUB related content in an `EPUB/` subdirectory by default+    (later this will be configurable).++    ```+      mimetype+      META-INF/+        com.apple.ibooks.display-options.xml+        container.xml+      EPUB/ <<--configurable-->>+        fonts/ <<--static-->>+        font.otf+      media/ <<--static-->>+        cover.jpg+        fig1.jpg+      styles/ <<--static-->>+        stylesheet.css+      content.opf+      toc.ncx+      text/ <<--static-->>+        ch001.xhtml+    ```++  * Added `--resource-path=SEARCHPATH` command line option (#852).+    SEARCHPATH is separated by the usual character, depending on OS+    (: on unix, ; on windows).  Default resource path is just working+    directory.  However, the working directory must be explicitly+    specified if the `--resource-path` option is used.++  * Added --abbreviations=FILE option for custom abbreviations file+    (#256).  Dfault abbreviations file (`data/abbreviations`) contains+    a list of strings that will be recognized by pandoc's+    Markdown parser as abbreviations.  (A nonbreaking space will+    be inserted after the period, preventing a sentence space in+    formats like LaTeX.) Users can override the default by putting a file+    abbreviations in their user data directory (`~/.pandoc` on *nix).++  * Allow a theme file as argument to `--highlight-style`.+    Also include a sample, `default.theme`, in `data/`.++  * Allow `--syntax-definition` option for dynamic loading of syntax+    highlighting definitions (#3334).++  * Lists in `markdown` by default now use the CommonMark variable+    nesting rules (#3511). The indentation required for a block-level+    item to be included in a list item is no longer fixed, but is+    determined by the first line of the list item.  To be included in+    the list item, a block must be indented to the level of the first+    non-space content after the list marker. Exception: if are 5 or more+    spaces after the list marker, then the content is interpreted as an+    indented code block, and continuation paragraphs must be indented+    two spaces beyond the end of the list marker.  See the CommonMark+    spec for more details and examples.++    Documents that adhere to the four-space rule should, in most cases,+    be parsed the same way by the new rules.  Here are some examples+    of texts that will be parsed differently:++        - a+          - b++    will be parsed as a list item with a sublist; under the four-space+    rule, it would be a list with two items.++        - a++              code++    Here we have an indented code block under the list item, even though it+    is only indented six spaces from the margin, because it is four spaces+    past the point where a continuation paragraph could begin.  With the+    four-space rule, this would be a regular paragraph rather than a code+    block.++        - a++                code++    Here the code block will start with two spaces, whereas under+    the four-space rule, it would start with `code`.  With the four-space+    rule, indented code under a list item always must be indented eight+    spaces from the margin, while the new rules require only that it+    be indented four spaces from the beginning of the first non-space+    text after the list marker (here, `a`).++    This change was motivated by a slew of bug reports from people+    who expected lists to work differently (#3125, #2367, #2575, #2210,+     #1990, #1137, #744, #172, #137, #128) and by the growing prevalance+    of CommonMark (now used by GitHub, for example).  Those who+    prefer the old behavior can use `-f markdown+four_space_rule`.++  * Added `four_space_rule` extension.  This triggers the old pandoc+    parsing rule for content nested under list items (the "four space+    rule").++  * Added `spaced_reference_links` extension (#2602).  It allows whitespace+    between the two parts of a reference link:  e.g.++        [a] [b]++        [b]: url++    This was previously enabled by default; now it is forbidden by default.++  * Add `space_in_atx_header` extension (#3512).  This is enabled by default+    in pandoc and GitHub markdown but not the other flavors.+    This requirse a space between the opening #'s and the header+    text in ATX headers (as CommonMark does but many other implementations+    do not).  This is desirable to avoid falsely capturing things ilke++        #hashtag++    or++        #5++  * Add `sourcefile` and `outputfile` template variables (Roland Hieber,+    #3431).++  * Allow ibooks-specific metadata in epubs (#2693).  You can now have+    the following fields in your YAML metadata, and it will be treated+    appropriately in the generated EPUB:++    ```+      ibooks:+        version: 1.3.4+        specified-fonts: false+        ipad-orientation-lock: portrait-only+        iphone-orientation-lock: landscape-only+        binding: true+        scroll-axis: vertical+    ```+++### Behavior changes++  * Reader functions no longer presuppose that CRs have been+    stripped from the input. (They strip CRs themselves, before+    parsing, to simplify the parsers.)++  * Added support for translations (localization) (#3559).+    Currently this only affects the LaTeX reader, for things+    like `\figurename`.  Translation data files for 46 languages+    can be found in `data/translations`.++  * Make `--ascii` work with DocBook output too.++  * Rename `--latex-engine` to `--pdf-engine`,+    and `--latex-engine-opt` to `--pdf-engine-opt`.++  * Removed `--parse-raw` and `readerParseRaw`.  These were confusing.+    Now we rely on the `+raw_tex` or `+raw_html` extension with latex or html+    input.  Thus, instead of `--parse-raw -f latex` we use `-f latex+raw_tex`,+    and instead of `--parse-raw -f html` we use `-f html+raw_html`.++  * With `--filter` R filters are now recognized, even if they are+    not executable (#3940, #3941, Andrie de Vries).++  * Support SVG in PDF output, converting with `rsvg2pdf` (#1793).++  * Make epub an alias for epub3, not epub2.++  * Removed `--epub-stylesheet`; use `--css` instead (#3472, #847).+    Multiple stylesheets may be used.  Stylesheets will be taken both from+    `--css` and from the `stylesheet` metadata field (which can contain+    either a file path or a list of them).++  * `--mathml` and MathML in HTMLMathMethod no longer take an argument.+    The argument was for a bridge JavaScript that used to be necessary+    in 2004.  We have removed the script already.++  * `--katex` improvements.  The latest version is used, and the+    autoload script is loaded by default.++  * Change MathJax CDN default since old one is shutting down (#3544).+    Note:  The new URL requires a version number, which we'll have+    to update manually in subsequent pandoc releases in order to+    take advantage of mathjax improvements.++  * `--self-contained`: don't incorporate elements with `data-external="1"`+    (#2656).  You can leave an external link as it is by adding the attribute+    data-external="1" to the element.  Pandoc will then not try to+    incorporate its content when `--self-contained` is used.  This is+    similar to a feature already supported by the EPUB writer.++  * Allow `--extract-media` to work with non-binary input formats+    (#1583, #2289).  If `--extract-media` is supplied with a non-binary+    input format, pandoc will attempt to extract the contents of all+    linked images, whether in local files, data: uris, or external uris.+    They will be named based on the sha1 hash of the contents.++  * Make `papersize: a4` work regardless of the case of `a4`.+    It is converted to `a4` in LaTeX and `A4` in ConTeXt.++  * Make `east_asian_line_breaks` affect all readers/writers (#3703).++  * Underlined elements are now treated consistently by readers+    (#2270, hftf); they are always put in a Span with class `underline`.+    This allows the user to treat them differently from other emphasis,+    using a filter.  Docx, Org, Textile, Txt2Tags, and HTML readers+    have been changed.++  * Improved behavior of `auto_identifiers` when there are explicit ids+    (#1745).  Previously only autogenerated ids were added to the list+    of header identifiers in state, so explicit ids weren't taken+    into account when generating unique identifiers.  Duplicated+    identifiers could result.  This simple fix ensures that explicitly given+    identifiers are also taken into account.++  * Use `table-of-contents` for contents of toc, make `toc` a boolean+    (#2872).  Changed markdown, rtf, and HTML-based templates accordingly.+    This allows you to set `toc: true` in the metadata; this+    previously produced strange results in some output formats.+    For backwards compatibility, `toc` is still set to the+    toc contents.  But it is recommended that you update templates+    to use `table-of-contents` for the toc contents and `toc`+    for a boolean flag.++  * Change behavior with binary format output to stdout.+    Previously, for binary formats, output to stdout was disabled+    unless we could detect that the output was being piped (and not+    sent to the terminal).  Unfortunately, such detection is not+    possible on Windows, leaving windows users no way to pipe binary+    output.  So we have changed the behavior in the following way:++    + Output to stdout is allowed when it can be determined that+      the output is being piped (on non-Windows platforms).+    + If the `-o` option is not used, binary output is never sent+      to stdout by default; instead, an error is raised.+    + If `-o -` is used, binary output is sent to stdout, regardless+      of whether it is being piped. This works on Windows too.++  * Better error behavior:  uses of `error` have been replaced by+    raising of `PandocError`, which can be trapped and handled by the+    calling program.++  * Removed `hard_line_breaks` extension from `markdown_github` (#3594).+    GitHub has two Markdown modes, one for long-form documents like READMEs+    and one for short things like issue coments. In issue comments, a line+    break is treated as a hard line break. In README, wikis, etc., it is+    treated as a space as in regular Markdown.  Since pandoc is more likely to+    be used to convert long-form documents from GitHub Markdown,+    `-hard_line_breaks` is a better default.++  * Include `backtick_code_blocks` extension in `mardkown_mmd` (#3637).++  * Escape `MetaString` values (as added with `-M/--metadata` flag) (#3792).+    Previously they would be transmitted to the template without any+    escaping.  Note that `--M title='*foo*'` yields a different result from++        ---+        title: *foo*+        ---++    In the latter case, we have emphasis; in the former case, just+    a string with literal asterisks (which will be escaped+    in formats, like Markdown, that require it).++  * Allow `em`, `cm`, `in` for image height/width in HTML, LaTeX (#3450).++  * HTML writer: Insert `data-` in front of unsupported attributes.  Thus,+    a span with attribute `foo` gets written to HTML5 with `data-foo`, so+    it is valid HTML5.  HTML4 is not affected.  This will allow us to use+    custom attributes in pandoc without producing invalid HTML. (With help+    from Wandmalfarbe, #3817.)++  * Plain writer:  improved super/subscript rendering.  We now+    handle more non-digit characters for which there are+    sub/superscripted unicode characters.  When unicode+    sub/superscripted characters are not available, we use+    `_(..)` or `^(..)` (#3518).++  * Docbook, JATS, TEI writers: print INFO message when omitting interior+    header (#3750).  This only applies to section headers inside list items,+    e.g., which were otherwise silently omitted.++  * Change to `--reference-links` in Markdown writer (#3701).  With+    `--reference-location` of `section` or `block`, pandoc will now repeat+    references that have been used in earlier sections.  The Markdown+    reader has also been modified, so that *exactly* repeated references+    do not generate a warning, only references with the same label but+    different targets.  The idea is that, with references after every block,+    one might want to repeat references sometimes.++  * ODT/OpenDocument writer:++    + Support `lang` attribute (#1667).+    + Added support for `--toc` (#2836).  Thanks to @anayrat.++  * Docx writer:++    + `lang` meta, see #1667 (Mauro Bieg, #3515).+    + Change `FigureWithCaption` to `CaptionedFigure` (iandol, #3658).+    + Use `Table` rather than `Table Normal` for table style (#3275).+      `Table Normal` is the default table style and can't be modified.+    + Pass through comments (#2994).  We assume that comments are defined as+      parsed by the docx reader:++        I want <span class="comment-start" id="0" author="Jesse Rosenthal"+        date="2016-05-09T16:13:00Z">I left a comment.</span>some text to+        have a comment <span class="comment-end" id="0"></span>on it.++      We assume also that the id attributes are unique and properly+      matched between comment-start and comment-end.+    + Bookmark improvements.  Bookmark start/end now surrounds content rather+      than preceding it.  Bookmarks generated for Div with id+      (jgm/pandoc-citeproc#205).+    + Add `keywords` metadata to docx document properties (Ian).++  * RST writer: support unknown interpreted text roles by+    parsing them as `Span` with `role` attributes (#3407).  This+    way they can be manipulated in the AST.++  * HTML writer:++    + Line block: Use class instead of style attribute (#1623).  We now+      issue `<div class="line-block">` and include a default definition+      for `line-block` in the default templates, instead of hard-coding a+      `style` on the div.+    + Add class `footnoteBack` to footnote back references (Timm Albers).+      This allows for easier CSS styling.+    + Render SmallCaps as span with smallcaps class (#1592), rather than+      using a style attribute directly.  This gives the user more flexibility+      in styling small caps in CSS.+    + With reveal.js we use `data-src` instead of `src` for images for+      lazy loading.+    + Special-case `.stretch` class for images in reveal.js (#1291).+      Now in reveal.js, an image with class `stretch` in a paragraph+      by itself will stretch to fill the whole screen, with no+      caption or figure environment.++  * Added warnings for non-rendered blocks to writers.++  * Writers now raise an error on template failure.++  * When creating a PDF via LaTeX, warn if the font is missing some+    characters (#3742).++  * Remove initial check for PDF-creating program (#3819).+    Instead, just try running it and raise the exception if it+    isn't found at that point.  This improves things for users of Cygwin+    on Windows, where the executable won't be found by `findExecutable`+    unless `.exe` is added.  The same exception is raised as before, but+    at a later point.++  * Readers issue warning for duplicate header identifiers (#1745).+    Autogenerated header identifiers are given suffixes so as not to clash+    with previously used header identifiers. But they may still coincide with+    an explicit identifier that is given for a header later in the document,+    or with an identifier on a div, span, link, or image. We now issue+    a warning in this case, so users can supply an explicit identifier.++  * CommonMark reader now supports `emoji`, `hard_line_breaks`, `smart`,+    and `raw_html` extensions.++  * Markdown reader:++    + Don't allow backslash + newline to affect block structure (#3730).+      Note that as a result of this change, the following, which formerly+      produced a header with two lines separated by a line break, will+      now produce a header followed by a paragraph:++        # Hi\+        there++      This may affect some existing documents that relied on+      this undocumented and unintended behavior.  This change makes pandoc+      more consistent with other Markdown implementations, and with itself+      (since the two-space version of a line break doesn't work inside ATX+      headers, and neither version works inside Setext headers).+++  * Org reader (Albert Krewinkel, unless noted):++    + Support `table.el` tables (#3314).+    + Support macros (#3401).+    + Support the `#+INCLUDE:` file inclusion mechanism (#3510).+      Recognized include types are `example`, `export`, `src`, and+      normal org file inclusion.  Advanced features like line numbers+      and level selection are not implemented yet.+    + Interpret more meta value as inlines.  The values of the following+      meta variables are now interpreted using org-markup instead of+      treating them as pure strings: `keywords` (comma-separated list of+      inlines), `subtitle` (inline values), `nocite` (inline values, can+      be repeated).+    + Support `\n` export option (#3940).  This turns all newlines in the+      text into hard linebreaks.++  * RST reader:++    + Improved admonition support (#223).  We no longer add an+      `admonition` class, we just use the class for the type of admonition,+      `note` for example.  We put the word corresponding to the label in+      a paragraph inside a `Div` at the beginning of the admonition with+      class `admonition-title`.  This is about as close as we can get to+      RST's own output.+    + Initial support of `.. table` directive.  This allows adding captions+      to tables.+    + Support `.. line-block` directive.  This is deprecated but may still+      be in older documents.+    + Support scale and align attributes of images (#2662).+    + Implemented implicit internal header links (#3475).+    + Support RST-style citations (#853).  The citations appear at the end+      of the document as a definition list in a special div with id+      `citations`. Citations link to the definitions.+    + Recurse into bodies of unknown directives (#3432).+      In most cases it's better to preserve the content than+      to emit it.  This isn't guaranteed to have good results;+      it will fail spectacularly for unknown raw or verbatim directives.+    + Handle chained link definitions (#262).  For example,++          .. _hello:+          .. _goodbye: example.com++      Here both `hello` and `goodbye` should link to `example.com`.+    + Support anchors (#262).  E.g.++          `hello`++          .. _hello:++          paragraph++      This is supported by putting "paragraph" in a `Div` with id `hello`.+    + Support `:widths:` attribute for table directive.+    + Implement csv-table directive (#3533).  Most attributes are supported,+      including `:file:` and `:url:`.+    + Support unknown interpreted text roles by parsing them as Span+      with "role" attributes (#3407).  This way they can be manipulated in+      the AST.++  * HTML reader: parse a span with class `smallcaps` as `SmallCaps`.++  * LaTeX reader:+ +    + Implemented `\graphicspath` (#736).+    + Properly handle column prefixes/suffixes.  For example, in+      `\begin{tabular}{>{$}l<{$}>{$}l<{$} >{$}l<{$}}`+      each cell will be interpreted as if it has a `$`+      before its content and a `$` after (math mode).+    + Handle komascript `\dedication` (#1845).  It now adds a+      `dedication` field to metadata.  It is up to the user to supply+      a template that uses this variable.+    + Support all `\textXX` commands, where XX = `rm`, `tt`, `up`, `md`,+      `sf`, `bf` (#3488).  Spans with a class are used when there is+      nothing better.+    + Expand `\newenvironment` macros (#987).+    + Add support for LaTeX subfiles package (Marc Schreiber, #3530).+    + Better support for subfigure package (#3577).+      A figure with two subfigures turns into two pandoc+      figures; the subcaptions are used and the main caption+      ignored, unless there are no subcaptions.+    + Add support for `\vdots` (Marc Schreiber, #3607).+    + Add basic support for hyphenat package (Marc Schreiber, #3603).+    + Add basic `\textcolor` support (Marc Schreiber).+    + Add support for `tabularx` environment (Marc Schreiber, #3632).+    + Better handling of comments inside math environments (#3113).+      This solves a problem with commented out `\end{eqnarray}` inside+      an eqnarray (among other things).+    + Parse tikzpicture as raw verbatim environment if `raw_tex` extension+      is selected (#3692).  Otherwise skip with a warning.  This is better+      than trying to parse it as text!+    + Add `\colorbox` support (Marc Schreiber).+    + Set identifiers on Spans used for `\label`.+    + Have `\setmainlanguage` set `lang` in metadata.+    + Support etoolbox's `\ifstrequal`.+    + Support `plainbreak`, `fancybreak` et al from the memoir class+      (bucklereed, #3833).+    + Support `\let`.  Also, fix regular macros so they're expanded at the+      point of use, and NOT also the point of definition.  `\let` macros,+      by contrast, are expanded at the point of definition.  Added an+      `ExpansionPoint` field to `Macro` to track this difference.+    + Support simple `\def` macros.  Note that we still don't support+      macros with fancy parameter delimiters, like `\def\foo#1..#2{...}`.+    + Support `\chaptername`, `\partname`, `\abstractname`, etc.  (#3559,+      obsoletes #3560).+    + Put content of `\ref`, `\label`, `\eqref` commands into `Span` with+      attributes, so they can be handled in filters (Marc Schreiber, #3639)+    + Add Support for `glossaries` and `acronym` package (Marc Schreiber,+      #3589). Acronyms are not resolved by the reader, but acronym and+      glossary information is put into attributes on Spans so that they+      can be processed in filters.+    + Use `Link` instead of `Span` for `\ref`.  This makes more sense+      semantically and avoids unnecessary `Span [Link]` nestings when+      references are resolved.+    + Rudimentary support for `\hyperlink`.+    + Support `\textquoteleft|right`, `\textquotedblleft|right` (#3849).+    + Support `\lq`, `\rq`.+    + Implement `\newtoggle`, `\iftoggle`, `\toggletrue|false` from etoolbox+      (#3853).+    + Support `\RN` and `\Rn`, from biblatex (bucklereed, #3854).+    + Improved support for `\hyperlink`, `\hypertarget` (#2549).+    + Support `\k` ogonek accent.+    + Improve handling of accents.  Handle ogonek, and fall back correctly+      with forms like `\"{}`.+    + Better support for ogonek accents.+    + Support for `\faCheck` and `\faClose` (Marc Schreiber, #3727).+    + Support for `xspace` (Marc Schreiber, #3797).+    + Support `\setmainlanguage` or `\setdefaultlanguage` (polyglossia)+      and `\figurename`.+    + Better handling of `\part` in LaTeX (#1905).  Now we parse chapters as+      level 0 headers, and parts as level -1 headers.  After parsing, we+      check for the lowest header level, and if it's less than 1 we bump+      everything up so that 1 is the lowest header level.  So `\part` will+      always produce a header; no command-line options are needed.+    + Add block version of `\textcolor` (Marc Schreiber).+    + `\textcolor` works as inline and block command (Marc Schreiber).+    + `\textcolor` will be parse as span at the beginning of a paragraph+      (Marc Schreiber).+    + Read polyglossia/babel `\text(LANG){...}` (bucklereed)+    + Improved handling of include files in LaTeX reader (#3971).+      Previously `\include` wouldn't work if the included file+      contained, e.g., a begin without a matching end.+    + Support `\expandafter` (#3983).+    + Handle `\DeclareRobustCommand` (#3983).  Currently it's just treated+      as a synonym for `\newcommand`.+    + Handle `\lettrine` (Mauro Bieg).++  * Math improvements due to updates in texmath:++    + Improved handling of accents and upper/lower delimiters.+    + Support for output in GNU eqn format (used with *roff).+    + Allow `\boldsymbol` + a token without braces, and similarly+      with other styling commands.+    + Improve parsing of `\mathop` to allow multi-character operator names.+    + Add thin space after math operators when "faking it with+      unicode."++  * `walk` is now used instead of `bottomUp` in the `ToJSONFilter`+    instance for `a -> [a]` (pandoc-types).  Note that behavior+    will be slightly different, since `bottomUp`'s treatment of+    a function `[a] -> [a]` is to apply it to each sublist of a+    list, while walk applies it only to maximal sublists.+    Usually the latter behavior is what is wanted, and the+    former can be simulated when needed.  But there may be+    existing filters that need to be rewritten in light of the+    new behavior.  Performance should be improved.++  * There are some changes to syntax highlighting due to revisions+    in the `skylighting` library:++    + Support for `powershell` has been added, and many syntax+      definitions have been updated.+    + Background colors have been added to the `kate` style.+    + The way highlighted code blocks are formatted in HTML has+      been changed (David Baynard), in ways that may require+      changes in hard-coded CSS affecting highlighting.+      (If you haven't included hard-coded highlighting CSS in+      your template, you needn't change anything.)+++### API changes++  * New module `Text.Pandoc.Class` (Jesse Rosenthal, John MacFarlane).+    This contains definitions of the `PandocMonad` typeclass, the+    `PandocIO` and `PandocPure` monads, and associated functions.++  * Changed types of all writers and readers.++    + We now use `Text` instead of `String` in the interface (#3731).+      (We have not yet changed the internals of most readers to work+      with `Text`, but making this change in the API now opens up a+      path to doing that.)+    + The result is now of form `m a` with constraint `PandocMonad m`.+      Readers and writers can be combined to form monadic values which+      can be run using either `runIO` or `runPure`.  If `runIO` is used,+      then both readers and writers will be able to do IO when needed+      (for include files, for example); if `runPure` is used,+      then the functions are pure and will not touch IO.+    + Where previously you used+      `writeRST def (readMarkdown def "[foo](url)")`, now you+      would use+      `runPure $ readMarkdown def (pack "[foo](url)") >>= writeRST def`.++  * New module `Text.Pandoc.Readers` (Albert Krewinkel).  This+    contains reader helper functions formerly defined in the+    top-level `Text.Pandoc` module.++    + Changed `StringReader` -> `TextReader`.+    + `getReader` now returns a pair of a reader and+      `Extensions`, instead of building the extensions into the+      reader (#3659).  The calling code must explicitly set+      `readerExtensions` using the `Extensions` returned.  The+      point of the change is to make it possible for the calling+      code to determine what extensions are being used.++  * New module `Text.Pandoc.Writers` (Albert Krewinkel).+    This contains writer helper functions formerly defined in the+    top-level `Text.Pandoc` module.++    + Changed `StringWriter` -> `TextWriter`.+    + `getWriter` now retuns a pair of a reader and+      `Extensions`, instead of building the extensions into the+      reader (#3659).  The calling code must explicitly set+      `readerExtensions` using the `Extensions` returned.  The+      point of the change is to make it possible for the calling+      code to determine what extensions are being used.++  * New module `Text.Pandoc.Lua`, exporting `runLuaFilter` (Albert Krewinkel,+    #3514).++  * New module `Text.Pandoc.App`.  This abstracts out the functionality+    of the command line program (`convertWithOpts`), so it can be reproduced+    e.g. in a desktop or web application.  Instead of exiting, we throw errors+    (#3548), which are caught (leading to exit) in pandoc.hs, but allow other+    users of `Text.Pandoc.App` to recover.  `pandoc.hs` is now a 2-liner.+    The module also exports some utility functions for parsing options+    and running filters.++  * New module `Text.Pandoc.Logging` (exported module) (#3392).+    This now contains the `Verbosity` definition previously in+    `Text.Pandoc.Options`, as well as a new `LogMessage` datatype that will+    eventually be used instead of raw strings for warnings.  This will enable+    us, among other things, to provide machine-readable warnings if desired.+    Include ToJSON instance and showLogMessage.  This gives us the possibility+    of both machine-readable and human-readable output for log messages.++  * New module `Text.Pandoc.BCP47`, with `getLang`, `Lang(..)`, `parseBCP47`.++  * New module `Text.Pandoc.Translations`, exporting `Term`,+    `Translations`, `readTranslations`.++  * New module `Text.Pandoc.Readers.LaTeX.Types', exporting `Macro`, `Tok`,+    `TokType`, `Line`, `Column`.++  * `Text.Pandoc.Error`: added many new constructors for `PandocError`.++  * Expose some previously private modules (#3260).  These are often+    helpful to people writing their own reader or writer modules:++    + `Text.Pandoc.Writers.Shared`+    + `Text.Pandoc.Parsing`+    + `Text.Pandoc.Asciify`+    + `Text.Pandoc.Emoji`+    + `Text.Pandoc.ImageSize`+    + `Text.Pandoc.Highlighting`+`+  * New module `Text.Pandoc.Extensions` (Albert Krewinkel):+    Extension parsing and processing functions were defined in the top-level+    `Text.Pandoc` module.  These functions are moved to the Extensions+    submodule as to enable reuse in other submodules.++  * Add `Ext_raw_attribute` constructor for `Extension`.++  * Add `Ext_fenced_divs` constructor for `Extension'.++  * Add `Ext_four_space_rule` constructor in `Extension`.++  * Add `Ext_gfm_auto_identifiers` constructor for `Extension`.++  * Add `Monoid` instance for `Extensions`.++  * Add `Text.Pandoc.Writers.Ms`, exporting `writeMs`.++  * Add `Text.Pandoc.Writers.JATS`, exporting `writeJATS`.++  * Add `Text.Pandoc.Writers.Muse`, exporting `writeMuse`.++  * Add `Text.Pandoc.Readers.Muse`, exporting `readMuse`.++  * Add `Text.Pandoc.Readers.TikiWiki`, exporting `readTikiWiki`.++  * Add `Text.Pandoc.Readers.Vimwiki`, exporting `readVimwiki`.++  * Add `Text.Pandoc.Readers.Creole`, exporting `readCreole`.++  * Export `setVerbosity` from `Text.Pandoc`.++  * `Text.Pandoc.Pretty`: Add `Eq` instance for `Doc`.++  * `Text.Pandoc.XML`: `toEntities`: changed type to `Text -> Text`.++  * `Text.Pandoc.UTF8`:++    + Export `fromText`, `fromTextLazy`, `toText`, `toTextLazy`.+      Define `toString`, `toStringLazy` in terms of them.+    + Add new functions parameterized on `Newline`: `writeFileWith`,+      `putStrWith`, `putStrLnWith`, `hPutStrWith`, `hPutStrLnWith`.++  * `Text.Pandoc.MediaBag`: removed `extractMediaBag`.++  * `Text.Pandoc.Highlighting`:++    + `highlighting` now returns an Either rather than Maybe.+      This allows us to display error information returned by the skylighting+      library.  Display a warning if the highlighting library throws an error.+    + Add parameter for `SyntaxMap` to `highlight`.++  * `Text.Pandoc.Writers.Math`:++    + Export `defaultMathJaxURL`, `defaultKaTeXURL`.  This will ensure that+      we only need to update these in one place.++  * `Text.Pandoc.SelfContained`:++    + Removed `WriterOptions` parameter from `makeSelfContained`.+    + Put `makeSelfContained` in PandocMonad instead of IO.  This removes+      the need to pass MediaBag around and improves exceptions.  It also+      opens up the possibility of using makeSelfContained purely.+    + Export `makeDataURI`.++  * `Text.Pandoc.ImageSize`:++    + Export `lengthToDim`, new function `scaleDimension`.+    + Export `inEm` from ImageSize (#3450).+    + Change `showFl` and `show` instance for `Dimension` so+      extra decimal places are omitted.+    + Added `Em` as a constructor of `Dimension`.+    + Add `WriterOptions` parameter to `imageSize` signature (Mauro Bieg).++  * `Text.Pandoc.Templates`:++    + Change type of `renderTemplate'`.  Now it runs in `PandocMonad`+      and raises a proper `PandocTemplateError` if there are problems, rather+      than failing with uncatchable `error`.+    + Change signature of `getDefaultTemplate`.  Now it runs in any instance+      of `PandocMonad`, and returns a `String` rather than an `Either` value.+      And it no longer takes a `datadir` parameter, since this can be+      retrieved from `CommonState`.++  * `Text.Pandoc.Options`:++    + Added `writerEpubSubdirectory` to `WriterOptions` (#3720).+      The EPUB writer now takes its EPUB subdirectory from this option.+    + In `WriterOptions`, rename `writerLaTeXEngine` to `writerPdfEngine`+      and `writerLaTeXArgs` to `writerPdfArgs` (Mauro Bieg, #3909).+    + Add `writerSyntaxMap` to `WriterOptions`.+    + Removed `writerEpubStylesheet` from `WriterOptions`.+    + Remove `writerUserDataDir` from `WriterOptions`.  It is now carried+      in `CommonState` in `PandocMonad` instances.  (And thus it can be used+      by readers too.)+    + Changed `writerEpubMetadata` to a `Maybe String`.+    + Removed `readerApplyMacros` from `ReaderOptions`.  Now we just check+      the `latex_macros` reader extension.+    + FromJSON/ToJSON instances for `ReaderOptions`.+    + In `HTMLMathMethod`, the `KaTeX` contsructor now takes only+      one string (for the KaTeX base URL), rather than two.+    + Removed `writerSourceURL` from `WriterOptions`.  We now use+      `stSourceURL` in `CommonState`, which is set by `setInputFiles`.++  * `Text.Pandoc.Shared`:++    + `tabFilter` now takes a `Text`, not `String`.+    + `openURL`: Changed type from an Either.  Now it will just raise+      an exception to be trapped later.+    + Remove `normalizeSpaces` (#1530).+    + Remove `warn`.  (Use `report` from `Text.Pandoc.Class` instead.)+    + Export a new function `crFilter`.+    + Add `eastAsianLineBreakFilter` (previously in Markdown reader).+    + Provide custom `isURI` that rejects unknown schemes.+      (Albert Krewinkel, #2713).  We also export the set of known+      `schemes`.  The new function replaces the function of the same name+      from `Network.URI`, as the latter did not check whether a scheme is+      well-known.  All official IANA schemes (as of 2017-05-22) are+      included in the set of known schemes.  The four non-official schemes+      `doi`, `isbn`, `javascript`, and `pmid` are kept.+    + Remove `err`.+    + Remove `readDataFile`, `readDefaultDataFile`, `getReferenceDocx`,+      `getReferenceODT`. These now live in `Text.Pandoc.Class`,+      where they are defined in terms of `PandocMonad`+      primitives and have different signatures.+    + Remove `openURL`.  Use `openURL` from `Text.Pandoc.Class` instead.+    + Add `underlineSpan`.++  * `Text.Pandoc.Readers.HTML`: export new `NamedTag` class.++  * `Text.Pandoc.Readers.Markdown`: remove `readDocxWithWarnings`.+     With the new API one can simply use `getLog` after running+     the reader.++  * `Text.Pandoc.Readers.LaTeX`: Changed types for `rawLaTeXInline`+     and `rawLaTeXBlock`.  (Both now return a `String`, and they are+     polymorphic in state.)+++### Bug fixes and under-the-hood improvements++  * TEI writer: Added identifiers on `<div>` elements.++  * DokuWiki reader: Better handling for code block in list item (#3824).++  * Custom writer: Remove old preprocesesor conditionals (Albert Krewinkel).++  * ZimWiki writer: Removed internal formatting from note and table cells,+    because ZimWiki does not support it (Alex Ivkin, #3446).++  * MediaWiki writer:++    + Updated list of syntax highlighting languages (#3461).+      Now `r` gets you `<source>` rather than `<code>` (among others).+    + Add display attribute on `<math>` tags (#3452).  This allows display+      math to be rendered properly.+    + Remove newline before `</ref>` (#2652).+    + Don't softbreak lines inside list items (#3531).++  * Org writer:++    + Reduce to two spaces after bullets (#3417, Albert Krewinkel).+    + Add unit tests (Alexander Krotov).+    + Stop using raw HTML to wrap divs (Albert Krewinkel, #3771).+    + Do not strip `#` from Org anchor links (Alexander Krotov).++  * CommonMark writer:++    + Avoid excess blank lines at end of output.+    + Prefer pipe tables to HTML tables even if it means losing relative+      column width information (#3734).+    + Support table, strikethrough extensions, when enabled (as with gfm).+      Note that we bypass the commonmark writer from cmark and construct our+      own pipe tables, with better results.+    + Properly support `--wrap=none`.+    + Use smallcaps class for `SmallCaps` (#1592).+    + Omit "fig:" prefix in image titles.  This is used internally to+      indicate internal figures.++  * RST writer:++    + Properly handle table captions.+    + Don't wrap lines in in definition list terms.  Wrapping is not allowed.+    + Implemented `+/-smart` and improved escaping with `+smart`.+    + Add empty comments when needed to avoid including a blockquote+      in the indented content of a preceding block (#3675).+    + Improve grid table output, fix bug with empty rows (#3516).+      Uses the new `gridTable` in Writers.Shared, which is here+      improved to better handle 0-width cells.+    + Remove space at beginning/end of RST code span (#3496).  Otherwise+      we get invalid RST.  There seems to be no way to escape the space.+    + Add header anchors when header has non-standard id (#3937).+    + Correctly handle inline code containing backticks, using a `:literal:`+      role (#3974).+    + Don't backslash-escape word-internal punctuation (#3978).++  * Markdown writer:++    + Don't include variables in metadata blocks.  Previously variables set+      on the command line were included in e.g. YAML metadata, contrary to+      documentation and intentions.+    + Improved escaping with `+smart`.+    + Fixed grid tables embedded in grid tables (#2834).+    + Use span with class 'smallcaps' for SmallCaps, instead of a style+      attribute as before (#1592).+    + Escape initial `%` in a paragraph if the `pandoc_title_blocks`+      extension is enabled (#3454).  Otherwise in a document starting with+      a literal `%` the first line is wrongly interpreted as a title.+    + Fixed false ordered lists in YAML metadata (#3492, #1685).  Now we+      properly escape things that would otherwise start ordered lists,+      such as++          ---+          title: 1. inline+          ...+    + Better handling of tables with empty columns (#3337).  We now+      calculate the number of columns based on the longest row (or the+      length of aligns or widths).+    + Escape unordered list markers at beginning of paragraph (#3497), to+      avoid false interpretation as a list.+    + Escape `|` appropriately.+    + Ensure space before list at top level (#3487).+    + Avoid spurious blanklines at end of document after tables and list,+      for example.+    + Fixed bugs in simple/multiline list output (#3384).+      Previously we got overlong lists with `--wrap=none`.  This is fixed.+      Previously a multiline list could become a simple list (and would+      always become one with `--wrap=none`).+    + Don't emit a simple table if `simple_tables` disabled (#3529).+    + Case-insensitive reference links (David A Roberts, #3616).+      Ensure that we do not generate reference links whose labels differ only+      by case.  Also allow implicit reference links when the link+      text and label are identical up to case.+    + Put space before reference link definitions (Mauro Bieg, #3630).+    + Better escaping for links (David A. Roberts, #3619).  Previously the+      Markdown writer would sometimes create links where there were none+      in the source.  This is now avoided by selectively escaping bracket+      characters when they occur in a place where a link might be created.+    + Added missing `\n` (David A. Roberts, #3647).+    + Fixed duplicated reference links with `--reference-links`+      and `--reference-location=section` (#3674).  Also ensure that there+      are no empty link references `[]`.+    + Avoid inline surround-marking with empty content (#3715).+      E.g. we don't want `<strong></strong>` to become `****`.+      Similarly for emphasis, super/subscript, strikeout.+    + Don't allow soft break in header (#3736).+    + Make sure `plain`, `markdown_github`, etc. work for raw.+      Previously only `markdown` worked.  Note: currently a raw block labeled+      `markdown_github` will be printed for any `markdown` format.+    + Ensure that `+` and `-` are escaped properly so they don't cause+      spurious lists (#3773).  Previously they were only+      if succeeded by a space, not if they were at end of line.+    + Use pipe tables if `raw_html` disabled and `pipe_tables` enabled,+      even if the table has relative width information (#3734).+    + Markdown writer: don't crash on `Str ""`.+    + Make `Span` with null attribute transparent.  That is, we don't use+      brackets or `<span>` tags to mark spans when there are no attributes;+      we simply output the contents.+    + Escape pipe characters when `pipe_tables` enabled (#3887).+    + Better escaping of `<` and `>`.  If `all_symbols_escapable` is set,+      we backslash escape these.  Otherwise we use entities as before.+    + When writing plain, don't use `&nbsp;` to separate list and indented+      code.  There's no need for it in this context, since this isn't to be+      interpreted using Markdown rules.+    + Preserve classes in JS obfuscated links (Timm Albers, #2989).+      HTML links containing classes originally now preserve them when using+      javascript email obfuscation.+    + Render `SmallCaps` as a native span when `native_spans` are enabled.+    + Always write attributes with `bracketed_spans` (d-dorazio).++  * Man writer:++    + Fix handling of nested font commands (#3568).  Previously pandoc emitted+      incorrect markup for bold + italic, for example, or bold + code.+    + Avoid error for definition lists with no definitions (#3832).++  * DocBook writer:++    + Fix internal links with `writerIdentifierPrefix opt`+      (#3397, Mauro Bieg).++  * Docx writer:++    + Don't include bookmarks on headers unless non-null id (#3476).+    + Support 9 levels of headers (#1642).+    + Allow 9 list levels (#3519).+    + Don't take `distArchive` from datadir (#3322).  The docx writer takes+      components from the distribution's version of `reference.docx` when it+      can't find them in a user's custom `reference.docx`.  Previously, we+      allowed a `reference.docx` in the data directory (e.g. `~/.pandoc`)+      to be used as the distribution's reference.docx.  This led to a+      bizarre situation where pandoc would produce a good docx using+      `--template ~/.pandoc/ref.docx`, but if `ref.docx` were moved to+      `~/.pandoc/reference.docx`, it would then produce a corrupted docx.+    + Fixed handling of soft hyphen (0173) (#3691).+    + Better handling of keywords (#3719).+    + Cleaner code for handling dir and style attributes for `Div`.+    + Use `Set` for dynamic styles to avoid duplicates.+    + Removed redundant element from data/docx/word/numbering.xml.+      The elements we need are generated when the document is+      compiled; this didn't do anything.+    + Activate `evenAndOddHeaders` from reference docx (#3901,+      Augustín Martín Barbero).++  * ODT/OpenDocument writer:++    + Calculate aspect ratio for percentage-sized images (Mauro Bieg, #3239).+    + Use more widely available bullet characters (#1400).  The old+      characters weren't available in some font sets.  These seem to work+      well on Windows and Linux versions of LibreOffice.+    + Wider labels for lists (#2421).  This avoids overly narrow labels for+      ordered lists with `()` delimiters.  However, arguably it creates+      overly wide labels for bullets.  Also, lists now start flush with+      the margin, rather than indented.+    + Fixed dropped elements in some ordered lists (#2434).++  * FB2 writer:++    + Don't render `RawBlock` as code.+    + Don't fail with an error on interior headers (e.g. in list) (#3750).+      Instead, omit them with an INFO message.+    + Add support for "lang" metadata (Alexander Krotov, #3625).+    + Format `LineBlock` as poem (Alexander Krotov).  Previously writer+      produced one paragraph with `<empty-line/>` elements, which are not+      allowed inside `<p>` according to FB2 schema.+    + Replace `concatMap` with `cMap` (Alexander Krotov).+    + Write FB2 lists without nesting blocks inside `<p>` (Alexander+      Krotov, #4004)++  * HTML writer:++    + Make sure `html4`, `html5` formats work for raw blocks/inlines.+    + Render raw inline environments when `--mathjax` used (#3816).+      We previously did this only with raw blocks, on the assumption+      that math environments would always be raw blocks. This has changed+      since we now parse them as inline environments.+    + Ensure we don't get two style attributes for width and height.+    + Report when not rendering raw inline/block.+    + Issue warning if no title specified and template used (#3473).+    + Info message if `lang` is unspecified (#3486).+    + Removed unused parameter in `dimensionsToAttributeList`.+    + Avoid two class attributes when adding `uri` class (#3716).+    + Fix internal links with `writerIdentifierPrefix opt` (#3397, Mauro+      Bieg).+    + Use revealjs's math plugin for mathjax (#3743).  This is a thin+      wrapper around mathjax that makes math look better on revealjs.+    + Slidy:  use h1 for all slides, even if they were originally+      level 2 headers (#3566).  Otherwise the built-in table of contents+      in Slidy breaks.++  * LaTeX writer:++    + Don't render LaTeX images with data: URIs (#3636).  Note that+      `--extract-media` can be used when the input contains data: URIs.+    + Make highlighted code blocks work in footnotes (Timm Albers).+    + Don't use figure inside table cell (#3836).+    + Use proper code for list enumerators (#3891).  This should fix problems+      with lists that don't use arabic numerals.+    + Always add hypertarget when there's a non-empty identifier (#2719).+      Previously the hypertargets were only added when there was actually+      a link to that identifier.+    + Use `%` after hypertarget before code block.+    + Add `\leavevmode` before hypertarget at start of paragraph (#2704,+      fixes formatting problems in beamer citations).+    + Don't use `lstinline` in `\item[..]` (#645).  If you do, the contents+      of item disappear or are misplaced.  Use `\texttt` instead.+    + Fix problem with escaping in `lstinline` (#1629).  Previously the+      LaTeX writer created invalid LaTeX when `--listings` was specified and+      a code span occurred inside emphasis or another construction.+    + Fix error with line breaks after empty content (#2874).  LaTeX+      requires something before a line break, so we insert a `~` if no+      printable content has yet been emitted.+    + Use BCP47 parser.+    + Fixed detection of otherlangs (#3770).  We weren't recursing into+      inline contexts.+    + Handle language in inline code with `--listings` (#3422).+    + Write euro symbol directly in LaTeX (Andrew Dunning, #3801).+      The textcomp package allows pdfLaTeX to parse `€` directly, making the+      `\euro` command unneeded.+    + Fixed footnotes in table captions (#2378).  Note that if the table has+      a first page header and a continuation page header, the notes will+      appear only on the first occurrence of the header.+    + In `writeBeamer` output, allow hyperlinks to frames (#3220).+      Previously you could link to a header above or below slide level but+      not *to* slide level.  This commit changes that.  Hypertargets are+      inserted inside frame titles; technically the reference is to just+      after the title, but in normal use (where slides are viewed full+      screen in a slide show), this does not matter.+    + Remove `\strut` at beginning of table cells (#3436).  This fixes a+      problem with alignment of lists in table cells.  The `\strut` at the+      end seems to be enough to avoid the too-close spacing that motivated+      addition of the strut  in #1573.+    + Add partial siunitx Support (Marc Schreiber, #3588).++  * ConTeXt writer:++    + Refactored to use BCP47 module.+    + Remove unnecessary `$` (Alexander Krotov, #3482).+    + Use header identifiers for chapters (#3968).++  * EPUB writer:++    + `title_page.xhtml` is now put in `text/`.+    + Don't strip formatting in TOC (#1611).++  * Textile reader:++    + Fix bug for certain links in table cells (#3667).+    + Allow 'pre' code in list item (#3916).++  * HTML reader:++    + Added warnings for ignored material (#3392).+    + Better sanity checks to avoid parsing unintended things as+      raw HTML in the Markdown reader (#3257).+    + Revise treatment of `li` with `id` attribute (#3596).  Previously we+      always added an empty div before the list item, but this created+      problems with spacing in tight lists.  Now we do this: If the list+      item contents begin with a `Plain` block, we modify the `Plain`+      block by adding a `Span` around its contents.  Otherwise, we add a+      `Div` around the contents of the list item (instead of adding an+      empty `Div` to the beginning, as before).+    + Add `details` tag to list of block tags (#3694).+    + Removed `button` from block tag list (#3717).  It is already in the+      `eitherBlockOrInlineTag` list, and should be both places.+    + Use `Set`s instead of lists for block tag lookup.+    + Rewrote to use `Text` throughout.  Effect on memory usage is modest+      (< 10%).+    + Use the lang value of `<html>` to set the lang meta value (bucklereed,+      #3765).+    + Ensure that paragraphs are closed properly when the parent block+      element closes, even without `</p>` (#3794).+    + Parse `<figure>` and `<figcaption>` (Mauro Bieg, #3813).+    + Parse `<main>` like `<div role=main>` (bucklereed, #3791).+      `<main>` closes `<p>` and behaves like a block element generally+    + Support column alignments (#1881).  These can be set either+      with a `width` attribute or with `text-width` in a `style` attribute.+    + Modified state type to be an instance of `HasLogMessages`, so+      `registerHeader` can issue warnings.+    + `</td>` or `</th>` should close any open block tag (#3991).+    + `<td>` should close an open `<th>` or `<td>`.+    + `htmlTag` improvements (#3989).  We previously failed on cases+      where an attribute contained a `>` character. This patch fixes the+      bug, which especially affects raw HTML in Markdown.++  * Txt2Tags reader:++    + Newline is not indentation (Alexander Krotov).++  * MediaWiki reader:++    + Allow extra hyphens after `|-` in tables (#2649).+    + Allow blank line after table start (#2649).+    + Fixed more table issues (#2649).+    + Ensure that list starts begin at left margin (#2606).  Including when+      they're in tables or other list items.+    + Make smart double quotes depend on `smart` extension (#3585).+    + Don't do curly quotes inside `<tt>` contexts (#3585).  Even if `+smart`.+    + Modified state type to be an instance of `HasLogMessages`, so+      `registerHeader` can issue warnings.++  * TWiki reader (Alexander Krotov):++    + Remove unnecessary `$` (#3597).+    + Simplify `linkText` (#3605).++  * EPUB reader:++    + Minor refactoring, avoiding explicit MediaBag handling.+      This all works behind the scenes in CommonState plumbing.++  * Docx reader:++    + Don't drop smartTag contents (#2242).+    + Handle local namespace declarations (#3365).  Previously we didn't+      recognize math, for example, when the xmlns declaration occurred on+      the element and not the root.+    + More efficient trimSps (#1530).  Replacing `trimLineBreaks`.  This+      does the work of `normalizeSpaces` as well, so we avoid the need for+      that function here.+    + Avoid 0-level headers (Jesse Rosenthal, #3830).  We used to parse+      paragraphs styled with "HeadingN" as "nth-level header." But if a+      document has a custom style named "Heading0", this will produce a+      0-level header, which shouldn't exist. We only parse this style+      if N>0. Otherwise we treat it as a normal style name, and+      follow its dependencies, if any.+    + Add tests for avoiding zero-level header (Jesse Rosenthal).++  * ODT reader:++    + Replaced `collectRights` with Rights from `Data.Either`.+    + Remove dead code (Albert Krewinkel).++  * Org reader (Albert Krewinkel, unless noted).++    + Don't allow tables inside list items (John MacFarlane, #3499).+    + Disallow tables on list marker lines (#3499).+    + Convert markup at beginning of footnotes (John MacFarlane, #3576).+    + Allow emphasized text to be followed by `[` (#3577).+    + Handle line numbering switch for src blocks.+      The line-numbering switch that can be given to source blocks (`-n` with+      an start number as an optional parameter) is parsed and translated to a+      class/key-value combination used by highlighting and other readers and+      writers.+    + Stop adding rundoc prefix to src params.  Source block parameter names+      are no longer prefixed with `rundoc`. This was intended to simplify+      working with the rundoc project, a babel runner. However, the rundoc+      project is unmaintained, and adding those markers is not the reader's+      job anyway.  The original language that is specified for a source+      element is now retained as the `data-org-language` attribute and only+      added if it differs from the translated language.+    + Allow multi-word arguments to src block params (#3477).  The reader now+      correctly parses src block parameter list even if parameter arguments+      contain multiple words.+    + Avoid creating `nullMeta` by applying `setMeta` directly+      (Alexander Krotov).+    + Replace `sequence . map` with `mapM`.+    + Fix smart parsing behavior.  Parsing of smart quotes and special+      characters can either be enabled via the `smart` language extension or+      the `'` and `-` export options. Smart parsing is active if either the+      extension or export option is enabled.  Only smart parsing of special+      characters (like ellipses and en and em dashes) is enabled by default,+      while smart quotes are disabled.  Previously, all smart parsing was+      disabled unless the language extension was enabled.+    + Subject full doc tree to headline transformations (Albert Krewinkel,+      #3695).  Emacs parses org documents into a tree structure, which is+      then post-processed during exporting. The reader is changed to do the+      same, turning the document into a single tree of headlines starting+      at level 0.+    + Fix cite parsing behaviour (Herwig Stuetz).  Until now, `org-ref`+      cite keys included special characters also at the end. This caused+      problems when citations occur right before colons or at the end of+      a sentence.  With this change, all non alphanumeric characters at+      the end of a cite key are ignored.  This also adds `,` to the list+      of special characters that are legal in cite keys to better mirror+      the behaviour of org-export.+    + Fix module names in haddock comments.  Copy-pasting had lead to+      haddock module descriptions containing the wrong module names.+    + Recognize babel result blocks with attributes (#3706).  Babel+      result blocks can have block attributes like captions and names.+      Result blocks with attributes were not recognized and were parsed+      as normal blocks without attributes.+    + Include tags in headlines.  The Emacs default is to include tags in the+      headline when exporting.  Instead of just empty spans, which contain the+      tag name as attribute, tags are rendered as small caps and wrapped in+      those spans.  Non-breaking spaces serve as separators for multiple tags.+    + Respect export option for tags (#3713).  Tags are appended to+      headlines by default, but will be omitted when the `tags` export option+      is set to nil.+    + Use `tag-name` attribute instead of `data-tag-name`.+    + Use `org-language` attribute rather than `data-org-language`.+    + Modified state type to be an instance of `HasLogMessages`, so+      `registerHeader` can issue warnings.+    + End footnotes after two blank lines.  Footnotes can not only be+      terminated by the start of a new footnote or a header, but also by two+      consecutive blank lines.+    + Update emphasis border chars (#3933).  The org reader was updated to+      match current org-mode behavior: the set of characters which are+      acceptable to occur as the first or last character in an org emphasis+      have been changed and now allows all non-whitespace chars at the+      inner border of emphasized text (see `org-emphasis-regexp-components`).++  * RST reader:++    + Fixed small bug in list parsing (#3432).  Previously the parser didn't+      handle properly this case:++          * - a+            - b+          * - c+            - d+    + Handle multiline cells in simple tables (#1166).+    + Parse list table directive (Keiichiro Shikano, #3432).+    + Make use of `anyLineNewline` (Alexander Krotov, #3686).+    + Use `anyLineNewline` in `rawListItem` (Alexander Krotov, #3702).+    + Reorganize block parsers for ~20% faster parsing.+    + Fixed `..include::` directive (#3880).+    + Handle blank lines correctly in line blocks (Alexander Krotov, #3881).+      Previously pandoc would sometimes combine two line blocks separated+      by blanks, and ignore trailing blank lines within the line block.+    + Fix indirect hyperlink targets (#512).++  * Markdown reader:++    + Allow attributes in reference links to start on next line (#3674).+    + Parse YAML metadata in a context that sees footnotes defined in+      the body of the document (#1279).+    + When splitting pipe table cells, skip tex math (#3481).+      You might have a `|` character inside math.  (Or for that matter+      something that the parser might mistake for raw HTML.)+    + Treat span with class `smallcaps` as SmallCaps.+      This allows users to specify small caps in Markdown this way:+      `[my text]{.smallcaps}` (#1592).+    + Fixed internal header links (#2397).+      This patch also adds `shortcut_reference_links` to the list+      of mmd extensions.+    + Treat certain environments as inline+      when they occur without space surrounding them (#3309, #2171).+      E.g. equation, math.  This avoids incorrect vertical space+      around equations.+    + Optimized `nonindentSpaces`.  Makes the benchmark go from 40 to 36 ms.+    + Allow latex macro definitions indented 1-3 spaces.+      Previously they only worked if nonindented.+    + Improved parsing of indented raw HTML blocks (#1841).+      Previously we inadvertently interpreted indented HTML as+      code blocks.  This was a regression.  We now seek to determine the+      indentation level of the contents of an HTML block, and (optionally)+      skip that much indentation.  As a side effect, indentation may be+      stripped off of raw HTML blocks, if `markdown_in_html_blocks` is+      used. This is better than having things interpreted as indented+      code blocks.+    + Fixed smart quotes after emphasis (#2228).  E.g. in `*foo*'s 'foo'`.+    + Warn for notes defined but not used (#1718).+    + Use `anyLineNewline` (Alexander Krotov).+    + Interpret YAML metadata as Inlines when possible (#3755).  If+      the metadata field is all on one line, we try to interpret it as+      Inlines, and only try parsing as Blocks if that fails.  If it+      extends over one line (including possibly the `|` or `>` character+      signaling an indented block), then we parse as Blocks.  This was+      motivated by some German users finding that `date: '22. Juin 2017'`+      got parsed as an ordered list.+    + Fixed spurious parsing as citation as reference def (#3840).+      We now disallow reference keys starting with `@` if the+      `citations` extension is enabled.+    + Parse `-@roe` as suppress-author citation (pandoc-citeproc#237).+      Previously only `[-@roe]` (with brackets) was recognized as+      suppress-author, and `-@roe` was treated the same as `@roe`.+    + Fixed parsing of fenced code after list when there is no intervening+      blank line (#3733).+    + Allow raw latex commands starting with `\start` (#3558).  Previously+      these weren't allowed because they were interpreted as starting+      ConTeXt environments, even without a corresponding `\stop`...+    + Added `inlines`, `inlines1`.+    + Require nonempty alt text for `implicit_figures` (#2844).+      A figure with an empty caption doesn't make sense.+    + Removed texmath macro material; now all this is handled+      in the LaTeX reader functions.+    + Fixed bug with indented code following raw LaTeX (#3947).++  * LaTeX reader:++    + Rewrote LaTeX reader with proper tokenization (#1390,+      #2118, #3236, #3779, #934, #982).  This rewrite is primarily+      motivated by the need to get macros working properly.  A side benefit+      is that the reader is significantly faster.  We now tokenize the+      input text, then parse the token stream.  Macros modify the token+      stream, so they should now be effective in any context, including+      math. Thus, we no longer need the clunky macro processing+      capacities of texmath.+    + Parse `\,` to `\8198` (six-per-em space) (Henri Werth).+    + Allow `\newcommand\foo{blah}` without braces.+    + Support `\lstinputlisting` (#2116).+    + Issue warnings when skipping unknown latex commands (#3392).+    + Include contents of `\parbox`.+    + Allow `\hspace` and `\vspace` to count as raw block or inline.+      Previously we would refuse to parse anything as raw inline if+      it was in the `blockCommands` list.  Now we allow exceptions+      if they're listed under ignoreInlines in inlineCommands.+      This should make it easier e.g. to include an `\hspace`+      between two side-by-side raw LaTeX tables.+    + Don't drop contents of `\hypertarget`.+    + Handle spaces before `\cite` arguments.+    + Allow newpage, clearpage, pagebreak in inline contexts as well as+      block contexts (#3494).+    + Treat `{{xxx}}` the same as `{xxx}` (#2115).+    + Use `pMacroDefinition` in macro (for more direct parsing).+      Note that this means that `macro` will now parse one+      macro at a time, rather than parsing a whole group together.+    + Fixed failures on `\ref{}`, `\label{}` with `+raw_tex`.  Now these+      commands are parsed as raw if `+raw_tex`; otherwise, their argument+      is parsed as a bracketed string.+    + Don't crash on empty `enumerate` environment (#3707).+    + Handle escaped `&` inside table cell (#3708).+    + Handle block structure inside table cells (#3709).  `minipage` is no+      longer required.+    + Handle some width specifiers on table columns (#3709).  Currently+      we only handle the form `0.9\linewidth`.  Anything else would have+      to be converted to a percentage, using some kind arbitrary assumptions+      about line widths.+    + Make sure `\write18` is parsed as raw LaTeX.  The change is in the+      LaTeX reader's treatment of raw commands, but it also affects the+      Markdown reader.+    + Fixed regression with starred environment names (#3803).+    + Handle optional args in raw `\titleformat` (#3804).+    + Improved heuristic for raw block/inline.  An unknown command at the+      beginning of the line that could be either block or inline is+      treated as block if we have a sequence of block commands followed by+      a newline or a `\startXXX` command (which might start a raw ConTeXt+      environment).+    + Don't remove macro definitions from the output, even if+      `Ext_latex_macros` is set, so that macros will be applied.+      Since they're only applied to math in Markdown, removing the macros+      can have bad effects.  Even for math macros, keeping them should be+      harmless.+    + Removed `macro`.  It is no longer necessary, since the+      `rawLaTeXBlock` parser will parse macro definitions.  This also avoids+      the need for a separate `latexMacro` parser in the Markdown reader.+    + Use `label` instead of `data-label` for label in caption (#3639).+    + Fixed space after `\figurename` etc.+    + Resolve references to section numbers.+    + Fix `\let\a=0` case, with single character token.+    + Allow `@` as a letter in control sequences.  `@` is commonly used+      in macros using `\makeatletter`.  Ideally we'd make the tokenizer+      sensitive to `\makeatletter` and `\makeatother`, but until then this+      seems a good change.+    + Track header numbers and correlate with labels.+    + Allow `]` inside group in option brackets (#3857).+    + lstinline with braces can be used (verb cannot be used with braces)+      (Marc Schreiber, #3535).+    + Fix keyval function: pandoc did not parse options in braces correctly+      (Marc Schreiber, #3642).+    + When parsing raw LaTeX commands, include trailing space (#1773).+      Otherwise things like `\noindent foo` break and turn into+      `\noindentfoo`.  Affects `-f latex+raw_tex` and `-f markdown` (and other+      formats that allow `raw_tex`).+    + Don't treat "..." as Quoted (#3958).  This caused quotes to be omitted in+      `\texttt` contexts.+    + Add tests for existing `\includegraphics` behaviour (Ben Firshman).+    + Allow space before `=` in bracketd options (Ben Firshman).+    + Be more forgiving in parsing command options.  This was needed, for+      example, to make some minted options work.+    + Strip off quotes in `\include` filenames.++  * Added `Text.Pandoc.CSV`, simple (unexported) CSV parser.++  * `Text.Pandoc.PDF`:++    + Got `--resource-path` working with PDF output (#852).+    + Fetch images when generating PDF via context (#3380).+      To do this, we create the temp directory as a subdirectory+      of the working directory. Since context mk IV by default looks+      for images in the parent directory, this works.+    + Use `report` instead of `warn`, make it sensitive to verbosity settings.+    + Use `fillMediaBag` and `extractMedia` to extract media to temp dir.+      This reduces code duplication.+    + `html2pdf`: use stdin instead of intermediate HTML file+    + Removed useless `TEXINPUTS` stuff for `context2pdf`.  mkiv context+      doesn't use `TEXINPUTS`.++  * `Text.Pandoc.Pretty`:++    + Simplified definition of `realLength`.+    + Don't error for blocks of size < 1.  Instead, resize to 1 (see #1785).++  * `Text.Pandoc.MIME`:++    + Use `application/javascript` (not `application/x-javascript`).+    + Added `emf` to mimeTypes with type `application/x-msmetafile` (#1713).++  * `Text.Pandoc.ImageSize`:++    + Improve SVG image size code (Marc Schreiber, #3580).+    + Make `imageSize` recognize basic SVG dimensions (Mauro Bieg, #3462).++  * Use `Control.Monad.State.Strict` throughout.  This gives 20-30% speedup+    and reduction of memory usage in most of the writers.++  * Use `foldrWithKey` instead of deprecated `foldWithKey`.++  * `Text.Pandoc.SelfContained`:++    + Fixed problem with embedded fonts (#3629).+    + Refactored getData from `getDataURI` in `SelfContained`.+    + Don't use data URIs for script or style (#3423).  Instead, just use+      script or style tags with the content inside.  The old method with+      data URIs prevents certain optimizations outside pandoc.  Exception:+      data URIs are still used when a script contains `</script>` or a+      style contains `</`.+    + SelfContained: Handle URL inside material retrieved from a URL+      (#3629).  This can happen e.g. with an @import of a google web font.+      (What is imported is some CSS which contains an url reference+      to the font itself.) Also, allow unescaped pipe (|) in URL.+    + Load resources from `data-src` (needed for lazy loading in+      reveal.js slide shows).+    + Handle `data-background-image` attribute on section (#3979).++  * `Text.Pandoc.Parsing`:++    + Added `indentWith` (Alexander Krotov, #3687).+    + Added `stateCitations` to `ParserState`.+    + Removed `stateChapters` from `ParserState`.+    + In `ParserState`, make `stateNotes'` a Map, add `stateNoteRefs`.+    + Added `gobbleSpaces` and `gobbleAtMostSpaces`.+    + Adjusted type of `insertIncludedFile` so it can be used with token+      parser.+    + Replace old texmath macro stuff from Parsing.  Use Macro from+      Text.Pandoc.Readers.LaTeX.Types instead.+    + Export `insertIncludedFile`.+    + Added `HasLogMessages`, `logMessage`, `reportLogMessages` (#3447).+    + Replace partial with total function (Albert Krewinkel).+    + Introduce `HasIncludeFiles` type class (Albert Krewinkel).  The+      `insertIncludeFile` function is generalized to work with all parser+      states which are instances of that class.+    + Add `insertIncludedFilesF` which returns F blocks (Albert Krewinkel).+      The `insertIncludeFiles` function was generalized and renamed+      to `insertIncludedFiles'`; the specialized versions are based on that.+    + `many1Till`: Check for the end condition before parsing (Herwig+      Stuetz).  By not checking for the end condition before the first+      parse, the parser was applied too often, consuming too much of the+      input. This only affects `many1Till p end` where `p` matches on a+      prefix of `end`.+    + Provide `parseFromString` (#3690).  This is a version of+      `parseFromString` specialied to ParserState, which resets+      `stateLastStrPos` at the end.  This is almost always what we want.+      This fixes a bug where `_hi_` wasn't treated as emphasis in the+      following, because pandoc got confused about the position of the+      last word: `- [o] _hi_`.+    + Added `takeP`, `takeWhileP` for efficient parsing of `[Char]`.+    + Fix `blanklines` documentation (Alexander Krotov, #3843).+    + Give less misleading line information with `parseWithString`.+      Previously positions would be reported past the end of the chunk.+      We now reset the source position within the chunk and report+      positions "in chunk."+    + Add `anyLineNewline` (Alexander Krotov).+    + Provide shared F monad functions for Markdown and Org readers+      (Albert Krewinkel).  The `F` monads used for delayed evaluation+      of certain values in the Markdown and Org readers are based on a+      shared data type capturing the common pattern of both `F` types.+    + Add `returnF` (Alexander Krotov).+    + Avoid parsing `Notes:**` as a bare URI (#3570).  This avoids parsing+      bare URIs that start with a scheme + colon + `*`, `_`, or `]`.+    + Added `readerAbbreviations` to `ParserState`.  Markdown reader+      now consults this to determine what is an abbreviation.+    + Combine grid table parsers (Albert Krewinkel, #3638).  The grid table+      parsers for markdown and rst was combined into one single+      parser `gridTable`, slightly changing parsing behavior of both+      parsers: (1) The markdown parser now compactifies block content+      cell-wise: pure text blocks in cells are now treated as paragraphs+      only if the cell contains multiple paragraphs, and as plain blocks+      otherwise. Before, this was true only for single-column tables. (2)+      The rst parser now accepts newlines and multiple blocks in header+      cells.+    + Generalize tableWith, gridTableWith (Albert Krewinkel).+      The parsing functions `tableWith` and `gridTableWith` are generalized+      to work with more parsers. The parser state only has to be an+      instance of the `HasOptions` class instead of requiring a concrete+      type. Block parsers are required to return blocks wrapped into a+      monad, as this makes it possible to use parsers returning results+      wrapped in `Future`s.++  * `Text.Pandoc.Shared`:++    + Simplify `toRomanNumeral` using guards (Alexander Krotov, #3445)+    + `stringify`: handle Quoted better (#3958).  Previously we were losing+      the quotation marks in Quoted elements.++  * `Text.Pandoc.Writers.Shared`:++    + Export `metaToJSON'`, `addVariablesToJSON` (#3439).+      This allows us to add the variables AFTER using the metadata+      to generate a YAML header (in the Markdown writer).+    + Added `unsmartify` (previously in RST writer).+      Undo literal double curly quotes.  Previously we left these.+    + Generalize type of `metaToJSON` so it can take a Text.  Previously a+      String was needed as argument; now any ToJSON instance will do.+    + Added `gridTable` (previously in Markdown writer).+    + `gridTable`: Refactored to use widths in chars.+    + `gridTable`:  remove unnecessary extra space in cells.+    + Fixed `addVariablesToJSON`.  It was previously not allowing multiple+      values to become lists.+    + Pipe tables: impose minimum cell size (see #3526).+++### Default template changes++  * HTML templates (including EPUB and HTML slide show templates):++    + Make default.html5 polyglot markup conformant (John Luke Bentley,+      #3473).  Polyglot markup is HTML5 that is also valid XHTML. See+      <https://www.w3.org/TR/html-polyglot>.  With this change, pandoc's+      html5 writer creates HTML that is both valid HTML5 and valid XHTML.+    + Regularized CSS in html/epub/html slide templates (#3485).+      All templates now include `code{white-space: pre-wrap}`+      and CSS for `q` if `--html-q-tags` is used.  Previously some templates+      had `pre` and others `pre-wrap`; the `q` styles were only sometimes+      included.+    + CSS for `.smallcaps`, (Mauro Bieg, #1592)+    + `default.revealjs`: make `history` default to true.+    + `default.revealjs`: use lazy loading (#2283).+    + `default.revealjs`: add `mathjax` variable and some conditional code+      to use the MathJaX plugin.+    + `default.slidy` uses `https` instead of `http` (ickc, #3848).+    + `default.dzslides`: Load Google Font using HTTPS by default+      (Yoan Blanc).++  * DocBook5 template: Use `lang` and `subtitle` variables (Jens Getreu,+    #3855).++  * LaTeX/Beamer template:++    + Combine LaTeX/Beamer templates (Andrew Dunning, #3878).+      `default.beamer` has been removed; beamer now uses the+      `default.latex` template.  Beamer-specific parts are conditional+      on the `beamer` variable set by the writer. Note that+      `pandoc -D beamer` will return this (combined) template.+    + Use `xcolor` for `colorlinks` option (Andrew Dunning, #3877).+      Beamer loads `xcolor` rather than `color`, and thus the+      `dvipsnames` option doesn't take effect. This also provides a wider+      range of colour selections with the `svgnames` option.+    + Use starred versions of `xcolor` names (Andrew Dunning).+      Prevents changes to documents defined using the `dvipsnames` list (e.g.+      `Blue` gives a different result with svgnames enabled).+    + Load `polyglossia` after header-includes (#3898).  It needs to be+      loaded as late as possible.+    + Use `unicode-math` (Vaclav Haisman).  Use `mathspec` with only+      XeLaTeX on request.+    + Don't load `fontspec` before `unicode-math` (over there).+      The `unicode-math` package loads `fontspec` so explict loading of+      `fontspec` before `unicode-math` is not necessary.+    + Use `unicode-math` by default in default.latex template.  mathspec will+      be used in xelatex if the `mathspec` variable is set; otherwise+      unicode-math will be used (Václav Haisman).+    + Use `dvipsnames` options when `colorlinks` specified (otherwise+      we get an error for `maroon`) (Thomas Hodgson).+    + Added beamer `titlegraphic` and `logo` variables (Thomas Hodgson).+    + Fix typo in fix for notes in tables (#2378, zeeMonkeez).+    + Fix `hyperref` options clash (Andrew Dunning, #3847) Avoids an options+      clash when loading a package (e.g. `tufte-latex`) that uses+      `hyperref` settings different from those in the template.+    + Add `natbiboptions` variable (#3768).+    + Fix links inside captions in LaTeX output with links-as-notes+      (Václav Haisman, #3651).  Declare our redefined `\href` robust.+    + Load `parskip` before `hyperref` (Václav Haisman, #3654).+    + Allow setting Japanese fonts when using LuaLaTeX (Václav Haisman,+      #3873).  by using the `luatexja-fontspec` and `luatexja-preset`+      packages. Use existing `CJKmainfont` and `CJKoptions` template+      variables. Add `luatexjafontspecoptions` for `luatexja-fontspec`+      and `luatexjapresetoptions` for `luatexja-preset`.+    + Added `aspectratio` variable to beamer template (Václav Haisman,+      #3723).+    + Modified template.latex to fix XeLaTex being used with tables+      (lwolfsonkin, #3661).  Reordered `lang` variable handling to+      immediately before `bidi`.++  * ConTeXt template: Improved font handling: `simplefonts` is now+    obsolete in ConTeXt (Pablo Rodríguez).+++### Documentation improvements++  * MANUAL.txt:++    + Add URL for Prince HTML > PDF engine (Ian, #3919).+    + Document that content above slide-level will be omitted in+      slide shows.  See #3460, #2265.+    + Explain `--webtex` SVG url (Mauro Bieg, #3471)+    + Small clarification in YAML metadata section.+    + Document that html4 is technically XHTML 1.0 transitional.+    + Remove refs to highlighting-kate (#3672).+    + Document ibooks specific epub metadata.+    + Clarify that mathml is used for ODT math.+    + Mention limitations of Literate Haskell Support (#3410,+      Joachim Breitner).+    + Add documentation of limitations of grid tables (Stephen+      McDowell, #3864).+    + Clarify that meta-json contains transformed values (Jakob Voß,+      #3491) Make clear that template variable `meta-json` does not+      contain plain text values or JSON output format but field values+      transformed to the selected output format.++  * COPYRIGHT:++    + Clarify that templates are dual-licensed.+    + Clarify that pandoc-types is BSD3 licensed.+    + List new files not written by jgm (Albert Krewinkel).+    + Update dates in copyright notices (Albert Krewinkel).  This follows+      the suggestions given by the FSF for GPL licensed software.+      <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>++  * INSTALL.md:++    + Improved instructions for tests with patterns.+    + Put RPM-based distros on separate point (Mauro Bieg, #3449)++  * CONTRIBUTING.md:++    + Fixed typos (Wandmalfarbe, #3479).+    + Add "ask on pandoc-discuss" (Mauro Bieg).++  * Add lua filter documentation in `doc/lua-filters.md`.  Note that the+    end of this document is autogenerated from `data/pandoc.lua`+    using `make doc/lua-filters.md`, which uses `tools/ldoc.ltp`+    (Albert Krewinkel).++  * Add `doc/filters.md`. This is the old scripting tutorial from+    the website.++  * Add `doc/using-the-pandoc-api.md` (#3289).  This gives an introduction+    to using pandoc as a Haskell library.+++### Build infrastructure improvements++  * Removed `data/templates` submodule.  Templates are now a subtree+    in `data/templates`.  This removes the need to do `git submodule+    update`.++  * Renamed `tests` -> `test`.++  * Remove `https` flag.  Always build with HTTPS support.++  * Use `file-embed` instead of `hsb2hs` to embed data files when+    `embed_data_files` flag is set.  `file-embed` gives us better dependency+    tracking:  if a data file changes, ghc/stack/cabal know to recompile+    the Data module.  This also removes `hsb2hs` as a build dependency.++  * Add `custom-setup` stanza to pandoc, lowercase field names.++  * Add `static` Cabal flag.++  * Name change OSX -> MacOS.  Add a -MacOS suffix to mac package rather+    than -OSX.  Changed local names from osx to macos.++  * make_macos_package.sh - Use strip to reduce executable size.++  * Revised binary linux package.  Now a completely static executable+    is created, using Docker and alpine.  We create both a deb and a+    tarball.  The old `deb` directory has been replaced with a `linux`+    directory.  Running `make` in the `linux` directory should+    perform the build, putting the binary packages in `artifacts/`.++  * `linux/control.in`: add `Replaces:`, so existing pandoc-citeproc and+    pandoc-data packages will be uninstalled; this package provides+    both (#3822).  Add latex packages as 'suggested', update+    description.++  * Remove cpphs build requirement -- it is no longer needed.++  * Replaced `{deb,macos,windows}/stack.yaml` with `stack.pkg.yaml`.++  * Name change OSX -> macOS (ickc, #3869).++  * Fix casing of Linux, UNIX, and Windows (ickc).++  * `.travis.yml`:  create a source dist and do cabal build and test there.+    That way we catch errors due to files missing from the data+    section of pandoc.cabal.++  * Makefile:++    + Split `make haddock` from `make full`.+    + Add BRANCH variable for winpkg.+    + Add `lint` target.+    + Improve `make full`. Disable optimizations.+      Build everything, inc. trypandoc and benchmarks.  Use parallel build.+    + Allow `make test` to take `TESTARGS`.++  * Added new command tests (`Tests.Command`), using small text files+    in `test/command/`.  Any files added in this directory will be treated+    as shell tests (see smart.md for an example).  This makes it very easy+    to add regression tests etc.++  * Test fixes so we can find data files.  In old tests & command tests,+    we now set the environment variable `pandoc_datadir`.  In lua tests,+    we set the datadir explicitly.++  * Refactored `compareOutput` in docx writer test.++  * Consolidated some common functions in `Tests.Helper`.++  * Small change to unbalanced bracket test to speed up test suite.++  * Speed up Native writer quickcheck tests.++  * Use tasty for tests rather than test-framework.++  * Add simple Emacs mode to help with Pandoc templates editing.+    (Václav Haisman, #3889). `tools/pandoc-template-mode.el`+++## pandoc 1.19.2.4 (2017-09-10)++  * Add dependencies on texmath and skylighting to the executable.+    This is needed for dependency version numbers to be available,+    with Cabal > 2.++## pandoc 1.19.2.3 (2017-09-09) ++  * Add CPP to Setup.hs so it works with Cabal >= 2 and < 2.++## pandoc 1.19.2.2 (2017-09-08)++  * Fix build with GHC 8.2.1 (#3876, Peter Simons).  Setup.hs does not+    compile with Cabal 2.x, so we require an earlier version via+    setup-depends.  The following packages need newer versions with+    GHC 8.2.1 and had their constraints relaxed accordingly:+    executable-path, process, syb, and time.++## pandoc 1.19.2.1 (2017-01-31)++  * Require skylighting >= 0.1.1.4.+  * Adjust test output for skylighting version.+  * Relax upper bounds on blaze-html and blaze-markup.++## pandoc 1.19.2 (2017-01-29)++  * Use skylighting library instead of highlighting-kate for syntax+    highlighting. Skylighting is faster and more accurate (#3363).+    Later we'll be able to add features like warning messages, dynamic+    loading of xml syntax definitions, and dynamic loading of themes.++  * Added a new highlight style, `breezeDark`.++  * Text.Pandoc.Highlighting: Update list of `listings` languages (#3374).+    This allows more languages to be used when using the `--listings`+    option.++  * OpenDocument writer:++    + Small refactoring.  Removed separate 'parent' parameter in paraStyle.+    + Don't profilerate text styles unnecessarily (#3371).+      This change makes the writer create only as many temporary+      text styles as are absolutely necessary. It also consolidates+      adjacent nodes with the same style.++  * Org reader (Albert Krewinkel):++    + Allow short hand for single-line raw blocks (Albert Krewinkel,+      #3366).  Single-line raw blocks can be given via `#+FORMAT: raw line`,+      where `FORMAT` must be one of `latex`, `beamer`, `html`, or `texinfo`.+    + Accept org-ref citations followed by commas (Albert Krewinkel).+      Bugfix for an issue which, whenever the citation was immediately+      followed by a comma, prevented correct parsing of org-ref citations.+    + Ensure emphasis markup can be nested.  Nested emphasis markup (e.g.+      `/*strong and emphasized*/`) was interpreted incorrectly in that the+      inner markup was not recognized.+    + Remove pipe char irking the haddock coverage tool (Albert Krewinkel).++  * Docx reader: Empty header should be list of lists (Jesse Rosenthal).+    In the past, the docx reader wrote an empty header as an empty list. It+    should have the same width as a row (and be filled with empty cells).++  * MediaWiki reader:++    + Improved handling of display math (#3362).  Sometimes display math is+      indented with more than one colon.  Previously we handled these cases+      badly, generating definition lists and missing the math.+    + Fix quotation mark parsing (#3336, tgkokk).  Change MediaWiki reader's+      behavior when the smart option is parsed to match other readers'+      behavior.++  * Markdown reader:++    + Fixed `-f markdown_github-hard_line_breaks+escaped_line_breaks`+      (#3341).  Previously this did not properly enable escaped line breaks.+    + Disallow space between inline code and attributes (#3326, #3323,+      Mauro Bieg).++  * DocBook5 writer: make id attribute xml:id, fixes #3329 (#3330, Mauro Bieg).++  * Added some test cases for ODT reader (#3306, #3308, Hubert Plociniczak).++  * LaTeX writer: allow tables with empty cells to count as "plain."+    This addresses a problem of too-wide tables when empty cells+    are used.  Thanks to Joost Kremers for reporting the issue.++  * Org writer: prefix footnote numbers with `fn:` (Albert Krewinkel).+    Unprefixed numbers where used by older org-mode versions, but are no+    longer supported.++  * HTML writer: don't process pars with empty RawInline, (#1040, #3327,+    Mauro Bieg).++  * Markdown writer: Fix display math with `--webtex` (#3298).++  * Fix sample.lua so it properly handles raw blocks/inlines (#3358,+    bumper314).++  * Templates:++    + default.latex: Moved geometry after hyperref (Václav Haisman).+      Otherwise PDF sizes can be wrong in some circumstances.+    + Copied a few changes from default.latex to default.beamer+      (Wandmalfarbe).+    + default.latex, default.beamer: Changed position of `\VerbatimNotes`+      and `fancyvrb`.  This fixes hyperlinks on footnotes in documents+      that contain verbatim in notes (#3361).  (Note: the beamer template+      was updated to match the LaTeX template, but at this point verbatim+      in notes seems not to work in beamer.)+    + default.latex: Allow passing `microtypeoptions` to microtype+      (Václav Haisman).+    + default.latex: Add hyphen option to url package.+    + default.docbook5: Fix namespace declarations (Mauro Bieg).++  * Moved `make_osx_package.sh` to `osx/` directory.++  * Travis continuous integration:++    + Fix false positives with dist build.+    + Speed improvements (Kolen Cheung, #3304, #3357).++  * MANUAL.txt:++    + Clarify that blank space is needed around footnotes (#3352).+    + Fixed typo (#3351, Alexey Rogechev).+    + Note that `--wrap=auto` does not work in HTML output.+    + Default `--columns` width is 72, not 80.+    + Fixed broken links (#3316, Kolen Cheung).+    + Document usage of `@*` in nocite section (#3333, John Muccigrosso).++  * INSTALL.md:++    + Indent code so it's properly formatted (#3335, Bheesham Persaud).+    + Added instructions for extracting binary from OSX, Windows packages.++  * CONTRIBUTING.md: Describe labels currently used in issue tracker+    (Albert Krewinkel).  The labels have changed over time, the list of+    labels is updated to reflect the current set of labels used in the+    issue tracker.++  * Rearrange and extend badges in README (Albert Krewinkel, #3354)++  * Bumped version bounds for dependencies.+++## pandoc 1.19.1 (2016-12-10)++  * Set `PANDOC_VERSION` environment variable for filters (#2640).+    This allows filters to check the pandoc version that produced+    the JSON they are receiving.++  * Docx reader: Ensure one-row tables don't have header (#3285,+    Jesse Rosenthal).  Tables in MS Word are set by default to have+    special first-row formatting, which pandoc uses to determine whether+    or not they have a header. This means that one-row tables will, by+    default, have only a header -- which we imagine is not what people+    want. This change ensures that a one-row table is not understood to+    be a header only.  Note that this means that it is impossible to+    produce a header-only table from docx, even though it is legal+    pandoc. But we believe that in nearly all cases, it will be an+    accidental (and unwelcome) result++  * HTML reader:++    + Fixed some bad regressions in HTML table parser (#3280).+      This regression leads to the introduction of empty rows+      in some circumstances.+    + Understand `style=width:` as well as `width` in `col` (#3286).++  * RST reader:++    + Print warnings when keys, substitition, notes not found.+      Previously the parsers failed and we got raw text.  Now we get a+      link with an empty URL, or empty inlines in the case of a note or+      substitution.++    + Fix hyperlink aliases (#3283).++  * Man writer: Ensure that periods are escaped at beginning of line+    (#3270).++  * LaTeX writer: Fix unnumbered headers when used with `--top-level`+    (#3272, Albert Krewinkel). Fix interaction of top-level+    divisions `part` or `chapter` with unnumbered headers when+    emitting LaTeX. Headers are ensured to be written using+    stared commands (like `\subsection*{}`).++  * LaTeX template: use comma not semicolon to separate keywords for+    `pdfkeywords`.  Thanks to Wandmalfarbe.++  * Markdown writer: Fixed incorrect word wrapping (#3277).+    Previously pandoc would sometimes wrap lines too early due to+    this bug.++  * Text.Pandoc.Pretty:  Added `afterBreak` [API change].  This makes it+    possible to insert escape codes for content that needs escaping at the+    beginning of a line.++  * Removed old MathMLInHTML.js from 2004, which should no longer+    be needed for MathML with modern browsers.++  * Fixed tests with dynamic linking (#2709).++  * Makefile: Use stack instead of cabal for targets.  This is just+    a convenience for developers.++  * Fixed bash completion of filenames with space (#2749).++  * MANUAL: improved documentation on how to create a custom+    `reference.docx`.++  * Fix minor spelling typos in the manual (#3273, Anthony Geoghegan)++## pandoc 1.19 (2016-12-01)++  * Changed resolution of filter paths.++    + We now first treat the argument of `--filter` as a full (absolute+      or relative) path, looking for a program there. If it's found, we+      run it.+    + If not, and if it is a simple program name or a relative path, we+      try resolving it relative to `$DATADIR/filters`.+    + If this fails, then we treat it as a program name and look in the+      user's PATH.+    + Removed a hardcoded '/' that may have caused problems with+      Windows paths.++    Previously if you did `--filter foo` and you had `foo` in your path and+    also an executable `foo` in your working directory, the one in the path+    would be used. Now the one in the working directory is used.++    In addition, when you do `--filter foo/bar.hs`, pandoc will now find a+    filter `$DATADIR/filters/foo/bar.hs` -- assuming there isn't a+    `foo/bar.hs` relative to the working directory.++  * Allow `file://` URIs as arguments (#3196). Also improved default reader+    format detection. Previously with a URI ending in .md or .markdown,+    pandoc would assume HTML input. Now it treats these as markdown.++  * Allow to overwrite top-level division type heuristics (#3258,+    Albert Krewinkel). Pandoc uses heuristics to determine the most+    reasonable top-level division type when emitting LaTeX or+    Docbook markup. It is now possible to overwrite this implicitly set+    top-level division via the `top-level-division` command line parameter.++  * Text.Pandoc.Options \[API changes\]:++    + Removed `writerStandalone` field in `WriterOptions`, made+      `writerTemplate` a `Maybe` value. Previously setting+      `writerStandalone = True` did nothing unless a template was provided+      in writerTemplate. Now a fragment will be generated if+      `writerTemplate` is `Nothing`; otherwise, the specified template+      will be used and standalone output generated.+    + `Division` has been renamed `TopLevelDivision` (#3197). The+      `Section`, `Chapter`, and `Part` constructors were renamed to+      `TopLevelSection`, `TopLevelChapter`, and+      `TopLevelPart`, respectively. An additional `TopLevelDefault`+      constructor was added, which is now also the new default value of+      the `writerTopLevelDivision` field in `WriterOptions`.++  * Improved error if they give wrong arg to `--top-level-division`.++  * Use new module from texmath to lookup MS font codepoints in Docx reader.+    Removed unexported module Text.Pandoc.Readers.Docx.Fonts. Its code now+    lives in texmath (0.9).++  * DocBook reader: Fixed xref lookup (#3243). It previously only worked+    when the qnames lacked the docbook namespace URI.++  * HTML reader:++    + Improved table parsing (#3027). We now check explicitly for non-1+      rowspan or colspan attributes, and fail when we encounter them.+      Previously we checked that each row had the same number of cells,+      but that could be true even with rowspans/colspans. And there are+      cases where it isn't true in tables that we can handle fine -- e.g.+      when a tr element is empty. So now we just pad rows with empty cells+      when needed.+    + Treat `<math>` as MathML by default unless something else is+      explicitly specified in xmlns. Provided it parses as MathML,+      of course. Also fixed default which should be to inline math if no+      display attribute is used.+    + Only treat "a" element as link if it has href (#3226). Otherwise+      treat as span.++  * Docx reader (Jesse Rosenthal):++    + Add a placeholder value for CHART. We wrap `[CHART]` in a+      `<span class="chart">`. Note that it maps to inlines because, in+      docx, anything in a drawing tag can be part of a larger paragraph.+    + Be more specific in parsing images We not only want `w:drawing`,+      because that could also include charts. Now we specify+      `w:drawing/pic:pic`. This shouldn't change behavior at all, but it's+      a first step toward allowing other sorts of drawing data as well.+    + Abstract out function to avoid code repetition.+    + Update tests for img title and alt (#3204).+    + Handle Alt text and titles in images. We use the "description" field+      as alt text and the "title" field as title. These can be accessed+      through the "Format Picture" dialog in Word.+    + Docx reader utils: handle empty namespace in `elemName`. Previously,+      if given an empty namespace `(elemName ns "" "foo")` `elemName`+      would output a QName with a `Just ""` namespace. This is never what+      we want. Now we output a `Nothing`. If someone *does* want a+      `Just ""` in the namespace, they can enter the QName+      value explicitly.++  * ODT reader/writer:++    + Inline code when text has a special style (Hubert Plociniczak). When+      a piece of text has a text `Source_Text` then we assume that this is+      a piece of the document that represents a code that needs to+      be inlined. Adapted the writer to also reflect that change.+      Previously it was just writing a 'preformatted' text using a+      non-distinguishable font style. Code blocks are still not recognized+      by the ODT reader. That's a separate issue.+    + Infer table's caption from the paragraph (#3224,+      Hubert Plociniczak). ODT's reader always put empty captions for the+      parsed tables. This commit++        1.  checks paragraphs that follow the table definition+        2.  treats specially a paragraph with a style named 'Table'+        3.  does some postprocessing of the paragraphs that combines tables+            followed immediately by captions++      The ODT writer used the `TableCaption` style for the caption+      paragraph.  This commit follows the OpenOffice approach which allows+      for appending captions to table but uses a built-in style named+      `Table` instead of `TableCaption`. Users of a custom `reference.odt`+      should change the style's name from `TableCaption` to `Table`.++  * ODT reader: Infer tables' header props from rows (#3199,+    Hubert Plociniczak). ODT reader simply provided an empty header list+    which meant that the contents of the whole table, even if not empty, was+    simply ignored. While we still do not infer headers we at least have to+    provide default properties of columns.++  * Markdown reader:++    +   Allow reference link labels starting with `@...` if `citations`+        extension disabled (#3209). Example: in++            \[link text\]\[@a\]++        `link text` isn't hyperlinked because `[@a]` is parsed as+        a citation. Previously this happened whether or not the `citations`+        extension was enabled. Now it happens only if the `citations`+        extension is enabled.+    +   Allow alignments to be specified in Markdown grid tables. For+        example,++            +-------+---------------+--------------------++            | Right    | Left                 | Centered |+            +=========:+:=================+:=============:++            | Bananas | $1.34         | built-in wrapper |+            +-------+---------------+--------------------+++    +   Allow Small Caps elements to be created using bracketed spans (as+        they already can be using HTML-syntax spans) (#3191, Kolen Cheung).++  * LaTeX reader:++    + Don't treat `\vspace` and `\hspace` as block commands (#3256).+      Fixed an error which came up, for example, with `\vspace` inside+      a caption. (Captions expect inlines.)+    + Improved table handling. We can now parse all of the tables emitted+      by pandoc in our tests. The only thing we don't get yet are+      alignments and column widths in more complex tables. See #2669.+    + Limited support for minipage.+    + Allow for `[]`s inside LaTeX optional args. Fixes cases like:+    + Handle BVerbatim from fancyvrb (#3203).+    + Handle hungarumlaut (#3201).+    + Allow beamer-style `<...>` options in raw LaTeX (also in Markdown)+      (#3184). This allows use of things like `\only<2,3>{my content}` in+      Markdown that is going to be converted to beamer.++  * Use pre-wrap for code in dzslides template (Nicolas Porcel). Otherwise+    overly long code will appear on every slide.++  * Org reader (Albert Krewinkel):++    +   Respect column width settings (#3246). Table column properties can+        optionally specify a column's width with which it is displayed in+        the buffer. Some exporters, notably the ODT exporter in org-mode+        v9.0, use these values to calculate relative column widths. The org+        reader now implements the same behavior. Note that the org-mode+        LaTeX and HTML exporters in Emacs don't support this feature yet,+        which should be kept in mind by users who use the column+        widths parameters.+    +   Allow HTML attribs on non-figure images (#3222). Images which are+        the only element in a paragraph can still be given HTML attributes,+        even if the image does not have a caption and is hence not a figure.+        The following will add set the `width` attribute of the image to+        `50%`:++            +ATTR\_HTML: :width 50%+            =======================++            \[\[file:image.jpg\]\]++    +   Support `ATTR_HTML` for special blocks (#3182). Special+        blocks (i.e. blocks with unrecognized names) can be prefixed with an+        `ATTR_HTML` block attribute. The attributes defined in that+        meta-directive are added to the `Div` which is used to represent the+        special block.+    +   Support the `todo` export option. The `todo` export option allows to+        toggle the inclusion of TODO keywords in the output. Setting this to+        `nil` causes TODO keywords to be dropped from headlines. The default+        is to include the keywords.+    +   Add support for todo-markers. Headlines can have optional+        todo-markers which can be controlled via the `#+TODO`, `#+SEQ_TODO`,+        or `#+TYP_TODO` meta directive. Multiple such directives can be+        given, each adding a new set of recognized todo-markers. If no+        custom todo-markers are defined, the default `TODO` and `DONE`+        markers are used. Todo-markers are conceptually separate from+        headline text and are hence excluded when autogenerating+        headline IDs. The markers are rendered as spans and labelled with+        two classes: One class is the markers name, the other signals the+        todo-state of the marker (either `todo` or `done`).++  * LaTeX writer:++    + Use `\autocites*` when "suppress-author" citation used.+    + Ensure that simple tables have simple cells (#2666). If cells+      contain more than a single Plain or Para, then we need to set+      nonzero widths and put contents into minipages.+    + Remove invalid inlines in sections (#3218, Hubert Plociniczak).++  * Markdown writer:++    + Fix calculation of column widths for aligned multiline tables+      (#1911, Björn Peemöller). This also fixes excessive CPU and memory+      usage for tables when `--columns` is set in such a way that cells+      must be very tiny. Now cells are guaranteed to be big enough so that+      single words don't need to line break, even if this pushes the line+      length above the column width.+    + Use bracketed form for native spans when `bracketed_spans`+      enabled (#3229).+    + Fixed inconsistent spacing issue (#3232). Previously a tight bullet+      sublist got rendered with a blank line after, while a tight ordered+      sublist did not. Now we don't get the blank line in either case.+    + Fix escaping of spaces in super/subscript (#3225). Previously two+      backslashes were inserted, which gave a literal backslash.+    + Adjust widths in Markdown grid tables so that they match+      on round-trip.++  * Docx writer:++    + Give full detail when there are errors converting tex math.+    + Handle title text in images (Jesse Rosenthal). We already handled+      alt text. This just puts the image "title" into the docx+      "title" attr.+    + Fixed XML markup for empty cells (#3238). Previously the Compact+      style wasn't being applied properly to empty cells.++  * HTML writer:++    + Updated `renderHtml` import from blaze-html.++  * Text.Pandoc.Pretty:++    + Fixed some bugs that caused blank lines in tables (#3251). The bugs+      caused spurious blank lines in grid tables when we had things like+      `blankline $$ blankline`.+    + Add exported function `minOffet` \[API change\] (Björn Peemöller).+    + Added error message for illegal call to `block` (Björn Peemöller).++  * Text.Pandoc.Shared:++    + Put `warn` in MonadIO.+    + `fetchItem`: Better handling of protocol-relative URL (#2635). If+      URL starts with `//` and there is no "base URL" (as there would be+      if a URL were used on the command line), then default to http:.++  * Export Text.Pandoc.getDefaultExtensions \[API change\] (#3178).++  * In --version, trap error in `getAppUserDataDirectory` (#3241). This+    fixes a crash with `pandoc --version` on unusual systems with no real+    user (e.g. SQL Server 2016).++  * Added weigh-pandoc for memory usage diagnostics (#3169).++  * Use correct mime types for woff and woff2 (#3228).++  * Remove make\_travis\_yml.hs (#3235, Kolen Cheung).++  * changelog: Moved an item that was misplaced in the 1.17.2 section to the+    1.18 section where it belongs.++  * CONTRIBUTING.md: minor change in wording and punctuation (#3252,+    Kolen Cheung).++  * Further revisions to manual for `--version` changes (#3244).++++## pandoc 1.18 (2016-10-26)++  * Added `--list-input-formats`, `--list-output-formats`,+    `--list-extensions`, `--list-highlight-languages`, and+    `--list-highlight-styles` (#3173).  Removed list of highlighting+    languages from `--version` output.  Removed list of input and output+    formats from default `--help` output.++  * Added `--reference-location=block|section|document` option+    (Jesse Rosenthal).  This determines whether Markdown link references+    and footnotes are placed at the end of the document, the end of the+    section, or the end of the top-level block.++  * Added `--top-level-division=section|chapter|part` (Albert Krewinkel).+    This determines what a level-1 header corresponds to in LaTeX,+    ConTeXt, DocBook, and TEI output.  The default is `section`.+    The `--chapters` option has been deprecated in favor of+    `--top-level-division=chapter`.++  * Added `LineBlock` constructor for `Block` (Albert Krewinkel).  This+    is now used in parsing RST and Markdown line blocks, DocBook+    `linegroup`/`line` combinations, and Org-mode `VERSE` blocks.+    Previously `Para` blocks with hard linebreaks were used.  `LineBlock`s+    are handled specially in the following ouput formats: AsciiDoc+    (as `[verse]` blocks), ConTeXt (`\startlines`/`\endlines`),+    HTML (`div` with a style), Markdown (line blocks if `line_blocks`+    is enabled), Org-mode (`VERSE` blocks), RST (line blocks). In+    other output formats, a paragraph with hard linebreaks is emitted.++  * Allow binary formats to be written to stdout (but not to tty) (#2677).+    Only works on posix, since we use the unix library to check whether+    output is to tty.  On Windows, pandoc works as before and always requires+    an output file parameter for binary formats.++  * Changed JSON output format (Jesse Rosenthal).  Previously we used+    generically generated JSON, but this was subject to change depending+    on the version of aeson pandoc was compiled with.  To ensure stability,+    we switched to using manually written ToJSON and FromJSON+    instances, and encoding the API version.  **Note:**  pandoc filter+    libraries will need to be revised to handle the format change.+    Here is a summary of the essential changes:++    + The toplevel JSON format is now `{"pandoc-api-version" :+      [MAJ, MIN, REV], "meta" : META, "blocks": BLOCKS}`+      instead of `[{"unMeta": META}, [BLOCKS]]`.+      Decoding fails if the major and minor version numbers don't+      match.+    + Leaf nodes no longer have an empty array for their "c" value.+      Thus, for example, a `Space` is encoded as `{"t":"Space"}`+      rather than `{"t":"Space","c":[]}` as before.++  * Removed `tests/Tests/Arbitrary.hs` and added a `Text.Pandoc.Arbitrary`+    module to pandoc-types (Jesse Rosenthal).  This makes it easier+    to use QuickCheck with pandoc types outside of pandoc itself.++  * Add `bracketed_spans` Markdown extension, enabled by default+    in pandoc `markdown`.  This allows you to create a native span+    using this syntax:  `[Here is my span]{#id .class key="val"}`.++  * Added `angle_brackets_escapable` Markdown extension (#2846).+    This is needed because github flavored Markdown has a slightly+    different set of escapable symbols than original Markdown;+    it includes angle brackets.++  * Export `Text.Pandoc.Error` in `Text.Pandoc` [API change].++  * Print highlighting-kate version in `--version`.++  * `Text.Pandoc.Options`:++    + `Extension` has new constructors `Ext_brackted_spans` and+      `Ext_angle_brackets_escapable` [API change].+    + Added `ReferenceLocation` type [API change] (Jesse Rosenthal).+    + Added `writerReferenceLocation` field to `WriterOptions` (Jesse+      Rosenthal).++  * `--filter`:  we now check `$DATADIR/filters` for filters before+    looking in the path (#3127, Jesse Rosenthal, thanks to Jakob+    Voß for the idea).  Filters placed in this directory need not+    be executable; if the extension is `.hs`, `.php`, `.pl`, `.js`,+    or `.rb`, pandoc will run the right interpreter.++  * For `--webtex`, replace deprecated Google Chart API by CodeCogs as+    default (Kolen Cheung).++  * Removed `raw_tex` extension from `markdown_mmd` defaults (Kolen Cheung).++  * Execute .js filters with node (Jakob Voß).++  * Textile reader:++    + Support `bc..` extended code blocks (#3037).  Also, remove trailing+      newline in code blocks (consistently with Markdown reader).+    + Improve table parsing.  We now handle cell and row attributes, mostly+      by skipping them.  However, alignments are now handled properly.+      Since in pandoc alignment is per-column, not per-cell, we+      try to devine column alignments from cell alignments.+      Table captions are also now parsed, and textile indicators+      for thead and tfoot no longer cause parse failure.  (However,+      a row designated as tfoot will just be a regular row in pandoc.)+    + Improve definition list parsing.  We now allow multiple terms+      (which we concatenate with linebreaks).  An exponential parsing+      bug (#3020) is also fixed.+    + Disallow empty URL in explicit link (#3036).++  * RST reader:++    + Use Div instead of BlockQuote for admonitions (#3031).+      The Div has class `admonition` and (if relevant) one of the+      following:  `attention`, `caution`, `danger`, `error`, `hint`,+      `important`, `note`, `tip`, `warning`.  **Note:** This will change+      the rendering of some RST documents!  The word ("Warning", "Attention",+      etc.) is no longer added; that must be done with CSS or a filter.+    + A Div is now used for `sidebar` as well.+    + Skip whitespace before note (Jesse Rosenthal, #3163).  RST requires a+      space before a footnote marker. We discard those spaces so that footnotes+      will be adjacent to the text that comes before it. This is in line with+      what rst2latex does.+    + Allow empty lines when parsing line blocks (Albert Krewinkel).++  * Markdown reader:++    + Allow empty lines when parsing line blocks (Albert Krewinkel).+    + Allow attributes on autolinks (#3183, Daniele D'Orazio).++  * LaTeX reader:++    + More robust parsing of unknown environments (#3026).+      We no longer fail on things like `^` inside options for tikz.+    + Be more forgiving of non-standard characters, e.g. `^` outside of math.+      Some custom environments give these a meaning, so we should try not to+      fall over when we encounter them.+    + Drop duplicate `*` in bibtexKeyChars (Albert Krewinkel)++  * MediaWiki reader:++    + Fix for unquoted attribute values in mediawiki tables (#3053).+      Previously an unquoted attribute value in a table row+      could cause parsing problems.+    + Improved treatment of verbatim constructions (#3055).+      Previously these yielded strings of alternating Code and Space+      elements; we now incorporate the spaces into the Code.  Emphasis+      etc. is still possible inside these.+    + Properly interpret XML tags in pre environments (#3042).  They are meant+      to be interpreted as literal text.++  * EPUB reader:  don't add root path to data: URIs (#3150).+    Thanks to @lep for the bug report and patch.++  * Org reader (Albert Krewinkel):++    + Preserve indentation of verse lines (#3064).  Leading spaces in verse+      lines are converted to non-breaking spaces, so indentation is preserved.+    + Ensure image sources are proper links.  Image sources as those in plain+      images, image links, or figures, must be proper URIs or relative file+      paths to be recognized as images.  This restriction is now enforced+      for all image sources.  This also fixes the reader's usage of uncleaned+      image sources, leading to `file:` prefixes not being deleted from+      figure images.  Thanks to @bsag for noticing this bug.+    + Trim verse lines properly (Albert Krewinkel).+    + Extract meta parsing code to module.  Parsing of meta-data is well+      separable from other block parsing tasks.  Moving into new module to+      get small files and clearly arranged code.+    + Read markup only for special meta keys.  Most meta-keys should be read+      as normal string values, only a few are interpreted as marked-up text.+    + Allow multiple, comma-separated authors.  Multiple authors can be+      specified in the `#+AUTHOR` meta line if they are given as a+      comma-separated list.+    + Give precedence to later meta lines.  The last meta-line of any given+      type is the significant line.  Previously the value of the first line+      was kept, even if more lines of the same type were encounterd.+    + Read LaTeX_header as header-includes.  LaTeX-specific header commands+      can be defined in `#+LaTeX_header` lines.  They are parsed as+      format-specific inlines to ensure that they will only show up in LaTeX+      output.+    + Set documentclass meta from LaTeX_class.+    + Set classoption meta from LaTeX_class_options.+    + Read HTML_head as header-includes.  HTML-specific head content can be+      defined in `#+HTML_head` lines.  They are parsed as format-specific+      inlines to ensure that they will only show up in HTML output.+    + Respect `author` export option.  The `author` option controls whether+      the author should be included in the final markup.  Setting+      `#+OPTIONS: author:nil` will drop the author from the final meta-data+      output.+    + Respect `email` export option.  The `email` option controls whether the+      email meta-field should be included in the final markup. Setting+      `#+OPTIONS: email:nil` will drop the email field from the final+      meta-data output.+    + Respect `creator` export option.  The `creator` option controls whether+      the creator meta-field should be included in the final markup.  Setting+      `#+OPTIONS: creator:nil` will drop the creator field from the final+      meta-data output.  Org-mode recognizes the special value `comment` for+      this field, causing the creator to be included in a comment.  This is+      difficult to translate to Pandoc internals and is hence interpreted the+      same as other truish values (i.e. the meta field is kept if it's+      present).+    + Respect unnumbered header property (#3095).  Sections the `unnumbered`+      property should, as the name implies, be excluded from the automatic+      numbering of section provided by some output formats.  The Pandoc+      convention for this is to add an "unnumbered" class to the header.  The+      reader treats properties as key-value pairs per default, so a special+      case is added to translate the above property to a class instead.+    + Allow figure with empty caption (Albert Krewinkel, #3161).+      A `#+CAPTION` attribute before an image is enough to turn an image into+      a figure. This wasn't the case because the `parseFromString` function,+      which processes the caption value, would fail on empty values. Adding+      a newline character to the caption value fixes this.++  * Docx reader:++    + Use XML convenience functions (Jesse Rosenthal).+      The functions `isElem` and `elemName` (defined in Docx/Util.hs) make+      the code a lot cleaner than the original XML.Light functions, but they+      had been used inconsistently. This puts them in wherever applicable.+    + Handle anchor spans with content in headers.  Previously, we would only+      be able to figure out internal links to a header in a docx if the+      anchor span was empty. We change that to read the inlines out of the+      first anchor span in a header.+    + Let headers use exisiting id.  Previously we always generated an id for+      headers (since they wouldn't bring one from Docx). Now we let it use an+      existing one if possible. This should allow us to recurs through anchor+      spans.+    + Use all anchor spans for header ids.  Previously we only used the first+      anchor span to affect header ids. This allows us to use all the anchor+      spans in a header, whether they're nested or not (#3088).+    + Test for nested anchor spans in header.  This ensures that anchor spans+      in header with content (or with other anchor spans inside) will resolve+      to links to a header id properly.++  * ODT reader (Hubert Plociniczak)++    + Include list's starting value.  Previously the starting value of+      the lists' items has been hardcoded to 1. In reality ODT's list+      style definition can provide a new starting value in one of its+      attributes.+    + Infer caption from the text following the image.+      Frame can contain other frames with the text boxes.+    + Add `fig:` to title for Image with a caption (as expected+      by pandoc's writers).+    + Basic support for images in ODT documents.+    + Don't duplicate text for anchors (#3143).  When creating an anchor+      element we were adding its representation as well as the original+      content, leading to text duplication.++  * DocBook writer:++    + Include an anchor element when a div or span has an id (#3102).+      Note that DocBook does not have a class attribute, but at least this+      provides an anchor for internal links.++  * LaTeX writer:++    + Don't use * for unnumbered paragraph, subparagraph.  The starred+      variants don't exist.  This helps with part of #3058...it gets rid of+      the spurious `*`s.  But we still have numbers on the 4th and 5th level+      headers.+    + Properly escape backticks in verbatim (#3121, Jesse Rosenthal).+      Otherwise they can cause unintended ligatures like `` ?` ``.+    + Handle NARRAOW NO-BREAK SPACE into LaTeX (Vaclav Zeman) as `\,`.+    + Don't include `[htbp]` placement for figures (#3103, Václav Haisman).+      This allows figure placement defaults to be changed by the user+      in the template.++  * TEI writer: remove heuristic to detect book template (Albert Krewinkel).+    TEI doesn't have `<book>` elements but only generic `<divN>` division+    elements. Checking the template for a trailing `</book>` is nonsensical.++  * MediaWiki writer:  transform filename with underscores in images (#3052).+    `foo bar.jpg` becomes `foo_bar.jpg`. This was already done+    for internal links, but it also needs to happen for images.++  * ICML writer: replace partial function (!!) in table handling (#3175,+    Mauro Bieg).++  * Man writer: allow section numbers that are not a single digit (#3089).++  * AsciiDoc writer: avoid unnecessary use of "unconstrained" emphasis+    (#3068).  In AsciiDoc, you must use a special form of emphasis+    (double `__`) for intraword emphasis.  Pandoc was previously using+    this more than necessary.++  * EPUB writer:  use stringify instead of plain writer for metadata+    (#3066).  This means that underscores won't be used for emphasis,+    or CAPS for bold.  The metadata fields will just have unadorned+    text.++  * Docx Writer:++    + Implement user-defined styles (Jesse Rosenthal).  Divs and Spans+      with a `custom-style` key in the attributes will apply the corresponding+      key to the contained blocks or inlines.+    + Add ReaderT env to the docx writer (Jesse Rosenthal).+    + Clean up and streamline RTL behavior (Jesse Rosenthal, #3140).+      You can set `dir: rtl` in YAML metadata, or use `-M dir=rtl`+      on the command line.  For finer-grained control, you can set+      the `dir` attribute in Div or Span elements.++  * Org writer (Albert Krewinkel):++    + Remove blank line after figure caption.  Org-mode only treats an image+      as a figure if it is directly preceded by a caption.+    + Ensure blank line after figure.  An Org-mode figure should be surrounded+      by blank lines.  The figure would be recognized regardless, but images+      in the following line would unintentionally be treated as figures as+      well.+    + Ensure link targets are paths or URLs.  Org-mode treats links as+      document internal searches unless the link target looks like a URL or+      file path, either relative or absolute.  This change ensures that this+      is always the case.+    + Translate language identifiers.  Pandoc and Org-mode use different+      programming language identifiers.  An additional translation between+      those identifiers is added to avoid unexpected behavior.  This fixes a+      problem where language specific source code would sometimes be output+      as example code.+    + Drop space before footnote markers (Albert Krewinkel, #3162).+      The writer no longer adds an extra space before footnote markers.++  * Markdown writer:++    + Don't emit HTML for tables unless `raw_html` extension is set (#3154).+      Emit `[TABLE]` if no suitable table formats are enabled and raw HTML+      is disabled.+    + Check for the `raw_html` extension before emitting a raw HTML block.+    + Abstract out note/ref function (Jesse Rosenthal).+    + Add ReaderT monad for environment variables (Jesse Rosenthal).++  * HTML, EPUB, slidy, revealjs templates: Use `<p>` instead of `<h1>` for+    subtitle, author, date (#3119).  Note that, as a result of this change,+    authors may need to update CSS.++  * revealjs template:  Added `notes-server` option+    (jgm/pandoc-templates#212, Yoan Blanc).++  * Beamer template:++    + Restore whitespace between paragraphs. This was+      a regression in the last release (jgm/pandoc-templates#207).+    + Added `themeoptions` variable (Carsten Gips).+    + Added `beamerarticle` variable.  This causes the `beamerarticle`+      package to be loaded in beamer, to produce an article from beamer+      slides.  (Carsten Gips)+    + Added support for `fontfamilies` structured variable+      (Artem Klevtsov).+    + Added hypersetup options (Jake Zimmerman).++  * LaTeX template:++    + Added dummy definition for `\institute`.+      This isn't a standard command, and we want to avoid a crash when+      `institute` is used with the default template.+    + Define default figure placement (Václav Haisman), since pandoc+      no longer includes `[htbp]` for figures.  Users with custom templates+      will want to add this. See #3103.+    + Use footnote package to fix notes in tables (jgm/pandoc-templates#208,+      Václav Haisman).++  * Moved template compiling/rendering code to a separate library.+    `doctemplates`.  This allows the pandoc templating system to be+    used independently.++  * Text.Pandoc.Error: Fix out of index error in `handleError`+    (Matthew Pickering).  The fix is to not try to show the exact line when+    it would cause an out-of-bounds error as a result of included files.++  * Text.Pandoc.Shared: Add `linesToBlock` function (Albert Krewinkel).++  * Text.Pandoc.Parsing.emailAddress: tighten up parsing of email+    addresses.  Technically `**@user` is a valid email address, but if we+    allow things like this, we get bad results in markdown flavors+    that autolink raw email addresses (see #2940).  So we exclude a few+    valid email addresses in order to avoid these more common bad cases.++  * Text.Pandoc.PDF:  Don't crash with nonexistent image (#3100).  Instead,+    emit the alt text, emphasized.  This accords with what the ODT writer+    currently does.  The user will still get a warning about a nonexistent+    image.++  * Fix example in API documentation (#3176, Thomas Weißschuh).++  * Tell where to get tarball in INSTALL (#3062).++  * Rename README to MANUAL.txt and add GitHub-friendly README.md+    (Albert Krewinkel, Kolen Cheung).++  * Replace COPYING with Markdown version COPYING.md from GNU (Kolen Cheung).++  * MANUAL.txt:++    + Put note on structured vars in separate paragraph (#2148, Albert+      Krewinkel).  Make it clearer that structured author variables require a+      custom template+    + Note that `--katex` works best with `html5` (#3077).+    + Fix the LaTeX and EPUB links in manual (Morton Fox).+    + Document `biblio-title` variable.++  * Improve spacing of footnotes in `--help` output (Waldir Pimenta).++  * Update KaTeX to v0.6.0 (Kolen Cheung).++  * Allow latest dependencies.++  * Use texmath 0.8.6.6 (#3040).++  * Allow http-client 0.4.30, which is the version in stackage lts.+    Previously we required 0.5.+    Remove CPP conditionals for earlier versions.++  * Remove support for GHC < 7.8 (Jesse Rosenthal).++    + Remove Compat.Monoid.+    + Remove an inline monad compatibility macro.+    + Remove Text.Pandoc.Compat.Except.+    + Remove directory compat.+    + Change constraint on mtl.+    + Remove unnecessary CPP condition in UTF8.+    + Bump base lower bound to 4.7.+    + Remove 7.6 build from .travis.yaml.+    + Bump supported ghc version in CONTRIBUTING.md.+    + Add note about GHC version support to INSTALL.+    + Remove GHC 7.6 from list of tested versions (Albert Krewinkel).+    + Remove TagSoup compat.+    + Add EOL note to time compat module.  Because time 1.4 is a boot library+      for GHC 7.8, we will support the compatibility module as long as we+      support 7.8. But we should be clear about when we will no longer need+      it.+    + Remove blaze-html CPP conditional.+    + Remove unnecessary CPP in custom Prelude.++## pandoc 1.17.2 (2016-07-17)++  * Added Zim Wiki writer, template and tests. `zimwiki` is now+    a valid output format. (Alex Ivkin)++  * Changed email-obfuscation default to no obfuscation (#2988).+    + `writerEmailObfuscation` in `defaultWriterOptions` is now+      `NoObfuscation`.+    + the default for the command-line `--email-obfuscation` option is+      now `none`.++  * Docbook writer: Declare xlink namespace in Docbook5 output (Ivo Clarysse).++  * Org writer:++    + Support arbitrary raw inlines (Albert Krewinkel).+      Org mode allows arbitrary raw inlines ("export snippets" in Emacs+      parlance) to be included as `@@format:raw foreign format text@@`.+    + Improve Div handling (Albert Krewinkel).  Div blocks handling is+      changed to make the output look more like idiomatic org mode:+        - Div-wrapped content is output as-is if the div's attribute is the+          null attribute.+        - Div containers with an id but neither classes nor key-value pairs+          are unwrapped and the id is added as an anchor.+        - Divs with classes associated with greater block elements are+          wrapped in a `#+BEGIN`...`#+END` block.+        - The old behavior for Divs with more complex attributes is kept.++  * HTML writer:  Better support for raw LaTeX environments (#2758).+    Previously we just passed all raw TeX through when MathJax+    was used for HTML math.  This passed through too much.+    With this patch, only raw LaTeX environments that MathJax+    can handle get passed through.+    This patch also causes raw LaTeX environments to be treated+    as math, when possible, with MathML and WebTeX output.++  * Markdown writer:  use raw HTML for simple, pipe tables with linebreaks+    (#2993).  Markdown line breaks involve a newline, and simple and pipe+    tables can't contain one.++  * Make --webtex work with the Markdown writer (#1177).+    This is a convenient option for people using+    websites whose Markdown flavors don't provide for math.++  * Docx writer:++    + Set paragraph to FirstPara after display math (Jesse Rosenthal).+      We treat display math like block quotes, and apply FirstParagraph style+      to paragraphs that follow them. These can be styled as the user+      wishes. (But, when the user is using indentation, this allows for+      paragraphs to continue after display math without indentation.)+    + Use actual creation time as doc prop (Jesse Rosenthal).+      Previously, we had used the user-supplied date, if available, for Word's+      document creation metadata. This could lead to weird results, as in+      cases where the user post-dates a document (so the modification might be+      prior to the creation). Here we use the actual computer time to set the+      document creation.++  * LaTeX writer:++    + Don't URI-escape image source (#2825).  Usually this is a local file,+      and replacing spaces with `%20` ruins things.+    + Allow 'standout' as a beamer frame option (#3007).+      `## Slide title {.standout}`.++  * RST reader: Fixed links with no explicit link text.  The link+    `` `<foo>`_ `` should have `foo` as both its link text and its URL.+    See RST spec at <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases>+    Closes Debian #828167 -- reported by Christian Heller.++  * Textile reader:++    + Fixed attributes (#2984).  Attributes can't be followed by+      a space.  So, `_(class)emph_` but `_(noclass) emph_`.+    + Fixed exponential parsing bug (#3020).+    + Fix overly aggressive interpretation as images (#2998).+      Spaces are not allowed in the image URL in textile.++  * LaTeX reader:++    + Fix `\cite` so it is a NormalCitation not AuthorInText.+    + Strip off double quotes around image source if present (#2825).+      Avoids interpreting these as part of the literal filename.++  * Org reader:++    + Add semicolon to list of special chars (Albert Krewinkel)+      Semicolons are used as special characters in citations syntax.  This+      ensures the correct parsing of Pandoc-style citations: `[prefix; @key;+      suffix]`.  Previously, parsing would have failed unless there was a space+      or other special character as the last <prefix> character.+    + Add support for "Berkeley-style" cites (Albert Krewinkel, #1978).+      A specification for an official Org-mode citation syntax was drafted by+      Richard Lawrence and enhanced with the help of others on the orgmode+      mailing list.  Basic support for this citation style is added to the+      reader.+    + Support arbitrary raw inlines (Albert Krewinkel).+      Org mode allows arbitrary raw inlines ("export snippets" in Emacs+      parlance) to be included as `@@format:raw foreign format text@@`.+    + Remove partial functions (Albert Krewinkel, #2991).+      Partial functions like `head` lead to avoidable errors and should be+      avoided.  They are replaced with total functions.+    + Support figure labels (Albert Krewinkel, #2496, #2999).+      Figure labels given as `#+LABEL: thelabel` are used as the ID of the+      respective image.  This allows e.g. the LaTeX to add proper `\label`+      markup.+    + Improve tag and properties type safety (Albert Krewinkel).+      Specific newtype definitions are used to replace stringly typing of tags+      and properties.  Type safety is increased while readability is improved.+    + Parse as headlines, convert to blocks (Albert Krewinkel).+      Emacs org-mode is based on outline-mode, which treats documents as trees+      with headlines are nodes.  The reader is refactored to parse into a+      similar tree structure.  This simplifies transformations acting on+      document (sub-)trees.+    * Refactor comment tree handling (Albert Krewinkel).+      Comment trees were handled after parsing, as pattern matching on lists+      is easier than matching on sequences.  The new method of reading+      documents as trees allows for more elegant subtree removal.+    * Support archived trees export options (Albert Krewinkel).+      Handling of archived trees can be modified using the `arch` option.+      Archived trees are either dropped, exported completely, or collapsed to+      include just the header when the `arch` option is nil, non-nil, or+      `headline`, respectively.+    * Put export setting parser into module (Albert Krewinkel).+      Export option parsing is distinct enough from general block parsing to+      justify putting it into a separate module.+    * Support headline levels export setting (Albert Krewinkel).+      The depths of headlines can be modified using the `H` option.  Deeper+      headlines will be converted to lists.+    * Replace ugly code with view pattern (Albert Krewinkel).+      Some less-than-smart code required a pragma switching of overlapping+      pattern warnings in order to compile seamlessly.  Using view patterns+      makes the code easier to read and also doesn't require overlapping+      pattern checks to be disabled.+    * Fix parsing of verbatim inlines (Albert Krewinkel, #3016).+      Org rules for allowed characters before or after markup chars were not+      checked for verbatim text.  This resultet in wrong parsing outcomes of+      if the verbatim text contained e.g. space enclosed markup characters as+      part of the text (`=is_substr = True=`).  Forcing the parser to update+      the positions of allowed/forbidden markup border characters fixes this.++  * LaTeX template: fix for obscure hyperref/xelatex issue.+    Here's a minimal case:++        \documentclass[]{article}+        \usepackage{hyperref}+        \begin{document}+        \section{\%á}+        \end{document}++    Without this change, this fails on the second invocation of xelatex.+    This affects inputs this like `# %á` with pdf output via xelatex.++  * trypandoc:  call results 'html' instead of 'result'.+    This is for better compatibility with babelmark2.++  * Document MultiMarkdown as input/output format (Albert Krewinkel, #2973).+    MultiMarkdown was only mentioned as a supported Markdown dialect but not+    as a possible input or output format.  A brief mention is added+    everywhere the other supported markdown dialects are mentioned.++  * Document Org mode as a format containing raw HTML (Albert Krewinkel)+    Raw HTML is kept when the output format is Emacs Org mode.++  * Implement `RawInline` and `RawBlock` in sample lua custom writer (#2985).++  * Text.Pandoc.Shared:++    + Introduce blocksToInlines function (Jesse Rosenthal).+      This is a lossy function for converting `[Block] -> [Inline]`. Its main+      use, at the moment, is for docx comments, which can contain arbitrary+      blocks (except for footnotes), but which will be converted to spans.+      This is, at the moment, pretty useless for everything but the basic+      `Para` and `Plain` comments. It can be improved, but the docx reader+      should probably emit a warning if the comment contains more than this.+    + Add BlockQuote to blocksToInlines (Jesse Rosenthal).+    + Add further formats for `normalizeDate` (Jesse Rosenthal).+      We want to avoid illegal dates -- in particular years with greater than+      four digits. We attempt to parse series of digits first as `%Y%m%d`, then+      `%Y%m`, and finally `%Y`.+    + `normalizeDate` should reject illegal years (Jesse Rosenthal).+      We only allow years between 1601 and 9999, inclusive. The ISO 8601+      actually says that years are supposed to start with 1583, but MS Word+      only allows 1601-9999. This should stop corrupted word files if the date+      is out of that range, or is parsed incorrectly.+    + Improve year sanity check in normalizeDate (Jesse Rosenthal).+      Previously we parsed a list of dates, took the first one, and then+      tested its year range. That meant that if the first one failed, we+      returned nothing, regardless of what the others did. Now we test for+      sanity before running `msum` over the list of Maybe values. Anything+      failing the test will be Nothing, so will not be a candidate.++  * Docx reader:++    + Add simple comment functionality. (Jesse Rosenthal).+      This adds simple track-changes comment parsing to the docx reader. It is+      turned on with `--track-changes=all`. All comments are converted to+      inlines, which can list some information. In the future a warning will be+      added for comments with formatting that seems like it will be excessively+      denatured.  Note that comments can extend across blocks. For that reason+      there are two spans: `comment-start` and `comment-end`.  `comment-start`+      will contain the comment. `comment-end` will always be empty.  The two+      will be associated by a numeric id.+    + Enable warnings in top-level reader (Jesse Rosenthal).+      Previously we had only allowed for warnings in the parser. Now we allow+      for them in the `Docx.hs` as well. The warnings are simply concatenated.+    + Add warning for advanced comment formatting. (Jesse Rosenthal).+      We can't guarantee we'll convert every comment correctly, though we'll+      do the best we can. This warns if the comment includes something other+      than Para or Plain.+    + Add tests for warnings. (Jesse Rosenthal).+    + Add tests for comments (Jesse Rosenthal).+      We test for comments, using all track-changes options. Note that we+      should only output comments if `--track-changes=all`. We also test for+      emitting warnings if there is complicated formatting.++  * README: update to include track-changes comments. (Jesse Rosenthal)++  * Improved Windows installer - don't ignore properties set on command-line.+    See #2708.  Needs testing to see if this resolves the issue.+    Thanks to @nkalvi.++  * Process markdown extensions on command line in L->R order (#2995).+    Previously they were processed, very unintuitively, in R->L+    order, so that `markdown-tex_math_dollars+tex_math_dollars`+    had `tex_math_dollars` disabled.++  * Added `secnumdepth` variable to LaTeX template (#2920).++  * Include table of contents in README.html in Windows package.++  * Writers: treat SoftBreak as space for stripping (Jesse Rosenthal)+    In Writers.Shared, we strip leading and trailing spaces for display+    math. Since SoftBreak's are treated as spaces, we should strip those+    too.++  * beamer, latex templates:  pass biblatexoptions directly in package load.+    This allows runtime optinos to be used.  Fixes jgm/pandoc-citeproc#201++  * CPP workaround for deprecation of `parseUrl` in http-client.++  * Removed some redundant class constraints.++  * make_oxs_package.sh - use OSX env variable.++  * Added `winpkg` target to Makefile.  This downloads the windows package+    from appveyor and signs it using the key.++  * Document Org mode as a format containing raw TeX (Albert Krewinkel).+    Raw TeX is kept verbatim when the output format is Emacs Org mode.++  * Support math with haddock-library >= 1.4.++  * Removed `-rtsopts` from library stanza.  It has no effect, and Hackage+    wouldn't accept the package.++  * Update library dependency versions.++## pandoc 1.17.1 (2016-06-04)++  * New output format: `docbook5` (Ivo Clarysse).++  * `Text.Pandoc.Options`: Add `writerDocBook5` to `WriterOptions`+    (API change).++  * Org writer:++    + Add :PROPERTIES: drawer support (Albert Krewinkel, #1962).+      This allows header attributes to be added to org documents in the form+      of `:PROPERTIES:` drawers.  All available attributes are stored as+      key/value pairs.  This reflects the way the org reader handles+      `:PROPERTIES:` blocks.+    + Add drawer capability (Carlos Sosa).  For the implementation of the+      Drawer element in the Org Writer, we make use of a generic Block+      container with attributes.  The presence of a `drawer` class defines+      that the `Div` constructor is a drawer. The first class defines the+      drawer name to use.  The key-value list in the attributes defines+      the keys to add inside the Drawer.  Lastly, the list of Block elements+      contains miscellaneous blocks elements to add inside of the Drawer.+    + Use `CUSTOM_ID` in properties (Albert Krewinkel).  The `ID` property is+      reserved for internal use by Org-mode and should not be used.+      The `CUSTOM_ID` property is to be used instead, it is converted to the+      `ID` property for certain export format.++  * LaTeX writer:++    + Ignore `--incremental` unless output format is beamer (#2843).+    + Fix polyglossia to babel env mapping (Mauro Bieg, #2728).+      Allow for optional argument in square brackets.+    + Recognize `la-x-classic` as Classical Latin (Andrew Dunning).+      This allows one to access the hyphenation patterns in CTAN's+      hyph-utf8.+    + Add missing languages from hyph-utf8 (Andrew Dunning).+    + Improve use of `\strut` with `\minipage` inside tables+      (Jose Luis Duran).  This improves spacing in multiline+      tables.+    + Use `{}` around options containing special chars (#2892).+    + Avoid lazy `foldl`.+    + Don't escape underscore in labels (#2921).  Previously they were+      escaped as `ux5f`.+    + brazilian -> brazil for polyglossia (#2953).++  * HTML writer: Ensure mathjax link is added when math appears in footnote+    (#2881).  Previously if a document only had math in a footnote, the+    MathJax link would not be added.++  * EPUB writer: set `navpage` variable on nav page.+    This allows templates to treat it differently.++  * DocBook writer:++    + Use docbook5 if `writerDocbook5` is set (Ivo Clarysse).+    + Properly handle `ulink`/`link` (Ivo Clarysse).++  * EPUB reader:++    + Unescape URIs in spine (#2924).+    + EPUB reader:  normalise link id (Mauro Bieg).++  * Docx Reader:++    + Parse `moveTo` and `moveFrom` (Jesse Rosenthal).+      `moveTo` and `moveFrom` are track-changes tags that are used when a+      block of text is moved in the document. We now recognize these tags and+      treat them the same as `insert` and `delete`, respectively. So,+      `--track-changes=accept` will show the moved version, while+      `--track-changes=reject` will show the original version.+    + Tests for track-changes moving (Jesse Rosenthal).++  * ODT, EPUB, Docx readers: throw `PandocError` on unzip failure+    (Jesse Rosenthal) Previously, `readDocx`, `readEPUB`, and `readOdt`+    would error out if zip-archive failed. We change the archive extraction+    step from `toArchive` to `toArchiveOrFail`, which returns an Either value.++  * Markdown, HTML readers:  be more forgiving about unescaped `&` in+    HTML (#2410).  We are now more forgiving about parsing invalid HTML with+    unescaped `&` as raw HTML.  (Previously any unescaped `&`+    would cause pandoc not to recognize the string as raw HTML.)++  * Markdown reader:++    + Fix pandoc title blocks with lines ending in 2 spaces (#2799).+    + Added `-s` to markdown-reader-more test.++  * HTML reader: fixed bug in `pClose`.  This caused exponential parsing+    behavior in documnets with unclosed tags in `dl`, `dd`, `dt`.++  * MediaWiki reader: Allow spaces before `!` in MediaWiki table header+    (roblabla).++  * RST reader: Support `:class:` option for code block in RST reader+    (Sidharth Kapur).++  * Org reader (all Albert Krewinkel, except where noted otherwise):++    + Stop padding short table rows.+      Emacs Org-mode doesn't add any padding to table rows.  The first+      row (header or first body row) is used to determine the column count,+      no other magic is performed.+    + Refactor rows-to-table conversion.  This refactors+      the codes conversing a list table lines to an org table ADT.+      The old code was simplified and is now slightly less ugly.+    + Fix handling of empty table cells, rows (Albert Krewinkel, #2616).+      This fixes Org mode parsing of some corner cases regarding empty cells+      and rows.  Empty cells weren't parsed correctly, e.g. `|||` should be+      two empty cells, but would be parsed as a single cell containing a pipe+      character.  Empty rows where parsed as alignment rows and dropped from+      the output.+    + Fix spacing after LaTeX-style symbols.+      The org-reader was droping space after unescaped LaTeX-style symbol+      commands: `\ForAll \Auml` resulted in `∀Ä` but should give `∀ Ä`+      instead.  This seems to be because the LaTeX-reader treats the+      command-terminating space as part of the command.  Dropping the trailing+      space from the symbol-command fixes this issue.+    + Print empty table rows.  Empty table rows should not+      be dropped from the output, so row-height is always set to be at least 1.+    + Move parser state into separate module.+      The org reader code has become large and confusing.  Extracting smaller+      parts into submodules should help to clean things up.+    + Add support for sub/superscript export options.+      Org-mode allows to specify export settings via `#+OPTIONS` lines.+      Disabling simple sub- and superscripts is one of these export options,+      this options is now supported.+    + Support special strings export option Parsing of special strings+      (like `...` as ellipsis or `--` as en dash) can be toggled using the `-`+      option.+    + Support emphasized text export option.  Parsing of emphasized text can+      be toggled using the `*` option.  This influences parsing of text marked+      as emphasized, strong, strikeout, and underline.  Parsing of inline math,+      code, and verbatim text is not affected by this option.+    + Support smart quotes export option.  Reading of smart quotes can be+      toggled using the `'` option.+    + Parse but ignore export options. All known export options are parsed+      but ignored.+    + Refactor block attribute handling.  A parser state attribute was used+      to keep track of block attributes defined in meta-lines.  Global state+      is undesirable, so block attributes are no longer saved as part of the+      parser state.  Old functions and the respective part of the parser state+      are removed.+    + Use custom `anyLine`.  Additional state changes need to be made after+      a newline is parsed, otherwise markup may not be recognized correctly.+      This fixes a bug where markup after certain block-types would not be+      recognized.+    + Add support for `ATTR_HTML` attributes (#1906).+      Arbitrary key-value pairs can be added to some block types using a+      `#+ATTR_HTML` line before the block.  Emacs Org-mode only includes these+      when exporting to HTML, but since we cannot make this distinction here,+      the attributes are always added.  The functionality is now supported+      for figures.+    + Add `:PROPERTIES:` drawer support (#1877).+      Headers can have optional `:PROPERTIES:` drawers associated with them.+      These drawers contain key/value pairs like the header's `id`.  The+      reader adds all listed pairs to the header's attributes; `id` and+      `class` attributes are handled specially to match the way `Attr` are+      defined.  This also changes behavior of how drawers of unknown type+      are handled.  Instead of including all unknown drawers, those are not+      read/exported, thereby matching current Emacs behavior.+    + Use `CUSTOM_ID` in properties.  See above on Org writer changes.+    + Respect drawer export setting.  The `d` export option can be used+      to control which drawers are exported and which are discarded.+      Basic support for this option is added here.+    + Ignore leading space in org code blocks (Emanuel Evans, #2862).+      Also fix up tab handling for leading whitespace in code blocks.+    + Support new syntax for export blocks.  Org-mode version 9+      uses a new syntax for export blocks.  Instead of `#+BEGIN_<FORMAT>`,+      where `<FORMAT>` is the format of the block's content, the new+      format uses `#+BEGIN_export <FORMAT>` instead.  Both types are+      supported.+    + Refactor `BEGIN...END` block parsing.+    + Fix handling of whitespace in blocks, allowing content to be indented+      less then the block header.+    + Support org-ref style citations.  The *org-ref* package is an+      org-mode extension commonly used to manage citations in org+      documents.  Basic support for the `cite:citeKey` and+      `[[cite:citeKey][prefix text::suffix text]]` syntax is added.+    + Split code into separate modules, making for cleaner code and+      better decoupling.++  * Added `docbook5` template.++  * `--mathjax` improvements:++    + Use new CommonHTML output for MathJax (updated default MathJax URL,+      #2858).+    + Change default mathjax setup to use `TeX-AMS_CHTML` configuration.+      This is designed for cases where the input is always TeX and maximal+      conformity with TeX is desired.  It seems to be smaller and load faster+      than what we used before.  See #2858.+    + Load the full MathJax config to maximize loading speed (KolenCheung).++  * Bumped upper version bounds to allow use of latest packages+    and compilation with ghc 8.++  * Require texmath 0.8.6.2.  Closes several texmath-related bugs (#2775,+    #2310, #2310, #2824).  This fixes behavior of roots, e.g.+    `\sqrt[3]{x}`, and issues with sub/superscript positioning+    and matrix column alignment in docx.++  * README:++    + Clarified documentation of `implicit_header_references` (#2904).+    + Improved documentation of `--columns` option.++  * Added appveyor setup, with artefacts (Jan Schulz).++  * stack.yaml versions: Use proper flags used for texmath, pandoc-citeproc.++  * LaTeX template: support for custom font families (vladipus).+    Needed for correct polyglossia operation with Cyrillic fonts and perhaps+    can find some other usages.  Example usage in YAML metadata:++          fontfamilies:+          - name: \cyrillicfont+            font: Liberation Serif+          - name: \cyrillicfonttt+            options: Scale=MatchLowercase+            font: Liberation++  * Create unsigned msi as build artifact in appveyor build.++  * On travis, test with ghc 8.0.1; drop testing for ghc 7.4.1.++++## pandoc 1.17.0.3 (2016-03-24)++  * LaTeX writer: Fixed position of label in figures (#2813).+    Previously the label wasn't in the right place, and `\ref`+    wouldn't work properly.+  * Added .tei test files to pandoc.cabal so they'll be included+    in tarball (#2811).+  * Updated copyright dates.++## pandoc 1.17.0.2 (2016-03-23)++  * Fixed serious regression in `htmlInBalanced`, which caused+    newlines to be omitted in some raw HTML blocks in Markdown+    (#2804).++## pandoc 1.17.0.1 (2016-03-21)++  * File scope is no longer used when there are no input files (i.e.,+    when input comes from stdin).  Previously file scope was triggered+    when the `json` reader was specified and input came from `stdin`,+    and this caused no output to be produced.  (Fix due to Jesse Rosenthal;+    thanks to Fedor Sheremetyev for calling the bug to our attention.)+  * Improved documentation of templates (#2797).++## pandoc 1.17 (2016-03-20)++  * Added `--file-scope` option (Jesse Rosenthal).+    By default pandoc operates on multiple files by first concatenating+    them (around extra line breaks) and then processing the joined file. So+    it only parses a multi-file document at the document scope. This has the+    benefit that footnotes and links can be in different files, but for+    some purposes it is useful to parse the individual files first+    and then combine their outputs (e.g. when the files use footnotes+    or links with the same labels).  The `--file-scope` option causes +    pandoc to parse the files first, and then combine the parsed output,+    instead of combining before parsing. `--file-scope` is selected+    automatically for binary input files (which cannot be concatenated)+    and for pandoc json.++  * Add TEI Writer (Chris Forster) and `tei` output format.++  * Added a general `ByteStringReader` with warnings, used by the docx+    reader (API change, Jesse Rosenthal).++  * Add `readDocxWithWarnings` (API change, Jesse Rosenthal).++  * Changed type of `Shared.uniqueIdent` argument from+    `[String]` to `Set String`.  This avoids performance problems in documents+    with many identically named headers (API change, #2671).++  * Removed `tex_math_single_backslash` from `markdown_github` options+    (#2707).++  * Make language extensions as well as full language names+    trigger syntax highlighting.  For example, `py` will now work as+    well as `python` (jgm/highlighting-kate#83).++  * Added `institute` variable to latex, beamer templates (Fraser+    Tweedale, Josef Svenningsson).++  * Docx reader (Jesse Rosenthal):++    + Handle alternate content.  Some word functions (especially graphics)+      give various choices for content so there can be backwards compatibility.+    + Don't turn numbered headers into lists.+    + Docx Reader: Add state to the parser, for warnings+    + Update feature checklist in source code.+    + Get rid of `Modifiable` typeclass.+    + Add tests for adjacent hyperlinks.+    + Add a "Link" modifier to `Reducible`. We want to make sure that+      links have their spaces removed, and are appropriately smushed+      together (#2689).++  * HTML reader:++    + Fixed behavior of base tag (#2777).+      If the base path does not end with slash, the last component+      will be replaced.  E.g. base = `http://example.com/foo`+      combines with `bar.html` to give `http://example.com/bar.html`.+      If the href begins with a slash, the whole path of the base+      is replaced.  E.g. base = `http://example.com/foo/` combines+      with `/bar.html` to give `http://example.com/bar.html`.+    + Rewrote `htmlInBalanced`.  This version avoids an exponential+      performance problem with `<script>` tags, and it should be faster+      in general (#2730).+    + Properly handle an empty cell in a simple table (#2718).+    + Handle multiple `<meta>` tags with same name.  Put them in a list+      in the metadata so they are all preserved, rather than (as before)+      throwing out all but one..++  * Markdown reader:++    + Improved pipe table parsing (#2765).+    + Allow `+` separators in pipe table cells.  We already allowed+      them in the header, but not in the body rows, for some reason.+      This gives compatibility with org-mode tables.+    + Don't cross line boundary parsing pipe table row.+      Previously an Emph element could be parsed across the newline+      at the end of the pipe table row.+    + Use `htmlInBalanced` for `rawVerbatimBlock`, for better+      performance (#2730).+    + Fixed bug with smart quotes around tex math.++  * LaTeX reader:++    + Handle interior `$` characters in math (#2743).  For example,+      `$$\hbox{$i$}$$`.+    + `inlineCommand` now gobbles an empty `{}` after any command (#2687).+      This gives better results when people write e.g. `\TeX{}` in Markdown.+    + Properly handle LaTeX "math" environment as inline math (#2171).++  * Textile reader: Support `>`, `<`, `=`, `<>` text alignment attributes.+    Closes #2674.++  * Org reader (Albert Krewinkel):++    + Prefix even empty figure names with "fig:" (#2643).  The+      convention used by pandoc for figures is to mark them by prefixing+      the name with `fig:`.  The org reader failed to do this if a figure+      had no name.+    + Refactor link-target processing (#2684).++  * ConTeXt writer: Fix whitespace at line beginning in line blocks (#2744).+    Thanks to @c-foster.++  * HTML writer: Don't include alignment attribute for default table columns.+    Previously these were given "left" alignment.  Better to leave off+    alignment attributes altogether (#2694).++  * Markdown writer: Use hyphens for YAML metadata block bottom line, for+    better compatibility with other Markdown flavors (Henrik Tramberend).++  * LaTeX writer:++    + Use image identifier to create a label and hypertarget for+      figures (Mauro Bieg).+    + Avoid double toprule in headerless table with caption (#2742).+    + Clean up options parser (Jesse Rosenthal).+    + Treat `memoir` template with `article` option as article, instead+      of treating all `memoir` templates as books.+    + Allow more flexible table alignment (Henrik Tramberend, #2665).+      New default is not to include `[c]` option (which is the default+      anyway if no positioning is specified).  Now LaTeX emplates can+      control the overall table alignment in a document by setting the+      longtable length variables `LTleft` and `LTright`.  For example,+      `\setlength\LTleft\parindent\setlength\LTright\fill`+      will create left-aligned tables that respect paragraph indentation.++  * Docx writer: Handle image alt text (#2754, Mauro Bieg).++  * Org writer - pass through RawInline with format "org".++  * DokuWiki writer: use `$$` for display math.++  * Custom writer: Pass attributes parameter to CaptionedImage (#2697).++  * Make protocol-relative URIs work again (#2737).++  * make_osx_package.sh:  Use env variable for developer id certs.++  * Raise `tagsoup` lower bound to 0.13.7 to fix entity-related+    problems (#2734).++  * Allow `zip-archive` 0.3.++  * Allow `aeson` 0.11.++## pandoc 1.16.0.2 (2016-01-12)++  * Depend on deepseq rather than deepseq-generics (fpco/stackage#1096).++  * Fixed regression in latex smart quote parsing (#2645).+    In cases where a match was not found for a quote, everything+    from the open quote to the end of the paragraph was being dropped.++## pandoc 1.16.0.1 (2016-01-10)++  * Fixed regression with `--latex-engine` (#2618). In 1.16+    `--latex-engine` raises an error if a full path is given.++  * Org reader: Fix function dropping subtrees tagged `:noexport`+    (Albert Krewinkel, #2628):++  * Markdown reader: renormalize table column widths if they exceed 100%+    (#2626).++  * Textile reader:  don't allow block HTML tags in inline contexts.+    The reader previously did allow this, following redcloth,+    which happily parses++        Html blocks can be <div>inlined</div> as well.++    as++        <p>Html blocks can be <div>inlined</div> as well.</p>++    This is invalid HTML.  The above sample now produces;++        <p>Html blocks can be</p>+        <div>+        <p>inlined</p>+        </div>+        <p>as well.</p>++  * Improved default template lookup for custom lua scripts (#2625).+    Previously, if you tried to do `pandoc -s -t /path/to/lua/script.lua`,+    pandoc would look for the template in+    `~/.pandoc/templates/default./path/to/lua/script.lua`.+    With this change it will look in the more reasonable+    `~/.pandoc/templates/default.script.lua`.  This makes it possible to+    store default templates for custom writers.++  * RST, Markdown writers: Fixed rendering of grid tables with blank rows+    (#2615).++  * LaTeX writer: restore old treatment of Span (#2624).  A Span is+    now rendered with surrounding `{}`, as it was before 1.16.++  * Entity handling fixes: improved handling of entities like+    `&lang;` that require a trailing semicolon.  Allow uppercase+    `x` in numerical hexidecimal character references, working+    around a tagsoup bug.++  * `stack.yaml` - use lts-4.0, but with older aeson to avoid excessive+    memory use on compile.  With aeson 0.10 we were getting an out of+    memory error on a 2GB Ubuntu 64-bit VM.++  * Improved deb package creation script. Made `DPKGVER` work.+    Renamed `COMMIT` to `TREE`.  You should now be able to do+    `TREE=1.16.0.1 DPKGVER=2 make deb`.+++## pandoc 1.16 (2016-01-02)++  * Added `Attr` field to `Link` and `Image` (Mauro Bieg, #261, API change).++    + Added syntax for link and image attributes to pandoc's Markdown.+    + Updated readers and writers to use link and image attributes+      when appropriate.+    + Support image attributes in Docx, Textile, RST readers.++  * Renamed link attribute extensions.  The old `link_attributes` is+    now `mmd_link_attributes`, and `link_attributes` now enables the+    new pandoc-style link and image attributes (API change).+    Note: this change could break some existing workflows.++  * Implemented `SoftBreak` and new `--wrap` option (#1701, API change).+    Added threefold wrapping option.++    + Command line option: deprecated `--no-wrap`, added+      `--wrap=[auto|none|preserve]`+    + Added `WrapOption`, exported from `Text.Pandoc.Options`+    + Changed type of `writerWrapText` in `WriterOptions` from+      `Bool` to `WrapOption`.+    + Modified `Text.Pandoc.Shared` functions to allow `SoftBreak`.+    + Supported `SoftBreak` in readers and writers.++  * Text.Pandoc.Options:  Added `writerDpi` to `WriterOptions` (API+    change, Mauro Bieg).++  * Added `--dpi` command-line option (Mauro Bieg).++  * Rationalized behavior of `--no-tex-ligatures` and `--smart` (#2541).+    This change makes `--no-tex-ligatures` affect the LaTeX reader+    as well as the LaTeX and ConTeXt writers.  If it is used,+    the LaTeX reader will parse characters `` ` ``, `'`, and `-`+    literally, rather than parsing ligatures for quotation marks+    and dashes.  And the LaTeX writer will print unicode quotation+    mark and dash characters literally, rather than converting+    them to the standard ASCII ligatures.  Note that `--smart` has+    no effect on the LaTeX reader.  `--smart` is still the default+    for all input formats when LaTeX or ConTeXt is the output format,+    *unless* `--no-tex-ligatures` is used.++    Some examples to illustrate the logic:++    ```+    % echo "'hi'" | pandoc -t latex+    `hi'+    % echo "'hi'" | pandoc -t latex --no-tex-ligatures+    'hi'+    % echo "'hi'" | pandoc -t latex --no-tex-ligatures --smart+    ‘hi’+    % echo "'hi'" | pandoc -f latex --no-tex-ligatures+    <p>'hi'</p>+    % echo "'hi'" | pandoc -f latex+    <p>’hi’</p>+    ```++  * Removed deprecated options `--offline` and `--html5`.++  * Fixed language code for Czech (`cs` not `cz`) (#2597).++  * Implemented `east_asian_line_breaks` extension (#2586).+    In `Text.Pandoc.Options`, added `Ext_east_asian_line_breaks` constructor+    to `Extension` (API change).  This extension is like+    `ignore_line_breaks`, but smarter -- it only ignores line breaks+    between two East Asian wide characters.  This makes it better suited+    for writing with a mix of East Asian and non-East Asian scripts.++  * Added support for PDF creation via `wkhtmltopdf`.+    To use this: `pandoc -t html5 -o result.pdf` (and add `--mathjax`+    if you have math.) Margins can be set using the variables+    `margin-top`, `margin-bottom`, `margin-left`, `margin-right`.+    Other styling can be done through CSS.++  * Fixed cite key parsing regression (jgm/pandoc-citeproc#201).+    We were capturing final colons as in `[@foo: bar]`; the citation id+    was being parsed as `@foo:`.++  * ICML writer:++    + Fixed image syntax for local files (#2589).+    + Changed type of `writeICML` (Mauro Bieg).+      API change:  It is now `WriterOptions -> Pandoc -> IO String`.+      Also handle new image attributes.+    + Intersperse line breaks instead of appending them to+      every `ParagraphStyleRange` (Mauro Bieg, #2501).+    + Add `Cite` style to citations (Mauro Bieg).+    + Added figure handling (#2590, Mauro Bieg).+    + Better handling of math.  Instead of just printing the raw tex,+      we now try to fake it with unicode characters.++  * HTML writer: Include `example` class for example lists (#2524).++  * ODT/OpenDocument writer: improved image attributes (Mauro Bieg).++    + Support for percentage widths/heights+    + Use `Attr` instead of title to get dimensions from ODT walker+      to `writeOpenDocument`.++  * AsciiDoc writer:++    + Support anchors in spans and divs with id elements+      (jgm/pandoc-citeproc#143).+    + Fixed code blocks (#1861).++  * Haddock writer:  omit formatting inside links, which isn't supported+    by Haddock (#2515).++  * MediaWiki writer:  Fixed spacing issues in table cells.++    + Start cell on new line unless it's a single Para or Plain+      (#2606).+    + For single Para or Plain, insert a space after the `|` to+      avoid problems when the text begins with a character like+      `-` (#2604).++  * Beamer writer: mark frame as fragile when it contains verbatim (#1613).++  * LaTeX writer:++    + Add support for GAP highlighting using listings (Raniere Silva).+    + Consider `header-includes` content as well as templates+      when determining whether to use csquotes (Andreas Lööw).+    + Create defaults for geometry using `margin-left` etc.+      If `geometry` has no value, but `margin-left`, `margin-right`,+      `margin-top`, and/or `-margin-bottom` are given, a default value+      for `geometry` is created from these.  Note that these variables+      already affect PDF production via HTML5 with `wkhtmltopdf`.++  * ConTeXt writer: set default layout based on `margin-left`, etc.+    This sets up `\setuplayout` based on the variables `margin-left`,+    `margin-right`, `margin-bottom`, and `margin-top`, if no layout+    is given.++  * Docx writer:  better handling of PDF images.  Previously we tried+    to get the image size from the image even if an explicit size was+    specified.  Since we still can't get image size for PDFs, this made+    it impossible to use PDF images in docx.  Now we don't try to get+    the image size when a size is already explicitly specified.++  * Markdown writer:  use raw HTML for link/image attributes when+    the `link_attributes` extension is unset and `raw_html` is set (#2554).++  * MediaWiki reader: interpret markup inside `<tt>`, `<code>` (#2607).++  * LaTeX reader:++    + Improved smart quote parsing (#2555). This fixes redering of+      unmatched quotes.+    + Use curly quotes for unmatched ` (#2555).+    + Allow blank space between braced arguments of commands (#2592).++  * Markdown reader:++    + Improved pipe table relative widths.  Previously pipe table+      columns got relative widths (based on the header underscore lines)+      when the source of one of the rows was greater in width than the+      column width.  This gave bad results in some cases where much of+      the width of the row was due to nonprinting material (e.g. link+      URLs).  Now pandoc only looks at printable width (the width of a+      plain string version of the source), which should give better results.+      Thanks to John Muccigrosso for bringing up the issue.+    + Fixed parsing bug with macros.  Previously macro definitions in+      indented code blocks were being parsed as macro definitions, not code.++  * Textile reader:  skip over attribute in image source (#2515).+    We don't have a place yet for styles or sizes on images, but+    we can skip the attributes rather than incorrectly taking them+    to be part of the filename.++  * Docx reader: Handle dummy list items (Jesse Rosenthal).+    These come up when people create a list item and then delete the+    bullet. It doesn't refer to any real list item, and we used to ignore+    it.++  * CommonMark reader/writer rewritten to use latest `cmark`.++  * Fixed Emoji character definitions (#2523).  There were many bugs in the+    definitions.++  * `Text.Pandoc.CSS`:++    + Added `pickStylesToKVs` function to extract multiple properties at+      once (API change, Mauro Bieg).+    + Parse CSS that doesn't contain the optional semicolon (Mauro Bieg).++  * `trypandoc`: sort drop-down lists.++  * Beamer template:++    + Made `\euro` conditional on presence of character.+      for xelatex and lualatex, as it is for pdflatex (Andrew Dunning).+    + Moved `header-includes` before setting of title (Thomas Hodgson),+      to match the LaTeX template (jgm/pandoc-templates#168).+    + Added `section-titles` variable (defaults to true)+      to enable/suppress section title pages in beamer+      slide shows (Thomas Hodgson).+    + Moved beamer themes after fonts, so that themes can+      change fonts.  (Previously the fonts set were being+      clobbered by lmodern.sty.) (Thomas Hodgson).++  * Beamer/LaTeX template changes (Thomas Hodgson):+    + Added `thanks` variable+    + Use `parskip.sty` when `indent` isn't set (fall back to using+      `setlength` as before if `parskip.sty` isn't available).+    + Use `biblio-style` with biblatex.+    + Added `biblatexoptions` variable.++  * LaTeX template changes:++    + Added `paper` after `$papersize$` variable in latex template.+      Thus you can say `papersize: a4` and the latex will contain+      `a4paper`.  This change may break some existing workflows; if+      you currently specify `a4paper`, you'll get `a4paperpaper` which+      is meaningless.  However, the change seems worth it, as it will+      make the `papersize` variable work uniformly across ConTeXt, LaTeX,+      and html->pdf via wkhtmltopdf.+    + Only pass options to color package if `colorlinks` is set+      (Andrew Dunning).+    + Make definition of `\euro` conditional in xelatex/lualatex,+      as it is already for pdflatex (Andrew Dunning).+    + Removed setting of `subject` in PDF metadata.+      This used to be set to the subtitle, but really the subtitle+      need not give the subject.  Also, `subtitle` can contain formatting,+      so we'd need, at least, a plain text version for this.+    + Moved `header-includes` before setting of `\title`, `\author`,+      etc.  This allows these macros to be redefined.+    + Use `\subtitle` command for `subtitle`, instead of tacking it+      on to the title as before.  We give a no-op fallback definition if it+      is not defined.  This change should produce much better results+      in classes that support `\subtitle`.  With the default article+      class, which does not define `\subtitle`, subtitles will no+      longer be printed unless the user defines `\subtitle` and+      redefines `\maketitle`.+    + Moved redefinitions of `\paragraph` and `\subparagraph` to+      before header-includes.++  * Context template:++    + Use `simplefonts` for font loading (Paolo Rodríguez).  This is+      needed for things to work on ConTeXt stable from TeXLive 2015.+    + Revert use of `\setuphead` in title block (Andrew Dunning,+      Rik Kabel).++  * Update LaTeX/ConTeXt link colour usage (Andrew Dunning).++  * Fixed man template so disabling hyphenation actually works.+    The command needs to come after .TH.++  * Added 'navigation' variable to beamer template (#2543).+    Valid values are `empty` (the default), `horizontal`, `vertical`,+    and `frame`.  Note that this changes the default behavior from+    `horizontal` to `empty`.  Closes #2543.++  * Added `toc` to HTML slide format templates (Andrew Dunning),+    so that `--toc` creates a contents slide.++  * Added `stack.full.yaml` to build `pandoc-citeproc` as well.++  * Allow pipe tables with no body rows (#2556).+    Previously this raised a runtime error.++  * Shared: Improved `fetchItem` so that `C:/Blah/Blah.jpg` isn't treated+    as URL.  The Haskell URI parsing routines will accept "C:" as a+    scheme, so we rule that out manually.  This helps with+    `--self-contained` and absolute Windows paths.++  * Define a `meta-json` variable for all writers (#2019).  This contains+    a JSON version of all the metadata, in the format selected for the+    writer.  So, for example, to get just the YAML metadata, you can run+    pandoc with the following custom template: `$meta-json$`.  The intent+    is to make it easier for static site generators and other tools to get+    at the metadata.++  * Document limitations of --self-contained (#2553).++  * Improved Citations section of README (#2551).  Added information+    about `link-citations` and a link to the pandoc-citeproc man page.++  * `ImageSize`: use `safeRead` instead of `readMaybe`, which isn't+    in base < 4.6.++  * Allow .adoc file extension for AsciiDoc (Andrew Dunning).++  * Improved implicit pandoc-citeproc inclusion.+    The filter pandoc-citeproc is automatically used when+    `--bibliography` is specified on the command line, unless+    `--natbib` or `--biblatex` is used.  However, previously this+    only worked if `--bibliography` was spelled out in full, and not+    if `--biblio` was used.++  * reveal.js: Interpret pauses correctly for all headers (#2530).+    Previously, when using headers below the slide level, pauses are left+    uninterpreted into pauses. In my opinion, unexpected behavior but+    intentional looking at the code.++  * Remove redundant `center` variable for reveal.js (Andrew Dunning).++  * Parsing: Add `extractIdClass`, modified type of `KeyTable` (Mauro+    Bieg, API change).++  * ImageSize:  Added functions for converting between image dimensions+    (Mauro Bieg).++  * Use lts-3.18 in stack.yaml.  This avoids Windows build+    issues with the HTTP library.++  * Bump version bounds for dependencies.++## pandoc 1.15.2.1 (2015-11-16)++  * Added two missing test files, and `stack.yaml`, to+    `extra-source-files` so they're included in the source tarball.++  * reveal.js template: Fixed parallaxBackground options.+    `parallaxBackgroundHorizontal` and `parallaxBackgroundVertical`+    need integer values, not strings.  (Vaughn Iverson)++## pandoc 1.15.2 (2015-11-15)++  * `pandoc my.md -t context -o my.pdf` will now create a PDF using+    ConTeXt rather than LaTeX (#2463).++  * Fixed omitted `url(...)` in CSS data-uri with `--self-contained` (#2489).++  * Added `emoji` Markdown extension, enabled by default in `markdown_github`+    (#2523).  Added `Ext_emoji` to `Extension` in `Text.Pandoc.Options`+    (API change).++  * `Text.Pandoc.Readers.HTML.parseTags`: Fixed over-eager raw HTML inline+    parsing (#2469).  Tightened up the inline HTML parser so it disallows+    TagWarnings.++  * Derive `Generic` instances for the types in `Text.Pandoc.Options`.++  * Org reader:++    + Fix paragraph/list interaction (Albert Krewinkel, #2464).+      Paragraphs can be followed by lists, even if there is no blank line+      between the two blocks.  However, this should only be true if the+      paragraph is not within a list, were the preceding block should be+      parsed as a plain instead of paragraph (to allow for compact lists).+      Thanks to @rgaiacs for bringing this up.+    + Allow toggling header args (Albert Krewinkel, #2269).+      Org-mode allows to skip the argument of a code block header argument if+      it's toggling a value.  Argument-less headers are now recognized,+      avoiding weird parsing errors.+    + Fix markup parsing in headers (Albert Krewinkel, #2504).+      Markup as the very first item in a header wasn't recognized.  This was+      caused by an incorrect parser state: positions at which inline markup+      can start need to be marked explicitly by changing the parser state.+      This wasn't done for headers.  The proper function to update the state+      is now called at the beginning of the header parser, fixing this issue.+    + Fix emphasis rules for smart parsing (Albert Krewinkel, #2513).+      Smart quotes, ellipses, and dashes should behave like normal quotes,+      single dashes, and dots with respect to text markup parsing.+    + Require whitespace around definition list markers (#2518).+      This rule was not checked before, resulting in bugs with footnotes+      and some link types.++  * Markdown reader:++    + Pipe tables with long lines now get relative cell widths (#2471).+      If a pipe table contains a line longer than the column width (as set by+      `--columns` or 80 by default), relative widths are computed based on the+      widths of the separator lines relative to the column width.  This should+      solve persistent problems with long pipe tables in LaTeX/PDF output, and+      give more flexibility for determining relative column widths in other+      formats, too.  For narrower pipe tables, column widths of 0 are used,+      telling pandoc not to specify widths explicitly in output formats that+      permit this.+    + Improved parser for `mmd_title_block`.  We now allow blank metadata+      fields.  These were explicitly disallowed before.+    + Citation keys can now contain `://`, so URLs and DOIs can be used+      as citation keys (jgm/pandoc-citeproc#166).++  * Beamer template:  fix incompatibility of section slides with natbib.+    Natbib (and presumably biblatex) bibliography commands create+    their own section.  Since these are in frame environments,+    we have an incompatibility with the `\AtBeginSection` macro+    which creates a special frame when a new section occurs.+    (We can't have a frame inside another frame.) This change disables+    `\AtBeginSection` inside bibliography slides.  Thinks to Yihui Xie for+    bringing the problem to my attention.  This supersedes #145.  See+    discussion there.++  * Textile reader:  don't do smart punctuation unless explicitly asked+    (#2480).  Note that although smart punctuation is part of the textile+    spec, it's not always wanted when converting from textile+    to, say, Markdown.  So it seems better to make this an option.++  * LaTeX reader: Handle `comment` environment (Arata Mizuki).+    The `comment` environment is handled in a similar way to the+    `verbatim` environment, except that its content is discarded.++  * Docx reader:  Follow relationships correctly in foot/endnotes (#2258,+    Jesse Rosenthal).  This fixes a problem with links in notes.++  * LaTeX and ConTeXt writers: support `lang` attribute on divs and spans+    (mb21).  For LaTeX, also collect `lang` and `dir` attributes on spans and+    divs to set the `lang`, `otherlangs` and `dir` variables if they aren’t set+    already.  See #895.++  * LaTeX writer:++    + Use proper command for `\textarabic` (mb21).+    + Added `de-CH-1901`, fixed `el-polyton` in `toPloyglossia` (Nick Bart).+    + Use `\hypertarget` and `\hyperlink` for links.  This works correctly+      to link to Div or Span elements.  We now don't bother defining `\label`+      for Div or Span elements.  Closes jgm/pandoc-citeproc#174.+    + Avoid footnotes in list of figures (#1506).+    + Properly handle footnotes in captions (#1506).+    + Add `\protect` to `\hyperlink` (#2490).  Thanks to Hadrien Mary.+    + Set `colorlinks` if `linkcolor`, `urlcolor`, `citecolor`, or+      `toccolor` is set (#2508).++  * Textile writer: support start number in ordered lists (#2465).++  * OpenDocument writer:  Allow customization of opendocument+    automatic styles.  Automatic styles can now be inserted in the+    template, which now provides the enclosing `<office:automatic-styles>`+    tags (#2520).++  * Docx writer:  insert space between footnote reference and note (#2527).+    This matches Word's default behavior.++  * EPUB writer:  don't download linked media when `data-external` attribute+    set (#2473).  By default pandoc downloads all linked media and includes it+    in the EPUB container.  This can be disabled by setting `data-external` on+    the tags linking to media that should not be downloaded.  Example:++        <audio controls="1">+         <source src="http://www.sixbarsjail.it/tmp/bach_toccata.mp3"+         type="audio/mpeg"></source>+        </audio>++  * HTML writer:  use width on whole table if col widths sum to < 100%.+    Otherwise some browsers display the table with the columns+    separated far apart.++  * AsciiDoc template:  Fix `author` and `date`; add `keywords`,+    `abstract` (Andrew Dunning).++  * HTML-based templates (Andrew Dunning):++    + Use en dash instead of hyphen between title prefix and title.+    + Add `keywords` to metadata.+    + Add `lang`, `dir`, `quotes` where missing.+    + Always make author and date display conditional.+    + Updated dzslides template from source.++  * Man template: make "generated by" comment conditional.++  * LaTeX, Beamer templates:++    + Add `babel-otherlangs` for language divs/spans; `babel-newcommands`,+      filled by commands that make babel understand the polyglossia-style+      language directives (mb21, #137).+    + Improved formatting of conditionals; `$for$` is always provided to allow+      multiple options (Andrew Dunning, #141).+    + Use `Ligatures=TeX` rather than `Mapping=tex-text` with `fontspec`+      to improve support for LuaTeX (Andrew Dunning, #135).+    + Revise `hyperref` usage (Andrew Dunning, #139, #141):+        - use same options for all LaTeX engines;+        - add `subtitle` and `keywords` to PDF metadata;+        - do not override `hyperref` link coloring without user input, effectively making+          the `hidelinks` option the default (removed as a separate variable);+        - link colors can be enabled (using a slightly darker version of the old+          defaults) using a new `colorlinks` variable, automatically used by+          the LaTeX writer when custom colors are specified;+        - `pdfborder={0 0 0}` is automatically set by `hyperref` with+          `colorlinks`, and is only applied if `colorlinks` is disabled.++  * ConTeXt template (Andrew Dunning):++    + New variables for controlling styles: `linkstyle`, `linkcolor`,+      `linkcontrastcolor`, `layout`, `pagenumbering`, `whitespace`, `indenting`,+      `interlinespace`, `headertext`, `footertext`, `mainfont`, `sansfont`,+      `monofont`, `mathfont`, `fontsize`.+    + Default template no longer supports MkII.+    + Improve writing of title block (suppressing numbering of first page).+    + Add `title` `subtitle`, `author`, `date`, `keywords` to PDF metadata.+    + Support `subtitle`, `abstract`.+    + Support list of figures (`lof`), list of tables (`lot`).+    + Disable link styling by default.+    + Define styles for all section types.+    + Enable microtype.+    + Improved formatting of conditionals.++  * Beamer template:  added code to prevent slide breaks inside paragraphs+    (#2422, thanks to Nick Bart).  This will matter, in practice, only when+    `allowframebreaks` is used.  It is especially helpful for bibliography+    slides.++  * OpenDocument template:  Add `<office:automatic-styles>` tag around+    automatic styles.  The writer now longer provides this (see #2520).++  * Restored Text.Pandoc.Compat.Monoid.++  * Do not export (<>) from custom Prelude.  The Prelude now matches+    base 4.8 Prelude's API.++  * Don't use custom prelude with ghc 7.10.  Use the custom prelude+    only for earlier versions.  This change makes `stack ghci` and+    `cabal repl` work (#2503), at least with ghc 7.10.++  * Changed § to % in operators from Odt.Arrows.Utils (#2457).+    This prevents problems building haddocks with "C" locale.++  * Change default for old-locale flag to False.++  * Use stack in deb, osx, and Windows package generators.++  * Added Vagrantfile for building deb in vm.+    This should help in automating binary package creation.  'make package'+    will make the package.  'make package COMMIT=blah' will make the package+    from commit blah.++  * README:++    + Consistent capitalization for pandoc and Markdown.+    + Fixed `auto_identifiers` examples (Benoit Schweblin).+    + Improved documentation of template variables (Andrew Dunning).++## pandoc 1.15.1 (2015-10-15)++  * `pandocVersion` is now defined in `Text.Pandoc.Shared`+    and reexported from `Text.Pandoc` (Alex Vong).  This allows+    writers to access it.  (Alex Vong) (API change)++  * For `markdown_mmd`, add: `implicit_figures`, `superscripts`,+    `subscripts` (#2401).++  * Added `odt` as input format (MarLinn).  Added new module+    `Text.Pandoc.Reader.ODT` (API change). Fully implemented features:+    Paragraphs, Headers, Basic styling, Unordered lists, Ordered lists,+    External Links, Internal Links, Footnotes, Endnotes, Blockquotes.+    Partly implemented features: Citations, Tables.++  * Markdown Reader:++    + Add basic tests for each header style (Ophir Lifshitz).+    + Add implicit header ref tests for headers with spaces (Ophir Lifshitz).+    + Skip spaces in headers (Ophir Lifshitz).+    + Handle 'id' and 'class' in parsing key/value attributes (#2396).+      `# Header {id="myid" class="foo bar"}`+      is now equivalent to `# Header {#myid .foo .bar}`.+    + Use '=' instead of '#' for atx-style headers in markdown+lhs.+      (Kristof Bastiaensen)+    + Pipe tables: allow indented columns.  Previously the left-hand column+      could not start with 4 or more spaces indent.  This was inconvenient+      for right-aligned left columns.  Note that the first (header column)+      must still have 3 or fewer spaces indentation, or the table will be+      treated as an indented code  block.+    + Fix regression:  allow HTML comments containing `--`.+      Technically this isn't allowed in an HTML comment, but+      we've always allowed it, and so do most other implementations.+      It is handy if e.g. you want to put command line arguments+      in HTML comments.++  * LaTeX reader:++    + Don't eat excess whitespace after macros with only optional+      arguments (#2446).+    + Support longtable (#2411).+    + Implement `\Cite` (#2335).+    + Support abstract environment.  The abstract populates an+      `abstract` metadata field.+    + Properly handle booktabs lines.  Lines aren't part of the+      pandoc table model, so we just ignore them (#2307).++  * HTML reader:++    + Handle type attribute on ol, e.g. `<ol type="i">` (#2313).+    + Updated for new automatic header attributes.+    + Add auto identifiers if not present on headers.  This makes+      TOC linking work properly.+    + Detect `font-variant` with `pickStyleAttrProps` (Ophir Lifshitz).+    + Test `<ol>` type, class, and inline list-style(-type) CSS+      (Ophir Lifshitz).+    + Better handling of "section" elements (#2438).  Previously+      `<section>` tags were just parsed as raw HTML blocks.  With+      this change, section elements are parsed as Div elements with+      the class "section".++  * MediaWiki reader:  handle unquoted table attributes (#2355).++  * DocBook reader:++    + Added proper support for DocBook `xref` elements (Frerich Raabe).+      Added `dbContent` field to reader state, so we can lookup+      cross refs.+    + Handle `informalexample` (#2319).++  * Docx Reader:++    + Create special punctuation test (Ophir Lifshitz).+    + Parse soft, no-break hyphen elements (Ophir Lifshitz).+    + Updated headers test (Ophir Lifshitz). Replaced `styles.xml`+      in `headers.docx` with pandoc's current `styles.xml`, which+      contains styles for Heading 1 through 6. Added Heading 4+      through 7 to the test document. Note that Heading 7 is not+      parsed as a Heading because there is no Heading 7 style.++  * RST reader:  better handling of indirect roles.+    Previously the parser failed on this kind of case++        .. role:: indirect(code)++        .. role:: py(indirect)+           :language: python++        :py:`hi`++    Now it correctly recognizes `:py:` as a code role.++  * Org reader:++    + Add auto identifiers if not present on headers+      (#2354, Juliusz Gonera).+    + Allow verse blocks to contain empty lines (#2402,+      Albert Krewinkel).++  * EPUB reader:  stop mangling external URLs (#2284).++  * RST writer:++    + Don't insert `\ ` when complex expression in matched pairs.+      E.g. `` [:sup:`3`] `` is okay; you don't need `` [:sup:`3`\ ] ``.+    + Ensure that `\ ` is inserted when needed before Cite and Span+      elements that begin with a "complex" element (jgm/pandoc-citeproc#157).+    + Normalize headers only in "standalone" mode (#2394).++  * Haddock writer: escape `*` and `^` (G. Bataille).++  * Markdown writer:++    + In TOC, add links to headers (#829).+    + Use unicode super/subscripts for digits in plain output+      (when the `superscripts` and `subscripts` extensions are+      not enabled).++  * Docx writer:++    + Moved invalid character stripping to `formattedString`.+      This avoids an inefficient generic traversal (#2356).+    + Use user data directory for `reference.docx` archive.+      This allows the test suite to work without installing pandoc first.+      It also brings the docx writer in line with the odt writer.+    + Tests:  docx writer tests now use `../data` for data directory.+      This allows tests to be run without installing first.+    + Tests: Use real jpg (not empty) for docx tests to avoid warning.++  * LaTeX writer:++    + Fixed detection of 'chapters' from template.+      If a documentclass isn't specified in metadata, but the+      template has a hardwired bookish documentclass, act as if+      `--chapters` was used.  This was the default in earlier+      versions, but it has been broken for a little while.+    + Correctly recognize book documentclass in metadata (#2395).+    + Set language-related variables automatically, depending+      on the value of the `lang` field, which is now always+      assumed to be in BCP47 format (mb21, #1614, #2437).+    + Add `\protect` to `\hyperdef` in inline context.  This way we+      don't get an error when this is used as a moveable argument (#2136).+    + Support all frame attributes in Beamer.+    + Percent-encode more special characters in URLs (#1640, #2377).+      The special characters are '<','>','|','"','{','}','[',']','^', '`'.++  * HTML writer:++    + Update KaTeX JS and CSS versions (Emily Eisenberg).+    + For dzslides, add `role="note"` for speaker notes (#1693).+    + Percent-encode more special characters in URLs (#1640, #2377).+      The special characters are '<','>','|','"','{','}','[',']','^', '`'.+    + Render Div with class `section` as `<section>` in HTML5.++  * EPUB writer:++    + In TOC, replace literal `<br/>` with space (#2105).+    + With `--webtex`, include image file rather than `data:` URI (#2363).++  * Native writer: format Div properly, with blocks separated.++  * Support bidirectional text output with XeLaTeX, ConTeXt and HTML+    (#2191, mb21).++  * Reference Docx:++    + Add missing Header 6 style (steel blue) (Ophir Lifshitz).+    + Correct `outlineLvl` for Header styles (Ophir Lifshitz).++  * Templates++    + Beamer:  Add `innertheme`, `outertheme` variables+      (Guilhem Bonnefille, #121). Add space after colon in figure caption.+      Integrate recent font and language updates from LaTeX template;+      allow use of `mainfont` variable for changing the slide text+      in XeTeX and LuaTeX (Andrew Dunning, #131).+    + LaTeX:  Add `mainfontoptions`, `sansfontoptions`,+      `monofontoptions`, `mathfontoptions`, `fontfamilyoptions`+      (Andrew Dunning, #122).  Support handling of bidirectional+      text (mb21, #120). Improve reliability of superscripts/subscripts+      under XeTeX and prevent letters and numbers from appearing on a+      different baseline by removing use of the `realscripts` package+      (via `xltxtra`).  To restore use of OpenType characters for these+      features under XeTeX or LuaTeX, add `\usepackage{realscripts}` to+      `header-includes` (Andrew Dunning, #130).  Remove redundant+      reference to `xunicode` (Andrew Dunning, #130).  Add `fontenc`,+      `indent`, `subparagraph` variables (Andrew Dunning).+      Allow use of `hidelinks` variable for `hyperref` package (Hugo Roy,+      #113).  Prevent package clash with `tufte-latex` and other classes that+      include `hyperref` or `color` (Xavier Olive, #115).+    + ConTeXt:  Support handling of bidirectional text (mb21, #120).+    + LaTeX and ConTeXt: Use more specific language variables.+      Instead of directly using `lang`, we now use `babel-lang` and+      `polyglossia-lang` and `context-lang`.  These variables are set by+      the writers to the necessary values, based on the `lang` variable+      (which now always takes a value in BCP47 format). (mb21, #114, #129).+    + HTML:  Support handling of bidirectional text (mb21, #120).+      Move HTML5 shiv after CSS and fix URL (Andrew Dunning).+      Add dir attribute in html5 (Andrew Dunning).+    + reveal.js: Add `controls`, `progress` variables (Grégoire Pineau, #127).+      Add `width`, `height` variables (Anrew Dunning).  Update template+      from 3.1 source (Andrew Dunning).  All configuration options are now+      available as variables, but are only be included if set (reveal.js+      uses defaults otherwise).+    + man: Added comment stating that the page is autogenerated by pandoc,+      giving version.  Added `adjusting` and `hyphenate` variables+      (Alex Vong, #123).++  * epub.css: added selectors for nested emphasis (Pablo Rodriguez).++  * MediaBag:  ensure that `/` is always used as path separator.++  * `sample.lua`: define `CaptionedImage`, add newline at end (#2393).++  * Added `--bash-completion` option.  This generates a bash completion+    script.  To use: `eval "$(pandoc --bash-completion)"`.++  * Text.Pandoc.Error: Define Typeable and Exception instances+    for PandocError (#2386).++  * Text.Pandoc.Parsing: `toKey`: strip off outer brackets.+    This makes keys with extra space at the beginning and end+    work:  e.g.++        [foo]: bar++        [ foo ]++    will now be a link to bar (it wasn't before).++  * Text.Pandoc: disable `auto_identifiers` for epub.+    The epub writer inserts its own auto identifiers;+    this is more complex due to splitting into "chapter" files.++  * Renamed Text.Pandoc.Compat.Locale -> Text.Pandoc.Compat.Time.+    It now reexports Data.Time.++  * Use custom Prelude to avoid compiler warnings.++    + The (non-exported) prelude is in prelude/Prelude.hs.+    + It exports Monoid and Applicative, like base 4.8 prelude,+      but works with older base versions.+    + It exports (<>) for mappend.+    + It hides 'catch' on older base versions.++  * Added a `stack.ymal` and stack install instructions to INSTALL.++  * Clarified what is "out of scope" in README and CONTRIBUTING.md.++  * Added note to CONTRIBUTING.md about ghc versions and travis.++  * Clarify docs on block quotes.  The space after `>` is optional (#2346).++  * Removed obsolete reference to default.csl (#2372).++  * List all styles in manual for `--reference-docx` (Chris Black)++  * Don't capitalize header links in man page.++  * Added section on repl to CONTRIBUTING.md.++  * README:  Added space after backslash in image example (#2329).++  * Document details of citation locator terms (Nick Bart).++  * Fixed some internal links in README (#2309).++  * Improve CSL documentation, variables documentations,+    links, and cross-references in README. (Andrew Dunning)++  * Fix build failure with `--flags=-https` (Sergei Trofimovich).++  * Use `newManager` instead of `withManager` in recent `http-client`.+    This avoids a deprecation warning.++  * Allow building with latest versions of http-types,+    HUnit, criterion, syb, aeson.++  * Updated benchmark program for new criterion API.++  * Setup.hs: rewrite so as not to use process, directory, filepath.+    Using anything outside base is dangerous, since older+    versions of ghc may link against two different versions.++  * Added appveyor (Windows continuous integration) builds.++  * New `.travis.yml`.  Autgenerated using `make_travis_yml.hs`.+    This script has been modified in a few ways, e.g. to add `GHCOPTS`.+    `make .travis.yml` regenerates it based on the tested-with+    field of the cabal file.++## pandoc 1.15.0.6 (2015-07-15)++  * `--self-contained`: Fixed overaggressive CSS minimization+    (#2301, 2286). Previously `--self-contained` wiped out all+    spaces in CSS, including semantically significant spaces.+    This was a regression from 1.14.x.++  * Markdown reader: don't allow bare URI links or autolinks in link+    label (#2300).  Added test cases.++  * `Text.Pandoc.Parsing`, `uri`: Improved bare autolink detection (#2299).+    Previously we disallowed `-` at the end of an autolink,+    and disallowed the combination `=-`.  This commit liberalizes the+    rules for allowing punctuation in a bare URI, and adds test cases.+    One potential drawback is that you can no longer put a bare+    URI in em dashes like this:+    `this uri---http://example.com---is an example.`+    But in this respect we now match github's treatment of bare URIs.++  * HTML writer:  support speaker notes in dzslides.+    With this change `<div class="notes">` and also `<div class="notes"+    role="note">` will be output if `-t dzslides` is used. So we can+    have speaker notes in dzslides too.  Thanks to maybegeek.++  * Updated dzslides template.++  * Improved documentation of options to print system default files (#2298).+    `--print-default-data-file` and `--print-default-template`.++  * DokuWiki writer: use `$..$` for Math instead of `<math>..</math>`+    (Tiziano Müller).  MathJax seems currently to be the only maintained+    math rendering extension for DokuWiki.++  * `Text.Pandoc.Shared`: Changed `hierarchicalize` so it treats references+    div as top-level header (#2294).  This fixes a bug with `--section-divs`,+    where the final references section added by pandoc-citeproc, enclosed in+    its own div, got nested in the div for the section previous to it.++  * Allow vector 0.11.++  * Require cmark > 0.4.++## pandoc 1.15.0.5 (2015-07-10)++  * HTML writer: Fixed email javascript obfuscation with `mailto:`+    URLs (#2280).  This fixes a potential security issue.  Because+    single quotes weren't being escaped in the link portion, a+    specially crafted email address could allow javascript code injection.++  * RST reader:  allow inline formatting in definition list field+    names (Lars-Dominik Braun).++  * PDF:  Make sure `--latex-engine-opt` goes before the filename+    on the command line.  LaTeX needs the argument to come after+    the options (#1779).++  * CommonMark writer: fixed tags used for super/subscript.++  * ConTeXt template:  activate hanging indent for definition lists+    (mb21).++  * Make cabal require `hsb2hs` >= 0.3.1 if `embed_data_files` specified.+    This is done by adding `hookedPrograms` in `Setup.hs`, which allows us+    to include `hsb2hs` in Build-Tools in cabal.++  * Improved Windows installer (thanks to nkalvi).++    + When per-machine installation is chosen, the system path+      is updated instead of the user's.+    + An appropriate default is used for per-machine installation+      directory.+    + Admin privileges are no longer required for a per-user install++  * Travis:  unpack sdist for build to catch packaging bugs.++  * Improved documentation on where user templates go (#2272).++## pandoc 1.15.0.4 (2015-07-03)++  * Added pandoc.1 man page to the repository.  It is no longer+    built as part of the cabal build process. (This proved too+    fragile.)  pandoc.1 can be regenerated (`make man/pandoc.1`)+    when `README` is changed.++  * Copying of the man page now respects `--destdir` (#2262).++  * Improved error messages for filters.  User is now informed if+    the filter requires an interpreter that isn't found in the path,+    or if the filter returns an error status.++## pandoc 1.15.0.3 (2015-07-02)++  * Ensure target directory is created when installing man page.++## pandoc 1.15.0.2 (2015-07-02)++  * Added files needed for building man page to Extra-Source-Files.++## pandoc 1.15.0.1 (2015-07-01)++  * Man page is now built and installed as part of the cabal build+    process. Removed Makefile target for man page.++## pandoc 1.15 (2015-07-01)++  * Man page changes:++    + Removed `--man1`, `--man5` options (breaking change).+    + Removed `Text.Pandoc.ManPages` module (breaking API change).+    + Makefile target for `man/man1/pandoc.1`.  This uses pandoc to+      create the man page from README using a custom template and filters.+    + Added `man/` directory with template and filters needed to build+      man page.+    + We no longer have two man pages: `pandoc.1` and `pandoc_markdown.5`.+      Now there is just pandoc.1, which has all the content from README.+      This change was needed because of the extensive cross-references+      between parts of the README.+    + Removed old `data/pandoc.1.template` and+      `data/pandoc_markdown.5.template`.++  * OpenDocument writer: Do not add a carriage return after a hard+    line break (Michael Chladek).++  * ConTeXt writer:++    + use `\goto` for internal links.+    + Added a `%` at end for `\reference` to avoid spurious space.++  * Ignore sandbox on 'make quick'++## pandoc 1.14.1 (2015-06-30)++  * Added `--man1` and `--man5` options to pandoc, allowing+    pandoc to generate its own man pages. Man pages are no longer+    automatically generated in the build process (the process for+    this was too complex and prone to failure, #2190). The+    `make-pandoc-man-pages` executable has been removed. The+    `man/` directory has been removed, and man page templates+    have been moved to `data/`. NOTE TO PACKAGERS: You will no+    longer find pandoc's man pages in `man/`, but you can+    generate them using `pandoc --man1 > pandoc.1` and `pandoc+    --man5 > pandoc_markdown.5`.++  * Added new unexported module:  `Text.Pandoc.ManPages`.++  * `README` now acts like a data file (even though it isn't in+    `data/`).  So, for example, `pandoc --print-default-data-file README`+    will produce the README.)  This change was required for the `--man1`+    and `--man5` options, since the man pages are produced from the+    README, but it may be useful for other purposes as well.++  * Allow `reference.docx` and `reference.odt` to be used with+    `--print-default-data-file` and to shadow defaults if placed in+    the user data directory.  Note that as of 1.14, we no longer+    include these files as data files; instead, we include their+    components.  This change causes pandoc to behave as if it has+    these data files; they are constructed on demand when needed+    using `getDefaultReferenceDocx` and `getDefaultReferenceODT`.++  * Fixed regression in CSS parsing with `--self-contained` (#2224).+    Pandoc 1.14.0.x used css-text to parse the CSS, but its parser+    silently drops big sections of CSS.  This commit replaces the+    use of css-text with a small but principled CSS preprocessor,+    which removes whitespace and comments and replaces `url()` with+    base 64 data when possible.++  * Use `https://` instead of `//` for MathJax and KaTeX CDN URLs (#1920).+    This will allow math to work when pages are being viewed locally.++  * `Text.Pandoc.Options`:  Export `plainExtensions`.+    These are the extensions used in `plain` output.++  * LaTeX reader: Don't parse `_` and `^` as sub/superscript outside of+    math mode; treat them as regular inline text.  Normally these will+    cause an error in LaTeX, but there are contexts (e.g. `alltt`+    environments) where they are allowed.++  * HTML reader:  allow `<body>` to close `<head>`.++  * DocBook reader: support `mediaobject`s and `figures` (#2184, mb21).++  * RST reader: Fix reference names with special characters+    (Lars-Dominik Braun).++  * Textile writer:  escape `+` and `-` as entities (#2225).++  * DokuWiki writer: Use proper `<code>` tags for code blocks (#2213).++  * Plain writer:  don't use symbols for super/subscript (#2237).+    Simplified code by using `plainExtensions`.++  * InDesign writer: Properly escape URLs containing more than one+    colon character (gohai).++  * Docx writer: Make sure we use dist version of `reference.docx`+    (and not the user's version) for certain settings.  Taking some+    settings values from a user-supplied reference.docx can lead to+    corruption.  This fixes a regression from the last release (#2249).++  * `Text.Pandoc.Shared`: exports `getDefaultReferenceDocx` and+    `getDefaultReferenceODT` (API change).  These functions have been+    removed from the Docx and ODT writers.++  * LaTeX template (Xavier Olive):+    + Added `CJKmainfont` and `CJKoptions` variables.+    + Allow dvipsnames (e.g. `MidnightBlue`) for colors (Xavier Olive).++  * Epub templates:  use `author.role`, not `author.type`.++  * Bump cmark version to >= 0.3.4.++  * Improved Windows installer (#2205, thanks to nkalvi).+    Users can now select a per-user or systemwide install, and can set+    the installation path.  At the end of installation, the install location+    is given.  The install location is also now given in the list of+    installed programs in Control Panel.  Cleaner WiX syntax is used for+    setting the path.++  * Added `download_stats` target to Makefile.++## pandoc 1.14.0.4 (2015-06-02)++  * Added missing commonmark template.++  * Improved try pandoc (moved button, show raw command).++## pandoc 1.14.0.3 (2015-06-01)++  * Allow compilation with syb 0.5.*.++  * Custom writer:  fixed some compiler warnings for ghc < 7.10.++## pandoc 1.14.0.2 (2015-05-31)++  * Allow building with hslua 0.4.++## pandoc 1.14.0.1 (2015-05-28)++  * Fixed problem with building of `reference.docx` and `reference.odt`+    when the `embed_data_files` flag is used.  Instead of having a phase+    of the build where `reference.docx` and `reference.odt` are created+    from their constituent data files, we now construct these archives+    from their constituents when a `docx` or `odt` is built.  The+    constituent files have been moved from `extra-source-files` to+    `data-files`, and `reference.docx` and `reference.odt` have been+    removed. Users can create their own `reference.docx` or+    `reference.odt` by using pandoc to create a simple `docx` or `odt`.+    `make-reference-files.hs` has been removed, simplifying the build+    process (#2187)++  * Don't include generated man pages in extra-source-files (#2189).++  * Bumped upper bound for aeson.++  * ConTeXt writer:  create internal link anchors for Div elements with+    identifiers.  (This is needed for linked citations to work.)++## pandoc 1.14 (2015-05-27)++### New features++  * Added `commonmark` as input and output format.++  * Added `--verbose` flag for debugging output in PDF production (#1840,+    #1653).++  * Allow wildcards in `--epub-embed-font` arguments (#1939).++  * Added `--latex-engine-opt` option (#969, #1779, Sumit Sahrawat).++  * Added `shortcut_reference_links` extension (Konstantin Zudov, #1977).+    This is enabled by default for those markdown flavors that+    support reading shortcut reference links, namely: `markdown`,+    `markdown_strict`, `markdown_github`, `markdown_php`.+    If the extension is enabled, the reader parses shortcut reference+    links like `[foo]`, and the writer creates such links unless doing+    so would cause problems.  Users of markdown flavors that support+    shortcut reference links should not notice a difference in reading+    markdown, but the markdown pandoc produces may differ.+    If shortcut links are not desired, the extension can be disabled+    in the normal way.++### Behavior changes++  * `--toc` is now supported for `docx` output (#458, Nikolay Yakimov).+    A "dirty" TOC is created at the beginning of document.+    It can be regenerated after the document has been opened.++  * An implicit `--filter pandoc-citeproc` is now triggered only when the+    `--bibliography` option is used, and not when the `bibliography`+    field in metadata is specified (#1849).++  * Markdown reader:++    + Reference links with `implicit_header_references` are no longer+      case-sensitive (#1606).+    + Definition lists no longer require indentation for first line (#2087).+      Previously the body of the definition (after the `:` or `~` marker)+      needed to be in column 4.  This commit relaxes that requirement,+      to better match the behavior of PHP Markdown Extra.  So, now+      this is a valid definition list:++            foo+            : bar+    + Resolve a potentially ambiguity with table captions:++            foo++              : bar++              -----+              table+              -----++      Is "bar" a definition, or the caption for the table?  We'll count+      it as a caption for the table.+    + Disallow headerless pipe tables (#1996), to conform to GFM and PHP+      Markdown Extra.  Note:  If you have been using headerless pipe tables,+      this change may cause existing tables to break.+    + Allow pipe tables with header but no body (#2017).+    + Allow a digit as first character of a citation key (Matthias Troffaes).+      See https://github.com/jgm/pandoc-citeproc/issues/97++  * LaTeX reader:++    + Don't limit includes to `.tex` extension (#1882).+      If the extension is not `.tex`, it must be given explicitly in+      the `\input` or `\include`.++  * Docx reader:++    + Allow numbering in the style file.  This allows inherited styles+      with numbering (lists) (Jesse Rosenthal).++  * Org reader:++    + Support smart punctuation (Craig Bosma).+    + Drop trees with a :noexport: tag (Albert Krewinkel). Trees having a+      `:noexport:` tag set are not exported.  This mirrors org-mode.+    + Put header tags into empty spans (Albert Krewinkel, #2160).+      Org mode allows headers to be tagged: `* Headline  :TAG1:TAG2`.+      Instead of being interpreted as part of the headline, the tags are now+      put into the attributes of empty spans.  Spans without textual content+      won't be visible by default, but they are detectable by filters.  They+      can also be styled using CSS when written as HTML.+    + Generalize code block result parsing (Albert Krewinkel).+      Previously, only code blocks were recognized as result blocks;+      now, any kind of block can be the result.++  * Append newline to the LineBreak in Dokuwiki, HTML, EPUB,+    LaTeX, MediaWiki, OpenDocument, Texinfo writers (#1924, Tim Lin).++  * HTML writer:++    + Add "inline" or "display" class to math spans (#1914).+      This allows inline and display math to be styled differently.+    + Include raw latex blocks if `--mathjax` specified (#1938).+    + Require highlighting-kate >= 0.5.14 (#1903).+      This ensures that all code blocks will be wrapped in a `div`+      with class `sourceCode`.  Also, the default highlighting CSS+      now adds `div.sourceCode { x-overflow: auto; }`, which means+      that code blocks (even with line numbers) will acquire a scroll+      bar on screens too small to display them (e.g. mobile phones).+      See also jgm/highlighting-kate#65.++  * LaTeX writer:++    + Use a declaration for tight lists (Jose Luis Duran, Joseph+      Harriott). Previously, pandoc hard-coded some commands to make+      tight lists in LaTeX.  Now we use a custom command instead,+      allowing the styling to be changed in a macro in the header.+      (Note:  existing templates may need to be modified to include+      the definition of this macro.  See the current template.)+    + Beamer output: if the header introducing a slide has the+      class `fragile`, add the `[fragile]` option to the slide (#2119).++  * MediaWiki writer:++    + Use `File:` instead of the deprecated `Image:` for images and+      other media files (Greg Rundlett).++  * DocBook writer:++    + Render a `Div (id,_,_) [Para _]` element as a `para` element+      with an `id` attribute.  This makes links to citations work in+      DocBook with pandoc-citeproc.++  * RST writer:++    + Normalize headings to sequential levels (Nikolay Yakimov).+      This is pretty much required by docutils.+    + Treat headings in block quotes, etc as rubrics (Nikolay Yakimov).+    + Better handling of raw latex inline (#1961).  We use+      `` :raw-latex:`...` `` and add a definition for this role to+      the template.++  * EPUB writer:++    + Remove `linear=no` from cover `itemref` (#1609).+    + Don't use `sup` element for epub footnotes (#1995).+      Instead, just use an a element with class `footnoteRef`.+      This allows more styling options, and provides better results+      in some readers (e.g. iBooks, where anything inside the a+      tag breaks popup footnotes).+    + Take TOC title from `toc-title` metadata field.++  * Docx writer:++    + Implemented `FirstParagraph` style (Jesse Rosenthal).+      Following the ODT writer, we add the `FirstParagraph` style to the+      first text paragraph following an image, blockquote, table, heading,+      or beginning of document.  This allows it to be styled differently.+      The default is for it to be the same as `Normal`.+    + Added `BodyText` style (Jesse Rosenthal).+      We apply a `BodyText` style to all unstyled paragraphs. This is,+      essentially, the same as `Normal`, except that since not everything+      inherits from `BodyText` (the metadata won't, for example, or+      the headers or footnote numbers), we can change the text in the body+      without having to make exceptions for everything.  If we do want to+      change *everything*, we can still do it through `Normal`.+    + Altered `Blockquote` style slightly (Jesse Rosenthal).+      Since `BlockQuote` derives from `BodyText`, we just want to specify+      by default that it won't indent, regardless of what `BodyText` does.+      Note that this will not produce any visible difference in the default+      configuration.+    + Take TOC title from `toc-title` metadata field (Nikolay Yakimov).+    + Added a style to figure images (Nikolay Yakimov).+      Figures with empty captions use style `Figure`.+      Figures with nonempty captions use style `Figure with Caption`, which+      is based on `Figure`, and additionally has `keepNext` set.++  * ODT writer:++    + Added figure captions (Nikolay Yakimov). The following styles are+      used for figures:+      `Figure` -- for figure with empty caption),+      `FigureWithCaption` (based on `Figure`) -- for figure with caption,+      `FigureCaption` (based on `Caption`) -- for figure captions.+      Also, `TableCaption` (based on `Caption`) is used for table captions.++### API changes++  * New `Text.Pandoc.Error` module with `PandocError` type+    (Matthew Pickering).++  * All readers now return `Either PandocError Pandoc` instead of `Pandoc`+    (Matthew Pickering).  This allows better handling of errors.++  * Added `Text.Pandoc.Writers.CommonMark`, exporting `writeCommonMark`.++  * Added `Text.Pandoc.Readers.CommonMark`, exporting `readCommonMark`.++  * Derive `Data` and `Typeable` instances for `MediaBag`, `Extension`,+    `ReaderOptions`, `EPUBVersion`, `CiteMethod`, `ObfuscationMethod`,+    `HTMLSlideVariant`, `TrackChanges`, `WriterOptions` (Shabbaz+    Youssefi).++  * New `Ext_shortcut_reference_links` constructor for `Extension`+    (Konstantin Zudov).++###  Bug fixes++  * Markdown reader:++    + Allow smart `'` after inline math (#1909, Nikolay Yakimov).+    + Check for tex macros after indented code (#1973).+    + Rewrote `charsInBalancedBrackets` for efficiency.+    + Make sure a closing `</div>` doesn't get included in a+      definition list item (#2127).+    + Don't parse bracketed text as citation if it might be a link,+      image, or footnote (Nikolay Yakimov).+    + Require space after key in mmd title block (#2026, Nikolay+      Yakimov).  Require space after key-value delimiter colon in mmd title+      block.+    + Require nonempty value in mmd title block (Nikolay Yakimov).+    + Disable all metadata block extensions when parsing+      metadata field values (#2026, Nikolay Yakimov).  Otherwise we+      could get a mmd title block inside YAML metadata, for example.++  * HTML reader:++    + Improve self-closing tag detection in `htmlInBalanced` (#2146).+    + Handle tables with `<th>` in body rows (#1859, mb21).+    + Fixed `htmlTag` (#1820).  If the tag parses as a comment, we check+      to see if the input starts with `<!--`. If not, it's bogus comment+      mode and we fail `htmlTag`.+    + Handle `base` tag; if it has an `href` value, this is added to+      all relative URLs in links and images.++  * DocBook reader:++    + Look inside "info" elements for section titles (#1931).++  * Docx reader:++    + Parse images in deprecated vml format (Jesse Rosenthal).+    + Allow sub/superscript verbatims (Jesse Rosenthal).+      Verbatim usually shuts off all other run styles, but we don't want it+      to shut off sub/superscript.++  * LaTeX reader:++    + Handle `tabular*` environment (#1850).+      Note that the table width is not actually parsed or taken into+      account, but pandoc no longer chokes on it.+    + Ignore options in `\lstinline` rather than raising error (#1997).+    + Add some test cases for simple tables (Mathias Schenner).+    + Handle valign argument in tables (Mathias Schenner) (currently+      we just ignore this).+    + Allow non-empty colsep in tables (Mathias Schenner).+      The `tabular` environment allows non-empty column separators+      with the "@{...}" syntax. Previously, pandoc would fail to+      parse tables if a non-empty colsep was present. With this+      commit, these separators are still ignored, but the table gets+      parsed. A test case is included.+    + Recognize `\newpage` as a block command.+    + Allow block content in `\title{}` (#2001).+    + Check for block-level newcommand aliases in blockCommand (Nikolay+      Yakimov).+    + Guard against paragraph starting with inline macro (Nikolay Yakimov).+    + Properly gobble spaces after `\\` (#2007).++  * Textile reader:++    +  Handle newlines in table cells, and empty cells (#1919).++  * Org reader:++    + Allow image links with non-image targets (Hans-Peter Deifel).+      This matches behavior of Org-Mode for links like+      `[[http://example.com][https://www.haskell.org/static/img/logo.png]]`.++  * Docbook writer:++    + Don't print empty id attributes (thanks to Steve Horne).++  * HTML writer:++    + Fixed list-style-type for numbered example lists.+      Should be "decimal," not "example" (#1902).+    + Do not omit missing `alt` attribute on `img` tag (#1131,+      Konstantin Zudov).+    + Allow multiple colgroups in table (#2122).+    + In revealjs, ensure that lists in speaker notes don't add "fragment"+      classes, which can cause additional keypresses to be needed to+      advance a slide (#1394).++  * LaTeX writer:++    + Don't escape `$` in URL (#1913).+    + Don't use listings in headers (Matthew Pickering, #1963).+    + Recognize book documentclass if set in metadata (#1971).+      This sets `--chapters` implicitly if the documentclass in metadata+      is a book documentclass.  Previously this was done only if a book+      documentclass was set in a variable.+    + Add a `\label` in `\hyperdef` for Div, Span (or links don't work).+    + Make `mainlang` work when `lang` is in metadata (#2174).++  * Texinfo writer:++    + Fix wrapping by using breakable spaces (Tim Lin).++  * RST writer:++    + Fixed toc depth in RST writer.  Previously the depth was being+      rendered as a floating point number with a decimal point.++  * Markdown writer:++    + Improved escaping (#2086).  `<` should not be escaped as `\<`, for+      compatibility with original Markdown.  We now escape `<` and `>`+      with entities.  Also, we now backslash-escape square brackets.+    + Avoid introducing spurious list items through wrapping (#1946).+    + Don't emit span tags if plain or raw HTML disabled.++  * MediaWiki writer:++    + Convert spaces to underscores in wikilink URL (#1982), like MediaWiki.++  * AsciiDoc writer:++    + Insert some needed blank lines (#1860).+    + Avoid wrapping after list marker (#1858).++  * EPUB writer:++    + Properly handle internal links to IDs in spans, divs (#1884).+    + Use plain writer for metadata dc: fields (#2121).+      This gives better results when we have, e.g. multiple paragraphs.+      Note that tags aren't allowed in these fields.+    + Properly handle image links without an extension (#1855).+    + Improved chapter splitting and internal link rewriting (#1887,+      #2162, #2163).  This will ensure that internal links work and+      that the references section produced by pandoc-citeproc is+      in its own chapter.+    + Fixed handling of svg images (#2183).++  * ICML writer:++    + Better handling of raw blocks and inlines (#1951).+      Previously these were always escaped and printed verbatim.+      Now they are ignored unless the format is `icml`, in which+      case they are passed through unescaped.+    + Fixed image URIs in ICML output (gohai).++  * Custom writer:++    + Raise error if loadstring returns an error status.+    + Raise `PandocLuaException` instead of using 'error'.+      Eventually we'll change the return type so that no exception+      is involved, but at least this can be trapped.+    + Use UTF-8 aware bytestring conversion.+    + Set foreign encoding to UTF-8 (Nikolay Yakimov, #2101, #1634).+      Also factored out ByteString, since it's only used as an intermediate+      representation.++  * Docx writer:++    + Copy hyphenation settings from reference.docx (Nikolay Yakimov).+    + Filter out illegal XML characters (#1992, Matthew Pickering).+    + Added `noProof` to docx syntax highlighting `SourceCode` style.+    + Added footnotes id -1 and 0 (Jesse Rosenthal).+      Word uses, by default, footnotes with id -1 and 0 for separators. If a+      user modifies `reference.docx`, they will end up with a `settings.xml`+      file that references these footnotes, but no such footnotes in the+      document. This will produce a corruption error. Here we add these to the+      document and `settings.xml` file, so future modifications won't break+      the file.+    + Handle lists correctly inside table cells (Jesse Rosenthal).+      Previously we didn't transform lists inside table cells.+    + Set firstRow information in tables (Nikolay Yakimov).+    + Don't replace `SourceCode` style in `reference.docx` if it is defined+      there (Nikolay Yakimov, #1872).  If `--no-highlight` specified, remove+      any `SourceCode` and `*Tok` styles in `reference.docx`.+    + Attempt to match international style names (#1607, Nikolay Yakimov).+    + Set these styles as custom (Nikolay Yakimov): `Author`, `Abstract`,+      `Compact`, `Image Caption`, `Table Caption`, `Definition Term`,+      `Definition`, `First Paragraph`.+    + Rename these styles to correspond with Word `Normal.dotm` (Nikolay+      Yakimov): `Block Quote -> Block Text`, `Link -> Hyperlink`,+      `Footnote Ref -> Footnote Reference`.+    + Added `Caption` style (Nikolay Yakimov).+    + Changed these styles' inheritance (Nikolay Yakimov):+      `Image Caption <- Caption`, `Table Caption <- Caption`.+    + Remove `SourceCode` style from `reference.docx` (#1872).+      This is added automatically by the docx writer.+    + Added toc heading style to `reference.docx` (Nikolay Yakimov).++  * `Text.Pandoc.PDF`++    + Don't suggest "Try xelatex" if xelatex already in use (mb21, #1832).+    + More comprehensible errors on image conversion (#2067).+      EPS can't be supported without shelling out to something like+      ImageMagick, but at least we can avoid mysterious error messages.++  * `Text.Pandoc.Shared`:++    + Make safeRead safe (#1801, Matthew Pickering).+    + Addded `mapLeft`, `hush` (Matthew Pickering).++  * `Text.Pandoc.Pretty`:++    + Remove partial function (Matthew Pickering).++  * `Text.Pandoc.SelfContained`:++    + Add `;charset=utf-8` to script mime type if missing (#1842).+    + Improved building of data URIs (#1940).  Now base64 is used except+      for `text/*` mime types.+    + `cssURLs` no longer tries to fetch fragment URLs (#2121).+    + Properly handle data URIs in css urls (#2129).+      Use a proper CSS parser (adds dependency on `text-css`).++  * `Text.Pandoc.UTF8`:++    + Better handling of bare CRs in input files (#2132).+      Previously we just stripped them out; now we convert+      other line ending styles to LF line endings.++  * `Text.Pandoc.ImageSize`:++    + Fixed some exif header parsing bugs (#1834).+    + Make imageSize return an Either, not a Maybe (#1834).+      Use `runGetOrFail` (with `binary >= 0.7`) to return `Left` on+      parse failure (rather than `error`).+    + Improved warnings when image size can't be determined.+    + Removed error landmines (Matthew Pickering).++  * Added woff2 to MIME types (Alfred Wechselberger).++  * pandoc:  When a binary input format is used, warn that file+    arguments past the first one are being ignored (Matthew Pickering).++### Template changes++  * LaTeX template:++    + Degrade gracefully if `\paragraph` not defined.+    + Include `grffile` together with `graphicx` (#2074).+      This properly handles filenames containing spaces and dots.+    + Redefine `\paragraph`, `\subparagraph`...  to behave more+      like section headers (#1658).+    + Import hyperref before polyglossia to avoid an error with xelatex,+      "please load package hyperref before bidi package" (Nick Bart).+    + Added `toccolor` variable to control link color in toc (Kaixhin).++  * LaTeX, Beamer templates:++    + Provide `\tightlist`, which is now used by the LaTeX writer.+    + Use polyglossia in beamer (#85).+    + Use `bibliography` instead of `biblio-files`+      (#1661).  Also use `\addbibresource` instead of `\bibliography` for+      biblatex.+    + Added `setotherlanguages` in polyglossia. This uses an `otherlang`+      variable that is derived from a comma-separated list in `lang`;+      the last language is `mainlang` and the others are `otherlang`.++  * EPUB templates:++    + Use `div`, not `p`, for "rights" on title page.+    + Added header-includes, include-before, include-after (#1987).++  * OpenDocument template:++    + Use `text:p` instead of `text:h` for title.+      Using `text:h` causes problems with numbering.  Closes #2059.+      Thansk to @nkalvi for diagnosing this.++  * reveal.js template:++    + Link to non-minified css, js.  The minified versions no longer+      ship with the library.+    + Correctly include style CSS (#1949).+    + New configurable options options: `center`, `maxScale`, `slideNuber`+      (Dmitry Smirnov, pandoc-templates#89).+    + Moved custom CSS after theme.  This allows custom CSS to modify+      themes, instead of being replaced by them.+    + Allow `center` to be set to false.++### Under the hood improvements++  * Removed pre-built `reference.docx` and `reference.odt` (Nikolay+    Yakimov).  Instead the repository now includes the component text files,+    and the zipped binaries are built from these using a helper+    program, `make-reference-files`.  This should make maintenance of+    these components easier going forward.++  * `Text.Pandoc.Parsing`:++    + Added new `<+?>` combinator (Nikolay Yakimov).+    + Added `stateHeaderKeys` to `ParserState`.++  * `make_deb.sh` fixes:++    + Detect architecture.+    + Add Installed-Size to debian package control file (#1900).+    + Use `fakeroot` to get permissions right.+    + Use `mkdir` and `cp` instead of `install`.+    + Set permissions of directories to 755.+    + Install in `/usr` rather than `/usr/local`.+    + Compress man pages.+    + Combine copyright files for `pandoc`, `pandoc-citeproc`.++  * Added `Text.Pandoc.Compat.Locale` and `old-locale` flag+    to assist with transition to `time` 1.5.++  * Updated CONTRIBUTING.md with information about issue tags (Matthew+    Pickering).++  * Updated travis installs to the new sudo-less syntax (Tim Lin).++  * Updated dependency version bounds.++  * EPUB tests:  don't use `joinPath`, which varies across platforms.+    Instead, use a forward-slash to join paths, regardless of the+    platform. This matches the way `MediaBag` now works.++  * Clarify JSON input and output in usage message (Caleb McDaniel).++  * Improved INSTALL instructions.++  * Always build man pages.  Removed make-pandoc-man-pages flag.++  * Makefile:  removed man target, now that we generate man pages by default.++  * README:++    + Fixed typos (J. Lewis Muir).+    + Added documentation on backtick_code_blocks (#2135, Nikolay Yakimov).+    + Added note on in-field markup in biblio databases (Nick Bart).+    + Fixed misleading example of raw HTML block.+    + Various minor formatting and consistency fixes for the program+      options (Andreas Lööw).+    + Made definition lists for options all "loose" for consistency.+    + Added YAML biblio format to table, and note on `pandoc-citeproc`'s+      `--bib2json` and `--bib2yaml` options (Nick Bart).+    + Removed obsolete reference to `mods2yaml` (Nick Bart).+    + Added section on syntax highlighting.+    + Documented `toccolor` variable.++## pandoc 1.13.2.1 (2015-04-15)++  * Updated to build with ghc 7.10.1.++  * Bumped package upper bounds for filepath, blaze-html, blaze-markup.++## pandoc 1.13.2 (2014-12-20)++  * TWiki Reader: add new new twiki reader (API chaneg, Alexander Sulfrian).++  * Markdown reader:++    + Better handling of paragraph in div (#1591).+      Previously text that ended a div would be parsed as Plain+      unless there was a blank line before the closing div tag.+    + Don't treat a citation as a reference link label (#1763).+    + Fix autolinks with following punctuation (#1811).+      The price of this is that autolinked bare URIs can no longer+      contain `>` characters, but this is not a big issue.+    + Fix `Ext_lists_without_preceding_blankline` bug (#1636, Artyom).+    + Allow `startnum` to work without `fancy_lists`. Formerly+      `pandoc -f markdown-fancy_lists+startnum` did not work properly.++  * RST reader (all Daniel Bergey):++    + Parse quoted literal blocks (#65).  RST quoted literal blocks are+      the same as indented literal blocks (which pandoc already supports)+      except that the quote character is preserved in each line.+    + Parse RST class directives. The class directive accepts one or more+      class names, and creates a Div value with those classes.  If the+      directive has an indented body, the body is parsed as the children of+      the Div.  If not, the first block following the directive is made a+      child of the Div. This differs from the behavior of rst2xml, which+      does not create a Div element.  Instead, the specified classes are+      applied to each child of the directive.  However, most Pandoc Block+      constructors to not take an Attr argument, so we can't duplicate this+      behavior.+    + Warn about skipped directives.+    + Literal role now produces Code. Code role should have "code" class.+    + Improved support for custom roles++        - Added `sourceCode` to classes for `:code:` role, and anything+          inheriting from it.+        - Add the name of the custom role to classes if the Inline+          constructor supports Attr.+        - If the custom role directive does not specify a parent role,+          inherit from the `:span:` role.++      This differs somewhat from the `rst2xml.py` behavior.  If a custom+      role inherits from another custom role, Pandoc will attach both+      roles' names as classes.  `rst2xml.py` will only use the class of+      the directly invoked role (though in the case of inheriting from a+      `:code:` role with a `:language:` defined, it will also provide the+      inherited language as a class).+    + Warn about ignored fields in role directives.++  * LaTeX reader:++    + Parse label after caption into a span instead of+     inserting an additional paragraph of bracketed text (#1747).+    + Parse math environments as inline when possible (#1821).+    + Better handling of `\noindent` and `\greektext` (#1783).+    + Handle `\texorpdfstring` more gracefully.+    + Handle `\cref` and `\sep` (Wikiwide).+    + Support `\smartcite` and `\Smartcite` from biblatex.++  * HTML reader:++    + Retain display type of MathML output (#1719, Matthew Pickering).+    + Recognise `<br>` tags inside `<pre>` blocks (#1620, Matthew Pickering).+    + Make `embed` tag either block or inline (#1756).++  * DocBook reader:++    + Handle `keycombo`, `keycap` (#1815).+    + Get string content in inner tags for literal elements (#1816).+    + Handle `menuchoice` elements better, with a `>` between (#1817).+    + Include `id` on section headers (#1818).+    + Document/test "type" as implemented (Brian O'Sullivan).+    + Add support for calloutlist and callout (Brian O'Sullivan).+      We treat a calloutlist as a bulleted list. This works well in practice.+    + Add support for `classname` (Bryan O'Sullivan).++  * Docx reader:++    + Fix window path for image lookup (Jesse Rosenthal).+      Don't use os-sensitive "combine", since we always want the paths in our+      zip-archive to use forward-slashes.+    + Single-item headers in ordered lists are headers (Jesse Rosenthal).+      When users number their headers, Word understands that as a single item+      enumerated list. We make the assumption that such a list is, in fact,+      a header.+    + Rewrite rewriteLink to work with new headers (Jesse Rosenthal).+      There could be new top-level headers after making lists, so we have to+      rewrite links after that.+    + Use polyglot header list (Jesse Rosenthal).+      We're just keeping a list of header formats that different languages+      use as their default styles. At the moment, we have English, German,+      Danish, and French. We can continue to add to this.+      This is simpler than parsing the styles file, and perhaps less+      error-prone, since there seems to be some variations, even within a+      language, of how a style file will define headers.+    + Remove header class properly in other langs (Jesse Rosenthal).+      When we encounter one of the polyglot header styles, we want to remove+      that from the par styles after we convert to a header. To do that, we+      have to keep track of the style name, and remove it appropriately.+    + Account for external link URLs with anchors. Previously, if a URL+      had an anchor, the reader would incorrectly identify it as an+      internal link and return only the anchor as URL. (Caleb McDaniel)+    + Fix for Issue #1692 (i18n styles) (Nikolay Yakimov).++  * Org reader:++    + Added state changing blanklines (Jesse Rosenthal).+      This allows us to emphasize at the beginning of a new paragraph (or, in+      general, after blank lines).+    + Fixed bug with bulleted lists:++        - a+        - b+        * c++      was being parsed as a list, even though an unindented `*`+      should make a heading.  See+      <http://orgmode.org/manual/Plain-lists.html#fn-1>.+    + Org reader: absolute, relative paths in link (#1741, Albert+      Krewinkel). The org reader was too restrictive when parsing links;+      some relative links and links to files given as absolute paths+      were not recognized correctly.+    + Org reader:  allow empty links (jgm/gitit#471, Albert Krewinkel).+      This is important for use in gitit, which uses empty links+      for wikilinks.+    + Respect indent when parsing Org bullet lists (#1650, Timothy+      Humphries).  Fixes issue with top-level bullet list parsing.+    + Fix indent issue for definition lists (Timothy Humphries,+      see #1650, #1698, #1680).+    + Parse multi-inline terms correctly in definition list (#1649,+      Matthew Pickering).+    + Fix rules for emphasis recognition (Albert Krewinkel).+      Things like `/hello,/` or `/hi'/` were falsy recognized as emphasised+      strings.  This is wrong, as `,` and `'` are forbidden border chars and+      may not occur on the inner border of emphasized text.+    + Drop COMMENT document trees (Albert Krewinkel).+      Document trees under a header starting with the word `COMMENT` are+      comment trees and should not be exported.  Those trees are dropped+      silently (#1678).+    + Properly handle links to `file:target` (Albert Krewinkel).+      Org links like `[[file:target][title]]` were not handled correctly,+      parsing the link target verbatim.  The org reader is changed such that+      the leading `file:` is dropped from the link target (see #756, #1812).+    + Parse LaTeX-style MathML entities (#1657, Albert Krewinkel).+      Org supports special symbols which can be included using LaTeX syntax,+      but are actually MathML entities.  Examples for this are+      `\nbsp` (non-breaking space), `\Aacute` (the letter A with accent acute)+      or `\copy` (the copyright sign ©)++  * EPUB reader:++    + URI handling improvements. Now we outsource most of the work to+      `fetchItem'`. Also, do not include queries in file extensions (#1671).++  * LaTeX writer:++    + Use `\texorpdfstring` for section captions when needed (Vaclav Zeman).+    + Handle consecutive linebreaks (#1733).+    + Protect graphics in headers (Jesse Rosenthal).+      Graphics in `\section`/`\subsection` etc titles need to be `\protect`ed.+    + Put `~` before header in list item text (Jesse Rosenthal).+      Because of the built-in line skip, LaTeX can't handle a section header+      as the first element in a list item.+    + Avoid using reserved characters as `\lstinline` delimiters (#1595).+    + Better handling of display math in simple tables (#1754).+      We convert display math to inline math in simple tables,+      since LaTeX can't deal with display math in simple tables.+    + Escape spaces in code (#1694, Bjorn Buckwalter).++  * MediaWiki writer:++    + Fixed links with URL = text. Previously these were rendered as bare+      words, even if the URL was not an absolute URL (#1825).++  * ICML writer:++    + Don't force all citations into footnotes.++  * RTF writer:++    + Add blankline at end of output (#1732, Matthew Pickering).++  * RST writer:++    + Ensure blank line after figure.+    + Avoid exces whitespace after last list item (#1777).+    + Wrap line blocks with spaces before continuations (#1656).+    + Fixed double-rendering of footnotes in RST tables (#1769).++  * DokuWiki writer:++    + Better handling of block quotes. This change ensures that+      multiple paragraph blockquotes are rendered using native `>`+      rather than as HTML (#1738).+    + Fix external images (#1739). Preface relative links with ":",+      absolute URIs without. (Timothy Humphries)++  * HTML writer:++    + Use protocol-relative URL for mathjax.+    + Put newline btw img and caption paragraph.+    + MathML now outputted with tex annotation (#1635, Matthew Pickering).+    + Add support for KaTeX HTML math (#1626, Matthew Pickering).+      This adds `KaTeX` to `HTMLMathMethod` (API change).+    + Don't double render when `email-obfuscation=none` (#1625, Matthew+      Pickering).+    + Make header attributes work outside top level (#1711).+      Previously they only appeared on top level header elements.+      Now they work e.g. in blockquotes.++  * ODT writer:++    + Correctly handle images without extensions (#1729).+    + Strip querystring in ODT write (#1682, Todd Sifleet).++  * FB2 writer:++    + Add newline to output.++  * EPUB writer:++    + Don't add `sourceURL` to absolute URIs (#1669).+    + Don't use unsupported `opf:title-type` for epub2.+    + Include "landmarks" section in nav document for epub3 (#1757).+    + Removed playOrder from navpoint elements in ncx file (#1760).+      These aren't required, and they make manual modification of epubs+      difficult.+    + Extract title even from structured title.+    + Don't include nav node in spine unless `--toc` was requested.+      Previously we included it in the spine with `linear="no"`, leading+      to odd results in some readers (#1593).+    + Fixed absolute URI detection (#1672).+    + Correctly resolve relative URIs (#1671).+    + Use regular page template for `nav.xhtml`, including doctype (#1759).++  * Docx writer:++    + Put docx table captions above tables (#1641, Nikolay Yakimov).+    + Get the page width from the reference docx file, and use+      it to scale images that are too large to fit (Grégory Bataille).+    + Partial fix for #1607 (Nikolay Yakimov). International heading styles+      are inferred based on `<w:name val="heading #">` fallback, if there+      are no en-US "Heading#" styles+    + Look in user data dir for archive `reference.docx`.+    + Renumber header and footer relationships to avoid collisions (Jesse+      Rosenthal). We previously took the old relationship names of the+      headers and footer in secptr. That led to collisions. We now make+      a map of availabl names in the relationships file, and then rename+     in secptr.++  * ConTeXt writer:++    + Add function toLabel (Mark Szepieniec).+      This function can be used to sanitize reference labels so that+      they do not contain any of the illegal characters \#[]",{}%()|= .+      Currently only Links have their labels sanitized, because they+      are the only Elements that use passed labels.++  * `Text.Pandoc.Shared`:++    + Moved import of `toChunks` outside of CPP conditional (#1590).+    + Fix `inDirectory` to reset to the original directory in case+      an exception occurs (Freiric Barral).++  * Templates:++    + LaTeX template: load polyglossia before bibtex (jgm/pandoc-templates#70).+      Thanks to bluebirch.+    + LaTeX template: Added `\VerbatimFootnotes` if there is verbatim in notes+      (#1616).+    + LaTeX template:  Add shorthands=off to babel options (#1648).+    + EPUB, EPUB3 templates: Added `id="cover"` to body of cover page.+      This aids styling, making it possible for example to set 0 margins+      on the title page (#1758).+    + EPUB, EPUB3 templates:  Handle structured metadata on titlepage.+      Previously we just expected 'title', 'subtitle', 'author', 'date'.+      Now we still support those, but also support the format recommended+      for epub metadata in the pandoc README:++        ---+        title:+        - type: main+          text: My Book+        - type: subtitle+          text: An investigation of metadata+        creator:+        - role: author+          text: John Smith+        - role: editor+          text: Sarah Jones+        identifier:+        - scheme: DOI+          text: doi:10.234234.234/33+        publisher:  My Press+        rights:  (c) 2007 John Smith, CC BY-NC+        ...++  * `Text.Pandoc.Templates.getDefaultTemplate`:+    don't fail when called with "fb2" (#1660).++  * `Text.Pandoc.Parsing`:++    + Fixed `inlineMath` so it handles `\text{..}` containing `$`.+      For example: `$x = \text{the $n$th root of $y$}` (#1677).+    + Change `parseFromString` to fail if not all input is consumed.+      (Matthew Pickering)+    + Moved `addWarning` from Markdown reader to `Parsing`, so it can be+      used by more readers (API change, Daniel Bergey).++  * `Text.Pandoc.Pretty`:++    +  Improve performance of `realLength` (Matthew Pickering).+    +  Make CR + BLANKLINE = BLANKLINE. This fixes an extra blank line we+       were getting at the end of markdown fragments (as well as rst, org,+       etc.) (#1705).++  * `Text.Pandoc.MIME`:++    + Add mime type for WebVTT (Jason Ronallo).+    + Changed mime type for `otf` to `application/vnd.ms-opentype` (#1761).+      This is needed for epub3 validation.++  * `Text.Pandoc.MediaBag`:++    + Fix Windows specific path problems (#1597).++  * `Text.Pandoc.Shared`:++    + Make `collapseFilePath` OS-agnostic (Matthew Pickering).++  * Link the test suite using `-threaded`.+    This allows the test suite to be run using `+RTS -N`.++  * Added `network` dependency under `network-uri` flag in test section.++  * Give better error messages when someone tries to convert from+    pdf, doc, odt (#1683).++  * Added `track` to list of tags treated by `--self-contained` (#1664).+++## pandoc 1.13.1 (2014-08-30)++  * Fixed `--self-contained` with Windows paths (#1558).+    Previously `C:\foo.js` was being wrongly interpreted as a URI.++  * HTML reader:  improved handling of tags that can be block or inline.+    Previously a section like this would be enclosed in a paragraph,+    with RawInline for the video tags (since video is a tag that can+    be either block or inline):++        <video controls="controls">+           <source src="../videos/test.mp4" type="video/mp4" />+           <source src="../videos/test.webm" type="video/webm" />+           <p>+              The videos can not be played back on your system.<br/>+              Try viewing on Youtube (requires Internet connection):+              <a href="http://youtu.be/etE5urBps_w">Relative Velocity on+        Youtube</a>.+           </p>+        </video>++    This change will cause the video and source tags to be parsed+    as RawBlock instead, giving better output.+    The general change is this:  when we're parsing a "plain" sequence+    of inlines, we don't parse anything that COULD be a block-level tag.++  * Docx reader:++    + Be sensitive to user styles.  Note that "Hyperlink" is+      "blacklisted," as we don't want the default underline styling to be+      inherited by all links by default (Jesse Rosenthal).+    + Read single paragraph in table cell as `Plain` (Jesse Rosenthal).+      This makes to docx reader's native output fit with the way the markdown+      reader understands its markdown output.++  * Txt2Tags reader:++    + Header is now parsed only if standalone flag is set (Matthew Pickering).+    + The header is now parsed as meta information. The first line is the+      `title`, the second is the `author` and third line is the `date`+      (Matthew Pickering).+    + Corrected formatting of `%%mtime` macro (Matthew Pickering).+    + Fixed crash when reading from stdin.++  * Textile writer:  Extended the range of cases where native textile+    tables will be used (as opposed to raw HTML):  we now handle any+    alignment type, but only for simple tables with no captions.++  * EPUB writer:  Don't use page-progression-direction in EPUB2, which+    doesn't support it.  Also, if page-progression-direction not specified+    in metadata, don't include the attribute even in EPUB3; not including it+    is the same as including it with the value "default", as we did before.+    (#1550)++  * Org writer: Accept example lines with indentation at the beginning+    (Calvin Beck).++  * DokuWiki writer:++    + Refactor to use Reader monad (Matthew Pickering).+    + Avoid using raw HTML in table cells; instead, use `\\`+      instead of newlines (Jesse Rosenthal).+    + Properly handle HTML table cell alignments, and use spacing+      to make the tables look prettier (#1566).++  * Docx writer:++    + Bibliography entries get `Bibliography` style (#1559).+    + Implement change tracking (Jesse Rosenthal).++  * LaTeX writer:++    + Fixed a bug that caused a table caption to repeat across all pages+      (Jose Luis Duran).+    + Improved vertical spacing in tables and made it customizable using+      standard lengths set by booktab.  See+      <https://groups.google.com/forum/#!msg/pandoc-discuss/qMu6_5lYy0o/ZAU7lzAIKw0J>+      (Jose Luis Duran).+    + Added `\strut` to fix spacing in multiline tables (Jose Luis Duran).+    + Use `\tabularnewline` instead of `\\` in table cells (Jose Luis Duran).+    + Made horizontal rules more flexible (Jose Luis Duran).++  * Text.Pandoc.MIME:++    + Added `MimeType` (type synonym for `String`) and `getMimeTypeDef`.+      Code cleanups (Artyom Kazak).++  * Templates:++    + LaTeX template: disable microtype protrusion for typewriter font (#1549,+      thanks lemzwerg).++  * Improved OSX build procedure.++  * Added `network-uri` flag, to deal with split of `network-uri` from+    `network`.++  * Fix build dependencies for the `trypandoc` flag, so that they are+    ignored if `trypandoc` flag is set to False (Gabor Pali).++  * Updated README to remove outdated claim that `--self-contained`+    looks in the user data directory for missing files.++## pandoc 1.13.0.1 (2014-08-17)++  * Docx writer:++    + Fixed regression which bungled list numbering (#1544), causing+      all lists to appear as basic ordered lists.+    + Include row width in table rows (Christoffer Ackelman, Viktor Kronvall).+      Added a property to all table rows where the sum of column widths+      is specified in pct (fraction of 5000).  This helps persuade Word+      to lay out the table with the widths we specify.++  * Fixed a bug in Windows 8 which caused pandoc not to find the+    `pandoc-citeproc` filter (#1542).++  * Docx reader: miscellaneous under-the-hood improvements (Jesse Rosenthal).+    Most significantly, the reader now uses Builder, leading to some+    performance improvements.++  * HTML reader:  Parse appropriately styled span as SmallCaps.++  * Markdown writer: don't escape `$`, `^`, `~` when `tex_math_dollars`,+    `superscript`, and `subscript` extensions, respectively, are+    deactivated (#1127).++  * Added `trypandoc` flag to build CGI executable used in the online+    demo.++  * Makefile:  Added 'quick', 'osxpkg' targets.++  * Updated README in templates to indicate templates license.+    The templates are dual-licensed, BSD3 and GPL2+.++## pandoc 1.13 (15 August 2014)++### New features++  * Added `docx` as an input format (Jesse Rosenthal).  The docx+    reader includes conversion of native Word equations to pandoc+    LaTeX `Math` elements.  Metadata is taken from paragraphs at the+    beginning of the document with styles `Author`, `Title`, `Subtitle`,+    `Date`, and `Abstract`.++  * Added `epub` as an input format (Matthew Pickering).  The epub+    reader includes conversion of MathML to pandoc LaTeX `Math`+    elements.++  * Added `t2t` (Txt2Tags) as an input format (Matthew Pickering).+    Txt2tags is a lightweight markup format described at+    <http://txt2tags.org/>.++  * Added `dokuwiki` as an output format (Clare Macrae).++  * Added `haddock` as an output format.++  * Added `--extract-media` option to extract media contained in a zip+    container (docx or epub) while adjusting image paths to point to the+    extracted images.++  * Added a new markdown extension, `compact_definition_lists`, that+    restores the syntax for definition lists of pandoc 1.12.x, allowing+    tight definition lists with no blank space between items, and+    disallowing lazy wrapping.  (See below under behavior changes.)++  * Added an extension `epub_html_exts` for parsing HTML in EPUBs.++  * Added extensions `native_spans` and `native_divs` to activate+    parsing of material in HTML span or div tags as Pandoc Span+    inlines or Div blocks.++  * `--trace` now works with the Markdown, HTML, Haddock, EPUB,+    Textile, and MediaWiki readers.  This is an option intended+    for debugging parsing problems; ordinary users should not need+    to use it.++### Behavior changes++  * Changed behavior of the `markdown_attribute` extension, to bring+    it in line with PHP markdown extra and multimarkdown.  Setting+    `markdown="1"` on an outer tag affects all contained tags,+    recursively, until it is reversed with `markdown="0"` (#1378).++  * Revised markdown definition list syntax (#1429).  Both the reader+    and writer are affected.  This change brings pandoc's definition list+    syntax into alignment with that used in PHP markdown extra and+    multimarkdown (with the exception that pandoc is more flexible about+    the definition markers, allowing tildes as well as colons).  Lazily+    wrapped definitions are now allowed.  Blank space is required+    between list items.  The space before a definition is used to determine+    whether it is a paragraph or a "plain" element.  **WARNING: This change+    may break existing documents!**  Either check your documents for+    definition lists without blank space between items, or use+    `markdown+compact_definition_lists` for the old behavior.++  * `.numberLines` now works in fenced code blocks even if no language+    is given (#1287, jgm/highlighting-kate#40).++  * Improvements to `--filter`:++    + Don't search PATH for a filter with an explicit path.+      This fixed a bug wherein `--filter ./caps.py` would run `caps.py` from+      the system path, even if there was a `caps.py` in the working directory.+    + Respect shebang if filter is executable (#1389).+    + Don't print misleading error message.+      Previously pandoc would say that a filter was not found,+      even in a case where the filter had a syntax error.++  * HTML reader:++    + Parse `div` and `span` elements even without `--parse-raw`,+      provided `native_divs` and `native_spans` extensions are set.+      Motivation:  these now generate native pandoc Div and Span+      elements, not raw HTML.+    + Parse EPUB-specific elements if the `epub_html_exts`+      extension is enabled.  These include `switch`, `footnote`,+      `rearnote`, `noteref`.++  * Org reader:++    + Support for inline LaTeX.  Inline LaTeX is now accepted and parsed by the+      org-mode reader.  Both math symbols (like `\tau`) and LaTeX commands (like+      `\cite{Coffee}`), can be used without any further escaping (Albert+      Krewinkel).++  * Textile reader and writer:++    + The `raw_tex` extension is no longer set by default.  You can+      enable it with `textile+raw_tex`.++  * DocBook reader:++    + Support `equation`, `informalequation`, `inlineequation` elements with+      `mml:math` content.  This is converted into LaTeX and put into a Pandoc+      Math inline.++  * Revised `plain` output, largely following the style of Project+    Gutenberg:++    + Emphasis is rendered with `_underscores_`, strong emphasis+      with ALL CAPS.+    + Headings are rendered differently, with space to set them off,+      not with setext style underlines. Level 1 headers are ALL CAPS.+    + Math is rendered using unicode when possible, but without the+      distracting emphasis markers around variables.+    + Footnotes use a regular `[n]` style.++  * Markdown writer:++    + Horizontal rules are now a line across the whole page.+    + Prettier pipe tables.  Columns are now aligned  (#1323).+    + Respect the `raw_html` extension.  `pandoc -t markdown-raw_html`+      no longer emits any raw HTML, including span and div tags+      generated by Span and Div elements.+    + Use span with style for `SmallCaps` (#1360).++  * HTML writer:++    + Autolinks now have class `uri`, and email autolinks have class+      `email`, so they can be styled.++  * Docx writer:++    + Document formatting is carried over from `reference.docx`.+      This includes margins, page size, page orientation, header,+      and footer, including images in headers and footers.+    + Include abstract (if present) with `Abstract` style (#1451).+    + Include subtitle (if present) with `Subtitle` style, rather+      than tacking it on to the title (#1451).++  * Org writer:++    + Write empty span elements with an id attribute as org anchors.+      For example `Span ("uid",[],[]) []` becomes `<<uid>>`.++  * LaTeX writer:++    + Put table captions above tables, to match the conventional+      standard.  (Previously they appeared below tables.)+    + Use `\(..\)` instead of `$..$` for inline math (#1464).+    + Use `\nolinkurl` in email autolinks.  This allows them to be styled+      using `\urlstyle{tt}`.  Thanks to Ulrike Fischer for the solution.+    + Use `\textquotesingle` for `'` in inline code.  Otherwise we get+      curly quotes in the PDF output (#1364).+    + Use `\footnote<.>{..}` for notes in beamer, so that footnotes+      do not appear before the overlays in which their markers appear+      (#1525).+    + Don't produce a `\label{..}` for a Div or Span element.  Do produce+      a `\hyperdef{..}` (#1519).++  * EPUB writer:++    + If the metadata includes `page-progression-direction` (which can be+      `ltr` or `rtl`, the `page-progression-direction` attribute will+      be set in the EPUB spine (#1455).++  * Custom lua writers:++    + Custom writers now work with `--template`.+    + Removed HTML header scaffolding from `sample.lua`.+    + Made citation information available in lua writers.++  * `--normalize` and `Text.Pandoc.Shared.normalize` now consolidate+    adjacent `RawBlock`s when possible.++### API changes++  * Added `Text.Pandoc.Readers.Docx`, exporting `readDocx` (Jesse Rosenthal).++  * Added `Text.Pandoc.Readers.EPUB`, exporting `readEPUB` (Matthew+    Pickering).++  * Added `Text.Pandoc.Readers.Txt2Tags`, exporting `readTxt2Tags` (Matthew+    Pickering).++  * Added `Text.Pandoc.Writers.DokuWiki`, exporting `writeDokuWiki`+    (Clare Macrae).++  * Added `Text.Pandoc.Writers.Haddock`, exporting `writeHaddock`.++  * Added `Text.Pandoc.MediaBag`, exporting `MediaBag`, `lookupMedia`,+    `insertMedia`, `mediaDirectory`, `extractMediaBag`.  The docx and epub+    readers return a pair of a `Pandoc` document and a `MediaBag` with+    the media resources they contain.  This can be extracted using+    `--extract-media`.  Writers that incorporate media (PDF, Docx,+    ODT, EPUB, RTF, or HTML formats with `--self-contained`) will look+    for resources in the `MediaBag` generated by the reader, in addition to+    the file system or web.++  * `Text.Pandoc.Readers.TexMath`: Removed deprecated `readTeXMath`.+    Renamed `readTeXMath'` to `texMathToInlines`.++  * `Text.Pandoc`: Added `Reader` data type (Matthew Pickering).+    `readers` now associates names of readers with `Reader`+     structures.  This allows inclusion of readers, like the docx+     reader, that take binary rather than textual input.++  * `Text.Pandoc.Shared`:++    + Added `capitalize` (Artyom Kazak), and replaced uses of+      `map toUpper` (which give bad results for many languages).+    + Added `collapseFilePath`, which removes intermediate `.` and+      `..` from a path (Matthew Pickering).+    + Added `fetchItem'`, which works like `fetchItem` but searches+      a `MediaBag` before looking on the net or file system.+    + Added `withTempDir`.+    + Added `removeFormatting`.+    + Added `extractSpaces` (from HTML reader) and generalized its type+      so that it can be used by the docx reader (Matthew Pickering).+    + Added `ordNub`.+    + Added `normalizeInlines`, `normalizeBlocks`.+    + `normalize` is now `Pandoc -> Pandoc` instead of+      `Data a :: a -> a`.  Some users may need to change their uses of+      `normalize` to the newly exported `normalizeInlines` or+      `normalizeBlocks`.++  * `Text.Pandoc.Options`:++    + Added `writerMediaBag` to `WriterOptions`.+    + Removed deprecated and no longer used `readerStrict` in+      `ReaderOptions`.  This is handled by `readerExtensions` now.+    + Added `Ext_compact_definition_lists`.+    + Added `Ext_epub_html_exts`.+    + Added `Ext_native_divs` and `Ext_native_spans`.+      This allows users to turn off the default pandoc behavior of+      parsing contents of div and span tags in markdown and HTML+      as native pandoc Div blocks and Span inlines.++  * `Text.Pandoc.Parsing`:++    + Generalized `readWith` to `readWithM` (Matthew Pickering).+    + Export `runParserT` and `Stream` (Matthew Pickering).+    + Added `HasQuoteContext` type class (Matthew Pickering).+    + Generalized types of `mathInline`, `smartPunctuation`, `quoted`,+      `singleQuoted`, `doubleQuoted`, `failIfInQuoteContext`,+      `applyMacros` (Matthew Pickering).+    + Added custom `token` (Matthew Pickering).+    + Added `stateInHtmlBlock` to `ParserState`.  This is used to keep+      track of the ending tag we're waiting for when we're parsing inside+      HTML block tags.+    + Added `stateMarkdownAttribute` to `ParserState`. This is used+      to keep track of whether the markdown attribute has been set in+      an enclosing tag.+    + Generalized type of `registerHeader`, using new type classes+      `HasReaderOptions`, `HasIdentifierList`, `HasHeaderMap` (Matthew+      Pickering).  These allow certain common functions to be reused+      even in parsers that use custom state (instead of `ParserState`),+      such as the MediaWiki reader.+    + Moved `inlineMath`, `displayMath` from Markdown reader to Parsing,+      and generalized their types (Matthew Pickering).++  * `Text.Pandoc.Pretty`:++    + Added `nestle`.+    + Added `blanklines`, which guarantees a certain number of blank lines+      (and no more).++### Bug fixes++  * Markdown reader:++    + Fixed parsing of indented code in list items.  Indented code+      at the beginning of a list item must be indented eight spaces+      from the margin (or edge of the container), or four spaces+      from the list marker, whichever is greater.+    + Fixed small bug in HTML parsing with `markdown_attribute`, which+      caused incorrect tag nesting for input like+      `<aside markdown="1">*hi*</aside>`.+    + Fixed regression with intraword underscores (#1121).+    + Improved parsing of inline links containing quote characters (#1534).+    + Slight rewrite of `enclosure`/`emphOrStrong` code.+    + Revamped raw HTML block parsing in markdown (#1330).+      We no longer include trailing spaces and newlines in the+      raw blocks.  We look for closing tags for elements (but without+      backtracking).  Each block-level tag is its own `RawBlock`;+      we no longer try to consolidate them (though `--normalize` will do so).+    + Combine consecutive latex environments.  This helps when you have+      two minipages which can't have blank lines between them (#690, #1196).+    + Support smallcaps through span.+      `<span style="font-variant:small-caps;">foo</span>` will be+      parsed as a `SmallCaps` inline, and will work in all output+      formats that support small caps (#1360).+    + Prevent spurious line breaks after list items (#1137).  When the+      `hard_line_breaks` option was specified, pandoc would formerly+      produce a spurious line break after a tight list item.+    + Fixed table parsing bug (#1333).+    + Handle `c++` and `objective-c` as language identifiers in+      github-style fenced blocks (#1318).+    + Inline math must have nonspace before final `$` (#1313).++  * LaTeX reader:++    + Handle comments at the end of tables.  This resolves the issue+      illustrated in <http://stackoverflow.com/questions/24009489>.+    + Correctly handle table rows with too few cells.  LaTeX seems to+      treat them as if they have empty cells at the end  (#241).+    + Handle leading/trailing spaces in `\emph` better.+      `\emph{ hi }` gets parsed as `[Space, Emph [Str "hi"], Space]`+      so that we don't get things like `* hi *` in markdown output.+      Also applies to `textbf` and some other constructions (#1146).+    + Don't assume preamble doesn't contain environments (#1338).+    + Allow (and discard) optional argument for `\caption` (James Aspnes).++  * HTML reader:++    + Fixed major parsing problem with HTML tables.  Table cells were+      being combined into one cell (#1341).+    + Fixed performance issue with malformed HTML tables.+      We let a `</table>` tag close an open `<tr>` or `<td>` (#1167).+    + Allow space between `<col>` and `</col>`.+    + Added `audio` and `source` in `eitherBlockOrInline`.+    + Moved `video`, `svg`, `progress`, `script`, `noscript`, `svg` from+      `blockTags` to `eitherBlockOrInline`.+    + `map` and `object` were mistakenly in both lists; they have been removed+      from `blockTags`.+    + Ignore `DOCTYPE` and `xml` declarations.++  * MediaWiki reader:++    + Don't parse backslash escapes inside `<source>` (#1445).+    + Tightened up template parsing.+      The opening `{{` must be followed by an alphanumeric or `:`.+      This prevents the exponential slowdown in #1033.+    + Support "Bild" for images.++  * DocBook reader:++    + Better handle elements inside code environments.  Pandoc's document+      model does not allow structure inside code blocks, but at least this way+      we preserve the text (#1449).+    + Support `<?asciidoc-br?>` (#1236).++  * Textile reader:++    + Fixed list parsing. Lists can now start without an intervening+      blank line (#1513).+    + HTML block-level tags that do not start a line are parsed as+      inline HTML and do not interrupt paragraphs (as in RedCloth).++  * Org reader:++    + Make tildes create inline code (#1345).  Also relabeled `code` and+      `verbatim` parsers to accord with the org-mode manual.+    + Respect `:exports` header argument in code blocks (Craig Bosma).+    + Fixed tight lists with sublists (#1437).++  * EPUB writer:++    + Avoid excess whitespace in `nav.xhtml`.  This should improve+      TOC view in iBooks (#1392).+    + Fixed regression on cover image.+      In 1.12.4 and 1.12.4.2, the cover image would not appear properly,+      because the metadata id was not correct.  Now we derive the id from the+      actual cover image filename, which we preserve rather than using+      "cover-image."+    + Keep newlines between block elements.  This allows+      easier diff-ability (#1424).+    + Use `stringify` instead of custom `plainify`.+    + Use `renderTags'` for all tag rendering.  This properly handles tags+      that should be self-closing.  Previously `<hr/>` would appear in EPUB+      output as `<hr></hr>` (#1420).+    + Better handle HTML media tags.+    + Handle multiple dates with OPF `event` attributes.  Note: in EPUB3 we+      can have only one dc:date, so only the first one is used.++  * LaTeX writer:++    + Correctly handle figures in notes.  Notes can't contain figures in+      LaTeX, so we fake it to avoid an error  (#1053).+    + Fixed strikeout + highlighted code (#1294).+      Previously strikeout highlighted code caused an error.++  * ConTeXt writer:++    + Improved detection of autolinks with URLs containing escapes.++  * RTF writer:++    + Improved image embedding: `fetchItem'` is now used to get the+      images, and calculated image sizes are indicated in the RTF.+    + Avoid extra paragraph tags in metadata (#1421).++  * HTML writer:++    + Deactivate "incremental" inside slide speaker notes (#1394).+    + Don't include empty items in the table of contents for+      slide shows.  (These would result from creating a slide+      using a horizontal rule.)++  * MediaWiki writer:++    + Minor renaming of `st` prefixed names.++  * AsciiDoc writer:++    + Double up emphasis and strong emphasis markers in intraword+      contexts, as required by asciidoc (#1441).++  * Markdown writer:++    + Avoid wrapping that might start a list, blockquote, or header (#1013).+    + Use Span instead of (hackish) `SmallCaps` in `plainify`.+    + Don't use braced attributes for fenced code (#1416).+      If `Ext_fenced_code_attributes` is not set, the first class+      attribute will be printed after the opening fence as a bare word.+    + Separate adjacent lists of the same kind with an HTML comment (#1458).++  * PDF writer:++    + Fixed treatment of data uris for images (#1062).++  * Docx writer:++    + Use Compact style for empty table cells (#1353).+      Otherwise we get overly tall lines when there are empty+      table cells and the other cells are compact.+    + Create overrides per-image for `media/` in reference docx.+      This should be somewhat more robust and cover more types of images.+    + Improved `entryFromArchive` to avoid an unneeded parse.+    + Section numbering carries over from reference.docx (#1305).+    + Simplified `abstractNumId` numbering.  Instead of sequential numbering,+      we assign numbers based on the list marker styles.++  * `Text.Pandoc.Options`:++    + Removed `Ext_fenced_code_attributes` from `markdown_github`+      extensions.++  * `Text.Pandoc.ImageSize`:++    + Use default instead of failing if image size not found+      in exif header (#1358).+    + ignore unknown exif header tag rather than crashing.+      Some images seem to have tag type of 256, which was causing+      a runtime error.++  * `Text.Pandoc.Shared`:++    + `fetchItem`:  unescape URI encoding before reading local file (#1427).+    + `fetchItem`:  strip a fragment like `?#iefix` from the extension before+      doing mime lookup, to improve mime type guessing.+    + Improved logic of `fetchItem`:  absolute URIs are fetched from the net;+      other things are treated as relative URIs if `sourceURL` is `Just _`,+      otherwise as file paths on the local file system.+    + `fetchItem` now properly handles links without a protocol (#1477).+    + `fetchItem` now escapes characters not allowed in URIs before trying+      to parse the URIs.+    + Fixed runtime error with `compactify'DL` on certain lists (#1452).++  * `pandoc.hs`: Don't strip path off of `writerSourceURL`: the path is+    needed to resolve relative URLs when we fetch resources (#750).++  * `Text.Pandoc.Parsing`++    + Simplified `dash` and `ellipsis` (#1419).+    + Removed `(>>~)` in favor of the equivalent `(<*)` (Matthew Pickering).+    + Generalized functions to use `ParsecT` (Matthew Pickering).+    + Added `isbn` and `pmid` to list of recognized schemes (Matthew+      Pickering).++### Template changes++  * Added haddock template.+  * EPUB3:  Added `type` attribute to `link` tags.  They are supposed to+    be "advisory" in HTML5, but kindlegen seems to require them.+  * EPUB3:  Put title page in section with `epub:type="titlepage"`.+  * LaTeX: Made `\subtitle` work properly (#1327).+  * LaTeX/Beamer: remove conditional around date (#1321).+  * LaTeX:  Added `lot` and `lof` variables, which can be set to+    get `\listoftables` and `\listoffigures` (#1407).  Note that+    these variables can be set at the command line with `-Vlot -Vlof`+    or in YAML metadata.++### Under the hood improvements++  * Rewrote normalize for efficiency (#1385).++  * Rewrote Haddock reader to use `haddock-library` (#1346).++    + This brings pandoc's rendering of haddock markup in line+      with the new haddock.+    + Fixed line breaks in `@` code blocks.+    + alex and happy are no longer build-depends.++  * Added `Text.Pandoc.Compat.Directory` to allow building against+    different versions of the `directory` library.++  + Added `Text.Pandoc.Compat.Except` to allow building against+    different verions of `mtl`.++  * Code cleanup in some writers, using Reader monad to avoid+    passing options parameter around (Matej Kollar).++  * Improved readability in `pandoc.hs`.++  * Miscellaneous code cleanups (Artyom Kazak).++  * Avoid `import Prelude hiding (catch)` (#1309, thanks to Michael+    Thompson).++  * Changed `http-conduit` flag to `https`.  Depend on `http-client`+    and `http-client-tls` instead of `http-conduit`.  (Note:  pandoc still+    depends on `conduit` via `yaml`.)++  * Require `highlighting-kate >= 0.5.8.5` (#1271, #1317, Debian #753299).+    This change to highlighting-kate means that PHP fragments no longer need+    to start with `<?php`.  It also fixes a serious bug causing failures with+    ocaml and fsharp.++  * Require latest `texmath`.  This fixes `\tilde{E}` and allows+    `\left` to be used with `]`, `)` etc. (#1319), among many other+    improvements.++  * Require latest `zip-archive`.  This has fixes for unicode path names.++  * Added tests for plain writer.++  * `Text.Pandoc.Templates`:++    + Fail informatively on template syntax errors.+      With the move from parsec to attoparsec, we lost good error+      reporting.  In fact, since we weren't testing for end of input,+      malformed templates would fail silently.  Here we revert back to+      Parsec for better error messages.+    + Use `ordNub` (#1022).++  * Benchmarks:++    + Made benchmarks compile again (Artyom Kazak).+    + Fixed so that the failure of one benchmark does not prevent others+      from running (Artyom Kazak).+    + Use `nfIO` instead of the `getLength` trick to force full evaluation.+    + Changed benchmark to use only the test suite, so that benchmarks+      run more quickly.++  * Windows build script:++    + Add `-windows` to file name.+    + Use one install command for pandoc, pandoc-citeproc.+    + Force install of pandoc-citeproc.++  * `make_osx_package`:  Call zip file `pandoc-VERSION-osx.zip`.+    The zip should not be named `SOMETHING.pkg.zip`, or OSX finder+    will extract it into a folder named `SOMETHING.pkg`, which it+    will interpret as a defective package (#1308).++  * `README`:++    + Made headers for all extensions so they have IDs and can be+      linked to (Beni Cherniavsky-Paskin).+    + Fixed typos (Phillip Alday).+    + Fixed documentation of attributes (#1315).+    + Clarified documentation on small caps (#1360).+    + Better documentation for `fenced_code_attributes` extension+      (Caleb McDaniel).+    + Documented fact that you can put YAML metadata in a separate file+      (#1412).+++## pandoc 1.12.4.2 (2014-05-14)++  * Require highlighting-kate >= 0.5.8.  Fixes a performance regression.++  * Shared:  `addMetaValue` now behaves slightly differently:+    if both the new and old values are lists, it concatenates their+    contents to form a new list.++  * LaTeX reader:++    + Set `bibliography` in metadata from `\bibliography` or+      `\addbibresource` command.+    + Don't error on `%foo` with no trailing newline.++  * Org reader:++    + Support code block headers (`#+BEGIN_SRC ...`) (Albert Krewinkel).+    + Fix parsing of blank lines within blocks (Albert Krewinkel).+    + Support pandoc citation extension (Albert Krewinkel).  This can+      be turned off by specifying `org-citation` as the input format.++  * Markdown reader:++    + `citeKey` moved to `Text.Pandoc.Parsing` so it can be used by+      other readers (Albert Krewinkel).++  * `Text.Pandoc.Parsing`:++    + Added `citeKey` (see above).+    + Added `HasLastStrPosition` type class and `updateLastStrPos`+      and `notAfterString` functions.++  * Updated copyright notices (Albert Krewinkel).++  * Added default.icml to data files so it installs with the package.++  * OSX package:++    + The binary is now built with options to ensure that it can be+      used with OSX 10.6+.+    + Moved OSX package materials to osx directory.+    + Added OSX package uninstall script, included in the zip container+      (thanks to Daniel T. Staal).++## pandoc 1.12.4 (2014-05-07)++  * Made it possible to run filters that aren't executable+    (#1096). Pandoc first tries to find the executable (searching+    the path if path isn't given). If it fails, but the file+    exists and has a `.py`, `.pl`, `.rb`, `.hs`, or `.php`+    extension, pandoc runs the filter using the appropriate+    interpreter. This should make it easier to use filters on+    Windows, and make it more convenient for everyone.++  * Added Emacs org-mode reader (Albert Krewinkel).++  * Added InDesign ICML Writer (mb21).++  * MediaWiki reader:++    + Accept image links in more languages (Jaime Marquínez Ferrándiz).+    + Fixed bug in certain nested lists (#1213).  If a level 2 list was+      followed by a level 1 list, the first item of the level 1 list+      would be lost.+    + Handle table rows containing just an HTML comment (#1230).++  * LaTeX reader:++    + Give better location information on errors, pointing to line+      numbers within included files (#1274).+    + LaTeX reader:  Better handling of `table` environment (#1204).+      Positioning options no longer rendered verbatim.+    + Better handling of figure and table with caption (#1204).+    + Handle `@{}` and `p{length}` in tabular.  The length is not actually+      recorded, but at least we get a table (#1180).+    + Properly handle `\nocite`.  It now adds a `nocite` metadata+      field.  Citations there will appear in the bibliography but not+      in the text (unless you explicitly put a `$nocite$` variable+      in your template).++  * Markdown reader:++    + Ensure that whole numbers in YAML metadata are rendered without+      decimal points.  (This became necessary with changes to aeson+      and yaml libraries.  aeson >= 0.7 and yaml >= 0.8.8.2 are now required.)+    + Fixed regression on line breaks in strict mode (#1203).+    + Small efficiency improvements.+    + Improved parsing of nested `div`s.  Formerly a closing `div` tag+      would be missed if it came right after other block-level tags.+    + Avoid backtracking when closing `</div>` not found.+    + Fixed bug in reference link parsing in `markdown_mmd`.+    + Fixed a bug in list parsing (#1154).  When reading a raw list+      item, we now strip off up to 4 spaces.+    + Fixed parsing of empty reference link definitions (#1186).+    + Made one-column pipe tables work (#1218).++  * Textile reader:++    + Better support for attributes.  Instead of being ignored, attributes+      are now parsed and included in Span inlines.  The output will be a bit+      different from stock textile: e.g. for `*(foo)hi*`, we'll get+      `<em><span class="foo">hi</span></em>` instead of+      `<em class="foo">hi</em>`.  But at least the data is not lost.+    + Improved treatment of HTML spans (%) (#1115).+    + Improved link parsing.  In particular we now pick up on attributes.+      Since pandoc links can't have attributes, we enclose the whole link in+      a span if there are attributes (#1008).+    + Implemented correct parsing rules for inline markup (#1175, Matthew+      Pickering).+    + Use Builder (Matthew Pickering).++  * DocBook reader:++    + Better treatment of `formalpara`.  We now emit the title (if present)+      as a separate paragraph with boldface text (#1215).+    + Set metadata `author` not `authors`.+    + Added recognition of `authorgroup` and `releaseinfo` elements (#1214,+      Matthew Pickering).+    + Converted current meta information parsing in DocBook to a more+      extensible version which is aware of the more recent meta+      representation (Matthew Pickering).++  * HTML reader:++    + Require tagsoup 0.13.1, to fix a bug with parsing of script tags+      (#1248).+    + Treat processing instructions & declarations as block.  Previously+      these were treated as inline, and included in paragraph tags in HTML+      or DocBook output, which is generally not what is wanted (#1233).+    + Updated `closes` with rules from HTML5 spec.+    + Use Builder (Matthew Pickering, #1162).++  * RST reader:++    + Remove duplicate `http` in PEP links (Albert Krewinkel).+    + Make rst figures true figures (#1168, CasperVector)+    + Enhanced Pandoc's support for rST roles (Merijn Verstaaten).+      rST parser now supports: all built-in rST roles, new role definition,+      role inheritance, though with some limitations.+    + Use `author` rather than `authors` in metadata.+    + Better handling of directives.  We now correctly handle field+      lists that are indented more than three spaces.  We treat an+      `aafig` directive as a code block with attributes, so it can be+      processed in a filter (#1212).++  * LaTeX writer:++    + Mark span contents with label if span has an ID (Albert Krewinkel).+    + Made `--toc-depth` work well with books in latex/pdf output (#1210).+    + Handle line breaks in simple table cells (#1217).+    + Workaround for level 4-5 headers in quotes.  These previously produced+      invalid LaTeX: `\paragraph` or `\subparagraph` in a `quote` environment.+      This adds an `mbox{}` in these contexts to work around the problem.+      See <http://tex.stackexchange.com/a/169833/22451> (#1221).+    + Use `\/` to avoid en-dash ligature instead of `-{}-` (Vaclav Zeman).+      This is to fix LuaLaTeX output. The `-{}-` sequence does not avoid the+      ligature with LuaLaTeX but `\/` does.+    + Fixed string escaping in `hyperref` and `hyperdef` (#1130).++  * ConTeXt writer:  Improved autolinks (#1270).++  * DocBook writer:++    + Improve handling of hard line breaks in Docbook writer+      (Neil Mayhew).  Use a `<literallayout>` for the entire paragraph, not+      just for the newline character.+    + Don't let line breaks inside footnotes influence the enclosing+      paragraph (Neil Mayhew).+    + Distinguish tight and loose lists in DocBook output, using+      `spacing="compact"` (Neil Mayhew, #1250).++  * Docx writer:  When needed files are not present in the user's+    `reference.docx`, fall back on the versions in the `reference.docx`+    in pandoc's data files. This fixes a bug that occurs when a+    `reference.docx` saved by LibreOffice is used. (#1185)++  * EPUB writer:++    + Include extension in epub ids.  This fixes a problem with duplicate+      extensions for fonts and images with the same base name but different+      extensions (#1254).+    + Handle files linked in raw `img` tags (#1170).+    + Handle media in `audio` source tags (#1170).+      Note that we now use a `media` directory rather than `images`.+    + Incorporate files linked in `video` tags (#1170).  `src` and `poster`+      will both be incorporated into `content.opf` and the epub container.++  * HTML writer:++    + Add colgroup around col tags (#877).  Also affects EPUB writer.+    + Fixed bug with unnumbered section headings.  Unnumbered section+      headings (with class `unnumbered`) were getting numbers.+    + Improved detection of image links. Previously image links with+      queries were not recognized, causing `<embed>` to be used instead+      of `<img>`.++  * Man writer:  Ensure that terms in definition lists aren't line wrapped+    (#1195).++  * Markdown writer:++    + Use proper escapes to avoid unwanted lists (#980).  Previously we used+      0-width spaces, an ugly hack.+    + Use longer backtick fences if needed (#1206).  If the content contains a+      backtick fence and there are attributes, make sure longer fences are+      used to delimit the code.  Note:  This works well in pandoc, but github+      markdown is more limited, and will interpret the first string of three+      or more backticks as ending the code block.++  * RST writer:  Avoid stack overflow with certain tables (#1197).++  * RTF writer:  Fixed table cells containing paragraphs.++  * Custom writer:++    + Correctly handle UTF-8 in custom lua scripts (#1189).+    + Fix bugs with lua scripts with mixed-case filenames and+      paths containing `+` or `-` (#1267).  Note that `getWriter`+      in `Text.Pandoc` no longer returns a custom writer on input+      `foo.lua`.++  * AsciiDoc writer:  Handle multiblock and empty table cells+    (#1245, #1246).  Added tests.++  * `Text.Pandoc.Options`: Added `readerTrace` to `ReaderOptions`++  * `Text.Pandoc.Shared`:++    + Added `compactify'DL` (formerly in markdown reader) (Albert Krewinkel).+    + Fixed bug in `toRomanNumeral`:  numbers ending with '9' would+      be rendered as Roman numerals ending with 'IXIV' (#1249).  Thanks to+      Jesse Rosenthal.+    + `openURL`: set proxy with value of http_proxy env variable (#1211).+      Note:  proxies with non-root paths are not supported, due to+      limitations in `http-conduit`.++  * `Text.Pandoc.PDF`:++    + Ensure that temp directories deleted on Windows (#1192).  The PDF is+      now read as a strict bytestring, ensuring that process ownership will+      be terminated, so the temp directory can be deleted.+    + Use `/` as path separators in a few places, even on Windows.+      This seems to be necessary for texlive (#1151, thanks to Tim Lin).+    + Use `;` for `TEXINPUTS` separator on Windows (#1151).+    + Changes to error reporting, to handle non-UTF8 error output.++  * `Text.Pandoc.Templates`:++    + Removed unneeded datatype context (Merijn Verstraaten).++    + YAML objects resolve to "true" in conditionals (#1133).+      Note:  If `address` is a YAML object and you just have `$address$`+      in your template, the word `true` will appear, which may be+      unexpected.  (Previously nothing would appear.)++  * `Text.Pandoc.SelfContained`:  Handle `poster` attribute in `video`+    tags (#1188).++  * `Text.Pandoc.Parsing`:++    + Made `F` an instance of Applicative (#1138).+    + Added `stateCaption`.+    + Added `HasMacros`, simplified other typeclasses.+      Removed `updateHeaderMap`, `setHeaderMap`, `getHeaderMap`,+      `updateIdentifierList`, `setIdentifierList`, `getIdentifierList`.+    + Changed the smart punctuation parser to return `Inlines`+      rather than `Inline` (Matthew Pickering).+    + Changed `HasReaderOptions`, `HasHeaderMap`, `HasIdentifierList`+      from typeclasses of monads to typeclasses of states.  This simplifies+      the instance definitions and provides more flexibility.  Generalized+      type of `getOption` and added a default definition.  Removed+      `askReaderOption`.  Added `extractReaderOption`.  Added+      `extractHeaderMap` and `updateHeaderMap` in `HasHeaderMap`.+      Gave default definitions for `getHeaderMap`, `putHeaderMap`,+      `modifyHeaderMap`.  Added `extractIdentifierList` and+      `updateIdentifierList` in `HasIdentifierList`.  Gave defaults+      for `getIdentifierList`, `putIdentifierList`, and+      `modifyIdentifierList`.  The ultimate goal here is to allow different+      parsers to use their own, tailored parser states (instead of+      `ParserState`) while still using shared functions.++  * Template changes:++    + LaTeX template: Use `fontenc` package only with `pdflatex` (#1164).+    + LaTeX template:  Add `linestretch` and `fontfamily` variables.+    + LaTeX template:  Conditionalize author and date commands.+    + Beamer template: Consistent styles for figure and table captions+      (aaronwolen).+    + LaTeX and beamer template:  Adjust widths correctly for oversized+      images.  Use `\setkeys{Gin}{}` to set appropriate defaults for+      `\includegraphics` (Yihui Xie, Garrick Aden-Buie).  Load+      `upquote` only after `fontenc` (Yihui Xie).+    + Beamer template: Added caption package (#1200).+    + Beamer template:  changes for better unicode handling (KarolS).+    + DocBook template:  use `authorgroup` if there are authors.+    + revealjs template: Move `include-after` to end (certainlyakey).+    + revealjs template: Fixed PDF print function (#1220, kevinkenan).++  * Bumped version bounds of dependencies.++  * Added a `--trace` command line option, for debugging backtracking+    bugs.  So far this only works with the markdown reader.++  * MathMLinHTML:  Fixed deprecation warning (#362, gwern, Albert Krewinkel).++  * Updated travis script to test with multiple GHC versions.++  * Force failure of a Travis build if GHC produces warnings (Albert+    Krewinkel).++  * Add `.editorconfig` (Albert Krewinkel).+    See <http://editorconfig.org/> for details.++  * Give more useful error message if '-t pdf' is specified (#1155).++  * Added `Cite`, `SmallCaps` to `Arbitrary` instance (#1269).++  * Allow `html4` as a synonym of `html` as a reader (it already works+    as a writer).++  * README:++    + Added an explanation of how to use YAML metadata to+      force items to appear in the bibliography without citations in+      the text (like LaTeX `\nocite`).+    + Added note to `--bibtex/--natbib`: not for use in making PDF+      (#1194, thanks to nahoj).+    + Added explanatory notes about `--natbib` and `--biblatex`.+    + Added specification of legal syntax for citation keys.+    + Fixed variable defaults documentation (Albert Krewinkel).++  * Removed copyright statements for files that have been removed+    (Albert Krewinkel).++  * Moved some doc files from `data-files` to `extra-source-files` (#1123).+    They aren't needed at runtime.  We keep README and COPYRIGHT in data+    to ensure that they'll be available on all systems on which pandoc+    is installed.++  * Use cabal sandboxes in Windows build script.++## pandoc 1.12.3.3 (2014-02-03)++  * To changes to source; recompiled tarball with latest alex and+    happy, so they will work with GHC 7.8.++## pandoc 1.12.3.2 (2014-02-03)++  * Bumped version bounds for blaze-html, blaze-markup.++  * ImageSize:  Avoid use of lookAhead, which is not in binary >= 0.6+    (#1124).++  * Fixed mediawiki ordered list parsing (#1122).++  * HTML reader:  Fixed bug reading inline math with `$$` (#225).++  * Added support for LaTeX style literate Haskell code blocks in rST+    (Merijn Verstraaten).++## pandoc 1.12.3.1 (2014-01-14)++  * Relaxed version constraint on binary, allowing the use of binary 0.5.+++## pandoc 1.12.3 (2014-01-10)++  * The `--bibliography` option now sets the `biblio-files` variable.+    So, if you're using `--natbib` or `--biblatex`, you can just use+    `--bibliography=foo.bib` instead of `-V bibliofiles=foo`.++  * Don't run pandoc-citeproc filter if `--bibliography` is+    used together with `--natbib` or `--biblatex` (Florian Eitel).++  * Template changes:++    + Updated beamer template to include booktabs.+    + Added `abstract` variable to LaTeX template.+    + Put `header-includes` after `title` in LaTeX template (#908).+    + Allow use of `\includegraphics[size]` in beamer.+      This just required porting a macro definition from the default+      LaTeX template to the default beamer template.++  * `reference.docx`:  Include `FootnoteText` style.+    Otherwise Word ignores the style, even when specified in the `pPr`.+    (#901)++  * `reference.odt`:  Tidied `styles.xml`.++  * Relaxed version bounds for dependencies.++  * Added `withSocketsDo` around http conduit code in `openURL`,+    so it works on Windows (#1080).++  * Added `Cite` function to `sample.lua`.++  * Markdown reader:++    + Fixed regression in title blocks (#1089).+      If author field was empty, date was being ignored.+    + Allow backslash-newline hard line breaks in grid and+      multiline table cells.+    + Citation keys may now start with underscores, and may contain+      underscores adjacent to internal punctuation.++  * LaTeX reader:++    + Add support for `Verb` macro (jrnold) (#1090).+    + Support babel-style quoting: `` "`..."' ``.++  * Properly handle script blocks in strict mode.  (That is,+    `markdown-markdown_in_html_blocks`.) Previously a spurious+    `<p>` tag was being added (#1093).++  * Docbook reader: Avoid failure if `tbody` contains no `tr` or `row`+    elements.++  * LaTeX writer:++    + Factored out function for table cell creation.+    + Better treatment of footnotes in tables.+      Notes now appear in the regular sequence, rather than in the+      table cell.  (This was a regression in 1.10.)++  * HTML reader: Parse name/content pairs from meta tags as metadata.+    Closes #1106.++  * Moved `fixDisplayMath` from Docx writer to `Writer.Shared`.++  * OpenDocument writer:  Fixed `RawInline`, `RawBlock` so they don't escape.++  * ODT writer:  Use mathml for proper rendering of formulas.+    Note:  LibreOffice's support for this seems a bit buggy.  But+    it should be better than what we had before.++  * RST writer: Ensure no blank line after def in definition list (#992).++  * Markdown writer: Don't use tilde code blocks with braced attributes in+    `markdown_github` output.  A consequence of this change is that the+    backtick form will be preferred in general if both are enabled.  That+    is good, as it is much more widespread than the tilde form.  (#1084)++  * Docx writer:  Fixed problem with some modified reference docx files.+    Include `word/_rels/settings.xml.rels` if it exists, as well as other+    `rels` files besides the ones pandoc generates explicitly.++  * HTML writer:++    + With `--toc`, headers no longer link to themselves (#1081).+    + Omit footnotes from TOC entries.  Otherwise we get doubled+      footnotes when headers have notes!++  * EPUB writer:++    + Avoid duplicate notes when headings contain notes.+      This arose because the headings are copied into the metadata+      "title" field, and the note gets rendered twice.  We strip the+      note now before putting the heading in "title".+    + Strip out footnotes from toc entries.+    + Fixed bug with `--epub-stylesheet`.  Now the contents of+      `writerEpubStylesheet` (set by `--epub-stylesheet`)+      should again work, and take precedence over a stylesheet specified+      in the metadata.++  * `Text.Pandoc.Pretty`:  Added `nestle`.  API change.++  * `Text.Pandoc.MIME`: Added `wmf`, `emf`.++  * `Text.Pandoc.Shared`:  `fetchItem` now handles image URLs beginning+    with `//`.++  * `Text.Pandoc.ImageSize`:  Parse EXIF format JPEGs.  Previously+    we could only get size information for JFIF format, which led+    to squished images in Word documents. Closes #976.++  * Removed old `MarkdownTest_1.0.3` directory (#1104).+++## pandoc 1.12.2.1 (2013-12-08)++  * Markdown reader:  Fixed regression in list parser, involving+    continuation lines containing raw HTML (or even verbatim raw HTML).++## pandoc 1.12.2 (2013-12-07)++  * Metadata may now be included in YAML blocks in a markdown document.+    For example,++        ---+        title:+        - type: main+          text: My Book+        - type: subtitle+          text: An investigation of metadata+        creator:+        - role: author+          text: John Smith+        - role: editor+          text: Sarah Jones+        identifier:+        - scheme: DOI+          text: doi:10.234234.234/33+        publisher:  My Press+        rights:  (c) 2007 John Smith, CC BY-NC+        cover-image: img/mypic.jpg+        stylesheet: style.css+        ...++    Metadata may still be provided using `--epub-metadata`; it will+    be merged with the metadata in YAML blocks.++  * EPUB writer:++    + `meta` tags are now used instead of `opf` attributes for EPUB3.+    + Insert "svg" property as needed in opf (EPUB 3).+    + Simplify `imageTypeOf` using `getMimeType`.+    + Add properties attribute to `cover-image` item for EPUB 3.+    + Don't include node for `cover.xhtml` if no cover!+    + Ensure that same identifier is used throughout (#1044).+      If an identifier is given in metadata, we use that; otherwise+      we generate a random uuid.+    + Add cover reference to guide element (EPUB 2) (Shaun Attfield).+      Fixes an issue with Calibre putting the cover at the end of the book+      if the spine has `linear="no"`.  Apparently this is best practice+      for other converters as well:+      <http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.6>.+    + Allow `stylesheet` in metadata.  The value is a path to the stylesheet.+    + Allow partial dates:  `YYYY`, `YYYY-MM`.++  * Markdown writer:  Fix rendering of tight sublists (#1050).+    Previously a spurious blank line was included after a tight sublist.++  * ODT writer:  Add `draw:name` attribute to `draw:frame` elements (#1069).+    This is reported to be necessary to avoid an error from recent+    versions of Libre Office when files contain more than one image+    Thanks to wmanley for reporting and diagnosing the problem.++  * ConTeXt writer:  Don't hardcode figure/table placement and numbering.+    Instead, let this be set in the template, using `\setupfloat`.+    Thanks to on4aa and Aditya Mahajan for the suggestion (#1067).++  * Implemented CSL flipflopping spans in DOCX, LaTeX, and HTML writers.++  * Fixed bug with markdown intraword emphasis.  Closes #1066.++  * Docbook writer:  Hierarchicalize block content in metadata.+    Previously headers just disappeared from block-level metadata+    when it was used in templates.  Now we apply the 'hierarchicalize'+    transformation.  Note that a block headed by a level-2 header will+    turn into a `<sect1>` element.++  * OpenDocument writer:  Skip raw HTML (#1035).+    Previously it was erroneously included as verbatim text.++  * HTML/EPUB writer, footnotes:  Put `<sup>` tag inside `<a>` tags.+    This allows better control of formatting, since the `<a>`+    tags have a distinguishing class (#1049).++  * Docx writer:++    + Use mime type info returned by fetchItem.+    + Fixed core metadata (#1046).+      Don't create empty date nodes if no date given.+      Don't create multiple `dc:creator` nodes; instead separate by+      semicolons.+    + Fix URL for core-properties in `_rels/.rels` (#1046).++  * Plain writer: don't print `<span>` tags.++  * LaTeX writer:++    + Fix definition lists with internal links in terms (#1032).+      This fix puts braces around a term that contains an internal+      link, to avoid problems with square brackets.+    + Properly escape pdftitle, pdfauthor (#1059).+    + Use booktabs package for tables (thanks to Jose Luis Duran).++  * Updated beamer template.  Now references should work properly+    (in a slide) when `--biblatex` or `--natbib` is used.++  * LaTeX reader:++    + Parse contents of curly quotes or matched `"` as quotes.+    + Support `\textnormal` as span with class `nodecor`.+      This is needed for pandoc-citeproc.+    + Improved citation parsing.  This fixes a run-time error that occurred+      with `\citet{}` (empty list of keys).  It also ensures that empty keys+      don't get produced.++  * MediaWiki reader:  Add automatic header identifiers.++  * HTML reader:++    + Use pandoc `Div` and `Span` for raw `<div>`, `<span>` when+      `--parse-raw`.+    + Recognize `svg` tags as block level content (thanks to MinRK).+    + Parse LaTeX math if appropriate options are set.++  * Markdown reader:++    + Yaml block must start immediately after `---`.  If there's a blank+      line after `---`, we interpreted it as a horizontal rule.+    + Correctly handle empty bullet list items.+    + Stop parsing "list lines" when we hit a block tag.+      This fixes exponential slowdown in certain input, e.g.+      a series of lists followed by `</div>`.++   * Slides:  Preserve `<div class="references">` in references slide.++  * `Text.Pandoc.Writer.Shared`:++    + Fixed bug in `tagWithAttrs`.  A space was omitted before key-value+      attributes, leading to invalid HTML.+    + `normalizeDate`: Allow dates with year only (thanks to Shaun Attfield).+    + Fixed bug in `openURL` with `data:` URIs.  Previously the base-64+      encoded bytestring was returned.  We now decode it so it's a proper+      image!++  * DocBook reader:  Handle numerical attributes starting with decimal.+    Also use `safeRead` instead of `read`.++  * `Text.Pandoc.Parsing`:++    + Generalized type of `registerHeader`, using new type classes+      `HasReadeOptions`, `HasIdentifierList`, `HasHeaderMap`.+      These allow certain common functions to be reused+      even in parsers that use custom state (instead of `ParserState`),+      such as the MediaWiki reader.+    + Moved inlineMath, displayMath from Markdown reader to Parsing.+      Generalize their types and export them from Parsing.  (API change.)++  * `Text.Pandoc.Readers.TexMath`: Export `readTeXMath'`, which attends+    to display/inline.  Deprecate `readTeXMath`, and use `readTeXMath'`+    in all the writers.  Require `texmath >= 0.6.5.2`.++  * `Text.Pandoc.MIME`:++    + Add entry for `jfif`.+    + In looking up extensions, drop the encoding info.+      E.g. for 'image/jpg;base64' we should lookup 'image/jpg'.++  * Templates:  Changed how array variables are resolved.  Previously if+    `foo` is an array (which might be because multiple values were set on+    the command line), `$foo$` would resolve to the concatenation of the+    elements of foo.  This is rarely useful behavior.  It has been changed+    so that the first value is rendered.  Of course, you can still iterate+    over the values using `$for(foo)$`.  This has the result that you can+    override earlier settings using `-V` by putting new values later on the+    command line, which is useful for many purposes.++  * `Text.Pandoc`:  Don't default to `pandocExtensions` for all writers.++  * Allow "epub2" as synonym for "epub", "html4" for "html".++  * Don't look for slidy files in data files with `--self-contained`.++  * Allow `https:` command line arguments to be downloaded.++  * Fixed `make_osx_package.sh` so data files embedded in `pandoc-citeproc`.++## pandoc 1.12.1 (2013-10-20)++  * `Text.Pandoc.Definition`:  Changed default JSON serialization format.+    Instead of `{"Str": "foo"}`, for example, we now have `{"t": "Str",+    "c": "foo"}`.  This new format is easier to work with outside of Haskell.+    Incidentally, "t" stands for "tag", "c" for "contents".++  * MediaWiki reader: Trim contents of `<math>` tags, to avoid problems+    when converting to markdown (#1027).++  * LaTeX reader:++    + Ensure that preamble doesn't contribute to the text of+      the document.+    + Fixed character escaping in `\url{}`.  Previously `\~` wasn't handled+      properly, among others.+    + Parse `{groups}` as `Span`.  This is needed for accurate conversion of+      bibtex titles, since we need to know what was protected from+      titlecase conversions.++  * LaTeX writer:++    + Specially escape non-ascii characters in labels.+      Otherwise we can get compile errors and other bugs when+      compiled with pdflatex (#1007).  Thanks to begemotv2718 for the fix.+    + Add link anchors for code blocks with identifiers (#1025).++  * Throughout the code, use `isURI` instead of `isAbsoluteURI`.+    It allows fragments identifiers.++  * Slide formats:++    + A Div element with class "notes" is treated as speaker+      notes.  Currently beamer goes to `\note{}`, revealjs to+      `<aside class="notes">`, and the notes are simply suppressed in+      other formats  (#925).+    + Fixed `. . .` (pause) on HTML slide formats.  Closes #1029.+      The old version caused a pause to be inserted before the first+      material on a slide. This has been fixed.+    + Removed data files for s5, slideous, slidy.+      Users of s5 and slideous will have to download the needed+      files, as has been documented for some time in the README.+      By default, slidy code will be sought on the web, as before.++  * HTML writer: Insert command to typeset mathjax only in slideous output+    (#966, #1012).++  * RST writer:  Skip spaces after display math.  Otherwise we get indentation+    problems, and part of the next paragraph may be rendered as part of the+    math.++  * OpenDocument writer:  Fix formatting of strikeout code (#995),+    thanks to wilx.  don't use `font-face-decls` variable.++  * Fixed test suite so it works with cabal sandboxes.++## pandoc 1.12.0.2 (2013-09-20)++  * Removed an unused dependency (`stringable`) from pandoc.cabal.+    This will help packagers, but users should not need to upgrade.++## pandoc 1.12.0.1 (2013-09-20)++  * Allow `--metadata` to be repeated for the same key to form a list.+    This also has the effect that `--bibliography` can be repeated,+    as before.++  * Handle boolean values in `--metadata`.  Note that anything not parseable+    as a YAML boolean or string is treated as a literal string.+    You can get a string value with "yes", or any of the strings interpretable+    as booleans, by quoting it:++        -M boolvalue=yes -M stringvalue='"yes"'++  * LaTeX writer: Don't print references if `--natbib` or `--biblatex`+    option used.++  * DOCX writer: Add `settings.xml` to the zip container.  Fixes a bug+    in which docx files could not be read by some versions of Word+    and LibreOffice (#990).++  * Fixed a regression involving slide shows with bibliographies.+    The Div container around references messed up the procedure for carving+    a document into slides.  So we now remove the surrounding Div in+    `prepSlides`.++  * More informative error message when a filter is not found in path.++  * Depend on pandoc-types 1.12.1.  This provide `ToJSONFilter`+    instances for `Data a => a -> [a]` and `Data a => a -> IO [a]`.++  * Don't use unicode_collation in building OSX package:+    it adds something like 50MB of dependencies to the package.++  * Declare alex and happy as build-tools (#986).++## pandoc 1.12 (2013-09-15)++### New features++  * Much more flexible metadata, including arbitrary fields and structured+    values.  Metadata can be specified flexibly in pandoc markdown using+    YAML metadata blocks, which may occur anywhere in the document:++        ---+        title: Here is my title.+        abstract: |+          This is the abstract.++          1. It can contain+          2. block content+             and *inline markup*++        tags: [cat, dog, animal]+        ...++    Metadata fields automatically populate template variables.++  * Added `opml` (OPML) as input and output format.  The `_note` attribute,+    used in OmniOutliner and supported by multimarkdown, is supported.+    We treat the contents as markdown blocks under a section header.++  * Added `haddock` (Haddock markup) as input format (David Lazar).++  * Added `revealjs` output format, for reveal.js HTML 5 slide shows.+    (Thanks to Jamie F. Olson for the initial patch.)+    Nested vertical stacks are used for hierarchical structure.+    Results for more than one level of nesting may be odd.++  * Custom writers can now be written in lua.++        pandoc -t data/sample.lua++    will load the script sample.lua and use it as a custom writer.+    (For a sample, do `pandoc --print-default-data-file sample.lua`.)+    Note that pandoc embeds a lua interpreter, so lua need not be+    installed separately.++  * New `--filter/-F` option to make it easier to run "filters"+    (Pandoc AST transformations that operate on JSON serializations).+    Filters are always passed the name of the output format, so their+    behavior can be tailored to it.  The repository+    <https://github.com/jgm/pandocfilters> contains+    a python module for writing pandoc filters in python, with+    a number of examples.++  * Added `--metadata/-M` option.+    This is like `--variable/-V`, but actually adds to metadata, not+    just variables.++  * Added `--print-default-data-file` option, which allows printing+    of any of pandoc's data files. (For example,+    `pandoc --print-default-data-file reference.odt` will print+    `reference.odt`.)++  * Added syntax for "pauses" in slide shows:++        This gives++        . . .++        me pause.++  * New markdown extensions:++    + `ignore_line_breaks`:  causes intra-paragraph line breaks to be ignored,+      rather than being treated as hard line breaks or spaces.  This is useful+      for some East Asian languages, where spaces aren't used between words,+      but text is separated into lines for readability.+    + `yaml_metadata_block`:  Parse YAML metadata blocks.  (Default.)+    + `ascii_identifiers`: This will force `auto_identifiers` to use ASCII+       only. (Default for `markdown_github`.) (#807)+    + `lists_without_preceding_blankline`:  Allow lists to start without+      preceding blank space.  (Default for `markdown_github`.) (#972)++### Behavior changes++  * `--toc-level` no longer implies `--toc`.+    Reason: EPUB users who don't want a visible TOC may still want+    to set the TOC level for in the book navigation.++  * `--help` now prints in and out formats in alphabetical order, and+    says something about PDF output (#720).++  * `--self-contained` now returns less verbose output (telling you+    which URLs it is fetching, but not giving the full header).  In+    addition, there are better error messages when fetching a URL fails.++  * Citation support is no longer baked in to core pandoc. Users who+    need citations will need to install and use a separate filter+    (`--filter pandoc-citeproc`).  This filter will take `bibliography`,+    `csl`, and `citation-abbreviations` from the metadata, though it+    may still be specified on the command line as before.++  * A `Cite` element is now created in parsing markdown whether or not+    there is a matching reference.++  * The `pandoc-citeproc` script will put the bibliography at the+    end of the document, as before.  However, it will be put inside a `Div`+    element with class "references", allowing users some control+    over the styling of references.  A final header, if any, will+    be included in the `Div`.++  * The markdown writer will not print a bibliography if the+    `citations` extension is enabled.  (If the citations are formatted+    as markdown citations, it is redundant to have a bibliography,+    since one will be generated automatically.)++  * Previously we used to store the directory of the first input file,+    even if it was local, and used this as a base directory for finding+    images in ODT, EPUB, Docx, and PDF.  This has been confusing to many+    users.  So we now look for images relative to the current+    working directory, even if the first file argument is in another+    directory.   Note that this change may break some existing workflows.+    If you have been assuming that relative links will be interpreted+    relative to the directory of the first file argument, you'll need+    to make that the current directory before running pandoc. (#942)++  * Better error reporting in some readers, due to changes in `readWith`:+    the line in which the error occurred is printed, with a caret pointing+    to the column.++  * All slide formats now support incremental slide view for definition lists.++  * Parse `\(..\)` and `\[..\]` as math in MediaWiki reader.+    Parse `:<math>...</math>` as display math.  These notations are used with+    the MathJax MediaWiki extension.++  * All writers: template variables are set automatically from metadata+    fields.  However, variables specified on the command line with+    `--variable` will completely shadow metadata fields.++  * If `--variable` is used to set many variables with the same name,+    a list is created.++  * Man writer:  The `title`, `section`, `header`, and `footer` can now+    all be set individually in metadata.  The `description` variable has been+    removed.  Quotes have been added so that spaces are allowed in the+    title.  If you have a title that begins++        COMMAND(1) footer here | header here++    pandoc will still parse it into a title, section, header, and+    footer.  But you can also specify these elements explicitly (#885).++  * Markdown reader++    + Added support for YAML metadata blocks, which can come anywhere+      in the document (not just at the beginning).  A document can contain+      multiple YAML metadata blocks.+    + HTML span and div tags are parsed as pandoc Span and Div elements.++  * Markdown writer++    + Allow simple tables to be printed as grid tables,+      if other table options are disabled.  This means you can do+      `pandoc -t markdown-pipe_tables-simple_tables-multiline_tables`+      and all tables will render as grid tables.+    + Support YAML title block (render fields in alphabetical order+      to make output predictable).++### API changes++  * `Meta` in `Text.Pandoc.Definition` has been changed to allow+    structured metadata.  (Note:  existing code that pattern-matches+    on `Meta` will have to be revised.)  Metadata can now contain+    indefinitely many fields, with content that can be a string,+    a Boolean, a list of `Inline` elements, a list of `Block`+    elements, or a map or list of these.++  * A new generic block container (`Div`) has been added to `Block`,+    and a generic inline container (`Span`) has been added to `Inline`.+    These can take attributes.  They will render in HTML, Textile,+    MediaWiki, Org, RST and Markdown (with `markdown_in_html`+    extension) as HTML `<div>` and `<span>` elements; in other formats+    they will simply pass through their contents.  But they can be+    targeted by scripts.++  * `Format` is now a newtype, not an alias for String.+    Equality comparisons are case-insensitive.++  * Added `Text.Pandoc.Walk`, which exports hand-written tree-walking+    functions that are much faster than the SYB functions from+    `Text.Pandoc.Generic`.  These functions are now used where possible+    in pandoc's code.  (`Tests.Walk` verifies that `walk` and `query`+    match the generic traversals `bottomUp` and `queryWith`.)++  * Added `Text.Pandoc.JSON`, which provides `ToJSON` and `FromJSON`+    instances for the basic pandoc types. They use GHC generics and+    should be faster than the old JSON serialization using+    `Data.Aeson.Generic`.++  * Added `Text.Pandoc.Process`, exporting `pipeProcess`.+    This is a souped-up version of `readProcessWithErrorcode` that+    uses lazy bytestrings instead of strings and allows setting+    environment variables.  (Used in `Text.Pandoc.PDF`.)++  * New module `Text.Pandoc.Readers.OPML`.++  * New module `Text.Pandoc.Writers.OPML`.++  * New module `Text.Pandoc.Readers.Haddock` (David Lazar).+    This is based on Haddock's own lexer/parser.++  * New module `Text.Pandoc.Writers.Custom`.++  * In `Text.Pandoc.Shared`, `openURL` and `fetchItem` now return an+    Either, for better error handling.++  * Made `stringify` polymorphic in `Text.Pandoc.Shared`.++  * Removed `stripTags` from `Text.Pandoc.XML`.++  * `Text.Pandoc.Templates`:++    + Simplified `Template` type to a newtype.+    + Removed `Empty`.+    + Changed type of `renderTemplate`: it now takes a JSON context+      and a compiled template.+    + Export `compileTemplate`.+    + Export `renderTemplate'` that takes a string instead of a compiled+      template.+    + Export `varListToJSON`.++  * `Text.Pandoc.PDF` exports `makePDF` instead of `tex2pdf`.++  * `Text.Pandoc`:++    + Made `toJsonFilter` an alias for `toJSONFilter` from `Text.Pandoc.JSON`.+    + Removed `ToJsonFilter` typeclass.  `ToJSONFilter` from+      `Text.Pandoc.JSON` should be used instead.  (Compiling against+      pandoc-types instead of pandoc will also produce smaller executables.)+    * Removed the deprecated `jsonFilter` function.+    + Added `readJSON`, `writeJSON` to the API (#817).++  * `Text.Pandoc.Options`:++    + Added `Ext_lists_without_preceding_blankline`,+      `Ext_ascii_identifiers`, `Ext_ignore_line_breaks`,+      `Ext_yaml_metadataBlock` to `Extension`.+    + Changed `writerSourceDirectory` to `writerSourceURL` and changed the+      type to a `Maybe`.  `writerSourceURL` is set to 'Just url' when the+      first command-line argument is an absolute URL.  (So, relative links+      will be resolved in relation to the first page.)  Otherwise, 'Nothing'.+    + All bibliography-related fields have been removed from+      `ReaderOptions` and `WriterOptions`: `writerBiblioFiles`,+      `readerReferences`, `readerCitationStyle`.++  * The `Text.Pandoc.Biblio` module has been removed.  Users of the+    pandoc library who want citation support will need to use+    `Text.CSL.Pandoc` from `pandoc-citeproc`.++### Bug fixes++  * In markdown, don't autolink a bare URI that is followed by `</a>`+    (#937).++  * `Text.Pandoc.Shared`++    + `openURL` now follows redirects (#701), properly handles `data:`+      URIs, and prints diagnostic output to stderr rather than stdout.+    + `readDefaultDataFile`: normalize the paths.  This fixes bugs in+      `--self-contained` on pandoc compiled with `embed_data_files` (#833).+    + Fixed `readDefaultDataFile` so it works on Windows.+    + Better error messages for `readDefaultDataFile`.  Instead of+      listing the last path tried, which can confuse people who are+      using `--self-contained`, so now we just list the data file name.+    + URL-escape pipe characters.  Even though these are legal, `Network.URI`+      doesn't regard them as legal in URLs.  So we escape them first (#535).++  * Mathjax in HTML slide shows:  include explicit "Typeset" call.+    This seems to be needed for some formats (e.g. slideous) and won't+    hurt in others (#966).++  * `Text.Pandoc.PDF`++    + On Windows, create temdir in working directory, since the system+      temp directory path may contain tildes, which can cause+      problems in LaTeX (#777).+    + Put temporary output directory in `TEXINPUTS` (see #917).+    + `makePDF` tries to download images that are not found locally,+      if the first argument is a URL (#917).+    + If compiling with `pdflatex` yields an encoding error, offer+      the suggestion to use `--latex-engine=xelatex`.++  * Produce automatic header identifiers in parsing textile, RST,+    and LaTeX, unless `auto_identifiers` extension is disabled (#967).++  * `Text.Pandoc.SelfContained`:  Strip off fragment, query of relative URL+     before treating as a filename.  This fixes `--self-contained` when used+     with CSS files that include web fonts using the method described here:+      <http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/>+      (#739).  Handle `src` in `embed`, `audio`, `source`, `input` tags.++  * `Text.Pandoc.Parsing`: `uri` parser no longer treats punctuation before+    percent-encoding, or a `+` character, as final punctuation.++  * `Text.Pandoc.ImageSize`:  Handle EPS (#903).  This change will make+    EPS images properly sized on conversion to Word.++  * Slidy:  Use slidy.js rather than slidy.js.gz.+    Reason:  some browsers have trouble with the gzipped js file,+    at least on the local file system (#795).++  * Markdown reader++    + Properly handle blank line at beginning of input (#882).+    + Fixed bug in unmatched reference links.  The input+      `[*infile*] [*outfile*]` was getting improperly parsed:+      "infile" was emphasized, but "*outfile*" was literal (#883).+    + Allow internal `+` in citation identifiers (#856).+    + Allow `.` or `)` after `#` in ATX headers if no `fancy_lists`.+    + Do not generate blank title, author, or date metadata elements.+      Leave these out entirely if they aren't present.+    + Allow backtick code blocks not to be preceded by blank line (#975).++  * Textile reader:++    + Correctly handle entities.+    + Improved handling of `<pre>` blocks (#927). Remove internal HTML tags+      in code blocks, rather than printing them verbatim. Parse attributes+      on `<pre>` tag for code blocks.++  * HTML reader: Handle non-simple tables (#893).  Column widths are read from+    `col` tags if present, otherwise divided equally.++  * LaTeX reader++    + Support alltt environment (#892).+    + Support `\textasciitilde`, `\textasciicircum` (#810).+    + Treat `\textsl` as emphasized text reader (#850).+    + Skip positional options after `\begin{figure}`.+    + Support `\v{}` for hacek (#926).+    + Don't add spurious ", " to citation suffixes.+      This is added when needed in pandoc-citeproc.+    + Allow spaces in alignment spec in tables, e.g. `{ l r c }`.+    + Improved support for accented characters (thanks to Scott Morrison).+    + Parse label after section command and set id (#951).++  * RST reader:++    + Don't insert paragraphs where docutils doesn't.+      `rst2html` doesn't add `<p>` tags to list items (even when they are+      separated by blank lines) unless there are multiple paragraphs in the+      list.  This commit changes the RST reader to conform more closely to+      what docutils does (#880).+    + Improved metadata.  Treat initial field list as metadata when+      standalone specified.  Previously ALL fields "title", "author",+      "date" in field lists were treated as metadata, even if not at+      the beginning.  Use `subtitle` metadata field for subtitle.+    + Fixed 'authors' metadata parsing in reST.  Semicolons separate+      different authors.++  * MediaWiki reader++    + Allow space before table rows.+    + Fixed regression for `<ref>URL</ref>`.+      `<` is no longer allowed in URLs, according to the uri parser+      in `Text.Pandoc.Parsing`.  Added a test case.+    + Correctly handle indented preformatted text without preceding+      or following blank line.+    + Fixed `|` links inside table cells.  Improved attribute parsing.+    + Skip attributes on table rows.  Previously we just crashed if+      rows had attributes, now we ignore them.+    + Ignore attributes on headers.+    + Allow `Image:` for images (#971).+    + Parse an image with caption in a paragraph by itself as a figure.++  * LaTeX writer++    + Don't use ligatures in escaping inline code.+    + Fixed footnote numbers in LaTeX/PDF tables.  This fixes a bug+      wherein notes were numbered incorrectly in tables (#827).+    + Always create labels for sections.  Previously the labels were only+      created when there were links to the section in the document (#871).+    + Stop escaping `|` in LaTeX math.+      This caused problems with array environments (#891).+    + Change `\` to `/` in paths.  `/` works even on Windows in LaTeX.+      `\` will cause major problems if unescaped.+    + Write id for code block to label attribute in LaTeX when listings+      is used (thanks to Florian Eitel).+    + Scale LaTeX tables so they don't exceed columnwidth.+    + Avoid problem with footnotes in unnumbered headers (#940).++  * Beamer writer: when creating beamer slides, add `allowframebreaks` option+      to the slide if it is one of the header classes.  It is recommended+      that your bibliography slide have this attribute:++        # References {.allowframebreaks}++    This causes multiple slides to be created if necessary, depending+    on the length of the bibliography.++  * ConTeXt writer: Properly handle tables without captions.  The old output+    only worked in MkII. This should work in MkIV as well (#837).++  * MediaWiki writer: Use native mediawiki tables instead of HTML (#720).++  * HTML writer:++    + Fixed `--no-highlight` (Alexander Kondratskiy).+    + Don't convert to lowercase in email obfuscation (#839).+    + Ensure proper escaping in `<title>` and `<meta>` fields.++  * AsciiDoc writer:++    + Support `--atx-headers` (Max Rydahl Andersen).+    + Don't print empty identifier blocks `([[]])` on headers (Max+      Rydahl Andersen).++  * ODT writer:++    + Fixing wrong numbered-list indentation in open document format+      (Alexander Kondratskiy) (#369).+    + `reference.odt`: Added pandoc as "generator" in `meta.xml`.+    + Minor changes for ODF 1.2 conformance (#939). We leave the+      nonconforming `contextual-spacing` attribute, which is provided by+      LibreOffice itself and seems well supported.++  * Docx writer:++    + Fixed rendering of display math in lists.+      In 1.11 and 1.11.1, display math in lists rendered as a new list+      item.  Now it always appears centered, just as outside of lists,+      and in proper display math style, no matter how far indented the+      containing list item is (#784).+    + Use `w:br` with `w:type` `textWrapping` for linebreaks.+      Previously we used `w:cr` (#873).+    + Use Compact style for Plain block elements, to+      differentiate between tight and loose lists (#775).+    + Ignore most components of `reference.docx`.+      We take the `word/styles.xml`, `docProps/app.xml`,+      `word/theme/theme1.xml`, and `word/fontTable.xml` from+      `reference.docx`, ignoring everything else.  This should help+      with the corruption problems caused when different versions of+      Word resave the reference.docx and reorganize things.+    +  Made `--no-highlight` work properly.++  * EPUB writer++    + Don't add `dc:creator` tags if present in EPUB metadata.+    + Add `id="toc-title"` to `h1` in `nav.xhtml` (#799).+    + Don't put blank title page in reading sequence.+      Set `linear="no"` if no title block.  Addresses #797.+    + Download webtex images and include as data URLs.+      This allows you to use `--webtex` in creating EPUBs.+      Math with `--webtex` is automatically made self-contained.+    + In `data/epub.css`, removed highlighting styles (which+      are no longer needed, since styles are added by the HTML+      writer according to `--highlighting-style`).  Simplified+      margin fields.+    + If resource not found, skip it, as in Docx writer (#916).++  * RTF writer:++    + Properly handle characters above the 0000-FFFF range.+      Uses surrogate pairs.  Thanks to Hiromi Ishii for the patch.+    + Fixed regression with RTF table of contents.+    + Only autolink absolute URIs.  This fixes a regression, #830.++  * Markdown writer:++    + Only autolink absolute URIs.  This fixes a regression, #830.+    + Don't wrap attributes in fenced code blocks.+    + Write full metadata in MMD style title blocks.+    + Put multiple authors on separate lines in pandoc titleblock.+      Also, don't wrap long author entries, as new lines get treated+      as new authors.++  * `Text.Pandoc.Templates`:++    + Fixed bug retrieving default template for markdown variants.+    + Templates can now contain "record lookups" in variables;+      for example, `author.institution` will retrieve the `institution`+      field of the `author` variable.+    + More consistent behavior of `$for$`.  When `foo` is not a list,+      `$for(foo)$...$endfor$` should behave like $if(foo)$...$endif$.+      So if `foo` resolves to "", no output should be produced.+      See pandoc-templates#39.++  * Citation processing improvements (now part of pandoc-citeproc):++    + Fixed `endWithPunct` The new version correctly sees a sentence+      ending in '.)' as ending with punctuation.  This fixes a bug which+      led such sentences to receive an extra period at the end: '.).'.+      Thanks to Steve Petersen for reporting.+    + Don't interfere with Notes that aren't citation notes.+      This fixes a bug in which notes not generated from citations were+      being altered (e.g. first letter capitalized) (#898).+    + Only capitalize footnote citations when they have a prefix.+    + Changes in suffix parsing.  A suffix beginning with a digit gets 'p'+      inserted before it before passing to citeproc-hs, so that bare numbers+      are treated as page numbers by default.  A suffix not beginning with+      punctuation has a space added at the beginning (rather than a comma and+      space, as was done before for not-author-in-text citations).+      The result is that `\citep[23]{item1}` in LaTeX will be interpreted+      properly, with '23' treated as a locator of type 'page'.+    + Many improvements to citation rendering, due to fixes in citeproc-hs+      (thanks to Andrea Rossato).+    + Warnings are issued for undefined citations, which are rendered+      as `???`.+    + Fixed hanging behavior when locale files cannot be found.++### Template changes++  * DocBook:  Use DocBook 4.5 doctype.++  * Org: '#+TITLE:' is inserted before the title.+    Previously the writer did this.++  * LaTeX:  Changes to make mathfont work with xelatex.+    We need the mathspec library, not just fontspec, for this.+    We also need to set options for setmathfont (#734).++  * LaTeX: Use `tex-ansi` mapping for `monofont`.+    This ensures that straight quotes appear as straight, rather than+    being treated as curly.  See #889.++  * Made `\includegraphics` more flexible in LaTeX template.+    Now it can be used with options, if needed.  Thanks to Bernhard Weichel.++  * LaTeX/Beamer: Added `classoption` variable.+    This is intended for class options like `oneside`; it may+    be repeated with different options.  (Thanks to Oliver Matthews.)++  * Beamer: Added `fonttheme` variable.  (Thanks to Luis Osa.)++  * LaTeX: Added `biblio-style` variable (#920).++  * DZSlides: title attribute on title section.++  * HTML5: add meta tag to allow scaling by user (Erik Evenson)++### Under-the-hood improvements++  * Markdown reader:Improved strong/emph parsing, using the strategy of+    <https://github.com/jgm/Markdown>.  The new parsing algorithm requires+    no backtracking, and no keeping track of nesting levels.  It will give+    different results in some edge cases, but these should not affect normal+    uses.++  * Added `Text.Pandoc.Compat.Monoid`.+    This allows pandoc to compile with `base` < 4.5, where `Data.Monoid`+    doesn't export `<>`.  Thanks to Dirk Ullirch for the patch.++  * Added `Text.Pandoc.Compat.TagSoupEntity`.+    This allows pandoc to compile with `tagsoup` 0.13.x.+    Thanks to Dirk Ullrich for the patch.++  * Most of `Text.Pandoc.Readers.TeXMath` has been moved to the+    `texmath` module (0.6.4).  (This allows `pandoc-citeproc` to+    handle simple math in bibliography fields.)++  * Added `Text.Pandoc.Writers.Shared` for shared functions used+    only in writers.  `metaToJSON` is used in writers to create a+    JSON object for use in the templates from the pandoc metadata+    and variables.  `getField`, `setField`, and `defField` are+    for working with JSON template contexts.++  * Added `Text.Pandoc.Asciify` utility module.+    This exports functions to create ASCII-only versions of identifiers.++  * `Text.Pandoc.Parsing`++    + Generalized state type on `readWith` (API change).+    + Specialize readWith to `String` input. (API change).+    + In `ParserState`, replace `stateTitle`, `stateAuthors`, `stateDate`+      with `stateMeta` and `stateMeta'`.++  * `Text.Pandoc.UTF8`: use strict bytestrings in reading.  The use of lazy+     bytestrings seemed to cause problems using pandoc on 64-bit Windows+     7/8 (#874).++  * Factored out `registerHeader` from markdown reader, added to+    `Text.Pandoc.Parsing`.++  * Removed `blaze_html_0_5` flag, require `blaze-html` >= 0.5.+    Reason:  < 0.5 does not provide a monoid instance for Attribute,+    which is now needed by the HTML writer (#803).++  * Added `http-conduit` flag, which allows fetching https resources.+    It also brings in a large number of dependencies (`http-conduit`+    and its dependencies), which is why for now it is an optional flag+    (#820).++  * Added CONTRIBUTING.md.++  * Improved INSTALL instructions.++  * `make-windows-installer.bat`: Removed explicit paths for executables.++  * `aeson` is now used instead of `json` for JSON.++  * Set default stack size to 16M.  This is needed for some large+    conversions, esp. if pandoc is compiled with 64-bit ghc.++  * Various small documentation improvements.+    Thanks to achalddave and drothlis for patches.++  * Removed comment that chokes recent versions of CPP (#933).++  * Removed support for GHC version < 7.2, since pandoc-types now+    requires at least GHC 7.2 for GHC generics.+++## pandoc 1.11.1 (2013-03-17)++  * Markdown reader:++    + Fixed regression in which parentheses were lost in link URLs.+      Added tests.  Closes #786.+    + Better handling of unmatched double quotes in `--smart` mode.+      These occur frequently in fiction, since it is customary not to+      close quotes in dialogue if the speaker does not change between+      paragraphs.  The unmatched quotes now get turned into literal+      left double quotes. (No `Quoted` inline is generated, however.)+      Closes #99 (again).++  * HTML writer: Fixed numbering mismatch between TOC and sections.+    `--number-offset` now affects TOC numbering as well+    as section numbering, as it should have all along.  Closes #789.++  * Markdown writer: Reverted 1.11 change that caused citations to be rendered+    as markdown citations, even if `--bibliography` was specified, unless+    `citation` extension is disabled.  Now, formatted citations are always+    printed if `--bibliography` was specified.  If you want to reformat+    markdown keeping pandoc markdown citations intact, don't use+    `--bibliography`.  Note that citations parsed from LaTeX documents will+    be rendered as pandoc markdown citations when `--bibliography` is not+    specified.++  * ODT writer: Fixed regression leading to corrupt ODTs.+    This was due to a change in the `Show` instance for+    `Text.Pandoc.Pretty.Doc`.  Closes #780.++  * Fixed spacing bugs involving code block attributes in+    RST reader and Markdown writer. Closes #763.++  * Windows package:  Various improvements due to Fyodor Sheremetyev.++    + Automatically set installation path (Program Files or Local App Data).+    + Set system PATH environment variable when installing for all users.+    + Pandoc can installed for all users using the following command.+      `msiexec /i pandoc-1.11.msi ALLUSERS=1`.++  * Bumped QuickCheck version bound.++## pandoc 1.11 (2013-03-09)++  * Added `--number-offset` option.  (See README for description.)++  * Added `--default-image-extension` option.  (See README for description.)++  * `--number-sections` behavior change: headers with class `unnumbered`+    will not be numbered.++  * `--version` now reports the default data directory.++  * `Text.Pandoc.Parsing` is no longer exposed. (API change.)++  * `Text.Pandoc.Highlighting` is no longer exposed. (API change.)++  * `Text.Pandoc.Shared`:  Changed type of `Element`.  `Sec` now includes+    a field for `Attr` rather than just `String`.  (API change.)++  * Added `markdown_github` as input format.  This was an accidental+    omission in 1.10.++  * Added `readerDefaultImageExtension` field to `ReaderOptions`.  (API+    change.)++  * Added `writerNumberOffset` field in `WriterOptions`. (API change.)++  * Beamer template:++    + Fixed captions with longtable.  Thanks to Joost Kremers.+    + Provide `\Oldincludegraphics` as in LaTeX template (Benjamin Bannier).++  * LaTeX template:++    + Load microtype after fonts.  Microtype needs to know+      what fonts are being used.  Thanks to dfc for the patch.+    + Set `secnumdepth` to 5 if `--number-sections` specified.+      This yields behavior equivalent to the other writers, numbering+      level 4 and 5 headers too.  Closes #753.++  * HTML reader:++    + Handle `<colgroup>` tag.+    + Preserve all header attributes.++  * LaTeX reader:++    + Parse `\hrule` as `HorizontalRule`.  Closes #746.+    + Parse starred variants of `\section` etc. as headers with+      attribute `unnumbered`.+    + Read optional attributes in `lstlisting` and `Verbatim` environments.+      We convert these to pandoc standard names, e.g. `numberLines`+      for `numbers=left`, `startFrom=100` from `firstnumber=100`.+    + Handle language attribute for lstlistings.+    + Better support for Verbatim and minted environments.  Closes #763.++  * Markdown reader:++    + `-` in an attribute context = `.unnumbered`.  The point of this+      is to provide a way to specify unnumbered headers in non-English+      documents.+    + Fixed bug parsing key/value attributes.  Parsing failed if you+      had an unquoted attribute immediately before the final '}'.+    + Make backslash escape work in attributes.+    + Fix title block parsing.  Now if `mmd_title_blocks` is specified,+      pandoc will parse a MMD title block if it sees one, even if+      `pandoc_title_blocks` is enabled.+    + Refactoring: `litChar` now includes entities, so we don't need+      to use `fromEntities` e.g. on titles.+    + Allow spaces around borders in pipe tables.  Closes #772.+    + Allow all punctuation in angle-bracket autolinks.  Previously+      things like `----` were disallowed, because the uri parser+      treated them as trailing punctuation.  Closes #768.+    + Make `implicit_header_references` work properly when+      headers are given explicit identifiers.+    + Check for tables before line blocks.  Otherwise some pipe+      tables get treated as line blocks.+    + Allow `&` in emails (for entities).+    + Properly handle entities in titles and links.  A markdown link+      `<http://g&ouml;ogle.com>` should be a link to `http://göogle.com`.+      Closes #723.++  * Textile reader:++    + Handle attributes on headers.++  * LaTeX reader:++    + Add `fig:` as title for images with captions.+      This is needed for them to be rendered as figures.  Closes #766.+    + Never emit an empty paragraph.  See #761.+    + Handle `\caption` for images in figures.  Closes #766.+    + Parse `\section*`, etc. as unnumbered sections.++  * HTML writer:++    + Support header attributes.  The attributes go on+      the enclosing `section` or `div` tag if `--section-divs` is specified.+    + Fixed a regression (only now noticed) in html+lhs output.+      Previously the bird tracks were being omitted.++  * LaTeX writer:++    + Omit lists with no items to avoid LaTeX errors.+    + Support line numbering with `--listings`.+      If `numberLines` class is present, we add `numbers=left`;+      if `startFrom` is present, we add `firstnumber=`. (#763)++  * ConTeXt writer:++    + Removed `\placecontent`.  This produced a duplicate toc,+      in conjunction with `\placelist`.+    + Use `\title`, `\subject` etc. for headers with+      `unnumbered` class.++  * Textile writer:++    + Support header attributes.++  * Markdown writer:++    + Use grid tables when needed, and if enabled.  Closes #740.+    + Render citations as pandoc-markdown citations.+      Previously citations were rendered as citeproc-formatted citations+      by default.  Now we render them as pandoc citations, e.g. `[@item1]`,+      unless the `citations` extension is disabled.+      If you still want formatted citations in your markdown output,+      use `pandoc -t markdown-citations`.++  * RST writer:++    + Support `:number-lines:` in code blocks.++  * Docx writer:++    + Better treatment of display math.  Display math inside a+      paragraph is now put in a separate paragraph, so it will render+      properly (centered and without extra blank lines around it).+      Partially addresses #742.+    + Content types and document rels xml files are now created from+      scratch, rather than being taken over from `reference.docx`.+      This fixes problems that arise when you edit the `reference.docx`+      with Word.+    + We also now encode mime types for each individual image rather+      than using defaults.  This should allow us to handle a wider+      range of image types (including PDF).   Closes #414.+    + Changed style names in `reference docx`.+      `FootnoteReference` -> `FootnoteRef`, `Hyperlink` -> `Link`.+      The old names got changed by Word when the `reference.docx` was+      edited.  Closes #414.++  * EPUB writer:++    + Fix section numbering.  Previously the numbering restarted from 1+      in each chapter (with `--number-sections`), though the numbers in+      the table of contents were correct.+    + Headers with "unnumbered" attribute are not numbered.  (Nor do they+      cause an increment in running numbering.) Section numbers now work+      properly, even when there is material before the first numbered section.+    + Include HTML TOC, even in epub2.  The TOC is included in `<spine>`,+      but `linear` is set to `no` unless the `--toc` option is specified.+      Include `<guide>` element in OPF.  This should allow the TOC to+      be useable in Kindles when converted with kindlegen. Closes #773.++  * `Text.Pandoc.Parsing`: Optimized `oneOfStringsCI`.+    This dramatically reduces the speed penalty that comes from enabling the+    `autolink_bare_uris` extension.  The penalty is still substantial (in one+    test, from 0.33s to 0.44s), but nowhere near what it used to be.+    The RST reader is also much faster now, as it autodetects URIs.++  * `Text.Pandoc.Shared`:  `hierarchicalize` will not number section+    with class "unnumbered".  Unnumbered sections get `[]` for their+    section number.++  * `Text.Pandoc.Pretty`:++    + Fixed `chomp` so it works inside `Prefixed` elements.+    + Changed `Show` instance so it is better for debugging.++  * `Text.Pandoc.ImageSize`:  Added `Pdf` to `ImageType`.++  * `Text.Pandoc.UTF8`:  Strip off BOM if present.  Closes #743.++  * Windows installer improvements:++    + The installer is now signed with a certificate (thanks to+      Fyodor Sheremetyev).+    + WiX is used instead of InnoSetup.  The installer is now a+      standard msi file.+    + The version number is now auto-detected, and need not be+      updated separately.++  * OSX installer improvements:++    + The package and pandoc executable are now signed with a+      certificate (thanks to Fyodor Sheremetyev).+    + RTF version of license is used.+    + Use full path for sysctl in `InstallationCheck` script (jonahbull).+      Closes #580.++  * Converted COPYING to markdown.++  * pandoc.cabal:  Require latest versions of highlighting-kate,+    texmath, citeproc-hs, zip-archive.++## pandoc 1.10.1 (2013-01-23)++  * Markdown reader:  various optimizations, leading to a+    significant performance boost.++  * RST reader:  Allow anonymous form of inline links:+    `` `hello <url>`__ `` Closes #724.++  * Mediawiki reader: Don't require newlines after tables.+    Thanks to jrunningen for the patch. Closes #733.++  * Fixed LaTeX macro parsing.  Now LaTeX macro definitions are preserved+    when output is LaTeX, and applied when it is another format.+    Partially addresses #730.++  * Markdown and RST readers:  Added parser to `block` that skips blank+    lines.  This fixes a subtle regression involving grid tables with+    empty cells.  Also added test for grid table with empty cells.+    Closes #732.++  * RST writer:  Use `.. code:: language` for code blocks with language.+    Closes #721.++  * DocBook writer:  Fixed output for hard line breaks, adding a newline+    between `<literallayout>` tags.++  * Markdown writer:  Use an autolink when link text matches url.+    Previously we also checked for a null title, but this+    test fails for links produced by citeproc-hs in bibliographies.+    So, if the link has a title, it will be lost on conversion+    to an autolink, but that seems okay.++  * Markdown writer:  Set title, author, date variables as before.+    These are no longer used in the default template, since we use+    titleblock, but we set them anyway for those who use custom templates.++  * LaTeX writer:  Avoid extra space at start/end of table cell.+    Thanks to Nick Bart for the suggestion of using @{}.++  * `Text.Pandoc.Parsing`:++    + More efficient version of `anyLine`.+    + Type of `macro` has changed; the parser now returns `Blocks`+      instead of `Block`.++  * Relaxed old-time version bound, allowing 1.0.*.++  * Removed obsolete `hsmarkdown` script.  Those who need `hsmarkdown`+    should create a symlink as described in the README.++## pandoc 1.10.0.5 (2013-01-23)++  * Markdown reader: Try `lhsCodeBlock` before `rawTeXBlock`.  Otherwise+    `\begin{code}...\end{code}` isn't handled properly in markdown+lhs.+    Thanks to Daniel Miot for noticing the bug and suggesting the fix.++  * Markdown reader: Fixed bug with headerless grid tables.+    The 1.10 code assumed that each table header cell contains exactly one+    block. That failed for headerless tables (0) and also for tables with+    multiple blocks in a header cell.  The code is fixed and tests provided.+    Thanks to Andrew Lee for pointing out the bug.++  * Markdown reader: Fixed regressions in fenced code blocks. Closes #722.++    + Tilde code fences can again take a bare language string+      (`~~~ haskell`), not just curly-bracketed attributes+      (`~~~ {.haskell}`).+    + Backtick code blocks can take the curly-bracketed attributes.+    + Backtick code blocks don't *require* a language.+    + Consolidated code for the two kinds of fenced code blocks.++  * LaTeX template: Use `\urlstyle{same}` to avoid monospace URLs.++  * Markdown writer: Use proportional font for email autolinks with+    obfuscation.  Closes #714.++  * Corrected name of `blank_before_blockquote` in README.  Closes #718.++  * `Text.Pandoc.Shared`: Fixed bug in `uri` parser.+    The bug prevented an autolink at the end of a string (e.g.+    at the end of a line block line) from counting as a link.  Closes #711.++  * Use the `hsb2hs` preprocessor instead of TH for embed_data_files.+    This should work on Windows, unlike the TH solution with+    file-embed.++  * Eliminated use of TH in test suite.++  * Added `Text.Pandoc.Data` (non-exported) to hold the association+    list of embedded data files, if the `embed_data_files` flag is selected.+    This isolates the code that needs special treatment with file-embed or+    `hsb2hs`.++  * Changes to `make-windows-installer.bat`.++    + Exit batch file if any of the cabal-dev installs fail.+    + There's no longer any need to reinstall `highlighting-kate`.+    + Don't start with a `cabal update`; leave that to the user.+    + Force reinstall of pandoc.++  * Fixed EPUB writer so it builds with blaze-html 0.4.x. Thanks to+    Jens Petersen.++## pandoc 1.10.0.4 (2013-01-20)++  * Fixed bug with escaped % in LaTeX reader. Closes #710.++## pandoc 1.10.0.3 (2013-01-20)++  * Added further missing fb2 tests to cabal file.++## pandoc 1.10.0.2 (2013-01-20)++  * Added fb2 tests to cabal file's extra-source-files.++## pandoc 1.10.0.1 (2013-01-20)++  * Bump version bounds on test-framework packages.++## pandoc 1.10 (2013-01-19)++### New features++  * New input formats:  `mediawiki` (MediaWiki markup).++  * New output formats:  `epub3` (EPUB v3 with MathML),+    `fb2` (FictionBook2 ebooks).++  * New `--toc-depth` option, specifying how many levels of+    headers to include in a table of contents.++  * New `--epub-chapter-level` option, specifying the header+    level at which to divide EPUBs into separate files.+    Note that this normally affects only performance, not the+    visual presentation of the EPUB in a reader.++  * Removed the `--strict` option.  Instead of using `--strict`,+    one can now use the format name `markdown_strict` for either input+    or output.  This gives more fine-grained control that `--strict`+    did, allowing one to convert from pandoc's markdown to strict+    markdown or vice versa.++  * It is now possible to enable or disable specific syntax+    extensions by appending them (with `+` or `-`) to the writer+    or reader name.  For example,++        pandoc -f markdown-footnotes+hard_line_breaks++    disables footnotes and enables treating newlines as hard+    line breaks.  The literate Haskell extensions are now implemented+    this way as well, using either `+lhs` or `+literate_haskell`.+    For a list of extension names, see the README under+    "Pandoc's Markdown."++  * The following aliases have been introduced for specific+    combinations of markdown extensions:  `markdown_phpextra`,+    `markdown_github`, `markdown_mmd`, `markdown_strict`.  These aliases+    work just like regular reader and writer names, and can be modified+    with extension modifiers as described above. (Note that conversion+    from one markdown dialect to another does not work perfectly,+    because there are differences in markdown parsers besides+    just the extensions, and because pandoc's internal document model is+    not rich enough to capture all of the extensions.)++  * New `--html-q-tags` option.  The previous default was to use `<q>`+    tags for smart quotes in HTML5.  But `<q>` tags are also valid HTML4.+    Moreover, they are not a robust way of typesetting quotes, since+    some user agents don't support them, and some CSS resets (e.g.+    bootstrap) prevent pandoc's quotes CSS from working properly.+    We now just insert literal quote characters by default in both+    `html` and `html5` output, but this option is provided for+    those who still want `<q>` tags.++  * The markdown reader now prints warnings (to stderr) about+    duplicate link and note references.  Closes #375.++  * Markdown syntax extensions:++    + Added pipe tables.  Thanks to François Gannaz for the initial patch.+      These conform to PHP Markdown Extra's pipe table syntax. A subset+      of org-mode table syntax is also supported, which means that you can+      use org-mode's nice table editor to create tables.++    + Added support for RST-style line blocks. These are+      useful for verse and addresses.++    + Attributes can now be specified for headers, using the same+      syntax as in code blocks.  (However, currently only the+      identifier has any effect in most writers.)  For example,++            # My header {#foo}++            See [the header above](#foo).++    + Pandoc will now act as if link references have been defined+      for all headers without explicit identifiers.+      So, you can do this:++            # My header++            Link to [My header].+            Another link to [it][My header].++      Closes #691.++  * LaTeX reader:++    + Command macros now work everywhere, including non-math.+      Environment macros still not supported.+    + `\input` now works, as well as `\include`.  TEXINPUTS is used.+      Pandoc looks recursively into included files for more included files.++### Behavior changes++  * The Markdown reader no longer puts the text of autolinks in a+    `Code` inline.  This means that autolinks will no longer appear+    in a monospace font.++  * The character `/` can now appear in markdown citation keys.++  * HTML blocks in strict_markdown are no longer required to begin+    at the left margin.  Technically this is required, according to+    the markdown syntax document, but `Markdown.pl` and other markdown+    processors are more liberal.++  * The `-V` option has been changed so that if there are duplicate+    variables, those specified later on the command line take precedence.++  * Tight lists now work in LaTeX and ConTeXt output.++  * The LaTeX writer no longer relien on the `enumerate` package.+    Instead, it uses standard LaTeX commands to change the list numbering+    style.++  * The LaTeX writer now uses `longtable` instead of `ctable`. This allows+    tables to be split over page boundaries.++  * The RST writer now uses a line block to render paragraphs containing+    linebreaks (which previously weren't supported at all).++  * The markdown writer now applies the `--id-prefix` to footnote IDs.+    Closes #614.++  * The plain writer no longer uses backslash-escaped line breaks+    (which are not very "plain").++  * `Text.Pandoc.UTF8`: Better error message for invalid UTF8.+    Read bytestring and use `Text`'s decodeUtf8 instead of using+    `System.IO.hGetContents`.  This way you get a message saying+    "invalid UTF-8 stream" instead of "invalid byte sequence."+    You are also told which byte caused the problem.++  * Docx, ODT, and EPUB writers now download images specified by a URL+    instead of skipping them or raising an error.++  * EPUB writer:++    + The default CSS now left-aligns headers by default, instead of+      centering.  This is more consistent with the rest of the writers.+    + A proper multi-level table of contents is now used in `toc.ncx`.+      There is no longer a subsidiary table of contents at the beginning+      of each chapter.+    + Code highlighting now works by default.+    + Section divs are used by default for better semantic markup.+    + The title is used instead of "Title Page" in the table of contents.+      Otherwise we have a hard-coded English string, which looks+      strange in ebooks written in other languages.  Closes #572.++  * HTML writer:++    + Put mathjax in span with class "math".  Closes #562.+    + Put citations in a span with class "citation." In HTML5, also include+      a `data-cite` attribute with a space-separated list of citation+      keys.++  * `Text.Pandoc.UTF8`:  use universalNewlineMode in reading.+    This treats both `\r\n` and `\n` as `\n` on input, no matter+    what platform we're running on.++  * Citation processing is now done in the Markdown and LaTeX+    readers, not in `pandoc.hs`.  This makes it easier for library users+    to use citations.++### Template changes++  * HTML: Added css to template to preserve spaces in `<code>` tags.+    Thanks to Dirk Laurie.++  * Beamer:  Remove English-centric strings in section pages.+    Section pages used to have "Section" and a number as well as the+    section title. Now they just have the title.  Similarly for part+    and subsection.  Closes #566.++  * LaTeX, ConTeXt: Added papersize variable.++  * LaTeX, Beamer templates: Use longtable instead of ctable.++  * LaTeX, Beamer templates: Don't require 'float' package for tables.+    We don't actually seem to use the '[H]' option.++  * Markdown, plain: Fixed titleblock so it is just a single string.+    Previously separate title, author, and date variables were used,+    but this didn't allow different kinds of title blocks.++  * EPUB:++    + Rationalized templates.  Previously there were three different+      templates involved in epub production. There is now just one+      template, `default.epub` or `default.epub3`. It can now be+      overridden using `--template`, just like other templates.+      The titlepage is now folded into the default template.+      A `titlepage` variable selects it.+    + UTF-8, lang tag, meta tags, title element.++  * Added scale-to-width feature to beamer template++### API changes++  * `Text.Pandoc.Definition`: Added `Attr` field to `Header`.+    Previously header identifiers were autogenerated by the writers.+    Now they are added in the readers (either automatically or explicitly).++  * `Text.Pandoc.Builder`:++    + `Inlines` and `Blocks` are now synonyms for `Many Inline` and+      `Many Block`.  `Many` is a newtype wrapper around `Seq`, with+      custom Monoid instances for `Many Inline` and `Many Block.  This+      allows `Many` to be made an instance of `Foldable` and `Traversable`.+    + The old `Listable` class has been removed.+    + The module now exports `isNull`, `toList`, `fromList`.+    + The old `Read` and `Show` instances have been removed; derived+      instances are now used.+    + Added `headerWith`.++  * The readers now take a `ReaderOptions` rather than a `ParserState`+    as a parameter.  Indeed, not all parsers use the `ParserState` type;+    some have a custom state.  The motivation for this change was to separate+    user-specifiable options from the accounting functions of parser state.++  * New module `Text.Pandoc.Options`.  This includes the `WriterOptions`+    formerly in `Text.Pandoc.Shared`, and its associated+    data types.  It also includes a new type `ReaderOptions`, which+    contains many options formerly in `ParserState`, and its associated+    data types:++    + `ParserState.stateParseRaw` -> `ReaderOptions.readerParseRaw`.+    + `ParserState.stateColumns` -> `ReaderOptions.readerColumns`.+    + `ParserState.stateTabStop` -> `ReaderOptions.readerTabStop`.+    + `ParserState.stateOldDashes` -> `ReaderOptions.readerOldDashes`.+    + `ParserState.stateLiterateHaskell` -> `ReaderOptions.readerLiterateHaskell`.+    + `ParserState.stateCitations` -> `ReaderOptions.readerReferences`.+    + `ParserState.stateApplyMacros` -> `ReaderOptions.readerApplyMacros`.+    + `ParserState.stateIndentedCodeClasses` ->+      `ReaderOptions.readerIndentedCodeClasses`.+    + Added `ReaderOptions.readerCitationStyle`.++  * `WriterOptions` now includes `writerEpubVersion`, `writerEpubChapterLevel`,+    `writerEpubStylesheet`, `writerEpubFonts`, `writerReferenceODT`,+    `writerReferenceDocx`, and `writerTOCDepth`.  `writerEPUBMetadata` has+    been renamed `writerEpubMetadata` for consistency.++  * Changed signatures of `writeODT`, `writeDocx`, `writeEPUB`, since they no+    longer stylesheet, fonts, reference files as separate parameters.++  * Removed `writerLiterateHaskell` from `WriterOptions`, and+    `readerLiterateHaskell` from `ReaderOptions`.  LHS is now handled+    by an extension (`Ext_literate_haskell`).++  * Removed deprecated `writerXeTeX`.++  * Removed `writerStrict` from `WriterOptions`.  Added `writerExtensions`.+    Strict is now handled through extensions.++  * `Text.Pandoc.Options` exports `pandocExtensions`, `strictExtensions`,+    `phpMarkdownExtraExtensions`, `githubMarkdownExtensions`,+    and `multimarkdownExtensions`, as well as the `Extensions` type.++  * New `Text.Pandoc.Readers.MediaWiki` module, exporting+    `readMediaWiki`.++  * New `Text.Pandoc.Writers.FB2` module, exporting `writeFB2`+    (thanks to Sergey Astanin).++  * `Text.Pandoc`:++    + Added `getReader`, `getWriter` to `Text.Pandoc`.+    + `writers` is now an association list `(String, Writer)`.+      A `Writer` can be a `PureStringWriter`, an `IOStringWriter`, or+      an `IOByteStringWriter`.  ALL writers are now in the 'writers'+      list, including the binary writers and FB2 writer.  This allows+      code in `pandoc.hs` to be simplified.+    + Changed type of `readers`, so all readers are in IO.+      Users who want pure readers can still get them form the reader+      modules; this just affects the function `getReader` that looks up+      a reader based on the format name.  The point of this change is to+      make it possible to print warnings from the parser.++  * `Text.Pandoc.Parsing`:++    + `Text.Parsec` now exports all Parsec functions used in pandoc code.+      No other module directly imports Parsec.  This will make it easier+      to change the parsing backend in the future, if we want to.+    + `Text.Parsec` is used instead of `Text.ParserCombinators.Parsec`.+    + Export the type synonym `Parser`.+    + Export `widthsFromIndices`, `NoteTable'`, `KeyTable'`, `Key'`, `toKey'`,+     `withQuoteContext`, `singleQuoteStart`, `singleQuoteEnd`,+     `doubleQuoteStart`, `doubleQuoteEnd`, `ellipses`, `apostrophe`,+     `dash`, `nested`, `F(..)`, `askF`, `asksF`, `runF`, `lineBlockLines`.+    + `ParserState` is no longer an instance of `Show`.+    + Added `stateSubstitutions` and `stateWarnings` to `ParserState`.+    + Generalized type of `withQuoteContext`.+    + Added `guardEnabled`, `guardDisabled`, `getOption`.+    + Removed `failIfStrict`.+    + `lookupKeySrc` and `fromKey` are no longer exported.++  * `Data.Default` instances are now provided for `ReaderOptions`,+    `WriterOptions`, and `ParserState`.  `Text.Pandoc` re-exports `def`.+    Now you can use `def` (which is re-exported by `Text.Pandoc`) instead+    of `defaultWriterOptions` (which is still defined).  Closes #546.++  * `Text.Pandoc.Shared`:++    + Added `safeRead`.+    + Renamed `removedLeadingTrailingSpace` to `trim`,+      `removeLeadingSpace` to `triml`, and `removeTrailingSpace` to `trimr`.+    + Count `\r` as space in `trim` functions.+    + Moved `renderTags'` from HTML reader and `Text.Pandoc.SelfContained`+      to `Shared`.+    + Removed `failUnlessLHS`.+    + Export `compactify'`, formerly in Markdown reader.+    + Export `isTightList`.+    + Do not export `findDataFile`.+    + `readDataFile` now returns a strict ByteString.+    + Export `readDataFileUTF8` which returns a String, like the+      old `readDataFile`.+    + Export `fetchItem` and `openURL`.++  * `Text.Pandoc.ImageSize`: Use strict, not lazy bytestrings.+    Removed `readImageSize`.++  * `Text.Pandoc.UTF8`: Export `encodePath`, `decodePath`,+     `decodeArg`, `toString`, `fromString`, `toStringLazy`,+     `fromStringLazy`.++  * `Text.Pandoc.UTF8` is now an exposed module.++  * `Text.Pandoc.Biblio`:++    + csl parameter now a `String` rather than a `FilePath`.+    + Changed type of `processBiblio`.  It is no longer in the IO monad.+      It now takes a `Maybe Style` argument rather than parameters for CSL+      and abbrev filenames.  (`pandoc.hs` now calls the functions to parse+      the style file and add abbreviations.)++  * Markdown reader now exports `readMarkdownWithWarnings`.++  * `Text.Pandoc.RTF` now exports `writeRTFWithEmbeddedImages` instead of+    `rtfEmbedImage`.++### Bug fixes++  * Make `--ascii` work properly with `--self-contained`.  Closes #568.++  * Markdown reader:++    + Fixed link parser to avoid exponential slowdowns.  Closes #620.+      Previously the parser would hang on input like this:++            [[[[[[[[[[[[[[[[[[hi++      We fixed this by making the link parser parser characters+      between balanced brackets (skipping brackets in inline code spans),+      then parsing the result as an inline list.  One change is that++            [hi *there]* bud](/url)++      is now no longer parsed as a link.  But in this respect pandoc behaved+      differently from most other implementations anyway, so that seems okay.++    + Look for raw html/latex blocks before tables.+      Otherwise the following gets parsed as a table:++            \begin{code}+            --------------+            -- My comment.+            \end{code}++      Closes #578.++  * RST reader:++    + Added support for `:target:` on `.. image::` blocks+      and substitutions.+    + Field list fixes:++        - Fixed field lists items with body beginning after a new line+          (Denis Laxalde).+        - Allow any char but ':' in names of field lists in RST reader+          (Denis Laxalde).+        - Don't allow line breaks in field names.+        - Require whitespace after field list field names.+        - Don't create empty definition list for metadata field lists.+          Previously a field list consisting only of metadata fields (author,+          title, date) would be parsed as an empty DefinitionList, which is+          not legal in LaTeX and not needed in any format.++    + Don't recognize inline-markup starts inside words.+      For example, `2*2 = 4*1` should not contain an emphasized+      section.  Added test case for "Literal symbols".  Closes #569.+    + Allow dashes as separator in simple tables.  Closes #555.+    + Added support for `container`, `compound`, `epigraph`,+      `rubric`, `highlights`, `pull-quote`.+    + Added support for `.. code::`.+    + Made directive labels case-insensitive.+    + Removed requirement that directives begin at left margin.+      This was (correctly) not in earlier releases; docutils doesn't+      make the requirement.+    + Added support for `replace::` and `unicode::` substitutions.+    + Ignore unknown interpreted roles.+    + Renamed image parser to `subst`, since it now handles all+      substitution references.++  * Textile reader:++    + Allow newlines before pipes in table.  Closes #654.+    + Fixed bug with list items containing line breaks.+      Now pandoc correctly handles hard line breaks inside list items.+      Previously they broke list parsing.+    + Implemented comment blocks.+    + Fixed bug affected words ending in hyphen.+    + Properly handle links with surrounding brackets.+      Square brackets need to be used when the link isn't surrounded by+      spaces or punctuation, or when the URL ending may be ambiguous.+      Closes #564.+    + Removed nullBlock.  Better to know about parsing problems than+      to skip stuff when we get stuck.+    + Allow ID attributes on headers.+    + Textile reader:  Avoid parsing dashes as strikeout.+      Previously the input++            text--+            text--+            text--+            text--++      would be parsed with strikeouts rather than dashes. This fixes+      the problem by requiring that a strikeout delimiting - not be+      followed by a -.  Closes #631.+    + Expanded list of `stringBreakers`.+      This fixes a bug on input like "(_hello_)" which should+      be a parenthesized emphasized "hello".+      The new list is taken from the PHP source of textile 2.4.+    + Fixed autolinks.  Previously the textile reader and writer+      incorrectly implented RST-style autolinks for URLs and email+      addresses.  This has been fixed.  Now an autolink is done this way:+      `"$":http://myurl.com`.+    + Fixed footnotes bug in textile.  This affected notes occurring+      before punctuation, e.g. `foo[1].`.  Closes #518.++  * LaTeX reader:++    + Better handling of citation commands.+    + Better handling of `\noindent`.+    + Added a 'try' in rawLaTeXBlock, so we can handle `\begin` without `{`.+      Closes #622.+    + Made `rawLaTeXInline` try to parse block commands as well.  This+      is usually what we want, given how `rawLaTeXInline` is used in+      the markdown and textile readers.  If a block-level LaTeX command+      is used in the middle of a paragraph (e.g. `\subtitle` inside a title),+      we can treat it as raw inline LaTeX.+    + Handle `\slash` command.  Closes #605.+    + Basic `\enquote` support.+    + Fixed parsing of paragraphs beginning with a group.  Closes #606.+    + Use curly quotes for bare straight quotes.+    + Support obeylines environment.  Closes #604.+    + Guard against "begin", "end" in inlineCommand and+      blockCommand.+    + Better error messages for environments.  Now it should tell you that+      it was looking for \end{env}, instead of giving "unknown parse error."++  * HTML reader:++    + Added HTML 5 tags to list of block-level tags.+    + HTML reader: Fixed bug in `htmlBalanced`, which+      caused hangs in parsing certain markdown input using+      strict mode.+    + Parse `<q>` as `Quoted DoubleQuote`.+    + Handle nested `<q>` tags properly.+    + Modified `htmlTag` for fewer false positives.+      A tag must start with `<` followed by `!`,`?`, `/`, or a letter.+      This makes it more useful in the wikimedia and markdown parsers.++  * DocBook reader: Support title in "figure" element.  Closes #650.++  * MediaWiki writer:++    + Remove newline after `<br/>` in translation of `LineBreak`+      There's no particular need for a newline (other than making the+      generated MediaWiki source look nice to a human), and in fact+      sometimes it is incorrect: in particular, inside an enumeration, list+      items cannot have embedded newline characters. (Brent Yorgey)+    + Use `<code>` not `<tt>` for Code.++  * Man writer: Escape `-` as `\-`.+    Unescaped `-`'s become hyphens, while `\-`'s are left as ascii minus+    signs.  That is preferable for use with command-line options.  See+    <http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html>.  Thanks+    to Andrea Bolognani for bringing the issue to our attention.++  * RST writer:++    + Improved line block output. Use nonbreaking spaces for+      initial indent (otherwise lost in HTML and LaTeX).+      Allow multiple paragraphs in a single line block.+      Allow soft breaks w continuations in line blocks.+    + Properly handle images with no alt text.  Closes #678.+    + Fixed bug with links with duplicate text.  We now (a) use anonymous+      links for links with inline URLs, and (b) use an inline link instead+      of a reference link if the reference link would require a label that+      has already been used for a different link.  Closes #511.+    + Fixed hyperlinked images. Closes #611. Use `:target:`+      field when you have a simple linked image.+    + Don't add `:align: center` to figures.++  * Texinfo writer:  Fixed internal cross-references.+    Now we insert anchors after each header, and use `@ref` instead of `@uref`+    for links.  Commas are now escaped as `@comma{}` only when needed;+    previously all commas were escaped.  (This change is needed, in part,+    because `@ref` commands must be followed by a real comma or period.) Also+    insert a blank line in from of `@verbatim` environments.++  * DocBook writer:++    + Made --id-prefix work in DocBook as well as HTML.+      Closes #607.+    + Don't include empty captions in figures.  Closes #581.++  * LaTeX writer:++    + Use `\hspace*` for nonbreaking space after line break,+      since `~` spaces after a line break are just ignored.+      Closes #687.+    + Don't escape `_` in URLs or hyperref identifiers.+    + Properly escape strings inside `\url{}`.  Closes #576.+    + Use `[fragile]` only for slides containing code rendered+      using listings. Closes #649.+    + Escape `|` as `\vert` in LaTeX math.  This avoids a clash with+      highlighting-kate's macros, which redefine `|` as a short verbatim+      delimiter.  Thanks to Björn Peemöller for raising this issue.+    + Use minipage rather than parbox for block containers in tables.+      This allows verbatim code to be included in grid tables.+      Closes #663.+    + Prevent paragraphs containing only linebreaks or spaces.++  * HTML writer:++    + Included `highlighting-css` for code spans, too.+      Previously it was only included if used in a code block.  Closes #653.+    + Improved line breaks with `<dd>` tags.  We now put a newline between+      `</dd>` and `<dd>` when there are multiple definitions.+    + Changed mathjax cdn url so it doesn't use https.  (This caused+      problems when used with `--self-contained`.) See #609.++  * EPUB writer:++    + `--number-sections` now works properly.+    + Don't strip meta and link elements in epub metadata.+      Patch from aberrancy. Closes #589.+    + Fixed a couple validation bugs.+    + Use ch001, ch002, etc. for chapter filenames.  This improves sorting+      of chapters in some readers, which apparently sort ch2 after ch10.+      Closes #610.++  * ODT writer: properly set title property (Arlo O'Keeffe).++  * Docx writer:++    + Fixed bug with nested lists.  Previously a list like++            1. one+                - a+                - b+            2. two++      would come out with a bullet instead of "2."+      Thanks to Russell Allen for reporting the bug.+    + Use `w:cr` in `w:r` instead of `w:br` for linebreaks.+      This seems to fix a problem viewing pandoc-generated+      docx files in LibreOffice.+    + Use integer ids for bookmarks.  Closes #626.+    + Added nsid to abstractNum elements.  This helps when merging+      word documents with numbered or bulleted lists.  Closes #627.+    + Use separate footnotes.xml for notes.+      This seems to help LibreOffice convert the file, even though+      it was valid docx before.  Closes #637.+    + Use rIdNN identifiers for r:embed in images.+    + Avoid reading image files again when we've already processed them.+    + Fixed typo in `referenc.docx` that prevented image captions from+      working. Thanks to Huashan Chen.++  * `Text.Pandoc.Parsing`:++    + Fixed bug in `withRaw`, which didn't correctly handle the case+      where nothing is parsed.+    + Made `emailAddress` parser more correct.  Now it is based on RFC 822,+      though it still doesn't implement quoted strings in email addresses.+    + Revised URI parser.  It now allows many more schemes, allows+      uppercase URIs, and better handles trailing punctuation and+      trailing slashes in bare URIs.  Added many tests.+    + Simplified and improved singleQuoteStart.  This makes `'s'`, `'l'`,+      etc. parse properly.  Formerly we had some English-centric heuristics,+      but they are no longer needed. Closes #698.++  * `Text.Pandoc.Pretty`:  Added wide punctuation range to `charWidth`.+    This fixes bug with Chinese commas in markdown and reST tables, and+    a bug that caused combining characters to be dropped.++  * `Text.Pandoc.MIME`: Added MIME types for .wof and .eot.  Closes #640.++  * `Text.Pandoc.Biblio`:++    + Run `mvPunc` and `deNote` on metadata too.+      This fixed a bug with notes on titles using footnote styles.+    + Fixed bug in fetching CSL files from CSL data directory.++  * `pandoc.hs`:  Give correct value to `writerSourceDirectory` when a URL+    is provided.  It should be the URL up to the path.++  * Fixed/simplified diff output for tests.+    Biblio: Make sure mvPunc and deNote run on metadata too.+    This fixed a bug with notes on titles using footnote styles.++### Under the hood improvements++  * We no longer depend on `utf8-string`.  Instead we use functions+    defined in `Text.Pandoc.UTF8` that use `Data.Text`'s conversions.++  * Use `safeRead` instead of using `reads` directly (various modules).++  * "Implicit figures" (images alone in a paragraph) are now handled+    differently.  The markdown reader gives their titles the prefix `fig:`; the+    writers look for this before treating the image as a figure.  Though this+    is a bit of a hack, it has two advantages: (i) implicit figures can be+    limited to the markdown reader, and (ii) they can be deactivated by turning+    off the `implicit_figures` extension.++  * `catch` from `Control.Exception` is now used instead of the+    old Preface `catch`.++  * `Text.Pandoc.Shared`:  Improved algorithm for `normalizeSpaces`+    and `oneOfStrings` (which is now non-backtracking).++  * `Text.Pandoc.Biblio`: Remove workaround for `toCapital`.+    Now citeproc-hs is fixed upstream, so this is no longer needed.+    Closes #531.++  * Textile reader: Improved speed of `hyphenedWords`.+    This speeds up the textile  reader by about a factor of 4.++  * Use `Text.Pandoc.Builder` in RST reader, for more flexibility,+    better performance, and automatic normalization.++  * Major rewrite of markdown reader:++    + Use `Text.Pandoc.Builder` instead of lists.  This also+      means that everything is normalized automatically.+    + Move to a one-pass parsing strategy, returning values in the reader+      monad, which are then run (at the end of parsing) against the final+      parser state.++  * In HTML writer, we now use `toHtml` instead of pre-escaping.+    We work around the problem that blaze-html unnecessarily escapes `'`+    by pre-escaping just the `'` characters, instead of the whole string.+    If blaze-html later stops escaping `'` characters, we can simplify+    `strToHtml` to `toHtml`.  Closes #629.++  * Moved code for embedding images in RTFs from `pandoc.hs` to the+    RTF writer (which now exports `writeRTFWithEmbeddedImages`).++  * Moved citation processing from `pandoc.hs` into the readers.+    This makes things more convenient for library users.++  * The man pages are now built by an executable `make-pandoc-man-pages`,+    which has its own stanza in the cabal file so that dependencies can be+    handled by Cabal. Special treatment in `Setup.hs` ensures that this+    executable never gets installed; it is only used to create the man pages.++  * The cabal file has been modified so that the pandoc library is used+    in building the pandoc executable.  (This required moving `pandoc.hs`+    from `src` to `.`.)  This cuts compile time in half.++  * The `executable` and `library` flags have been removed.++  * `-threaded` has been removed from ghc-options.++  * Version bounds of dependencies have been raised, and the+    `blaze_html_0_5` flag now defaults to True.  Pandoc now compiles on+    GHC 7.6.++  * We now require base >= 4.2.++  * Integrated the benchmark program into cabal.  One can now do:++        cabal configure --enable-benchmarks && cabal build+        cabal bench --benchmark-option='markdown' --benchmark-option='-s 20'++    The benchmark now uses README + testsuite, so benchmark results+    from older versions aren't comparable.++  * Integrated test suite with cabal.+    To run tests, configure with `--enable-tests`, then `cabal test`.+    You can specify particular tests using `--test-options='-t markdown'`.+    No output is shown unless tests fail.  The Haskell test modules+    have been moved from `src/` to `tests/`.++  * Moved all data files and templates to the `data/` subdirectory.++  * Added an `embed_data_files` cabal flag.  This causes all+    data files to be embedded in the binary, so that the binary+    is self-sufficient and can be relocated anywhere, copied on+    a USB key, etc.  The Windows installer now uses this.+    (Since we no longer have the option to build the executable+    without the library, this is the only way to get a relocatable+    binary on Windows.)++  * Removed pcre3.dll from windows package.+    It isn't needed unless highlighting-kate is compiled with the+    `pcre-light` flag. By default, regex-prce-builtin is used.+++## pandoc 1.9.4.5 (2012-10-21)++  * Raised version bounds on network, base64-bytestring, json,+    and template-haskell.++## pandoc 1.9.4.4 (2012-10-20)++  * Removed `tests` flag and made test suite into a proper cabal+    test suite, which can now be enabled using `--enable-tests`+    and run with `cabal test`.++  * Moved man page creation out of `Setup.hs` and into an+    executable built by Cabal, but never installed.  This+    allows dependencies to be specified, and solves a problem+    with 1.9.4.3, which could only be installed if `data-default`+    had already been installed.++  * Updated `lhs-latex.tex` test for latest highlighting-kate+    representation of backticks.++## pandoc 1.9.4.3 (2012-10-20)++  * Removed `-threaded` from default compile flags.++  * Modified modules to compile with GHC 7.6 and latest version of time+    package.++## pandoc 1.9.4.2 (2012-06-29)++  * Don't encode/decode file paths if base >= 4.4.+    Prior to base 4.4, filepaths and command line arguments were treated+    as unencoded lists of bytes, not unicode strings, so we had to work+    around that by encoding and decoding them. This commit adds CPP+    checks for the base version that intelligibly enable encoding/decoding+    when needed. Fixes a bug with multilingual filenames when pandoc was+    compiled with ghc 7.4 (#540).++  * Don't generate an empty H1 after hrule slide breaks.+    We now use a slide-level header with contents `[Str "\0"]` to mark+    an hrule break.  This avoids creation of an empty H1 in these+    contexts.  Closes #484.++  * Docbook reader: Added support for "bold" emphasis.  Thanks to mb21.++  * In make_osx_package.sh, ensure citeproc-hs is built with the+    embed_data_files flag.++  * MediaWiki writer: Avoid extra blank lines after sublists (Gavin Beatty).++  * ConTeXt writer: Don't escape `&`, `^`, `<`, `>`, `_`,+    simplified escapes for `}` and `{` to `\{` and `\}` (Aditya Mahajan).++  * Fixed handling of absolute URLs in CSS imports with `--self-contained`.+    Closes #535.++  * Added webm to mime types. Closes #543.++  * Added some missing exports and tests to the cabal file+    (Alexander V Vershilov).++  * Compile with `-rtsopts` and `-threaded` by default.++## pandoc 1.9.4.1 (2012-06-08)++  * Markdown reader: Added `cf.` and `cp.` to list of likely abbreviations.++  * LaTeX template: Added `linkcolor`, `urlcolor` and `links-as-notes`+    variables.  Make TOC links black.++  * LaTeX template improvements.++    + Don't print date unless one is given explicitly in the document.+    + Simplified templates.+    + Use fontenc [T1] by default, and lmodern.+    + Use microtype if available.++  * Biblio:++    + Add comma to beginning of bare suffix, e.g. `@item1 [50]`.+      Motivation: `@item1 [50]` should be as close as possible to+      `[@item1, 50]`.+    + Added workaround for a bug in citeproc-hs 0.3.4 that causes footnotes+      beginning with a citation to be empty.  Closes #531.++  * Fixed documentation on mixed lists.  Closes #533.++## pandoc 1.9.4 (2012-06-03)++  * Simplified `Text.Pandoc.Biblio` and fixed bugs with citations inside+    footnotes and captions.  We now handle note citations by inserting+    footnotes during initial citation processing, and doing a separate+    pass later to remove notes inside notes.++  * Added 'zenburn' highlight style from highlighting-kate.++  * Added Slideous writer. Slideous is an HTML + javascript slide show+    format, similar to Slidy, but works with IE 7. (Jonas Smedegaard)++  * LaTeX writer:++    + Ensure we don't have extra blank lines at ends of cells.+      This can cause LaTeX errors, as they are interpreted as new paragraphs.+    + More consistent interblock spacing.+    + Require highlighting-kate >= 0.5.1, for proper highlighted inline+      code in LaTeX.  Closes #527.+    + Ensure that a Verbatim at the end of a footnote is followed by+      a newline. (Fixes a regression in the previous version.)+    + In default template, use black for internal links and TOC.+      Added commented-out code to use footnotes for links, as would+      be suitable in print output.++  * Beamer writer:  When `--incremental` is used, lists inside+    a block quote should appear all at once.  (This makes Beamer+    output consistent with the HTML slide show formats.)++  * ConTeXt writer:++    + Escape `%` as `\letterpercent{}` not `\letterpercent `,+      to avoid gobbling spaces after the `%` sign.+    + Ensure space after `\stopformula`.++  * Markdown writer:++    + Use `:` form instead of `~` in definition lists, for better+      compatibility with other markdown implementations.+    + Don't wrap the term, because it breaks definition lists.+    + Use a nonzero space to prevent false recognition+      of list marker in ordered lists.  Closes #516.++  * Org writer: Add space before language name.  Closes #523.++  * Docx writer: Simplified bullet characters so they work properly+    with Word 2007. Closes #520.++  * LaTeX reader: Support `\centerline`.++  * RST reader:  handle figures.  Closes #522.++  * Textile reader: fix for `<notextile>` and `==`.  Closes #517.+    (Paul Rivier)++## pandoc 1.9.3 (2012-05-12)++  * Added docbook reader (with contributions from Mauro Bieg).++  * Fixed bug in `fromEntities`.  The previous version would turn+    `hi & low you know;` into `hi &`.++  * HTML reader:++    + Don't skip nonbreaking spaces.+      Previously a paragraph containing just `&nbsp;` would be rendered+      as an empty paragraph. Thanks to Paul Vorbach for pointing out the bug.+    + Support `<col>` and `<caption>` in tables. Closes #486.++  * Markdown reader:++    + Don't recognize references inside delimited code blocks.+    + Allow list items to begin with lists.++  * LaTeX reader:++    + Handle `\bgroup`, `\egroup`, `\begingroup`, `\endgroup`.+    + Control sequences can't be followed by a letter.+      This fixes a bug where `\begingroup` was parsed as `\begin`+      followed by `group`.+    + Parse 'dimension' arguments to unknown commands.  e.g. `\parindent0pt`+    + Make `\label` and `\ref` sensitive to `--parse-raw`.+      If `--parse-raw` is selected, these will be parsed as raw latex+      inlines, rather than bracketed text.+    + Don't crash on unknown block commands (like `\vspace{10pt}`)+      inside `\author`; just skip them.  Closes #505.++  * Textile reader:++    + Implemented literal escapes with `==` and `<notextile>`.  Closes #473.+    + Added support for LaTeX blocks and inlines (Paul Rivier).+    + Better conformance to RedCloth inline parsing (Paul Rivier).+    + Parse '+text+' as emphasized (should be underlined, but this+      is better than leaving literal plus characters in the output.++  * Docx writer: Fixed multi-paragraph list items.  Previously they each+    got a list marker.  Closes #457.++  * LaTeX writer:++    + Added `--no-tex-ligatures` option to avoid replacing+      quotation marks and dashes with TeX ligatures.+    + Use `fixltx2e` package to provide `\textsubscript`.+    + Improve spacing around LaTeX block environments:+      quote, verbatim, itemize, description, enumerate.+      Closes #502.+    + Use blue instead of pink for URL links in latex/pdf output.++  * ConTeXt writer: Fixed escaping of `%`.+    In text, `%` needs to be escaped as `\letterpercent`, not `\%`+    Inside URLs, `%` needs to be escaped as `\%`+    Thanks to jmarca and adityam for the fix.  Closes #492.++  * Texinfo writer:  Escape special characters in node titles.+    This fixes a problem pointed out by Joost Kremers.  Pandoc used+    to escape an '@' in a chapter title, but not in the corresponding+    node title, leading to invalid texinfo.++  * Fixed document encoding in texinfo template.+    Resolves Debian Bug #667816.++  * Markdown writer:++    + Don't force delimited code blocks to be flush left.+      Fixes bug with delimited code blocks inside lists etc.+    + Escape `<` and `$`.++  * LaTeX writer: Use `\hyperref[ident]{text}` for internal links.+    Previously we used `\href{\#ident}{text}`, which didn't work on+    all systems. Thanks to Dirk Laurie.++  * RST writer: Don't wrap link references.  Closes #487.++  * Updated to use latest versions of blaze-html, mtl.+++## pandoc 1.9.2 (2012-04-05)++  * LaTeX reader:++    + Made `lstlisting` work as a proper verbatim environment.+    + Fixed bug parsing LaTeX tables with one column.++  * LaTeX writer:++    + Use `{}` around `ctable` caption, so that formatting can be used.+    + Don't require eurosym package unless document has a €.++  * LaTeX template: Added variables for `geometry`, `romanfont`,+    `sansfont`, `mathfont`, `mainfont` so users can more easily+    customize fonts.++  * PDF writer:++    + Run latex engine at least two times, to ensure+      that PDFs will have hyperlinked bookmarks.+    + Added PDF metadata (title,author) in LaTeX standalone + PDF output.++  * Texinfo writer: retain directories in image paths.  (Peter Wang)++  * RST writer:  Better handling of inline formatting, in accord+    with docutils' "inline markup recognition rules" (though we don't+    implement the unicode rules fully). Now `hi*there*hi` gets+    rendered properly as `hi\ *there*\ hi`, and unnecessary+    `\ ` are avoided around `:math:`, `:sub:`, `:sup:`.++  * RST reader:++    + Parse `\ ` as null, not escaped space.+    + Allow `` :math:`...` `` even when not followed by blank+      or `\`.  This does not implement the complex rule docutils follows,+      but it should be good enough for most purposes.+    + Add support for the rST default-role directive. (Greg Maslov)++  * Text.Pandoc.Parsing: Added `stateRstDefaultRole` field to `ParserState`.+    (Greg Maslov)++  * Markdown reader: Properly handle citations nested in other inline+    elements.++  * Markdown writer:  don't replace empty alt in image with "image".++  * DZSlides:  Updated template.html and styles in default template.+    Removed bizarre CSS for `q` in dzslides template.++  * Avoid repeated `id` attribute in section and header in HTML slides.++  * README improvements:  new instructions on internal links,+    removed misleading note on reST math.++  * Build system:++    + Fixed Windows installer so that dzslides works.+    + Removed stripansi.sh.+    + Added .travis.yml for Travis continuous integration support..+    + Fixed upper bound for zlib (Sergei Trofimovich).+    + Fixed upper bound for test-framework.+    + Updated haddocks for haddock-2.10 (Sergei Trofimovich).+++## pandoc 1.9.1.2 (2012-03-09)++  * Added `beamer+lhs` as output format.++  * Don't escape `<` in `<style>` tags with `--self-contained`.+    This fixes a bug which prevented highlighting from working+    when using `--self-contained`.++  * PDF: run latex engine three times if `--toc` specified.+    This fixes page numbers in the table of contents.++  * Docx writer: Added TableNormal style to tables.++  * LaTeX math environment fixes. `aligned` is now used instead of+    the nonexistent `aligned*`. `multline` instead of the nonexistent+    `multiline`.++  * LaTeX writer: Use `\textasciitilde` for literal `~`.++  * HTML writer: Don't escape contents of EQ tags with --gladtex.+    This fixes a regression from 1.8.++  * Use `<q>` tags for Quoted items for HTML5 output.+    The quote style can be changed by modifying the template+    or including a css file. A default quote style is included.++  * LaTeX reader: Fixed accents (\~{a}, `\c{c}`).+    Correctly handle \^{}. Support "minted" as a LaTeX verbatim block.++  * Updated LaTeX template for better language support.+    Use `polyglossia` instead of `babel` with xetex.+    Set `lang` as documentclass option.+    `\setmainlanguage` will use the last of a comma-separated+    list of languages. Thanks to François Gannaz.++  * Fixed default LaTeX template so `\euro` and `€` work.  The+    `eurosym` package is needed if you are using pdflatex.++  * Fixed escaping of period in man writer (thanks to Michael Thompson).++  * Fixed list label positions in beamer.++  * Set `mainlang` variable in context writer.+    This parallels behavior of latex writer.  `mainlang` is the last+    of a comma-separated list of languages in lang.++  * EPUB language metadat: convert e.g. `en_US` from locale to `en-US`.++  * Changed `-V` so that you can specify a key without a value.+    Such keys get the value `true`.++  * Fixed permissions on installed man pages - thanks Magnus Therning.++  * Windows installer: require XP or higher.  The installer is+    now compiled on a Windows 7 machine, which fixes a problem+    using citation functions on Windows 7.++  * OSX package: Check for 64-bit Intel CPU before installing.+++## pandoc 1.9.1.1 (2012-02-11)++  * Better handling of raw latex environments in markdown.  Now++        \begin{equation}+        a_1+        \end{equation}++    turns into a raw latex block as expected.++  * Improvements to LaTeX reader:++    + Skip options after block commands.+    + Correctly handle `{\\}` in braced.+    + Added a needed 'try'.+    + Citations: add `, ` to suffix if it doesn't start with space or+      punctuation. Otherwise we get no space between the year and the+      suffix in author-date styles.++  * Added two needed data files for S5.  This fixes a problem with+    `pandoc -t s5 --self-contained`.  Also removed `slides.min.js`,+    which was no longer being used.++  * Fixed some minor problems in `reference.docx`:+    name on "Date" style, `xCs` instead of `xIs`.++  * Fixed a problem creating docx files using a reference docx+    modified using Word.  The problem seems to be that Word+    modifies `_rels/.rels`, changing the Type of the Relationship to+    `docProps/core.xml`. Pandoc now changes this back to the correct+    value if it has been altered, fixing the problem.++  * Fixed html5 template so it works properly with highlighting.++## pandoc 1.9.1 (2012-02-09)++  * LaTeX reader:++    + Fixed regression in 1.9; properly handle escaped $ in latex math.+    + Put LaTeX verse environments in blockquotes.++  * Markdown reader:++    + Limit nesting of strong/emph.  This avoids exponential lookahead+      in parasitic cases, like `a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**`.+    + Improved attributes syntax (in code blocks/spans): (1)+      Attributes can contain line breaks. (2) Values in key-value+      attributes can be surrounded by either double or single quotes, or+      left unquoted if they contain no spaces.++  * Headers no longer wrap in markdown or RST writers.++  * Added `stateMaxNestingLevel` to `ParserState`.+    We set this to 6, so you can still have `Emph` inside `Emph`,+    just not indefinitely.++  * More efficient implementation of `nowrap` in `Text.Pandoc.Pretty`.++  * `Text.Pandoc.PDF`:  Only run latex twice if `\tableofcontents`+    is present.++  * Require highlighting-kate >= 0.5.0.2, texmath >= 0.6.0.2.++## pandoc 1.9.0.5 (2012-02-06)++  * Changed cabal file so that build-depends for the test program+    are not required unless the tests flag is used.++  * LaTeX writer:  insert `{}` between adjacent hyphens so they don't+    form ligatures (dashes) in code spans.++## pandoc 1.9.0.4 (2012-02-06)++  * Raised version bound on test-framework to avoid problems+    compiling tests on GHC 7.4.1.++  * LaTeX reader: Use raw LaTeX as fallback inline text for Cites,+    so citations don't just disappear unless you process with+    citeproc.  Ignore `\bibliographystyle`, `\nocite`.++  * Simplified tex2pdf; it will always run latex twice to+    resolve table of contents and hyperrefs.++## pandoc 1.9.0.3 (2012-02-06)++  * Require Cabal >= 1.10.++  * Tweaked cabal file to meet Cabal 1.10 requirements.++## pandoc 1.9.0.2 (2012-02-05)++  * Allow build with json 0.4 or 0.5.  Otherwise we can't build with+    ghc 6.12.++## pandoc 1.9 (2012-02-05)++### New features++  * Added a Microsoft Word `docx` writer. The writer includes support+    for highlighted code and for math (which is converted from TeX to OMML,+    Office's native math markup language, using texmath's new OMML module).+    A new option `--reference-docx` allows the user to customize the+    styles.++  * Added an `asciidoc` writer (<http://www.methods.co.nz/asciidoc/>).++  * Better support for slide shows:++    + Added a `dzslides` writer. DZSlides is a lightweight HTML5/javascript+      slide show format due to Paul Rouget (<http://paulrouget.com/dzslides/>).++    + Added a LaTeX `beamer` writer. Beamer is a LaTeX package for creating+      slide presentations.++    + New, flexible rules for dividing documents into sections and slides+      (see the "Structuring the slide show" in the User's Guide).  These+      are backward-compatible with the old rules, but they allow slide+      shows to be organized into sections and subsections containing+      multiple slides.++    + A new `--slide-level` option allows users to override defaults+      and select a slide level below the first header level with content.++  * A new `--self-contained` option produces HTML output that does not+    depend on an internet connection or the presence of any external+    files. Linked images, CSS, and javascript is downloaded (or fetched+    locally) and encoded in `data:` URIs. This is useful for making portable+    `HTML slide shows. The --offline` option has been deprecated and is now+    `treated as a synonym or --self-contained`.++  * Support for PDF output:++    + Removed the old `markdown2pdf`.+    + `pandoc` can now create PDFs (assuming you have latex and a set of+      appropriate packages installed): just specify an output file with the+      `.pdf` extension.+    + A new option `--latex-engine` allows you to specify `pdflatex`,+      `xelatex`, or `lualatex` as the processor.++  * Highlighting changes:++    + Syntax highlighting is now a standard feature; the `highlighting`+      flag is no longer needed when compiling.+    + A new `--no-highlight` option allows highlighting to be disabled.+    + Highlighting now works in `docx`, `latex`, and `epub`, as well as+      `html`, `html5`, `dzslides`, `s5`, and `slidy`.+    + A new `--highlight-style` option selects between various highlighting+      color themes.++  * Internal links to sections now work in ConTeXt and LaTeX as well as HTML.++  * LaTeX `\include` and `\usepackage` commands are now processed,+    provided the files are in the working directory.++  * EPUB improvements:++    + Internal and external links now work in EPUB.+    + Raw HTML is allowed.+    + New `--epub-embed-font` option.+    + Customizable templates for EPUB pages offer more control over+      formatting: `epub-page.html`, `epub-coverimage.html`,+      `epub-titlepage.html`.++  * `--mathml` now works with DocBook.++  * Added support for math in RST reader and writer.  Inline math uses the+    `` :math:`...` `` construct.  Display math uses++        .. math:: ...++    or if the math is multiline,++        .. math::++           ...++    These constructions are now supported now by `rst2latex.py`.++  * Github syntax for fenced code blocks is supported in pandoc's+    markdown.  You can now write++        ```ruby+        x = 2+        ```++    instead of++        ~~~ {.ruby}+        x = 2+        ~~~~++  * Easier scripting:  a new `toJsonFilter` function makes it easier to+    write Haskell scripts to manipulate the Pandoc AST.+    See [Scripting with pandoc](scripting.html#pandoc-1.9-changes).++### Behavior changes++  * Fixed parsing of consecutive lists in markdown.+    Pandoc previously behaved like Markdown.pl for consecutive+    lists of different styles. Thus, the following would be parsed+    as a single ordered list, rather than an ordered list followed+    by an unordered list:++        1. one+        2. two++        - one+        - two++    This change makes pandoc behave more sensibly, parsing this as+    two lists.  Any change in list type (ordered/unordered) or in+    list number style will trigger a new list. Thus, the following+    will also be parsed as two lists:++        1. one+        2. two++        a. one+        b. two++    Since we regard this as a bug in Markdown.pl, and not something+    anyone would ever rely on, we do not preserve the old behavior+    even when `--strict` is selected.++  * Dashes work differently with `--smart`: `---` is always em-dash,+    and `--` is always en-dash.  Pandoc no longer tries to guess when+    `-` should be en-dash.  *Note:* This may change how existing documents+    look when processed with pandoc. A new option, `--old-dashes`,+    is provided for legacy documents.++  * The markdown writer now uses setext headers for levels 1-2.+    The old behavior (ATX headers for all levels) can be restored+    using the new `--atx-headers` option.++  * Links are now allowed in markdown image captions.  They are also+    allowed in links, but will appear there as regular text. So,++        [link with [link](/url)](/url)++    will turn into++        <p><a href="/url">link with link</a></p>++  * Improved handling of citations using `citeproc-hs-0.3.4`.+    Added `--citation-abbreviations` option.++  * Citation keys can no longer end with a punctuation character.+    This means that `@item1.` will be parsed as a citation with key+    'item1', followed by a period, instead of a citation with key+    'item1.', as was the case previously.++  * In HTML output, citations are now put in a span with class `citation`.++  * The markdown reader now recognizes DocBook block and inline tags.+    It was always possible to include raw DocBook tags in a markdown+    document, but now pandoc will be able to distinguish block from+    inline tags and behave accordingly. Thus, for example,++        <sidebar>+        hello+        </sidebar>++    will not be wrapped in `<para>` tags.++  * The LaTeX parser has been completely rewritten; it is now much more+    accurate, robust, and extensible. However, there are two important+    changes in how it treats unknown LaTeX. (1) Previously, unknown+    environments became BlockQuote elements; now, they are treated+    as "transparent", so `\begin{unknown}xyz\end{unknown}` is the+    same as `xyz`.  (2) Previously, arguments of unknown commands+    were passed through with their braces; now the braces are stripped+    off.++  * `--smart` is no longer selected automatically with `man` output.++  * The deprecated `--xetex` option has been removed.++  * The `--html5`/`-5` option has been deprecated. Use `-t html5`+    instead. `html5` and `html5+lhs` are now separate output formats.++  * Single quotes are no longer escaped in HTML output.  They do not+    need to be escaped outside of attributes.++  * Pandoc will no longer transform leading newlines in code+    blocks to `<br/>` tags.++  * The ODT writer now sizes images appropriately, using the image+    size and DPI information embedded in the image.++  * `--standalone` is once again implicitly for a non-text output format+    (ODT, EPUB).  You can again do `pandoc test.txt -o test.odt`+    and get a standalone ODT file.++  * The Docbook writer now uses `<sect1>`, `<sect2>`, etc. instead of+    `<section>`.++  * The HTML writer now uses `<del>` for strikeout.++  * In HTML output with `--section-divs`, the classes `section` and+    `level[1,2,..6]` are put on the `div` tags so they can be styled.+    In HTML 5 output with `--section-divs`, the classes+    `level[1,2,...6]` are put on `section` tags.++  * EPUB writer changes:++    + The `lang` variable now sets the language+      in the metadata (if it is not set, we default to the locale).+    + EPUB:  UTF-8 is used rather than decimal entities.++  * Added `titleslide` class to title slide in S5 template.++  * In HTML, EPUB, and docx metadata, the date is normalized into+    YYYY-MM-DD format if possible. (This is required for validation.)++  * Attributes in highlighted code blocks are now preserved in HTML.+    The container element will have the classes, id, and key-value attributes+    you specified in the delimited code block. Previously these were stripped+    off.++  * The reference backlink in the HTML writer no longer has a special+    `footnoteBacklink` class.++  * The HTML template has been split into `html` and `html5` templates.++  * Author and date are treated more consistently in HTML templates.+    Authors are now `<h2>`, date `<h3>`.++  * URLs are hyphenated in the ConTeXt writer (B. Scott Michel).++  * In `Text.Pandoc.Builder`, `+++` has been replaced by `<>`.++### Bug fixes++  * Better support for combining characters and East Asian wide characters+    in markdown and reST.++  * Better handling of single quotes with `--smart`.+    Previously `D'oh l'*aide*` would be parsed with left and right single+    quotes instead of apostrophes. This kind of error is now fixed.++  * Highlighting: Use `reads` instead of `read` for better error handling.+    Fixes crash on `startNum="abc"`.++  * Added blank comment after directives in rst template.++  * Unescape entities in citation `refId`. The `refId`s coming+    from citeproc contain XML numeric entities, and these don't match with the+    citation keys parsed by pandoc. Solution is to unescape them.++  * HTML reader: Fixed bug parsing tables with both thead and tbody.++  * Markdown reader:++    + Better handling of escapes in link URLs and titles.+    + Fixed backslash escapes in reference links.+    + Fixed bug in table/hrule parsing, by checking that the top+      line of a table is not followed by a blank line. This bug caused+      slowdowns on some files with hrules and tables, as pandoc tried to+      interpret the hrules as the tops of multiline tables.+    + Fixed bug in code block attribute parser. Previously the ID attribute+      got lost if it didn't come first. Now attributes can come in any order.++  * RST reader: allow footnotes followed by newline without space characters.++  * LaTeX reader:++    + Ignore empty groups {}, { }.+    + LaTeX reader: Handle `\@`.+    + LaTeX reader:  Don't crash on commands like `\itemsep`.+    + LaTeX reader:  Better handling of letter environments.++  * RST writer: Fixed bug involving empty table cells. isSimple was being+    calculated in a way that assumed there were no non-empty cells.++  * ConTeXt writer:++    + Made `--toc` work even without `--number-sections`.+    + Escape # in link URLs.+    + Use buffering for footnotes containing code blocks.+    + Changed 'descr' to 'description', fixed alignment.++  * LaTeX writer:++    + Escape euro character.+    + Don't escape `~` inside `\href{...}`.+    + Escape `#` in href URLs.+    + Improved detection of book classes.  We now check the+      `documentclass` variable, and if that is not set, we look through+      the template itself.  Also, we have added the KOMA classes scrreprt+      and scrbook.  You can now make a book using+      `pandoc -V documentclass:book mybook.txt -o mybook.pdf`+    + LHS files now set the "listings" variable, so that the definition+      of the `code` environment will be included in the template.+    + Links are colored blue by default (this can be changed by+      modifying `hyperref` settings in the template).+    + Added `lang` variable to LaTeX template.++  * HTML writer:++    + Fixed bug in HTML template with html5 and mathml.+    + Don't use self-closing img, br, hr tags for HTML5.+    + Use `<section>` for footnotes if HTML5.+    + Update HTML templates to use Content-Style-Type meta tag.+    + Use separate variables for meta-date, meta-author.+      This makes footnotes work in author and date fields.+    + Use 'vertical-align:middle' in WebTeX math for better alignment.++  * S5/slidy writer:  Make footnotes appear on separate slide at end.++  * MIME: Added 'layout-cache' to getMimeType. This ensures that the+    META-INF/manifest.xml for ODT files will have everything it needs, so+    that ODT files modified by LibreOffice can be used as `--reference-odt`.++  * `Text.Pandoc.Templates`: Return empty string for json template.++  * `Text.Pandoc.Biblio`:++    + Expand citations recursively inside nested inlines.+    + Treat `\160` as space when parsing locator and suffix.+      This fixes a bug with "p. 33" when `--smart` is used. Previously+      the whole "p. 33" would be included in the suffix, with no locator.+    + Put whole author-in-text citation in a Cite.  Previously just the+      date and other info went in the Cite.+    + Don't add comma+space to prefix if it ends in punctuation.++  * Updated chicago-author-date.csl.  The old version did not work+    properly for edited volumes with no author.++  * EPUB writer:++    + Add date to EPUB titlepage and metadata.+    + Added TOC identifier in EPUB page template.+    + Don't generate superfluous file `cover-image.jpg`.++###  Under the hood improvements++  * Modified `make_osx_package.sh` to use cabal-dev.+    Items are no longer installed as root.+    Man pages are zipped and given proper permissions.++  * Modified windows installer generater to use cabal-dev.++  * Setup: Making man pages now works with cabal-dev (at least on OSX). In+    Setup.hs we now invoke 'runghc' in a way that points it to the correct+    package databases, instead of always falling back to the default user+    package db.++  * Updated to work with GHC 7.4.1.++  * Removed dependency on old-time.++  * Removed dependency on dlist.++  * New slidy directory for "self-contained."++  * TeXMath writer:  Use unicode thin spaces for thin spaces.++  * Markdown citations: don't strip off initial space in locator.++### API changes++  * Removed `Apostrophe`, `EmDash`, `EnDash`, and `Ellipses`+    from the native `Inline` type in pandoc-types.  Now we use `Str`+    elements with unicode.++  * Improvements to `Text.Pandoc.Builder`:++    + `Inlines` and `Blocks` are now newtypes (not synonyms for+      sequences).+    + Instances are defined for `IsString`, `Show`, `Read`, `Monoid`,+      and a new `Listable` class, which allows these to be manipulated+      to some extent like lists. Monoid append includes automatic+      normalization.+    + `+++` has been replaced by `<>` (mappend).++  * Use blaze-html instead of xhtml for HTML generation.+    This changes the type of `writeHtml`.++  * `Text.Pandoc.Shared`:++    + Added `warn` and `err`.+    + Removed `unescapeURI`, modified `escapeURI`.+      (See under [behavior changes], above.)++  * Changes in URI escaping:  Previously the readers escaped URIs by+    converting unicode characters to octets and then percent encoding.+    Now unicode characters are left as they are, and `escapeURI` only+    percent-encodes space characters.  This gives more readable+    URIs, and works well with modern user agents. URIs are no longer unescaped+    at all on conversion to `markdown`, `asciidoc`, `rst`, `org`.++  * New module `Text.Pandoc.SelfContained`.++  * New module `Text.Pandoc.Docx`.++  * New module `Text.Pandoc.PDF`.++  * Added `writerBeamer` to `WriterOptions`.++  * Added `normalizeDate` to `Text.Pandoc.Shared`.++  * Added `splitStringWithIndices` in `Text.Pandoc.Shared`.+    This is like `splitWithIndices`, but it is sensitive to distinctions+    between wide, combining, and regular characters.++  * `Text.Pandoc.Pretty`:++    + Added `chomp` combinator.+    + Added `beforeNonBreak` combinator.  This allows you to include+      something conditionally on it being before a nonblank.+      Used for RST inline math.+    + Added `charWidth` function. All characters marked W or F in the unicode+      spec EastAsianWidth.txt get width 2.+    + Added `realLength`, based on `charWidth`. `realLength` is now+      used in calculating offsets.++  * New module `Text.Pandoc.Slides`, for common functions for breaking+    a document into slides.++  * Removed `Text.Pandoc.S5`, which is no longer needed.++  * Removed `Text.Pandoc.CharacterReferences`.  Moved+    `characterReference` to `Text.Pandoc.Parsing`.+    `decodeCharacterReferences` is replaced by `fromEntities`+    in `Text.Pandoc.XML`.++  * Added `Text.Pandoc.ImageSize`.  This is intened for use+    in `docx` and `odt` writers, so the size and dpi of images+    can be calculated.++  * Removed `writerAscii` in `WriterOptions`.++  * Added `writerHighlight` to `WriterOptions`.++  * Added `DZSlides` to `HTMLSlideVariant`.++  * `writeEPUB` has a new argument for font files to embed.++  * Added `stateLastStrPos` to `ParserState`. This lets us keep track+    of whether we're parsing the position immediately after a regular+    (non-space, non-symbol) string, which is useful for distinguishing+    apostrophes from single quote starts.++  * `Text.Pandoc.Parsing`:++    + `escaped` now returns a `Char`.+    + Removed `charsInBalanced'`, added a character parser as+      a parameter of `charsInBalanced`.  This is needed for+      proper handling of escapes, etc.+    + Added `withRaw`.++  * Added `toEntities` to `Text.Pandoc.XML`.++  * `Text.Pandoc.Readers.LaTeX`:++    + Export `handleIncludes`.+    + Export `rawLaTeXBlock` instead of `rawLaTeXEnvironment'`.++  * Added `ToJsonFilter` class and `toJsonFilter` function to+    `Text.Pandoc`, deprecating the old `jsonFilter` function.++  * `Text.Pandoc.Highlighting`:++     + Removed `highlightHtml`, `defaultHighlightingCss`.+     + Export `formatLaTeXInline`, `formatLaTeXBlock`, and `highlight`, plus+       key functions from highlighting-kate.+     + Changed types of highlighting function.  `highlight` returns a+       `Maybe`, not an `Either`.+++## pandoc 1.8.2.1 (2011-08-01)++  * Adjusted Arbitrary instance to help avoid timeouts in tests.++  * Added `Tests.Writers.Markdown` to cabal file.++  * Relaxed version bounds on pandoc-types, test-framework.++## pandoc 1.8.2 (2011-07-30)++  * Added script to produce OS X package.++  * Made `templates` directory a git submodule.  This should make it+    easier for people to revise their custom templates when the default+    templates change.++  * Changed template naming scheme: `FORMAT.template` -> `default.FORMAT`.+    **Note:** If you have existing templates in `~/.pandoc/templates`, you+    must rename them to conform to the new scheme!++  * Default template improvements:++    + HTML:  Display author and date after title.+    + HTML:  Made table of contents more customizable.  The container+      for the TOC is now in the template, so users can insert a header+      or other styling. (Thanks to Bruce D'Arcus for the suggestion.)+    + HTML, Slidy, S5:  Enclose scripts in CDATA tags.+    + Slidy, S5: Added `s5-url` and `slidy-url` variables, instead of+      hard-coding.  If you want to put your slidy files in the slidy+      subdirectory, for example, you can do+      `pandoc -t slidy -V slidy-url=slidy -s`.+    + LaTeX: Use `\and` to separate authors in LaTeX documents (reader+      & writer).  Closes #279.+    + LaTeX: Set `\emergencystretch` to prevent overfull lines.+    + LaTeX: Use different `hyperref` options for `xetex`, fixing+      problems with unicode bookmarks (thanks to CircleCode).+    + LaTeX: Removed `ucs` package, use `utf8` rather than `utf8x`+      with `inputenc`.  This covers fewer characters but is more+      robust with other packages, and `ucs` is unmaintained.  Users+      who need better unicode support should use xelatex or lualatex.++  * If a template specified with `--template` is not found, look for it+    in `datadir`.  Also, if no extension is provided, supply one based+    on the writer.  So now you can put your `special.latex` template in+    `~/.pandoc/templates`, and use it from any directory via+    `pandoc -t latex --template special`.++  * Added `nonspaceChar` to `Text.Pandoc.Parsing`.++  * Fixed smart quotes bug, now handling `'...hi'` properly.++  * RST reader:++    + Partial support for labeled footnotes.+    + Improved accuracy of `simpleReferenceName` parser.++  * HTML reader:++    + Substitute correct unicode characters for+      characters in the 128..159 range, which are often found even in+      HTML that purports to be UTF-8.++  * LaTeX reader:  Handle `\subtitle` command (a subtitle is added+    to the title, after a colon and linebreak). Closes #280.++  * Leaner `reference.odt`.++  * Added unexported module `Text.Pandoc.MIME` for use in+    the ODT writer.++  * ODT writer:  Construct `manifest.xml` based on archive contents.+    This fixes a bug in ODTs containing images. Recent versions of+    LibreOffice would reject these as corrupt, because `manifest.xml`+    did not contain a reference to the image files.++  * LaTeX writer:++    + Make verbatim environments flush to avoid spurious+      blank lines.  Closes #277.+    + Use `\texttt` and escapes insntead of `\verb!...!`, which+      is too fragile (doesn't work in command arguments).+    + Use `\enquote{}` for quotes if the template includes+      the `csquotes` package. This provides better support for+      local quoting styles. (Thanks to Andreas Wagner for the idea.)++  * ConTeXt writer:  Make `\starttyping`/`\stoptyping` flush with+    margin, preventing spurious blank lines.++  * Slidy writer:++    + Use non-minimized version of `slidy.css` with `--offline`+      option, so users can more easily edit it.+    + Also fixed a bug in the CSS that prevented proper centering+      of title (now reported and fixed upstream).++  * S5 writer:++    + Replaced `s5/default/slides.js.{comment,packed}` with+      new compressed `s5/default/slides.min.js`.+    + Use `data:` protocol to embed S5 CSS in `<link>` tags,+      when `--offline` is specified. Using inline CSS didn't+      work with Chrome or Safari.  This fixes offline+      S5 on those browsers.++  * HTML writer:  Removed English title on footnote backlinks.+    This is incongrous in non-English documents.++  * Docbook writer:++    + Use CALS tables.  (Some older docbook software does not work+      well with XHTML tables.)  Closes #77.+    + Use `programlisting` tags (instead of `screen`) for code blocks.++  * `markdown2pdf`:++    + Calls latex with `-halt-on-error -interaction nonstopmode` instead+      of `-interaction=batchmode`, which essentially just ignored errors,+      leading to bad results. Better to know when something is wrong.+    + Fixed issues with non-UTF-8 output of `pdflatex`.+    + Better error reporting.++  * `--mathjax` now takes an optional URL argument. If it is not+    provided, pandoc links directly to the (secure) mathjax CDN,+    as now recommended (thanks to dsanson).++  * Deprecated `--xetex` option in `pandoc`.  It is no longer needed,+    since the LaTeX writer now produces a file that can be processed by+    `latex`, `pdflatex`, `lualatex`, or `xelatex`.++  * Introduced `--luatex` option to `markdown2pdf`. This causes `lualatex`+    to be used to create the PDF.+++## pandoc 1.8.1.2 (2011-07-16)++  * Added `--epub-cover-image` option.++  * Documented `--biblatex` and `--natbib` options.++  * Allow `--section-divs` with slidy output.  Resolves Issue #296.++  * Disallow notes within notes in reST and markdown.+    These previously caused infinite looping and stack overflows.+    For example:++        [^1]++        [^1]: See [^1]++    Note references are allowed in reST notes, so this isn't a full+    implementation of reST. That can come later. For now we need to+    prevent the stack overflows.  Partially resolves Issue #297.++  * EPUB writer: Allow non-plain math methods.++  * Forbid ()s in citation item keys.  Resolves Issue #304: problems with+    `(@item1; @item2)` because the final paren was being parsed as part of+    the item key.++  * Changed URI parser so it doesn't include trailing punctuation.+    So, in RST, `http://google.com.` should be parsed as a link followed by a+    period. The parser is smart enough to recognize balanced parentheses, as+    often occur in wikipedia links: `http://foo.bar/baz_(bam)`.++  * Markdown+lhs reader: Require space after inverse bird tracks, so that+    HTML tags can be used freely at the left margin of a markdown+lhs document.+    Thanks to Conal Elliot for the suggestion.++  * Markdown reader: Fixed bug in footnote order (reported by CircleCode).++  * RST reader:+      + Fixed bug in in field lists with multi-line items at the+        end of the list.+      + Added parentheses to RST `specialChars`, so+        `(http://google.com)` will be parsed as a link in parens.+        Resolves Issue #291.+      + Allow `|` followed by newline in RST line block.++  * LaTeX reader:+      + Support `\dots`.+      + Gobble option & space after linebreak `\\[10pt]`.++  * Textile reader:+      + Make it possible to have colons after links.  (qerub)+      + Make it possible to have colons after links.  (Christoffer Sawicki)++  * HTML reader:+      + Skip spaces after `<b>`, `<emph>`, etc.+      + Handle tbody, thead in simple tables.  Closes #274.+      + Implicit `Para`s instead of `Plains` in some contexts.++  * OpenDocument writer:  Use special `First paragraph` style for+    first paragraph after most non-paragraph blocks. This allows users to+    specify e.g. that only paragraphs after the first paragraph of a block are+    to be indented. Thanks to Andrea Rossato for the patch. Closes #20.++  * LaTeX writer:  use `deVerb` on table and picture captions.+    Otherwise LaTeX complains about `\verb` inside command argument.+    Thanks to bbanier for reporting the bug.++  * Markdown writer: Insert HTML comment btw list and indented code block.+    This prevents the code block from being interpreted as part of the list.++  * EPUB writer: Add a meta element specify the cover.+    Some EPUB e-readers, such as the Nook, require a meta element inside the+    OPF metadata block to ensure the cover image is properly displayed.+    (Kelsey Hightower)++  * HTML writer: Use embed tag for images with non-image extensions.+    (e.g.  PDFs).  Closes #264.++  * LaTeX writer: Improved tables.++      + More space between lines, top-align cells.+      + Use ctable package, which allows footnotes and+        provides additional options.+      + Made cell alignments work in multiline tables.+      + Closes #271, #272.++  * Un-URI-escape image filenames in LaTeX, ConTeXt, RTF, Texinfo.+    Also do this when copying image files into EPUBs and ODTs.+    Closes #263.++  * Changed to github issue tracker.++  * Added failing emph/strong markdown test case due to Perry Wagle.++  * Slidy improvements:+      + Updated to use Slidy2.+      + Fixed bug, unclosed div tag.+      + Added `duration` variable in template.+        Setting this activates the timer.+      + Use 'titlepage' instead of 'cover' for title div.+++## pandoc 1.8.1.1 (2011-02-13)++  * `markdown2pdf`:  Removed some debugging lines accidentally included+    in the 1.8.1 release. With those lines, the temp directory is created+    in the working directory, and it is not deleted.  This fix restores+    the original behavior.++## pandoc 1.8.1 (2011-02-13)++  * Added `--ascii` option.  Currently supported only in HTML writer,+    which it causes to use numerical entities instead of UTF-8.++  * EPUB writer: `--toc` now works to provide a table of contents+    at the beginning of each chapter.++  * LaTeX writer:  Change figure defaults to `htbp`.+    This prevents "too many unprocessed floats."  Resolves+    Issue #285.++  * `Text.Pandoc.UTF8`:  Encode filenames even when using recent+    base.++  * `markdown2pdf`: Fixed filename encoding issues. With help from Paulo+    Tanimoto. Resolves Issue #286.++  * HTML writer: Put line breaks in section divs.++  * `Text.Pandoc.Shared`: Make `writerSectionDivs` default to False.++## pandoc 1.8.0.3 (2011-02-05)++  * Fixed Source-repository stanza in cabal file.++## pandoc 1.8.0.2 (2011-02-05)++  * HTML writer:++    + Stringify alt text instead of converting to HTML.+    + Break lines after block elements, not inside tags.+      HTML output now closely resembles that of tidy. Resolves Issue #134.++  * Markdown reader: Fixed bug in footnote block parser (pointed out+    by Jesse Rosenthal).  The problem arose when the blank line+    at the end of a footnote block contained indenting spaces.++  * Shared: Improved 'normalize' function so it normalizes Spaces too.+    In normal form, Space elements only occur to separate two non-Space+    elements.  So, we never have [Space], or [, ..., Space].++  * Tests:++    + Improved Arbitrary instance.+    + Added timeout for test instances.++  * README:++    + Added section on four-space rule for lists.  Resolves Issue #283.+    + Clarified optional arguments on math options.++  * markdown2pdf: Fixed bug with output file extensions.+    Previously `markdown2pdf test.txt -o test.en.pdf` would produce+    `test.pdf`, not `test.en.pdf`.  Thanks to Paolo Tanimoto for the fix.++## pandoc 1.8.0.1 (2011-01-31)++  * 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 (2011-01-30)++### 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 (2010-07-24)+++ New EPUB and HTML Slidy writers. (Issue #122)++    - [EPUB] is a standard ebook format, used in Apple's iBooks for+      the iPad and iPhone, Barnes and Noble's nook reader, the Sony+      reader, and many other devices, and by online ebook readers like+      [bookworm]. (Amazon's Kindle uses a different format, MobiPocket,+      but EPUB books can easily be converted to Kindle format.) Now you+      can write your book in markdown and produce an ebook with a single+      command! I've put up a short [tutorial here].+    - [Slidy], like S5, is a system for producing HTML+javascript slide shows.+++ All input is assumed to be UTF-8, no matter what the locale and ghc+  version, and all output is UTF-8. This reverts to pre-1.5 behavior.+  Also, a BOM, if present, is stripped from the input.+++ Markdown now supports grid tables, whose cells can contain+  arbitrary block elements. (Issue #43)+++ Sequentially numbered example lists in markdown with `@` marker.+++ Markdown table captions can begin with a bare colon and no longer need+  to include the English word "table." Also, a caption can now occur+  either before or after the table. (Issue #227)+++ New command-line options:++    - `--epub-stylesheet` allows you to specify a CSS file that will+      be used to style your ebook.+    - `--epub-metadata` allows you to specify metadata for the ebook.+    - `--offline` causes the generated HTML slideshow to include all+      needed scripts and stylesheets.+    - `--webtex` causes TeX math to be converted to images using the+      Google Charts API (unless a different URL is specified).+    - `--section-divs` causes div tags to be added around each section+      in an HTML document. (Issue #230, 239)+++ Default behavior of S5 writer in standalone mode has changed:+  previously, it would include all needed scripts and stylesheets+  in the generated HTML; now, only links are included unless+  the `--offline` option is used.+++ Default behavior of HTML writer has changed. Between 1.2 and 1.5,+  pandoc would enclose sections in div tags with identifiers on the+  div tags, so that the sections can be manipulated in javascript.+  This caused undesirable interactions with raw HTML div tags. So,+  starting with 1.6, the default is to put the identifiers directly+  on the header tags, and not to include the divs.  The `--section-divs`+  option selects the 1.2-1.5 behavior.+++ API changes:++    - `HTMLMathMethod`: Added `WebTeX`, removed `MimeTeX`.+    - `WriterOptions`: Added `writerUserDataDir`, `writerSourceDirectory`,+      `writerEPUBMetadata` fields. Removed `writerIncludeBefore`,+      `writerIncludeAfter`.+    - Added `headerShift` to `Text.Pandoc.Shared`.+    - Moved parsing code and `ParserState` from `Text.Pandoc.Shared`+      to a new module, `Text.Pandoc.Parsing`.+    - Added `stateHasChapters` to `ParserState`.+    - Added `HTMLSlideVariant`.+    - Made `KeyTable` a map instead of an association list.+    - Added accessors for `Meta` fields (`docTitle`, `docAuthors`, `docDate`).+    - `Pandoc`, `Meta`, `Inline`, and `Block` have been given `Ord` instances.+    - Reference keys now have a type of their own (`Key`), with its+      own `Ord` instance for case-insensitive comparison.+    - Added `Text.Pandoc.Writers.EPUB`.+    - Added `Text.Pandoc.UUID`.+    - Removed `Text.Pandoc.ODT`, added `Text.Pandoc.Writers.ODT`.+      Removed `saveOpenDocumentAsODT`, added `writeODT`.+    - Added `Text.Pandoc.Writers.Native` and `writeNative`.+      Removed `prettyPandoc`.+    - Added `Text.Pandoc.UTF8` for portable UTF8 string IO.+    - Removed `Text.Pandoc.Writers.S5` and the `writeS5` function.+      Moved `s5Includes` to a new module, `Text.Pandoc.S5`.+      To write S5, you now use `writeHtml` with `writerSlideVariant`+      set to `S5Slides` or `SlidySlides`.+++ Template changes.  If you use custom templates, please update them,+  particularly if you use syntax highlighting with pandoc. The old HTML+  templates hardcoded highlighting CSS that will no longer work with+  the most recent version of highlighting-kate.++    - HTML template: avoid empty meta tag if no date.+    - HTML template: Use default highlighting CSS from highlighting-kate+      instead of hard-coding the CSS into the template.+    - HTML template: insert-before text goes before the title, and+      immediately after the `<body>` tag, as documented. (Issue #241)+    - Added slidy and s5 templates.+    - Added amssymb to preamble of latex template. (github Issue 1)+++ Removed excess newlines at the end of output. Note: because output+  will not contain an extra newline, you may need to make adjustments+  if you are inserting pandoc's output into a template.+++ In S5 and slidy, horizontal rules now cause a new slide, so you+  are no longer limited to one slide per section.+++ Improved handling of code in man writer. Inline code is now monospace,+  not bold, and code blocks now use .nf (no fill) and .IP (indented para).+++ HTML reader parses `<tt>` as Code. (Issue #247)+++ html+lhs output now contains bird tracks, even when compiled without+  highlighting support. (Issue #242)+++ Colons are now no longer allowed in autogenerated XML/HTML identifiers,+  since they have a special meaning in XML.+++ Code improvements in ODT writer.  Remote images are now replaced with+  their alt text rather than a broken link.+++ LaTeX reader improvements:++    - Made latex `\section`, `\chapter` parsers more forgiving of whitespace.+    - Parse `\chapter{}` in latex.+    - Changed `rawLaTeXInline` to accept `\section`, `\begin`, etc.+    - Use new `rawLaTeXInline'` in LaTeX reader, and export `rawLaTeXInline`+      for use in markdown reader.+    - Fixes bug wherein `\section{foo}` was not recognized as raw TeX+      in markdown document.+++ LaTeX writer:  images are automatically shrunk if they would extend+  beyond the page margin.+++ Plain, markdown, RST writers now use unicode for smart punctuation.+++ Man writer converts math to unicode when possible, as in other writers.+++ `markdown2pdf` can now recognize citeproc options.+++ Command-line arguments are converted to UTF-8. (Issue #234)+++ `Text.Pandoc.TeXMath` has been rewritten to use texmath's parser.+  This allows it to handle a wider range of formulas. Also, if a formula+  cannot be converted, it is left in raw TeX; formulas are no longer+  partially converted.+++ Unicode curly quotes are left alone when parsing smart quotes. (Issue #143)+++ Cabal file changes:++    - Removed parsec < 3 restriction.+    - Added 'threaded' flag for architectures where GHC lacks a threaded+      runtime.+    - Use 'threaded' only for markdown2pdf; it is not needed for pandoc.+    - Require highlighting-kate 0.2.7.+++ Use explicit imports from `Data.Generics`. Otherwise we have a+  conflict with the 'empty' symbol, introduced in syb >= 0.2. (Issue #237)+++ New data files:  slidy/slidy.min.js, slidy/slidy.min.css, epub.css.++[EPUB]: http://en.wikipedia.org/wiki/EPUB+[Slidy]: http://www.w3.org/Talks/Tools/Slidy+[bookworm]: http://bookworm.oreilly.com/+[tutorial here]: http://johnmacfarlane.net/pandoc/epub.html++## pandoc  1.5.1.1 (2010-03-29)+++ Fixed header identifiers (uniqueIdent in Shared) so they+  work as advertized in README and are guaranteed to be+  valid XHTML names. Thanks to Xyne for reporting the bug.++## pandoc  1.5.1 (2010-03-23)+++ Fixed treatment of unicode characters in URIs.++ Revised Setup.hs so it works with debian's build process.++ Fixed bug in OpenDocument writer that led to invalid+  XML for some input.++## pandoc  1.5.0.1 (2010-03-21)+++ HTML writer: Fixed error in math writer (with MathML option)+  that caused an infinite loop for unparsable MathML.++## pandoc  1.5 (2010-03-20)+++ Moved repository to [github](http://github.com/jgm/pandoc).++ New `--mathml` option, for display of TeX math as MathML.++ New `--data-dir` option, allowing users to specify a data+  directory other than `~/.pandoc`.  Files placed in this directory+  will be used instead of system defaults.++ New `--base-header-level` option. For example, `--base-header-level=2`+  changes level 1 headers to level 2, level 2 to level 3, etc.++ New 'plain' output format: plain text without pictures, hyperlinks,+  inline formatting, or anything else that looks even vaguely+  markupish.++ Titles and authors in title blocks can now span multiple lines,+  as long as the continuation lines begin with a space character.++ When given an absolute URI as a parameter, pandoc will fetch+  the content via HTTP.++ The HTML reader has been made much more forgiving. It no+  longer requires well-formed xhtml as input.++ `html2markdown` has been removed; it is no longer necessary, given+  the last two changes. `pandoc` can be used by itself to convert+  web pages to markdown or other formats.++ `hsmarkdown` has also been removed.  Use `pandoc --strict` instead.+  Or symlink pandoc's executable to `hsmarkdown`; `pandoc` will then+  behave like `hsmarkdown` used to.++ An image in a paragraph by itself is now rendered as a figure+  in most writers, with the alt text as the caption.++ Incomplete support for reST tables (simple and grid). Thanks to+  Eric Kow. Colspans and rowspans not yet supported.++ In mediawiki, links with relative URLs are now formatted as wikilinks.+  Also, headers have been promoted: `= head =` is now level 1 instead of+  level 2.++ The markdown reader now handles "inverse bird tracks" when parsing+  literate haskell.  These are used for haskell example code that+  is not part of the literate program.++ The `-B` and `-A` options now imply `-s` and no longer work in+  fragment mode.++ Headerless tables are now printed properly in all writers.+  In addition, tbody, thead, and cols are used in HTML and Docbook+  tables.++ Improved build system; removed obsolete Makefile.++ In LaTeX writer, `\chapter` is now used instead of `\section`.+  when the documentclass is book, report, or memoir.++ Many small bug fixes. See [changelog] for details.++## pandoc  1.4 (2010-01-02)+++ New template system replaces old headers, giving users much+  more control over pandoc's output in `--standalone` mode.+  Added `--template` and `--variable` options.  The `--print-default-header`+  option is now `--print-default-template`.  See README under+  "Templates" for details.++ The old `--custom-header` option should still work, but it has+  been deprecated.++ New `--reference-odt` option allows users to customize styles+  in ODT output.++ Users may now put custom templates, s5 styles, and a reference+  ODT in the `~/.pandoc` directory, where they will override system+  defaults. See README for details.++ Unicode is now used whenever possible in HTML and XML output. Entities+  are used only where necessary (`&gt;`, `&lt;`, `&quot;`, `&amp;`).++ Authors and dates may now include formatting and notes.++ Added `--xetex` option for `pandoc` and `markdown2pdf`.++ Windows installer now includes highlighting support and+  `markdown2pdf` and `hsmarkdown` wrappers.++ Pandoc no longer requires Template Haskell, which should make+  it more portable.++ Pandoc can now be built on GHC 6.12, as well as earlier versions.++ See README for other small improvements and bug fixes.++## pandoc  1.3 (2009-12-10)+++ Added `--id-prefix` option to help prevent duplicate+  identifiers when you're generating HTML fragments.++ Added `--indented-code-classes` option, which specifies+  default highlighting syntax for indented code blocks.++ `--number-sections` now affects HTML output.++ Improved syntax for markdown definition lists.++ Better looking simple tables.++ Markdown tables without headers are now possible.++ New hard line break syntax:  backslash followed by newline.++ Improved performance of markdown reader by ~10% by eliminating the+  need for a separate parsing pass for notes.++ Improved syntax highlighting for literate Haskell.++ Support for "..code-block" directive in RST reader.++ Windows binary now includes highlighting support.++ Many bug fixes and small improvements. See [changelog]+  for details.++## pandoc  1.2.1 (2009-07-18)+++ Improved the efficiency of the markdown reader's+  abbreviation parsing (should give a big performance+  boost with `--smart`).++ HTML writer now wraps sections in divs with unique+  identifiers, for easier manipulation.++ Improved LaTeX reader's coverage of math modes.++ Added a portable Haskell version of markdown2pdf (thanks+  to Paolo Tanimoto).++ Made `--strict` compatible with `--standalone` and `--toc.`++ Many other small improvements and bug fixes.+  See [changelog] for details.++## pandoc  1.2 (2009-03-01)+++ Added support for literate Haskell. lhs support is triggered by+  '+lhs' suffixes in formats. For example, 'latex+lhs' is literate+  Haskell LaTeX. '.lhs' files are treated by default as literate+  markdown.++ Added `--email-obfuscation` option.++ Brought citeproc support up to date for citeproc-hs-0.2.++ Many bugs fixed. See [changelog] for details.++## pandoc  1.1 (2008-11-06)+++ New `--jsmath` option supporting use of pandoc with [jsMath].++ Classes on HTML table output for better CSS styling.++ Windows installer no longer requires admin privileges.++ Many bugs fixed.  See [changelog] for details.++## pandoc  1.0 (2008-09-13)+++ New writers for MediaWiki, GNU Texinfo (thanks to Peter Wang),+  OpenDocument XML (thanks to Andrea Rossato), and ODT (OpenOffice+  document).++ New [delimited code blocks](README.html#delimited-code-blocks),+  with optional syntax highlighting.++ Reorganized build system:  pandoc can now be built using standard+  Cabal tools.  It can be compiled on Windows without Cygwin.+  The tests can also be run without perl or unix tools.++ LaTeXMathML replaces ASCIIMathML for rendering math in HTML.++ Support for "displayed" math.++ Common abbreviations are now handled more intelligently, with+  a non-breaking space (and not a sentence-ending space) after+  the period.++ Code is -Wall clean.++ Many bug fixes and small improvements.  See [changelog] for+  full details.++## pandoc  0.46 (2008-01-08)+++ Added a `--sanitize-html` option (and a corresponding parameter+  in `ParserState` for those using the pandoc libraries in programs).+  This option causes pandoc to sanitize HTML (in HTML or Markdown+  input) using a whitelist method. Possibly harmful HTML elements+  are replaced with HTML comments. This should be useful in the+  context of web applications, where pandoc may be used to convert+  user input into HTML.++ Made -H, -A, and -B options cumulative: if they are specified+  multiple times, multiple files will be included.++ Many bug fixes and small improvements.  See [changelog] for full+  details.++## pandoc  0.45 (2007-12-09)+++ Many bug fixes and structural improvements.  See [changelog] for+  full details.++ Improved treatment of math. Math is now rendered using unicode+  by default in HTML, RTF, and DocBook output. For more accurate+  display of math in HTML, `--gladtex`, `--mimetex`, and `--asciimathml`+  options are provided. See the [User's Guide](README.html#math) for+  details.++ Removed support for box-style block quotes in markdown.++ More idiomatic ConTeXt output.++ Text wrapping in ConTeXt and LaTeX output.++ Pandoc now correctly handles all standard line endings+  (CR, LF, CRLF).++ New `--no-wrap` option that disables line wrapping and minimizes+  whitespace in HTML output.++ Build process is now compatible with both GHC 6.8 and GHC 6.6.+  GHC and GHC_PKG environment variables may be used to specify+  which version of the compiler to use, when multiple versions are+  installed.++## pandoc 0.44 (2007-09-03)++  [ John MacFarlane ]++  * Fixed bug in HTML writer:  when --toc was used, anchors were put around+    headers, which is invalid XHTML (block content within inline element).+    Now the anchors are put inside the header tags.  Resolves Issue #23.++  * Added xmlns attribute to html element in html writer tests.+    This attribute is added by more recent versions of the+    xhtml library (>= 3000), and is required for valid XHTML.++  [ Recai Oktaş ]++  * On configure, compile 'Setup.hs' to 'setup' and use 'setup' as the build+    command instead of 'runhaskell', which, on some platforms (such as s390,+    alpha, m68k), throws the following error:++        runhaskell Setup.hs configure --prefix=/usr+        ghc-6.6.1: not built for interactive use++    This causes a serious FTBFS bug.  Closes: #440668.++## pandoc 0.43 (2007-09-02)++  [ John MacFarlane ]++  * The focus of this release is performance.  The markdown parser+    is about five times faster than in 0.42, based on benchmarks+    with the TextMate manual.++  * Main.hs: Replaced CRFilter and tabFilter with single function+    tabFilter, which operates on the whole string rather than breaking+    it into lines, and handles dos-style line-endings as well as tabs.++  * Added separate LaTeX reader and native reader tests; removed+    round-trip tests.++  * Text.Pandoc.Shared:++    + Removed tabsToSpaces and tabsInLine (they were used only in Main.hs.)+    + General code cleanup (to elimante warnings when compiling with -Wall.)+    + Added 'wrapped' function, which helps wrap text into paragraphs,+      using the prettyprinting library.+    + Rewrote charsInBalanced and charsInBalanced'.+        - Documented restriction: open and close must be distinct characters.+        - Rearranged options for greater efficiency.+        - Bug fix: Changed inner call to charsInBalanced inside+          charsInBalanced' to charsInBalanced'.+    + anyLine now requires that the line end with a newline (not eof).+      This is a harmless assumption, since we always add newlines to the+      end of a block before parsing with anyLine, and it yields a 10% speed+      boost.+    + Removed unnecessary 'try' in anyLine.+    + Removed unneeded 'try' from romanNumeral parser.+    + Use notFollowedBy instead of notFollowedBy' in charsInBalanced.+    + Removed unneeded 'try' in parseFromString.+    + Removed unneeded 'try' from stringAnyCase.  (Now it behaves+      like 'string'.)+    + Changed definition of 'enclosed' in Text.Pandoc.Shared so that+      'try' is not automatically applied to the 'end' parser. Added+      'try' in calls to 'enclosed' where needed. Slight speed increase.++  * Writers:++    + Replaced individual wrapping routines in RST, Man, and Markdown+      writers with 'wrapped' from Text.Pandoc.Shared.+    + Rewrote LaTeX writer to use the prettyprinting library,+      so we get word wrapping, etc.+    + Modified latex writer tests for new latex writer using prettyprinter.+    + Fixed bug in LaTeX writer: autolinks would not cause+      `\usepackage{url}` to be put in the document header. Also, changes+      to state in enumerated list items would be overwritten.+    + In Markdown writer, escape paragraphs that begin with ordered list+      markers, so they don't get interpreted as ordered lists.++  * Text.Pandoc.Reades.LaTeX:++    + Fixed bug in LaTeX reader, which wrongly assumed that the roman+      numeral after "enum" in "setcounter" would consist entirely of+      "i"s. 'enumiv' is legitimate.+    + LaTeX command and environment names can't contain numbers.+    + Rearranged order of parsers in inline for slight speed improvement.+    + Added '`' to special characters and 'unescapedChar'.++  * Text.Pandoc.Readers.RST:++    + Removed unneeded try's in RST reader; also minor code cleanup.+    + Removed tabchar.+    + Rearranged parsers in inline (doubled speed).++  * Text.Pandoc.Readers.Markdown:++    + Skip notes parsing if running in strict mode. (This yields a nice+      speed improvement in strict mode.)+    + Simplify autolink parsing code, using Network.URI to test for+      URIs. Added dependency on network library to debian/control and+      pandoc.cabal.+    + More perspicuous definition of nonindentSpaces.+    + Removed unneeded 'try' in 'rawLine'.+    + Combined linebreak and whitespace into a new whitespace parser, to+      avoid unnecessary reparsing of space characters.+    + Removed unnecessary 'try' in 'codeBlock', 'ellipses', 'noteMarker',+      'multilineRow', 'dashedLine', 'rawHtmlBlocks'.+    + Use lookAhead in parsers for setext headers and definition lists+      to see if the next line begins appropriately; if not, don't waste+      any more time parsing.+    + Don't require blank lines after code block. (It's sufficient to+      end code block with a nonindented line.)+    + Changed definition of 'emph': italics with '_' must not+      be followed by an alphanumeric character. This is to help+      prevent interpretation of e.g. `[LC_TYPE]: my_type` as+      `[LC<em>TYPE]:my</em>type`.+    + Improved Markdown.pl-compatibility in referenceLink: the two parts+      of a reference-style link may be separated by one space, but not+      more... [a] [link], [not]    [a link].+    + Fixed markdown inline code parsing so it better accords with+      Markdown.pl: the marker for the end of the code section is a clump+      of the same number of `'s with which the section began, followed+      by a non-` character. So, for example,+         ` h ``` i ` -> `<code>h ``` i</code>`.+    + Split 'title' into 'linkTitle' and 'referenceTitle', since the+      rules are slightly different.+    + Rewrote 'para' for greater efficiency.+    + Rewrote link parsers for greater efficiency.+    + Removed redundant 'referenceLink' in definition of inline (it's+      already in 'link').+    + Refactored escapeChar so it doesn't need 'try'.+    + Refactored hrule for performance in Markdown reader.+    + More intelligent rearranging of 'inline' so that most frequently+      used parsers are tried first.+    + Removed tabchar parser, as whitespace handles tabs anyway.++  * Text.Pandoc.CharacterReferences:++    + Refactored.+    + Removed unnecessary 'try's for a speed improvement.+    + Removed unnecessary '&' and ';' from the entity table.++  * Build process:++    + Makefile: Get VERSION from cabal file, not Main.hs.+    + Modified MacPorts Portfile:+        - Depend on haddock+        - Build and install libraries and library documentation in+          addition to pandoc executable+        - Added template item for md5 sum in Portfile.in.+        - Incorporated changes from MacPorts repository (r28278).+    + FreeBSD port:  Don't try to generate distinfo in Makefile.+      It can be made using 'make makesum' in FreeBSD.+    + Make both freebsd and macports targets depend on tarball.++  * Website and documentation:++    + Updated INSTALL instructions.+    + Added pandocwiki demo to website.+    + Removed local references to Portfile, since pandoc is now in the+      MacPorts repository.++## pandoc 0.42 (2007-08-26)++  [ John MacFarlane ]++  * Main.hs: Use utf8 conversion on the extra files loaded with+    the -H, -C, -B, and -A options.  This fixes problems with unicode+    characters in these files.++  * Exposed Text.Pandoc.ASCIIMathML, since it is imported in+    Text.Pandoc.Readers.HTML and without it we get a linking error when+    using the library.++  * Markdown reader:++    + Added new rule for enhanced markdown ordered lists: if the list+      marker is a capital letter followed by a period (including a+      single-letter capital roman numeral), then it must be followed by+      at least two spaces. The point of this is to avoid accidentally+      treating people's initials as list markers: a paragraph might begin,+      "B. Russell was an English philosopher," and this shouldn't be+      treated as a list.  Documented change in README.+    + Blocks that start with "p. " and a digit are no longer treated+      as ordered lists (it's a page number).+    + Added a needed 'try' to listItem.+    + Removed check for a following setext header in endline.+      A full test is too inefficient (doubles benchmark time), and the+      substitute we had before is not 100% accurate.+    + Don't use Code elements for autolinks if --strict specified.++  * LaTeX writer:  When a footnote ends with a Verbatim environment, the+    close } of the footnote cannot occur on the same line or an error occurs.+    Fixed this by adding a newline before the closing } of every footnote.++  * HTML writer:+    + Removed incorrect "{}" around style information in HTML tables.+      Column widths now work properly in HTML.+    + If --strict option is specified (and --toc is not), don't include+      identifiers in headers, for better Markdown compatibility.++  * Build process:++    + Separated $(web_dest) and website targets.+    + In website, index.txt is now constructed from template index.txt.in.+    + Added freebsd target to Markefile. This creates the freebsd Makefile+      from Makefile.in, and creates distinfo.  Removed Makefile and distinfo+      from the repository.+    + Added macport target to Makefile. Portfile is built from template+      Portfile.in.+    + Removed OSX package targets.  (Too many difficulties involving+      dependencies on dynamic libraries.)+    + More complete INSTALL instructions for all architectures.++  * Website:+    + Added a programming demo, pandocwiki.++  [ Recai Oktaş ]++  * Do not forget to close pandoc's ITP.  Closes: #391666++## pandoc 0.41 (2007-08-19)++  [ John MacFarlane ]++  * Fixed bugs in HTML reader:+    + Skip material at end *only if* `</html>` is present (previously,+      only part of the document would be parsed if an error was+      found; now a proper error message is given).+    + Added new constant eitherBlockOrInline with elements that may+      count either as block-level or as inline. Modified isInline and+      isBlock to take this into account.+    + Modified rawHtmlBlock to accept any tag (even an inline tag):+      this is innocuous, because rawHtmlBlock is tried only if a regular+      inline element can't be parsed.+    + Added a necessary 'try' in definition of 'para'.++  * Fixed bug in markdown ordered list parsing.  The problem was that+    anyOrderedListStart did not check for a space following the+    ordered list marker.  So in 'A.B. 2007' the parser would be+    expecting a list item, but would not find one, causing an error.+    Fixed a similar bug in the RST reader.  Resolves Issue #22.++  * Refactored RST and Markdown readers using parseFromString.++  * LaTeX reader will now skip anything after \end{document}.++  * Fixed blockquote output in markdown writer: previously, block+    quotes in indented contexts would be indented only in the first+    line.++  * Added note to INSTALL about variations in versions of the xhtml+    library that can lead to failed tests (thanks to Leif LeBaron).++## pandoc 0.4 (2007-01-16)++  [ John MacFarlane ]++  * Added two new output formats: groff man pages and ConTeXt. By+    default, output files with extensions ".ctx" and ".context" are+    assumed to be ConTeXt, and output files with single-digit extensions+    are assumed to be man pages.++  * Enhanced ordered lists (documented in README, under Lists):+    + The OrderedList block element now stores information about+      list number style, list number delimiter, and starting number.+    + The readers parse this information when possible.+    + The writers use this information to style ordered lists.+    + The enhancement can be disabled using the --strict option.++  * Added support for tables (with a new Table block element). Two kinds+    of tables are supported: a simple table with one-line rows, and a+    more complex variety with multiline rows. All output formats are+    supported, but only markdown tables are parsed at the moment. The+    syntax is documented in README.++  * Added support for definition lists (with a new DefinitionList block+    element). All output and input formats are supported. The syntax is+    documented in README.++  * Added support for superscripts and subscripts (with new Superscript+    and Subscript inline elements).  All input and output+    formats.  The syntax is documented in README.++  * Added support for strikeout (with a new Strikeout inline element).+    All input and output formats are supported. Thanks to Bradley Kuhn,+    who contributed a patch. The syntax is documented in README. Resolves+    Issue #18.++  * Added a --toc|--table-of-contents option.  This causes an automatically+    generated table of contents (or an instruction that creates one) to+    be inserted at the beginning of the document. Not supported in S5,+    DocBook, or man page writers.++  * Modified the -m|--asciimathml option:++    + If an optional URL argument is provided, a link is inserted+      instead of the contents of the ASCIIMathML.js script.+    + Nothing is inserted unless the document actually contains+      LaTeX math.++  * Removed Blank block element as unnecessary.++  * Removed Key and Note blocks from the Pandoc data structure. All+    links are now stored as explicit links, and note contents are+    stored with the (inline) notes.++    + All link Targets are now explicit (URL, title) pairs; there+      is no longer a 'Ref' target.+    + Markdown and RST parsers now need to extract data from key and+      note blocks and insert them into the relevant inline elements.+      Other parsers have been simplified, since there is no longer any need+      to construct separate key and note blocks.+    + Markdown, RST, and HTML writers need to construct lists of+      notes; Markdown and RST writers need to construct lists of link+      references (when the --reference-links option is specified); and+      the RST writer needs to construct a list of image substitution+      references. All writers have been rewritten to use the State monad+      when state is required.+    + Several functions (generateReference, keyTable,+      replaceReferenceLinks, replaceRefLinksBlockList, and some auxiliaries+      used by them) have been removed from Text.Pandoc.Shared, since+      they are no longer needed. New functions and data structures+      (Reference, isNoteBlock, isKeyBlock, isLineClump) have been+      added. The functions inTags, selfClosingTag, inTagsSimple, and+      inTagsIndented have been moved to the DocBook writer, since that+      is now the only module that uses them. NoteTable is now exported+      in Text.Pandoc.Shared.+    + Added stateKeys and stateNotes to ParserState; removed stateKeyBlocks,+      stateKeysUsed, stateNoteBlocks, stateNoteIdentifiers, stateInlineLinks.+    + Added writerNotes and writerReferenceLinks to WriterOptions.++  * Added Text.Pandoc module that exports basic readers, writers,+    definitions, and utility functions. This should export everything+    needed for most uses of Pandoc libraries. The haddock documentation+    includes a short example program.++  * Text.Pandoc.ASCIIMathML is no longer an exported module.++  * Added Text.Pandoc.Blocks module to help in printing markdown+    and RST tables.  This module provides functions for working with+    fixed-width blocks of text--e.g., placing them side by side, as+    in a table row.++  * Refactored to avoid reliance on Haskell's Text.Regex library, which+    (a) is slow, and (b) does not properly handle unicode.  This fixed+    some strange bugs, e.g. in parsing S-cedilla, and improved performance.++    + Replaced 'gsub' with a general list function  'substitute'+      that does not rely on Text.Regex.+    + Rewrote extractTagType in HTML reader so that it doesn't use+      regexs.+    + In Markdown reader, replaced email regex test with a custom email+      autolink parser (autoLinkEmail). Also replaced selfClosingTag regex+      with a custom function isSelfClosingTag.+    + Modified Docbook writer so that it doesn't rely on Text.Regex for+      detecting 'mailto' links.+    + Removed escapePreservingRegex and reamped entity-handling+      functions in Text.Pandoc.Shared and Text.Pandoc.CharacterReferences to+      avoid reliance on Text.Regex (see below on character reference+      handling changes).++  * Renamed Text.Pandoc.Entities as Text.Pandoc.CharacterReferences.++  * Changed handling of XML entities.  Entities are now parsed (and unicode+    characters returned) in the Markdown and HTML readers, rather than being+    handled in the writers.  In HTML and Docbook writers, UTF-8 is now used+    instead of entities for characters above 128.  This makes the HTML and+    DocBook output much more readable and more easily editable.++    + Removed sgmlHexEntity, sgmlDecimalEntity, sgmlNamedEntity, and+      sgmlCharacterEntity regexes from Text.Pandoc.Shared.+    + Renamed escapeSGMLChar to escapeCharForXML.  Added escapeStringForXML.+      Moved both functions to Text.Pandoc.Writers.Docbook.+    + Added characterReference parser to Text.Pandoc.CharacterReferences.+      This parses a string and return a unicode character.+    + Rewrote decodeCharacterReferences to use the new parser instead of+      Text.Regex.+    + Added new charRef parser for Markdown and HTML, which replaces the+      old 'entity' parser. Added '&' as a special character in Markdown reader.+    + Modified HTML and Markdown readers to call decodeEntities on all raw+      strings (e.g. authors, dates, link titles), to ensure that no+      unprocessed entities are included in the native representation of+      the document.  (In the HTML reader, most of this work is done by a+      change in extractAttributeName.)+    + In XML and Markdown output, escape unicode nonbreaking space as '&nbsp;',+      since a unicode non-breaking space is impossible to distinguish visually+      from a regular space.  (Resolves Issue #3.)+    + Removed encodeEntitiesNumerical.+    + Use Data.Map for entityTable and (new) reverseEntityTable, for a+      slight performance boost over the old association list.+    + Removed unneeded decodeEntities from 'str' parser in HTML and+      Markdown readers.++  * Text.Pandoc.UTF8:  Renamed encodeUTF8 to toUTF8, decodeUTF8 to+    fromUTF8, for clarity.++  * Replaced old haskell98 module names replaced by hierarchical module+    names, e.g. List by Data.List.  Removed haskell98 from dependencies+    in pandoc.cabal, and added mtl (needed for state monad). Substituted+    xhtml for html.++  * Refactored and cleaned up character escaping in writers, using+    backslashEscapes and escapeStringUsing functions.++  * Instead of adding `\n\n` to the end of an input string in Main.hs,+    this is now done in the readers. This makes the libraries behave+    the way you'd expect from the pandoc program. Resolves Issue #10.++  * URLs and email addresses in autolinks are now typeset as Code.++  * In Main.hs, changed putStr to putStrLn -- mainly because MacOS X+    doesn't display the whole output unless there's a line ending.++  * Major code cleanup in all modules, for greater consistency, concision,+    and readability.++  * HTML reader:++    + Fixed several bugs (extractTagType, attribute parsing).+    + Remove Null blocks in lists of blocks when possible.+    + Allow HTML comments as raw HTML inline.++  * Markdown reader:++    + Ordered list items may no longer begin with uppercase letters, or+      letters greater than 'n'.  (This prevents first initials and page+      reference, e.g. 'p. 400', from being parsed as beginning lists.)+      Also, numbers beginning list items may no longer end with ')',+      which is now allowed only after letters.  Note: These changes+      may cause documents to be parsed differently. Users should take+      care in upgrading.+    + Changed autoLink parsing to conform better to Markdown.pl's+      behavior. `<google.com>` is not treated as a link, but+      `<http://google.com>`, `<ftp://google.com>`, and+      `<mailto:google@google.com>` are.+    + Cleaned up handling of embedded quotes in link titles.  Now these are+      stored as a '"' character, not as '&quot;'.+    + Use lookAhead parser for the 'first pass' (looking for reference keys),+      instead of parsing normally, then using setInput to reset input.  This+      yields a slight performance boost.+    + Fixed several bugs in smart quote recognition.+    + Fixed bug in indentSpaces (which didn't properly handle+      cases with mixed spaces and tabs).+    + Consolidated 'text', 'special', and 'inline' into 'inline'.+    + Fixed bug which allowed URL and title to be separated by multiple blank+      lines in links and reference keys.  They can be on separate lines but+      can't have blank lines between them.+    + Correctly handle bracketed text inside inline footnotes and links,using+      new function inlinesInBalanced.  Resolves Issue #14.+    + Fixed bug in footnotes: links in footnotes were not being+      processed. Solution: three-stage parse. First, get all the+      reference keys and add information to state. Next, get all the+      notes and add information to state. (Reference keys may be needed+      at this stage.) Finally, parse everything else.+    + Replaced named constants like 'emphStart' with literals.+    + Removed an extra occurrence of escapedChar in definition of inline.++  * RST reader:++    + Allow the URI in a RST hyperlink target to start on the line+      after the reference key.+    + Added 'try' in front of 'string', where needed, or used a different+      parser.  This fixes a bug where ````` would not be correctly parsed as+      a verbatim `.+    + Fixed slow performance in parsing inline literals in RST reader.  The+      problem was that ``#`` was seen by 'inline' as a potential link or image.+      Fix:  inserted 'notFollowedBy (char '`')' in link parsers.+      Resolves Issue #8.+    + Use lookAhead instead of getInput/setInput in RST reader.  Removed+      unneeded getState call, since lookAhead automatically saves and+      restores the parser state.+    + Allow hyperlink target URIs to be split over multiple lines, and+      to start on the line after the reference. Resolves Issue #7.+    + Fixed handling of autolinks.++  * LaTeX reader:++    + Replaced `choice [(try (string ...), ...]` idiom with `oneOfStrings`,+      for clarity.+    + Added clauses for tilde and caret. Tilde is `\ensuremath{\sim}`, and+      caret is `\^{}`, not `\^` as before.+    + Added parsing for `\url`.+    + Parse `\texttt{}` as code, provided there's nothing fancy inside.++  * HTML writer:++    + Modified HTML writer to use the Text.XHtml library. This results+      in cleaner, faster code, and it makes it easier to use Pandoc in+      other projects, like wikis, which use Text.XHtml. Two functions are+      now provided, writeHtml and writeHtmlString: the former outputs an+      Html structure, the latter a rendered string. The S5 writer is also+      changed, in parallel ways (writeS5, writeS5String).+    + The Html header is now written programmatically, so it has been+      removed from the 'headers' directory. The S5 header is still+      needed, but the doctype and some of the meta declarations have+      been removed, since they are written programmatically. This change+      introduces a new dependency on the xhtml package.+    + Fixed two bugs in email obfuscation involving improper escaping+      of '&' in the `<noscript>` section and in `--strict` mode. Resolves+      Issue #9.+    + Fixed another bug in email obfuscation: If the text to be obfuscated+      contains an entity, this needs to be decoded before obfuscation.+      Thanks to thsutton for the patch. Resolves Issue #15.+    + Changed the way the backlink is displayed in HTML footnotes.+      Instead of appearing on a line by itself, it now generally+      appears on the last line of the note.  (Exception:  when the+      note does not end with a Plain or Para block.) This saves space+      and looks better.+    + Added automatic unique identifiers to headers:+      - The identifier is derived from the header via a scheme+        documented in README.+      - WriterState now includes a list of header identifiers and a table+        of contents in addition to notes.+      - The function uniqueIdentifiers creates a list of unique identifiers+        from a list of inline lists (e.g. headers).+      - This list is part of WriterState and gets consumed by blockToHtml+        each time a header is encountered.+    + Include CSS for .strikethrough class in header only if strikethrough+      text appears in the document.+    + If the 'strict' option is specified, elements that do not appear in+      standard markdown (like definition lists) are passed through as+      raw HTML.+    + Simplified treatment of autolinks, using pattern matching instead of+      conditionals.++  * Markdown writer:++    + Links in markdown output are now printed as inline links by default,+      rather than reference links.  A --reference-links option has been added+      that forces links to be printed as reference links.  Resolves Issue #4.+    + Use autolinks when possible.  Instead of `[site.com](site.com)`,+      use `<site.com>`.++  * LaTeX writer:++    + Rewrote to use the State monad. The preamble now includes only those+      packages that are actually required, given the document's content.+      Thus, for example, if strikeout is not used, ulem is not required.+      Modified LaTeXHeader accordingly.+    + Modified LaTeX writer to insert `\,` between consecutive quotes.+    + Removed unused function tableRowColumnWidths.+    + Simplified code for escaping special characters.+    + Leave extra blank line after `\maketitle`.+    + Include empty `\author{}` when no author specified to avoid LaTeX+      errors.+    + Include fancyvrb code in header only if needed -- that is, only+      if there is actually code in a footnote.+    + Use `\url{}` for autolinks.+    + Include [mathletters] option in ucs package, so that basic unicode+      Greek letters will work correctly.++  * RST writer:  Force blank line before lists, so that sublists will+    be handled correctly.++  * Docbook writer:  Fixed a bug:  email links with text, like+    [foo](me@bar.baz), were being incorrectly treated as autolinks.++  * Removed Text.ParserCombinators.Pandoc and moved all its functions to+    Text.Pandoc.Shared.++  * Text.Pandoc.Shared:++    + Added defaultWriterOptions.+    + Added writerTableOfContents to WriterOptions.+    + Added writerIgnoreNotes option to WriterOptions.  This is needed+      for processing header blocks for a table of contents, since notes on+      headers should not appear in the TOC.+    + Added prettyprinting for native Table format.+    + Removed some unneeded imports.+    + Moved escape and nullBlock parsers from+      Text.ParserCombinators.Pandoc, since the latter is for+      general-purpose parsers that don't depend on Text.Pandoc.Definition.+    + Moved isHeaderBlock from Text.Pandoc.Writers.HTML.+    + Moved Element, headerAtLeast, and hierarchicalize from Docbook+      writer, because HTML writer now uses these in constructing a table+      of contents.+    + Added clauses for new inline elements (Strikeout, Superscript,+      Subscript) to refsMatch.+    + Removed backslashEscape; added new functions escapeStringUsing and+      backslashEscapes.+    + Moved failIfStrict from markdown reader, since it is now used also+      by the HTML reader.+    + Added a 'try' to the definition of indentSpaces.+    + In definition of 'reference', added check to make sure it's not a note+      reference.+    + Added functions: camelCaseToHyphenated, toRomanNumeral,+      anyOrderedListMarker, orderedListmarker, orderedListMarkers,+      charsInBalanced', withHorizDisplacement, romanNumeral+    + Fixed a bug in the anyLine parser. Previously it would parse an empty+      string "", but it should fail on an empty string, or we get an error+      when it is used inside "many" combinators.+    + Removed followedBy' parser, replacing it with the lookAhead parser from+      Parsec.+    + Added some needed 'try's before multicharacter parsers, especially in+      'option' contexts.+    + Removed the 'try' from the 'end' parser in 'enclosed', so that+      'enclosed' behaves like 'option', 'manyTill', etc.+    + Added lineClump parser, which parses a raw line block up to and+      including any following blank lines.+    + Renamed parseFromStr to parseFromString.+    + Added a 'try' to the 'end' parser in 'enclosed'.  This makes errors in+      the use of 'enclosed' less likely. Removed some now-unnecessary 'try's+      in calling code.+    + Removed unneeded 'try' in blanklines.+    + Removed endsWith function and rewrote calling functions to use+      isSuffixOf instead.+    + Added >>~ combinator.+    + Fixed bug in normalizeSpaces:  Space:Str "":Space should compress to+      Space.++  * Refactored runtests.pl; added separate tests for tables.++  * Shell scripts:++    + Added -asxhtml flag to tidy in html2markdown. This will+      perhaps help the parser, which expects closing tags.+    + Modified markdown2pdf to run pdflatex a second time if --toc or+      --table-of-contents was specified; otherwise the table of+      contents won't appear.+    + Modified markdown2pdf to print a helpful message if the 'ulem'+      LaTeX package is required and not found.++  * Changes to build process:++    + Dropped support for compilation with GHC 6.4.  GHC 6.6 or higher+      is now required.+    + Removed cabalize and Pandoc.cabal.in. The repository now contains+      pandoc.cabal itself.+    + Pandoc.cabal has been changed to pandoc.cabal, because HackageDB+      likes the cabal file to have the same name as the tarball.+    + Expanded and revised the package description in pandoc.cabal.+      Revised the package synopsis.+    + The tarball built by 'make tarball' now contains files built from+      templates (including man pages and shell scripts), so pandoc can+      be built directly using Cabal tools, without preprocessing.+    + Executable binaries are now stripped before installing.+    + Man pages are now generated from markdown sources, using pandoc's+      man page writer.+    + Use HTML version of README (instead of RTF) in Mac OS X installer.+    + Instead of testing for the existence of a pandoc symlink in build-exec,+      use ln -f.++  * Documentation:++    + Updated README and man pages with information on new features.+    + Updated INSTALL instructions with some useful clarifications and+      links.+    + Updated web content.++  * Added FreeBSD port.++  [ Recai Oktaş ]++  * debian/control:++    + Changed pandoc's Build-Depends to include libghc6-mtl-dev and+      libghc6-xhtml-dev.  Removed libghc6-html-dev.+    + Suggest texlive-latex-recommended | tetex-extra instead of+      tetex-bin.  This brings in fancyvrb and unicode support.+++## pandoc 0.3 (2007-01-05)++  [ John MacFarlane ]++  * Changes in pandoc options:++    + Allow options to follow or precede arguments.+    + Changed '--smartypants' to '--smart' and adjusted symbols accordingly.+    + Added '--strict' option.+    + Added '-o/--output' option.+    + Added '--dump-args' and '--ignore-args' options (for use in wrappers).+    + Modified '-v' and '-h' output to go to STDERR, not STDOUT, and return+      error conditions.  This is helpful for writing wrappers.+    + Added copyright message to '-v' output, modeled after FSF messages.+    + Reformatted usage message so that it doesn't wrap illegibly.+    + Removed extra blanks after '-h' and '-D' output.++  * Added docbook writer.++  * Added implicit setting of default input and output format based+    on input and output filename extensions.  These defaults are+    overridden if explicit input and output formats are specified using+    '-t', '-f', '-r', or '-w' options.  Documented in pandoc(1) man page+    and README.++  * Allow ordered list items to begin with (single) letters, as well+    as numbers.  The list item marker may now be terminated either by+    '.' or by ')'.  This extension to standard markdown is documented+    in README.++  * Revised footnote syntax.  (See README for full details.)  The+    '[^1]' format now standard in markdown extensions is supported,+    as are inline footnotes with this syntax: `^[My note.]`.+    The earlier footnote syntax `^(1)` is no longer supported.++  * Improved HTML representation of footnotes.  All footnotes+    are now auto-numbered and appear in an ordered list at the+    end of the HTML document.  Since the default appearance is now+    acceptable, the old footnote styles have been removed from the+    HTML header.++  * Bug fixes:++    + Fixed a serious bug in the markdown, LaTeX, and RST readers.+      These readers ran 'runParser' on processed chunks of text to handle+      embedded block lists in lists and quotation blocks.  But then+      any changes made to the parser state in these chunks was lost,+      as the state is local to the parser.  So, for example, footnotes+      didn't work in quotes or list items.  The fix:  instead of calling+      runParser on some raw text, use setInput to make it the input, then+      parse it, then use setInput to restore the input to what it was+      before.  This is shorter and more elegant, and it fixes the problem.+    + Fixed bug in notFollowedBy' combinator (adding 'try' before+      'parser').  Adjusted code that uses this combinator accordingly.+    + Fixed bug in RTF writer that caused improper indentation on+      footnotes occurring in indented blocks like lists.+    + Fixed parsing of metadata in LaTeX reader.  Now the title, author,+      and date are parsed correctly.  Everything else in the preamble+      is skipped.+    + Modified escapedChar in LaTeX reader to allow a `\` at the end of a+      line to count as escaped whitespace.+    + Modified LaTeX reader to produce inline links rather than reference+      links.  Otherwise, links in footnotes aren't handled properly.+    + Fixed handling of titles in links in Markdown reader, so that+      embedded quotation marks are now handled properly.+    + Fixed Markdown reader's handling of embedded brackets in links.+    + Fixed Markdown reader so that it only parses bracketed material+      as a reference link if there is actually a corresponding key.+    + Revised inline code parsing in Markdown reader to conform to+      markdown standard.  Now any number of `s can begin inline code,+      which will end with the same number of `s.  For example, to+      have two backticks as code, write ``` `` ```.  Modified Markdown+      writer accordingly.+    + Fixed bug in text-wrapping routine in Markdown and RST writers.+      Now LineBreaks no longer cause wrapping problems.+    + Supported hexadecimal numerical entity references as well as+      decimal ones.+    + Fixed bug in Markdown reader's handling of underscores and other+      inline formatting markers inside reference labels:  for example,+      in '[A_B]: /url/a_b', the material between underscores was being+      parsed as emphasized inlines.+    + Changed Markdown reader's handling of backslash escapes so that+      only non-alphanumeric characters can be escaped.  Strict mode+      follows Markdown.pl in only allowing a select group of punctuation+      characters to be escaped.+    + Modified HTML reader to skip a newline following a `<br>` tag.+      Otherwise the newline will be treated as a space at the beginning+      of the next line.++  * Made handling of code blocks more consistent.  Previously, some+    readers allowed trailing newlines, while others stripped them.+    Now, all readers strip trailing newlines in code blocks. Writers+    insert a newline at the end of code blocks as needed.++  * Modified readers to make spacing at the end of output more consistent.++  * Minor improvements to LaTeX reader:++    + `\thanks` now treated like a footnote.+    + Simplified parsing of LaTeX command arguments and options.+      commandArgs now returns a list of arguments OR options (in+      whatever order they appear).  The brackets are included, and+      a new stripFirstAndLast function is provided to strip them off+      when needed.  This fixes a problem in dealing with \newcommand+      and \newenvironment.++  * Revised RTF writer:++    + Default font is now Helvetica.+    + An `\f0` is added to each `\pard`, so that font resizing works+      correctly.++  * Moved handling of "smart typography" from the writers to the Markdown+    and LaTeX readers.  This allows great simplification of the writers+    and more accurate smart quotes, dashes, and ellipses.  DocBook can+    now use `<quote>`.  The '--smart' option now toggles an option in+    the parser state rather than a writer option.  Several new kinds+    of inline elements have been added: Quoted, Ellipses, Apostrophe,+    EmDash, EnDash.++  * Changes in HTML writer:++    + Include title block in header even when title is null.+    + Made javascript obfuscation of emails even more obfuscatory,+      by combining it with entity obfuscation.++  * Changed default ASCIIMathML text color to black.++  * Test suite:++    + Added --strip-trailing-cr option to diff in runtests.pl, for+      compatibility with Windows.+    + Added regression tests with footnotes in quote blocks and lists.++  * Makefile changes:++    + osx-pkg target creates a Mac OS X package (directory). New osx+      directory contains files needed for construction of the package.+    + osx-dmg target creates a compressed disk image containing the package.+    + win-pkg target creates Windows binary package.+    + tarball target creates distribution source tarball.+    + website target generates pandoc's website automatically, including+      demos.  New 'web' directory contains files needed for construction+      of the website (which will be created as the 'pandoc' subdirectory+      of 'web').+    + Makefile checks to see if we're running Windows/Cygwin; if so,+      a '.exe' extension is added to each executable in EXECS.++  * Removed all wrappers except markdown2pdf and html2markdown.++  * Added new wrapper hsmarkdown, to be used as a drop-in replacement+    for Markdown.pl.  hsmarkdown calls pandoc with the '--strict'+    option and disables other options.++  * Added code to html2markdown that tries to determine the character+    encoding of an HTML file, by parsing the "Content-type" meta tag.++    + If the encoding can't be determined, then if the content is local,+      the local encoding is used; if it comes from a URL, UTF-8 is used+      by default.+    + If input is from STDIN, don't try to determine character encoding.+    + Encoding can be specified explicitly using '-e' option.++  * Improved warning messages in wrappers:++    + Print warning if iconv not available+    + More user-friendly error messages in markdown2pdf, when+      pdflatex fails.++  * Code cleanup:++    + Renamed 'Text/Pandoc/HtmlEntities' module to+      'Text/Pandoc/Entities'. Also changed function names so as+      not to be HTML-specific.+    + Refactored SGML string escaping functions from HTML and Docbook+      writers into Text/Pandoc/Shared.  (escapeSGML, stringToSGML)+    + Removed 'BlockQuoteContext' from ParserContext, as it isn't+      used anywhere.+    + Removed splitBySpace and replaced it with a general, polymorphic+      splitBy function.+    + Refactored LaTeX reader for clarity (added isArg function).+    + Converted some CR's to LF's in src/ui/default/print.css.+    + Added license text to top of source files.+    + Added module data for haddock to source files.+    + Reformatted code for consistency.++  * Rewrote documentation and man pages.  Split README into INSTALL+    and README.++  * Split LICENSE into COPYING and COPYRIGHT.++  * Removed TODO, since we now maintain ToDo on the wiki.++  * Made COPYRIGHT in top level a symlink to debian/copyright, to avoid+    duplication.++  [ Recai Oktaş ]++  * Revamped build process to conform to debian standards and created+    a proper debian package.  Closes: #391666.++  * Modified build process to support GHC 6.6.++    + The package can still be compiled using GHC 6.4.2, though because+      of dependencies the "make deb" target works only with GHC 6.6+.+    + The script 'cabalize' is used to create an appropriate+      'Pandoc.cabal' from 'Pandoc.cabal.in', depending on the GHC and+      Cabal versions.++  * Refactored template processing (fillTemplates.pl).++  * Modified wrapper scripts to make them more robust and portable.+    To avoid code duplication and ensure consistency, wrappers are+    generated via a templating system from templates in src/wrappers.++    + Wrappers now accept multiple filenames, when appropriate.+    + Spaces and tabs allowed in filenames.+    + getopts shell builtin is used for portable option parsing.+    + Improved html2markdown's web grabber code, making it more robust,+      configurable and verbose.  Added '-e', '-g' options.+++## pandoc 0.2 (2006-08-14)++  * Fixed unicode/utf-8 translation++## pandoc 0.1 (2006-08-14)++  * Initial creation of debian package+
data/docx/word/styles.xml view
@@ -138,7 +138,7 @@       <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />       <w:b />       <w:bCs />-      <w:color w:val="345A8A" w:themeColor="accent1" w:themeShade="B5" />+      <w:color w:val="4F81BD" w:themeColor="accent1" />       <w:sz w:val="32" />       <w:szCs w:val="32" />     </w:rPr>@@ -161,8 +161,8 @@       <w:b />       <w:bCs />       <w:color w:val="4F81BD" w:themeColor="accent1" />-      <w:sz w:val="32" />-      <w:szCs w:val="32" />+      <w:sz w:val="28" />+      <w:szCs w:val="28" />     </w:rPr>   </w:style>   <w:style w:type="paragraph" w:styleId="Heading3">@@ -183,8 +183,8 @@       <w:b />       <w:bCs />       <w:color w:val="4F81BD" w:themeColor="accent1" />-      <w:sz w:val="28" />-      <w:szCs w:val="28" />+      <w:sz w:val="24" />+      <w:szCs w:val="24" />     </w:rPr>   </w:style>   <w:style w:type="paragraph" w:styleId="Heading4">@@ -202,7 +202,7 @@     </w:pPr>     <w:rPr>       <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />-      <w:b />+      <w:i />       <w:bCs />       <w:color w:val="4F81BD" w:themeColor="accent1" />       <w:sz w:val="24" />@@ -224,7 +224,6 @@     </w:pPr>     <w:rPr>       <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />-      <w:i />       <w:iCs />       <w:color w:val="4F81BD" w:themeColor="accent1" />       <w:sz w:val="24" />@@ -320,14 +319,8 @@     <w:qFormat />     <w:pPr>       <w:spacing w:before="100" w:after="100" />-      <w:ind w:firstLine="0" />+      <w:ind w:firstLine="0" w:left="480" w:right="480" />     </w:pPr>-    <w:rPr>-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />-      <w:bCs />-      <w:sz w:val="20" />-      <w:szCs w:val="20" />-    </w:rPr>   </w:style>   <w:style w:type="paragraph" w:styleId="FootnoteText">     <w:name w:val="Footnote Text" />
data/epub.css view
@@ -22,3 +22,4 @@ span.underline{ text-decoration: underline; } q { quotes: "“" "”" "‘" "’"; } div.column{ display: inline-block; vertical-align: top; width: 50%; }+div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
data/jats.csl view
@@ -37,9 +37,9 @@     </names>   </macro> -  <macro name="editor">+  <macro name="editor" delimiter=" ">     <names variable="editor" prefix="{{jats}}&lt;person-group person-group-type=&quot;editor&quot;&gt;{{/jats}}" suffix="{{jats}}&lt;/person-group&gt;{{/jats}}">-      <name prefix="{{jats}}&lt;name&gt;{{/jats}}" suffix="{{jats}}&lt;/name&gt;{{/jats}}" name-as-sort-order="all" sort-separator="">+      <name prefix="{{jats}}&lt;name&gt;{{/jats}}" suffix="{{jats}}&lt;/name&gt;{{/jats}}" name-as-sort-order="all" sort-separator=" ">         <name-part name="family" text-case="capitalize-first" prefix="{{jats}}&lt;surname&gt;{{/jats}}" suffix="{{jats}}&lt;/surname&gt;{{/jats}}"/>         <name-part name="given" text-case="capitalize-first" prefix="{{jats}}&lt;given-names&gt;{{/jats}}" suffix="{{jats}}&lt;/given-names&gt;{{/jats}}"/>       </name>
data/pandoc.lua view
@@ -28,6 +28,7 @@ M.List = require 'pandoc.List' M.mediabag = require 'pandoc.mediabag' M.system = require 'pandoc.system'+M.types = require 'pandoc.types' M.utils = require 'pandoc.utils' M.text = require 'text' @@ -49,11 +50,15 @@ -- @param indices list of indices, starting with the most deeply nested -- @return newly created function -- @local-function make_indexing_function(template, indices)+function make_indexing_function(template, ...)+  local indices = {...}   local loadstring = loadstring or load   local bracketed = {}   for i = 1, #indices do-    bracketed[i] = string.format('[%d]', indices[#indices - i + 1])+    local idx = indices[#indices - i + 1]+    bracketed[i] = type(idx) == 'number'+      and string.format('[%d]', idx)+      or string.format('.%s', idx)   end   local fnstr = string.format('return ' .. template, table.concat(bracketed))   return assert(loadstring(fnstr))()@@ -68,11 +73,16 @@   local res = {}   function add_accessors(acc, ...)     if type(acc) == 'string' then-      res[acc] = make_indexing_function(fn_template, {...})+      res[acc] = make_indexing_function(fn_template, ...)     elseif type(acc) == 'table' and #acc == 0 and next(acc) then+      -- Named substructure: the given names are accessed via the substructure,+      -- but the accessors are also added to the result table, enabling direct+      -- access from the parent element. Mainly used for `attr`.       local name, substructure = next(acc)-      res[name] = make_indexing_function(fn_template, {...})-      add_accessors(substructure, ...)+      res[name] = make_indexing_function(fn_template, ...)+      for _, subname in ipairs(substructure) do+        res[subname] = make_indexing_function(fn_template, subname, ...)+      end     else       for i = 1, #(acc or {}) do         add_accessors(acc[i], i, ...)@@ -271,6 +281,35 @@   return {inlines, blocks} end +--- Split a string into it's words, using whitespace as separators.+local function words (str)+  local ws = {}+  for w in str:gmatch("([^%s]+)") do ws[#ws + 1] = w end+  return ws+end++--- Try hard to turn the arguments into an Attr object.+local function ensureAttr(attr)+  if type(attr) == 'table' then+    if #attr > 0 then return M.Attr(table.unpack(attr)) end++    -- assume HTML-like key-value pairs+    local ident = attr.id or ''+    local classes = words(attr.class or '')+    local attributes = attr+    attributes.id = nil+    attributes.class = nil+    return M.Attr(ident, classes, attributes)+  elseif attr == nil then+    return M.Attr()+  elseif type(attr) == 'string' then+    -- treat argument as ID+    return M.Attr(attr)+  end+  -- print(arg, ...)+  error('Could not convert to Attr')+end+ ------------------------------------------------------------------------ --- Pandoc Document -- @section document@@ -280,6 +319,7 @@ -- @tparam      {Block,...} blocks      document content -- @tparam[opt] Meta        meta        document meta data M.Pandoc = AstElement:make_subtype'Pandoc'+M.Pandoc.behavior.clone = M.types.clone.Pandoc function M.Pandoc:new (blocks, meta)   return {     blocks = ensureList(blocks),@@ -299,6 +339,7 @@ -- @function Meta -- @tparam meta table table containing document meta information M.Meta = AstElement:make_subtype'Meta'+M.Meta.behavior.clone = M.types.clone.Meta function M.Meta:new (meta) return meta end  @@ -306,6 +347,7 @@ -- MetaValue -- @section MetaValue M.MetaValue = AstElement:make_subtype('MetaValue')+M.MetaValue.behavior.clone = M.types.clone.MetaValue  --- Meta blocks -- @function MetaBlocks@@ -369,6 +411,7 @@  --- Block elements M.Block = AstElement:make_subtype'Block'+M.Block.behavior.clone = M.types.clone.Block  --- Creates a block quote element -- @function BlockQuote@@ -397,7 +440,7 @@ -- @treturn     Block                   code block element M.CodeBlock = M.Block:create_constructor(   "CodeBlock",-  function(text, attr) return {c = {attr or M.Attr(), text}} end,+  function(text, attr) return {c = {ensureAttr(attr), text}} end,   {{attr = {"identifier", "classes", "attributes"}}, "text"} ) @@ -421,7 +464,7 @@ M.Div = M.Block:create_constructor(   "Div",   function(content, attr)-    return {c = {attr or M.Attr(), ensureList(content)}}+    return {c = {ensureAttr(attr), ensureList(content)}}   end,   {{attr = {"identifier", "classes", "attributes"}}, "content"} )@@ -435,7 +478,7 @@ M.Header = M.Block:create_constructor(   "Header",   function(level, content, attr)-    return {c = {level, attr or M.Attr(), ensureInlineList(content)}}+    return {c = {level, ensureAttr(attr), ensureInlineList(content)}}   end,   {"level", {attr = {"identifier", "classes", "attributes"}}, "content"} )@@ -542,6 +585,7 @@  --- Inline element class M.Inline = AstElement:make_subtype'Inline'+M.Inline.behavior.clone = M.types.clone.Inline  --- Creates a Cite inline element -- @function Cite@@ -563,7 +607,7 @@ -- @treturn Inline code element M.Code = M.Inline:create_constructor(   "Code",-  function(text, attr) return {c = {attr or M.Attr(), text}} end,+  function(text, attr) return {c = {ensureAttr(attr), text}} end,   {{attr = {"identifier", "classes", "attributes"}}, "text"} ) @@ -588,8 +632,7 @@   "Image",   function(caption, src, title, attr)     title = title or ""-    attr = attr or M.Attr()-    return {c = {attr, ensureInlineList(caption), {src, title}}}+    return {c = {ensureAttr(attr), ensureInlineList(caption), {src, title}}}   end,   {{attr = {"identifier", "classes", "attributes"}}, "caption", {"src", "title"}} )@@ -613,7 +656,7 @@   "Link",   function(content, target, title, attr)     title = title or ""-    attr = attr or M.Attr()+    attr = ensureAttr(attr)     return {c = {attr, ensureInlineList(content), {target, title}}}   end,   {{attr = {"identifier", "classes", "attributes"}}, "content", {"target", "title"}}@@ -737,7 +780,7 @@ M.Span = M.Inline:create_constructor(   "Span",   function(content, attr)-    return {c = {attr or M.Attr(), ensureInlineList(content)}}+    return {c = {ensureAttr(attr), ensureInlineList(content)}}   end,   {{attr = {"identifier", "classes", "attributes"}}, "content"} )@@ -896,16 +939,21 @@   identifier = identifier or ''   classes = ensureList(classes or {})   attributes = setmetatable(to_alist(attributes or {}), AttributeList)-  return {identifier, classes, attributes}+  return setmetatable({identifier, classes, attributes}, self.behavior) end+M.Attr.behavior.clone = M.types.clone.Attr+M.Attr.behavior.tag = 'Attr' M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3} M.Attr.behavior.__eq = utils.equals M.Attr.behavior.__index = function(t, k)-  return rawget(t, getmetatable(t)._field_names[k]) or+  return (k == 't' and t.tag) or+    rawget(t, getmetatable(t)._field_names[k]) or     getmetatable(t)[k] end M.Attr.behavior.__newindex = function(t, k, v)-  if getmetatable(t)._field_names[k] then+  if k == 'attributes' then+    rawset(t, 3, setmetatable(to_alist(v or {}), AttributeList))+  elseif getmetatable(t)._field_names[k] then     rawset(t, getmetatable(t)._field_names[k], v)   else     rawset(t, k, v)@@ -920,8 +968,27 @@   return make_next_function(fields), t, nil end +-- Monkey-patch setters for `attr` fields to be more forgiving in the input that+-- results in a valid Attr value.+function augment_attr_setter (setters)+  if setters.attr then+    local orig = setters.attr+    setters.attr = function(k, v)+      orig(k, ensureAttr(v))+    end+  end+end+for _, blk in pairs(M.Block.constructor) do+  augment_attr_setter(blk.behavior.setters)+end+for _, inln in pairs(M.Inline.constructor) do+  augment_attr_setter(inln.behavior.setters)+end++ -- Citation M.Citation = AstElement:make_subtype'Citation'+M.Citation.behavior.clone = M.types.clone.Citation  --- Creates a single citation. -- @function Citation@@ -944,6 +1011,7 @@  -- ListAttributes M.ListAttributes = AstElement:make_subtype 'ListAttributes'+M.ListAttributes.behavior.clone = M.types.clone.ListAttributes  --- Creates a set of list attributes. -- @function ListAttributes
data/templates/default.context view
@@ -27,7 +27,6 @@ % make chapter, section bookmarks visible when opening document \placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section] \setupinteractionscreen[option=bookmark]-\setuptagging[state=start]  $if(papersize)$ \setuppapersize[$for(papersize)$$papersize$$sep$,$endfor$]@@ -37,14 +36,18 @@ $endif$ $if(pagenumbering)$ \setuppagenumbering[$for(pagenumbering)$$pagenumbering$$sep$,$endfor$]+$else$+\setuppagenumbering[location={footer,middle}] $endif$ $if(pdfa)$ % attempt to generate PDF/A \setupbackend-  [format=PDF/A-1b:2005,-   intent=sRGB IEC61966-2.1,-   profile=sRGB.icc]+  [format=PDF/A-$pdfa$,+   profile={$if(pdfaiccprofile)$$for(pdfaiccprofile)$$pdfaiccprofile$$sep$,$endfor$$else$sRGB.icc$endif$},+   intent=$if(pdfaintent)$$pdfaintent$$else$sRGB IEC61966-2.1$endif$] $endif$+\setupbackend[export=yes]+\setupstructure[state=start,method=auto]  % use microtypography \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]@@ -104,6 +107,27 @@ \setupxtable[body][] \setupxtable[foot][bottomframe=on] +$if(csl-refs)$+\newdimen\cslhangindent+\cslhangindent=1.5em+\definestartstop [cslreferences] [+	$if(csl-hanging-indent)$+	before={%+		\setupnarrower[left=\cslhangindent]+    	\startnarrower[left]%+    	\setupindenting[-\leftskip,yes,first]%+    	%\setuphead[chapter,section][indentnext=yes]%+		\indentation%+  	},+  	after=\stopnarrower,+	$endif$+]+$endif$+$if(includesource)$+$for(sourcefile)$+\attachment[file=$curdir$/$sourcefile$,method=hidden]+$endfor$+$endif$ $for(header-includes)$ $header-includes$ $endfor$
data/templates/default.docbook4 view
@@ -23,10 +23,10 @@ $endif$   </articleinfo> $for(include-before)$-$include-before$+  $include-before$ $endfor$-$body$+  $body$ $for(include-after)$-$include-after$+  $include-after$ $endfor$ </article>
data/templates/default.docbook5 view
@@ -28,10 +28,10 @@ $endif$   </info> $for(include-before)$-$include-before$+  $include-before$ $endfor$-$body$+  $body$ $for(include-after)$-$include-after$+  $include-after$ $endfor$ </article>
data/templates/default.dzslides view
@@ -13,19 +13,8 @@ $endif$   <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>   <style>-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$-  </style>-$if(highlighting-css)$-  <style>-$highlighting-css$+    $styles.html()$   </style>-$endif$ $if(css)$ $for(css)$   <link rel="stylesheet" href="$css$">
data/templates/default.epub2 view
@@ -46,6 +46,13 @@   <div class="rights">$rights$</div> $endif$ $else$+$if(coverpage)$+<div id="cover-image">+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 $cover-image-width$ $cover-image-height$" preserveAspectRatio="none">+<image width="$cover-image-width$" height="$cover-image-height$" xlink:href="../media/$cover-image$" />+</svg>+</div>+$else$ $for(include-before)$ $include-before$ $endfor$@@ -53,6 +60,7 @@ $for(include-after)$ $include-after$ $endfor$+$endif$ $endif$ </body> </html>
data/templates/default.epub3 view
@@ -47,6 +47,13 @@ $endif$ </section> $else$+$if(coverpage)$+<div id="cover-image">+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 $cover-image-width$ $cover-image-height$" preserveAspectRatio="none">+<image width="$cover-image-width$" height="$cover-image-height$" xlink:href="../media/$cover-image$" />+</svg>+</div>+$else$ $for(include-before)$ $include-before$ $endfor$@@ -54,6 +61,7 @@ $for(include-after)$ $include-after$ $endfor$+$endif$ $endif$ </body> </html>
data/templates/default.html4 view
@@ -15,19 +15,8 @@ $endif$   <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$-  </style>-$if(highlighting-css)$-  <style type="text/css">-$highlighting-css$+    $styles.html()$   </style>-$endif$ $for(css)$   <link rel="stylesheet" href="$css$" type="text/css" /> $endfor$
data/templates/default.html5 view
@@ -15,19 +15,8 @@ $endif$   <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>   <style>-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$-  </style>-$if(highlighting-css)$-  <style>-$highlighting-css$+    $styles.html()$   </style>-$endif$ $for(css)$   <link rel="stylesheet" href="$css$" /> $endfor$
data/templates/default.icml view
@@ -4,7 +4,7 @@ <Document DOMVersion="8.0" Self="pandoc_doc">     <RootCharacterStyleGroup Self="pandoc_character_styles">       <CharacterStyle Self="$$ID/NormalCharacterStyle" Name="Default" />-      $charStyles$ +      $charStyles$     </RootCharacterStyleGroup>     <RootParagraphStyleGroup Self="pandoc_paragraph_styles">       <ParagraphStyle Self="$$ID/NormalParagraphStyle" Name="$$ID/NormalParagraphStyle"@@ -20,7 +20,7 @@           </TabList>         </Properties>       </ParagraphStyle>-      $parStyles$ +      $parStyles$     </RootParagraphStyleGroup>     <RootTableStyleGroup Self="pandoc_table_styles">       <TableStyle Self="TableStyle/Table" Name="Table" />
data/templates/default.jats view
@@ -2,12 +2,12 @@ $if(xml-stylesheet)$ <?xml-stylesheet type="text/xsl" href="$xml-stylesheet$"?> $endif$-<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"+<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1 20151215//EN"                   "JATS-journalpublishing1.dtd"> $if(article.type)$-<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="$article.type$">+<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.1" article-type="$article.type$"> $else$-<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">+<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.1" article-type="other"> $endif$ <front> <journal-meta>@@ -166,6 +166,11 @@ </license> </permissions> $endif$+$endif$+$if(abstract)$+<abstract>+$abstract$+</abstract> $endif$ $if(tags)$ <kwd-group kwd-group-type="author">
data/templates/default.latex view
@@ -137,7 +137,7 @@ $endif$ $if(CJKmainfont)$   \ifxetex-    \usepackage{xeCJK}+    \usepackage[space]{xeCJK}     \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}   \fi $endif$@@ -270,7 +270,7 @@ $endif$ $endif$ $if(graphics)$-\usepackage{graphicx,grffile}+\usepackage{graphicx} \makeatletter \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}@@ -358,6 +358,14 @@ $for(bibliography)$ \addbibresource{$bibliography$} $endfor$+$endif$+$if(csl-refs)$+\newlength{\cslhangindent}+\setlength{\cslhangindent}{1.5em}+\newenvironment{cslreferences}%+  {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}%+  \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%+  {\par} $endif$  $if(title)$
data/templates/default.man view
@@ -12,7 +12,7 @@ $if(hyphenate)$ .hy $else$-.nh \" Turn off hyphenation by default.+.nh $endif$ $for(header-includes)$ $header-includes$
data/templates/default.ms view
@@ -31,11 +31,11 @@ .\" line height .nr VS $if(lineheight)$$lineheight$$else$12p$endif$ .\" font family: A, BM, H, HN, N, P, T, ZCM-.fam $if(fontfamily)$$fontfamily$$else$T$endif$+.fam $if(fontfamily)$$fontfamily$$else$P$endif$ .\" paragraph indent-.nr PI $if(indent)$$indent$$else$2m$endif$+.nr PI $if(indent)$$indent$$else$0m$endif$ .\" interparagraph space-.nr PD 0.33v+.nr PD 0.4v .\" footnote width .nr FL \n[LL] .\" footnote point size@@ -57,6 +57,9 @@ .\" comment these out if you want a dot after section numbers: .als SN SN-NO-DOT .als SN-STYLE SN-NO-DOT+.\" page numbers in footer, centered+.rm CH+.ds CF % .\" pdf outline fold level .nr PDFOUTLINE.FOLDLEVEL 3 .\" start out in outline view@@ -71,7 +74,7 @@ $if(hyphenate)$ .hy $else$-.nh \" Turn off hyphenation by default.+.nh $endif$ $if(has-inline-math)$ .EQ
data/templates/default.muse view
@@ -1,5 +1,5 @@ $if(author)$-#author $author$+#author $for(author)$$author$$sep$; $endfor$ $endif$ $if(title)$ #title $title$
data/templates/default.revealjs view
@@ -19,19 +19,8 @@   <link rel="stylesheet" href="$revealjs-url$/css/reset.css">   <link rel="stylesheet" href="$revealjs-url$/css/reveal.css">   <style>-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$-  </style>-$if(highlighting-css)$-  <style>-$highlighting-css$+    $styles.html()$   </style>-$endif$ $if(theme)$   <link rel="stylesheet" href="$revealjs-url$/css/theme/$theme$.css" id="theme"> $else$@@ -137,6 +126,10 @@ $if(rtl)$         // Change the presentation direction to be RTL         rtl: $rtl$,+$endif$+$if(navigationMode)$+        // see https://github.com/hakimel/reveal.js/#navigation-mode+        navigationMode: '$navigationMode$', $endif$ $if(fragments)$         // Turns fragments on and off globally
data/templates/default.s5 view
@@ -16,22 +16,11 @@ $endif$   <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$+    $styles.html()$   </style>   <!-- configuration parameters -->   <meta name="defaultView" content="slideshow" />   <meta name="controlVis" content="hidden" />-$if(highlighting-css)$-  <style type="text/css">-$highlighting-css$-  </style>-$endif$ $for(css)$   <link rel="stylesheet" href="$css$" type="text/css" /> $endfor$
data/templates/default.slideous view
@@ -17,19 +17,8 @@ $endif$   <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$-  </style>-$if(highlighting-css)$-  <style type="text/css">-$highlighting-css$+    $styles.html()$   </style>-$endif$   <link rel="stylesheet" type="text/css" media="screen, projection, print"     href="$slideous-url$/slideous.css" /> $for(css)$
data/templates/default.slidy view
@@ -17,19 +17,8 @@ $endif$   <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$-      q { quotes: "“" "”" "‘" "’"; }-$endif$-  </style>-$if(highlighting-css)$-  <style type="text/css">-$highlighting-css$+    $styles.html()$   </style>-$endif$   <link rel="stylesheet" type="text/css" media="screen, projection, print"     href="$slidy-url$/styles/slidy.css" /> $for(css)$
+ data/templates/styles.html view
@@ -0,0 +1,11 @@+code{white-space: pre-wrap;}+span.smallcaps{font-variant: small-caps;}+span.underline{text-decoration: underline;}+div.column{display: inline-block; vertical-align: top; width: 50%;}+div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}+$if(quotes)$+q { quotes: "“" "”" "‘" "’"; }+$endif$+$if(highlighting-css)$+$highlighting-css$+$endif$
man/pandoc.1 view
@@ -1,6264 +1,7012 @@ .\"t-.TH PANDOC 1 "June 11, 2019" "pandoc 2.7.3"-.SH NAME-pandoc - general markup converter-.SH SYNOPSIS-.PP-\f[C]pandoc\f[R] [\f[I]options\f[R]] [\f[I]input-file\f[R]]...-.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.-.PP-Pandoc can convert between numerous markup and word processing formats,-including, but not limited to, various flavors of Markdown, HTML, LaTeX-and Word docx.-For the full lists of input and output formats, see the \f[C]--from\f[R]-and \f[C]--to\f[R] options below.-Pandoc can also produce PDF output: see creating a PDF, below.-.PP-Pandoc\[aq]s enhanced version of Markdown includes syntax for tables,-definition lists, metadata blocks, footnotes, citations, math, and much-more.-See below under Pandoc\[aq]s Markdown.-.PP-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 (an \f[I]abstract syntax tree\f[R] or AST), 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.-Users can also run custom pandoc filters to modify the intermediate AST.-.PP-Because pandoc\[aq]s intermediate representation of a document is less-expressive than many of the formats it converts between, one should not-expect perfect conversions between every format and every other.-Pandoc attempts to preserve the structural elements of a document, but-not formatting details such as margin size.-And some document elements, such as complex tables, may not fit into-pandoc\[aq]s simple document model.-While conversions from pandoc\[aq]s Markdown to all formats aspire to be-perfect, conversions from formats more expressive than pandoc\[aq]s-Markdown can be expected to be lossy.-.SS Using pandoc-.PP-If no \f[I]input-files\f[R] are specified, input is read from-\f[I]stdin\f[R].-Output goes to \f[I]stdout\f[R] by default.-For output to a file, use the \f[C]-o\f[R] option:-.IP-.nf-\f[C]-pandoc -o output.html input.txt-\f[R]-.fi-.PP-By default, pandoc produces a document fragment.-To produce a standalone document (e.g.-a valid HTML file including \f[C]<head>\f[R] and \f[C]<body>\f[R]), use-the \f[C]-s\f[R] or \f[C]--standalone\f[R] flag:-.IP-.nf-\f[C]-pandoc -s -o output.html input.txt-\f[R]-.fi-.PP-For more information on how standalone documents are produced, see-Templates below.-.PP-If multiple input files are given, \f[C]pandoc\f[R] will concatenate-them all (with blank lines between them) before parsing.-(Use \f[C]--file-scope\f[R] to parse files individually.)-.SS Specifying formats-.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]-f/--from\f[R] option,-the output format using the \f[C]-t/--to\f[R] option.-Thus, to convert \f[C]hello.txt\f[R] from Markdown to LaTeX, you could-type:-.IP-.nf-\f[C]-pandoc -f markdown -t latex hello.txt-\f[R]-.fi-.PP-To convert \f[C]hello.html\f[R] from HTML to Markdown:-.IP-.nf-\f[C]-pandoc -f html -t markdown hello.html-\f[R]-.fi-.PP-Supported input and output formats are listed below under Options (see-\f[C]-f\f[R] for input formats and \f[C]-t\f[R] for output formats).-You can also use \f[C]pandoc --list-input-formats\f[R] and-\f[C]pandoc --list-output-formats\f[R] to print lists of supported-formats.-.PP-If the input or output format is not specified explicitly,-\f[C]pandoc\f[R] will attempt to guess it from the extensions of the-filenames.-Thus, for example,-.IP-.nf-\f[C]-pandoc -o hello.tex hello.txt-\f[R]-.fi-.PP-will convert \f[C]hello.txt\f[R] from Markdown to LaTeX.-If no output file is specified (so that output goes to-\f[I]stdout\f[R]), 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[R]), or if the input files\[aq] extensions are unknown, the-input format will be assumed to be Markdown.-.SS Character encoding-.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[R]:-.IP-.nf-\f[C]-iconv -t utf-8 input.txt | pandoc | iconv -f utf-8-\f[R]-.fi-.PP-Note that in some output formats (such as HTML, LaTeX, ConTeXt, RTF,-OPML, DocBook, and Texinfo), information about the character encoding is-included in the document header, which will only be included if you use-the \f[C]-s/--standalone\f[R] option.-.SS Creating a PDF-.PP-To produce a PDF, specify an output file with a \f[C].pdf\f[R]-extension:-.IP-.nf-\f[C]-pandoc test.txt -o test.pdf-\f[R]-.fi-.PP-By default, pandoc will use LaTeX to create the PDF, which requires that-a LaTeX engine be installed (see \f[C]--pdf-engine\f[R] below).-.PP-Alternatively, pandoc can use ConTeXt, \f[C]pdfroff\f[R], or any of the-following HTML/CSS-to-PDF-engines, to create a PDF:-\f[C]wkhtmltopdf\f[R], \f[C]weasyprint\f[R] or \f[C]prince\f[R].-To do this, specify an output file with a \f[C].pdf\f[R] extension, as-before, but add the \f[C]--pdf-engine\f[R] option or-\f[C]-t context\f[R], \f[C]-t html\f[R], or \f[C]-t ms\f[R] to the-command line (\f[C]-t html\f[R] defaults to-\f[C]--pdf-engine=wkhtmltopdf\f[R]).-.PP-PDF output uses variables for LaTeX (with a LaTeX engine); variables for-ConTeXt (with ConTeXt); or variables for \f[C]wkhtmltopdf\f[R] (an-HTML/CSS-to-PDF engine; \f[C]--css\f[R] also affects the output).-.PP-To debug the PDF creation, it can be useful to look at the intermediate-representation: instead of \f[C]-o test.pdf\f[R], use for example-\f[C]-s -o test.tex\f[R] to output the generated LaTeX.-You can then test it with \f[C]pdflatex test.tex\f[R].-.PP-When using LaTeX, the following packages need to be available (they are-included with all recent versions of TeX Live): \f[C]amsfonts\f[R],-\f[C]amsmath\f[R], \f[C]lm\f[R], \f[C]unicode-math\f[R],-\f[C]ifxetex\f[R], \f[C]ifluatex\f[R], \f[C]listings\f[R] (if the-\f[C]--listings\f[R] option is used), \f[C]fancyvrb\f[R],-\f[C]longtable\f[R], \f[C]booktabs\f[R], \f[C]graphicx\f[R] and-\f[C]grffile\f[R] (if the document contains images), \f[C]hyperref\f[R],-\f[C]xcolor\f[R], \f[C]ulem\f[R], \f[C]geometry\f[R] (with the-\f[C]geometry\f[R] variable set), \f[C]setspace\f[R] (with-\f[C]linestretch\f[R]), and \f[C]babel\f[R] (with \f[C]lang\f[R]).-The use of \f[C]xelatex\f[R] or \f[C]lualatex\f[R] as the PDF engine-requires \f[C]fontspec\f[R].-\f[C]xelatex\f[R] uses \f[C]polyglossia\f[R] (with \f[C]lang\f[R]),-\f[C]xecjk\f[R], and \f[C]bidi\f[R] (with the \f[C]dir\f[R] variable-set).-If the \f[C]mathspec\f[R] variable is set, \f[C]xelatex\f[R] will use-\f[C]mathspec\f[R] instead of \f[C]unicode-math\f[R].-The \f[C]upquote\f[R] and \f[C]microtype\f[R] packages are used if-available, and \f[C]csquotes\f[R] will be used for typography if-\f[C]\[rs]usepackage{csquotes}\f[R] is present in the template or-included via \f[C]/H/--include-in-header\f[R].-The \f[C]natbib\f[R], \f[C]biblatex\f[R], \f[C]bibtex\f[R], and-\f[C]biber\f[R] packages can optionally be used for citation rendering.-The following packages will be used to improve output quality if-present, but pandoc does not require them to be present:-\f[C]upquote\f[R] (for straight quotes in verbatim environments),-\f[C]microtype\f[R] (for better spacing adjustments), \f[C]parskip\f[R]-(for better inter-paragraph spaces), \f[C]xurl\f[R] (for better line-breaks in URLs), \f[C]bookmark\f[R] (for better PDF bookmarks), and-\f[C]footnotehyper\f[R] or \f[C]footnote\f[R] (to allow footnotes in-tables).-.SS Reading from the Web-.PP-Instead of an input 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[R]-.fi-.PP-It is possible to supply a custom User-Agent string or other header when-requesting a document from a URL:-.IP-.nf-\f[C]-pandoc -f html -t markdown --request-header User-Agent:\[dq]Mozilla/5.0\[dq] \[rs]-  http://www.fsf.org-\f[R]-.fi-.SH OPTIONS-.SS General options-.TP-.B \f[C]-f\f[R] \f[I]FORMAT\f[R], \f[C]-r\f[R] \f[I]FORMAT\f[R], \f[C]--from=\f[R]\f[I]FORMAT\f[R], \f[C]--read=\f[R]\f[I]FORMAT\f[R]-Specify input format.-\f[I]FORMAT\f[R] can be:-.RS-.IP \[bu] 2-\f[C]commonmark\f[R] (CommonMark Markdown)-.IP \[bu] 2-\f[C]creole\f[R] (Creole 1.0)-.IP \[bu] 2-\f[C]docbook\f[R] (DocBook)-.IP \[bu] 2-\f[C]docx\f[R] (Word docx)-.IP \[bu] 2-\f[C]dokuwiki\f[R] (DokuWiki markup)-.IP \[bu] 2-\f[C]epub\f[R] (EPUB)-.IP \[bu] 2-\f[C]fb2\f[R] (FictionBook2 e-book)-.IP \[bu] 2-\f[C]gfm\f[R] (GitHub-Flavored Markdown), or the deprecated and less-accurate \f[C]markdown_github\f[R]; use \f[C]markdown_github\f[R] only-if you need extensions not supported in \f[C]gfm\f[R].-.IP \[bu] 2-\f[C]haddock\f[R] (Haddock markup)-.IP \[bu] 2-\f[C]html\f[R] (HTML)-.IP \[bu] 2-\f[C]ipynb\f[R] (Jupyter notebook)-.IP \[bu] 2-\f[C]jats\f[R] (JATS XML)-.IP \[bu] 2-\f[C]json\f[R] (JSON version of native AST)-.IP \[bu] 2-\f[C]latex\f[R] (LaTeX)-.IP \[bu] 2-\f[C]markdown\f[R] (Pandoc\[aq]s Markdown)-.IP \[bu] 2-\f[C]markdown_mmd\f[R] (MultiMarkdown)-.IP \[bu] 2-\f[C]markdown_phpextra\f[R] (PHP Markdown Extra)-.IP \[bu] 2-\f[C]markdown_strict\f[R] (original unextended Markdown)-.IP \[bu] 2-\f[C]mediawiki\f[R] (MediaWiki markup)-.IP \[bu] 2-\f[C]man\f[R] (roff man)-.IP \[bu] 2-\f[C]muse\f[R] (Muse)-.IP \[bu] 2-\f[C]native\f[R] (native Haskell)-.IP \[bu] 2-\f[C]odt\f[R] (ODT)-.IP \[bu] 2-\f[C]opml\f[R] (OPML)-.IP \[bu] 2-\f[C]org\f[R] (Emacs Org mode)-.IP \[bu] 2-\f[C]rst\f[R] (reStructuredText)-.IP \[bu] 2-\f[C]t2t\f[R] (txt2tags)-.IP \[bu] 2-\f[C]textile\f[R] (Textile)-.IP \[bu] 2-\f[C]tikiwiki\f[R] (TikiWiki markup)-.IP \[bu] 2-\f[C]twiki\f[R] (TWiki markup)-.IP \[bu] 2-\f[C]vimwiki\f[R] (Vimwiki)-.PP-Extensions can be individually enabled or disabled by appending-\f[C]+EXTENSION\f[R] or \f[C]-EXTENSION\f[R] to the format name.-See Extensions below, for a list of extensions and their names.-See \f[C]--list-input-formats\f[R] and \f[C]--list-extensions\f[R],-below.-.RE-.TP-.B \f[C]-t\f[R] \f[I]FORMAT\f[R], \f[C]-w\f[R] \f[I]FORMAT\f[R], \f[C]--to=\f[R]\f[I]FORMAT\f[R], \f[C]--write=\f[R]\f[I]FORMAT\f[R]-Specify output format.-\f[I]FORMAT\f[R] can be:-.RS-.IP \[bu] 2-\f[C]asciidoc\f[R] (AsciiDoc) or \f[C]asciidoctor\f[R] (AsciiDoctor)-.IP \[bu] 2-\f[C]beamer\f[R] (LaTeX beamer slide show)-.IP \[bu] 2-\f[C]commonmark\f[R] (CommonMark Markdown)-.IP \[bu] 2-\f[C]context\f[R] (ConTeXt)-.IP \[bu] 2-\f[C]docbook\f[R] or \f[C]docbook4\f[R] (DocBook 4)-.IP \[bu] 2-\f[C]docbook5\f[R] (DocBook 5)-.IP \[bu] 2-\f[C]docx\f[R] (Word docx)-.IP \[bu] 2-\f[C]dokuwiki\f[R] (DokuWiki markup)-.IP \[bu] 2-\f[C]epub\f[R] or \f[C]epub3\f[R] (EPUB v3 book)-.IP \[bu] 2-\f[C]epub2\f[R] (EPUB v2)-.IP \[bu] 2-\f[C]fb2\f[R] (FictionBook2 e-book)-.IP \[bu] 2-\f[C]gfm\f[R] (GitHub-Flavored Markdown), or the deprecated and less-accurate \f[C]markdown_github\f[R]; use \f[C]markdown_github\f[R] only-if you need extensions not supported in \f[C]gfm\f[R].-.IP \[bu] 2-\f[C]haddock\f[R] (Haddock markup)-.IP \[bu] 2-\f[C]html\f[R] or \f[C]html5\f[R] (HTML, i.e.-HTML5/XHTML polyglot markup)-.IP \[bu] 2-\f[C]html4\f[R] (XHTML 1.0 Transitional)-.IP \[bu] 2-\f[C]icml\f[R] (InDesign ICML)-.IP \[bu] 2-\f[C]ipynb\f[R] (Jupyter notebook)-.IP \[bu] 2-\f[C]jats\f[R] (JATS XML)-.IP \[bu] 2-\f[C]jira\f[R] (Jira wiki markup)-.IP \[bu] 2-\f[C]json\f[R] (JSON version of native AST)-.IP \[bu] 2-\f[C]latex\f[R] (LaTeX)-.IP \[bu] 2-\f[C]man\f[R] (roff man)-.IP \[bu] 2-\f[C]markdown\f[R] (Pandoc\[aq]s Markdown)-.IP \[bu] 2-\f[C]markdown_mmd\f[R] (MultiMarkdown)-.IP \[bu] 2-\f[C]markdown_phpextra\f[R] (PHP Markdown Extra)-.IP \[bu] 2-\f[C]markdown_strict\f[R] (original unextended Markdown)-.IP \[bu] 2-\f[C]mediawiki\f[R] (MediaWiki markup)-.IP \[bu] 2-\f[C]ms\f[R] (roff ms)-.IP \[bu] 2-\f[C]muse\f[R] (Muse),-.IP \[bu] 2-\f[C]native\f[R] (native Haskell),-.IP \[bu] 2-\f[C]odt\f[R] (OpenOffice text document)-.IP \[bu] 2-\f[C]opml\f[R] (OPML)-.IP \[bu] 2-\f[C]opendocument\f[R] (OpenDocument)-.IP \[bu] 2-\f[C]org\f[R] (Emacs Org mode)-.IP \[bu] 2-\f[C]plain\f[R] (plain text),-.IP \[bu] 2-\f[C]pptx\f[R] (PowerPoint slide show)-.IP \[bu] 2-\f[C]rst\f[R] (reStructuredText)-.IP \[bu] 2-\f[C]rtf\f[R] (Rich Text Format)-.IP \[bu] 2-\f[C]texinfo\f[R] (GNU Texinfo)-.IP \[bu] 2-\f[C]textile\f[R] (Textile)-.IP \[bu] 2-\f[C]slideous\f[R] (Slideous HTML and JavaScript slide show)-.IP \[bu] 2-\f[C]slidy\f[R] (Slidy HTML and JavaScript slide show)-.IP \[bu] 2-\f[C]dzslides\f[R] (DZSlides HTML5 + JavaScript slide show),-.IP \[bu] 2-\f[C]revealjs\f[R] (reveal.js HTML5 + JavaScript slide show)-.IP \[bu] 2-\f[C]s5\f[R] (S5 HTML and JavaScript slide show)-.IP \[bu] 2-\f[C]tei\f[R] (TEI Simple)-.IP \[bu] 2-\f[C]xwiki\f[R] (XWiki markup)-.IP \[bu] 2-\f[C]zimwiki\f[R] (ZimWiki markup)-.IP \[bu] 2-the path of a custom lua writer, see Custom writers below-.PP-Note that \f[C]odt\f[R], \f[C]docx\f[R], and \f[C]epub\f[R] output will-not be directed to \f[I]stdout\f[R] unless forced with \f[C]-o -\f[R].-.PP-Extensions can be individually enabled or disabled by appending-\f[C]+EXTENSION\f[R] or \f[C]-EXTENSION\f[R] to the format name.-See Extensions below, for a list of extensions and their names.-See \f[C]--list-output-formats\f[R] and \f[C]--list-extensions\f[R],-below.-.RE-.TP-.B \f[C]-o\f[R] \f[I]FILE\f[R], \f[C]--output=\f[R]\f[I]FILE\f[R]-Write output to \f[I]FILE\f[R] instead of \f[I]stdout\f[R].-If \f[I]FILE\f[R] is \f[C]-\f[R], output will go to \f[I]stdout\f[R],-even if a non-textual format (\f[C]docx\f[R], \f[C]odt\f[R],-\f[C]epub2\f[R], \f[C]epub3\f[R]) is specified.-.TP-.B \f[C]--data-dir=\f[R]\f[I]DIRECTORY\f[R]-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.-On *nix and macOS systems this will be the \f[C]pandoc\f[R] subdirectory-of the XDG data directory (by default, \f[C]$HOME/.local/share\f[R],-overridable by setting the \f[C]XDG_DATA_HOME\f[R] environment-variable).-If that directory does not exist, \f[C]$HOME/.pandoc\f[R] will be used-(for backwards compatibility).-In Windows the default user data directory is-\f[C]C:\[rs]Users\[rs]USERNAME\[rs]AppData\[rs]Roaming\[rs]pandoc\f[R].-You can find the default user data directory on your system by looking-at the output of \f[C]pandoc --version\f[R].-A \f[C]reference.odt\f[R], \f[C]reference.docx\f[R], \f[C]epub.css\f[R],-\f[C]templates\f[R], \f[C]slidy\f[R], \f[C]slideous\f[R], or-\f[C]s5\f[R] directory placed in this directory will override-pandoc\[aq]s normal defaults.-.TP-.B \f[C]--bash-completion\f[R]-Generate a bash completion script.-To enable bash completion with pandoc, add this to your-\f[C].bashrc\f[R]:-.RS-.IP-.nf-\f[C]-eval \[dq]$(pandoc --bash-completion)\[dq]-\f[R]-.fi-.RE-.TP-.B \f[C]--verbose\f[R]-Give verbose debugging output.-Currently this only has an effect with PDF output.-.TP-.B \f[C]--quiet\f[R]-Suppress warning messages.-.TP-.B \f[C]--fail-if-warnings\f[R]-Exit with error status if there are any warnings.-.TP-.B \f[C]--log=\f[R]\f[I]FILE\f[R]-Write log messages in machine-readable JSON format to \f[I]FILE\f[R].-All messages above DEBUG level will be written, regardless of verbosity-settings (\f[C]--verbose\f[R], \f[C]--quiet\f[R]).-.TP-.B \f[C]--list-input-formats\f[R]-List supported input formats, one per line.-.TP-.B \f[C]--list-output-formats\f[R]-List supported output formats, one per line.-.TP-.B \f[C]--list-extensions\f[R][\f[C]=\f[R]\f[I]FORMAT\f[R]]-List supported extensions, one per line, preceded by a \f[C]+\f[R] or-\f[C]-\f[R] indicating whether it is enabled by default in-\f[I]FORMAT\f[R].-If \f[I]FORMAT\f[R] is not specified, defaults for pandoc\[aq]s Markdown-are given.-.TP-.B \f[C]--list-highlight-languages\f[R]-List supported languages for syntax highlighting, one per line.-.TP-.B \f[C]--list-highlight-styles\f[R]-List supported styles for syntax highlighting, one per line.-See \f[C]--highlight-style\f[R].-.TP-.B \f[C]-v\f[R], \f[C]--version\f[R]-Print version.-.TP-.B \f[C]-h\f[R], \f[C]--help\f[R]-Show usage message.-.SS Reader options-.TP-.B \f[C]--base-header-level=\f[R]\f[I]NUMBER\f[R]-Specify the base level for headings (defaults to 1).-.TP-.B \f[C]--strip-empty-paragraphs\f[R]-\f[I]Deprecated. Use the \f[CI]+empty_paragraphs\f[I] extension-instead.\f[R] Ignore paragraphs with no content.-This option is useful for converting word processing documents where-users have used empty paragraphs to create inter-paragraph space.-.TP-.B \f[C]--indented-code-classes=\f[R]\f[I]CLASSES\f[R]-Specify classes to use for indented code blocks--for example,-\f[C]perl,numberLines\f[R] or \f[C]haskell\f[R].-Multiple classes may be separated by spaces or commas.-.TP-.B \f[C]--default-image-extension=\f[R]\f[I]EXTENSION\f[R]-Specify a default extension to use when image paths/URLs have no-extension.-This allows you to use the same source for formats that require-different kinds of images.-Currently this option only affects the Markdown and LaTeX readers.-.TP-.B \f[C]--file-scope\f[R]-Parse each file individually before combining for multifile documents.-This will allow footnotes in different files with the same identifiers-to work as expected.-If this option is set, footnotes and links will not work across files.-Reading binary files (docx, odt, epub) implies \f[C]--file-scope\f[R].-.TP-.B \f[C]-F\f[R] \f[I]PROGRAM\f[R], \f[C]--filter=\f[R]\f[I]PROGRAM\f[R]-Specify an executable to be used as a filter transforming the pandoc AST-after the input is parsed and before the output is written.-The executable should read JSON from stdin and write JSON to stdout.-The JSON must be formatted like pandoc\[aq]s own JSON input and output.-The name of the output format will be passed to the filter as the first-argument.-Hence,-.RS-.IP-.nf-\f[C]-pandoc --filter ./caps.py -t latex-\f[R]-.fi-.PP-is equivalent to-.IP-.nf-\f[C]-pandoc -t json | ./caps.py latex | pandoc -f json -t latex-\f[R]-.fi-.PP-The latter form may be useful for debugging filters.-.PP-Filters may be written in any language.-\f[C]Text.Pandoc.JSON\f[R] exports \f[C]toJSONFilter\f[R] to facilitate-writing filters in Haskell.-Those who would prefer to write filters in python can use the module-\f[C]pandocfilters\f[R], installable from PyPI.-There are also pandoc filter libraries in PHP, perl, and-JavaScript/node.js.-.PP-In order of preference, pandoc will look for filters in-.IP "1." 3-a specified full or relative path (executable or non-executable)-.IP "2." 3-\f[C]$DATADIR/filters\f[R] (executable or non-executable) where-\f[C]$DATADIR\f[R] is the user data directory (see \f[C]--data-dir\f[R],-above).-.IP "3." 3-\f[C]$PATH\f[R] (executable only)-.PP-Filters and lua-filters are applied in the order specified on the-command line.-.RE-.TP-.B \f[C]--lua-filter=\f[R]\f[I]SCRIPT\f[R]-Transform the document in a similar fashion as JSON filters (see-\f[C]--filter\f[R]), but use pandoc\[aq]s build-in lua filtering system.-The given lua script is expected to return a list of lua filters which-will be applied in order.-Each lua filter must contain element-transforming functions indexed by-the name of the AST element on which the filter function should be-applied.-.RS-.PP-The \f[C]pandoc\f[R] lua module provides helper functions for element-creation.-It is always loaded into the script\[aq]s lua environment.-.PP-The following is an example lua script for macro-expansion:-.IP-.nf-\f[C]-function expand_hello_world(inline)-  if inline.c == \[aq]{{helloworld}}\[aq] then-    return pandoc.Emph{ pandoc.Str \[dq]Hello, World\[dq] }-  else-    return inline-  end-end--return {{Str = expand_hello_world}}-\f[R]-.fi-.PP-In order of preference, pandoc will look for lua filters in-.IP "1." 3-a specified full or relative path (executable or non-executable)-.IP "2." 3-\f[C]$DATADIR/filters\f[R] (executable or non-executable) where-\f[C]$DATADIR\f[R] is the user data directory (see \f[C]--data-dir\f[R],-above).-.RE-.TP-.B \f[C]-M\f[R] \f[I]KEY\f[R][\f[C]=\f[R]\f[I]VAL\f[R]], \f[C]--metadata=\f[R]\f[I]KEY\f[R][\f[C]:\f[R]\f[I]VAL\f[R]]-Set the metadata field \f[I]KEY\f[R] to the value \f[I]VAL\f[R].-A value specified on the command line overrides a value specified in the-document using YAML metadata blocks.-Values will be parsed as YAML boolean or string values.-If no value is specified, the value will be treated as Boolean true.-Like \f[C]--variable\f[R], \f[C]--metadata\f[R] causes template-variables to be set.-But unlike \f[C]--variable\f[R], \f[C]--metadata\f[R] affects the-metadata of the underlying document (which is accessible from filters-and may be printed in some output formats) and metadata values will be-escaped when inserted into the template.-.TP-.B \f[C]--metadata-file=\f[R]\f[I]FILE\f[R]-Read metadata from the supplied YAML (or JSON) file.-This option can be used with every input format, but string scalars in-the YAML file will always be parsed as Markdown.-Generally, the input will be handled the same as in YAML metadata-blocks.-Metadata values specified inside the document, or by using \f[C]-M\f[R],-overwrite values specified with this option.-.TP-.B \f[C]-p\f[R], \f[C]--preserve-tabs\f[R]-Preserve tabs instead of converting them to spaces (the default).-Note that this will only affect tabs in literal code spans and code-blocks; tabs in regular text will be treated as spaces.-.TP-.B \f[C]--tab-stop=\f[R]\f[I]NUMBER\f[R]-Specify the number of spaces per tab (default is 4).-.TP-.B \f[C]--track-changes=accept\f[R]|\f[C]reject\f[R]|\f[C]all\f[R]-Specifies what to do with insertions, deletions, and comments produced-by the MS Word \[dq]Track Changes\[dq] feature.-\f[C]accept\f[R] (the default), inserts all insertions, and ignores all-deletions.-\f[C]reject\f[R] inserts all deletions and ignores insertions.-Both \f[C]accept\f[R] and \f[C]reject\f[R] ignore comments.-\f[C]all\f[R] puts in insertions, deletions, and comments, wrapped in-spans with \f[C]insertion\f[R], \f[C]deletion\f[R],-\f[C]comment-start\f[R], and \f[C]comment-end\f[R] classes,-respectively.-The author and time of change is included.-\f[C]all\f[R] is useful for scripting: only accepting changes from a-certain reviewer, say, or before a certain date.-If a paragraph is inserted or deleted, \f[C]track-changes=all\f[R]-produces a span with the class-\f[C]paragraph-insertion\f[R]/\f[C]paragraph-deletion\f[R] before the-affected paragraph break.-This option only affects the docx reader.-.TP-.B \f[C]--extract-media=\f[R]\f[I]DIR\f[R]-Extract images and other media contained in or linked from the source-document to the path \f[I]DIR\f[R], creating it if necessary, and adjust-the images references in the document so they point to the extracted-files.-If the source format is a binary container (docx, epub, or odt), the-media is extracted from the container and the original filenames are-used.-Otherwise the media is read from the file system or downloaded, and new-filenames are constructed based on SHA1 hashes of the contents.-.TP-.B \f[C]--abbreviations=\f[R]\f[I]FILE\f[R]-Specifies a custom abbreviations file, with abbreviations one to a line.-If this option is not specified, pandoc will read the data file-\f[C]abbreviations\f[R] from the user data directory or fall back on a-system default.-To see the system default, use-\f[C]pandoc --print-default-data-file=abbreviations\f[R].-The only use pandoc makes of this list is in the Markdown reader.-Strings ending in a period that are found in this list will be followed-by a nonbreaking space, so that the period will not produce-sentence-ending space in formats like LaTeX.-.SS General writer options-.TP-.B \f[C]-s\f[R], \f[C]--standalone\f[R]-Produce output with an appropriate header and footer (e.g.-a standalone HTML, LaTeX, TEI, or RTF file, not a fragment).-This option is set automatically for \f[C]pdf\f[R], \f[C]epub\f[R],-\f[C]epub3\f[R], \f[C]fb2\f[R], \f[C]docx\f[R], and \f[C]odt\f[R]-output.-For \f[C]native\f[R] output, this option causes metadata to be included;-otherwise, metadata is suppressed.-.TP-.B \f[C]--template=\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]-Use the specified file as a custom template for the generated document.-Implies \f[C]--standalone\f[R].-See Templates, below, for a description of template syntax.-If no extension is specified, an extension corresponding to the writer-will be added, so that \f[C]--template=special\f[R] looks for-\f[C]special.html\f[R] for HTML output.-If the template is not found, pandoc will search for it in the-\f[C]templates\f[R] subdirectory of the user data directory (see-\f[C]--data-dir\f[R]).-If this option is not used, a default template appropriate for the-output format will be used (see \f[C]-D/--print-default-template\f[R]).-.TP-.B \f[C]-V\f[R] \f[I]KEY\f[R][\f[C]=\f[R]\f[I]VAL\f[R]], \f[C]--variable=\f[R]\f[I]KEY\f[R][\f[C]:\f[R]\f[I]VAL\f[R]]-Set the template variable \f[I]KEY\f[R] to the value \f[I]VAL\f[R] when-rendering the document in standalone mode.-This is generally only useful when the \f[C]--template\f[R] option is-used to specify a custom template, since pandoc automatically sets the-variables used in the default templates.-If no \f[I]VAL\f[R] is specified, the key will be given the value-\f[C]true\f[R].-.TP-.B \f[C]-D\f[R] \f[I]FORMAT\f[R], \f[C]--print-default-template=\f[R]\f[I]FORMAT\f[R]-Print the system default template for an output \f[I]FORMAT\f[R].-(See \f[C]-t\f[R] for a list of possible \f[I]FORMAT\f[R]s.) Templates-in the user data directory are ignored.-This option may be used with \f[C]-o\f[R]/\f[C]--output\f[R] to redirect-output to a file, but \f[C]-o\f[R]/\f[C]--output\f[R] must come before-\f[C]--print-default-template\f[R] on the command line.-.TP-.B \f[C]--print-default-data-file=\f[R]\f[I]FILE\f[R]-Print a system default data file.-Files in the user data directory are ignored.-This option may be used with \f[C]-o\f[R]/\f[C]--output\f[R] to redirect-output to a file, but \f[C]-o\f[R]/\f[C]--output\f[R] must come before-\f[C]--print-default-data-file\f[R] on the command line.-.TP-.B \f[C]--eol=crlf\f[R]|\f[C]lf\f[R]|\f[C]native\f[R]-Manually specify line endings: \f[C]crlf\f[R] (Windows), \f[C]lf\f[R]-(macOS/Linux/UNIX), or \f[C]native\f[R] (line endings appropriate to the-OS on which pandoc is being run).-The default is \f[C]native\f[R].-.TP-.B \f[C]--dpi\f[R]=\f[I]NUMBER\f[R]-Specify the dpi (dots per inch) value for conversion from pixels to-inch/centimeters and vice versa.-The default is 96dpi.-Technically, the correct term would be ppi (pixels per inch).-.TP-.B \f[C]--wrap=auto\f[R]|\f[C]none\f[R]|\f[C]preserve\f[R]-Determine how text is wrapped in the output (the source code, not the-rendered version).-With \f[C]auto\f[R] (the default), pandoc will attempt to wrap lines to-the column width specified by \f[C]--columns\f[R] (default 72).-With \f[C]none\f[R], pandoc will not wrap lines at all.-With \f[C]preserve\f[R], pandoc will attempt to preserve the wrapping-from the source document (that is, where there are nonsemantic newlines-in the source, there will be nonsemantic newlines in the output as-well).-Automatic wrapping does not currently work in HTML output.-In \f[C]ipynb\f[R] output, this option affects wrapping of the contents-of markdown cells.-.TP-.B \f[C]--columns=\f[R]\f[I]NUMBER\f[R]-Specify length of lines in characters.-This affects text wrapping in the generated source code (see-\f[C]--wrap\f[R]).-It also affects calculation of column widths for plain text tables (see-Tables below).-.TP-.B \f[C]--toc\f[R], \f[C]--table-of-contents\f[R]-Include an automatically generated table of contents (or, in the case of-\f[C]latex\f[R], \f[C]context\f[R], \f[C]docx\f[R], \f[C]odt\f[R],-\f[C]opendocument\f[R], \f[C]rst\f[R], or \f[C]ms\f[R], an instruction-to create one) in the output document.-This option has no effect unless \f[C]-s/--standalone\f[R] is used, and-it has no effect on \f[C]man\f[R], \f[C]docbook4\f[R],-\f[C]docbook5\f[R], or \f[C]jats\f[R] output.-.RS-.PP-Note that if you are producing a PDF via \f[C]ms\f[R], the table of-contents will appear at the beginning of the document, before the title.-If you would prefer it to be at the end of the document, use the option-\f[C]--pdf-engine-opt=--no-toc-relocation\f[R].-.RE-.TP-.B \f[C]--toc-depth=\f[R]\f[I]NUMBER\f[R]-Specify the number of section levels to include in the table of-contents.-The default is 3 (which means that level-1, 2, and 3 headings will be-listed in the contents).-.TP-.B \f[C]--strip-comments\f[R]-Strip out HTML comments in the Markdown or Textile source, rather than-passing them on to Markdown, Textile or HTML output as raw HTML.-This does not apply to HTML comments inside raw HTML blocks when the-\f[C]markdown_in_html_blocks\f[R] extension is not set.-.TP-.B \f[C]--no-highlight\f[R]-Disables syntax highlighting for code blocks and inlines, even when a-language attribute is given.-.TP-.B \f[C]--highlight-style=\f[R]\f[I]STYLE\f[R]|\f[I]FILE\f[R]-Specifies the coloring style to be used in highlighted source code.-Options are \f[C]pygments\f[R] (the default), \f[C]kate\f[R],-\f[C]monochrome\f[R], \f[C]breezeDark\f[R], \f[C]espresso\f[R],-\f[C]zenburn\f[R], \f[C]haddock\f[R], and \f[C]tango\f[R].-For more information on syntax highlighting in pandoc, see Syntax-highlighting, below.-See also \f[C]--list-highlight-styles\f[R].-.RS-.PP-Instead of a \f[I]STYLE\f[R] name, a JSON file with extension-\f[C].theme\f[R] may be supplied.-This will be parsed as a KDE syntax highlighting theme and (if valid)-used as the highlighting style.-.PP-To generate the JSON version of an existing style, use-\f[C]--print-highlight-style\f[R].-.RE-.TP-.B \f[C]--print-highlight-style=\f[R]\f[I]STYLE\f[R]|\f[I]FILE\f[R]-Prints a JSON version of a highlighting style, which can be modified,-saved with a \f[C].theme\f[R] extension, and used with-\f[C]--highlight-style\f[R].-This option may be used with \f[C]-o\f[R]/\f[C]--output\f[R] to redirect-output to a file, but \f[C]-o\f[R]/\f[C]--output\f[R] must come before-\f[C]--print-highlight-style\f[R] on the command line.-.TP-.B \f[C]--syntax-definition=\f[R]\f[I]FILE\f[R]-Instructs pandoc to load a KDE XML syntax definition file, which will be-used for syntax highlighting of appropriately marked code blocks.-This can be used to add support for new languages or to use altered-syntax definitions for existing languages.-.TP-.B \f[C]-H\f[R] \f[I]FILE\f[R], \f[C]--include-in-header=\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]-Include contents of \f[I]FILE\f[R], 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[R].-.TP-.B \f[C]-B\f[R] \f[I]FILE\f[R], \f[C]--include-before-body=\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]-Include contents of \f[I]FILE\f[R], verbatim, at the beginning of the-document body (e.g.-after the \f[C]<body>\f[R] tag in HTML, or the-\f[C]\[rs]begin{document}\f[R] 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[R].-.TP-.B \f[C]-A\f[R] \f[I]FILE\f[R], \f[C]--include-after-body=\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]-Include contents of \f[I]FILE\f[R], verbatim, at the end of the document-body (before the \f[C]</body>\f[R] tag in HTML, or the-\f[C]\[rs]end{document}\f[R] command in LaTeX).-This option can be used repeatedly to include multiple files.-They will be included in the order specified.-Implies \f[C]--standalone\f[R].-.TP-.B \f[C]--resource-path=\f[R]\f[I]SEARCHPATH\f[R]-List of paths to search for images and other resources.-The paths should be separated by \f[C]:\f[R] on Linux, UNIX, and macOS-systems, and by \f[C];\f[R] on Windows.-If \f[C]--resource-path\f[R] is not specified, the default resource path-is the working directory.-Note that, if \f[C]--resource-path\f[R] is specified, the working-directory must be explicitly listed or it will not be searched.-For example: \f[C]--resource-path=.:test\f[R] will search the working-directory and the \f[C]test\f[R] subdirectory, in that order.-.RS-.PP-\f[C]--resource-path\f[R] only has an effect if (a) the output format-embeds images (for example, \f[C]docx\f[R], \f[C]pdf\f[R], or-\f[C]html\f[R] with \f[C]--self-contained\f[R]) or (b) it is used-together with \f[C]--extract-media\f[R].-.RE-.TP-.B \f[C]--request-header=\f[R]\f[I]NAME\f[R]\f[C]:\f[R]\f[I]VAL\f[R]-Set the request header \f[I]NAME\f[R] to the value \f[I]VAL\f[R] when-making HTTP requests (for example, when a URL is given on the command-line, or when resources used in a document must be downloaded).-If you\[aq]re behind a proxy, you also need to set the environment-variable \f[C]http_proxy\f[R] to \f[C]http://...\f[R].-.SS Options affecting specific writers-.TP-.B \f[C]--self-contained\f[R]-Produce a standalone HTML file with no external dependencies, using-\f[C]data:\f[R] URIs to incorporate the contents of linked scripts,-stylesheets, images, and videos.-Implies \f[C]--standalone\f[R].-The resulting file should be \[dq]self-contained,\[dq] in the sense that-it needs no external files and no net access to be displayed properly by-a browser.-This option works only with HTML output formats, including-\f[C]html4\f[R], \f[C]html5\f[R], \f[C]html+lhs\f[R],-\f[C]html5+lhs\f[R], \f[C]s5\f[R], \f[C]slidy\f[R], \f[C]slideous\f[R],-\f[C]dzslides\f[R], and \f[C]revealjs\f[R].-Scripts, images, and stylesheets at absolute URLs will be downloaded;-those at relative URLs will be sought relative to the working directory-(if the first source file is local) or relative to the base URL (if the-first source file is remote).-Elements with the attribute \f[C]data-external=\[dq]1\[dq]\f[R] will be-left alone; the documents they link to will not be incorporated in the-document.-Limitation: resources that are loaded dynamically through JavaScript-cannot be incorporated; as a result, \f[C]--self-contained\f[R] does not-work with \f[C]--mathjax\f[R], and some advanced features (e.g.-zoom or speaker notes) may not work in an offline-\[dq]self-contained\[dq] \f[C]reveal.js\f[R] slide show.-.TP-.B \f[C]--html-q-tags\f[R]-Use \f[C]<q>\f[R] tags for quotes in HTML.-.TP-.B \f[C]--ascii\f[R]-Use only ASCII characters in output.-Currently supported for XML and HTML formats (which use entities instead-of UTF-8 when this option is selected), CommonMark, gfm, and Markdown-(which use entities), roff ms (which use hexadecimal escapes), and to a-limited degree LaTeX (which uses standard commands for accented-characters when possible).-roff man output uses ASCII by default.-.TP-.B \f[C]--reference-links\f[R]-Use reference-style links, rather than inline links, in writing Markdown-or reStructuredText.-By default inline links are used.-The placement of link references is affected by the-\f[C]--reference-location\f[R] option.-.TP-.B \f[C]--reference-location = block\f[R]|\f[C]section\f[R]|\f[C]document\f[R]-Specify whether footnotes (and references, if \f[C]reference-links\f[R]-is set) are placed at the end of the current (top-level) block, the-current section, or the document.-The default is \f[C]document\f[R].-Currently only affects the markdown writer.-.TP-.B \f[C]--atx-headers\f[R]-Use ATX-style headings in Markdown output.-The default is to use setext-style headings for levels 1 to 2, and then-ATX headings.-(Note: for \f[C]gfm\f[R] output, ATX headings are always used.) This-option also affects markdown cells in \f[C]ipynb\f[R] output.-.TP-.B \f[C]--top-level-division=[default|section|chapter|part]\f[R]-Treat top-level headings as the given division type in LaTeX, ConTeXt,-DocBook, and TEI output.-The hierarchy order is part, chapter, then section; all headings are-shifted such that the top-level heading becomes the specified type.-The default behavior is to determine the best division type via-heuristics: unless other conditions apply, \f[C]section\f[R] is chosen.-When the LaTeX document class is set to \f[C]report\f[R],-\f[C]book\f[R], or \f[C]memoir\f[R] (unless the \f[C]article\f[R] option-is specified), \f[C]chapter\f[R] is implied as the setting for this-option.-If \f[C]beamer\f[R] is the output format, specifying either-\f[C]chapter\f[R] or \f[C]part\f[R] will cause top-level headings to-become \f[C]\[rs]part{..}\f[R], while second-level headings remain as-their default type.-.TP-.B \f[C]-N\f[R], \f[C]--number-sections\f[R]-Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.-By default, sections are not numbered.-Sections with class \f[C]unnumbered\f[R] will never be numbered, even if-\f[C]--number-sections\f[R] is specified.-.TP-.B \f[C]--number-offset=\f[R]\f[I]NUMBER\f[R][\f[C],\f[R]\f[I]NUMBER\f[R]\f[C],\f[R]\f[I]...\f[R]]-Offset for section headings in HTML output (ignored in other output-formats).-The first number is added to the section number for top-level headings,-the second for second-level headings, and so on.-So, for example, if you want the first top-level heading in your-document to be numbered \[dq]6\[dq], specify-\f[C]--number-offset=5\f[R].-If your document starts with a level-2 heading which you want to be-numbered \[dq]1.5\[dq], specify \f[C]--number-offset=1,4\f[R].-Offsets are 0 by default.-Implies \f[C]--number-sections\f[R].-.TP-.B \f[C]--listings\f[R]-Use the \f[C]listings\f[R] package for LaTeX code blocks.-The package does not support multi-byte encoding for source code.-To handle UTF-8 you would need to use a custom template.-This issue is fully documented here: Encoding issue with the listings-package.-.TP-.B \f[C]-i\f[R], \f[C]--incremental\f[R]-Make list items in slide shows display incrementally (one by one).-The default is for lists to be displayed all at once.-.TP-.B \f[C]--slide-level=\f[R]\f[I]NUMBER\f[R]-Specifies that headings with the specified level create slides (for-\f[C]beamer\f[R], \f[C]s5\f[R], \f[C]slidy\f[R], \f[C]slideous\f[R],-\f[C]dzslides\f[R]).-Headings above this level in the hierarchy are used to divide the slide-show into sections; headings below this level create subheads within a-slide.-Note that content that is not contained under slide-level headings will-not appear in the slide show.-The default is to set the slide level based on the contents of the-document; see Structuring the slide show.-.TP-.B \f[C]--section-divs\f[R]-Wrap sections in \f[C]<section>\f[R] tags (or \f[C]<div>\f[R] tags for-\f[C]html4\f[R]), and attach identifiers to the enclosing-\f[C]<section>\f[R] (or \f[C]<div>\f[R]) rather than the heading itself.-See Heading identifiers, below.-.TP-.B \f[C]--email-obfuscation=none\f[R]|\f[C]javascript\f[R]|\f[C]references\f[R]-Specify a method for obfuscating \f[C]mailto:\f[R] links in HTML-documents.-\f[C]none\f[R] leaves \f[C]mailto:\f[R] links as they are.-\f[C]javascript\f[R] obfuscates them using JavaScript.-\f[C]references\f[R] obfuscates them by printing their letters as-decimal or hexadecimal character references.-The default is \f[C]none\f[R].-.TP-.B \f[C]--id-prefix=\f[R]\f[I]STRING\f[R]-Specify a prefix to be added to all identifiers and internal links in-HTML and DocBook output, and to footnote numbers in Markdown and Haddock-output.-This is useful for preventing duplicate identifiers when generating-fragments to be included in other pages.-.TP-.B \f[C]-T\f[R] \f[I]STRING\f[R], \f[C]--title-prefix=\f[R]\f[I]STRING\f[R]-Specify \f[I]STRING\f[R] 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[R].-.TP-.B \f[C]-c\f[R] \f[I]URL\f[R], \f[C]--css=\f[R]\f[I]URL\f[R]-Link to a CSS style sheet.-This option can be used repeatedly to include multiple files.-They will be included in the order specified.-.RS-.PP-A stylesheet is required for generating EPUB.-If none is provided using this option (or the \f[C]css\f[R] or-\f[C]stylesheet\f[R] metadata fields), pandoc will look for a file-\f[C]epub.css\f[R] in the user data directory (see-\f[C]--data-dir\f[R]).-If it is not found there, sensible defaults will be used.-.RE-.TP-.B \f[C]--reference-doc=\f[R]\f[I]FILE\f[R]-Use the specified file as a style reference in producing a docx or ODT-file.-.RS-.TP-.B Docx-For best results, the reference docx should be a modified version of a-docx file produced using pandoc.-The contents of the reference docx are ignored, but its stylesheets and-document properties (including margins, page size, header, and footer)-are used in the new docx.-If no reference docx is specified on the command line, pandoc will look-for a file \f[C]reference.docx\f[R] in the user data directory (see-\f[C]--data-dir\f[R]).-If this is not found either, sensible defaults will be used.-.RS-.PP-To produce a custom \f[C]reference.docx\f[R], first get a copy of the-default \f[C]reference.docx\f[R]:-\f[C]pandoc -o custom-reference.docx --print-default-data-file reference.docx\f[R].-Then open \f[C]custom-reference.docx\f[R] in Word, modify the styles as-you wish, and save the file.-For best results, do not make changes to this file other than modifying-the styles used by pandoc:-.PP-Paragraph styles:-.IP \[bu] 2-Normal-.IP \[bu] 2-Body Text-.IP \[bu] 2-First Paragraph-.IP \[bu] 2-Compact-.IP \[bu] 2-Title-.IP \[bu] 2-Subtitle-.IP \[bu] 2-Author-.IP \[bu] 2-Date-.IP \[bu] 2-Abstract-.IP \[bu] 2-Bibliography-.IP \[bu] 2-Heading 1-.IP \[bu] 2-Heading 2-.IP \[bu] 2-Heading 3-.IP \[bu] 2-Heading 4-.IP \[bu] 2-Heading 5-.IP \[bu] 2-Heading 6-.IP \[bu] 2-Heading 7-.IP \[bu] 2-Heading 8-.IP \[bu] 2-Heading 9-.IP \[bu] 2-Block Text-.IP \[bu] 2-Footnote Text-.IP \[bu] 2-Definition Term-.IP \[bu] 2-Definition-.IP \[bu] 2-Caption-.IP \[bu] 2-Table Caption-.IP \[bu] 2-Image Caption-.IP \[bu] 2-Figure-.IP \[bu] 2-Captioned Figure-.IP \[bu] 2-TOC Heading-.PP-Character styles:-.IP \[bu] 2-Default Paragraph Font-.IP \[bu] 2-Body Text Char-.IP \[bu] 2-Verbatim Char-.IP \[bu] 2-Footnote Reference-.IP \[bu] 2-Hyperlink-.PP-Table style:-.IP \[bu] 2-Table-.RE-.TP-.B 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[R] in the user data directory (see-\f[C]--data-dir\f[R]).-If this is not found either, sensible defaults will be used.-.RS-.PP-To produce a custom \f[C]reference.odt\f[R], first get a copy of the-default \f[C]reference.odt\f[R]:-\f[C]pandoc -o custom-reference.odt --print-default-data-file reference.odt\f[R].-Then open \f[C]custom-reference.odt\f[R] in LibreOffice, modify the-styles as you wish, and save the file.-.RE-.TP-.B PowerPoint-Templates included with Microsoft PowerPoint 2013 (either with-\f[C].pptx\f[R] or \f[C].potx\f[R] extension) are known to work, as are-most templates derived from these.-.RS-.PP-The specific requirement is that the template should begin with the-following first four layouts:-.IP "1." 3-Title Slide-.IP "2." 3-Title and Content-.IP "3." 3-Section Header-.IP "4." 3-Two Content-.PP-All templates included with a recent version of MS PowerPoint will fit-these criteria.-(You can click on \f[C]Layout\f[R] under the \f[C]Home\f[R] menu to-check.)-.PP-You can also modify the default \f[C]reference.pptx\f[R]: first run-\f[C]pandoc -o custom-reference.pptx --print-default-data-file reference.pptx\f[R],-and then modify \f[C]custom-reference.pptx\f[R] in MS PowerPoint (pandoc-will use the first four layout slides, as mentioned above).-.RE-.RE-.TP-.B \f[C]--epub-cover-image=\f[R]\f[I]FILE\f[R]-Use the specified image as the EPUB cover.-It is recommended that the image be less than 1000px in width and-height.-Note that in a Markdown source document you can also specify-\f[C]cover-image\f[R] in a YAML metadata block (see EPUB Metadata,-below).-.TP-.B \f[C]--epub-metadata=\f[R]\f[I]FILE\f[R]-Look in the specified XML file for metadata for the EPUB.-The file should contain a series of Dublin Core elements.-For example:-.RS-.IP-.nf-\f[C]- <dc:rights>Creative Commons</dc:rights>- <dc:language>es-AR</dc:language>-\f[R]-.fi-.PP-By default, pandoc will include the following metadata elements:-\f[C]<dc:title>\f[R] (from the document title), \f[C]<dc:creator>\f[R]-(from the document authors), \f[C]<dc:date>\f[R] (from the document-date, which should be in ISO 8601 format), \f[C]<dc:language>\f[R] (from-the \f[C]lang\f[R] variable, or, if is not set, the locale), and-\f[C]<dc:identifier id=\[dq]BookId\[dq]>\f[R] (a randomly generated-UUID).-Any of these may be overridden by elements in the metadata file.-.PP-Note: if the source document is Markdown, a YAML metadata block in the-document can be used instead.-See below under EPUB Metadata.-.RE-.TP-.B \f[C]--epub-embed-font=\f[R]\f[I]FILE\f[R]-Embed the specified font in the EPUB.-This option can be repeated to embed multiple fonts.-Wildcards can also be used: for example, \f[C]DejaVuSans-*.ttf\f[R].-However, if you use wildcards on the command line, be sure to escape-them or put the whole filename in single quotes, to prevent them from-being interpreted by the shell.-To use the embedded fonts, you will need to add declarations like the-following to your CSS (see \f[C]--css\f[R]):-.RS-.IP-.nf-\f[C]-\[at]font-face {-font-family: DejaVuSans;-font-style: normal;-font-weight: normal;-src:url(\[dq]DejaVuSans-Regular.ttf\[dq]);-}-\[at]font-face {-font-family: DejaVuSans;-font-style: normal;-font-weight: bold;-src:url(\[dq]DejaVuSans-Bold.ttf\[dq]);-}-\[at]font-face {-font-family: DejaVuSans;-font-style: italic;-font-weight: normal;-src:url(\[dq]DejaVuSans-Oblique.ttf\[dq]);-}-\[at]font-face {-font-family: DejaVuSans;-font-style: italic;-font-weight: bold;-src:url(\[dq]DejaVuSans-BoldOblique.ttf\[dq]);-}-body { font-family: \[dq]DejaVuSans\[dq]; }-\f[R]-.fi-.RE-.TP-.B \f[C]--epub-chapter-level=\f[R]\f[I]NUMBER\f[R]-Specify the heading level at which to split the EPUB into separate-\[dq]chapter\[dq] files.-The default is to split into chapters at level-1 headings.-This option only affects the internal composition of the EPUB, not the-way chapters and sections are displayed to users.-Some readers may be slow if the chapter files are too large, so for-large documents with few level-1 headings, one might want to use a-chapter level of 2 or 3.-.TP-.B \f[C]--epub-subdirectory=\f[R]\f[I]DIRNAME\f[R]-Specify the subdirectory in the OCF container that is to hold the-EPUB-specific contents.-The default is \f[C]EPUB\f[R].-To put the EPUB contents in the top level, use an empty string.-.TP-.B \f[C]--ipynb-output=all|none|best\f[R]-Determines how ipynb output cells are treated.-\f[C]all\f[R] means that all of the data formats included in the-original are preserved.-\f[C]none\f[R] means that the contents of data cells are omitted.-\f[C]best\f[R] causes pandoc to try to pick the richest data block in-each output cell that is compatible with the output format.-The default is \f[C]best\f[R].-.TP-.B \f[C]--pdf-engine=\f[R]\f[I]PROGRAM\f[R]-Use the specified engine when producing PDF output.-Valid values are \f[C]pdflatex\f[R], \f[C]lualatex\f[R],-\f[C]xelatex\f[R], \f[C]latexmk\f[R], \f[C]tectonic\f[R],-\f[C]wkhtmltopdf\f[R], \f[C]weasyprint\f[R], \f[C]prince\f[R],-\f[C]context\f[R], and \f[C]pdfroff\f[R].-The default is \f[C]pdflatex\f[R].-If the engine is not in your PATH, the full path of the engine may be-specified here.-.TP-.B \f[C]--pdf-engine-opt=\f[R]\f[I]STRING\f[R]-Use the given string as a command-line argument to the-\f[C]pdf-engine\f[R].-For example, to use a persistent directory \f[C]foo\f[R] for-\f[C]latexmk\f[R]\[aq]s auxiliary files, use-\f[C]--pdf-engine-opt=-outdir=foo\f[R].-Note that no check for duplicate options is done.-.SS Citation rendering-.TP-.B \f[C]--bibliography=\f[R]\f[I]FILE\f[R]-Set the \f[C]bibliography\f[R] field in the document\[aq]s metadata to-\f[I]FILE\f[R], overriding any value set in the metadata, and process-citations using \f[C]pandoc-citeproc\f[R].-(This is equivalent to-\f[C]--metadata bibliography=FILE --filter pandoc-citeproc\f[R].) If-\f[C]--natbib\f[R] or \f[C]--biblatex\f[R] is also supplied,-\f[C]pandoc-citeproc\f[R] is not used, making this equivalent to-\f[C]--metadata bibliography=FILE\f[R].-If you supply this argument multiple times, each \f[I]FILE\f[R] will be-added to bibliography.-.TP-.B \f[C]--csl=\f[R]\f[I]FILE\f[R]-Set the \f[C]csl\f[R] field in the document\[aq]s metadata to-\f[I]FILE\f[R], overriding any value set in the metadata.-(This is equivalent to \f[C]--metadata csl=FILE\f[R].) This option is-only relevant with \f[C]pandoc-citeproc\f[R].-.TP-.B \f[C]--citation-abbreviations=\f[R]\f[I]FILE\f[R]-Set the \f[C]citation-abbreviations\f[R] field in the document\[aq]s-metadata to \f[I]FILE\f[R], overriding any value set in the metadata.-(This is equivalent to-\f[C]--metadata citation-abbreviations=FILE\f[R].) This option is only-relevant with \f[C]pandoc-citeproc\f[R].-.TP-.B \f[C]--natbib\f[R]-Use \f[C]natbib\f[R] for citations in LaTeX output.-This option is not for use with the \f[C]pandoc-citeproc\f[R] filter or-with PDF output.-It is intended for use in producing a LaTeX file that can be processed-with \f[C]bibtex\f[R].-.TP-.B \f[C]--biblatex\f[R]-Use \f[C]biblatex\f[R] for citations in LaTeX output.-This option is not for use with the \f[C]pandoc-citeproc\f[R] filter or-with PDF output.-It is intended for use in producing a LaTeX file that can be processed-with \f[C]bibtex\f[R] or \f[C]biber\f[R].-.SS Math rendering in HTML-.PP-The default is to render TeX math as far as possible using Unicode-characters.-Formulas are put inside a \f[C]span\f[R] with-\f[C]class=\[dq]math\[dq]\f[R], so that they may be styled differently-from the surrounding text if needed.-However, this gives acceptable results only for basic math, usually you-will want to use \f[C]--mathjax\f[R] or another of the following-options.-.TP-.B \f[C]--mathjax\f[R][\f[C]=\f[R]\f[I]URL\f[R]]-Use MathJax to display embedded TeX math in HTML output.-TeX math will be put between \f[C]\[rs](...\[rs])\f[R] (for inline math)-or \f[C]\[rs][...\[rs]]\f[R] (for display math) and wrapped in-\f[C]<span>\f[R] tags with class \f[C]math\f[R].-Then the MathJax JavaScript will render it.-The \f[I]URL\f[R] should point to the \f[C]MathJax.js\f[R] load script.-If a \f[I]URL\f[R] is not provided, a link to the Cloudflare CDN will be-inserted.-.TP-.B \f[C]--mathml\f[R]-Convert TeX math to MathML (in \f[C]epub3\f[R], \f[C]docbook4\f[R],-\f[C]docbook5\f[R], \f[C]jats\f[R], \f[C]html4\f[R] and-\f[C]html5\f[R]).-This is the default in \f[C]odt\f[R] output.-Note that currently only Firefox and Safari (and select e-book readers)-natively support MathML.-.TP-.B \f[C]--webtex\f[R][\f[C]=\f[R]\f[I]URL\f[R]]-Convert TeX formulas to \f[C]<img>\f[R] tags that link to an external-script that converts formulas to images.-The formula will be URL-encoded and concatenated with the URL provided.-For SVG images you can for example use-\f[C]--webtex https://latex.codecogs.com/svg.latex?\f[R].-If no URL is specified, the CodeCogs URL generating PNGs will be used-(\f[C]https://latex.codecogs.com/png.latex?\f[R]).-Note: the \f[C]--webtex\f[R] option will affect Markdown output as well-as HTML, which is useful if you\[aq]re targeting a version of Markdown-without native math support.-.TP-.B \f[C]--katex\f[R][\f[C]=\f[R]\f[I]URL\f[R]]-Use KaTeX to display embedded TeX math in HTML output.-The \f[I]URL\f[R] is the base URL for the KaTeX library.-That directory should contain a \f[C]katex.min.js\f[R] and a-\f[C]katex.min.css\f[R] file.-If a \f[I]URL\f[R] is not provided, a link to the KaTeX CDN will be-inserted.-.TP-.B \f[C]--gladtex\f[R]-Enclose TeX math in \f[C]<eq>\f[R] tags in HTML output.-The resulting HTML can then be processed by GladTeX to produce images of-the typeset formulas and an HTML file with links to these images.-So, the procedure is:-.RS-.IP-.nf-\f[C]-pandoc -s --gladtex input.md -o myfile.htex-gladtex -d myfile-images myfile.htex-# produces myfile.html and images in myfile-images-\f[R]-.fi-.RE-.SS Options for wrapper scripts-.TP-.B \f[C]--dump-args\f[R]-Print information about command-line arguments to \f[I]stdout\f[R], 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[R] option, or \f[C]-\f[R] (for \f[I]stdout\f[R]) 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[R] separator at the end-of the line.-.TP-.B \f[C]--ignore-args\f[R]-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[R]-.fi-.PP-is equivalent to-.IP-.nf-\f[C]-pandoc -o foo.html -s-\f[R]-.fi-.RE-.SH TEMPLATES-.PP-When the \f[C]-s/--standalone\f[R] 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[R]-.fi-.PP-where \f[I]FORMAT\f[R] is the name of the output format.-A custom template can be specified using the \f[C]--template\f[R]-option.-You can also override the system default templates for a given output-format \f[I]FORMAT\f[R] by putting a file-\f[C]templates/default.*FORMAT*\f[R] in the user data directory (see-\f[C]--data-dir\f[R], above).-\f[I]Exceptions:\f[R]-.IP \[bu] 2-For \f[C]odt\f[R] output, customize the \f[C]default.opendocument\f[R]-template.-.IP \[bu] 2-For \f[C]pdf\f[R] output, customize the \f[C]default.latex\f[R] template-(or the \f[C]default.context\f[R] template, if you use-\f[C]-t context\f[R], or the \f[C]default.ms\f[R] template, if you use-\f[C]-t ms\f[R], or the \f[C]default.html\f[R] template, if you use-\f[C]-t html\f[R]).-.IP \[bu] 2-\f[C]docx\f[R] and \f[C]pptx\f[R] have no template (however, you can use-\f[C]--reference-doc\f[R] to customize the output).-.PP-Templates contain \f[I]variables\f[R], which allow for the inclusion of-arbitrary information at any point in the file.-They may be set at the command line using the \f[C]-V/--variable\f[R]-option.-If a variable is not set, pandoc will look for the key in the-document\[aq]s metadata \[en] which can be set using either YAML-metadata blocks or with the \f[C]-M/--metadata\f[R] option.-.SS Metadata variables-.TP-.B \f[C]title\f[R], \f[C]author\f[R], \f[C]date\f[R]-allow identification of basic aspects of the document.-Included in PDF metadata through LaTeX and ConTeXt.-These can be set through a pandoc title block, which allows for multiple-authors, or through a YAML metadata block:-.RS-.IP-.nf-\f[C]-----author:-- Aristotle-- Peter Abelard-\&...-\f[R]-.fi-.PP-Note that if you just want to set PDF or HTML metadata, without-including a title block in the document itself, you can set the-\f[C]title-meta\f[R], \f[C]author-meta\f[R], and \f[C]date-meta\f[R]-variables.-(By default these are set automatically, based on \f[C]title\f[R],-\f[C]author\f[R], and \f[C]date\f[R].)-.RE-.TP-.B \f[C]subtitle\f[R]-document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx-documents-.TP-.B \f[C]abstract\f[R]-document summary, included in LaTeX, ConTeXt, AsciiDoc, and docx-documents-.TP-.B \f[C]keywords\f[R]-list of keywords to be included in HTML, PDF, ODT, pptx, docx and-AsciiDoc metadata; repeat as for \f[C]author\f[R], above-.TP-.B \f[C]subject\f[R]-document subject, included in ODT, PDF, docx and pptx metadata-.TP-.B \f[C]description\f[R]-document description, included in ODT, docx and pptx metadata.-Some applications show this as \f[C]Comments\f[R] metadata.-.TP-.B \f[C]category\f[R]-document category, included in docx and pptx metadata-.PP-Additionally, any root-level string metadata, not included in ODT, docx-or pptx metadata is added as a \f[I]custom property\f[R].-The following YAML metadata block for instance:-.IP-.nf-\f[C]-----title:  \[aq]This is the title\[aq]-subtitle: \[dq]This is the subtitle\[dq]-author:-- Author One-- Author Two-description: |-    This is a long-    description.--    It consists of two paragraphs-\&...-\f[R]-.fi-.PP-will include \f[C]title\f[R], \f[C]author\f[R] and \f[C]description\f[R]-as standard document properties and \f[C]subtitle\f[R] as a custom-property when converting to docx, ODT or pptx.-.SS Language variables-.TP-.B \f[C]lang\f[R]-identifies the main language of the document using IETF language tags-(following the BCP 47 standard), such as \f[C]en\f[R] or-\f[C]en-GB\f[R].-The Language subtag lookup tool can look up or verify these tags.-This affects most formats, and controls hyphenation in PDF output when-using LaTeX (through \f[C]babel\f[R] and \f[C]polyglossia\f[R]) or-ConTeXt.-.RS-.PP-Use native pandoc Divs and Spans with the \f[C]lang\f[R] attribute to-switch the language:-.IP-.nf-\f[C]-----lang: en-GB-\&...--Text in the main document language (British English).--::: {lang=fr-CA}-> Cette citation est \['e]crite en fran\[,c]ais canadien.-:::--More text in English. [\[aq]Zitat auf Deutsch.\[aq]]{lang=de}-\f[R]-.fi-.RE-.TP-.B \f[C]dir\f[R]-the base script direction, either \f[C]rtl\f[R] (right-to-left) or-\f[C]ltr\f[R] (left-to-right).-.RS-.PP-For bidirectional documents, native pandoc \f[C]span\f[R]s and-\f[C]div\f[R]s with the \f[C]dir\f[R] attribute (value \f[C]rtl\f[R] or-\f[C]ltr\f[R]) can be used to override the base direction in some output-formats.-This may not always be necessary if the final renderer (e.g.-the browser, when generating HTML) supports the Unicode Bidirectional-Algorithm.-.PP-When using LaTeX for bidirectional documents, only the \f[C]xelatex\f[R]-engine is fully supported (use \f[C]--pdf-engine=xelatex\f[R]).-.RE-.SS Variables for HTML slides-.PP-These affect HTML output when producing slide shows with pandoc.-All reveal.js configuration options are available as variables.-.TP-.B \f[C]revealjs-url\f[R]-base URL for reveal.js documents (defaults to \f[C]reveal.js\f[R])-.TP-.B \f[C]s5-url\f[R]-base URL for S5 documents (defaults to \f[C]s5/default\f[R])-.TP-.B \f[C]slidy-url\f[R]-base URL for Slidy documents (defaults to-\f[C]https://www.w3.org/Talks/Tools/Slidy2\f[R])-.TP-.B \f[C]slideous-url\f[R]-base URL for Slideous documents (defaults to \f[C]slideous\f[R])-.SS Variables for Beamer slides-.PP-These variables change the appearance of PDF slides using-\f[C]beamer\f[R].-.TP-.B \f[C]aspectratio\f[R]-slide aspect ratio (\f[C]43\f[R] for 4:3 [default], \f[C]169\f[R] for-16:9, \f[C]1610\f[R] for 16:10, \f[C]149\f[R] for 14:9, \f[C]141\f[R]-for 1.41:1, \f[C]54\f[R] for 5:4, \f[C]32\f[R] for 3:2)-.TP-.B \f[C]beamerarticle\f[R]-produce an article from Beamer slides-.TP-.B \f[C]beameroption\f[R]-add extra beamer option with \f[C]\[rs]setbeameroption{}\f[R]-.TP-.B \f[C]institute\f[R]-author affiliations: can be a list when there are multiple authors-.TP-.B \f[C]logo\f[R]-logo image for slides-.TP-.B \f[C]navigation\f[R]-controls navigation symbols (default is \f[C]empty\f[R] for no-navigation symbols; other valid values are \f[C]frame\f[R],-\f[C]vertical\f[R], and \f[C]horizontal\f[R])-.TP-.B \f[C]section-titles\f[R]-enables \[dq]title pages\[dq] for new sections (default is true)-.TP-.B \f[C]theme\f[R], \f[C]colortheme\f[R], \f[C]fonttheme\f[R], \f[C]innertheme\f[R], \f[C]outertheme\f[R]-beamer themes:-.TP-.B \f[C]themeoptions\f[R]-options for LaTeX beamer themes (a list).-.TP-.B \f[C]titlegraphic\f[R]-image for title slide-.SS Variables for LaTeX-.PP-Pandoc uses these variables when creating a PDF with a LaTeX engine.-.SS Layout-.TP-.B \f[C]block-headings\f[R]-make \f[C]\[rs]paragraph\f[R] and \f[C]\[rs]subparagraph\f[R] (fourth--and fifth-level headings, or fifth- and sixth-level with book classes)-free-standing rather than run-in; requires further formatting to-distinguish from \f[C]\[rs]subsubsection\f[R] (third- or fourth-level-headings).-Instead of using this option, KOMA-Script can adjust headings more-extensively:-.RS-.IP-.nf-\f[C]-----documentclass: scrartcl-header-includes: |-  \[rs]RedeclareSectionCommand[-    beforeskip=-10pt plus -2pt minus -1pt,-    afterskip=1sp plus -1sp minus 1sp,-    font=\[rs]normalfont\[rs]itshape]{paragraph}-  \[rs]RedeclareSectionCommand[-    beforeskip=-10pt plus -2pt minus -1pt,-    afterskip=1sp plus -1sp minus 1sp,-    font=\[rs]normalfont\[rs]scshape,-    indent=0pt]{subparagraph}-\&...-\f[R]-.fi-.RE-.TP-.B \f[C]classoption\f[R]-option for document class, e.g.-\f[C]oneside\f[R]; repeat for multiple options:-.RS-.IP-.nf-\f[C]-----classoption:-- twocolumn-- landscape-\&...-\f[R]-.fi-.RE-.TP-.B \f[C]documentclass\f[R]-document class: usually one of the standard classes, \f[C]article\f[R],-\f[C]book\f[R], and \f[C]report\f[R]; the KOMA-Script equivalents,-\f[C]scrartcl\f[R], \f[C]scrbook\f[R], and \f[C]scrreprt\f[R], which-default to smaller margins; or \f[C]memoir\f[R]-.TP-.B \f[C]geometry\f[R]-option for \f[C]geometry\f[R] package, e.g.-\f[C]margin=1in\f[R]; repeat for multiple options:-.RS-.IP-.nf-\f[C]-----geometry:-- top=30mm-- left=20mm-- heightrounded-\&...-\f[R]-.fi-.RE-.TP-.B \f[C]indent\f[R]-uses document class settings for indentation (the default LaTeX template-otherwise removes indentation and adds space between paragraphs)-.TP-.B \f[C]linestretch\f[R]-adjusts line spacing using the \f[C]setspace\f[R] package, e.g.-\f[C]1.25\f[R], \f[C]1.5\f[R]-.TP-.B \f[C]margin-left\f[R], \f[C]margin-right\f[R], \f[C]margin-top\f[R], \f[C]margin-bottom\f[R]-sets margins if \f[C]geometry\f[R] is not used (otherwise-\f[C]geometry\f[R] overrides these)-.TP-.B \f[C]pagestyle\f[R]-control \f[C]\[rs]pagestyle{}\f[R]: the default article class supports-\f[C]plain\f[R] (default), \f[C]empty\f[R] (no running heads or page-numbers), and \f[C]headings\f[R] (section titles in running heads)-.TP-.B \f[C]papersize\f[R]-paper size, e.g.-\f[C]letter\f[R], \f[C]a4\f[R]-.TP-.B \f[C]secnumdepth\f[R]-numbering depth for sections (with \f[C]--number-sections\f[R] option or-\f[C]numbersections\f[R] variable)-.SS Fonts-.TP-.B \f[C]fontenc\f[R]-allows font encoding to be specified through \f[C]fontenc\f[R] package-(with \f[C]pdflatex\f[R]); default is \f[C]T1\f[R] (see LaTeX font-encodings guide)-.TP-.B \f[C]fontfamily\f[R]-font package for use with \f[C]pdflatex\f[R]: TeX Live includes many-options, documented in the LaTeX Font Catalogue.-The default is Latin Modern.-.TP-.B \f[C]fontfamilyoptions\f[R]-options for package used as \f[C]fontfamily\f[R]; repeat for multiple-options.-For example, to use the Libertine font with proportional lowercase-(old-style) figures through the \f[C]libertinus\f[R] package:-.RS-.IP-.nf-\f[C]-----fontfamily: libertinus-fontfamilyoptions:-- osf-- p-\&...-\f[R]-.fi-.RE-.TP-.B \f[C]fontsize\f[R]-font size for body text.-The standard classes allow 10pt, 11pt, and 12pt.-To use another size, set \f[C]documentclass\f[R] to one of the-KOMA-Script classes, such as \f[C]scrartcl\f[R] or \f[C]scrbook\f[R].-.TP-.B \f[C]mainfont\f[R], \f[C]sansfont\f[R], \f[C]monofont\f[R], \f[C]mathfont\f[R], \f[C]CJKmainfont\f[R]-font families for use with \f[C]xelatex\f[R] or \f[C]lualatex\f[R]: take-the name of any system font, using the \f[C]fontspec\f[R] package.-\f[C]CJKmainfont\f[R] uses the \f[C]xecjk\f[R] package.-.TP-.B \f[C]mainfontoptions\f[R], \f[C]sansfontoptions\f[R], \f[C]monofontoptions\f[R], \f[C]mathfontoptions\f[R], \f[C]CJKoptions\f[R]-options to use with \f[C]mainfont\f[R], \f[C]sansfont\f[R],-\f[C]monofont\f[R], \f[C]mathfont\f[R], \f[C]CJKmainfont\f[R] in-\f[C]xelatex\f[R] and \f[C]lualatex\f[R].-Allow for any choices available through \f[C]fontspec\f[R]; repeat for-multiple options.-For example, to use the TeX Gyre version of Palatino with lowercase-figures:-.RS-.IP-.nf-\f[C]-----mainfont: TeX Gyre Pagella-mainfontoptions:-- Numbers=Lowercase-- Numbers=Proportional-\&...-\f[R]-.fi-.RE-.TP-.B \f[C]microtypeoptions\f[R]-options to pass to the microtype package-.SS Links-.TP-.B \f[C]colorlinks\f[R]-add color to link text; automatically enabled if any of-\f[C]linkcolor\f[R], \f[C]filecolor\f[R], \f[C]citecolor\f[R],-\f[C]urlcolor\f[R], or \f[C]toccolor\f[R] are set-.TP-.B \f[C]linkcolor\f[R], \f[C]filecolor\f[R], \f[C]citecolor\f[R], \f[C]urlcolor\f[R], \f[C]toccolor\f[R]-color for internal links, external links, citation links, linked URLs,-and links in table of contents, respectively: uses options allowed by-\f[C]xcolor\f[R], including the \f[C]dvipsnames\f[R],-\f[C]svgnames\f[R], and \f[C]x11names\f[R] lists-.TP-.B \f[C]links-as-notes\f[R]-causes links to be printed as footnotes-.SS Front matter-.TP-.B \f[C]lof\f[R], \f[C]lot\f[R]-include list of figures, list of tables-.TP-.B \f[C]thanks\f[R]-contents of acknowledgments footnote after document title-.TP-.B \f[C]toc\f[R]-include table of contents (can also be set using-\f[C]--toc/--table-of-contents\f[R])-.TP-.B \f[C]toc-depth\f[R]-level of section to include in table of contents-.SS BibLaTeX Bibliographies-.PP-These variables function when using BibLaTeX for citation rendering.-.TP-.B \f[C]biblatexoptions\f[R]-list of options for biblatex-.TP-.B \f[C]biblio-style\f[R]-bibliography style, when used with \f[C]--natbib\f[R] and-\f[C]--biblatex\f[R].-.TP-.B \f[C]biblio-title\f[R]-bibliography title, when used with \f[C]--natbib\f[R] and-\f[C]--biblatex\f[R].-.TP-.B \f[C]bibliography\f[R]-bibliography to use for resolving references-.TP-.B \f[C]natbiboptions\f[R]-list of options for natbib-.SS Variables for ConTeXt-.PP-Pandoc uses these variables when creating a PDF with ConTeXt.-.TP-.B \f[C]fontsize\f[R]-font size for body text (e.g.-\f[C]10pt\f[R], \f[C]12pt\f[R])-.TP-.B \f[C]headertext\f[R], \f[C]footertext\f[R]-text to be placed in running header or footer (see ConTeXt Headers and-Footers); repeat up to four times for different placement-.TP-.B \f[C]indenting\f[R]-controls indentation of paragraphs, e.g.-\f[C]yes,small,next\f[R] (see ConTeXt Indentation); repeat for multiple-options-.TP-.B \f[C]interlinespace\f[R]-adjusts line spacing, e.g.-\f[C]4ex\f[R] (using \f[C]setupinterlinespace\f[R]); repeat for multiple-options-.TP-.B \f[C]layout\f[R]-options for page margins and text arrangement (see ConTeXt Layout);-repeat for multiple options-.TP-.B \f[C]linkcolor\f[R], \f[C]contrastcolor\f[R]-color for links outside and inside a page, e.g.-\f[C]red\f[R], \f[C]blue\f[R] (see ConTeXt Color)-.TP-.B \f[C]linkstyle\f[R]-typeface style for links, e.g.-\f[C]normal\f[R], \f[C]bold\f[R], \f[C]slanted\f[R],-\f[C]boldslanted\f[R], \f[C]type\f[R], \f[C]cap\f[R], \f[C]small\f[R]-.TP-.B \f[C]lof\f[R], \f[C]lot\f[R]-include list of figures, list of tables-.TP-.B \f[C]mainfont\f[R], \f[C]sansfont\f[R], \f[C]monofont\f[R], \f[C]mathfont\f[R]-font families: take the name of any system font (see ConTeXt Font-Switching)-.TP-.B \f[C]margin-left\f[R], \f[C]margin-right\f[R], \f[C]margin-top\f[R], \f[C]margin-bottom\f[R]-sets margins, if \f[C]layout\f[R] is not used (otherwise-\f[C]layout\f[R] overrides these)-.TP-.B \f[C]pagenumbering\f[R]-page number style and location (using \f[C]setuppagenumbering\f[R]);-repeat for multiple options-.TP-.B \f[C]papersize\f[R]-paper size, e.g.-\f[C]letter\f[R], \f[C]A4\f[R], \f[C]landscape\f[R] (see ConTeXt Paper-Setup); repeat for multiple options-.TP-.B \f[C]pdfa\f[R]-adds to the preamble the setup necessary to generate PDF/A-1b:2005.-To successfully generate PDF/A the required ICC color profiles have to-be available and the content and all included files (such as images)-have to be standard conforming.-The ICC profiles can be obtained from ConTeXt ICC Profiles.-See also ConTeXt PDFA for more details.-.TP-.B \f[C]toc\f[R]-include table of contents (can also be set using-\f[C]--toc/--table-of-contents\f[R])-.TP-.B \f[C]whitespace\f[R]-spacing between paragraphs, e.g.-\f[C]none\f[R], \f[C]small\f[R] (using \f[C]setupwhitespace\f[R])-.SS Variables for \f[C]wkhtmltopdf\f[R]-.PP-Pandoc uses these variables when creating a PDF with-\f[C]wkhtmltopdf\f[R].-The \f[C]--css\f[R] option also affects the output.-.TP-.B \f[C]footer-html\f[R], \f[C]header-html\f[R]-add information to the header and footer-.TP-.B \f[C]margin-left\f[R], \f[C]margin-right\f[R], \f[C]margin-top\f[R], \f[C]margin-bottom\f[R]-set the page margins-.TP-.B \f[C]papersize\f[R]-sets the PDF paper size-.SS Variables for man pages-.TP-.B \f[C]adjusting\f[R]-adjusts text to left (\f[C]l\f[R]), right (\f[C]r\f[R]), center-(\f[C]c\f[R]), or both (\f[C]b\f[R]) margins-.TP-.B \f[C]footer\f[R]-footer in man pages-.TP-.B \f[C]header\f[R]-header in man pages-.TP-.B \f[C]hyphenate\f[R]-if \f[C]true\f[R] (the default), hyphenation will be used-.TP-.B \f[C]section\f[R]-section number in man pages-.SS Variables for ms-.TP-.B \f[C]fontfamily\f[R]-font family (e.g.-\f[C]T\f[R] or \f[C]P\f[R])-.TP-.B \f[C]indent\f[R]-paragraph indent (e.g.-\f[C]2m\f[R])-.TP-.B \f[C]lineheight\f[R]-line height (e.g.-\f[C]12p\f[R])-.TP-.B \f[C]pointsize\f[R]-point size (e.g.-\f[C]10p\f[R])-.SS Structural variables-.PP-Pandoc sets these variables automatically in response to options or-document contents; users can also modify them.-These vary depending on the output format, and include the following:-.TP-.B \f[C]body\f[R]-body of document-.TP-.B \f[C]date-meta\f[R]-the \f[C]date\f[R] variable converted to ISO 8601 YYYY-MM-DD, included-in all HTML based formats (dzslides, epub, html, html4, html5, revealjs,-s5, slideous, slidy).-The recognized formats for \f[C]date\f[R] are: \f[C]mm/dd/yyyy\f[R],-\f[C]mm/dd/yy\f[R], \f[C]yyyy-mm-dd\f[R] (ISO 8601),-\f[C]dd MM yyyy\f[R] (e.g.-either \f[C]02 Apr 2018\f[R] or \f[C]02 April 2018\f[R]),-\f[C]MM dd, yyyy\f[R] (e.g.-\f[C]Apr. 02, 2018\f[R] or-\f[C]April 02, 2018),\f[R]yyyy[mm[dd]]]\f[C](e.g.\f[R]20180402,-\f[C]201804\f[R] or \f[C]2018\f[R]).-.TP-.B \f[C]header-includes\f[R]-contents specified by \f[C]-H/--include-in-header\f[R] (may have-multiple values)-.TP-.B \f[C]include-before\f[R]-contents specified by \f[C]-B/--include-before-body\f[R] (may have-multiple values)-.TP-.B \f[C]include-after\f[R]-contents specified by \f[C]-A/--include-after-body\f[R] (may have-multiple values)-.TP-.B \f[C]meta-json\f[R]-JSON representation of all of the document\[aq]s metadata.-Field values are transformed to the selected output format.-.TP-.B \f[C]numbersections\f[R]-non-null value if \f[C]-N/--number-sections\f[R] was specified-.TP-.B \f[C]sourcefile\f[R], \f[C]outputfile\f[R]-source and destination filenames, as given on the command line.-\f[C]sourcefile\f[R] can also be a list if input comes from multiple-files, or empty if input is from stdin.-You can use the following snippet in your template to distinguish them:-.RS-.IP-.nf-\f[C]-$if(sourcefile)$-$for(sourcefile)$-$sourcefile$-$endfor$-$else$-(stdin)-$endif$-\f[R]-.fi-.PP-Similarly, \f[C]outputfile\f[R] can be \f[C]-\f[R] if output goes to the-terminal.-.PP-If you need absolute paths, use e.g.-\f[C]$curdir$/$sourcefile$\f[R].-.RE-.TP-.B \f[C]curdir\f[R]-working directory from which pandoc is run.-.TP-.B \f[C]toc\f[R]-non-null value if \f[C]--toc/--table-of-contents\f[R] was specified-.TP-.B \f[C]toc-title\f[R]-title of table of contents (works only with EPUB, opendocument, odt,-docx, pptx, beamer, LaTeX)-.SS Using variables in templates-.PP-Variable names are sequences of alphanumerics, \f[C]-\f[R], and-\f[C]_\f[R], starting with a letter.-A variable name surrounded by \f[C]$\f[R] signs will be replaced by its-value.-For example, the string \f[C]$title$\f[R] in-.IP-.nf-\f[C]-<title>$title$</title>-\f[R]-.fi-.PP-will be replaced by the document title.-.PP-To write a literal \f[C]$\f[R] in a template, use \f[C]$$\f[R].-.PP-Templates may contain conditionals.-The syntax is as follows:-.IP-.nf-\f[C]-$if(variable)$-X-$else$-Y-$endif$-\f[R]-.fi-.PP-This will include \f[C]X\f[R] in the template if \f[C]variable\f[R] has-a truthy value; otherwise it will include \f[C]Y\f[R].-Here a truthy value is any of the following:-.IP \[bu] 2-a string that is not entirely white space,-.IP \[bu] 2-a non-empty array where the first value is truthy,-.IP \[bu] 2-any number (including zero),-.IP \[bu] 2-any object,-.IP \[bu] 2-the boolean \f[C]true\f[R] (to specify the boolean \f[C]true\f[R] value-using YAML metadata or the \f[C]--metadata\f[R] flag, use-\f[C]true\f[R], \f[C]True\f[R], or \f[C]TRUE\f[R]; with the-\f[C]--variable\f[R] flag, simply omit a value for the variable, e.g.-\f[C]--variable draft\f[R]).-.PP-\f[C]X\f[R] and \f[C]Y\f[R] are placeholders for any valid template-text, and may include interpolated variables or other conditionals.-The \f[C]$else$\f[R] section may be omitted.-.PP-When variables can have multiple values (for example, \f[C]author\f[R]-in a multi-author document), you can use the \f[C]$for$\f[R] keyword:-.IP-.nf-\f[C]-$for(author)$-<meta name=\[dq]author\[dq] content=\[dq]$author$\[dq] />-$endfor$-\f[R]-.fi-.PP-You can optionally specify a separator to be used between consecutive-items:-.IP-.nf-\f[C]-$for(author)$$author$$sep$, $endfor$-\f[R]-.fi-.PP-Note that the separator needs to be specified immediately before the-\f[C]$endfor\f[R] keyword.-.PP-A dot can be used to select a field of a variable that takes an object-as its value.-So, for example:-.IP-.nf-\f[C]-$author.name$ ($author.affiliation$)-\f[R]-.fi-.PP-The value of a variable will be indented to the same level as the-variable.-.PP-If you use custom templates, you may need to revise them as pandoc-changes.-We recommend tracking the changes in the default templates, and-modifying your custom templates accordingly.-An easy way to do this is to fork the pandoc-templates repository and-merge in changes after each pandoc release.-.PP-Templates may contain comments: anything on a line after \f[C]$--\f[R]-will be treated as a comment and ignored.-.SH EXTENSIONS-.PP-The behavior of some of the readers and writers can be adjusted by-enabling or disabling various extensions.-.PP-An extension can be enabled by adding \f[C]+EXTENSION\f[R] to the format-name and disabled by adding \f[C]-EXTENSION\f[R].-For example, \f[C]--from markdown_strict+footnotes\f[R] is strict-Markdown with footnotes enabled, while-\f[C]--from markdown-footnotes-pipe_tables\f[R] is pandoc\[aq]s Markdown-without footnotes or pipe tables.-.PP-The markdown reader and writer make by far the most use of extensions.-Extensions only used by them are therefore covered in the section-Pandoc\[aq]s Markdown below (See Markdown variants for-\f[C]commonmark\f[R] and \f[C]gfm\f[R].) In the following, extensions-that also work for other formats are covered.-.PP-Note that markdown extensions added to the \f[C]ipynb\f[R] format affect-Markdown cells in Jupyter notebooks (as do command-line options like-\f[C]--atx-headers\f[R]).-.SS Typography-.SS Extension: \f[C]smart\f[R]-.PP-Interpret straight quotes as curly quotes, \f[C]---\f[R] as em-dashes,-\f[C]--\f[R] as en-dashes, and \f[C]...\f[R] as ellipses.-Nonbreaking spaces are inserted after certain abbreviations, such as-\[dq]Mr.\[dq]-.PP-This extension can be enabled/disabled for the following formats:-.TP-.B input formats-\f[C]markdown\f[R], \f[C]commonmark\f[R], \f[C]latex\f[R],-\f[C]mediawiki\f[R], \f[C]org\f[R], \f[C]rst\f[R], \f[C]twiki\f[R]-.TP-.B output formats-\f[C]markdown\f[R], \f[C]latex\f[R], \f[C]context\f[R], \f[C]rst\f[R]-.TP-.B enabled by default in-\f[C]markdown\f[R], \f[C]latex\f[R], \f[C]context\f[R] (both input and-output)-.PP-Note: If you are \f[I]writing\f[R] Markdown, then the \f[C]smart\f[R]-extension has the reverse effect: what would have been curly quotes-comes out straight.-.PP-In LaTeX, \f[C]smart\f[R] means to use the standard TeX ligatures for-quotation marks (\f[C]\[ga]\[ga]\f[R] and \f[C]\[aq]\[aq]\f[R] for-double quotes, \f[C]\[ga]\f[R] and \f[C]\[aq]\f[R] for single quotes)-and dashes (\f[C]--\f[R] for en-dash and \f[C]---\f[R] for em-dash).-If \f[C]smart\f[R] is disabled, then in reading LaTeX pandoc will parse-these characters literally.-In writing LaTeX, enabling \f[C]smart\f[R] tells pandoc to use the-ligatures when possible; if \f[C]smart\f[R] is disabled pandoc will use-unicode quotation mark and dash characters.-.SS Headings and sections-.SS Extension: \f[C]auto_identifiers\f[R]-.PP-A heading without an explicitly specified identifier will be-automatically assigned a unique identifier based on the heading text.-.PP-This extension can be enabled/disabled for the following formats:-.TP-.B input formats-\f[C]markdown\f[R], \f[C]latex\f[R], \f[C]rst\f[R], \f[C]mediawiki\f[R],-\f[C]textile\f[R]-.TP-.B output formats-\f[C]markdown\f[R], \f[C]muse\f[R]-.TP-.B enabled by default in-\f[C]markdown\f[R], \f[C]muse\f[R]-.PP-The default algorithm used to derive the identifier from the heading-text is:-.IP \[bu] 2-Remove all formatting, links, etc.-.IP \[bu] 2-Remove all footnotes.-.IP \[bu] 2-Remove all non-alphanumeric characters, 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[R].-.PP-Thus, for example,-.PP-.TS-tab(@);-l l.-T{-Heading-T}@T{-Identifier-T}-_-T{-\f[C]Heading identifiers in HTML\f[R]-T}@T{-\f[C]heading-identifiers-in-html\f[R]-T}-T{-\f[C]Ma\[^i]tre d\[aq]h\[^o]tel\f[R]-T}@T{-\f[C]ma\[^i]tre-dh\[^o]tel\f[R]-T}-T{-\f[C]*Dogs*?--in *my* house?\f[R]-T}@T{-\f[C]dogs--in-my-house\f[R]-T}-T{-\f[C][HTML], [S5], or [RTF]?\f[R]-T}@T{-\f[C]html-s5-or-rtf\f[R]-T}-T{-\f[C]3. Applications\f[R]-T}@T{-\f[C]applications\f[R]-T}-T{-\f[C]33\f[R]-T}@T{-\f[C]section\f[R]-T}-.TE-.PP-These rules should, in most cases, allow one to determine the identifier-from the heading text.-The exception is when several headings 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[R] appended; the third with-\f[C]-2\f[R]; and so on.-.PP-(However, a different algorithm is used if-\f[C]gfm_auto_identifiers\f[R] is enabled; see below.)-.PP-These identifiers are used to provide link targets in the table of-contents generated by the \f[C]--toc|--table-of-contents\f[R] 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-[heading identifiers](#heading-identifiers-in-html-latex-and-context).-\f[R]-.fi-.PP-Note, however, that this method of providing links to sections works-only in HTML, LaTeX, and ConTeXt formats.-.PP-If the \f[C]--section-divs\f[R] option is specified, then each section-will be wrapped in a \f[C]section\f[R] (or a \f[C]div\f[R], if-\f[C]html4\f[R] was specified), and the identifier will be attached to-the enclosing \f[C]<section>\f[R] (or \f[C]<div>\f[R]) tag rather than-the heading itself.-This allows entire sections to be manipulated using JavaScript or-treated differently in CSS.-.SS Extension: \f[C]ascii_identifiers\f[R]-.PP-Causes the identifiers produced by \f[C]auto_identifiers\f[R] to be pure-ASCII.-Accents are stripped off of accented Latin letters, and non-Latin-letters are omitted.-.SS Extension: \f[C]gfm_auto_identifiers\f[R]-.PP-Changes the algorithm used by \f[C]auto_identifiers\f[R] to conform to-GitHub\[aq]s method.-Spaces are converted to dashes (\f[C]-\f[R]), uppercase characters to-lowercase characters, and punctuation characters other than \f[C]-\f[R]-and \f[C]_\f[R] are removed.-.SS Math Input-.PP-The extensions \f[C]tex_math_dollars\f[R],-\f[C]tex_math_single_backslash\f[R], and-\f[C]tex_math_double_backslash\f[R] are described in the section about-Pandoc\[aq]s Markdown.-.PP-However, they can also be used with HTML input.-This is handy for reading web pages formatted using MathJax, for-example.-.SS Raw HTML/TeX-.PP-The following extensions (especially how they affect Markdown-input/output) are also described in more detail in their respective-sections of Pandoc\[aq]s Markdown.-.SS Extension: \f[C]raw_html\f[R]-.PP-When converting from HTML, parse elements to raw HTML which are not-representable in pandoc\[aq]s AST.-By default, this is disabled for HTML input.-.SS Extension: \f[C]raw_tex\f[R]-.PP-Allows raw LaTeX, TeX, and ConTeXt to be included in a document.-.PP-This extension can be enabled/disabled for the following formats (in-addition to \f[C]markdown\f[R]):-.TP-.B input formats-\f[C]latex\f[R], \f[C]org\f[R], \f[C]textile\f[R], \f[C]html\f[R]-(environments, \f[C]\[rs]ref\f[R], and \f[C]\[rs]eqref\f[R] only),-\f[C]ipynb\f[R]-.TP-.B output formats-\f[C]textile\f[R], \f[C]commonmark\f[R]-.PP-Note: as applied to \f[C]ipynb\f[R], \f[C]raw_html\f[R] and-\f[C]raw_tex\f[R] affect not only raw TeX in markdown cells, but data-with mime type \f[C]text/html\f[R] in output cells.-Since the \f[C]ipynb\f[R] reader attempts to preserve the richest-possible outputs when several options are given, you will get best-results if you disable \f[C]raw_html\f[R] and \f[C]raw_tex\f[R] when-converting to formats like \f[C]docx\f[R] which don\[aq]t allow raw-\f[C]html\f[R] or \f[C]tex\f[R].-.SS Extension: \f[C]native_divs\f[R]-.PP-This extension is enabled by default for HTML input.-This means that \f[C]div\f[R]s are parsed to pandoc native elements.-(Alternatively, you can parse them to raw HTML using-\f[C]-f html-native_divs+raw_html\f[R].)-.PP-When converting HTML to Markdown, for example, you may want to drop all-\f[C]div\f[R]s and \f[C]span\f[R]s:-.IP-.nf-\f[C]-pandoc -f html-native_divs-native_spans -t markdown-\f[R]-.fi-.SS Extension: \f[C]native_spans\f[R]-.PP-Analogous to \f[C]native_divs\f[R] above.-.SS Literate Haskell support-.SS Extension: \f[C]literate_haskell\f[R]-.PP-Treat the document as literate Haskell source.-.PP-This extension can be enabled/disabled for the following formats:-.TP-.B input formats-\f[C]markdown\f[R], \f[C]rst\f[R], \f[C]latex\f[R]-.TP-.B output formats-\f[C]markdown\f[R], \f[C]rst\f[R], \f[C]latex\f[R], \f[C]html\f[R]-.PP-If you append \f[C]+lhs\f[R] (or \f[C]+literate_haskell\f[R]) to one of-the formats above, pandoc will treat the document as literate Haskell-source.-This means that-.IP \[bu] 2-In Markdown input, \[dq]bird track\[dq] sections will be parsed as-Haskell code rather than block quotations.-Text between \f[C]\[rs]begin{code}\f[R] and \f[C]\[rs]end{code}\f[R]-will also be treated as Haskell code.-For ATX-style headings the character \[aq]=\[aq] will be used instead of-\[aq]#\[aq].-.IP \[bu] 2-In Markdown output, code blocks with classes \f[C]haskell\f[R] and-\f[C]literate\f[R] 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, headings 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, \[dq]bird track\[dq] sections will be parsed-as Haskell code.-.IP \[bu] 2-In restructured text output, code blocks with class \f[C]haskell\f[R]-will be rendered using bird tracks.-.IP \[bu] 2-In LaTeX input, text in \f[C]code\f[R] environments will be parsed as-Haskell code.-.IP \[bu] 2-In LaTeX output, code blocks with class \f[C]haskell\f[R] will be-rendered inside \f[C]code\f[R] environments.-.IP \[bu] 2-In HTML output, code blocks with class \f[C]haskell\f[R] will be-rendered with class \f[C]literatehaskell\f[R] and bird tracks.-.PP-Examples:-.IP-.nf-\f[C]-pandoc -f markdown+lhs -t html-\f[R]-.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[R]-.fi-.PP-writes HTML with the Haskell code in bird tracks, so it can be copied-and pasted as literate Haskell source.-.PP-Note that GHC expects the bird tracks in the first column, so indented-literate code blocks (e.g.-inside an itemized environment) will not be picked up by the Haskell-compiler.-.SS Other extensions-.SS Extension: \f[C]empty_paragraphs\f[R]-.PP-Allows empty paragraphs.-By default empty paragraphs are omitted.-.PP-This extension can be enabled/disabled for the following formats:-.TP-.B input formats-\f[C]docx\f[R], \f[C]html\f[R]-.TP-.B output formats-\f[C]docx\f[R], \f[C]odt\f[R], \f[C]opendocument\f[R], \f[C]html\f[R]-.SS Extension: \f[C]styles\f[R]-.PP-When converting from docx, read all docx styles as divs (for paragraph-styles) and spans (for character styles) regardless of whether pandoc-understands the meaning of these styles.-This can be used with docx custom styles.-Disabled by default.-.TP-.B input formats-\f[C]docx\f[R]-.SS Extension: \f[C]amuse\f[R]-.PP-In the \f[C]muse\f[R] input format, this enables Text::Amuse extensions-to Emacs Muse markup.-.SS Extension: \f[C]citations\f[R]-.PP-Some aspects of Pandoc\[aq]s Markdown citation syntax are also accepted-in \f[C]org\f[R] input.-.SS Extension: \f[C]ntb\f[R]-.PP-In the \f[C]context\f[R] output format this enables the use of Natural-Tables (TABLE) instead of the default Extreme Tables (xtables).-Natural tables allow more fine-grained global customization but come at-a performance penalty compared to extreme tables.-.SH PANDOC\[aq]S MARKDOWN-.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 using the-\f[C]markdown_strict\f[R] format instead of \f[C]markdown\f[R].-Extensions can be enabled or disabled to specify the behavior more-granularly.-They are described in the following.-See also Extensions above, for extensions that work also on other-formats.-.SS 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.-.SS Paragraphs-.PP-A paragraph is one or more lines of text followed by one or more blank-lines.-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.-.SS Extension: \f[C]escaped_line_breaks\f[R]-.PP-A backslash followed by a newline is also a hard line break.-Note: in multiline and grid table cells, this is the only way to create-a hard line break, since trailing spaces in the cells are ignored.-.SS Headings-.PP-There are two kinds of headings: Setext and ATX.-.SS Setext-style headings-.PP-A setext-style heading is a line of text \[dq]underlined\[dq] with a row-of \f[C]=\f[R] signs (for a level-one heading) or \f[C]-\f[R] signs (for-a level-two heading):-.IP-.nf-\f[C]-A level-one heading-===================--A level-two heading---------------------\f[R]-.fi-.PP-The heading text can contain inline formatting, such as emphasis (see-Inline formatting, below).-.SS ATX-style headings-.PP-An ATX-style heading consists of one to six \f[C]#\f[R] signs and a line-of text, optionally followed by any number of \f[C]#\f[R] signs.-The number of \f[C]#\f[R] signs at the beginning of the line is the-heading level:-.IP-.nf-\f[C]-## A level-two heading--### A level-three heading ###-\f[R]-.fi-.PP-As with setext-style headings, the heading text can contain formatting:-.IP-.nf-\f[C]-# A level-one heading with a [link](/url) and *emphasis*-\f[R]-.fi-.SS Extension: \f[C]blank_before_header\f[R]-.PP-Standard Markdown syntax does not require a blank line before a heading.-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[R] 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[R]-.fi-.SS Extension: \f[C]space_in_atx_header\f[R]-.PP-Many Markdown implementations do not require a space between the opening-\f[C]#\f[R]s of an ATX heading and the heading text, so that-\f[C]#5 bolt\f[R] and \f[C]#hashtag\f[R] count as headings.-With this extension, pandoc does require the space.-.SS Heading identifiers-.PP-See also the \f[C]auto_identifiers\f[R] extension above.-.SS Extension: \f[C]header_attributes\f[R]-.PP-Headings can be assigned attributes using this syntax at the end of the-line containing the heading text:-.IP-.nf-\f[C]-{#identifier .class .class key=value key=value}-\f[R]-.fi-.PP-Thus, for example, the following headings will all be assigned the-identifier \f[C]foo\f[R]:-.IP-.nf-\f[C]-# My heading {#foo}--## My heading ##    {#foo}--My other heading   {#foo}-----------------\f[R]-.fi-.PP-(This syntax is compatible with PHP Markdown Extra.)-.PP-Note that although this syntax allows assignment of classes and-key/value attributes, writers generally don\[aq]t use all of this-information.-Identifiers, classes, and key/value attributes are used in HTML and-HTML-based formats such as EPUB and slidy.-Identifiers are used for labels and link anchors in the LaTeX, ConTeXt,-Textile, Jira markup, and AsciiDoc writers.-.PP-Headings with the class \f[C]unnumbered\f[R] will not be numbered, even-if \f[C]--number-sections\f[R] is specified.-A single hyphen (\f[C]-\f[R]) in an attribute context is equivalent to-\f[C].unnumbered\f[R], and preferable in non-English documents.-So,-.IP-.nf-\f[C]-# My heading {-}-\f[R]-.fi-.PP-is just the same as-.IP-.nf-\f[C]-# My heading {.unnumbered}-\f[R]-.fi-.SS Extension: \f[C]implicit_header_references\f[R]-.PP-Pandoc behaves as if reference links have been defined for each heading.-So, to link to a heading-.IP-.nf-\f[C]-# Heading identifiers in HTML-\f[R]-.fi-.PP-you can simply write-.IP-.nf-\f[C]-[Heading identifiers in HTML]-\f[R]-.fi-.PP-or-.IP-.nf-\f[C]-[Heading identifiers in HTML][]-\f[R]-.fi-.PP-or-.IP-.nf-\f[C]-[the section on heading identifiers][heading identifiers in-HTML]-\f[R]-.fi-.PP-instead of giving the identifier explicitly:-.IP-.nf-\f[C]-[Heading identifiers in HTML](#heading-identifiers-in-html)-\f[R]-.fi-.PP-If there are multiple headings with identical text, the corresponding-reference will link to the first one only, and you will need to use-explicit links to link to the others, as described above.-.PP-Like regular reference links, these references are case-insensitive.-.PP-Explicit link reference definitions always take priority over implicit-heading references.-So, in the following example, the link will point to \f[C]bar\f[R], not-to \f[C]#foo\f[R]:-.IP-.nf-\f[C]-# Foo--[foo]: bar--See [foo]-\f[R]-.fi-.SS 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 headings), with each line preceded by a \f[C]>\f[R]-character and an optional space.-(The \f[C]>\f[R] 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[R]-.fi-.PP-A \[dq]lazy\[dq] form, which requires the \f[C]>\f[R] 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[R]-.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[R]-.fi-.PP-If the \f[C]>\f[R] character is followed by an optional space, that-space will be considered part of the block quote marker and not part of-the indentation of the contents.-Thus, to put an indented code block in a block quote, you need five-spaces after the \f[C]>\f[R]:-.IP-.nf-\f[C]->     code-\f[R]-.fi-.SS Extension: \f[C]blank_before_blockquote\f[R]-.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[R] to end up at the beginning of a line by accident (perhaps-through line wrapping).-So, unless the \f[C]markdown_strict\f[R] format is used, the following-does not produce a nested block quote in pandoc:-.IP-.nf-\f[C]-> This is a block quote.->> Nested.-\f[R]-.fi-.SS 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[R]-.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 Fenced code blocks-.SS Extension: \f[C]fenced_code_blocks\f[R]-.PP-In addition to standard indented code blocks, pandoc supports-\f[I]fenced\f[R] code blocks.-These begin with a row of three or more tildes (\f[C]\[ti]\f[R]) and end-with a row of tildes that must be at least as long as the starting row.-Everything between these lines is treated as code.-No indentation is necessary:-.IP-.nf-\f[C]-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-if (a > 3) {-  moveShip(5 * gravity, DOWN);-}-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-\f[R]-.fi-.PP-Like regular code blocks, fenced code blocks must be separated from-surrounding text by blank lines.-.PP-If the code itself contains a row of tildes or backticks, just use a-longer row of tildes or backticks at the start and end:-.IP-.nf-\f[C]-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-code including tildes-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-\f[R]-.fi-.SS Extension: \f[C]backtick_code_blocks\f[R]-.PP-Same as \f[C]fenced_code_blocks\f[R], but uses backticks-(\f[C]\[ga]\f[R]) instead of tildes (\f[C]\[ti]\f[R]).-.SS Extension: \f[C]fenced_code_attributes\f[R]-.PP-Optionally, you may attach attributes to fenced or backtick code block-using this syntax:-.IP-.nf-\f[C]-\[ti]\[ti]\[ti]\[ti] {#mycode .haskell .numberLines startFrom=\[dq]100\[dq]}-qsort []     = []-qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++-               qsort (filter (>= x) xs)-\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]-\f[R]-.fi-.PP-Here \f[C]mycode\f[R] is an identifier, \f[C]haskell\f[R] and-\f[C]numberLines\f[R] are classes, and \f[C]startFrom\f[R] is an-attribute with value \f[C]100\f[R].-Some output formats can use this information to do syntax highlighting.-Currently, the only output formats that uses this information are HTML,-LaTeX, Docx, Ms, and PowerPoint.-If highlighting is supported for your output format and language, then-the code block above will appear highlighted, with numbered lines.-(To see which languages are supported, type-\f[C]pandoc --list-highlight-languages\f[R].) Otherwise, the code block-above will appear as follows:-.IP-.nf-\f[C]-<pre id=\[dq]mycode\[dq] class=\[dq]haskell numberLines\[dq] startFrom=\[dq]100\[dq]>-  <code>-  ...-  </code>-</pre>-\f[R]-.fi-.PP-The \f[C]numberLines\f[R] (or \f[C]number-lines\f[R]) class will cause-the lines of the code block to be numbered, starting with \f[C]1\f[R] or-the value of the \f[C]startFrom\f[R] attribute.-The \f[C]lineAnchors\f[R] (or \f[C]line-anchors\f[R]) class will cause-the lines to be clickable anchors in HTML output.-.PP-A shortcut form can also be used for specifying the language of the code-block:-.IP-.nf-\f[C]-\[ga]\[ga]\[ga]haskell-qsort [] = []-\[ga]\[ga]\[ga]-\f[R]-.fi-.PP-This is equivalent to:-.IP-.nf-\f[C]-\[ga]\[ga]\[ga] {.haskell}-qsort [] = []-\[ga]\[ga]\[ga]-\f[R]-.fi-.PP-If the \f[C]fenced_code_attributes\f[R] extension is disabled, but input-contains class attribute(s) for the code block, the first class-attribute will be printed after the opening fence as a bare word.-.PP-To prevent all highlighting, use the \f[C]--no-highlight\f[R] flag.-To set the highlighting style, use \f[C]--highlight-style\f[R].-For more information on highlighting, see Syntax highlighting, below.-.SS Line blocks-.SS Extension: \f[C]line_blocks\f[R]-.PP-A line block is a sequence of lines beginning with a vertical bar-(\f[C]|\f[R]) followed by a space.-The division into lines will be preserved in the output, as will any-leading spaces; otherwise, the lines will be formatted as Markdown.-This is useful for verse and addresses:-.IP-.nf-\f[C]-| The limerick packs laughs anatomical-| In space that is quite economical.-|    But the good ones I\[aq]ve seen-|    So seldom are clean-| And the clean ones so seldom are comical--| 200 Main St.-| Berkeley, CA 94718-\f[R]-.fi-.PP-The lines can be hard-wrapped if needed, but the continuation line must-begin with a space.-.IP-.nf-\f[C]-| The Right Honorable Most Venerable and Righteous Samuel L.-  Constable, Jr.-| 200 Main St.-| Berkeley, CA 94718-\f[R]-.fi-.PP-This syntax is borrowed from reStructuredText.-.SS 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[R], \f[C]+\f[R], or-\f[C]-\f[R]).-Here is a simple example:-.IP-.nf-\f[C]-* one-* two-* three-\f[R]-.fi-.PP-This will produce a \[dq]compact\[dq] list.-If you want a \[dq]loose\[dq] list, in which each item is formatted as a-paragraph, put spaces between the items:-.IP-.nf-\f[C]-* one--* two--* three-\f[R]-.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-List items look best if subsequent lines are flush with the first line-(after the bullet):-.IP-.nf-\f[C]-* here is my first-  list item.-* and my second.-\f[R]-.fi-.PP-But Markdown also allows a \[dq]lazy\[dq] format:-.IP-.nf-\f[C]-* here is my first-list item.-* and my second.-\f[R]-.fi-.SS Block content in list items-.PP-A list item may contain multiple paragraphs and other block-level-content.-However, subsequent paragraphs must be preceded by a blank line and-indented to line up with the first non-space content after the list-marker.-.IP-.nf-\f[C]-  * First paragraph.--    Continued.--  * Second paragraph. With a code block, which must be indented-    eight spaces:--        { code }-\f[R]-.fi-.PP-Exception: if the list marker is followed by an indented code block,-which must begin 5 spaces after the list marker, then subsequent-paragraphs must begin two columns after the last character of the list-marker:-.IP-.nf-\f[C]-*     code--  continuation paragraph-\f[R]-.fi-.PP-List items may include other lists.-In this case the preceding blank line is optional.-The nested list must be indented to line up with the first non-space-character after the list marker of the containing list item.-.IP-.nf-\f[C]-* fruits-  + apples-    - macintosh-    - red delicious-  + pears-  + peaches-* vegetables-  + broccoli-  + chard-\f[R]-.fi-.PP-As noted above, Markdown allows you to write list items-\[dq]lazily,\[dq] 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[R]-.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[R]-.fi-.PP-and this one:-.IP-.nf-\f[C]-5.  one-7.  two-1.  three-\f[R]-.fi-.SS Extension: \f[C]fancy_lists\f[R]-.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.-.PP-The \f[C]fancy_lists\f[R] extension also allows \[aq]\f[C]#\f[R]\[aq] to-be used as an ordered list marker in place of a numeral:-.IP-.nf-\f[C]-#. one-#. two-\f[R]-.fi-.SS Extension: \f[C]startnum\f[R]-.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[R]-.fi-.PP-Pandoc will start a new list each time a different type of list marker-is used.-So, the following will create three lists:-.IP-.nf-\f[C]-(2) Two-(5) Three-1.  Four-*   Five-\f[R]-.fi-.PP-If default list markers are desired, use \f[C]#.\f[R]:-.IP-.nf-\f[C]-#.  one-#.  two-#.  three-\f[R]-.fi-.SS Extension: \f[C]task_lists\f[R]-.PP-Pandoc supports task lists, using the syntax of GitHub-Flavored-Markdown.-.IP-.nf-\f[C]-- [ ] an unchecked task list item-- [x] checked item-\f[R]-.fi-.SS Definition lists-.SS Extension: \f[C]definition_lists\f[R]-.PP-Pandoc supports definition lists, using the syntax of PHP Markdown Extra-with some extensions.-.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[R]-.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.-.PP-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.-The body of the definition (including the first line, aside from the-colon or tilde) should be indented four spaces.-However, as with other Markdown lists, you can \[dq]lazily\[dq] omit-indentation except at the beginning of a paragraph or other block-element:-.IP-.nf-\f[C]-Term 1--:   Definition-with lazy continuation.--    Second paragraph of the definition.-\f[R]-.fi-.PP-If you leave space before the definition (as in the example above), the-text of the definition will be treated as a paragraph.-In some output formats, this will mean greater spacing between-term/definition pairs.-For a more compact definition list, omit the space before the-definition:-.IP-.nf-\f[C]-Term 1-  \[ti] Definition 1--Term 2-  \[ti] Definition 2a-  \[ti] Definition 2b-\f[R]-.fi-.PP-Note that space between items in a definition list is required.-(A variant that loosens this requirement, but disallows \[dq]lazy\[dq]-hard wrapping, can be activated with \f[C]compact_definition_lists\f[R]:-see Non-pandoc extensions, below.)-.SS Numbered example lists-.SS Extension: \f[C]example_lists\f[R]-.PP-The special list marker \f[C]\[at]\f[R] can be used for sequentially-numbered examples.-The first list item with a \f[C]\[at]\f[R] 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]\[at]\f[R] will take up where the last stopped.-So, for example:-.IP-.nf-\f[C]-(\[at])  My first example will be numbered (1).-(\[at])  My second example will be numbered (2).--Explanation of examples.--(\[at])  My third example will be numbered (3).-\f[R]-.fi-.PP-Numbered examples can be labeled and referred to elsewhere in the-document:-.IP-.nf-\f[C]-(\[at]good)  This is a good example.--As (\[at]good) illustrates, ...-\f[R]-.fi-.PP-The label can be any string of alphanumeric characters, underscores, or-hyphens.-.PP-Note: continuation paragraphs in example lists must always be indented-four spaces, regardless of the length of the list marker.-That is, example lists always behave as if the \f[C]four_space_rule\f[R]-extension is set.-This is because example labels tend to be long, and indenting content to-the first non-space character after the label would be awkward.-.SS Compact and loose lists-.PP-Pandoc behaves differently from \f[C]Markdown.pl\f[R] on some \[dq]edge-cases\[dq] involving lists.-Consider this source:-.IP-.nf-\f[C]-+   First-+   Second:-    -   Fee-    -   Fie-    -   Foe--+   Third-\f[R]-.fi-.PP-Pandoc transforms this into a \[dq]compact list\[dq] (with no-\f[C]<p>\f[R] tags around \[dq]First\[dq], \[dq]Second\[dq], or-\[dq]Third\[dq]), while Markdown puts \f[C]<p>\f[R] tags around-\[dq]Second\[dq] and \[dq]Third\[dq] (but not \[dq]First\[dq]), because-of the blank space around \[dq]Third\[dq].-Pandoc follows a simple rule: if the text is followed by a blank line,-it is treated as a paragraph.-Since \[dq]Second\[dq] 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]markdown_strict\f[R]-format 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[R].)-.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[R]-.fi-.PP-Trouble! Here pandoc (like other Markdown implementations) will treat-\f[C]{ my code block }\f[R] as the second paragraph of item two, and not-as a code block.-.PP-To \[dq]cut off\[dq] 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[R]-.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--<!-- -->--1.  uno-2.  dos-3.  tres-\f[R]-.fi-.SS Horizontal rules-.PP-A line containing a row of three or more \f[C]*\f[R], \f[C]-\f[R], or-\f[C]_\f[R] characters (optionally separated by spaces) produces a-horizontal rule:-.IP-.nf-\f[C]-*  *  *  *------------------\f[R]-.fi-.SS Tables-.PP-Four kinds of tables may be used.-The first three kinds presuppose the use of a fixed-width font, such as-Courier.-The fourth kind can be used with proportionally spaced fonts, as it does-not require lining up columns.-.SS Extension: \f[C]table_captions\f[R]-.PP-A caption may optionally be provided with all 4 kinds of tables (as-illustrated in the examples below).-A caption is a paragraph beginning with the string \f[C]Table:\f[R] (or-just \f[C]:\f[R]), which will be stripped off.-It may appear either before or after the table.-.SS Extension: \f[C]simple_tables\f[R]-.PP-Simple tables 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[R]-.fi-.PP-The header 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:-.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.-.PP-The column header row 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[R]-.fi-.PP-When the header row is 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.-.SS Extension: \f[C]multiline_tables\f[R]-.PP-Multiline tables allow header 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[R]-.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-header row is 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-The header 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 a header.-\f[R]-.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.-.SS Extension: \f[C]grid_tables\f[R]-.PP-Grid tables 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[R]-.fi-.PP-The row of \f[C]=\f[R]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.).-Cells that span multiple columns or rows are not supported.-Grid tables can be created easily using Emacs table mode.-.PP-Alignments can be specified as with pipe tables, by putting colons at-the boundaries of the separator line after the header:-.IP-.nf-\f[C]-+---------------+---------------+--------------------+-| Right         | Left          | Centered           |-+==============:+:==============+:==================:+-| Bananas       | $1.34         | built-in wrapper   |-+---------------+---------------+--------------------+-\f[R]-.fi-.PP-For headerless tables, the colons go on the top line instead:-.IP-.nf-\f[C]-+--------------:+:--------------+:------------------:+-| Right         | Left          | Centered           |-+---------------+---------------+--------------------+-\f[R]-.fi-.SS Grid Table Limitations-.PP-Pandoc does not support grid tables with row spans or column spans.-This means that neither variable numbers of columns across rows nor-variable numbers of rows across columns are supported by Pandoc.-All grid tables must have the same number of columns in each row, and-the same number of rows in each column.-For example, the Docutils sample grid tables will not render as expected-with Pandoc.-.SS Extension: \f[C]pipe_tables\f[R]-.PP-Pipe tables look like this:-.IP-.nf-\f[C]-| Right | Left | Default | Center |-|------:|:-----|---------|:------:|-|   12  |  12  |    12   |    12  |-|  123  |  123 |   123   |   123  |-|    1  |    1 |     1   |     1  |--  : Demonstration of pipe table syntax.-\f[R]-.fi-.PP-The syntax is identical to PHP Markdown Extra tables.-The beginning and ending pipe characters are optional, but pipes are-required between all columns.-The colons indicate column alignment as shown.-The header cannot be omitted.-To simulate a headerless table, include a header with blank cells.-.PP-Since the pipes indicate column boundaries, columns need not be-vertically aligned, as they are in the above example.-So, this is a perfectly legal (though ugly) pipe table:-.IP-.nf-\f[C]-fruit| price------|-----:-apple|2.05-pear|1.37-orange|3.09-\f[R]-.fi-.PP-The cells of pipe tables cannot contain block elements like paragraphs-and lists, and cannot span multiple lines.-If a pipe table contains a row whose printable content is wider than the-column width (see \f[C]--columns\f[R]), then the table will take up the-full text width and the cell contents will wrap, with the relative cell-widths determined by the number of dashes in the line separating the-table header from the table body.-(For example \f[C]---|-\f[R] would make the first column 3/4 and the-second column 1/4 of the full text width.) On the other hand, if no-lines are wider than column width, then cell contents will not be-wrapped, and the cells will be sized to their contents.-.PP-Note: pandoc also recognizes pipe tables of the following form, as can-be produced by Emacs\[aq] orgtbl-mode:-.IP-.nf-\f[C]-| One | Two   |-|-----+-------|-| my  | table |-| is  | nice  |-\f[R]-.fi-.PP-The difference is that \f[C]+\f[R] is used instead of \f[C]|\f[R].-Other orgtbl features are not supported.-In particular, to get non-default column alignment, you\[aq]ll need to-add colons as above.-.SS Metadata blocks-.SS Extension: \f[C]pandoc_title_block\f[R]-.PP-If the file begins with a title block-.IP-.nf-\f[C]-% title-% author(s) (separated by semicolons)-% date-\f[R]-.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[R]-.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[R]-.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[R]-.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[R] (\f[C]-s\f[R]) 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[R] or \f[C]-T\f[R] option).-The title in the body appears as an H1 element with class-\[dq]title\[dq], so it can be suppressed or reformatted with CSS.-If a title prefix is specified with \f[C]-T\f[R] 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[R]) should be used to separate the-footer text from the header text.-Thus,-.IP-.nf-\f[C]-% PANDOC(1)-\f[R]-.fi-.PP-will yield a man page with the title \f[C]PANDOC\f[R] and section 1.-.IP-.nf-\f[C]-% PANDOC(1) Pandoc User Manuals-\f[R]-.fi-.PP-will also have \[dq]Pandoc User Manuals\[dq] in the footer.-.IP-.nf-\f[C]-% PANDOC(1) Pandoc User Manuals | Version 4.0-\f[R]-.fi-.PP-will also have \[dq]Version 4.0\[dq] in the header.-.SS Extension: \f[C]yaml_metadata_block\f[R]-.PP-A YAML metadata block is a valid YAML object, delimited by a line of-three hyphens (\f[C]---\f[R]) at the top and a line of three hyphens-(\f[C]---\f[R]) or three dots (\f[C]...\f[R]) at the bottom.-A YAML metadata block may occur anywhere in the document, but if it is-not at the beginning, it must be preceded by a blank line.-(Note that, because of the way pandoc concatenates input files when-several are provided, you may also keep the metadata in a separate YAML-file and pass it to pandoc as an argument, along with your Markdown-files:-.IP-.nf-\f[C]-pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html-\f[R]-.fi-.PP-Just be sure that the YAML file begins with \f[C]---\f[R] and ends with-\f[C]---\f[R] or \f[C]...\f[R].) Alternatively, you can use the-\f[C]--metadata-file\f[R] option.-Using that approach however, you cannot reference content (like-footnotes) from the main markdown input document.-.PP-Metadata will be taken from the fields of the YAML object and added to-any existing document metadata.-Metadata can contain lists and objects (nested arbitrarily), but all-string scalars will be interpreted as Markdown.-Fields with names ending in an underscore will be ignored by pandoc.-(They may be given a role by external processors.) Field names must not-be interpretable as YAML numbers or boolean values (so, for example,-\f[C]yes\f[R], \f[C]True\f[R], and \f[C]15\f[R] cannot be used as field-names).-.PP-A document may contain multiple metadata blocks.-The metadata fields will be combined through a \f[I]left-biased-union\f[R]: if two metadata blocks attempt to set the same field, the-value from the first block will be taken.-.PP-When pandoc is used with \f[C]-t markdown\f[R] to create a Markdown-document, a YAML metadata block will be produced only if the-\f[C]-s/--standalone\f[R] option is used.-All of the metadata will appear in a single block at the beginning of-the document.-.PP-Note that YAML escaping rules must be followed.-Thus, for example, if a title contains a colon, it must be quoted.-The pipe character (\f[C]|\f[R]) can be used to begin an indented block-that will be interpreted literally, without need for escaping.-This form is necessary when the field contains blank lines or-block-level formatting:-.IP-.nf-\f[C]-----title:  \[aq]This is the title: it contains a colon\[aq]-author:-- Author One-- Author Two-keywords: [nothing, nothingness]-abstract: |-  This is the abstract.--  It consists of two paragraphs.-\&...-\f[R]-.fi-.PP-Template variables will be set automatically from the metadata.-Thus, for example, in writing HTML, the variable \f[C]abstract\f[R] will-be set to the HTML equivalent of the Markdown in the \f[C]abstract\f[R]-field:-.IP-.nf-\f[C]-<p>This is the abstract.</p>-<p>It consists of two paragraphs.</p>-\f[R]-.fi-.PP-Variables can contain arbitrary YAML structures, but the template must-match this structure.-The \f[C]author\f[R] variable in the default templates expects a simple-list or string, but can be changed to support more complicated-structures.-The following combination, for example, would add an affiliation to the-author if one is given:-.IP-.nf-\f[C]-----title: The document title-author:-- name: Author One-  affiliation: University of Somewhere-- name: Author Two-  affiliation: University of Nowhere-\&...-\f[R]-.fi-.PP-To use the structured authors in the example above, you would need a-custom template:-.IP-.nf-\f[C]-$for(author)$-$if(author.name)$-$author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$-$else$-$author$-$endif$-$endfor$-\f[R]-.fi-.PP-Raw content to include in the document\[aq]s header may be specified-using \f[C]header-includes\f[R]; however, it is important to mark up-this content as raw code for a particular output format, using the-\f[C]raw_attribute\f[R] extension), or it will be interpreted as-markdown.-For example:-.IP-.nf-\f[C]-header-includes:-- |-  \[ga]\[ga]\[ga]{=latex}-  \[rs]let\[rs]oldsection\[rs]section-  \[rs]renewcommand{\[rs]section}[1]{\[rs]clearpage\[rs]oldsection{#1}}-  \[ga]\[ga]\[ga]-\f[R]-.fi-.SS Backslash escapes-.SS Extension: \f[C]all_symbols_escapable\f[R]-.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]-*\[rs]*hello\[rs]**-\f[R]-.fi-.PP-one will get-.IP-.nf-\f[C]-<em>*hello*</em>-\f[R]-.fi-.PP-instead of-.IP-.nf-\f[C]-<strong>hello</strong>-\f[R]-.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]-\[rs]\[ga]*_{}[]()>#+-.!-\f[R]-.fi-.PP-(However, if the \f[C]markdown_strict\f[R] format is used, 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]\[ti]\f[R] and in HTML and XML as-\f[C]\[rs]&#160;\f[R] or \f[C]\[rs]&nbsp;\f[R].-.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]\[rs]\[rs]\f[R] and in HTML as-\f[C]<br />\f[R].-This is a nice alternative to Markdown\[aq]s \[dq]invisible\[dq] way of-indicating hard line breaks using two trailing spaces on a line.-.PP-Backslash escapes do not work in verbatim contexts.-.SS Inline formatting-.SS Emphasis-.PP-To \f[I]emphasize\f[R] some text, surround it with \f[C]*\f[R]s or-\f[C]_\f[R], like this:-.IP-.nf-\f[C]-This text is _emphasized with underscores_, and this-is *emphasized with asterisks*.-\f[R]-.fi-.PP-Double \f[C]*\f[R] or \f[C]_\f[R] produces \f[B]strong emphasis\f[R]:-.IP-.nf-\f[C]-This is **strong emphasis** and __with underscores__.-\f[R]-.fi-.PP-A \f[C]*\f[R] or \f[C]_\f[R] character surrounded by spaces, or-backslash-escaped, will not trigger emphasis:-.IP-.nf-\f[C]-This is * not emphasized *, and \[rs]*neither is this\[rs]*.-\f[R]-.fi-.SS Extension: \f[C]intraword_underscores\f[R]-.PP-Because \f[C]_\f[R] is sometimes used inside words and identifiers,-pandoc does not interpret a \f[C]_\f[R] surrounded by alphanumeric-characters as an emphasis marker.-If you want to emphasize just part of a word, use \f[C]*\f[R]:-.IP-.nf-\f[C]-feas*ible*, not feas*able*.-\f[R]-.fi-.SS Strikeout-.SS Extension: \f[C]strikeout\f[R]-.PP-To strikeout a section of text with a horizontal line, begin and end it-with \f[C]\[ti]\[ti]\f[R].-Thus, for example,-.IP-.nf-\f[C]-This \[ti]\[ti]is deleted text.\[ti]\[ti]-\f[R]-.fi-.SS Superscripts and subscripts-.SS Extension: \f[C]superscript\f[R], \f[C]subscript\f[R]-.PP-Superscripts may be written by surrounding the superscripted text by-\f[C]\[ha]\f[R] characters; subscripts may be written by surrounding the-subscripted text by \f[C]\[ti]\f[R] characters.-Thus, for example,-.IP-.nf-\f[C]-H\[ti]2\[ti]O is a liquid.  2\[ha]10\[ha] is 1024.-\f[R]-.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]\[ti]\f[R] and \f[C]\[ha]\f[R].) Thus, if you-want the letter P with \[aq]a cat\[aq] in subscripts, use-\f[C]P\[ti]a\[rs] cat\[ti]\f[R], not \f[C]P\[ti]a cat\[ti]\f[R].-.SS Verbatim-.PP-To make a short span of text verbatim, put it inside backticks:-.IP-.nf-\f[C]-What is the difference between \[ga]>>=\[ga] and \[ga]>>\[ga]?-\f[R]-.fi-.PP-If the verbatim text includes a backtick, use double backticks:-.IP-.nf-\f[C]-Here is a literal backtick \[ga]\[ga] \[ga] \[ga]\[ga].-\f[R]-.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: \[ga]\[rs]*\[ga].-\f[R]-.fi-.SS Extension: \f[C]inline_code_attributes\f[R]-.PP-Attributes can be attached to verbatim text, just as with fenced code-blocks:-.IP-.nf-\f[C]-\[ga]<$>\[ga]{.haskell}-\f[R]-.fi-.SS Small caps-.PP-To write small caps, use the \f[C]smallcaps\f[R] class:-.IP-.nf-\f[C]-[Small caps]{.smallcaps}-\f[R]-.fi-.PP-Or, without the \f[C]bracketed_spans\f[R] extension:-.IP-.nf-\f[C]-<span class=\[dq]smallcaps\[dq]>Small caps</span>-\f[R]-.fi-.PP-For compatibility with other Markdown flavors, CSS is also supported:-.IP-.nf-\f[C]-<span style=\[dq]font-variant:small-caps;\[dq]>Small caps</span>-\f[R]-.fi-.PP-This will work in all output formats that support small caps.-.SS Math-.SS Extension: \f[C]tex_math_dollars\f[R]-.PP-Anything between two \f[C]$\f[R] characters will be treated as TeX math.-The opening \f[C]$\f[R] must have a non-space character immediately to-its right, while the closing \f[C]$\f[R] must have a non-space character-immediately to its left, and must not be followed immediately by a-digit.-Thus, \f[C]$20,000 and $30,000\f[R] won\[aq]t parse as math.-If for some reason you need to enclose text in literal \f[C]$\f[R]-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 LaTeX-It will appear verbatim surrounded by \f[C]\[rs](...\[rs])\f[R] (for-inline math) or \f[C]\[rs][...\[rs]]\f[R] (for display math).-.TP-.B Markdown, Emacs Org mode, ConTeXt, ZimWiki-It will appear verbatim surrounded by \f[C]$...$\f[R] (for inline math)-or \f[C]$$...$$\f[R] (for display math).-.TP-.B XWiki-It will appear verbatim surrounded by-\f[C]{{formula}}..{{/formula}}\f[R].-.TP-.B reStructuredText-It will be rendered using an interpreted text role \f[C]:math:\f[R].-.TP-.B AsciiDoc-For AsciiDoc output format (\f[C]-t asciidoc\f[R]) it will appear-verbatim surrounded by \f[C]latexmath:[$...$]\f[R] (for inline math) or-\f[C][latexmath]++++\[rs][...\[rs]]+++\f[R] (for display math).-For AsciiDoctor output format (\f[C]-t asciidoctor\f[R]) the LaTex-delimiters (\f[C]$..$\f[R] and \f[C]\[rs][..\[rs]]\f[R]) are omitted.-.TP-.B Texinfo-It will be rendered inside a \f[C]\[at]math\f[R] command.-.TP-.B roff man, Jira markup-It will be rendered verbatim without \f[C]$\f[R]\[aq]s.-.TP-.B MediaWiki, DokuWiki-It will be rendered inside \f[C]<math>\f[R] tags.-.TP-.B Textile-It will be rendered inside \f[C]<span class=\[dq]math\[dq]>\f[R] tags.-.TP-.B RTF, OpenDocument-It will be rendered, if possible, using Unicode characters, and will-otherwise appear verbatim.-.TP-.B ODT-It will be rendered, if possible, using MathML.-.TP-.B DocBook-If the \f[C]--mathml\f[R] flag is used, it will be rendered using MathML-in an \f[C]inlineequation\f[R] or \f[C]informalequation\f[R] tag.-Otherwise it will be rendered, if possible, using Unicode characters.-.TP-.B Docx-It will be rendered using OMML math markup.-.TP-.B FictionBook2-If the \f[C]--webtex\f[R] option is used, formulas are rendered as-images using CodeCogs or other compatible web service, downloaded and-embedded in the e-book.-Otherwise, they will appear verbatim.-.TP-.B HTML, Slidy, DZSlides, S5, EPUB-The way math is rendered in HTML will depend on the command-line options-selected.-Therefore see Math rendering in HTML above.-.SS Raw HTML-.SS Extension: \f[C]raw_html\f[R]-.PP-Markdown allows you to insert raw HTML (or DocBook) anywhere in a-document (except verbatim contexts, where \f[C]<\f[R], \f[C]>\f[R], and-\f[C]&\f[R] are interpreted literally).-(Technically this is not an extension, since standard Markdown allows-it, but it has been made an extension so that it can be disabled if-desired.)-.PP-The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,-DZSlides, EPUB, Markdown, CommonMark, Emacs Org mode, and Textile-output, and suppressed in other formats.-.PP-For a more explicit way of including raw HTML in a Markdown document,-see the \f[C]raw_attribute\f[R] extension.-.PP-In the CommonMark format, if \f[C]raw_html\f[R] is enabled,-superscripts, subscripts, strikeouts and small capitals will be-represented as HTML.-Otherwise, plain-text fallbacks will be used.-Note that even if \f[C]raw_html\f[R] is disabled, tables will be-rendered with HTML syntax if they cannot use pipe syntax.-.SS Extension: \f[C]markdown_in_html_blocks\f[R]-.PP-Standard Markdown allows you to include HTML \[dq]blocks\[dq]: 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[R] does not signify emphasis.-.PP-Pandoc behaves this way when the \f[C]markdown_strict\f[R] format is-used; 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[R]-.fi-.PP-into-.IP-.nf-\f[C]-<table>-<tr>-<td><em>one</em></td>-<td><a href=\[dq]http://google.com\[dq]>a link</a></td>-</tr>-</table>-\f[R]-.fi-.PP-whereas \f[C]Markdown.pl\f[R] will preserve it as is.-.PP-There is one exception to this rule: text between \f[C]<script>\f[R] and-\f[C]<style>\f[R] 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[R] tags without preventing it from being interpreted as-Markdown.-.SS Extension: \f[C]native_divs\f[R]-.PP-Use native pandoc \f[C]Div\f[R] blocks for content inside-\f[C]<div>\f[R] tags.-For the most part this should give the same output as-\f[C]markdown_in_html_blocks\f[R], but it makes it easier to write-pandoc filters to manipulate groups of blocks.-.SS Extension: \f[C]native_spans\f[R]-.PP-Use native pandoc \f[C]Span\f[R] blocks for content inside-\f[C]<span>\f[R] tags.-For the most part this should give the same output as-\f[C]raw_html\f[R], but it makes it easier to write pandoc filters to-manipulate groups of inlines.-.SS Extension: \f[C]raw_tex\f[R]-.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 \[rs]cite{jones.1967}.-\f[R]-.fi-.PP-Note that in LaTeX environments, like-.IP-.nf-\f[C]-\[rs]begin{tabular}{|l|l|}\[rs]hline-Age & Frequency \[rs]\[rs] \[rs]hline-18--25  & 15 \[rs]\[rs]-26--35  & 33 \[rs]\[rs]-36--45  & 22 \[rs]\[rs] \[rs]hline-\[rs]end{tabular}-\f[R]-.fi-.PP-the material between the begin and end tags will be interpreted as raw-LaTeX, not as Markdown.-.PP-For a more explicit and flexible way of including raw TeX in a Markdown-document, see the \f[C]raw_attribute\f[R] extension.-.PP-Inline LaTeX is ignored in output formats other than Markdown, LaTeX,-Emacs Org mode, and ConTeXt.-.SS Generic raw attribute-.SS Extension: \f[C]raw_attribute\f[R]-.PP-Inline spans and fenced code blocks with a special kind of attribute-will be parsed as raw content with the designated format.-For example, the following produces a raw roff \f[C]ms\f[R] block:-.IP-.nf-\f[C]-\[ga]\[ga]\[ga]{=ms}-\&.MYMACRO-blah blah-\[ga]\[ga]\[ga]-\f[R]-.fi-.PP-And the following produces a raw \f[C]html\f[R] inline element:-.IP-.nf-\f[C]-This is \[ga]<a>html</a>\[ga]{=html}-\f[R]-.fi-.PP-This can be useful to insert raw xml into \f[C]docx\f[R] documents, e.g.-a pagebreak:-.IP-.nf-\f[C]-\[ga]\[ga]\[ga]{=openxml}-<w:p>-  <w:r>-    <w:br w:type=\[dq]page\[dq]/>-  </w:r>-</w:p>-\[ga]\[ga]\[ga]-\f[R]-.fi-.PP-The format name should match the target format name (see-\f[C]-t/--to\f[R], above, for a list, or use-\f[C]pandoc --list-output-formats\f[R]).-Use \f[C]openxml\f[R] for \f[C]docx\f[R] output, \f[C]opendocument\f[R]-for \f[C]odt\f[R] output, \f[C]html5\f[R] for \f[C]epub3\f[R] output,-\f[C]html4\f[R] for \f[C]epub2\f[R] output, and \f[C]latex\f[R],-\f[C]beamer\f[R], \f[C]ms\f[R], or \f[C]html5\f[R] for \f[C]pdf\f[R]-output (depending on what you use for \f[C]--pdf-engine\f[R]).-.PP-This extension presupposes that the relevant kind of inline code or-fenced code block is enabled.-Thus, for example, to use a raw attribute with a backtick code block,-\f[C]backtick_code_blocks\f[R] must be enabled.-.PP-The raw attribute cannot be combined with regular attributes.-.SS LaTeX macros-.SS Extension: \f[C]latex_macros\f[R]-.PP-When this extension is enabled, pandoc will parse LaTeX macro-definitions and apply the resulting macros to all LaTeX math and raw-LaTeX.-So, for example, the following will work in all output formats, not just-LaTeX:-.IP-.nf-\f[C]-\[rs]newcommand{\[rs]tuple}[1]{\[rs]langle #1 \[rs]rangle}--$\[rs]tuple{a, b, c}$-\f[R]-.fi-.PP-Note that LaTeX macros will not be applied if they occur inside a raw-span or block marked with the \f[C]raw_attribute\f[R] extension.-.PP-When \f[C]latex_macros\f[R] is disabled, the raw LaTeX and math will not-have macros applied.-This is usually a better approach when you are targeting LaTeX or PDF.-.PP-Whether or not \f[C]latex_macros\f[R] is enabled, the macro definitions-will still be passed through as raw LaTeX.-.SS 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\[at]green.eggs.ham>-\f[R]-.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 \[dq]click here for a good time!\[dq]).-\f[R]-.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.-.PP-Email addresses in inline links are not autodetected, so they have to be-prefixed with \f[C]mailto\f[R]:-.IP-.nf-\f[C]-[Write me!](mailto:sam\[at]green.eggs.ham)-\f[R]-.fi-.SS Reference links-.PP-An \f[I]explicit\f[R] 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 cannot be space between the two unless the-\f[C]spaced_reference_links\f[R] extension is enabled.) The link-definition 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.-The label must not be parseable as a citation (assuming the-\f[C]citations\f[R] extension is enabled): citations take precedence-over link labels.-.PP-Here are some examples:-.IP-.nf-\f[C]-[my label 1]: /foo/bar.html  \[dq]My title, optional\[dq]-[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[R]-.fi-.PP-The URL may optionally be surrounded by angle brackets:-.IP-.nf-\f[C]-[my label 5]: <http://foo.bar.baz>-\f[R]-.fi-.PP-The title may go on the next line:-.IP-.nf-\f[C]-[my label 3]: http://fsf.org-  \[dq]The free software foundation\[dq]-\f[R]-.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[R]-.fi-.PP-In an \f[I]implicit\f[R] reference link, the second pair of brackets is-empty:-.IP-.nf-\f[C]-See [my website][].--[my website]: http://foo.bar.baz-\f[R]-.fi-.PP-Note: In \f[C]Markdown.pl\f[R] and most other Markdown implementations,-reference link definitions cannot occur in nested constructions such as-list items or block quotes.-Pandoc lifts this arbitrary seeming restriction.-So the following is fine in pandoc, though not in most other-implementations:-.IP-.nf-\f[C]-> My block [quote].->-> [quote]: /foo-\f[R]-.fi-.SS Extension: \f[C]shortcut_reference_links\f[R]-.PP-In a \f[I]shortcut\f[R] reference link, the second pair of brackets may-be omitted entirely:-.IP-.nf-\f[C]-See [my website].--[my website]: http://foo.bar.baz-\f[R]-.fi-.SS Internal links-.PP-To link to another section of the same document, use the automatically-generated identifier (see Heading identifiers).-For example:-.IP-.nf-\f[C]-See the [Introduction](#introduction).-\f[R]-.fi-.PP-or-.IP-.nf-\f[C]-See the [Introduction].--[Introduction]: #introduction-\f[R]-.fi-.PP-Internal links are currently supported for HTML formats (including HTML-slide shows and EPUB), LaTeX, and ConTeXt.-.SS Images-.PP-A link immediately preceded by a \f[C]!\f[R] 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 \[dq]Voyage to the moon\[dq])--![movie reel]--[movie reel]: movie.gif-\f[R]-.fi-.SS Extension: \f[C]implicit_figures\f[R]-.PP-An image with nonempty alt text, occurring by itself in a paragraph,-will be rendered as a figure with a caption.-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[R]-.fi-.PP-How this is rendered depends on the output format.-Some output formats (e.g.-RTF) do not yet support figures.-In those formats, you\[aq]ll just get an image in a paragraph by itself,-with no caption.-.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)\[rs]-\f[R]-.fi-.PP-Note that in reveal.js slide shows, an image in a paragraph by itself-that has the \f[C]stretch\f[R] class will fill the screen, and the-caption and figure tags will be omitted.-.SS Extension: \f[C]link_attributes\f[R]-.PP-Attributes can be set on links and images:-.IP-.nf-\f[C]-An inline ![image](foo.jpg){#id .class width=30 height=20px}-and a reference ![image][ref] with attributes.--[ref]: foo.jpg \[dq]optional title\[dq] {#id .class key=val key2=\[dq]val 2\[dq]}-\f[R]-.fi-.PP-(This syntax is compatible with PHP Markdown Extra when only-\f[C]#id\f[R] and \f[C].class\f[R] are used.)-.PP-For HTML and EPUB, all attributes except \f[C]width\f[R] and-\f[C]height\f[R] (but including \f[C]srcset\f[R] and \f[C]sizes\f[R])-are passed through as is.-The other writers ignore attributes that are not supported by their-output format.-.PP-The \f[C]width\f[R] and \f[C]height\f[R] attributes on images are-treated specially.-When used without a unit, the unit is assumed to be pixels.-However, any of the following unit identifiers can be used:-\f[C]px\f[R], \f[C]cm\f[R], \f[C]mm\f[R], \f[C]in\f[R], \f[C]inch\f[R]-and \f[C]%\f[R].-There must not be any spaces between the number and the unit.-For example:-.IP-.nf-\f[C]-![](file.jpg){ width=50% }-\f[R]-.fi-.IP \[bu] 2-Dimensions are converted to inches for output in page-based formats like-LaTeX.-Dimensions are converted to pixels for output in HTML-like formats.-Use the \f[C]--dpi\f[R] option to specify the number of pixels per inch.-The default is 96dpi.-.IP \[bu] 2-The \f[C]%\f[R] unit is generally relative to some available space.-For example the above example will render to the following.-.RS 2-.IP \[bu] 2-HTML:-\f[C]<img href=\[dq]file.jpg\[dq] style=\[dq]width: 50%;\[dq] />\f[R]-.IP \[bu] 2-LaTeX:-\f[C]\[rs]includegraphics[width=0.5\[rs]textwidth,height=\[rs]textheight]{file.jpg}\f[R]-(If you\[aq]re using a custom template, you need to configure-\f[C]graphicx\f[R] as in the default template.)-.IP \[bu] 2-ConTeXt:-\f[C]\[rs]externalfigure[file.jpg][width=0.5\[rs]textwidth]\f[R]-.RE-.IP \[bu] 2-Some output formats have a notion of a class (ConTeXt) or a unique-identifier (LaTeX \f[C]\[rs]caption\f[R]), or both (HTML).-.IP \[bu] 2-When no \f[C]width\f[R] or \f[C]height\f[R] attributes are specified,-the fallback is to look at the image resolution and the dpi metadata-embedded in the image file.-.SS Divs and Spans-.PP-Using the \f[C]native_divs\f[R] and \f[C]native_spans\f[R] extensions-(see above), HTML syntax can be used as part of markdown to create-native \f[C]Div\f[R] and \f[C]Span\f[R] elements in the pandoc AST (as-opposed to raw HTML).-However, there is also nicer syntax available:-.SS Extension: \f[C]fenced_divs\f[R]-.PP-Allow special fenced syntax for native \f[C]Div\f[R] blocks.-A Div starts with a fence containing at least three consecutive colons-plus some attributes.-The attributes may optionally be followed by another string of-consecutive colons.-The attribute syntax is exactly as in fenced code blocks (see Extension:-\f[C]fenced_code_attributes\f[R]).-As with fenced code blocks, one can use either attributes in curly-braces or a single unbraced word, which will be treated as a class name.-The Div ends with another line containing a string of at least three-consecutive colons.-The fenced Div should be separated by blank lines from preceding and-following blocks.-.PP-Example:-.IP-.nf-\f[C]-::::: {#special .sidebar}-Here is a paragraph.--And another.-:::::-\f[R]-.fi-.PP-Fenced divs can be nested.-Opening fences are distinguished because they \f[I]must\f[R] have-attributes:-.IP-.nf-\f[C]-::: Warning ::::::-This is a warning.--::: Danger-This is a warning within a warning.-:::-::::::::::::::::::-\f[R]-.fi-.PP-Fences without attributes are always closing fences.-Unlike with fenced code blocks, the number of colons in the closing-fence need not match the number in the opening fence.-However, it can be helpful for visual clarity to use fences of different-lengths to distinguish nested divs from their parents.-.SS Extension: \f[C]bracketed_spans\f[R]-.PP-A bracketed sequence of inlines, as one would use to begin a link, will-be treated as a \f[C]Span\f[R] with attributes if it is followed-immediately by attributes:-.IP-.nf-\f[C]-[This is *some text*]{.class key=\[dq]val\[dq]}-\f[R]-.fi-.SS Footnotes-.SS Extension: \f[C]footnotes\f[R]-.PP-Pandoc\[aq]s Markdown allows footnotes, using the following syntax:-.IP-.nf-\f[C]-Here is a footnote reference,[\[ha]1] and another.[\[ha]longnote]--[\[ha]1]: Here is the footnote.--[\[ha]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[R]-.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.).-Each footnote should be separated from surrounding content (including-other footnotes) by blank lines.-.SS Extension: \f[C]inline_notes\f[R]-.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.\[ha][Inlines notes are easier to write, since-you don\[aq]t have to pick an identifier and move down to type the-note.]-\f[R]-.fi-.PP-Inline and regular footnotes may be mixed freely.-.SS Citations-.SS Extension: \f[C]citations\f[R]-.PP-Using an external filter, \f[C]pandoc-citeproc\f[R], pandoc can-automatically generate citations and a bibliography in a number of-styles.-Basic usage is-.IP-.nf-\f[C]-pandoc --filter pandoc-citeproc myinput.txt-\f[R]-.fi-.PP-In order to use this feature, you will need to specify a bibliography-file using the \f[C]bibliography\f[R] metadata field in a YAML metadata-section, or \f[C]--bibliography\f[R] command line argument.-You can supply multiple \f[C]--bibliography\f[R] arguments or set-\f[C]bibliography\f[R] metadata field to YAML array, if you want to use-multiple bibliography files.-The bibliography may have any of these formats:-.PP-.TS-tab(@);-l l.-T{-Format-T}@T{-File extension-T}-_-T{-BibLaTeX-T}@T{-\&.bib-T}-T{-BibTeX-T}@T{-\&.bibtex-T}-T{-Copac-T}@T{-\&.copac-T}-T{-CSL JSON-T}@T{-\&.json-T}-T{-CSL YAML-T}@T{-\&.yaml-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{-MODS-T}@T{-\&.mods-T}-T{-RIS-T}@T{-\&.ris-T}-.TE-.PP-Note that \f[C].bib\f[R] can be used with both BibTeX and BibLaTeX-files; use \f[C].bibtex\f[R] to force BibTeX.-.PP-Note that \f[C]pandoc-citeproc --bib2json\f[R] and-\f[C]pandoc-citeproc --bib2yaml\f[R] can produce \f[C].json\f[R] and-\f[C].yaml\f[R] files from any of the supported formats.-.PP-In-field markup: In BibTeX and BibLaTeX databases, pandoc-citeproc-parses a subset of LaTeX markup; in CSL YAML databases, pandoc Markdown;-and in CSL JSON databases, an HTML-like markup:-.TP-.B \f[C]<i>...</i>\f[R]-italics-.TP-.B \f[C]<b>...</b>\f[R]-bold-.TP-.B \f[C]<span style=\[dq]font-variant:small-caps;\[dq]>...</span>\f[R] or \f[C]<sc>...</sc>\f[R]-small capitals-.TP-.B \f[C]<sub>...</sub>\f[R]-subscript-.TP-.B \f[C]<sup>...</sup>\f[R]-superscript-.TP-.B \f[C]<span class=\[dq]nocase\[dq]>...</span>\f[R]-prevent a phrase from being capitalized as title case-.PP-\f[C]pandoc-citeproc -j\f[R] and \f[C]-y\f[R] interconvert the CSL JSON-and CSL YAML formats as far as possible.-.PP-As an alternative to specifying a bibliography file using-\f[C]--bibliography\f[R] or the YAML metadata field-\f[C]bibliography\f[R], you can include the citation data directly in-the \f[C]references\f[R] field of the document\[aq]s YAML metadata.-The field should contain an array of YAML-encoded references, for-example:-.IP-.nf-\f[C]-----references:-- type: article-journal-  id: WatsonCrick1953-  author:-  - family: Watson-    given: J. D.-  - family: Crick-    given: F. H. C.-  issued:-    date-parts:-    - - 1953-      - 4-      - 25-  title: \[aq]Molecular structure of nucleic acids: a structure for deoxyribose-    nucleic acid\[aq]-  title-short: Molecular structure of nucleic acids-  container-title: Nature-  volume: 171-  issue: 4356-  page: 737-738-  DOI: 10.1038/171737a0-  URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html-  language: en-GB-\&...-\f[R]-.fi-.PP-(\f[C]pandoc-citeproc --bib2yaml\f[R] can produce these from a-bibliography file in one of the supported formats.)-.PP-Citations and references can be formatted using any style supported by-the Citation Style Language, listed in the Zotero Style Repository.-These files are specified using the \f[C]--csl\f[R] option or the-\f[C]csl\f[R] metadata field.-By default, \f[C]pandoc-citeproc\f[R] will use the Chicago Manual of-Style author-date format.-The CSL project provides further information on finding and editing-styles.-.PP-To make your citations hyperlinks to the corresponding bibliography-entries, add \f[C]link-citations: true\f[R] to your YAML metadata.-.PP-Citations go inside square brackets and are separated by semicolons.-Each citation must have a key, composed of \[aq]\[at]\[aq] + the-citation identifier from the database, and may optionally have a prefix,-a locator, and a suffix.-The citation key must begin with a letter, digit, or \f[C]_\f[R], and-may contain alphanumerics, \f[C]_\f[R], and internal punctuation-characters (\f[C]:.#$%&-+?<>\[ti]/\f[R]).-Here are some examples:-.IP-.nf-\f[C]-Blah blah [see \[at]doe99, pp. 33-35; also \[at]smith04, chap. 1].--Blah blah [\[at]doe99, pp. 33-35, 38-39 and *passim*].--Blah blah [\[at]smith04; \[at]doe99].-\f[R]-.fi-.PP-\f[C]pandoc-citeproc\f[R] detects locator terms in the CSL locale files.-Either abbreviated or unabbreviated forms are accepted.-In the \f[C]en-US\f[R] locale, locator terms can be written in either-singular or plural forms, as \f[C]book\f[R],-\f[C]bk.\f[R]/\f[C]bks.\f[R]; \f[C]chapter\f[R],-\f[C]chap.\f[R]/\f[C]chaps.\f[R]; \f[C]column\f[R],-\f[C]col.\f[R]/\f[C]cols.\f[R]; \f[C]figure\f[R],-\f[C]fig.\f[R]/\f[C]figs.\f[R]; \f[C]folio\f[R],-\f[C]fol.\f[R]/\f[C]fols.\f[R]; \f[C]number\f[R],-\f[C]no.\f[R]/\f[C]nos.\f[R]; \f[C]line\f[R],-\f[C]l.\f[R]/\f[C]ll.\f[R]; \f[C]note\f[R], \f[C]n.\f[R]/\f[C]nn.\f[R];-\f[C]opus\f[R], \f[C]op.\f[R]/\f[C]opp.\f[R]; \f[C]page\f[R],-\f[C]p.\f[R]/\f[C]pp.\f[R]; \f[C]paragraph\f[R],-\f[C]para.\f[R]/\f[C]paras.\f[R]; \f[C]part\f[R],-\f[C]pt.\f[R]/\f[C]pts.\f[R]; \f[C]section\f[R],-\f[C]sec.\f[R]/\f[C]secs.\f[R]; \f[C]sub verbo\f[R],-\f[C]s.v.\f[R]/\f[C]s.vv.\f[R]; \f[C]verse\f[R],-\f[C]v.\f[R]/\f[C]vv.\f[R]; \f[C]volume\f[R],-\f[C]vol.\f[R]/\f[C]vols.\f[R]; \f[C]\[ps]\f[R]/\f[C]\[ps]\[ps]\f[R];-\f[C]\[sc]\f[R]/\f[C]\[sc]\[sc]\f[R].-If no locator term is used, \[dq]page\[dq] is assumed.-.PP-\f[C]pandoc-citeproc\f[R] will use heuristics to distinguish the locator-from the suffix.-In complex cases, the locator can be enclosed in curly braces (using-\f[C]pandoc-citeproc\f[R] 0.15 and higher only):-.IP-.nf-\f[C]-[\[at]smith{ii, A, D-Z}, with a suffix]-[\[at]smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]-\f[R]-.fi-.PP-A minus sign (\f[C]-\f[R]) before the \f[C]\[at]\f[R] 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 [-\[at]smith04].-\f[R]-.fi-.PP-You can also write an in-text citation, as follows:-.IP-.nf-\f[C]-\[at]smith04 says blah.--\[at]smith04 [p. 33] says blah.-\f[R]-.fi-.PP-If the style calls for a list of works cited, it will be placed in a div-with id \f[C]refs\f[R], if one exists:-.IP-.nf-\f[C]-::: {#refs}-:::-\f[R]-.fi-.PP-Otherwise, it will be placed at the end of the document.-Generation of the bibliography can be suppressed by setting-\f[C]suppress-bibliography: true\f[R] in the YAML metadata.-.PP-If you wish the bibliography to have a section heading, you can set-\f[C]reference-section-title\f[R] in the metadata, or put the heading at-the beginning of the div with id \f[C]refs\f[R] (if you are using it) or-at the end of your document:-.IP-.nf-\f[C]-last paragraph...--# References-\f[R]-.fi-.PP-The bibliography will be inserted after this heading.-Note that the \f[C]unnumbered\f[R] class will be added to this heading,-so that the section will not be numbered.-.PP-If you want to include items in the bibliography without actually citing-them in the body text, you can define a dummy \f[C]nocite\f[R] metadata-field and put the citations there:-.IP-.nf-\f[C]-----nocite: |-  \[at]item1, \[at]item2-\&...--\[at]item3-\f[R]-.fi-.PP-In this example, the document will contain a citation for-\f[C]item3\f[R] only, but the bibliography will contain entries for-\f[C]item1\f[R], \f[C]item2\f[R], and \f[C]item3\f[R].-.PP-It is possible to create a bibliography with all the citations, whether-or not they appear in the document, by using a wildcard:-.IP-.nf-\f[C]-----nocite: |-  \[at]*-\&...-\f[R]-.fi-.PP-For LaTeX output, you can also use \f[C]natbib\f[R] or-\f[C]biblatex\f[R] to render the bibliography.-In order to do so, specify bibliography files as outlined above, and add-\f[C]--natbib\f[R] or \f[C]--biblatex\f[R] argument to \f[C]pandoc\f[R]-invocation.-Bear in mind that bibliography files have to be in respective format-(either BibTeX or BibLaTeX).-.PP-For more information, see the pandoc-citeproc man page.-.SS Non-pandoc extensions-.PP-The following Markdown syntax extensions are not enabled by default in-pandoc, but may be enabled by adding \f[C]+EXTENSION\f[R] to the format-name, where \f[C]EXTENSION\f[R] is the name of the extension.-Thus, for example, \f[C]markdown+hard_line_breaks\f[R] is Markdown with-hard line breaks.-.SS Extension: \f[C]old_dashes\f[R]-.PP-Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:-\f[C]-\f[R] before a numeral is an en-dash, and \f[C]--\f[R] is an-em-dash.-This option only has an effect if \f[C]smart\f[R] is enabled.-It is selected automatically for \f[C]textile\f[R] input.-.SS Extension: \f[C]angle_brackets_escapable\f[R]-.PP-Allow \f[C]<\f[R] and \f[C]>\f[R] to be backslash-escaped, as they can-be in GitHub flavored Markdown but not original Markdown.-This is implied by pandoc\[aq]s default \f[C]all_symbols_escapable\f[R].-.SS Extension: \f[C]lists_without_preceding_blankline\f[R]-.PP-Allow a list to occur right after a paragraph, with no intervening blank-space.-.SS Extension: \f[C]four_space_rule\f[R]-.PP-Selects the pandoc <= 2.0 behavior for parsing lists, so that four-spaces indent are needed for list item continuation paragraphs.-.SS Extension: \f[C]spaced_reference_links\f[R]-.PP-Allow whitespace between the two components of a reference link, for-example,-.IP-.nf-\f[C]-[foo] [bar].-\f[R]-.fi-.SS Extension: \f[C]hard_line_breaks\f[R]-.PP-Causes all newlines within a paragraph to be interpreted as hard line-breaks instead of spaces.-.SS Extension: \f[C]ignore_line_breaks\f[R]-.PP-Causes newlines within a paragraph to be ignored, rather than being-treated as spaces or as hard line breaks.-This option is intended for use with East Asian languages where spaces-are not used between words, but text is divided into lines for-readability.-.SS Extension: \f[C]east_asian_line_breaks\f[R]-.PP-Causes newlines within a paragraph to be ignored, rather than being-treated as spaces or as hard line breaks, when they occur between two-East Asian wide characters.-This is a better choice than \f[C]ignore_line_breaks\f[R] for texts that-include a mix of East Asian wide characters and other characters.-.SS Extension: \f[C]emoji\f[R]-.PP-Parses textual emojis like \f[C]:smile:\f[R] as Unicode emoticons.-.SS Extension: \f[C]tex_math_single_backslash\f[R]-.PP-Causes anything between \f[C]\[rs](\f[R] and \f[C]\[rs])\f[R] to be-interpreted as inline TeX math, and anything between \f[C]\[rs][\f[R]-and \f[C]\[rs]]\f[R] to be interpreted as display TeX math.-Note: a drawback of this extension is that it precludes escaping-\f[C](\f[R] and \f[C][\f[R].-.SS Extension: \f[C]tex_math_double_backslash\f[R]-.PP-Causes anything between \f[C]\[rs]\[rs](\f[R] and \f[C]\[rs]\[rs])\f[R]-to be interpreted as inline TeX math, and anything between-\f[C]\[rs]\[rs][\f[R] and \f[C]\[rs]\[rs]]\f[R] to be interpreted as-display TeX math.-.SS Extension: \f[C]markdown_attribute\f[R]-.PP-By default, pandoc interprets material inside block-level tags as-Markdown.-This extension changes the behavior so that Markdown is only parsed-inside block-level tags if the tags have the attribute-\f[C]markdown=1\f[R].-.SS Extension: \f[C]mmd_title_block\f[R]-.PP-Enables a MultiMarkdown style title block at the top of the document,-for example:-.IP-.nf-\f[C]-Title:   My title-Author:  John Doe-Date:    September 1, 2008-Comment: This is a sample mmd title block, with-         a field spanning multiple lines.-\f[R]-.fi-.PP-See the MultiMarkdown documentation for details.-If \f[C]pandoc_title_block\f[R] or \f[C]yaml_metadata_block\f[R] is-enabled, it will take precedence over \f[C]mmd_title_block\f[R].-.SS Extension: \f[C]abbreviations\f[R]-.PP-Parses PHP Markdown Extra abbreviation keys, like-.IP-.nf-\f[C]-*[HTML]: Hypertext Markup Language-\f[R]-.fi-.PP-Note that the pandoc document model does not support abbreviations, so-if this extension is enabled, abbreviation keys are simply skipped (as-opposed to being parsed as paragraphs).-.SS Extension: \f[C]autolink_bare_uris\f[R]-.PP-Makes all absolute URIs into links, even when not surrounded by pointy-braces \f[C]<...>\f[R].-.SS Extension: \f[C]mmd_link_attributes\f[R]-.PP-Parses multimarkdown style key-value attributes on link and image-references.-This extension should not be confused with the \f[C]link_attributes\f[R]-extension.-.IP-.nf-\f[C]-This is a reference ![image][ref] with multimarkdown attributes.--[ref]: http://path.to/image \[dq]Image title\[dq] width=20px height=30px-       id=myId class=\[dq]myClass1 myClass2\[dq]-\f[R]-.fi-.SS Extension: \f[C]mmd_header_identifiers\f[R]-.PP-Parses multimarkdown style heading identifiers (in square brackets,-after the heading but before any trailing \f[C]#\f[R]s in an ATX-heading).-.SS Extension: \f[C]compact_definition_lists\f[R]-.PP-Activates the definition list syntax of pandoc 1.12.x and earlier.-This syntax differs from the one described above under Definition lists-in several respects:-.IP \[bu] 2-No blank line is required between consecutive items of the definition-list.-.IP \[bu] 2-To get a \[dq]tight\[dq] or \[dq]compact\[dq] list, omit space between-consecutive items; the space between a term and its definition does not-affect anything.-.IP \[bu] 2-Lazy wrapping of paragraphs is not allowed: the entire definition must-be indented four spaces.-.SS Markdown variants-.PP-In addition to pandoc\[aq]s extended Markdown, the following Markdown-variants are supported:-.TP-.B \f[C]markdown_phpextra\f[R] (PHP Markdown Extra)-\f[C]footnotes\f[R], \f[C]pipe_tables\f[R], \f[C]raw_html\f[R],-\f[C]markdown_attribute\f[R], \f[C]fenced_code_blocks\f[R],-\f[C]definition_lists\f[R], \f[C]intraword_underscores\f[R],-\f[C]header_attributes\f[R], \f[C]link_attributes\f[R],-\f[C]abbreviations\f[R], \f[C]shortcut_reference_links\f[R],-\f[C]spaced_reference_links\f[R].-.TP-.B \f[C]markdown_github\f[R] (deprecated GitHub-Flavored Markdown)-\f[C]pipe_tables\f[R], \f[C]raw_html\f[R], \f[C]fenced_code_blocks\f[R],-\f[C]auto_identifiers\f[R], \f[C]gfm_auto_identifiers\f[R],-\f[C]backtick_code_blocks\f[R], \f[C]autolink_bare_uris\f[R],-\f[C]space_in_atx_header\f[R], \f[C]intraword_underscores\f[R],-\f[C]strikeout\f[R], \f[C]task_lists\f[R], \f[C]emoji\f[R],-\f[C]shortcut_reference_links\f[R], \f[C]angle_brackets_escapable\f[R],-\f[C]lists_without_preceding_blankline\f[R].-.TP-.B \f[C]markdown_mmd\f[R] (MultiMarkdown)-\f[C]pipe_tables\f[R], \f[C]raw_html\f[R], \f[C]markdown_attribute\f[R],-\f[C]mmd_link_attributes\f[R], \f[C]tex_math_double_backslash\f[R],-\f[C]intraword_underscores\f[R], \f[C]mmd_title_block\f[R],-\f[C]footnotes\f[R], \f[C]definition_lists\f[R],-\f[C]all_symbols_escapable\f[R], \f[C]implicit_header_references\f[R],-\f[C]auto_identifiers\f[R], \f[C]mmd_header_identifiers\f[R],-\f[C]shortcut_reference_links\f[R], \f[C]implicit_figures\f[R],-\f[C]superscript\f[R], \f[C]subscript\f[R],-\f[C]backtick_code_blocks\f[R], \f[C]spaced_reference_links\f[R],-\f[C]raw_attribute\f[R].-.TP-.B \f[C]markdown_strict\f[R] (Markdown.pl)-\f[C]raw_html\f[R], \f[C]shortcut_reference_links\f[R],-\f[C]spaced_reference_links\f[R].-.PP-We also support \f[C]commonmark\f[R] and \f[C]gfm\f[R] (GitHub-Flavored-Markdown, which is implemented as a set of extensions on-\f[C]commonmark\f[R]).-.PP-Note, however, that \f[C]commonmark\f[R] and \f[C]gfm\f[R] have limited-support for extensions.-Only those listed below (and \f[C]smart\f[R], \f[C]raw_tex\f[R], and-\f[C]hard_line_breaks\f[R]) will work.-The extensions can, however, all be individually disabled.-Also, \f[C]raw_tex\f[R] only affects \f[C]gfm\f[R] output, not input.-.TP-.B \f[C]gfm\f[R] (GitHub-Flavored Markdown)-\f[C]pipe_tables\f[R], \f[C]raw_html\f[R], \f[C]fenced_code_blocks\f[R],-\f[C]auto_identifiers\f[R], \f[C]gfm_auto_identifiers\f[R],-\f[C]backtick_code_blocks\f[R], \f[C]autolink_bare_uris\f[R],-\f[C]space_in_atx_header\f[R], \f[C]intraword_underscores\f[R],-\f[C]strikeout\f[R], \f[C]task_lists\f[R], \f[C]emoji\f[R],-\f[C]shortcut_reference_links\f[R], \f[C]angle_brackets_escapable\f[R],-\f[C]lists_without_preceding_blankline\f[R].-.SH PRODUCING 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 five ways to do this, using S5, DZSlides, Slidy, Slideous, or-reveal.js.-You can also produce a PDF slide show using LaTeX \f[C]beamer\f[R], or-slides shows in Microsoft PowerPoint format.-.PP-Here\[aq]s the Markdown source for a simple slide show,-\f[C]habits.txt\f[R]:-.IP-.nf-\f[C]-% Habits-% John Doe-% March 22, 2005--# In the morning--## Getting up--- Turn off alarm-- Get out of bed--## Breakfast--- Eat eggs-- Drink coffee--# In the evening--## Dinner--- Eat spaghetti-- Drink wine----------------------![picture of spaghetti](images/spaghetti.jpg)--## Going to sleep--- Get in bed-- Count sheep-\f[R]-.fi-.PP-To produce an HTML/JavaScript slide show, simply type-.IP-.nf-\f[C]-pandoc -t FORMAT -s habits.txt -o habits.html-\f[R]-.fi-.PP-where \f[C]FORMAT\f[R] is either \f[C]s5\f[R], \f[C]slidy\f[R],-\f[C]slideous\f[R], \f[C]dzslides\f[R], or \f[C]revealjs\f[R].-.PP-For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with-the \f[C]-s/--standalone\f[R] option embeds a link to JavaScript and CSS-files, which are assumed to be available at the relative path-\f[C]s5/default\f[R] (for S5), \f[C]slideous\f[R] (for Slideous),-\f[C]reveal.js\f[R] (for reveal.js), or at the Slidy website at-\f[C]w3.org\f[R] (for Slidy).-(These paths can be changed by setting the \f[C]slidy-url\f[R],-\f[C]slideous-url\f[R], \f[C]revealjs-url\f[R], or \f[C]s5-url\f[R]-variables; see Variables for HTML slides, above.) For DZSlides, the-(relatively short) JavaScript and CSS are included in the file by-default.-.PP-With all HTML slide formats, the \f[C]--self-contained\f[R] option can-be used to produce a single file that contains all of the data necessary-to display the slide show, including linked scripts, stylesheets,-images, and videos.-.PP-To produce a PDF slide show using beamer, type-.IP-.nf-\f[C]-pandoc -t beamer habits.txt -o habits.pdf-\f[R]-.fi-.PP-Note that a reveal.js slide show can also be converted to a PDF by-printing it to a file from the browser.-.PP-To produce a Powerpoint slide show, type-.IP-.nf-\f[C]-pandoc habits.txt -o habits.pptx-\f[R]-.fi-.SS Structuring the slide show-.PP-By default, the \f[I]slide level\f[R] is the highest heading level in-the hierarchy that is followed immediately by content, and not another-heading, somewhere in the document.-In the example above, level-1 headings are always followed by level-2-headings, which are followed by content, so the slide level is 2.-This default can be overridden using the \f[C]--slide-level\f[R] option.-.PP-The document is carved up into slides according to the following rules:-.IP \[bu] 2-A horizontal rule always starts a new slide.-.IP \[bu] 2-A heading at the slide level always starts a new slide.-.IP \[bu] 2-Headings \f[I]below\f[R] the slide level in the hierarchy create-headings \f[I]within\f[R] a slide.-.IP \[bu] 2-Headings \f[I]above\f[R] the slide level in the hierarchy create-\[dq]title slides,\[dq] which just contain the section title and help to-break the slide show into sections.-Non-slide content under these headings will be included on the title-slide (for HTML slide shows) or in a subsequent slide with the same-title (for beamer).-.IP \[bu] 2-A title page is constructed automatically from the document\[aq]s title-block, if present.-(In the case of beamer, this can be disabled by commenting out some-lines in the default template.)-.PP-These rules are designed to support many different styles of slide show.-If you don\[aq]t care about structuring your slides into sections and-subsections, you can just use level-1 headings for all each slide.-(In that case, level-1 will be the slide level.) But you can also-structure the slide show into sections, as in the example above.-.PP-Note: in reveal.js slide shows, if slide level is 2, a two-dimensional-layout will be produced, with level-1 headings building horizontally and-level-2 headings building vertically.-It is not recommended that you use deeper nesting of section levels with-reveal.js.-.SS Incremental lists-.PP-By default, these writers produce lists that display \[dq]all at-once.\[dq] If you want your lists to display incrementally (one item at-a time), use the \f[C]-i\f[R] option.-If you want a particular list to depart from the default, put it in a-\f[C]div\f[R] block with class \f[C]incremental\f[R] or-\f[C]nonincremental\f[R].-So, for example, using the \f[C]fenced div\f[R] syntax, the following-would be incremental regardless of the document default:-.IP-.nf-\f[C]-::: incremental--- Eat spaghetti-- Drink wine--:::-\f[R]-.fi-.PP-or-.IP-.nf-\f[C]-::: nonincremental--- Eat spaghetti-- Drink wine--:::-\f[R]-.fi-.PP-While using \f[C]incremental\f[R] and \f[C]nonincremental\f[R] divs are-the recommended method of setting incremental lists on a per-case basis,-an older method is also supported: putting lists inside a blockquote-will depart from the document default (that is, it will display-incrementally without the \f[C]-i\f[R] option and all at once with the-\f[C]-i\f[R] option):-.IP-.nf-\f[C]-> - Eat spaghetti-> - Drink wine-\f[R]-.fi-.PP-Both methods allow incremental and nonincremental lists to be mixed in a-single document.-.SS Inserting pauses-.PP-You can add \[dq]pauses\[dq] within a slide by including a paragraph-containing three dots, separated by spaces:-.IP-.nf-\f[C]-# Slide with a pause--content before the pause--\&. . .--content after the pause-\f[R]-.fi-.SS Styling the slides-.PP-You can change the style of HTML slides by putting customized CSS files-in \f[C]$DATADIR/s5/default\f[R] (for S5), \f[C]$DATADIR/slidy\f[R] (for-Slidy), or \f[C]$DATADIR/slideous\f[R] (for Slideous), where-\f[C]$DATADIR\f[R] is the user data directory (see \f[C]--data-dir\f[R],-above).-The originals may be found in pandoc\[aq]s system data directory-(generally \f[C]$CABALDIR/pandoc-VERSION/s5/default\f[R]).-Pandoc will look there for any files it does not find in the user data-directory.-.PP-For dzslides, the CSS is included in the HTML file itself, and may be-modified there.-.PP-All reveal.js configuration options can be set through variables.-For example, themes can be used by setting the \f[C]theme\f[R] variable:-.IP-.nf-\f[C]--V theme=moon-\f[R]-.fi-.PP-Or you can specify a custom stylesheet using the \f[C]--css\f[R] option.-.PP-To style beamer slides, you can specify a \f[C]theme\f[R],-\f[C]colortheme\f[R], \f[C]fonttheme\f[R], \f[C]innertheme\f[R], and-\f[C]outertheme\f[R], using the \f[C]-V\f[R] option:-.IP-.nf-\f[C]-pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf-\f[R]-.fi-.PP-Note that heading attributes will turn into slide attributes (on a-\f[C]<div>\f[R] or \f[C]<section>\f[R]) in HTML slide formats, allowing-you to style individual slides.-In beamer, the only heading attribute that affects slides is the-\f[C]allowframebreaks\f[R] class, which sets the-\f[C]allowframebreaks\f[R] option, causing multiple slides to be created-if the content overfills the frame.-This is recommended especially for bibliographies:-.IP-.nf-\f[C]-# References {.allowframebreaks}-\f[R]-.fi-.SS Speaker notes-.PP-Speaker notes are supported in reveal.js and PowerPoint (pptx) output.-You can add notes to your Markdown document thus:-.IP-.nf-\f[C]-::: notes--This is my note.--- It can contain Markdown-- like this list--:::-\f[R]-.fi-.PP-To show the notes window in reveal.js, press \f[C]s\f[R] while viewing-the presentation.-Speaker notes in PowerPoint will be available, as usual, in handouts and-presenter view.-.PP-Notes are not yet supported for other slide formats, but the notes will-not appear on the slides themselves.-.SS Columns-.PP-To put material in side by side columns, you can use a native div-container with class \f[C]columns\f[R], containing two or more div-containers with class \f[C]column\f[R] and a \f[C]width\f[R] attribute:-.IP-.nf-\f[C]-:::::::::::::: {.columns}-::: {.column width=\[dq]40%\[dq]}-contents...-:::-::: {.column width=\[dq]60%\[dq]}-contents...-:::-::::::::::::::-\f[R]-.fi-.SS Frame attributes in beamer-.PP-Sometimes it is necessary to add the LaTeX \f[C][fragile]\f[R] option to-a frame in beamer (for example, when using the \f[C]minted\f[R]-environment).-This can be forced by adding the \f[C]fragile\f[R] class to the heading-introducing the slide:-.IP-.nf-\f[C]-# Fragile slide {.fragile}-\f[R]-.fi-.PP-All of the other frame attributes described in Section 8.1 of the Beamer-User\[aq]s Guide may also be used: \f[C]allowdisplaybreaks\f[R],-\f[C]allowframebreaks\f[R], \f[C]b\f[R], \f[C]c\f[R], \f[C]t\f[R],-\f[C]environment\f[R], \f[C]label\f[R], \f[C]plain\f[R],-\f[C]shrink\f[R], \f[C]standout\f[R], \f[C]noframenumbering\f[R].-.SS Background in reveal.js and beamer-.PP-Background images can be added to self-contained reveal.js slideshows-and to beamer slideshows.-.PP-For the same image on every slide, use the configuration option-\f[C]background-image\f[R] either in the YAML metadata block or as a-command-line variable.-(There are no other options in beamer and the rest of this section-concerns reveal.js slideshows.)-.PP-For reveal.js, you can instead use the reveal.js-native option-\f[C]parallaxBackgroundImage\f[R].-You can also set \f[C]parallaxBackgroundHorizontal\f[R] and-\f[C]parallaxBackgroundVertical\f[R] the same way and must also set-\f[C]parallaxBackgroundSize\f[R] to have your values take effect.-.PP-To set an image for a particular reveal.js slide, add-\f[C]{data-background-image=\[dq]/path/to/image\[dq]}\f[R] to the first-slide-level heading on the slide (which may even be empty).-.PP-In reveal.js\[aq]s overview mode, the parallaxBackgroundImage will show-up only on the first slide.-.PP-Other reveal.js background settings also work on individual slides,-including \f[C]data-background-size\f[R],-\f[C]data-background-repeat\f[R], \f[C]data-background-color\f[R],-\f[C]data-transition\f[R], and \f[C]data-transition-speed\f[R].-.PP-See the reveal.js documentation for more details.-.PP-For example in reveal.js:-.IP-.nf-\f[C]-----title: My Slideshow-parallaxBackgroundImage: /path/to/my/background_image.png------## Slide One--Slide 1 has background_image.png as its background.--## {data-background-image=\[dq]/path/to/special_image.jpg\[dq]}--Slide 2 has a special image for its background, even though the heading has no content.-\f[R]-.fi-.SH CREATING EPUBS WITH PANDOC-.SS EPUB Metadata-.PP-EPUB metadata may be specified using the \f[C]--epub-metadata\f[R]-option, but if the source document is Markdown, it is better to use a-YAML metadata block.-Here is an example:-.IP-.nf-\f[C]-----title:-- type: main-  text: My Book-- type: subtitle-  text: An investigation of metadata-creator:-- role: author-  text: John Smith-- role: editor-  text: Sarah Jones-identifier:-- scheme: DOI-  text: doi:10.234234.234/33-publisher:  My Press-rights: \[co] 2007 John Smith, CC BY-NC-ibooks:-  version: 1.3.4-\&...-\f[R]-.fi-.PP-The following fields are recognized:-.TP-.B \f[C]identifier\f[R]-Either a string value or an object with fields \f[C]text\f[R] and-\f[C]scheme\f[R].-Valid values for \f[C]scheme\f[R] are \f[C]ISBN-10\f[R],-\f[C]GTIN-13\f[R], \f[C]UPC\f[R], \f[C]ISMN-10\f[R], \f[C]DOI\f[R],-\f[C]LCCN\f[R], \f[C]GTIN-14\f[R], \f[C]ISBN-13\f[R],-\f[C]Legal deposit number\f[R], \f[C]URN\f[R], \f[C]OCLC\f[R],-\f[C]ISMN-13\f[R], \f[C]ISBN-A\f[R], \f[C]JP\f[R], \f[C]OLCC\f[R].-.TP-.B \f[C]title\f[R]-Either a string value, or an object with fields \f[C]file-as\f[R] and-\f[C]type\f[R], or a list of such objects.-Valid values for \f[C]type\f[R] are \f[C]main\f[R], \f[C]subtitle\f[R],-\f[C]short\f[R], \f[C]collection\f[R], \f[C]edition\f[R],-\f[C]extended\f[R].-.TP-.B \f[C]creator\f[R]-Either a string value, or an object with fields \f[C]role\f[R],-\f[C]file-as\f[R], and \f[C]text\f[R], or a list of such objects.-Valid values for \f[C]role\f[R] are MARC relators, but pandoc will-attempt to translate the human-readable versions (like \[dq]author\[dq]-and \[dq]editor\[dq]) to the appropriate marc relators.-.TP-.B \f[C]contributor\f[R]-Same format as \f[C]creator\f[R].-.TP-.B \f[C]date\f[R]-A string value in \f[C]YYYY-MM-DD\f[R] format.-(Only the year is necessary.) Pandoc will attempt to convert other-common date formats.-.TP-.B \f[C]lang\f[R] (or legacy: \f[C]language\f[R])-A string value in BCP 47 format.-Pandoc will default to the local language if nothing is specified.-.TP-.B \f[C]subject\f[R]-A string value or a list of such values.-.TP-.B \f[C]description\f[R]-A string value.-.TP-.B \f[C]type\f[R]-A string value.-.TP-.B \f[C]format\f[R]-A string value.-.TP-.B \f[C]relation\f[R]-A string value.-.TP-.B \f[C]coverage\f[R]-A string value.-.TP-.B \f[C]rights\f[R]-A string value.-.TP-.B \f[C]cover-image\f[R]-A string value (path to cover image).-.TP-.B \f[C]css\f[R] (or legacy: \f[C]stylesheet\f[R])-A string value (path to CSS stylesheet).-.TP-.B \f[C]page-progression-direction\f[R]-Either \f[C]ltr\f[R] or \f[C]rtl\f[R].-Specifies the \f[C]page-progression-direction\f[R] attribute for the-\f[C]spine\f[R] element.-.TP-.B \f[C]ibooks\f[R]-iBooks-specific metadata, with the following fields:-.RS-.IP \[bu] 2-\f[C]version\f[R]: (string)-.IP \[bu] 2-\f[C]specified-fonts\f[R]: \f[C]true\f[R]|\f[C]false\f[R] (default-\f[C]false\f[R])-.IP \[bu] 2-\f[C]ipad-orientation-lock\f[R]:-\f[C]portrait-only\f[R]|\f[C]landscape-only\f[R]-.IP \[bu] 2-\f[C]iphone-orientation-lock\f[R]:-\f[C]portrait-only\f[R]|\f[C]landscape-only\f[R]-.IP \[bu] 2-\f[C]binding\f[R]: \f[C]true\f[R]|\f[C]false\f[R] (default-\f[C]true\f[R])-.IP \[bu] 2-\f[C]scroll-axis\f[R]:-\f[C]vertical\f[R]|\f[C]horizontal\f[R]|\f[C]default\f[R]-.RE-.SS The \f[C]epub:type\f[R] attribute-.PP-For \f[C]epub3\f[R] output, you can mark up the heading that corresponds-to an EPUB chapter using the \f[C]epub:type\f[R] attribute.-For example, to set the attribute to the value \f[C]prologue\f[R], use-this markdown:-.IP-.nf-\f[C]-# My chapter {epub:type=prologue}-\f[R]-.fi-.PP-Which will result in:-.IP-.nf-\f[C]-<body epub:type=\[dq]frontmatter\[dq]>-  <section epub:type=\[dq]prologue\[dq]>-    <h1>My chapter</h1>-\f[R]-.fi-.PP-Pandoc will output \f[C]<body epub:type=\[dq]bodymatter\[dq]>\f[R],-unless you use one of the following values, in which case either-\f[C]frontmatter\f[R] or \f[C]backmatter\f[R] will be output.-.PP-.TS-tab(@);-l l.-T{-\f[C]epub:type\f[R] of first section-T}@T{-\f[C]epub:type\f[R] of body-T}-_-T{-prologue-T}@T{-frontmatter-T}-T{-abstract-T}@T{-frontmatter-T}-T{-acknowledgments-T}@T{-frontmatter-T}-T{-copyright-page-T}@T{-frontmatter-T}-T{-dedication-T}@T{-frontmatter-T}-T{-credits-T}@T{-frontmatter-T}-T{-keywords-T}@T{-frontmatter-T}-T{-imprint-T}@T{-frontmatter-T}-T{-contributors-T}@T{-frontmatter-T}-T{-other-credits-T}@T{-frontmatter-T}-T{-errata-T}@T{-frontmatter-T}-T{-revision-history-T}@T{-frontmatter-T}-T{-titlepage-T}@T{-frontmatter-T}-T{-halftitlepage-T}@T{-frontmatter-T}-T{-seriespage-T}@T{-frontmatter-T}-T{-foreword-T}@T{-frontmatter-T}-T{-preface-T}@T{-frontmatter-T}-T{-seriespage-T}@T{-frontmatter-T}-T{-titlepage-T}@T{-frontmatter-T}-T{-appendix-T}@T{-backmatter-T}-T{-colophon-T}@T{-backmatter-T}-T{-bibliography-T}@T{-backmatter-T}-T{-index-T}@T{-backmatter-T}-.TE-.SS Linked media-.PP-By default, pandoc will download media referenced from any-\f[C]<img>\f[R], \f[C]<audio>\f[R], \f[C]<video>\f[R] or-\f[C]<source>\f[R] element present in the generated EPUB, and include it-in the EPUB container, yielding a completely self-contained EPUB.-If you want to link to external media resources instead, use raw HTML in-your source and add \f[C]data-external=\[dq]1\[dq]\f[R] to the tag with-the \f[C]src\f[R] attribute.-For example:-.IP-.nf-\f[C]-<audio controls=\[dq]1\[dq]>-  <source src=\[dq]http://example.com/music/toccata.mp3\[dq]-          data-external=\[dq]1\[dq] type=\[dq]audio/mpeg\[dq]>-  </source>-</audio>-\f[R]-.fi-.SH CREATING JUPYTER NOTEBOOKS WITH PANDOC-.PP-When creating a Jupyter notebook, pandoc will try to infer the notebook-structure.-Code blocks with the class \f[C]code\f[R] will be taken as code cells,-and intervening content will be taken as Markdown cells.-Attachments will automatically be created for images in Markdown cells.-Metadata will be taken from the \f[C]jupyter\f[R] metadata field.-For example:-.IP-.nf-\f[C]-----title: My notebook-jupyter:-  nbformat: 4-  nbformat_minor: 5-  kernelspec:-     display_name: Python 2-     language: python-     name: python2-  language_info:-     codemirror_mode:-       name: ipython-       version: 2-     file_extension: \[dq].py\[dq]-     mimetype: \[dq]text/x-python\[dq]-     name: \[dq]python\[dq]-     nbconvert_exporter: \[dq]python\[dq]-     pygments_lexer: \[dq]ipython2\[dq]-     version: \[dq]2.7.15\[dq]------# Lorem ipsum--**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus-bibendum felis dictum sodales.--\[ga]\[ga]\[ga] code-print(\[dq]hello\[dq])-\[ga]\[ga]\[ga]--## Pyout--\[ga]\[ga]\[ga] code-from IPython.display import HTML-HTML(\[dq]\[dq]\[dq]-<script>-console.log(\[dq]hello\[dq]);-</script>-<b>HTML</b>-\[dq]\[dq]\[dq])-\[ga]\[ga]\[ga]--## Image--This image ![image](myimage.png) will be-included as a cell attachment.-\f[R]-.fi-.PP-If you want to add cell attributes, group cells differently, or add-output to code cells, then you need to include divs to indicate the-structure.-You can use either fenced divs or native divs for this.-Here is an example:-.IP-.nf-\f[C]-:::::: {.cell .markdown}-# Lorem--**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus-bibendum felis dictum sodales.-::::::--:::::: {.cell .code execution_count=1}-\[ga]\[ga]\[ga] {.python}-print(\[dq]hello\[dq])-\[ga]\[ga]\[ga]--::: {.output .stream .stdout}-\[ga]\[ga]\[ga]-hello-\[ga]\[ga]\[ga]-:::-::::::--:::::: {.cell .code execution_count=2}-\[ga]\[ga]\[ga] {.python}-from IPython.display import HTML-HTML(\[dq]\[dq]\[dq]-<script>-console.log(\[dq]hello\[dq]);-</script>-<b>HTML</b>-\[dq]\[dq]\[dq])-\[ga]\[ga]\[ga]--::: {.output .execute_result execution_count=2}-\[ga]\[ga]\[ga]{=html}-<script>-console.log(\[dq]hello\[dq]);-</script>-<b>HTML</b>-hello-\[ga]\[ga]\[ga]-:::-::::::-\f[R]-.fi-.PP-If you include raw HTML or TeX in an output cell, use the [raw-attribute][Extension: \f[C]fenced_attribute\f[R]], as shown in the last-cell of the example above.-Although pandoc can process \[dq]bare\[dq] raw HTML and TeX, the result-is often interspersed raw elements and normal textual elements, and in-an output cell pandoc expects a single, connected raw block.-To avoid using raw HTML or TeX except when marked explicitly using raw-attributes, we recommend specifying the extensions-\f[C]-raw_html-raw_tex+raw_attribute\f[R] when translating between-Markdown and ipynb notebooks.-.PP-Note that options and extensions that affect reading and writing of-Markdown will also affect Markdown cells in ipynb notebooks.-For example, \f[C]--wrap=preserve\f[R] will preserve soft line breaks in-Markdown cells; \f[C]--atx-headers\f[R] will cause ATX-style headings to-be used; and \f[C]--preserve-tabs\f[R] will prevent tabs from being-turned to spaces.-.SH SYNTAX HIGHLIGHTING-.PP-Pandoc will automatically highlight syntax in fenced code blocks that-are marked with a language name.-The Haskell library skylighting is used for highlighting.-Currently highlighting is supported only for HTML, EPUB, Docx, Ms, and-LaTeX/PDF output.-To see a list of language names that pandoc will recognize, type-\f[C]pandoc --list-highlight-languages\f[R].-.PP-The color scheme can be selected using the \f[C]--highlight-style\f[R]-option.-The default color scheme is \f[C]pygments\f[R], which imitates the-default color scheme used by the Python library pygments (though-pygments is not actually used to do the highlighting).-To see a list of highlight styles, type-\f[C]pandoc --list-highlight-styles\f[R].-.PP-If you are not satisfied with the predefined styles, you can use-\f[C]--print-highlight-style\f[R] to generate a JSON \f[C].theme\f[R]-file which can be modified and used as the argument to-\f[C]--highlight-style\f[R].-To get a JSON version of the \f[C]pygments\f[R] style, for example:-.IP-.nf-\f[C]-pandoc --print-highlight-style pygments > my.theme-\f[R]-.fi-.PP-Then edit \f[C]my.theme\f[R] and use it like this:-.IP-.nf-\f[C]-pandoc --highlight-style my.theme-\f[R]-.fi-.PP-If you are not satisfied with the built-in highlighting, or you want-highlight a language that isn\[aq]t supported, you can use the-\f[C]--syntax-definition\f[R] option to load a KDE-style XML syntax-definition file.-Before writing your own, have a look at KDE\[aq]s repository of syntax-definitions.-.PP-To disable highlighting, use the \f[C]--no-highlight\f[R] option.-.SH CUSTOM STYLES-.PP-Custom styles can be used in the docx and ICML formats.-.SS Output-.PP-By default, pandoc\[aq]s docx and ICML output applies a predefined set-of styles for blocks such as paragraphs and block quotes, and uses-largely default formatting (italics, bold) for inlines.-This will work for most purposes, especially alongside a-\f[C]reference.docx\f[R] file.-However, if you need to apply your own styles to blocks, or match a-preexisting set of styles, pandoc allows you to define custom styles for-blocks and text using \f[C]div\f[R]s and \f[C]span\f[R]s, respectively.-.PP-If you define a \f[C]div\f[R] or \f[C]span\f[R] with the attribute-\f[C]custom-style\f[R], pandoc will apply your specified style to the-contained elements.-So, for example using the \f[C]bracketed_spans\f[R] syntax,-.IP-.nf-\f[C]-[Get out]{custom-style=\[dq]Emphatically\[dq]}, he said.-\f[R]-.fi-.PP-would produce a docx file with \[dq]Get out\[dq] styled with character-style \f[C]Emphatically\f[R].-Similarly, using the \f[C]fenced_divs\f[R] syntax,-.IP-.nf-\f[C]-Dickinson starts the poem simply:--::: {custom-style=\[dq]Poetry\[dq]}-| A Bird came down the Walk----| He did not know I saw----:::-\f[R]-.fi-.PP-would style the two contained lines with the \f[C]Poetry\f[R] paragraph-style.-.PP-For docx output, styles will be defined in the output file as inheriting-from normal text, if the styles are not yet in your reference.docx.-If they are already defined, pandoc will not alter the definition.-.PP-This feature allows for greatest customization in conjunction with-pandoc filters.-If you want all paragraphs after block quotes to be indented, you can-write a filter to apply the styles necessary.-If you want all italics to be transformed to the \f[C]Emphasis\f[R]-character style (perhaps to change their color), you can write a filter-which will transform all italicized inlines to inlines within an-\f[C]Emphasis\f[R] custom-style \f[C]span\f[R].-.PP-For docx output, you don\[aq]t need to enable any extensions for custom-styles to work.-.SS Input-.PP-The docx reader, by default, only reads those styles that it can convert-into pandoc elements, either by direct conversion or interpreting the-derivation of the input document\[aq]s styles.-.PP-By enabling the \f[C]styles\f[R] extension in the docx reader-(\f[C]-f docx+styles\f[R]), you can produce output that maintains the-styles of the input document, using the \f[C]custom-style\f[R] class.-Paragraph styles are interpreted as divs, while character styles are-interpreted as spans.-.PP-For example, using the \f[C]custom-style-reference.docx\f[R] file in the-test directory, we have the following different outputs:-.PP-Without the \f[C]+styles\f[R] extension:-.IP-.nf-\f[C]-$ pandoc test/docx/custom-style-reference.docx -f docx -t markdown-This is some text.--This is text with an *emphasized* text style. And this is text with a-**strengthened** text style.--> Here is a styled paragraph that inherits from Block Text.-\f[R]-.fi-.PP-And with the extension:-.IP-.nf-\f[C]-$ pandoc test/docx/custom-style-reference.docx -f docx+styles -t markdown--::: {custom-style=\[dq]FirstParagraph\[dq]}-This is some text.-:::--::: {custom-style=\[dq]BodyText\[dq]}-This is text with an [emphasized]{custom-style=\[dq]Emphatic\[dq]} text style.-And this is text with a [strengthened]{custom-style=\[dq]Strengthened\[dq]}-text style.-:::--::: {custom-style=\[dq]MyBlockStyle\[dq]}-> Here is a styled paragraph that inherits from Block Text.-:::-\f[R]-.fi-.PP-With these custom styles, you can use your input document as a-reference-doc while creating docx output (see below), and maintain the-same styles in your input and output files.-.SH CUSTOM WRITERS-.PP-Pandoc can be extended with custom writers written in lua.-(Pandoc includes a lua interpreter, so lua need not be installed-separately.)-.PP-To use a custom writer, simply specify the path to the lua script in-place of the output format.-For example:-.IP-.nf-\f[C]-pandoc -t data/sample.lua-\f[R]-.fi-.PP-Creating a custom writer requires writing a lua function for each-possible element in a pandoc document.-To get a documented example which you can modify according to your-needs, do-.IP-.nf-\f[C]-pandoc --print-default-data-file sample.lua-\f[R]-.fi+.TH PANDOC 1 "November 22, 2019" "pandoc 2.8"+.SH NAME+pandoc - general markup converter+.SH SYNOPSIS+.PP+\f[C]pandoc\f[R] [\f[I]options\f[R]] [\f[I]input-file\f[R]]...+.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.+.PP+Pandoc can convert between numerous markup and word processing formats,+including, but not limited to, various flavors of Markdown, HTML, LaTeX+and Word docx.+For the full lists of input and output formats, see the \f[C]--from\f[R]+and \f[C]--to\f[R] options below.+Pandoc can also produce PDF output: see creating a PDF, below.+.PP+Pandoc\[aq]s enhanced version of Markdown includes syntax for tables,+definition lists, metadata blocks, footnotes, citations, math, and much+more.+See below under Pandoc\[aq]s Markdown.+.PP+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 (an \f[I]abstract syntax tree\f[R] or AST), 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.+Users can also run custom pandoc filters to modify the intermediate AST.+.PP+Because pandoc\[aq]s intermediate representation of a document is less+expressive than many of the formats it converts between, one should not+expect perfect conversions between every format and every other.+Pandoc attempts to preserve the structural elements of a document, but+not formatting details such as margin size.+And some document elements, such as complex tables, may not fit into+pandoc\[aq]s simple document model.+While conversions from pandoc\[aq]s Markdown to all formats aspire to be+perfect, conversions from formats more expressive than pandoc\[aq]s+Markdown can be expected to be lossy.+.SS Using pandoc+.PP+If no \f[I]input-files\f[R] are specified, input is read from+\f[I]stdin\f[R].+Output goes to \f[I]stdout\f[R] by default.+For output to a file, use the \f[C]-o\f[R] option:+.IP+.nf+\f[C]+pandoc -o output.html input.txt+\f[R]+.fi+.PP+By default, pandoc produces a document fragment.+To produce a standalone document (e.g.+a valid HTML file including \f[C]<head>\f[R] and \f[C]<body>\f[R]), use+the \f[C]-s\f[R] or \f[C]--standalone\f[R] flag:+.IP+.nf+\f[C]+pandoc -s -o output.html input.txt+\f[R]+.fi+.PP+For more information on how standalone documents are produced, see+Templates below.+.PP+If multiple input files are given, \f[C]pandoc\f[R] will concatenate+them all (with blank lines between them) before parsing.+(Use \f[C]--file-scope\f[R] to parse files individually.)+.SS Specifying formats+.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]-f/--from\f[R] option,+the output format using the \f[C]-t/--to\f[R] option.+Thus, to convert \f[C]hello.txt\f[R] from Markdown to LaTeX, you could+type:+.IP+.nf+\f[C]+pandoc -f markdown -t latex hello.txt+\f[R]+.fi+.PP+To convert \f[C]hello.html\f[R] from HTML to Markdown:+.IP+.nf+\f[C]+pandoc -f html -t markdown hello.html+\f[R]+.fi+.PP+Supported input and output formats are listed below under Options (see+\f[C]-f\f[R] for input formats and \f[C]-t\f[R] for output formats).+You can also use \f[C]pandoc --list-input-formats\f[R] and+\f[C]pandoc --list-output-formats\f[R] to print lists of supported+formats.+.PP+If the input or output format is not specified explicitly,+\f[C]pandoc\f[R] will attempt to guess it from the extensions of the+filenames.+Thus, for example,+.IP+.nf+\f[C]+pandoc -o hello.tex hello.txt+\f[R]+.fi+.PP+will convert \f[C]hello.txt\f[R] from Markdown to LaTeX.+If no output file is specified (so that output goes to+\f[I]stdout\f[R]), 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[R]), or if the input files\[aq] extensions are unknown, the+input format will be assumed to be Markdown.+.SS Character encoding+.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[R]:+.IP+.nf+\f[C]+iconv -t utf-8 input.txt | pandoc | iconv -f utf-8+\f[R]+.fi+.PP+Note that in some output formats (such as HTML, LaTeX, ConTeXt, RTF,+OPML, DocBook, and Texinfo), information about the character encoding is+included in the document header, which will only be included if you use+the \f[C]-s/--standalone\f[R] option.+.SS Creating a PDF+.PP+To produce a PDF, specify an output file with a \f[C].pdf\f[R]+extension:+.IP+.nf+\f[C]+pandoc test.txt -o test.pdf+\f[R]+.fi+.PP+By default, pandoc will use LaTeX to create the PDF, which requires that+a LaTeX engine be installed (see \f[C]--pdf-engine\f[R] below).+.PP+Alternatively, pandoc can use ConTeXt, \f[C]pdfroff\f[R], or any of the+following HTML/CSS-to-PDF-engines, to create a PDF:+\f[C]wkhtmltopdf\f[R], \f[C]weasyprint\f[R] or \f[C]prince\f[R].+To do this, specify an output file with a \f[C].pdf\f[R] extension, as+before, but add the \f[C]--pdf-engine\f[R] option or+\f[C]-t context\f[R], \f[C]-t html\f[R], or \f[C]-t ms\f[R] to the+command line (\f[C]-t html\f[R] defaults to+\f[C]--pdf-engine=wkhtmltopdf\f[R]).+.PP+PDF output uses variables for LaTeX (with a LaTeX engine); variables for+ConTeXt (with ConTeXt); or variables for \f[C]wkhtmltopdf\f[R] (an+HTML/CSS-to-PDF engine; \f[C]--css\f[R] also affects the output).+.PP+To debug the PDF creation, it can be useful to look at the intermediate+representation: instead of \f[C]-o test.pdf\f[R], use for example+\f[C]-s -o test.tex\f[R] to output the generated LaTeX.+You can then test it with \f[C]pdflatex test.tex\f[R].+.PP+When using LaTeX, the following packages need to be available (they are+included with all recent versions of TeX Live): \f[C]amsfonts\f[R],+\f[C]amsmath\f[R], \f[C]lm\f[R], \f[C]unicode-math\f[R],+\f[C]ifxetex\f[R], \f[C]ifluatex\f[R], \f[C]listings\f[R] (if the+\f[C]--listings\f[R] option is used), \f[C]fancyvrb\f[R],+\f[C]longtable\f[R], \f[C]booktabs\f[R], \f[C]graphicx\f[R] and+\f[C]grffile\f[R] (if the document contains images), \f[C]hyperref\f[R],+\f[C]xcolor\f[R], \f[C]ulem\f[R], \f[C]geometry\f[R] (with the+\f[C]geometry\f[R] variable set), \f[C]setspace\f[R] (with+\f[C]linestretch\f[R]), and \f[C]babel\f[R] (with \f[C]lang\f[R]).+The use of \f[C]xelatex\f[R] or \f[C]lualatex\f[R] as the PDF engine+requires \f[C]fontspec\f[R].+\f[C]xelatex\f[R] uses \f[C]polyglossia\f[R] (with \f[C]lang\f[R]),+\f[C]xecjk\f[R], and \f[C]bidi\f[R] (with the \f[C]dir\f[R] variable+set).+If the \f[C]mathspec\f[R] variable is set, \f[C]xelatex\f[R] will use+\f[C]mathspec\f[R] instead of \f[C]unicode-math\f[R].+The \f[C]upquote\f[R] and \f[C]microtype\f[R] packages are used if+available, and \f[C]csquotes\f[R] will be used for typography if the+\f[C]csquotes\f[R] variable or metadata field is set to a true value.+The \f[C]natbib\f[R], \f[C]biblatex\f[R], \f[C]bibtex\f[R], and+\f[C]biber\f[R] packages can optionally be used for citation rendering.+The following packages will be used to improve output quality if+present, but pandoc does not require them to be present:+\f[C]upquote\f[R] (for straight quotes in verbatim environments),+\f[C]microtype\f[R] (for better spacing adjustments), \f[C]parskip\f[R]+(for better inter-paragraph spaces), \f[C]xurl\f[R] (for better line+breaks in URLs), \f[C]bookmark\f[R] (for better PDF bookmarks), and+\f[C]footnotehyper\f[R] or \f[C]footnote\f[R] (to allow footnotes in+tables).+.SS Reading from the Web+.PP+Instead of an input 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[R]+.fi+.PP+It is possible to supply a custom User-Agent string or other header when+requesting a document from a URL:+.IP+.nf+\f[C]+pandoc -f html -t markdown --request-header User-Agent:\[dq]Mozilla/5.0\[dq] \[rs]+  http://www.fsf.org+\f[R]+.fi+.SH OPTIONS+.SS General options+.TP+\f[B]\f[CB]-f\f[B]\f[R] \f[I]FORMAT\f[R], \f[B]\f[CB]-r\f[B]\f[R] \f[I]FORMAT\f[R], \f[B]\f[CB]--from=\f[B]\f[R]\f[I]FORMAT\f[R], \f[B]\f[CB]--read=\f[B]\f[R]\f[I]FORMAT\f[R]+Specify input format.+\f[I]FORMAT\f[R] can be:+.RS+.IP \[bu] 2+\f[C]commonmark\f[R] (CommonMark Markdown)+.IP \[bu] 2+\f[C]creole\f[R] (Creole 1.0)+.IP \[bu] 2+\f[C]docbook\f[R] (DocBook)+.IP \[bu] 2+\f[C]docx\f[R] (Word docx)+.IP \[bu] 2+\f[C]dokuwiki\f[R] (DokuWiki markup)+.IP \[bu] 2+\f[C]epub\f[R] (EPUB)+.IP \[bu] 2+\f[C]fb2\f[R] (FictionBook2 e-book)+.IP \[bu] 2+\f[C]gfm\f[R] (GitHub-Flavored Markdown), or the deprecated and less+accurate \f[C]markdown_github\f[R]; use \f[C]markdown_github\f[R] only+if you need extensions not supported in \f[C]gfm\f[R].+.IP \[bu] 2+\f[C]haddock\f[R] (Haddock markup)+.IP \[bu] 2+\f[C]html\f[R] (HTML)+.IP \[bu] 2+\f[C]ipynb\f[R] (Jupyter notebook)+.IP \[bu] 2+\f[C]jats\f[R] (JATS XML)+.IP \[bu] 2+\f[C]json\f[R] (JSON version of native AST)+.IP \[bu] 2+\f[C]latex\f[R] (LaTeX)+.IP \[bu] 2+\f[C]markdown\f[R] (Pandoc\[aq]s Markdown)+.IP \[bu] 2+\f[C]markdown_mmd\f[R] (MultiMarkdown)+.IP \[bu] 2+\f[C]markdown_phpextra\f[R] (PHP Markdown Extra)+.IP \[bu] 2+\f[C]markdown_strict\f[R] (original unextended Markdown)+.IP \[bu] 2+\f[C]mediawiki\f[R] (MediaWiki markup)+.IP \[bu] 2+\f[C]man\f[R] (roff man)+.IP \[bu] 2+\f[C]muse\f[R] (Muse)+.IP \[bu] 2+\f[C]native\f[R] (native Haskell)+.IP \[bu] 2+\f[C]odt\f[R] (ODT)+.IP \[bu] 2+\f[C]opml\f[R] (OPML)+.IP \[bu] 2+\f[C]org\f[R] (Emacs Org mode)+.IP \[bu] 2+\f[C]rst\f[R] (reStructuredText)+.IP \[bu] 2+\f[C]t2t\f[R] (txt2tags)+.IP \[bu] 2+\f[C]textile\f[R] (Textile)+.IP \[bu] 2+\f[C]tikiwiki\f[R] (TikiWiki markup)+.IP \[bu] 2+\f[C]twiki\f[R] (TWiki markup)+.IP \[bu] 2+\f[C]vimwiki\f[R] (Vimwiki)+.PP+Extensions can be individually enabled or disabled by appending+\f[C]+EXTENSION\f[R] or \f[C]-EXTENSION\f[R] to the format name.+See Extensions below, for a list of extensions and their names.+See \f[C]--list-input-formats\f[R] and \f[C]--list-extensions\f[R],+below.+.RE+.TP+\f[B]\f[CB]-t\f[B]\f[R] \f[I]FORMAT\f[R], \f[B]\f[CB]-w\f[B]\f[R] \f[I]FORMAT\f[R], \f[B]\f[CB]--to=\f[B]\f[R]\f[I]FORMAT\f[R], \f[B]\f[CB]--write=\f[B]\f[R]\f[I]FORMAT\f[R]+Specify output format.+\f[I]FORMAT\f[R] can be:+.RS+.IP \[bu] 2+\f[C]asciidoc\f[R] (AsciiDoc) or \f[C]asciidoctor\f[R] (AsciiDoctor)+.IP \[bu] 2+\f[C]beamer\f[R] (LaTeX beamer slide show)+.IP \[bu] 2+\f[C]commonmark\f[R] (CommonMark Markdown)+.IP \[bu] 2+\f[C]context\f[R] (ConTeXt)+.IP \[bu] 2+\f[C]docbook\f[R] or \f[C]docbook4\f[R] (DocBook 4)+.IP \[bu] 2+\f[C]docbook5\f[R] (DocBook 5)+.IP \[bu] 2+\f[C]docx\f[R] (Word docx)+.IP \[bu] 2+\f[C]dokuwiki\f[R] (DokuWiki markup)+.IP \[bu] 2+\f[C]epub\f[R] or \f[C]epub3\f[R] (EPUB v3 book)+.IP \[bu] 2+\f[C]epub2\f[R] (EPUB v2)+.IP \[bu] 2+\f[C]fb2\f[R] (FictionBook2 e-book)+.IP \[bu] 2+\f[C]gfm\f[R] (GitHub-Flavored Markdown), or the deprecated and less+accurate \f[C]markdown_github\f[R]; use \f[C]markdown_github\f[R] only+if you need extensions not supported in \f[C]gfm\f[R].+.IP \[bu] 2+\f[C]haddock\f[R] (Haddock markup)+.IP \[bu] 2+\f[C]html\f[R] or \f[C]html5\f[R] (HTML, i.e.+HTML5/XHTML polyglot markup)+.IP \[bu] 2+\f[C]html4\f[R] (XHTML 1.0 Transitional)+.IP \[bu] 2+\f[C]icml\f[R] (InDesign ICML)+.IP \[bu] 2+\f[C]ipynb\f[R] (Jupyter notebook)+.IP \[bu] 2+\f[C]jats\f[R] (JATS XML)+.IP \[bu] 2+\f[C]jira\f[R] (Jira wiki markup)+.IP \[bu] 2+\f[C]json\f[R] (JSON version of native AST)+.IP \[bu] 2+\f[C]latex\f[R] (LaTeX)+.IP \[bu] 2+\f[C]man\f[R] (roff man)+.IP \[bu] 2+\f[C]markdown\f[R] (Pandoc\[aq]s Markdown)+.IP \[bu] 2+\f[C]markdown_mmd\f[R] (MultiMarkdown)+.IP \[bu] 2+\f[C]markdown_phpextra\f[R] (PHP Markdown Extra)+.IP \[bu] 2+\f[C]markdown_strict\f[R] (original unextended Markdown)+.IP \[bu] 2+\f[C]mediawiki\f[R] (MediaWiki markup)+.IP \[bu] 2+\f[C]ms\f[R] (roff ms)+.IP \[bu] 2+\f[C]muse\f[R] (Muse),+.IP \[bu] 2+\f[C]native\f[R] (native Haskell),+.IP \[bu] 2+\f[C]odt\f[R] (OpenOffice text document)+.IP \[bu] 2+\f[C]opml\f[R] (OPML)+.IP \[bu] 2+\f[C]opendocument\f[R] (OpenDocument)+.IP \[bu] 2+\f[C]org\f[R] (Emacs Org mode)+.IP \[bu] 2+\f[C]pdf\f[R] (PDF)+.IP \[bu] 2+\f[C]plain\f[R] (plain text),+.IP \[bu] 2+\f[C]pptx\f[R] (PowerPoint slide show)+.IP \[bu] 2+\f[C]rst\f[R] (reStructuredText)+.IP \[bu] 2+\f[C]rtf\f[R] (Rich Text Format)+.IP \[bu] 2+\f[C]texinfo\f[R] (GNU Texinfo)+.IP \[bu] 2+\f[C]textile\f[R] (Textile)+.IP \[bu] 2+\f[C]slideous\f[R] (Slideous HTML and JavaScript slide show)+.IP \[bu] 2+\f[C]slidy\f[R] (Slidy HTML and JavaScript slide show)+.IP \[bu] 2+\f[C]dzslides\f[R] (DZSlides HTML5 + JavaScript slide show),+.IP \[bu] 2+\f[C]revealjs\f[R] (reveal.js HTML5 + JavaScript slide show)+.IP \[bu] 2+\f[C]s5\f[R] (S5 HTML and JavaScript slide show)+.IP \[bu] 2+\f[C]tei\f[R] (TEI Simple)+.IP \[bu] 2+\f[C]xwiki\f[R] (XWiki markup)+.IP \[bu] 2+\f[C]zimwiki\f[R] (ZimWiki markup)+.IP \[bu] 2+the path of a custom lua writer, see Custom writers below+.PP+Note that \f[C]odt\f[R], \f[C]docx\f[R], \f[C]epub\f[R], and+\f[C]pdf\f[R] output will not be directed to \f[I]stdout\f[R] unless+forced with \f[C]-o -\f[R].+.PP+Extensions can be individually enabled or disabled by appending+\f[C]+EXTENSION\f[R] or \f[C]-EXTENSION\f[R] to the format name.+See Extensions below, for a list of extensions and their names.+See \f[C]--list-output-formats\f[R] and \f[C]--list-extensions\f[R],+below.+.RE+.TP+\f[B]\f[CB]-o\f[B]\f[R] \f[I]FILE\f[R], \f[B]\f[CB]--output=\f[B]\f[R]\f[I]FILE\f[R]+Write output to \f[I]FILE\f[R] instead of \f[I]stdout\f[R].+If \f[I]FILE\f[R] is \f[C]-\f[R], output will go to \f[I]stdout\f[R],+even if a non-textual format (\f[C]docx\f[R], \f[C]odt\f[R],+\f[C]epub2\f[R], \f[C]epub3\f[R]) is specified.+.TP+\f[B]\f[CB]--data-dir=\f[B]\f[R]\f[I]DIRECTORY\f[R]+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.+On *nix and macOS systems this will be the \f[C]pandoc\f[R] subdirectory+of the XDG data directory (by default, \f[C]$HOME/.local/share\f[R],+overridable by setting the \f[C]XDG_DATA_HOME\f[R] environment+variable).+If that directory does not exist, \f[C]$HOME/.pandoc\f[R] will be used+(for backwards compatibility).+In Windows the default user data directory is+\f[C]C:\[rs]Users\[rs]USERNAME\[rs]AppData\[rs]Roaming\[rs]pandoc\f[R].+You can find the default user data directory on your system by looking+at the output of \f[C]pandoc --version\f[R].+A \f[C]reference.odt\f[R], \f[C]reference.docx\f[R], \f[C]epub.css\f[R],+\f[C]templates\f[R], \f[C]slidy\f[R], \f[C]slideous\f[R], or+\f[C]s5\f[R] directory placed in this directory will override+pandoc\[aq]s normal defaults.+.TP+\f[B]\f[CB]-d\f[B]\f[R] \f[I]FILE\f[R], \f[B]\f[CB]--defaults=\f[B]\f[R]\f[I]FILE\f[R]+Specify a set of default option settings.+\f[I]FILE\f[R] is a YAML file whose fields correspond to command-line+option settings.+All options for document conversion, including input and output files,+can be set using a defaults file.+The file will be searched for first in the working directory, and then+in the \f[C]defaults\f[R] subdirectory of the user data directory (see+\f[C]--data-dir\f[R]).+The \f[C].yaml\f[R] extension may be omitted.+See the section Default files for more information on the file format.+Settings from the defaults file may be overridden or extended by+subsequent options on the command line.+.TP+\f[B]\f[CB]--bash-completion\f[B]\f[R]+Generate a bash completion script.+To enable bash completion with pandoc, add this to your+\f[C].bashrc\f[R]:+.RS+.IP+.nf+\f[C]+eval \[dq]$(pandoc --bash-completion)\[dq]+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]--verbose\f[B]\f[R]+Give verbose debugging output.+Currently this only has an effect with PDF output.+.TP+\f[B]\f[CB]--quiet\f[B]\f[R]+Suppress warning messages.+.TP+\f[B]\f[CB]--fail-if-warnings\f[B]\f[R]+Exit with error status if there are any warnings.+.TP+\f[B]\f[CB]--log=\f[B]\f[R]\f[I]FILE\f[R]+Write log messages in machine-readable JSON format to \f[I]FILE\f[R].+All messages above DEBUG level will be written, regardless of verbosity+settings (\f[C]--verbose\f[R], \f[C]--quiet\f[R]).+.TP+\f[B]\f[CB]--list-input-formats\f[B]\f[R]+List supported input formats, one per line.+.TP+\f[B]\f[CB]--list-output-formats\f[B]\f[R]+List supported output formats, one per line.+.TP+\f[B]\f[CB]--list-extensions\f[B]\f[R][\f[B]\f[CB]=\f[B]\f[R]\f[I]FORMAT\f[R]]+List supported extensions for \f[I]FORMAT\f[R], one per line, preceded+by a \f[C]+\f[R] or \f[C]-\f[R] indicating whether it is enabled by+default in \f[I]FORMAT\f[R].+If \f[I]FORMAT\f[R] is not specified, defaults for pandoc\[aq]s Markdown+are given.+.TP+\f[B]\f[CB]--list-highlight-languages\f[B]\f[R]+List supported languages for syntax highlighting, one per line.+.TP+\f[B]\f[CB]--list-highlight-styles\f[B]\f[R]+List supported styles for syntax highlighting, one per line.+See \f[C]--highlight-style\f[R].+.TP+\f[B]\f[CB]-v\f[B]\f[R], \f[B]\f[CB]--version\f[B]\f[R]+Print version.+.TP+\f[B]\f[CB]-h\f[B]\f[R], \f[B]\f[CB]--help\f[B]\f[R]+Show usage message.+.SS Reader options+.TP+\f[B]\f[CB]--shift-heading-level-by=\f[B]\f[R]\f[I]NUMBER\f[R]+Shift heading levels by a positive or negative integer.+For example, with \f[C]--shift-heading-level-by=-1\f[R], level 2+headings become level 1 headings, and level 3 headings become level 2+headings.+Headings cannot have a level less than 1, so a heading that would be+shifted below level 1 becomes a regular paragraph.+Exception: with a shift of -1, a level-1 heading at the beginning of the+document replaces the metadata title.+Conversely, with a shift of +1, a nonempty metadata title becomes a+level-1 heading at the beginning of the document.+\f[C]--shift-heading-level-by=-1\f[R] is a good choice when converting+HTML or Markdown documents that use an initial level-1 heading for the+document title and level-2+ headings for sections.+.TP+\f[B]\f[CB]--base-header-level=\f[B]\f[R]\f[I]NUMBER\f[R]+\f[I]Deprecated. Use \f[CI]--shift-heading-level-by\f[I] instead.\f[R]+Specify the base level for headings (defaults to 1).+.TP+\f[B]\f[CB]--strip-empty-paragraphs\f[B]\f[R]+\f[I]Deprecated. Use the \f[CI]+empty_paragraphs\f[I] extension+instead.\f[R] Ignore paragraphs with no content.+This option is useful for converting word processing documents where+users have used empty paragraphs to create inter-paragraph space.+.TP+\f[B]\f[CB]--indented-code-classes=\f[B]\f[R]\f[I]CLASSES\f[R]+Specify classes to use for indented code blocks--for example,+\f[C]perl,numberLines\f[R] or \f[C]haskell\f[R].+Multiple classes may be separated by spaces or commas.+.TP+\f[B]\f[CB]--default-image-extension=\f[B]\f[R]\f[I]EXTENSION\f[R]+Specify a default extension to use when image paths/URLs have no+extension.+This allows you to use the same source for formats that require+different kinds of images.+Currently this option only affects the Markdown and LaTeX readers.+.TP+\f[B]\f[CB]--file-scope\f[B]\f[R]+Parse each file individually before combining for multifile documents.+This will allow footnotes in different files with the same identifiers+to work as expected.+If this option is set, footnotes and links will not work across files.+Reading binary files (docx, odt, epub) implies \f[C]--file-scope\f[R].+.TP+\f[B]\f[CB]-F\f[B]\f[R] \f[I]PROGRAM\f[R], \f[B]\f[CB]--filter=\f[B]\f[R]\f[I]PROGRAM\f[R]+Specify an executable to be used as a filter transforming the pandoc AST+after the input is parsed and before the output is written.+The executable should read JSON from stdin and write JSON to stdout.+The JSON must be formatted like pandoc\[aq]s own JSON input and output.+The name of the output format will be passed to the filter as the first+argument.+Hence,+.RS+.IP+.nf+\f[C]+pandoc --filter ./caps.py -t latex+\f[R]+.fi+.PP+is equivalent to+.IP+.nf+\f[C]+pandoc -t json | ./caps.py latex | pandoc -f json -t latex+\f[R]+.fi+.PP+The latter form may be useful for debugging filters.+.PP+Filters may be written in any language.+\f[C]Text.Pandoc.JSON\f[R] exports \f[C]toJSONFilter\f[R] to facilitate+writing filters in Haskell.+Those who would prefer to write filters in python can use the module+\f[C]pandocfilters\f[R], installable from PyPI.+There are also pandoc filter libraries in PHP, perl, and+JavaScript/node.js.+.PP+In order of preference, pandoc will look for filters in+.IP "1." 3+a specified full or relative path (executable or non-executable)+.IP "2." 3+\f[C]$DATADIR/filters\f[R] (executable or non-executable) where+\f[C]$DATADIR\f[R] is the user data directory (see \f[C]--data-dir\f[R],+above).+.IP "3." 3+\f[C]$PATH\f[R] (executable only)+.PP+Filters and lua-filters are applied in the order specified on the+command line.+.RE+.TP+\f[B]\f[CB]-L\f[B]\f[R] \f[I]SCRIPT\f[R], \f[B]\f[CB]--lua-filter=\f[B]\f[R]\f[I]SCRIPT\f[R]+Transform the document in a similar fashion as JSON filters (see+\f[C]--filter\f[R]), but use pandoc\[aq]s build-in lua filtering system.+The given lua script is expected to return a list of lua filters which+will be applied in order.+Each lua filter must contain element-transforming functions indexed by+the name of the AST element on which the filter function should be+applied.+.RS+.PP+The \f[C]pandoc\f[R] lua module provides helper functions for element+creation.+It is always loaded into the script\[aq]s lua environment.+.PP+The following is an example lua script for macro-expansion:+.IP+.nf+\f[C]+function expand_hello_world(inline)+  if inline.c == \[aq]{{helloworld}}\[aq] then+    return pandoc.Emph{ pandoc.Str \[dq]Hello, World\[dq] }+  else+    return inline+  end+end++return {{Str = expand_hello_world}}+\f[R]+.fi+.PP+In order of preference, pandoc will look for lua filters in+.IP "1." 3+a specified full or relative path (executable or non-executable)+.IP "2." 3+\f[C]$DATADIR/filters\f[R] (executable or non-executable) where+\f[C]$DATADIR\f[R] is the user data directory (see \f[C]--data-dir\f[R],+above).+.RE+.TP+\f[B]\f[CB]-M\f[B]\f[R] \f[I]KEY\f[R][\f[B]\f[CB]=\f[B]\f[R]\f[I]VAL\f[R]], \f[B]\f[CB]--metadata=\f[B]\f[R]\f[I]KEY\f[R][\f[B]\f[CB]:\f[B]\f[R]\f[I]VAL\f[R]]+Set the metadata field \f[I]KEY\f[R] to the value \f[I]VAL\f[R].+A value specified on the command line overrides a value specified in the+document using YAML metadata blocks.+Values will be parsed as YAML boolean or string values.+If no value is specified, the value will be treated as Boolean true.+Like \f[C]--variable\f[R], \f[C]--metadata\f[R] causes template+variables to be set.+But unlike \f[C]--variable\f[R], \f[C]--metadata\f[R] affects the+metadata of the underlying document (which is accessible from filters+and may be printed in some output formats) and metadata values will be+escaped when inserted into the template.+.TP+\f[B]\f[CB]--metadata-file=\f[B]\f[R]\f[I]FILE\f[R]+Read metadata from the supplied YAML (or JSON) file.+This option can be used with every input format, but string scalars in+the YAML file will always be parsed as Markdown.+Generally, the input will be handled the same as in YAML metadata+blocks.+This option can be used repeatedly to include multiple metadata files;+values in files specified later on the command line will be preferred+over those specified in earlier files.+Metadata values specified inside the document, or by using \f[C]-M\f[R],+overwrite values specified with this option.+.TP+\f[B]\f[CB]-p\f[B]\f[R], \f[B]\f[CB]--preserve-tabs\f[B]\f[R]+Preserve tabs instead of converting them to spaces.+(By default, pandoc converts tabs to spaces before parsing its input.)+Note that this will only affect tabs in literal code spans and code+blocks.+Tabs in regular text are always treated as spaces.+.TP+\f[B]\f[CB]--tab-stop=\f[B]\f[R]\f[I]NUMBER\f[R]+Specify the number of spaces per tab (default is 4).+.TP+\f[B]\f[CB]--track-changes=accept\f[B]\f[R]|\f[B]\f[CB]reject\f[B]\f[R]|\f[B]\f[CB]all\f[B]\f[R]+Specifies what to do with insertions, deletions, and comments produced+by the MS Word \[dq]Track Changes\[dq] feature.+\f[C]accept\f[R] (the default), inserts all insertions, and ignores all+deletions.+\f[C]reject\f[R] inserts all deletions and ignores insertions.+Both \f[C]accept\f[R] and \f[C]reject\f[R] ignore comments.+\f[C]all\f[R] puts in insertions, deletions, and comments, wrapped in+spans with \f[C]insertion\f[R], \f[C]deletion\f[R],+\f[C]comment-start\f[R], and \f[C]comment-end\f[R] classes,+respectively.+The author and time of change is included.+\f[C]all\f[R] is useful for scripting: only accepting changes from a+certain reviewer, say, or before a certain date.+If a paragraph is inserted or deleted, \f[C]track-changes=all\f[R]+produces a span with the class+\f[C]paragraph-insertion\f[R]/\f[C]paragraph-deletion\f[R] before the+affected paragraph break.+This option only affects the docx reader.+.TP+\f[B]\f[CB]--extract-media=\f[B]\f[R]\f[I]DIR\f[R]+Extract images and other media contained in or linked from the source+document to the path \f[I]DIR\f[R], creating it if necessary, and adjust+the images references in the document so they point to the extracted+files.+If the source format is a binary container (docx, epub, or odt), the+media is extracted from the container and the original filenames are+used.+Otherwise the media is read from the file system or downloaded, and new+filenames are constructed based on SHA1 hashes of the contents.+.TP+\f[B]\f[CB]--abbreviations=\f[B]\f[R]\f[I]FILE\f[R]+Specifies a custom abbreviations file, with abbreviations one to a line.+If this option is not specified, pandoc will read the data file+\f[C]abbreviations\f[R] from the user data directory or fall back on a+system default.+To see the system default, use+\f[C]pandoc --print-default-data-file=abbreviations\f[R].+The only use pandoc makes of this list is in the Markdown reader.+Strings ending in a period that are found in this list will be followed+by a nonbreaking space, so that the period will not produce+sentence-ending space in formats like LaTeX.+.SS General writer options+.TP+\f[B]\f[CB]-s\f[B]\f[R], \f[B]\f[CB]--standalone\f[B]\f[R]+Produce output with an appropriate header and footer (e.g.+a standalone HTML, LaTeX, TEI, or RTF file, not a fragment).+This option is set automatically for \f[C]pdf\f[R], \f[C]epub\f[R],+\f[C]epub3\f[R], \f[C]fb2\f[R], \f[C]docx\f[R], and \f[C]odt\f[R]+output.+For \f[C]native\f[R] output, this option causes metadata to be included;+otherwise, metadata is suppressed.+.TP+\f[B]\f[CB]--template=\f[B]\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]+Use the specified file as a custom template for the generated document.+Implies \f[C]--standalone\f[R].+See Templates, below, for a description of template syntax.+If no extension is specified, an extension corresponding to the writer+will be added, so that \f[C]--template=special\f[R] looks for+\f[C]special.html\f[R] for HTML output.+If the template is not found, pandoc will search for it in the+\f[C]templates\f[R] subdirectory of the user data directory (see+\f[C]--data-dir\f[R]).+If this option is not used, a default template appropriate for the+output format will be used (see \f[C]-D/--print-default-template\f[R]).+.TP+\f[B]\f[CB]-V\f[B]\f[R] \f[I]KEY\f[R][\f[B]\f[CB]=\f[B]\f[R]\f[I]VAL\f[R]], \f[B]\f[CB]--variable=\f[B]\f[R]\f[I]KEY\f[R][\f[B]\f[CB]:\f[B]\f[R]\f[I]VAL\f[R]]+Set the template variable \f[I]KEY\f[R] to the value \f[I]VAL\f[R] when+rendering the document in standalone mode.+If no \f[I]VAL\f[R] is specified, the key will be given the value+\f[C]true\f[R].+.TP+\f[B]\f[CB]-D\f[B]\f[R] \f[I]FORMAT\f[R], \f[B]\f[CB]--print-default-template=\f[B]\f[R]\f[I]FORMAT\f[R]+Print the system default template for an output \f[I]FORMAT\f[R].+(See \f[C]-t\f[R] for a list of possible \f[I]FORMAT\f[R]s.) Templates+in the user data directory are ignored.+This option may be used with \f[C]-o\f[R]/\f[C]--output\f[R] to redirect+output to a file, but \f[C]-o\f[R]/\f[C]--output\f[R] must come before+\f[C]--print-default-template\f[R] on the command line.+.RS+.PP+Note that some of the default templates use partials, for example+\f[C]styles.html\f[R].+To print the partials, use \f[C]--print-default-data-file\f[R]: for+example, \f[C]--print-default-data-file=templates/styles.html\f[R].+.RE+.TP+\f[B]\f[CB]--print-default-data-file=\f[B]\f[R]\f[I]FILE\f[R]+Print a system default data file.+Files in the user data directory are ignored.+This option may be used with \f[C]-o\f[R]/\f[C]--output\f[R] to redirect+output to a file, but \f[C]-o\f[R]/\f[C]--output\f[R] must come before+\f[C]--print-default-data-file\f[R] on the command line.+.TP+\f[B]\f[CB]--eol=crlf\f[B]\f[R]|\f[B]\f[CB]lf\f[B]\f[R]|\f[B]\f[CB]native\f[B]\f[R]+Manually specify line endings: \f[C]crlf\f[R] (Windows), \f[C]lf\f[R]+(macOS/Linux/UNIX), or \f[C]native\f[R] (line endings appropriate to the+OS on which pandoc is being run).+The default is \f[C]native\f[R].+.TP+\f[B]\f[CB]--dpi\f[B]\f[R]=\f[I]NUMBER\f[R]+Specify the default dpi (dots per inch) value for conversion from pixels+to inch/centimeters and vice versa.+(Technically, the correct term would be ppi: pixels per inch.) The+default is 96dpi.+When images contain information about dpi internally, the encoded value+is used instead of the default specified by this option.+.TP+\f[B]\f[CB]--wrap=auto\f[B]\f[R]|\f[B]\f[CB]none\f[B]\f[R]|\f[B]\f[CB]preserve\f[B]\f[R]+Determine how text is wrapped in the output (the source code, not the+rendered version).+With \f[C]auto\f[R] (the default), pandoc will attempt to wrap lines to+the column width specified by \f[C]--columns\f[R] (default 72).+With \f[C]none\f[R], pandoc will not wrap lines at all.+With \f[C]preserve\f[R], pandoc will attempt to preserve the wrapping+from the source document (that is, where there are nonsemantic newlines+in the source, there will be nonsemantic newlines in the output as+well).+Automatic wrapping does not currently work in HTML output.+In \f[C]ipynb\f[R] output, this option affects wrapping of the contents+of markdown cells.+.TP+\f[B]\f[CB]--columns=\f[B]\f[R]\f[I]NUMBER\f[R]+Specify length of lines in characters.+This affects text wrapping in the generated source code (see+\f[C]--wrap\f[R]).+It also affects calculation of column widths for plain text tables (see+Tables below).+.TP+\f[B]\f[CB]--toc\f[B]\f[R], \f[B]\f[CB]--table-of-contents\f[B]\f[R]+Include an automatically generated table of contents (or, in the case of+\f[C]latex\f[R], \f[C]context\f[R], \f[C]docx\f[R], \f[C]odt\f[R],+\f[C]opendocument\f[R], \f[C]rst\f[R], or \f[C]ms\f[R], an instruction+to create one) in the output document.+This option has no effect unless \f[C]-s/--standalone\f[R] is used, and+it has no effect on \f[C]man\f[R], \f[C]docbook4\f[R],+\f[C]docbook5\f[R], or \f[C]jats\f[R] output.+.RS+.PP+Note that if you are producing a PDF via \f[C]ms\f[R], the table of+contents will appear at the beginning of the document, before the title.+If you would prefer it to be at the end of the document, use the option+\f[C]--pdf-engine-opt=--no-toc-relocation\f[R].+.RE+.TP+\f[B]\f[CB]--toc-depth=\f[B]\f[R]\f[I]NUMBER\f[R]+Specify the number of section levels to include in the table of+contents.+The default is 3 (which means that level-1, 2, and 3 headings will be+listed in the contents).+.TP+\f[B]\f[CB]--strip-comments\f[B]\f[R]+Strip out HTML comments in the Markdown or Textile source, rather than+passing them on to Markdown, Textile or HTML output as raw HTML.+This does not apply to HTML comments inside raw HTML blocks when the+\f[C]markdown_in_html_blocks\f[R] extension is not set.+.TP+\f[B]\f[CB]--no-highlight\f[B]\f[R]+Disables syntax highlighting for code blocks and inlines, even when a+language attribute is given.+.TP+\f[B]\f[CB]--highlight-style=\f[B]\f[R]\f[I]STYLE\f[R]|\f[I]FILE\f[R]+Specifies the coloring style to be used in highlighted source code.+Options are \f[C]pygments\f[R] (the default), \f[C]kate\f[R],+\f[C]monochrome\f[R], \f[C]breezeDark\f[R], \f[C]espresso\f[R],+\f[C]zenburn\f[R], \f[C]haddock\f[R], and \f[C]tango\f[R].+For more information on syntax highlighting in pandoc, see Syntax+highlighting, below.+See also \f[C]--list-highlight-styles\f[R].+.RS+.PP+Instead of a \f[I]STYLE\f[R] name, a JSON file with extension+\f[C].theme\f[R] may be supplied.+This will be parsed as a KDE syntax highlighting theme and (if valid)+used as the highlighting style.+.PP+To generate the JSON version of an existing style, use+\f[C]--print-highlight-style\f[R].+.RE+.TP+\f[B]\f[CB]--print-highlight-style=\f[B]\f[R]\f[I]STYLE\f[R]|\f[I]FILE\f[R]+Prints a JSON version of a highlighting style, which can be modified,+saved with a \f[C].theme\f[R] extension, and used with+\f[C]--highlight-style\f[R].+This option may be used with \f[C]-o\f[R]/\f[C]--output\f[R] to redirect+output to a file, but \f[C]-o\f[R]/\f[C]--output\f[R] must come before+\f[C]--print-highlight-style\f[R] on the command line.+.TP+\f[B]\f[CB]--syntax-definition=\f[B]\f[R]\f[I]FILE\f[R]+Instructs pandoc to load a KDE XML syntax definition file, which will be+used for syntax highlighting of appropriately marked code blocks.+This can be used to add support for new languages or to use altered+syntax definitions for existing languages.+This option may be repeated to add multiple syntax definitions.+.TP+\f[B]\f[CB]-H\f[B]\f[R] \f[I]FILE\f[R], \f[B]\f[CB]--include-in-header=\f[B]\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]+Include contents of \f[I]FILE\f[R], 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[R].+.TP+\f[B]\f[CB]-B\f[B]\f[R] \f[I]FILE\f[R], \f[B]\f[CB]--include-before-body=\f[B]\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]+Include contents of \f[I]FILE\f[R], verbatim, at the beginning of the+document body (e.g.+after the \f[C]<body>\f[R] tag in HTML, or the+\f[C]\[rs]begin{document}\f[R] 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[R].+.TP+\f[B]\f[CB]-A\f[B]\f[R] \f[I]FILE\f[R], \f[B]\f[CB]--include-after-body=\f[B]\f[R]\f[I]FILE\f[R]|\f[I]URL\f[R]+Include contents of \f[I]FILE\f[R], verbatim, at the end of the document+body (before the \f[C]</body>\f[R] tag in HTML, or the+\f[C]\[rs]end{document}\f[R] command in LaTeX).+This option can be used repeatedly to include multiple files.+They will be included in the order specified.+Implies \f[C]--standalone\f[R].+.TP+\f[B]\f[CB]--resource-path=\f[B]\f[R]\f[I]SEARCHPATH\f[R]+List of paths to search for images and other resources.+The paths should be separated by \f[C]:\f[R] on Linux, UNIX, and macOS+systems, and by \f[C];\f[R] on Windows.+If \f[C]--resource-path\f[R] is not specified, the default resource path+is the working directory.+Note that, if \f[C]--resource-path\f[R] is specified, the working+directory must be explicitly listed or it will not be searched.+For example: \f[C]--resource-path=.:test\f[R] will search the working+directory and the \f[C]test\f[R] subdirectory, in that order.+.RS+.PP+\f[C]--resource-path\f[R] only has an effect if (a) the output format+embeds images (for example, \f[C]docx\f[R], \f[C]pdf\f[R], or+\f[C]html\f[R] with \f[C]--self-contained\f[R]) or (b) it is used+together with \f[C]--extract-media\f[R].+.RE+.TP+\f[B]\f[CB]--request-header=\f[B]\f[R]\f[I]NAME\f[R]\f[B]\f[CB]:\f[B]\f[R]\f[I]VAL\f[R]+Set the request header \f[I]NAME\f[R] to the value \f[I]VAL\f[R] when+making HTTP requests (for example, when a URL is given on the command+line, or when resources used in a document must be downloaded).+If you\[aq]re behind a proxy, you also need to set the environment+variable \f[C]http_proxy\f[R] to \f[C]http://...\f[R].+.SS Options affecting specific writers+.TP+\f[B]\f[CB]--self-contained\f[B]\f[R]+Produce a standalone HTML file with no external dependencies, using+\f[C]data:\f[R] URIs to incorporate the contents of linked scripts,+stylesheets, images, and videos.+Implies \f[C]--standalone\f[R].+The resulting file should be \[dq]self-contained,\[dq] in the sense that+it needs no external files and no net access to be displayed properly by+a browser.+This option works only with HTML output formats, including+\f[C]html4\f[R], \f[C]html5\f[R], \f[C]html+lhs\f[R],+\f[C]html5+lhs\f[R], \f[C]s5\f[R], \f[C]slidy\f[R], \f[C]slideous\f[R],+\f[C]dzslides\f[R], and \f[C]revealjs\f[R].+Scripts, images, and stylesheets at absolute URLs will be downloaded;+those at relative URLs will be sought relative to the working directory+(if the first source file is local) or relative to the base URL (if the+first source file is remote).+Elements with the attribute \f[C]data-external=\[dq]1\[dq]\f[R] will be+left alone; the documents they link to will not be incorporated in the+document.+Limitation: resources that are loaded dynamically through JavaScript+cannot be incorporated; as a result, \f[C]--self-contained\f[R] does not+work with \f[C]--mathjax\f[R], and some advanced features (e.g.+zoom or speaker notes) may not work in an offline+\[dq]self-contained\[dq] \f[C]reveal.js\f[R] slide show.+.TP+\f[B]\f[CB]--html-q-tags\f[B]\f[R]+Use \f[C]<q>\f[R] tags for quotes in HTML.+.TP+\f[B]\f[CB]--ascii\f[B]\f[R]+Use only ASCII characters in output.+Currently supported for XML and HTML formats (which use entities instead+of UTF-8 when this option is selected), CommonMark, gfm, and Markdown+(which use entities), roff ms (which use hexadecimal escapes), and to a+limited degree LaTeX (which uses standard commands for accented+characters when possible).+roff man output uses ASCII by default.+.TP+\f[B]\f[CB]--reference-links\f[B]\f[R]+Use reference-style links, rather than inline links, in writing Markdown+or reStructuredText.+By default inline links are used.+The placement of link references is affected by the+\f[C]--reference-location\f[R] option.+.TP+\f[B]\f[CB]--reference-location = block\f[B]\f[R]|\f[B]\f[CB]section\f[B]\f[R]|\f[B]\f[CB]document\f[B]\f[R]+Specify whether footnotes (and references, if \f[C]reference-links\f[R]+is set) are placed at the end of the current (top-level) block, the+current section, or the document.+The default is \f[C]document\f[R].+Currently only affects the markdown writer.+.TP+\f[B]\f[CB]--atx-headers\f[B]\f[R]+Use ATX-style headings in Markdown output.+The default is to use setext-style headings for levels 1 to 2, and then+ATX headings.+(Note: for \f[C]gfm\f[R] output, ATX headings are always used.) This+option also affects markdown cells in \f[C]ipynb\f[R] output.+.TP+\f[B]\f[CB]--top-level-division=[default|section|chapter|part]\f[B]\f[R]+Treat top-level headings as the given division type in LaTeX, ConTeXt,+DocBook, and TEI output.+The hierarchy order is part, chapter, then section; all headings are+shifted such that the top-level heading becomes the specified type.+The default behavior is to determine the best division type via+heuristics: unless other conditions apply, \f[C]section\f[R] is chosen.+When the \f[C]documentclass\f[R] variable is set to \f[C]report\f[R],+\f[C]book\f[R], or \f[C]memoir\f[R] (unless the \f[C]article\f[R] option+is specified), \f[C]chapter\f[R] is implied as the setting for this+option.+If \f[C]beamer\f[R] is the output format, specifying either+\f[C]chapter\f[R] or \f[C]part\f[R] will cause top-level headings to+become \f[C]\[rs]part{..}\f[R], while second-level headings remain as+their default type.+.TP+\f[B]\f[CB]-N\f[B]\f[R], \f[B]\f[CB]--number-sections\f[B]\f[R]+Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.+By default, sections are not numbered.+Sections with class \f[C]unnumbered\f[R] will never be numbered, even if+\f[C]--number-sections\f[R] is specified.+.TP+\f[B]\f[CB]--number-offset=\f[B]\f[R]\f[I]NUMBER\f[R][\f[B]\f[CB],\f[B]\f[R]\f[I]NUMBER\f[R]\f[B]\f[CB],\f[B]\f[R]\f[I]...\f[R]]+Offset for section headings in HTML output (ignored in other output+formats).+The first number is added to the section number for top-level headings,+the second for second-level headings, and so on.+So, for example, if you want the first top-level heading in your+document to be numbered \[dq]6\[dq], specify+\f[C]--number-offset=5\f[R].+If your document starts with a level-2 heading which you want to be+numbered \[dq]1.5\[dq], specify \f[C]--number-offset=1,4\f[R].+Offsets are 0 by default.+Implies \f[C]--number-sections\f[R].+.TP+\f[B]\f[CB]--listings\f[B]\f[R]+Use the \f[C]listings\f[R] package for LaTeX code blocks.+The package does not support multi-byte encoding for source code.+To handle UTF-8 you would need to use a custom template.+This issue is fully documented here: Encoding issue with the listings+package.+.TP+\f[B]\f[CB]-i\f[B]\f[R], \f[B]\f[CB]--incremental\f[B]\f[R]+Make list items in slide shows display incrementally (one by one).+The default is for lists to be displayed all at once.+.TP+\f[B]\f[CB]--slide-level=\f[B]\f[R]\f[I]NUMBER\f[R]+Specifies that headings with the specified level create slides (for+\f[C]beamer\f[R], \f[C]s5\f[R], \f[C]slidy\f[R], \f[C]slideous\f[R],+\f[C]dzslides\f[R]).+Headings above this level in the hierarchy are used to divide the slide+show into sections; headings below this level create subheads within a+slide.+Note that content that is not contained under slide-level headings will+not appear in the slide show.+The default is to set the slide level based on the contents of the+document; see Structuring the slide show.+.TP+\f[B]\f[CB]--section-divs\f[B]\f[R]+Wrap sections in \f[C]<section>\f[R] tags (or \f[C]<div>\f[R] tags for+\f[C]html4\f[R]), and attach identifiers to the enclosing+\f[C]<section>\f[R] (or \f[C]<div>\f[R]) rather than the heading itself.+See Heading identifiers, below.+.TP+\f[B]\f[CB]--email-obfuscation=none\f[B]\f[R]|\f[B]\f[CB]javascript\f[B]\f[R]|\f[B]\f[CB]references\f[B]\f[R]+Specify a method for obfuscating \f[C]mailto:\f[R] links in HTML+documents.+\f[C]none\f[R] leaves \f[C]mailto:\f[R] links as they are.+\f[C]javascript\f[R] obfuscates them using JavaScript.+\f[C]references\f[R] obfuscates them by printing their letters as+decimal or hexadecimal character references.+The default is \f[C]none\f[R].+.TP+\f[B]\f[CB]--id-prefix=\f[B]\f[R]\f[I]STRING\f[R]+Specify a prefix to be added to all identifiers and internal links in+HTML and DocBook output, and to footnote numbers in Markdown and Haddock+output.+This is useful for preventing duplicate identifiers when generating+fragments to be included in other pages.+.TP+\f[B]\f[CB]-T\f[B]\f[R] \f[I]STRING\f[R], \f[B]\f[CB]--title-prefix=\f[B]\f[R]\f[I]STRING\f[R]+Specify \f[I]STRING\f[R] 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[R].+.TP+\f[B]\f[CB]-c\f[B]\f[R] \f[I]URL\f[R], \f[B]\f[CB]--css=\f[B]\f[R]\f[I]URL\f[R]+Link to a CSS style sheet.+This option can be used repeatedly to include multiple files.+They will be included in the order specified.+.RS+.PP+A stylesheet is required for generating EPUB.+If none is provided using this option (or the \f[C]css\f[R] or+\f[C]stylesheet\f[R] metadata fields), pandoc will look for a file+\f[C]epub.css\f[R] in the user data directory (see+\f[C]--data-dir\f[R]).+If it is not found there, sensible defaults will be used.+.RE+.TP+\f[B]\f[CB]--reference-doc=\f[B]\f[R]\f[I]FILE\f[R]+Use the specified file as a style reference in producing a docx or ODT+file.+.RS+.TP+Docx+For best results, the reference docx should be a modified version of a+docx file produced using pandoc.+The contents of the reference docx are ignored, but its stylesheets and+document properties (including margins, page size, header, and footer)+are used in the new docx.+If no reference docx is specified on the command line, pandoc will look+for a file \f[C]reference.docx\f[R] in the user data directory (see+\f[C]--data-dir\f[R]).+If this is not found either, sensible defaults will be used.+.RS+.PP+To produce a custom \f[C]reference.docx\f[R], first get a copy of the+default \f[C]reference.docx\f[R]:+\f[C]pandoc -o custom-reference.docx --print-default-data-file reference.docx\f[R].+Then open \f[C]custom-reference.docx\f[R] in Word, modify the styles as+you wish, and save the file.+For best results, do not make changes to this file other than modifying+the styles used by pandoc:+.PP+Paragraph styles:+.IP \[bu] 2+Normal+.IP \[bu] 2+Body Text+.IP \[bu] 2+First Paragraph+.IP \[bu] 2+Compact+.IP \[bu] 2+Title+.IP \[bu] 2+Subtitle+.IP \[bu] 2+Author+.IP \[bu] 2+Date+.IP \[bu] 2+Abstract+.IP \[bu] 2+Bibliography+.IP \[bu] 2+Heading 1+.IP \[bu] 2+Heading 2+.IP \[bu] 2+Heading 3+.IP \[bu] 2+Heading 4+.IP \[bu] 2+Heading 5+.IP \[bu] 2+Heading 6+.IP \[bu] 2+Heading 7+.IP \[bu] 2+Heading 8+.IP \[bu] 2+Heading 9+.IP \[bu] 2+Block Text+.IP \[bu] 2+Footnote Text+.IP \[bu] 2+Definition Term+.IP \[bu] 2+Definition+.IP \[bu] 2+Caption+.IP \[bu] 2+Table Caption+.IP \[bu] 2+Image Caption+.IP \[bu] 2+Figure+.IP \[bu] 2+Captioned Figure+.IP \[bu] 2+TOC Heading+.PP+Character styles:+.IP \[bu] 2+Default Paragraph Font+.IP \[bu] 2+Body Text Char+.IP \[bu] 2+Verbatim Char+.IP \[bu] 2+Footnote Reference+.IP \[bu] 2+Hyperlink+.PP+Table style:+.IP \[bu] 2+Table+.RE+.TP+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[R] in the user data directory (see+\f[C]--data-dir\f[R]).+If this is not found either, sensible defaults will be used.+.RS+.PP+To produce a custom \f[C]reference.odt\f[R], first get a copy of the+default \f[C]reference.odt\f[R]:+\f[C]pandoc -o custom-reference.odt --print-default-data-file reference.odt\f[R].+Then open \f[C]custom-reference.odt\f[R] in LibreOffice, modify the+styles as you wish, and save the file.+.RE+.TP+PowerPoint+Templates included with Microsoft PowerPoint 2013 (either with+\f[C].pptx\f[R] or \f[C].potx\f[R] extension) are known to work, as are+most templates derived from these.+.RS+.PP+The specific requirement is that the template should begin with the+following first four layouts:+.IP "1." 3+Title Slide+.IP "2." 3+Title and Content+.IP "3." 3+Section Header+.IP "4." 3+Two Content+.PP+All templates included with a recent version of MS PowerPoint will fit+these criteria.+(You can click on \f[C]Layout\f[R] under the \f[C]Home\f[R] menu to+check.)+.PP+You can also modify the default \f[C]reference.pptx\f[R]: first run+\f[C]pandoc -o custom-reference.pptx --print-default-data-file reference.pptx\f[R],+and then modify \f[C]custom-reference.pptx\f[R] in MS PowerPoint (pandoc+will use the first four layout slides, as mentioned above).+.RE+.RE+.TP+\f[B]\f[CB]--epub-cover-image=\f[B]\f[R]\f[I]FILE\f[R]+Use the specified image as the EPUB cover.+It is recommended that the image be less than 1000px in width and+height.+Note that in a Markdown source document you can also specify+\f[C]cover-image\f[R] in a YAML metadata block (see EPUB Metadata,+below).+.TP+\f[B]\f[CB]--epub-metadata=\f[B]\f[R]\f[I]FILE\f[R]+Look in the specified XML file for metadata for the EPUB.+The file should contain a series of Dublin Core elements.+For example:+.RS+.IP+.nf+\f[C]+ <dc:rights>Creative Commons</dc:rights>+ <dc:language>es-AR</dc:language>+\f[R]+.fi+.PP+By default, pandoc will include the following metadata elements:+\f[C]<dc:title>\f[R] (from the document title), \f[C]<dc:creator>\f[R]+(from the document authors), \f[C]<dc:date>\f[R] (from the document+date, which should be in ISO 8601 format), \f[C]<dc:language>\f[R] (from+the \f[C]lang\f[R] variable, or, if is not set, the locale), and+\f[C]<dc:identifier id=\[dq]BookId\[dq]>\f[R] (a randomly generated+UUID).+Any of these may be overridden by elements in the metadata file.+.PP+Note: if the source document is Markdown, a YAML metadata block in the+document can be used instead.+See below under EPUB Metadata.+.RE+.TP+\f[B]\f[CB]--epub-embed-font=\f[B]\f[R]\f[I]FILE\f[R]+Embed the specified font in the EPUB.+This option can be repeated to embed multiple fonts.+Wildcards can also be used: for example, \f[C]DejaVuSans-*.ttf\f[R].+However, if you use wildcards on the command line, be sure to escape+them or put the whole filename in single quotes, to prevent them from+being interpreted by the shell.+To use the embedded fonts, you will need to add declarations like the+following to your CSS (see \f[C]--css\f[R]):+.RS+.IP+.nf+\f[C]+\[at]font-face {+font-family: DejaVuSans;+font-style: normal;+font-weight: normal;+src:url(\[dq]DejaVuSans-Regular.ttf\[dq]);+}+\[at]font-face {+font-family: DejaVuSans;+font-style: normal;+font-weight: bold;+src:url(\[dq]DejaVuSans-Bold.ttf\[dq]);+}+\[at]font-face {+font-family: DejaVuSans;+font-style: italic;+font-weight: normal;+src:url(\[dq]DejaVuSans-Oblique.ttf\[dq]);+}+\[at]font-face {+font-family: DejaVuSans;+font-style: italic;+font-weight: bold;+src:url(\[dq]DejaVuSans-BoldOblique.ttf\[dq]);+}+body { font-family: \[dq]DejaVuSans\[dq]; }+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]--epub-chapter-level=\f[B]\f[R]\f[I]NUMBER\f[R]+Specify the heading level at which to split the EPUB into separate+\[dq]chapter\[dq] files.+The default is to split into chapters at level-1 headings.+This option only affects the internal composition of the EPUB, not the+way chapters and sections are displayed to users.+Some readers may be slow if the chapter files are too large, so for+large documents with few level-1 headings, one might want to use a+chapter level of 2 or 3.+.TP+\f[B]\f[CB]--epub-subdirectory=\f[B]\f[R]\f[I]DIRNAME\f[R]+Specify the subdirectory in the OCF container that is to hold the+EPUB-specific contents.+The default is \f[C]EPUB\f[R].+To put the EPUB contents in the top level, use an empty string.+.TP+\f[B]\f[CB]--ipynb-output=all|none|best\f[B]\f[R]+Determines how ipynb output cells are treated.+\f[C]all\f[R] means that all of the data formats included in the+original are preserved.+\f[C]none\f[R] means that the contents of data cells are omitted.+\f[C]best\f[R] causes pandoc to try to pick the richest data block in+each output cell that is compatible with the output format.+The default is \f[C]best\f[R].+.TP+\f[B]\f[CB]--pdf-engine=\f[B]\f[R]\f[I]PROGRAM\f[R]+Use the specified engine when producing PDF output.+Valid values are \f[C]pdflatex\f[R], \f[C]lualatex\f[R],+\f[C]xelatex\f[R], \f[C]latexmk\f[R], \f[C]tectonic\f[R],+\f[C]wkhtmltopdf\f[R], \f[C]weasyprint\f[R], \f[C]prince\f[R],+\f[C]context\f[R], and \f[C]pdfroff\f[R].+The default is \f[C]pdflatex\f[R].+If the engine is not in your PATH, the full path of the engine may be+specified here.+.TP+\f[B]\f[CB]--pdf-engine-opt=\f[B]\f[R]\f[I]STRING\f[R]+Use the given string as a command-line argument to the+\f[C]pdf-engine\f[R].+For example, to use a persistent directory \f[C]foo\f[R] for+\f[C]latexmk\f[R]\[aq]s auxiliary files, use+\f[C]--pdf-engine-opt=-outdir=foo\f[R].+Note that no check for duplicate options is done.+.SS Citation rendering+.TP+\f[B]\f[CB]--bibliography=\f[B]\f[R]\f[I]FILE\f[R]+Set the \f[C]bibliography\f[R] field in the document\[aq]s metadata to+\f[I]FILE\f[R], overriding any value set in the metadata, and process+citations using \f[C]pandoc-citeproc\f[R].+(This is equivalent to+\f[C]--metadata bibliography=FILE --filter pandoc-citeproc\f[R].) If+\f[C]--natbib\f[R] or \f[C]--biblatex\f[R] is also supplied,+\f[C]pandoc-citeproc\f[R] is not used, making this equivalent to+\f[C]--metadata bibliography=FILE\f[R].+If you supply this argument multiple times, each \f[I]FILE\f[R] will be+added to bibliography.+.TP+\f[B]\f[CB]--csl=\f[B]\f[R]\f[I]FILE\f[R]+Set the \f[C]csl\f[R] field in the document\[aq]s metadata to+\f[I]FILE\f[R], overriding any value set in the metadata.+(This is equivalent to \f[C]--metadata csl=FILE\f[R].) This option is+only relevant with \f[C]pandoc-citeproc\f[R].+.TP+\f[B]\f[CB]--citation-abbreviations=\f[B]\f[R]\f[I]FILE\f[R]+Set the \f[C]citation-abbreviations\f[R] field in the document\[aq]s+metadata to \f[I]FILE\f[R], overriding any value set in the metadata.+(This is equivalent to+\f[C]--metadata citation-abbreviations=FILE\f[R].) This option is only+relevant with \f[C]pandoc-citeproc\f[R].+.TP+\f[B]\f[CB]--natbib\f[B]\f[R]+Use \f[C]natbib\f[R] for citations in LaTeX output.+This option is not for use with the \f[C]pandoc-citeproc\f[R] filter or+with PDF output.+It is intended for use in producing a LaTeX file that can be processed+with \f[C]bibtex\f[R].+.TP+\f[B]\f[CB]--biblatex\f[B]\f[R]+Use \f[C]biblatex\f[R] for citations in LaTeX output.+This option is not for use with the \f[C]pandoc-citeproc\f[R] filter or+with PDF output.+It is intended for use in producing a LaTeX file that can be processed+with \f[C]bibtex\f[R] or \f[C]biber\f[R].+.SS Math rendering in HTML+.PP+The default is to render TeX math as far as possible using Unicode+characters.+Formulas are put inside a \f[C]span\f[R] with+\f[C]class=\[dq]math\[dq]\f[R], so that they may be styled differently+from the surrounding text if needed.+However, this gives acceptable results only for basic math, usually you+will want to use \f[C]--mathjax\f[R] or another of the following+options.+.TP+\f[B]\f[CB]--mathjax\f[B]\f[R][\f[B]\f[CB]=\f[B]\f[R]\f[I]URL\f[R]]+Use MathJax to display embedded TeX math in HTML output.+TeX math will be put between \f[C]\[rs](...\[rs])\f[R] (for inline math)+or \f[C]\[rs][...\[rs]]\f[R] (for display math) and wrapped in+\f[C]<span>\f[R] tags with class \f[C]math\f[R].+Then the MathJax JavaScript will render it.+The \f[I]URL\f[R] should point to the \f[C]MathJax.js\f[R] load script.+If a \f[I]URL\f[R] is not provided, a link to the Cloudflare CDN will be+inserted.+.TP+\f[B]\f[CB]--mathml\f[B]\f[R]+Convert TeX math to MathML (in \f[C]epub3\f[R], \f[C]docbook4\f[R],+\f[C]docbook5\f[R], \f[C]jats\f[R], \f[C]html4\f[R] and+\f[C]html5\f[R]).+This is the default in \f[C]odt\f[R] output.+Note that currently only Firefox and Safari (and select e-book readers)+natively support MathML.+.TP+\f[B]\f[CB]--webtex\f[B]\f[R][\f[B]\f[CB]=\f[B]\f[R]\f[I]URL\f[R]]+Convert TeX formulas to \f[C]<img>\f[R] tags that link to an external+script that converts formulas to images.+The formula will be URL-encoded and concatenated with the URL provided.+For SVG images you can for example use+\f[C]--webtex https://latex.codecogs.com/svg.latex?\f[R].+If no URL is specified, the CodeCogs URL generating PNGs will be used+(\f[C]https://latex.codecogs.com/png.latex?\f[R]).+Note: the \f[C]--webtex\f[R] option will affect Markdown output as well+as HTML, which is useful if you\[aq]re targeting a version of Markdown+without native math support.+.TP+\f[B]\f[CB]--katex\f[B]\f[R][\f[B]\f[CB]=\f[B]\f[R]\f[I]URL\f[R]]+Use KaTeX to display embedded TeX math in HTML output.+The \f[I]URL\f[R] is the base URL for the KaTeX library.+That directory should contain a \f[C]katex.min.js\f[R] and a+\f[C]katex.min.css\f[R] file.+If a \f[I]URL\f[R] is not provided, a link to the KaTeX CDN will be+inserted.+.TP+\f[B]\f[CB]--gladtex\f[B]\f[R]+Enclose TeX math in \f[C]<eq>\f[R] tags in HTML output.+The resulting HTML can then be processed by GladTeX to produce images of+the typeset formulas and an HTML file with links to these images.+So, the procedure is:+.RS+.IP+.nf+\f[C]+pandoc -s --gladtex input.md -o myfile.htex+gladtex -d myfile-images myfile.htex+# produces myfile.html and images in myfile-images+\f[R]+.fi+.RE+.SS Options for wrapper scripts+.TP+\f[B]\f[CB]--dump-args\f[B]\f[R]+Print information about command-line arguments to \f[I]stdout\f[R], 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[R] option, or \f[C]-\f[R] (for \f[I]stdout\f[R]) 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[R] separator at the end+of the line.+.TP+\f[B]\f[CB]--ignore-args\f[B]\f[R]+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[R]+.fi+.PP+is equivalent to+.IP+.nf+\f[C]+pandoc -o foo.html -s+\f[R]+.fi+.RE+.SH EXIT CODES+.PP+If pandoc completes successfully, it will return exit code 0.+Nonzero exit codes have the following meanings:+.PP+.TS+tab(@);+r l.+T{+Code+T}@T{+Error+T}+_+T{+3+T}@T{+PandocFailOnWarningError+T}+T{+4+T}@T{+PandocAppError+T}+T{+5+T}@T{+PandocTemplateError+T}+T{+6+T}@T{+PandocOptionError+T}+T{+21+T}@T{+PandocUnknownReaderError+T}+T{+22+T}@T{+PandocUnknownWriterError+T}+T{+23+T}@T{+PandocUnsupportedExtensionError+T}+T{+31+T}@T{+PandocEpubSubdirectoryError+T}+T{+43+T}@T{+PandocPDFError+T}+T{+47+T}@T{+PandocPDFProgramNotFoundError+T}+T{+61+T}@T{+PandocHttpError+T}+T{+62+T}@T{+PandocShouldNeverHappenError+T}+T{+63+T}@T{+PandocSomeError+T}+T{+64+T}@T{+PandocParseError+T}+T{+65+T}@T{+PandocParsecError+T}+T{+66+T}@T{+PandocMakePDFError+T}+T{+67+T}@T{+PandocSyntaxMapError+T}+T{+83+T}@T{+PandocFilterError+T}+T{+91+T}@T{+PandocMacroLoop+T}+T{+92+T}@T{+PandocUTF8DecodingError+T}+T{+93+T}@T{+PandocIpynbDecodingError+T}+T{+97+T}@T{+PandocCouldNotFindDataFileError+T}+T{+99+T}@T{+PandocResourceNotFound+T}+.TE+.SH DEFAULT FILES+.PP+The \f[C]--defaults\f[R] option may be used to specify a package of+options.+Here is a sample defaults file demonstrating all of the fields that may+be used:+.IP+.nf+\f[C]+from: markdown+emoji+# reader: may be used instead of from:+to: html5+# writer: may be used instead of to:++# leave blank for output to stdout:+output-file:+# leave blank for input from stdin, use [] for no input:+input-files:+- preface.md+- content.md+# or you may use input-file: with a single value++template: letter+standalone: true+self-contained: false++# note that structured variables may be specified:+variables:+  documentclass: book+  classoption:+    - twosides+    - draft++# metadata values specified here are parsed as literal+# string text, not markdown:+metadata:+  author:+  - Sam Smith+  - Julie Liu+metadata-files:+- boilerplate.yaml+# or you may use metadata-file: with a single value++# Note that these take files, not their contents:+include-before-body: []+include-after-body: []+include-in-header: []+resource-path: [\[dq].\[dq]]++# filters will be assumed to be lua filters if they have+# the .lua extension, and json filters otherwise.  But+# the filter type can also be specified explicitly, as shown:+filters:+- pandoc-citeproc+- wordcount.lua+- type: json+  path: foo.lua++file-scope: false++data-dir:++# ERROR, WARNING, or INFO+verbosity: INFO+log-file: log.json++# citeproc, natbib, or biblatex+cite-method: citeproc+# part, chapter, section, or default:+top-level-division: chapter+abbreviations:++pdf-engine: pdflatex+pdf-engine-opts:+- \[dq]-shell-escape\[dq]+# you may also use pdf-engine-opt: with a single option+# pdf-engine-opt: \[dq]-shell-escape\[dq]++# auto, preserve, or none+wrap: auto+columns: 78+dpi: 72++extract-media: mediadir++table-of-contents: true+toc-depth: 2+number-sections: false+# a list of offsets at each heading level+number-offset: [0,0,0,0,0,0]+# toc: may also be used instead of table-of-contents:+shift-heading-level-by: 1+section-divs: true+identifier-prefix: foo+title-prefix: \[dq]\[dq]+strip-empty-paragraphs: true+# lf, crlf, or native+eol: lf+strip-comments: false+indented-code-classes: []+ascii: true+default-image-extension: \[dq].jpg\[dq]++# either a style name of a style definition file:+highlight-style: pygments+syntax-definitions:+- c.xml+# or you may use syntax-definition: with a single value+listings: false++reference-doc: myref.docx++# method is plain, webtex, gladtex, mathml, mathjax, katex+# you may specify a url with webtex, mathjax, katex+html-math-method:+  method: mathjax+  url: \[dq]https://cdn.jsdelivr.net/npm/mathjax\[at]3/es5/tex-mml-chtml.js\[dq]+# none, references, or javascript+email-obfuscation: javascript++tab-stop: 8+preserve-tabs: true++incremental: false+slide-level: 2++epub-subdirectory: EPUB+epub-metadata: meta.xml+epub-fonts:+- foobar.otf+epub-chapter-level: 1+epub-cover-image: cover.jpg++reference-links: true+# block, section, or document+reference-location: block+atx-headers: false++# accept, reject, or all+track-changes: accept++html-q-tags: false+css:+- site.css++# none, all, or best+ipynb-output: best++# A list of two-element lists+request-headers:+- [\[dq]User-Agent\[dq], \[dq]Mozilla/5.0\[dq]]++fail-if-warnings: false+dump-args: false+ignore-args: false+trace: false+\f[R]+.fi+.PP+Fields that are omitted will just have their regular default values.+So a defaults file can be as simple as one line:+.IP+.nf+\f[C]+verbosity: INFO+\f[R]+.fi+.PP+Default files can be placed in the \f[C]defaults\f[R] subdirectory of+the user data directory and used from any directory.+For example, one could create a file specifying defaults for writing+letters, save it as \f[C]letter.yaml\f[R] in the \f[C]defaults\f[R]+subdirectory of the user data directory, and then invoke these defaults+from any directory using \f[C]pandoc --defaults letter\f[R] or+\f[C]pandoc -dletter\f[R].+.PP+When multiple defaults are used, their contents will be combined.+.PP+Note that, where command-line arguments may be repeated+(\f[C]--metadata-file\f[R], \f[C]--css\f[R],+\f[C]--include-in-header\f[R], \f[C]--include-before-body\f[R],+\f[C]--include-after-body\f[R], \f[C]--variable\f[R],+\f[C]--metadata\f[R], \f[C]--syntax-definition\f[R]), the values+specified on the command line will combine with values specified in the+defaults file, rather than replacing them.+.SH TEMPLATES+.PP+When the \f[C]-s/--standalone\f[R] 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[R]+.fi+.PP+where \f[I]FORMAT\f[R] is the name of the output format.+A custom template can be specified using the \f[C]--template\f[R]+option.+You can also override the system default templates for a given output+format \f[I]FORMAT\f[R] by putting a file+\f[C]templates/default.*FORMAT*\f[R] in the user data directory (see+\f[C]--data-dir\f[R], above).+\f[I]Exceptions:\f[R]+.IP \[bu] 2+For \f[C]odt\f[R] output, customize the \f[C]default.opendocument\f[R]+template.+.IP \[bu] 2+For \f[C]pdf\f[R] output, customize the \f[C]default.latex\f[R] template+(or the \f[C]default.context\f[R] template, if you use+\f[C]-t context\f[R], or the \f[C]default.ms\f[R] template, if you use+\f[C]-t ms\f[R], or the \f[C]default.html\f[R] template, if you use+\f[C]-t html\f[R]).+.IP \[bu] 2+\f[C]docx\f[R] and \f[C]pptx\f[R] have no template (however, you can use+\f[C]--reference-doc\f[R] to customize the output).+.PP+Templates contain \f[I]variables\f[R], which allow for the inclusion of+arbitrary information at any point in the file.+They may be set at the command line using the \f[C]-V/--variable\f[R]+option.+If a variable is not set, pandoc will look for the key in the+document\[aq]s metadata, which can be set using either YAML metadata+blocks or with the \f[C]-M/--metadata\f[R] option.+In addition, some variables are given default values by pandoc.+See Variables below for a list of variables used in pandoc\[aq]s default+templates.+.PP+If you use custom templates, you may need to revise them as pandoc+changes.+We recommend tracking the changes in the default templates, and+modifying your custom templates accordingly.+An easy way to do this is to fork the pandoc-templates repository and+merge in changes after each pandoc release.+.SS Template syntax+.SS Comments+.PP+Anything between the sequence \f[C]$--\f[R] and the end of the line will+be treated as a comment and omitted from the output.+.SS Delimiters+.PP+To mark variables and control structures in the template, either+\f[C]$\f[R]...\f[C]$\f[R] or \f[C]${\f[R]...\f[C]}\f[R] may be used as+delimiters.+The styles may also be mixed in the same template, but the opening and+closing delimiter must match in each case.+The opening delimiter may be followed by one or more spaces or tabs,+which will be ignored.+The closing delimiter may be followed by one or more spaces or tabs,+which will be ignored.+.PP+To include a literal \f[C]$\f[R] in the document, use \f[C]$$\f[R].+.SS Interpolated variables+.PP+A slot for an interpolated variable is a variable name surrounded by+matched delimiters.+Variable names must begin with a letter and can contain letters,+numbers, \f[C]_\f[R], \f[C]-\f[R], and \f[C].\f[R].+The keywords \f[C]it\f[R], \f[C]if\f[R], \f[C]else\f[R],+\f[C]endif\f[R], \f[C]for\f[R], \f[C]sep\f[R], and \f[C]endfor\f[R] may+not be used as variable names.+Examples:+.IP+.nf+\f[C]+$foo$+$foo.bar.baz$+$foo_bar.baz-bim$+$ foo $+${foo}+${foo.bar.baz}+${foo_bar.baz-bim}+${ foo }+\f[R]+.fi+.PP+Variable names with periods are used to get at structured variable+values.+So, for example, \f[C]employee.salary\f[R] will return the value of the+\f[C]salary\f[R] field of the object that is the value of the+\f[C]employee\f[R] field.+.IP \[bu] 2+If the value of the variable is simple value, it will be rendered+verbatim.+(Note that no escaping is done; the assumption is that the calling+program will escape the strings appropriately for the output format.)+.IP \[bu] 2+If the value is a list, the values will be concatenated.+.IP \[bu] 2+If the value is a map, the string \f[C]true\f[R] will be rendered.+.IP \[bu] 2+Every other value will be rendered as the empty string.+.SS Conditionals+.PP+A conditional begins with \f[C]if(variable)\f[R] (enclosed in matched+delimiters) and ends with \f[C]endif\f[R] (enclosed in matched+delimiters).+It may optionally contain an \f[C]else\f[R] (enclosed in matched+delimiters).+The \f[C]if\f[R] section is used if \f[C]variable\f[R] has a non-empty+value, otherwise the \f[C]else\f[R] section is used (if present).+Examples:+.IP+.nf+\f[C]+$if(foo)$bar$endif$++$if(foo)$+  $foo$+$endif$++$if(foo)$+part one+$else$+part two+$endif$++${if(foo)}bar${endif}++${if(foo)}+  ${foo}+${endif}++${if(foo)}+${ foo.bar }+${else}+no foo!+${endif}+\f[R]+.fi+.PP+The keyword \f[C]elseif\f[R] may be used to simplify complex nested+conditionals:+.IP+.nf+\f[C]+$if(foo)$+XXX+$elseif(bar)$+YYY+$else$+ZZZ+$endif$+\f[R]+.fi+.SS For loops+.PP+A for loop begins with \f[C]for(variable)\f[R] (enclosed in matched+delimiters) and ends with \f[C]endfor\f[R] (enclosed in matched+delimiters.+.IP \[bu] 2+If \f[C]variable\f[R] is an array, the material inside the loop will be+evaluated repeatedly, with \f[C]variable\f[R] being set to each value of+the array in turn, and concatenated.+.IP \[bu] 2+If the value of the associated variable is not an array or a map, a+single iteration will be performed on its value.+.PP+Examples:+.IP+.nf+\f[C]+$for(foo)$$foo$$sep$, $endfor$++$for(foo)$+  - $foo.last$, $foo.first$+$endfor$++${ for(foo.bar) }+  - ${ foo.bar.last }, ${ foo.bar.first }+${ endfor }+\f[R]+.fi+.PP+You may optionally specify a separator between consecutive values using+\f[C]sep\f[R] (enclosed in matched delimiters).+The material between \f[C]sep\f[R] and the \f[C]endfor\f[R] is the+separator.+.IP+.nf+\f[C]+${ for(foo) }${ foo }${ sep }, ${ endfor }+\f[R]+.fi+.PP+Instead of using \f[C]variable\f[R] inside the loop, the special+anaphoric keyword \f[C]it\f[R] may be used.+.IP+.nf+\f[C]+${ for(foo.bar) }+  - ${ it.last }, ${ it.first }+${ endfor }+\f[R]+.fi+.SS Partials+.PP+Partials (subtemplates stored in different files) may be included using+the syntax+.IP+.nf+\f[C]+${ boilerplate() }+\f[R]+.fi+.PP+Partials will be sought in the directory containing the main template,+and will be assumed to have the same extension as the main template if+they lack an explicit extension.+(If the partials are not found here, they will also be sought in the+\f[C]templates\f[R] subdirectory of the user data directory.)+.PP+Partials may optionally be applied to variables using a colon:+.IP+.nf+\f[C]+${ date:fancy() }++${ articles:bibentry() }+\f[R]+.fi+.PP+If \f[C]articles\f[R] is an array, this will iterate over its values,+applying the partial \f[C]bibentry()\f[R] to each one.+So the second example above is equivalent to+.IP+.nf+\f[C]+${ for(articles) }+${ it:bibentry() }+${ endfor }+\f[R]+.fi+.PP+Note that the anaphoric keyword \f[C]it\f[R] must be used when iterating+over partials.+In the above examples, the \f[C]bibentry\f[R] partial should contain+\f[C]it.title\f[R] (and so on) instead of \f[C]articles.title\f[R].+.PP+Final newlines are omitted from included partials.+.PP+Partials may include other partials.+.PP+A separator between values of an array may be specified in square+brackets, immediately after the variable name or partial:+.IP+.nf+\f[C]+${months[, ]}$++${articles:bibentry()[; ]$+\f[R]+.fi+.PP+The separator in this case is literal and (unlike with \f[C]sep\f[R] in+an explicit \f[C]for\f[R] loop) cannot contain interpolated variables or+other template directives.+.SS Nesting+.PP+To ensure that content is \[dq]nested,\[dq] that is, subsequent lines+indented, use the \f[C]\[ha]\f[R] directive:+.IP+.nf+\f[C]+$item.number$  $\[ha]$$item.description$ ($item.price$)+\f[R]+.fi+.PP+In this example, if \f[C]item.description\f[R] has multiple lines, they+will all be indented to line up with the first line:+.IP+.nf+\f[C]+00123  A fine bottle of 18-year old+       Oban whiskey. ($148)+\f[R]+.fi+.PP+To nest multiple lines to the same level, align them with the+\f[C]\[ha]\f[R] directive in the template.+For example:+.IP+.nf+\f[C]+$item.number$  $\[ha]$$item.description$ ($item.price$)+               (Available til $item.sellby$.)+\f[R]+.fi+.PP+will produce+.IP+.nf+\f[C]+00123  A fine bottle of 18-year old+       Oban whiskey. ($148)+       (Available til March 30, 2020.)+\f[R]+.fi+.PP+If a variable occurs by itself on a line, preceded by whitespace and not+followed by further text or directives on the same line, and the+variable\[aq]s value contains multiple lines, it will be nested+automatically.+.SS Breakable spaces+.PP+Normally, spaces in the template itself (as opposed to values of the+interpolated variables) are not breakable, but they can be made+breakable in part of the template by using the \f[C]\[ti]\f[R] keyword+(ended with another \f[C]\[ti]\f[R]).+.IP+.nf+\f[C]+$\[ti]$This long line may break if the document is rendered+with a short line length.$\[ti]$+\f[R]+.fi+.SS Filters+.PP+A filter transforms the value of a variable or partial.+Filters are specified using a slash (\f[C]/\f[R]) between the variable+name (or partial) and the filter name.+Example:+.IP+.nf+\f[C]+$for(name)$+$name/uppercase$+$endfor$++$for(metadata/pairs)$+- $it.key$: $it.value$+$endfor$++$employee:name()/uppercase$+\f[R]+.fi+.PP+Filters may be chained:+.IP+.nf+\f[C]+$for(employees/pairs)$+$it.key/alpha/uppercase$. $it.name$+$endfor$+\f[R]+.fi+.PP+Some filters take parameters:+.IP+.nf+\f[C]+|----------------------|------------|+$for(employee)$+$it.name.first/uppercase/left 20 \[dq]| \[dq]$$it.name.salary/right 10 \[dq] | \[dq] \[dq] |\[dq]$+$endfor$+|----------------------|------------|+\f[R]+.fi+.PP+Currently the following filters are predefined:+.IP \[bu] 2+\f[C]pairs\f[R]: Converts a map or array to an array of maps, each with+\f[C]key\f[R] and \f[C]value\f[R] fields.+If the original value was an array, the \f[C]key\f[R] will be the array+index, starting with 1.+.IP \[bu] 2+\f[C]uppercase\f[R]: Converts a textual value to uppercase, and has no+effect on other values.+.IP \[bu] 2+\f[C]lowercase\f[R]: Converts a textual value to lowercase, and has no+effect on other values.+.IP \[bu] 2+\f[C]length\f[R]: Returns the length of the value: number of characters+for a textual value, number of elements for a map or array.+.IP \[bu] 2+\f[C]reverse\f[R]: Reverses a textual value or array, and has no effect+on other values.+.IP \[bu] 2+\f[C]chomp\f[R]: Removes trailing newlines (and breakable space) from a+textual value, and has no effect on other values.+.IP \[bu] 2+\f[C]alpha\f[R]: Converts a textual value that can be read as an integer+into a lowercase alphabetic character \f[C]a..z\f[R] (mod 26), and has+no effect on other values.+This can be used to get lettered enumeration from array indices.+To get uppercase letters, chain with \f[C]uppercase\f[R].+.IP \[bu] 2+\f[C]roman\f[R]: Converts a textual value that can be read as an integer+into a lowercase roman numerial, and has no effect on other values.+This can be used to get lettered enumeration from array indices.+To get uppercase roman, chain with \f[C]uppercase\f[R].+.IP \[bu] 2+\f[C]left n \[dq]leftborder\[dq] \[dq]rightborder\[dq]\f[R]: Renders a+textual value in a block of width \f[C]n\f[R], aligned to the left, with+an optional left and right border.+Has no effect on other values.+This can be used to align material in tables.+Widths are positive integers indicating the number of characters.+Borders are strings inside double quotes; literal \f[C]\[dq]\f[R] and+\f[C]\[rs]\f[R] characters must be backslash-escaped.+.IP \[bu] 2+\f[C]right n \[dq]leftborder\[dq] \[dq]rightborder\[dq]\f[R]: Renders a+textual value in a block of width \f[C]n\f[R], aligned to the right, and+has no effect on other values.+.IP \[bu] 2+\f[C]center n \[dq]leftborder\[dq] \[dq]rightborder\[dq]\f[R]: Renders a+textual value in a block of width \f[C]n\f[R], aligned to the center,+and has no effect on other values.+.SS Variables+.SS Metadata variables+.TP+\f[B]\f[CB]title\f[B]\f[R], \f[B]\f[CB]author\f[B]\f[R], \f[B]\f[CB]date\f[B]\f[R]+allow identification of basic aspects of the document.+Included in PDF metadata through LaTeX and ConTeXt.+These can be set through a pandoc title block, which allows for multiple+authors, or through a YAML metadata block:+.RS+.IP+.nf+\f[C]+---+author:+- Aristotle+- Peter Abelard+\&...+\f[R]+.fi+.PP+Note that if you just want to set PDF or HTML metadata, without+including a title block in the document itself, you can set the+\f[C]title-meta\f[R], \f[C]author-meta\f[R], and \f[C]date-meta\f[R]+variables.+(By default these are set automatically, based on \f[C]title\f[R],+\f[C]author\f[R], and \f[C]date\f[R].)+.RE+.TP+\f[B]\f[CB]subtitle\f[B]\f[R]+document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx+documents+.TP+\f[B]\f[CB]abstract\f[B]\f[R]+document summary, included in LaTeX, ConTeXt, AsciiDoc, and docx+documents+.TP+\f[B]\f[CB]keywords\f[B]\f[R]+list of keywords to be included in HTML, PDF, ODT, pptx, docx and+AsciiDoc metadata; repeat as for \f[C]author\f[R], above+.TP+\f[B]\f[CB]subject\f[B]\f[R]+document subject, included in ODT, PDF, docx and pptx metadata+.TP+\f[B]\f[CB]description\f[B]\f[R]+document description, included in ODT, docx and pptx metadata.+Some applications show this as \f[C]Comments\f[R] metadata.+.TP+\f[B]\f[CB]category\f[B]\f[R]+document category, included in docx and pptx metadata+.PP+Additionally, any root-level string metadata, not included in ODT, docx+or pptx metadata is added as a \f[I]custom property\f[R].+The following YAML metadata block for instance:+.IP+.nf+\f[C]+---+title:  \[aq]This is the title\[aq]+subtitle: \[dq]This is the subtitle\[dq]+author:+- Author One+- Author Two+description: |+    This is a long+    description.++    It consists of two paragraphs+\&...+\f[R]+.fi+.PP+will include \f[C]title\f[R], \f[C]author\f[R] and \f[C]description\f[R]+as standard document properties and \f[C]subtitle\f[R] as a custom+property when converting to docx, ODT or pptx.+.SS Language variables+.TP+\f[B]\f[CB]lang\f[B]\f[R]+identifies the main language of the document using IETF language tags+(following the BCP 47 standard), such as \f[C]en\f[R] or+\f[C]en-GB\f[R].+The Language subtag lookup tool can look up or verify these tags.+This affects most formats, and controls hyphenation in PDF output when+using LaTeX (through \f[C]babel\f[R] and \f[C]polyglossia\f[R]) or+ConTeXt.+.RS+.PP+Use native pandoc Divs and Spans with the \f[C]lang\f[R] attribute to+switch the language:+.IP+.nf+\f[C]+---+lang: en-GB+\&...++Text in the main document language (British English).++::: {lang=fr-CA}+> Cette citation est \['e]crite en fran\[,c]ais canadien.+:::++More text in English. [\[aq]Zitat auf Deutsch.\[aq]]{lang=de}+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]dir\f[B]\f[R]+the base script direction, either \f[C]rtl\f[R] (right-to-left) or+\f[C]ltr\f[R] (left-to-right).+.RS+.PP+For bidirectional documents, native pandoc \f[C]span\f[R]s and+\f[C]div\f[R]s with the \f[C]dir\f[R] attribute (value \f[C]rtl\f[R] or+\f[C]ltr\f[R]) can be used to override the base direction in some output+formats.+This may not always be necessary if the final renderer (e.g.+the browser, when generating HTML) supports the Unicode Bidirectional+Algorithm.+.PP+When using LaTeX for bidirectional documents, only the \f[C]xelatex\f[R]+engine is fully supported (use \f[C]--pdf-engine=xelatex\f[R]).+.RE+.SS Variables for HTML math+.TP+\f[B]\f[CB]classoption\f[B]\f[R]+when using KaTeX, you can render display math equations flush left using+YAML metadata or with \f[C]-M classoption=fleqn\f[R].+.SS Variables for HTML slides+.PP+These affect HTML output when producing slide shows with pandoc.+.PP+All reveal.js configuration options are available as variables.+To turn off boolean flags that default to true in reveal.js, use+\f[C]0\f[R].+.TP+\f[B]\f[CB]revealjs-url\f[B]\f[R]+base URL for reveal.js documents (defaults to \f[C]reveal.js\f[R])+.TP+\f[B]\f[CB]s5-url\f[B]\f[R]+base URL for S5 documents (defaults to \f[C]s5/default\f[R])+.TP+\f[B]\f[CB]slidy-url\f[B]\f[R]+base URL for Slidy documents (defaults to+\f[C]https://www.w3.org/Talks/Tools/Slidy2\f[R])+.TP+\f[B]\f[CB]slideous-url\f[B]\f[R]+base URL for Slideous documents (defaults to \f[C]slideous\f[R])+.SS Variables for Beamer slides+.PP+These variables change the appearance of PDF slides using+\f[C]beamer\f[R].+.TP+\f[B]\f[CB]aspectratio\f[B]\f[R]+slide aspect ratio (\f[C]43\f[R] for 4:3 [default], \f[C]169\f[R] for+16:9, \f[C]1610\f[R] for 16:10, \f[C]149\f[R] for 14:9, \f[C]141\f[R]+for 1.41:1, \f[C]54\f[R] for 5:4, \f[C]32\f[R] for 3:2)+.TP+\f[B]\f[CB]beamerarticle\f[B]\f[R]+produce an article from Beamer slides+.TP+\f[B]\f[CB]beameroption\f[B]\f[R]+add extra beamer option with \f[C]\[rs]setbeameroption{}\f[R]+.TP+\f[B]\f[CB]institute\f[B]\f[R]+author affiliations: can be a list when there are multiple authors+.TP+\f[B]\f[CB]logo\f[B]\f[R]+logo image for slides+.TP+\f[B]\f[CB]navigation\f[B]\f[R]+controls navigation symbols (default is \f[C]empty\f[R] for no+navigation symbols; other valid values are \f[C]frame\f[R],+\f[C]vertical\f[R], and \f[C]horizontal\f[R])+.TP+\f[B]\f[CB]section-titles\f[B]\f[R]+enables \[dq]title pages\[dq] for new sections (default is true)+.TP+\f[B]\f[CB]theme\f[B]\f[R], \f[B]\f[CB]colortheme\f[B]\f[R], \f[B]\f[CB]fonttheme\f[B]\f[R], \f[B]\f[CB]innertheme\f[B]\f[R], \f[B]\f[CB]outertheme\f[B]\f[R]+beamer themes+.TP+\f[B]\f[CB]themeoptions\f[B]\f[R]+options for LaTeX beamer themes (a list).+.TP+\f[B]\f[CB]titlegraphic\f[B]\f[R]+image for title slide+.SS Variables for PowerPoint+.PP+These variables control the visual aspects of a slide show that are not+easily controlled via templates.+.TP+\f[B]\f[CB]monofont\f[B]\f[R]+font to use for code.+.SS Variables for LaTeX+.PP+Pandoc uses these variables when creating a PDF with a LaTeX engine.+.SS Layout+.TP+\f[B]\f[CB]block-headings\f[B]\f[R]+make \f[C]\[rs]paragraph\f[R] and \f[C]\[rs]subparagraph\f[R] (fourth-+and fifth-level headings, or fifth- and sixth-level with book classes)+free-standing rather than run-in; requires further formatting to+distinguish from \f[C]\[rs]subsubsection\f[R] (third- or fourth-level+headings).+Instead of using this option, KOMA-Script can adjust headings more+extensively:+.RS+.IP+.nf+\f[C]+---+documentclass: scrartcl+header-includes: |+  \[rs]RedeclareSectionCommand[+    beforeskip=-10pt plus -2pt minus -1pt,+    afterskip=1sp plus -1sp minus 1sp,+    font=\[rs]normalfont\[rs]itshape]{paragraph}+  \[rs]RedeclareSectionCommand[+    beforeskip=-10pt plus -2pt minus -1pt,+    afterskip=1sp plus -1sp minus 1sp,+    font=\[rs]normalfont\[rs]scshape,+    indent=0pt]{subparagraph}+\&...+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]classoption\f[B]\f[R]+option for document class, e.g.+\f[C]oneside\f[R]; repeat for multiple options:+.RS+.IP+.nf+\f[C]+---+classoption:+- twocolumn+- landscape+\&...+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]documentclass\f[B]\f[R]+document class: usually one of the standard classes, \f[C]article\f[R],+\f[C]book\f[R], and \f[C]report\f[R]; the KOMA-Script equivalents,+\f[C]scrartcl\f[R], \f[C]scrbook\f[R], and \f[C]scrreprt\f[R], which+default to smaller margins; or \f[C]memoir\f[R]+.TP+\f[B]\f[CB]geometry\f[B]\f[R]+option for \f[C]geometry\f[R] package, e.g.+\f[C]margin=1in\f[R]; repeat for multiple options:+.RS+.IP+.nf+\f[C]+---+geometry:+- top=30mm+- left=20mm+- heightrounded+\&...+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]hyperrefoptions\f[B]\f[R]+option for \f[C]hyperref\f[R] package, e.g.+\f[C]linktoc=all\f[R]; repeat for multiple options:+.RS+.IP+.nf+\f[C]+---+hyperrefoptions:+- linktoc=all+- pdfwindowui+- pdfpagemode=FullScreen+\&...+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]indent\f[B]\f[R]+uses document class settings for indentation (the default LaTeX template+otherwise removes indentation and adds space between paragraphs)+.TP+\f[B]\f[CB]linestretch\f[B]\f[R]+adjusts line spacing using the \f[C]setspace\f[R] package, e.g.+\f[C]1.25\f[R], \f[C]1.5\f[R]+.TP+\f[B]\f[CB]margin-left\f[B]\f[R], \f[B]\f[CB]margin-right\f[B]\f[R], \f[B]\f[CB]margin-top\f[B]\f[R], \f[B]\f[CB]margin-bottom\f[B]\f[R]+sets margins if \f[C]geometry\f[R] is not used (otherwise+\f[C]geometry\f[R] overrides these)+.TP+\f[B]\f[CB]pagestyle\f[B]\f[R]+control \f[C]\[rs]pagestyle{}\f[R]: the default article class supports+\f[C]plain\f[R] (default), \f[C]empty\f[R] (no running heads or page+numbers), and \f[C]headings\f[R] (section titles in running heads)+.TP+\f[B]\f[CB]papersize\f[B]\f[R]+paper size, e.g.+\f[C]letter\f[R], \f[C]a4\f[R]+.TP+\f[B]\f[CB]secnumdepth\f[B]\f[R]+numbering depth for sections (with \f[C]--number-sections\f[R] option or+\f[C]numbersections\f[R] variable)+.SS Fonts+.TP+\f[B]\f[CB]fontenc\f[B]\f[R]+allows font encoding to be specified through \f[C]fontenc\f[R] package+(with \f[C]pdflatex\f[R]); default is \f[C]T1\f[R] (see LaTeX font+encodings guide)+.TP+\f[B]\f[CB]fontfamily\f[B]\f[R]+font package for use with \f[C]pdflatex\f[R]: TeX Live includes many+options, documented in the LaTeX Font Catalogue.+The default is Latin Modern.+.TP+\f[B]\f[CB]fontfamilyoptions\f[B]\f[R]+options for package used as \f[C]fontfamily\f[R]; repeat for multiple+options.+For example, to use the Libertine font with proportional lowercase+(old-style) figures through the \f[C]libertinus\f[R] package:+.RS+.IP+.nf+\f[C]+---+fontfamily: libertinus+fontfamilyoptions:+- osf+- p+\&...+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]fontsize\f[B]\f[R]+font size for body text.+The standard classes allow 10pt, 11pt, and 12pt.+To use another size, set \f[C]documentclass\f[R] to one of the+KOMA-Script classes, such as \f[C]scrartcl\f[R] or \f[C]scrbook\f[R].+.TP+\f[B]\f[CB]mainfont\f[B]\f[R], \f[B]\f[CB]sansfont\f[B]\f[R], \f[B]\f[CB]monofont\f[B]\f[R], \f[B]\f[CB]mathfont\f[B]\f[R], \f[B]\f[CB]CJKmainfont\f[B]\f[R]+font families for use with \f[C]xelatex\f[R] or \f[C]lualatex\f[R]: take+the name of any system font, using the \f[C]fontspec\f[R] package.+\f[C]CJKmainfont\f[R] uses the \f[C]xecjk\f[R] package.+.TP+\f[B]\f[CB]mainfontoptions\f[B]\f[R], \f[B]\f[CB]sansfontoptions\f[B]\f[R], \f[B]\f[CB]monofontoptions\f[B]\f[R], \f[B]\f[CB]mathfontoptions\f[B]\f[R], \f[B]\f[CB]CJKoptions\f[B]\f[R]+options to use with \f[C]mainfont\f[R], \f[C]sansfont\f[R],+\f[C]monofont\f[R], \f[C]mathfont\f[R], \f[C]CJKmainfont\f[R] in+\f[C]xelatex\f[R] and \f[C]lualatex\f[R].+Allow for any choices available through \f[C]fontspec\f[R]; repeat for+multiple options.+For example, to use the TeX Gyre version of Palatino with lowercase+figures:+.RS+.IP+.nf+\f[C]+---+mainfont: TeX Gyre Pagella+mainfontoptions:+- Numbers=Lowercase+- Numbers=Proportional+\&...+\f[R]+.fi+.RE+.TP+\f[B]\f[CB]microtypeoptions\f[B]\f[R]+options to pass to the microtype package+.SS Links+.TP+\f[B]\f[CB]colorlinks\f[B]\f[R]+add color to link text; automatically enabled if any of+\f[C]linkcolor\f[R], \f[C]filecolor\f[R], \f[C]citecolor\f[R],+\f[C]urlcolor\f[R], or \f[C]toccolor\f[R] are set+.TP+\f[B]\f[CB]linkcolor\f[B]\f[R], \f[B]\f[CB]filecolor\f[B]\f[R], \f[B]\f[CB]citecolor\f[B]\f[R], \f[B]\f[CB]urlcolor\f[B]\f[R], \f[B]\f[CB]toccolor\f[B]\f[R]+color for internal links, external links, citation links, linked URLs,+and links in table of contents, respectively: uses options allowed by+\f[C]xcolor\f[R], including the \f[C]dvipsnames\f[R],+\f[C]svgnames\f[R], and \f[C]x11names\f[R] lists+.TP+\f[B]\f[CB]links-as-notes\f[B]\f[R]+causes links to be printed as footnotes+.SS Front matter+.TP+\f[B]\f[CB]lof\f[B]\f[R], \f[B]\f[CB]lot\f[B]\f[R]+include list of figures, list of tables+.TP+\f[B]\f[CB]thanks\f[B]\f[R]+contents of acknowledgments footnote after document title+.TP+\f[B]\f[CB]toc\f[B]\f[R]+include table of contents (can also be set using+\f[C]--toc/--table-of-contents\f[R])+.TP+\f[B]\f[CB]toc-depth\f[B]\f[R]+level of section to include in table of contents+.SS BibLaTeX Bibliographies+.PP+These variables function when using BibLaTeX for citation rendering.+.TP+\f[B]\f[CB]biblatexoptions\f[B]\f[R]+list of options for biblatex+.TP+\f[B]\f[CB]biblio-style\f[B]\f[R]+bibliography style, when used with \f[C]--natbib\f[R] and+\f[C]--biblatex\f[R].+.TP+\f[B]\f[CB]biblio-title\f[B]\f[R]+bibliography title, when used with \f[C]--natbib\f[R] and+\f[C]--biblatex\f[R].+.TP+\f[B]\f[CB]bibliography\f[B]\f[R]+bibliography to use for resolving references+.TP+\f[B]\f[CB]natbiboptions\f[B]\f[R]+list of options for natbib+.SS Variables for ConTeXt+.PP+Pandoc uses these variables when creating a PDF with ConTeXt.+.TP+\f[B]\f[CB]fontsize\f[B]\f[R]+font size for body text (e.g.+\f[C]10pt\f[R], \f[C]12pt\f[R])+.TP+\f[B]\f[CB]headertext\f[B]\f[R], \f[B]\f[CB]footertext\f[B]\f[R]+text to be placed in running header or footer (see ConTeXt Headers and+Footers); repeat up to four times for different placement+.TP+\f[B]\f[CB]indenting\f[B]\f[R]+controls indentation of paragraphs, e.g.+\f[C]yes,small,next\f[R] (see ConTeXt Indentation); repeat for multiple+options+.TP+\f[B]\f[CB]interlinespace\f[B]\f[R]+adjusts line spacing, e.g.+\f[C]4ex\f[R] (using \f[C]setupinterlinespace\f[R]); repeat for multiple+options+.TP+\f[B]\f[CB]layout\f[B]\f[R]+options for page margins and text arrangement (see ConTeXt Layout);+repeat for multiple options+.TP+\f[B]\f[CB]linkcolor\f[B]\f[R], \f[B]\f[CB]contrastcolor\f[B]\f[R]+color for links outside and inside a page, e.g.+\f[C]red\f[R], \f[C]blue\f[R] (see ConTeXt Color)+.TP+\f[B]\f[CB]linkstyle\f[B]\f[R]+typeface style for links, e.g.+\f[C]normal\f[R], \f[C]bold\f[R], \f[C]slanted\f[R],+\f[C]boldslanted\f[R], \f[C]type\f[R], \f[C]cap\f[R], \f[C]small\f[R]+.TP+\f[B]\f[CB]lof\f[B]\f[R], \f[B]\f[CB]lot\f[B]\f[R]+include list of figures, list of tables+.TP+\f[B]\f[CB]mainfont\f[B]\f[R], \f[B]\f[CB]sansfont\f[B]\f[R], \f[B]\f[CB]monofont\f[B]\f[R], \f[B]\f[CB]mathfont\f[B]\f[R]+font families: take the name of any system font (see ConTeXt Font+Switching)+.TP+\f[B]\f[CB]margin-left\f[B]\f[R], \f[B]\f[CB]margin-right\f[B]\f[R], \f[B]\f[CB]margin-top\f[B]\f[R], \f[B]\f[CB]margin-bottom\f[B]\f[R]+sets margins, if \f[C]layout\f[R] is not used (otherwise+\f[C]layout\f[R] overrides these)+.TP+\f[B]\f[CB]pagenumbering\f[B]\f[R]+page number style and location (using \f[C]setuppagenumbering\f[R]);+repeat for multiple options+.TP+\f[B]\f[CB]papersize\f[B]\f[R]+paper size, e.g.+\f[C]letter\f[R], \f[C]A4\f[R], \f[C]landscape\f[R] (see ConTeXt Paper+Setup); repeat for multiple options+.TP+\f[B]\f[CB]pdfa\f[B]\f[R]+adds to the preamble the setup necessary to generate PDF/A of the type+specified, e.g.+\f[C]1a:2005\f[R], \f[C]2a\f[R].+If no type is specified (i.e.+the value is set to True, by e.g.+\f[C]--metadata=pdfa\f[R] or \f[C]pdfa: true\f[R] in a YAML metadata+block), \f[C]1b:2005\f[R] will be used as default, for reasons of+backwards compatibility.+Using \f[C]--variable=pdfa\f[R] without specified value is not+supported.+To successfully generate PDF/A the required ICC color profiles have to+be available and the content and all included files (such as images)+have to be standard conforming.+The ICC profiles and output intent may be specified using the variables+\f[C]pdfaiccprofile\f[R] and \f[C]pdfaintent\f[R].+See also ConTeXt PDFA for more details.+.TP+\f[B]\f[CB]pdfaiccprofile\f[B]\f[R]+when used in conjunction with \f[C]pdfa\f[R], specifies the ICC profile+to use in the PDF, e.g.+\f[C]default.cmyk\f[R].+If left unspecified, \f[C]sRGB.icc\f[R] is used as default.+May be repeated to include multiple profiles.+Note that the profiles have to be available on the system.+They can be obtained from ConTeXt ICC Profiles.+.TP+\f[B]\f[CB]pdfaintent\f[B]\f[R]+when used in conjunction with \f[C]pdfa\f[R], specifies the output+intent for the colors, e.g.+\f[C]ISO coated v2 300\[rs]letterpercent\[rs]space (ECI)\f[R] If left+unspecified, \f[C]sRGB IEC61966-2.1\f[R] is used as default.+.TP+\f[B]\f[CB]toc\f[B]\f[R]+include table of contents (can also be set using+\f[C]--toc/--table-of-contents\f[R])+.TP+\f[B]\f[CB]whitespace\f[B]\f[R]+spacing between paragraphs, e.g.+\f[C]none\f[R], \f[C]small\f[R] (using \f[C]setupwhitespace\f[R])+.TP+\f[B]\f[CB]includesource\f[B]\f[R]+include all source documents as file attachments in the PDF file+.SS Variables for \f[C]wkhtmltopdf\f[R]+.PP+Pandoc uses these variables when creating a PDF with+\f[C]wkhtmltopdf\f[R].+The \f[C]--css\f[R] option also affects the output.+.TP+\f[B]\f[CB]footer-html\f[B]\f[R], \f[B]\f[CB]header-html\f[B]\f[R]+add information to the header and footer+.TP+\f[B]\f[CB]margin-left\f[B]\f[R], \f[B]\f[CB]margin-right\f[B]\f[R], \f[B]\f[CB]margin-top\f[B]\f[R], \f[B]\f[CB]margin-bottom\f[B]\f[R]+set the page margins+.TP+\f[B]\f[CB]papersize\f[B]\f[R]+sets the PDF paper size+.SS Variables for man pages+.TP+\f[B]\f[CB]adjusting\f[B]\f[R]+adjusts text to left (\f[C]l\f[R]), right (\f[C]r\f[R]), center+(\f[C]c\f[R]), or both (\f[C]b\f[R]) margins+.TP+\f[B]\f[CB]footer\f[B]\f[R]+footer in man pages+.TP+\f[B]\f[CB]header\f[B]\f[R]+header in man pages+.TP+\f[B]\f[CB]hyphenate\f[B]\f[R]+if \f[C]true\f[R] (the default), hyphenation will be used+.TP+\f[B]\f[CB]section\f[B]\f[R]+section number in man pages+.SS Variables for ms+.TP+\f[B]\f[CB]fontfamily\f[B]\f[R]+font family (e.g.+\f[C]T\f[R] or \f[C]P\f[R])+.TP+\f[B]\f[CB]indent\f[B]\f[R]+paragraph indent (e.g.+\f[C]2m\f[R])+.TP+\f[B]\f[CB]lineheight\f[B]\f[R]+line height (e.g.+\f[C]12p\f[R])+.TP+\f[B]\f[CB]pointsize\f[B]\f[R]+point size (e.g.+\f[C]10p\f[R])+.SS Variables set automatically+.PP+Pandoc sets these variables automatically in response to options or+document contents; users can also modify them.+These vary depending on the output format, and include the following:+.TP+\f[B]\f[CB]body\f[B]\f[R]+body of document+.TP+\f[B]\f[CB]date-meta\f[B]\f[R]+the \f[C]date\f[R] variable converted to ISO 8601 YYYY-MM-DD, included+in all HTML based formats (dzslides, epub, html, html4, html5, revealjs,+s5, slideous, slidy).+The recognized formats for \f[C]date\f[R] are: \f[C]mm/dd/yyyy\f[R],+\f[C]mm/dd/yy\f[R], \f[C]yyyy-mm-dd\f[R] (ISO 8601),+\f[C]dd MM yyyy\f[R] (e.g.+either \f[C]02 Apr 2018\f[R] or \f[C]02 April 2018\f[R]),+\f[C]MM dd, yyyy\f[R] (e.g.+\f[C]Apr. 02, 2018\f[R] or+\f[C]April 02, 2018),\f[R]yyyy[mm[dd]]]\f[C](e.g.\f[R]20180402,+\f[C]201804\f[R] or \f[C]2018\f[R]).+.TP+\f[B]\f[CB]header-includes\f[B]\f[R]+contents specified by \f[C]-H/--include-in-header\f[R] (may have+multiple values)+.TP+\f[B]\f[CB]include-before\f[B]\f[R]+contents specified by \f[C]-B/--include-before-body\f[R] (may have+multiple values)+.TP+\f[B]\f[CB]include-after\f[B]\f[R]+contents specified by \f[C]-A/--include-after-body\f[R] (may have+multiple values)+.TP+\f[B]\f[CB]meta-json\f[B]\f[R]+JSON representation of all of the document\[aq]s metadata.+Field values are transformed to the selected output format.+.TP+\f[B]\f[CB]numbersections\f[B]\f[R]+non-null value if \f[C]-N/--number-sections\f[R] was specified+.TP+\f[B]\f[CB]sourcefile\f[B]\f[R], \f[B]\f[CB]outputfile\f[B]\f[R]+source and destination filenames, as given on the command line.+\f[C]sourcefile\f[R] can also be a list if input comes from multiple+files, or empty if input is from stdin.+You can use the following snippet in your template to distinguish them:+.RS+.IP+.nf+\f[C]+$if(sourcefile)$+$for(sourcefile)$+$sourcefile$+$endfor$+$else$+(stdin)+$endif$+\f[R]+.fi+.PP+Similarly, \f[C]outputfile\f[R] can be \f[C]-\f[R] if output goes to the+terminal.+.PP+If you need absolute paths, use e.g.+\f[C]$curdir$/$sourcefile$\f[R].+.RE+.TP+\f[B]\f[CB]curdir\f[B]\f[R]+working directory from which pandoc is run.+.TP+\f[B]\f[CB]toc\f[B]\f[R]+non-null value if \f[C]--toc/--table-of-contents\f[R] was specified+.TP+\f[B]\f[CB]toc-title\f[B]\f[R]+title of table of contents (works only with EPUB, opendocument, odt,+docx, pptx, beamer, LaTeX)+.SH EXTENSIONS+.PP+The behavior of some of the readers and writers can be adjusted by+enabling or disabling various extensions.+.PP+An extension can be enabled by adding \f[C]+EXTENSION\f[R] to the format+name and disabled by adding \f[C]-EXTENSION\f[R].+For example, \f[C]--from markdown_strict+footnotes\f[R] is strict+Markdown with footnotes enabled, while+\f[C]--from markdown-footnotes-pipe_tables\f[R] is pandoc\[aq]s Markdown+without footnotes or pipe tables.+.PP+The markdown reader and writer make by far the most use of extensions.+Extensions only used by them are therefore covered in the section+Pandoc\[aq]s Markdown below (See Markdown variants for+\f[C]commonmark\f[R] and \f[C]gfm\f[R].) In the following, extensions+that also work for other formats are covered.+.PP+Note that markdown extensions added to the \f[C]ipynb\f[R] format affect+Markdown cells in Jupyter notebooks (as do command-line options like+\f[C]--atx-headers\f[R]).+.SS Typography+.SS Extension: \f[C]smart\f[R]+.PP+Interpret straight quotes as curly quotes, \f[C]---\f[R] as em-dashes,+\f[C]--\f[R] as en-dashes, and \f[C]...\f[R] as ellipses.+Nonbreaking spaces are inserted after certain abbreviations, such as+\[dq]Mr.\[dq]+.PP+This extension can be enabled/disabled for the following formats:+.TP+input formats+\f[C]markdown\f[R], \f[C]commonmark\f[R], \f[C]latex\f[R],+\f[C]mediawiki\f[R], \f[C]org\f[R], \f[C]rst\f[R], \f[C]twiki\f[R]+.TP+output formats+\f[C]markdown\f[R], \f[C]latex\f[R], \f[C]context\f[R], \f[C]rst\f[R]+.TP+enabled by default in+\f[C]markdown\f[R], \f[C]latex\f[R], \f[C]context\f[R] (both input and+output)+.PP+Note: If you are \f[I]writing\f[R] Markdown, then the \f[C]smart\f[R]+extension has the reverse effect: what would have been curly quotes+comes out straight.+.PP+In LaTeX, \f[C]smart\f[R] means to use the standard TeX ligatures for+quotation marks (\f[C]\[ga]\[ga]\f[R] and \f[C]\[aq]\[aq]\f[R] for+double quotes, \f[C]\[ga]\f[R] and \f[C]\[aq]\f[R] for single quotes)+and dashes (\f[C]--\f[R] for en-dash and \f[C]---\f[R] for em-dash).+If \f[C]smart\f[R] is disabled, then in reading LaTeX pandoc will parse+these characters literally.+In writing LaTeX, enabling \f[C]smart\f[R] tells pandoc to use the+ligatures when possible; if \f[C]smart\f[R] is disabled pandoc will use+unicode quotation mark and dash characters.+.SS Headings and sections+.SS Extension: \f[C]auto_identifiers\f[R]+.PP+A heading without an explicitly specified identifier will be+automatically assigned a unique identifier based on the heading text.+.PP+This extension can be enabled/disabled for the following formats:+.TP+input formats+\f[C]markdown\f[R], \f[C]latex\f[R], \f[C]rst\f[R], \f[C]mediawiki\f[R],+\f[C]textile\f[R]+.TP+output formats+\f[C]markdown\f[R], \f[C]muse\f[R]+.TP+enabled by default in+\f[C]markdown\f[R], \f[C]muse\f[R]+.PP+The default algorithm used to derive the identifier from the heading+text is:+.IP \[bu] 2+Remove all formatting, links, etc.+.IP \[bu] 2+Remove all footnotes.+.IP \[bu] 2+Remove all non-alphanumeric characters, 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[R].+.PP+Thus, for example,+.PP+.TS+tab(@);+l l.+T{+Heading+T}@T{+Identifier+T}+_+T{+\f[C]Heading identifiers in HTML\f[R]+T}@T{+\f[C]heading-identifiers-in-html\f[R]+T}+T{+\f[C]Ma\[^i]tre d\[aq]h\[^o]tel\f[R]+T}@T{+\f[C]ma\[^i]tre-dh\[^o]tel\f[R]+T}+T{+\f[C]*Dogs*?--in *my* house?\f[R]+T}@T{+\f[C]dogs--in-my-house\f[R]+T}+T{+\f[C][HTML], [S5], or [RTF]?\f[R]+T}@T{+\f[C]html-s5-or-rtf\f[R]+T}+T{+\f[C]3. Applications\f[R]+T}@T{+\f[C]applications\f[R]+T}+T{+\f[C]33\f[R]+T}@T{+\f[C]section\f[R]+T}+.TE+.PP+These rules should, in most cases, allow one to determine the identifier+from the heading text.+The exception is when several headings 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[R] appended; the third with+\f[C]-2\f[R]; and so on.+.PP+(However, a different algorithm is used if+\f[C]gfm_auto_identifiers\f[R] is enabled; see below.)+.PP+These identifiers are used to provide link targets in the table of+contents generated by the \f[C]--toc|--table-of-contents\f[R] 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+[heading identifiers](#heading-identifiers-in-html-latex-and-context).+\f[R]+.fi+.PP+Note, however, that this method of providing links to sections works+only in HTML, LaTeX, and ConTeXt formats.+.PP+If the \f[C]--section-divs\f[R] option is specified, then each section+will be wrapped in a \f[C]section\f[R] (or a \f[C]div\f[R], if+\f[C]html4\f[R] was specified), and the identifier will be attached to+the enclosing \f[C]<section>\f[R] (or \f[C]<div>\f[R]) tag rather than+the heading itself.+This allows entire sections to be manipulated using JavaScript or+treated differently in CSS.+.SS Extension: \f[C]ascii_identifiers\f[R]+.PP+Causes the identifiers produced by \f[C]auto_identifiers\f[R] to be pure+ASCII.+Accents are stripped off of accented Latin letters, and non-Latin+letters are omitted.+.SS Extension: \f[C]gfm_auto_identifiers\f[R]+.PP+Changes the algorithm used by \f[C]auto_identifiers\f[R] to conform to+GitHub\[aq]s method.+Spaces are converted to dashes (\f[C]-\f[R]), uppercase characters to+lowercase characters, and punctuation characters other than \f[C]-\f[R]+and \f[C]_\f[R] are removed.+Emojis are replaced by their names.+.SS Math Input+.PP+The extensions \f[C]tex_math_dollars\f[R],+\f[C]tex_math_single_backslash\f[R], and+\f[C]tex_math_double_backslash\f[R] are described in the section about+Pandoc\[aq]s Markdown.+.PP+However, they can also be used with HTML input.+This is handy for reading web pages formatted using MathJax, for+example.+.SS Raw HTML/TeX+.PP+The following extensions (especially how they affect Markdown+input/output) are also described in more detail in their respective+sections of Pandoc\[aq]s Markdown.+.SS Extension: \f[C]raw_html\f[R]+.PP+When converting from HTML, parse elements to raw HTML which are not+representable in pandoc\[aq]s AST.+By default, this is disabled for HTML input.+.SS Extension: \f[C]raw_tex\f[R]+.PP+Allows raw LaTeX, TeX, and ConTeXt to be included in a document.+.PP+This extension can be enabled/disabled for the following formats (in+addition to \f[C]markdown\f[R]):+.TP+input formats+\f[C]latex\f[R], \f[C]org\f[R], \f[C]textile\f[R], \f[C]html\f[R]+(environments, \f[C]\[rs]ref\f[R], and \f[C]\[rs]eqref\f[R] only),+\f[C]ipynb\f[R]+.TP+output formats+\f[C]textile\f[R], \f[C]commonmark\f[R]+.PP+Note: as applied to \f[C]ipynb\f[R], \f[C]raw_html\f[R] and+\f[C]raw_tex\f[R] affect not only raw TeX in markdown cells, but data+with mime type \f[C]text/html\f[R] in output cells.+Since the \f[C]ipynb\f[R] reader attempts to preserve the richest+possible outputs when several options are given, you will get best+results if you disable \f[C]raw_html\f[R] and \f[C]raw_tex\f[R] when+converting to formats like \f[C]docx\f[R] which don\[aq]t allow raw+\f[C]html\f[R] or \f[C]tex\f[R].+.SS Extension: \f[C]native_divs\f[R]+.PP+This extension is enabled by default for HTML input.+This means that \f[C]div\f[R]s are parsed to pandoc native elements.+(Alternatively, you can parse them to raw HTML using+\f[C]-f html-native_divs+raw_html\f[R].)+.PP+When converting HTML to Markdown, for example, you may want to drop all+\f[C]div\f[R]s and \f[C]span\f[R]s:+.IP+.nf+\f[C]+pandoc -f html-native_divs-native_spans -t markdown+\f[R]+.fi+.SS Extension: \f[C]native_spans\f[R]+.PP+Analogous to \f[C]native_divs\f[R] above.+.SS Literate Haskell support+.SS Extension: \f[C]literate_haskell\f[R]+.PP+Treat the document as literate Haskell source.+.PP+This extension can be enabled/disabled for the following formats:+.TP+input formats+\f[C]markdown\f[R], \f[C]rst\f[R], \f[C]latex\f[R]+.TP+output formats+\f[C]markdown\f[R], \f[C]rst\f[R], \f[C]latex\f[R], \f[C]html\f[R]+.PP+If you append \f[C]+lhs\f[R] (or \f[C]+literate_haskell\f[R]) to one of+the formats above, pandoc will treat the document as literate Haskell+source.+This means that+.IP \[bu] 2+In Markdown input, \[dq]bird track\[dq] sections will be parsed as+Haskell code rather than block quotations.+Text between \f[C]\[rs]begin{code}\f[R] and \f[C]\[rs]end{code}\f[R]+will also be treated as Haskell code.+For ATX-style headings the character \[aq]=\[aq] will be used instead of+\[aq]#\[aq].+.IP \[bu] 2+In Markdown output, code blocks with classes \f[C]haskell\f[R] and+\f[C]literate\f[R] 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, headings 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, \[dq]bird track\[dq] sections will be parsed+as Haskell code.+.IP \[bu] 2+In restructured text output, code blocks with class \f[C]haskell\f[R]+will be rendered using bird tracks.+.IP \[bu] 2+In LaTeX input, text in \f[C]code\f[R] environments will be parsed as+Haskell code.+.IP \[bu] 2+In LaTeX output, code blocks with class \f[C]haskell\f[R] will be+rendered inside \f[C]code\f[R] environments.+.IP \[bu] 2+In HTML output, code blocks with class \f[C]haskell\f[R] will be+rendered with class \f[C]literatehaskell\f[R] and bird tracks.+.PP+Examples:+.IP+.nf+\f[C]+pandoc -f markdown+lhs -t html+\f[R]+.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[R]+.fi+.PP+writes HTML with the Haskell code in bird tracks, so it can be copied+and pasted as literate Haskell source.+.PP+Note that GHC expects the bird tracks in the first column, so indented+literate code blocks (e.g.+inside an itemized environment) will not be picked up by the Haskell+compiler.+.SS Other extensions+.SS Extension: \f[C]empty_paragraphs\f[R]+.PP+Allows empty paragraphs.+By default empty paragraphs are omitted.+.PP+This extension can be enabled/disabled for the following formats:+.TP+input formats+\f[C]docx\f[R], \f[C]html\f[R]+.TP+output formats+\f[C]docx\f[R], \f[C]odt\f[R], \f[C]opendocument\f[R], \f[C]html\f[R]+.SS Extension: \f[C]native_numbering\f[R]+.PP+Enables native numbering of figures and tables.+Enumeration starts at 1.+.PP+This extension can be enabled/disabled for the following formats:+.TP+output formats+\f[C]odt\f[R], \f[C]opendocument\f[R]+.SS Extension: \f[C]styles\f[R]+.PP+When converting from docx, read all docx styles as divs (for paragraph+styles) and spans (for character styles) regardless of whether pandoc+understands the meaning of these styles.+This can be used with docx custom styles.+Disabled by default.+.TP+input formats+\f[C]docx\f[R]+.SS Extension: \f[C]amuse\f[R]+.PP+In the \f[C]muse\f[R] input format, this enables Text::Amuse extensions+to Emacs Muse markup.+.SS Extension: \f[C]citations\f[R]+.PP+Some aspects of Pandoc\[aq]s Markdown citation syntax are also accepted+in \f[C]org\f[R] input.+.SS Extension: \f[C]ntb\f[R]+.PP+In the \f[C]context\f[R] output format this enables the use of Natural+Tables (TABLE) instead of the default Extreme Tables (xtables).+Natural tables allow more fine-grained global customization but come at+a performance penalty compared to extreme tables.+.SH PANDOC\[aq]S MARKDOWN+.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 using the+\f[C]markdown_strict\f[R] format instead of \f[C]markdown\f[R].+Extensions can be enabled or disabled to specify the behavior more+granularly.+They are described in the following.+See also Extensions above, for extensions that work also on other+formats.+.SS 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.+.SS Paragraphs+.PP+A paragraph is one or more lines of text followed by one or more blank+lines.+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.+.SS Extension: \f[C]escaped_line_breaks\f[R]+.PP+A backslash followed by a newline is also a hard line break.+Note: in multiline and grid table cells, this is the only way to create+a hard line break, since trailing spaces in the cells are ignored.+.SS Headings+.PP+There are two kinds of headings: Setext and ATX.+.SS Setext-style headings+.PP+A setext-style heading is a line of text \[dq]underlined\[dq] with a row+of \f[C]=\f[R] signs (for a level-one heading) or \f[C]-\f[R] signs (for+a level-two heading):+.IP+.nf+\f[C]+A level-one heading+===================++A level-two heading+-------------------+\f[R]+.fi+.PP+The heading text can contain inline formatting, such as emphasis (see+Inline formatting, below).+.SS ATX-style headings+.PP+An ATX-style heading consists of one to six \f[C]#\f[R] signs and a line+of text, optionally followed by any number of \f[C]#\f[R] signs.+The number of \f[C]#\f[R] signs at the beginning of the line is the+heading level:+.IP+.nf+\f[C]+## A level-two heading++### A level-three heading ###+\f[R]+.fi+.PP+As with setext-style headings, the heading text can contain formatting:+.IP+.nf+\f[C]+# A level-one heading with a [link](/url) and *emphasis*+\f[R]+.fi+.SS Extension: \f[C]blank_before_header\f[R]+.PP+Standard Markdown syntax does not require a blank line before a heading.+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[R] 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[R]+.fi+.SS Extension: \f[C]space_in_atx_header\f[R]+.PP+Many Markdown implementations do not require a space between the opening+\f[C]#\f[R]s of an ATX heading and the heading text, so that+\f[C]#5 bolt\f[R] and \f[C]#hashtag\f[R] count as headings.+With this extension, pandoc does require the space.+.SS Heading identifiers+.PP+See also the \f[C]auto_identifiers\f[R] extension above.+.SS Extension: \f[C]header_attributes\f[R]+.PP+Headings can be assigned attributes using this syntax at the end of the+line containing the heading text:+.IP+.nf+\f[C]+{#identifier .class .class key=value key=value}+\f[R]+.fi+.PP+Thus, for example, the following headings will all be assigned the+identifier \f[C]foo\f[R]:+.IP+.nf+\f[C]+# My heading {#foo}++## My heading ##    {#foo}++My other heading   {#foo}+---------------+\f[R]+.fi+.PP+(This syntax is compatible with PHP Markdown Extra.)+.PP+Note that although this syntax allows assignment of classes and+key/value attributes, writers generally don\[aq]t use all of this+information.+Identifiers, classes, and key/value attributes are used in HTML and+HTML-based formats such as EPUB and slidy.+Identifiers are used for labels and link anchors in the LaTeX, ConTeXt,+Textile, Jira markup, and AsciiDoc writers.+.PP+Headings with the class \f[C]unnumbered\f[R] will not be numbered, even+if \f[C]--number-sections\f[R] is specified.+A single hyphen (\f[C]-\f[R]) in an attribute context is equivalent to+\f[C].unnumbered\f[R], and preferable in non-English documents.+So,+.IP+.nf+\f[C]+# My heading {-}+\f[R]+.fi+.PP+is just the same as+.IP+.nf+\f[C]+# My heading {.unnumbered}+\f[R]+.fi+.PP+If the \f[C]unlisted\f[R] class is present in addition to+\f[C]unnumbered\f[R], the heading will not be included in a table of+contents.+(Currently this feature is only implemented for certain formats: those+based on LaTeX and HTML, PowerPoint, and RTF.)+.SS Extension: \f[C]implicit_header_references\f[R]+.PP+Pandoc behaves as if reference links have been defined for each heading.+So, to link to a heading+.IP+.nf+\f[C]+# Heading identifiers in HTML+\f[R]+.fi+.PP+you can simply write+.IP+.nf+\f[C]+[Heading identifiers in HTML]+\f[R]+.fi+.PP+or+.IP+.nf+\f[C]+[Heading identifiers in HTML][]+\f[R]+.fi+.PP+or+.IP+.nf+\f[C]+[the section on heading identifiers][heading identifiers in+HTML]+\f[R]+.fi+.PP+instead of giving the identifier explicitly:+.IP+.nf+\f[C]+[Heading identifiers in HTML](#heading-identifiers-in-html)+\f[R]+.fi+.PP+If there are multiple headings with identical text, the corresponding+reference will link to the first one only, and you will need to use+explicit links to link to the others, as described above.+.PP+Like regular reference links, these references are case-insensitive.+.PP+Explicit link reference definitions always take priority over implicit+heading references.+So, in the following example, the link will point to \f[C]bar\f[R], not+to \f[C]#foo\f[R]:+.IP+.nf+\f[C]+# Foo++[foo]: bar++See [foo]+\f[R]+.fi+.SS 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 headings), with each line preceded by a \f[C]>\f[R]+character and an optional space.+(The \f[C]>\f[R] 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[R]+.fi+.PP+A \[dq]lazy\[dq] form, which requires the \f[C]>\f[R] 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[R]+.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[R]+.fi+.PP+If the \f[C]>\f[R] character is followed by an optional space, that+space will be considered part of the block quote marker and not part of+the indentation of the contents.+Thus, to put an indented code block in a block quote, you need five+spaces after the \f[C]>\f[R]:+.IP+.nf+\f[C]+>     code+\f[R]+.fi+.SS Extension: \f[C]blank_before_blockquote\f[R]+.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[R] to end up at the beginning of a line by accident (perhaps+through line wrapping).+So, unless the \f[C]markdown_strict\f[R] format is used, the following+does not produce a nested block quote in pandoc:+.IP+.nf+\f[C]+> This is a block quote.+>> Nested.+\f[R]+.fi+.SS 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[R]+.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 Fenced code blocks+.SS Extension: \f[C]fenced_code_blocks\f[R]+.PP+In addition to standard indented code blocks, pandoc supports+\f[I]fenced\f[R] code blocks.+These begin with a row of three or more tildes (\f[C]\[ti]\f[R]) and end+with a row of tildes that must be at least as long as the starting row.+Everything between these lines is treated as code.+No indentation is necessary:+.IP+.nf+\f[C]+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+if (a > 3) {+  moveShip(5 * gravity, DOWN);+}+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+\f[R]+.fi+.PP+Like regular code blocks, fenced code blocks must be separated from+surrounding text by blank lines.+.PP+If the code itself contains a row of tildes or backticks, just use a+longer row of tildes or backticks at the start and end:+.IP+.nf+\f[C]+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+code including tildes+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+\f[R]+.fi+.SS Extension: \f[C]backtick_code_blocks\f[R]+.PP+Same as \f[C]fenced_code_blocks\f[R], but uses backticks+(\f[C]\[ga]\f[R]) instead of tildes (\f[C]\[ti]\f[R]).+.SS Extension: \f[C]fenced_code_attributes\f[R]+.PP+Optionally, you may attach attributes to fenced or backtick code block+using this syntax:+.IP+.nf+\f[C]+\[ti]\[ti]\[ti]\[ti] {#mycode .haskell .numberLines startFrom=\[dq]100\[dq]}+qsort []     = []+qsort (x:xs) = qsort (filter (< x) xs) ++ [x] +++               qsort (filter (>= x) xs)+\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]\[ti]+\f[R]+.fi+.PP+Here \f[C]mycode\f[R] is an identifier, \f[C]haskell\f[R] and+\f[C]numberLines\f[R] are classes, and \f[C]startFrom\f[R] is an+attribute with value \f[C]100\f[R].+Some output formats can use this information to do syntax highlighting.+Currently, the only output formats that uses this information are HTML,+LaTeX, Docx, Ms, and PowerPoint.+If highlighting is supported for your output format and language, then+the code block above will appear highlighted, with numbered lines.+(To see which languages are supported, type+\f[C]pandoc --list-highlight-languages\f[R].) Otherwise, the code block+above will appear as follows:+.IP+.nf+\f[C]+<pre id=\[dq]mycode\[dq] class=\[dq]haskell numberLines\[dq] startFrom=\[dq]100\[dq]>+  <code>+  ...+  </code>+</pre>+\f[R]+.fi+.PP+The \f[C]numberLines\f[R] (or \f[C]number-lines\f[R]) class will cause+the lines of the code block to be numbered, starting with \f[C]1\f[R] or+the value of the \f[C]startFrom\f[R] attribute.+The \f[C]lineAnchors\f[R] (or \f[C]line-anchors\f[R]) class will cause+the lines to be clickable anchors in HTML output.+.PP+A shortcut form can also be used for specifying the language of the code+block:+.IP+.nf+\f[C]+\[ga]\[ga]\[ga]haskell+qsort [] = []+\[ga]\[ga]\[ga]+\f[R]+.fi+.PP+This is equivalent to:+.IP+.nf+\f[C]+\[ga]\[ga]\[ga] {.haskell}+qsort [] = []+\[ga]\[ga]\[ga]+\f[R]+.fi+.PP+If the \f[C]fenced_code_attributes\f[R] extension is disabled, but input+contains class attribute(s) for the code block, the first class+attribute will be printed after the opening fence as a bare word.+.PP+To prevent all highlighting, use the \f[C]--no-highlight\f[R] flag.+To set the highlighting style, use \f[C]--highlight-style\f[R].+For more information on highlighting, see Syntax highlighting, below.+.SS Line blocks+.SS Extension: \f[C]line_blocks\f[R]+.PP+A line block is a sequence of lines beginning with a vertical bar+(\f[C]|\f[R]) followed by a space.+The division into lines will be preserved in the output, as will any+leading spaces; otherwise, the lines will be formatted as Markdown.+This is useful for verse and addresses:+.IP+.nf+\f[C]+| The limerick packs laughs anatomical+| In space that is quite economical.+|    But the good ones I\[aq]ve seen+|    So seldom are clean+| And the clean ones so seldom are comical++| 200 Main St.+| Berkeley, CA 94718+\f[R]+.fi+.PP+The lines can be hard-wrapped if needed, but the continuation line must+begin with a space.+.IP+.nf+\f[C]+| The Right Honorable Most Venerable and Righteous Samuel L.+  Constable, Jr.+| 200 Main St.+| Berkeley, CA 94718+\f[R]+.fi+.PP+This syntax is borrowed from reStructuredText.+.SS 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[R], \f[C]+\f[R], or+\f[C]-\f[R]).+Here is a simple example:+.IP+.nf+\f[C]+* one+* two+* three+\f[R]+.fi+.PP+This will produce a \[dq]compact\[dq] list.+If you want a \[dq]loose\[dq] list, in which each item is formatted as a+paragraph, put spaces between the items:+.IP+.nf+\f[C]+* one++* two++* three+\f[R]+.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+List items look best if subsequent lines are flush with the first line+(after the bullet):+.IP+.nf+\f[C]+* here is my first+  list item.+* and my second.+\f[R]+.fi+.PP+But Markdown also allows a \[dq]lazy\[dq] format:+.IP+.nf+\f[C]+* here is my first+list item.+* and my second.+\f[R]+.fi+.SS Block content in list items+.PP+A list item may contain multiple paragraphs and other block-level+content.+However, subsequent paragraphs must be preceded by a blank line and+indented to line up with the first non-space content after the list+marker.+.IP+.nf+\f[C]+  * First paragraph.++    Continued.++  * Second paragraph. With a code block, which must be indented+    eight spaces:++        { code }+\f[R]+.fi+.PP+Exception: if the list marker is followed by an indented code block,+which must begin 5 spaces after the list marker, then subsequent+paragraphs must begin two columns after the last character of the list+marker:+.IP+.nf+\f[C]+*     code++  continuation paragraph+\f[R]+.fi+.PP+List items may include other lists.+In this case the preceding blank line is optional.+The nested list must be indented to line up with the first non-space+character after the list marker of the containing list item.+.IP+.nf+\f[C]+* fruits+  + apples+    - macintosh+    - red delicious+  + pears+  + peaches+* vegetables+  + broccoli+  + chard+\f[R]+.fi+.PP+As noted above, Markdown allows you to write list items+\[dq]lazily,\[dq] 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[R]+.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[R]+.fi+.PP+and this one:+.IP+.nf+\f[C]+5.  one+7.  two+1.  three+\f[R]+.fi+.SS Extension: \f[C]fancy_lists\f[R]+.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.+.PP+The \f[C]fancy_lists\f[R] extension also allows \[aq]\f[C]#\f[R]\[aq] to+be used as an ordered list marker in place of a numeral:+.IP+.nf+\f[C]+#. one+#. two+\f[R]+.fi+.SS Extension: \f[C]startnum\f[R]+.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[R]+.fi+.PP+Pandoc will start a new list each time a different type of list marker+is used.+So, the following will create three lists:+.IP+.nf+\f[C]+(2) Two+(5) Three+1.  Four+*   Five+\f[R]+.fi+.PP+If default list markers are desired, use \f[C]#.\f[R]:+.IP+.nf+\f[C]+#.  one+#.  two+#.  three+\f[R]+.fi+.SS Extension: \f[C]task_lists\f[R]+.PP+Pandoc supports task lists, using the syntax of GitHub-Flavored+Markdown.+.IP+.nf+\f[C]+- [ ] an unchecked task list item+- [x] checked item+\f[R]+.fi+.SS Definition lists+.SS Extension: \f[C]definition_lists\f[R]+.PP+Pandoc supports definition lists, using the syntax of PHP Markdown Extra+with some extensions.+.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[R]+.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.+.PP+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.+The body of the definition (including the first line, aside from the+colon or tilde) should be indented four spaces.+However, as with other Markdown lists, you can \[dq]lazily\[dq] omit+indentation except at the beginning of a paragraph or other block+element:+.IP+.nf+\f[C]+Term 1++:   Definition+with lazy continuation.++    Second paragraph of the definition.+\f[R]+.fi+.PP+If you leave space before the definition (as in the example above), the+text of the definition will be treated as a paragraph.+In some output formats, this will mean greater spacing between+term/definition pairs.+For a more compact definition list, omit the space before the+definition:+.IP+.nf+\f[C]+Term 1+  \[ti] Definition 1++Term 2+  \[ti] Definition 2a+  \[ti] Definition 2b+\f[R]+.fi+.PP+Note that space between items in a definition list is required.+(A variant that loosens this requirement, but disallows \[dq]lazy\[dq]+hard wrapping, can be activated with \f[C]compact_definition_lists\f[R]:+see Non-pandoc extensions, below.)+.SS Numbered example lists+.SS Extension: \f[C]example_lists\f[R]+.PP+The special list marker \f[C]\[at]\f[R] can be used for sequentially+numbered examples.+The first list item with a \f[C]\[at]\f[R] 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]\[at]\f[R] will take up where the last stopped.+So, for example:+.IP+.nf+\f[C]+(\[at])  My first example will be numbered (1).+(\[at])  My second example will be numbered (2).++Explanation of examples.++(\[at])  My third example will be numbered (3).+\f[R]+.fi+.PP+Numbered examples can be labeled and referred to elsewhere in the+document:+.IP+.nf+\f[C]+(\[at]good)  This is a good example.++As (\[at]good) illustrates, ...+\f[R]+.fi+.PP+The label can be any string of alphanumeric characters, underscores, or+hyphens.+.PP+Note: continuation paragraphs in example lists must always be indented+four spaces, regardless of the length of the list marker.+That is, example lists always behave as if the \f[C]four_space_rule\f[R]+extension is set.+This is because example labels tend to be long, and indenting content to+the first non-space character after the label would be awkward.+.SS Compact and loose lists+.PP+Pandoc behaves differently from \f[C]Markdown.pl\f[R] on some \[dq]edge+cases\[dq] involving lists.+Consider this source:+.IP+.nf+\f[C]++   First++   Second:+    -   Fee+    -   Fie+    -   Foe+++   Third+\f[R]+.fi+.PP+Pandoc transforms this into a \[dq]compact list\[dq] (with no+\f[C]<p>\f[R] tags around \[dq]First\[dq], \[dq]Second\[dq], or+\[dq]Third\[dq]), while Markdown puts \f[C]<p>\f[R] tags around+\[dq]Second\[dq] and \[dq]Third\[dq] (but not \[dq]First\[dq]), because+of the blank space around \[dq]Third\[dq].+Pandoc follows a simple rule: if the text is followed by a blank line,+it is treated as a paragraph.+Since \[dq]Second\[dq] 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]markdown_strict\f[R]+format 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[R].)+.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[R]+.fi+.PP+Trouble! Here pandoc (like other Markdown implementations) will treat+\f[C]{ my code block }\f[R] as the second paragraph of item two, and not+as a code block.+.PP+To \[dq]cut off\[dq] 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[R]+.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++<!-- -->++1.  uno+2.  dos+3.  tres+\f[R]+.fi+.SS Horizontal rules+.PP+A line containing a row of three or more \f[C]*\f[R], \f[C]-\f[R], or+\f[C]_\f[R] characters (optionally separated by spaces) produces a+horizontal rule:+.IP+.nf+\f[C]+*  *  *  *++---------------+\f[R]+.fi+.SS Tables+.PP+Four kinds of tables may be used.+The first three kinds presuppose the use of a fixed-width font, such as+Courier.+The fourth kind can be used with proportionally spaced fonts, as it does+not require lining up columns.+.SS Extension: \f[C]table_captions\f[R]+.PP+A caption may optionally be provided with all 4 kinds of tables (as+illustrated in the examples below).+A caption is a paragraph beginning with the string \f[C]Table:\f[R] (or+just \f[C]:\f[R]), which will be stripped off.+It may appear either before or after the table.+.SS Extension: \f[C]simple_tables\f[R]+.PP+Simple tables 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[R]+.fi+.PP+The header 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:+.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.+.PP+The column header row 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[R]+.fi+.PP+When the header row is 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.+.SS Extension: \f[C]multiline_tables\f[R]+.PP+Multiline tables allow header 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[R]+.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+header row is 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+The header 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 a header.+\f[R]+.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.+.SS Extension: \f[C]grid_tables\f[R]+.PP+Grid tables 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[R]+.fi+.PP+The row of \f[C]=\f[R]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.).+Cells that span multiple columns or rows are not supported.+Grid tables can be created easily using Emacs\[aq] table-mode+(\f[C]M-x table-insert\f[R]).+.PP+Alignments can be specified as with pipe tables, by putting colons at+the boundaries of the separator line after the header:+.IP+.nf+\f[C]++---------------+---------------+--------------------++| Right         | Left          | Centered           |++==============:+:==============+:==================:++| Bananas       | $1.34         | built-in wrapper   |++---------------+---------------+--------------------++\f[R]+.fi+.PP+For headerless tables, the colons go on the top line instead:+.IP+.nf+\f[C]++--------------:+:--------------+:------------------:++| Right         | Left          | Centered           |++---------------+---------------+--------------------++\f[R]+.fi+.SS Grid Table Limitations+.PP+Pandoc does not support grid tables with row spans or column spans.+This means that neither variable numbers of columns across rows nor+variable numbers of rows across columns are supported by Pandoc.+All grid tables must have the same number of columns in each row, and+the same number of rows in each column.+For example, the Docutils sample grid tables will not render as expected+with Pandoc.+.SS Extension: \f[C]pipe_tables\f[R]+.PP+Pipe tables look like this:+.IP+.nf+\f[C]+| Right | Left | Default | Center |+|------:|:-----|---------|:------:|+|   12  |  12  |    12   |    12  |+|  123  |  123 |   123   |   123  |+|    1  |    1 |     1   |     1  |++  : Demonstration of pipe table syntax.+\f[R]+.fi+.PP+The syntax is identical to PHP Markdown Extra tables.+The beginning and ending pipe characters are optional, but pipes are+required between all columns.+The colons indicate column alignment as shown.+The header cannot be omitted.+To simulate a headerless table, include a header with blank cells.+.PP+Since the pipes indicate column boundaries, columns need not be+vertically aligned, as they are in the above example.+So, this is a perfectly legal (though ugly) pipe table:+.IP+.nf+\f[C]+fruit| price+-----|-----:+apple|2.05+pear|1.37+orange|3.09+\f[R]+.fi+.PP+The cells of pipe tables cannot contain block elements like paragraphs+and lists, and cannot span multiple lines.+If a pipe table contains a row whose printable content is wider than the+column width (see \f[C]--columns\f[R]), then the table will take up the+full text width and the cell contents will wrap, with the relative cell+widths determined by the number of dashes in the line separating the+table header from the table body.+(For example \f[C]---|-\f[R] would make the first column 3/4 and the+second column 1/4 of the full text width.) On the other hand, if no+lines are wider than column width, then cell contents will not be+wrapped, and the cells will be sized to their contents.+.PP+Note: pandoc also recognizes pipe tables of the following form, as can+be produced by Emacs\[aq] orgtbl-mode:+.IP+.nf+\f[C]+| One | Two   |+|-----+-------|+| my  | table |+| is  | nice  |+\f[R]+.fi+.PP+The difference is that \f[C]+\f[R] is used instead of \f[C]|\f[R].+Other orgtbl features are not supported.+In particular, to get non-default column alignment, you\[aq]ll need to+add colons as above.+.SS Metadata blocks+.SS Extension: \f[C]pandoc_title_block\f[R]+.PP+If the file begins with a title block+.IP+.nf+\f[C]+% title+% author(s) (separated by semicolons)+% date+\f[R]+.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[R]+.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[R]+.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[R]+.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[R] (\f[C]-s\f[R]) 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[R] or \f[C]-T\f[R] option).+The title in the body appears as an H1 element with class+\[dq]title\[dq], so it can be suppressed or reformatted with CSS.+If a title prefix is specified with \f[C]-T\f[R] 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[R]) should be used to separate the+footer text from the header text.+Thus,+.IP+.nf+\f[C]+% PANDOC(1)+\f[R]+.fi+.PP+will yield a man page with the title \f[C]PANDOC\f[R] and section 1.+.IP+.nf+\f[C]+% PANDOC(1) Pandoc User Manuals+\f[R]+.fi+.PP+will also have \[dq]Pandoc User Manuals\[dq] in the footer.+.IP+.nf+\f[C]+% PANDOC(1) Pandoc User Manuals | Version 4.0+\f[R]+.fi+.PP+will also have \[dq]Version 4.0\[dq] in the header.+.SS Extension: \f[C]yaml_metadata_block\f[R]+.PP+A YAML metadata block is a valid YAML object, delimited by a line of+three hyphens (\f[C]---\f[R]) at the top and a line of three hyphens+(\f[C]---\f[R]) or three dots (\f[C]...\f[R]) at the bottom.+A YAML metadata block may occur anywhere in the document, but if it is+not at the beginning, it must be preceded by a blank line.+(Note that, because of the way pandoc concatenates input files when+several are provided, you may also keep the metadata in a separate YAML+file and pass it to pandoc as an argument, along with your Markdown+files:+.IP+.nf+\f[C]+pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html+\f[R]+.fi+.PP+Just be sure that the YAML file begins with \f[C]---\f[R] and ends with+\f[C]---\f[R] or \f[C]...\f[R].) Alternatively, you can use the+\f[C]--metadata-file\f[R] option.+Using that approach however, you cannot reference content (like+footnotes) from the main markdown input document.+.PP+Metadata will be taken from the fields of the YAML object and added to+any existing document metadata.+Metadata can contain lists and objects (nested arbitrarily), but all+string scalars will be interpreted as Markdown.+Fields with names ending in an underscore will be ignored by pandoc.+(They may be given a role by external processors.) Field names must not+be interpretable as YAML numbers or boolean values (so, for example,+\f[C]yes\f[R], \f[C]True\f[R], and \f[C]15\f[R] cannot be used as field+names).+.PP+A document may contain multiple metadata blocks.+If two metadata blocks attempt to set the same field, the value from the+second block will be taken.+.PP+When pandoc is used with \f[C]-t markdown\f[R] to create a Markdown+document, a YAML metadata block will be produced only if the+\f[C]-s/--standalone\f[R] option is used.+All of the metadata will appear in a single block at the beginning of+the document.+.PP+Note that YAML escaping rules must be followed.+Thus, for example, if a title contains a colon, it must be quoted.+The pipe character (\f[C]|\f[R]) can be used to begin an indented block+that will be interpreted literally, without need for escaping.+This form is necessary when the field contains blank lines or+block-level formatting:+.IP+.nf+\f[C]+---+title:  \[aq]This is the title: it contains a colon\[aq]+author:+- Author One+- Author Two+keywords: [nothing, nothingness]+abstract: |+  This is the abstract.++  It consists of two paragraphs.+\&...+\f[R]+.fi+.PP+Template variables will be set automatically from the metadata.+Thus, for example, in writing HTML, the variable \f[C]abstract\f[R] will+be set to the HTML equivalent of the Markdown in the \f[C]abstract\f[R]+field:+.IP+.nf+\f[C]+<p>This is the abstract.</p>+<p>It consists of two paragraphs.</p>+\f[R]+.fi+.PP+Variables can contain arbitrary YAML structures, but the template must+match this structure.+The \f[C]author\f[R] variable in the default templates expects a simple+list or string, but can be changed to support more complicated+structures.+The following combination, for example, would add an affiliation to the+author if one is given:+.IP+.nf+\f[C]+---+title: The document title+author:+- name: Author One+  affiliation: University of Somewhere+- name: Author Two+  affiliation: University of Nowhere+\&...+\f[R]+.fi+.PP+To use the structured authors in the example above, you would need a+custom template:+.IP+.nf+\f[C]+$for(author)$+$if(author.name)$+$author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$+$else$+$author$+$endif$+$endfor$+\f[R]+.fi+.PP+Raw content to include in the document\[aq]s header may be specified+using \f[C]header-includes\f[R]; however, it is important to mark up+this content as raw code for a particular output format, using the+\f[C]raw_attribute\f[R] extension), or it will be interpreted as+markdown.+For example:+.IP+.nf+\f[C]+header-includes:+- |+  \[ga]\[ga]\[ga]{=latex}+  \[rs]let\[rs]oldsection\[rs]section+  \[rs]renewcommand{\[rs]section}[1]{\[rs]clearpage\[rs]oldsection{#1}}+  \[ga]\[ga]\[ga]+\f[R]+.fi+.SS Backslash escapes+.SS Extension: \f[C]all_symbols_escapable\f[R]+.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]+*\[rs]*hello\[rs]**+\f[R]+.fi+.PP+one will get+.IP+.nf+\f[C]+<em>*hello*</em>+\f[R]+.fi+.PP+instead of+.IP+.nf+\f[C]+<strong>hello</strong>+\f[R]+.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]+\[rs]\[ga]*_{}[]()>#+-.!+\f[R]+.fi+.PP+(However, if the \f[C]markdown_strict\f[R] format is used, 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]\[ti]\f[R] and in HTML and XML as+\f[C]\[rs]&#160;\f[R] or \f[C]\[rs]&nbsp;\f[R].+.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]\[rs]\[rs]\f[R] and in HTML as+\f[C]<br />\f[R].+This is a nice alternative to Markdown\[aq]s \[dq]invisible\[dq] way of+indicating hard line breaks using two trailing spaces on a line.+.PP+Backslash escapes do not work in verbatim contexts.+.SS Inline formatting+.SS Emphasis+.PP+To \f[I]emphasize\f[R] some text, surround it with \f[C]*\f[R]s or+\f[C]_\f[R], like this:+.IP+.nf+\f[C]+This text is _emphasized with underscores_, and this+is *emphasized with asterisks*.+\f[R]+.fi+.PP+Double \f[C]*\f[R] or \f[C]_\f[R] produces \f[B]strong emphasis\f[R]:+.IP+.nf+\f[C]+This is **strong emphasis** and __with underscores__.+\f[R]+.fi+.PP+A \f[C]*\f[R] or \f[C]_\f[R] character surrounded by spaces, or+backslash-escaped, will not trigger emphasis:+.IP+.nf+\f[C]+This is * not emphasized *, and \[rs]*neither is this\[rs]*.+\f[R]+.fi+.SS Extension: \f[C]intraword_underscores\f[R]+.PP+Because \f[C]_\f[R] is sometimes used inside words and identifiers,+pandoc does not interpret a \f[C]_\f[R] surrounded by alphanumeric+characters as an emphasis marker.+If you want to emphasize just part of a word, use \f[C]*\f[R]:+.IP+.nf+\f[C]+feas*ible*, not feas*able*.+\f[R]+.fi+.SS Strikeout+.SS Extension: \f[C]strikeout\f[R]+.PP+To strikeout a section of text with a horizontal line, begin and end it+with \f[C]\[ti]\[ti]\f[R].+Thus, for example,+.IP+.nf+\f[C]+This \[ti]\[ti]is deleted text.\[ti]\[ti]+\f[R]+.fi+.SS Superscripts and subscripts+.SS Extension: \f[C]superscript\f[R], \f[C]subscript\f[R]+.PP+Superscripts may be written by surrounding the superscripted text by+\f[C]\[ha]\f[R] characters; subscripts may be written by surrounding the+subscripted text by \f[C]\[ti]\f[R] characters.+Thus, for example,+.IP+.nf+\f[C]+H\[ti]2\[ti]O is a liquid.  2\[ha]10\[ha] is 1024.+\f[R]+.fi+.PP+The text between \f[C]\[ha]...\[ha]\f[R] or \f[C]\[ti]...\[ti]\f[R] may+not contain spaces or newlines.+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]\[ti]\f[R] and \f[C]\[ha]\f[R], and also bad+interactions with footnotes.) Thus, if you want the letter P with \[aq]a+cat\[aq] in subscripts, use \f[C]P\[ti]a\[rs] cat\[ti]\f[R], not+\f[C]P\[ti]a cat\[ti]\f[R].+.SS Verbatim+.PP+To make a short span of text verbatim, put it inside backticks:+.IP+.nf+\f[C]+What is the difference between \[ga]>>=\[ga] and \[ga]>>\[ga]?+\f[R]+.fi+.PP+If the verbatim text includes a backtick, use double backticks:+.IP+.nf+\f[C]+Here is a literal backtick \[ga]\[ga] \[ga] \[ga]\[ga].+\f[R]+.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: \[ga]\[rs]*\[ga].+\f[R]+.fi+.SS Extension: \f[C]inline_code_attributes\f[R]+.PP+Attributes can be attached to verbatim text, just as with fenced code+blocks:+.IP+.nf+\f[C]+\[ga]<$>\[ga]{.haskell}+\f[R]+.fi+.SS Small caps+.PP+To write small caps, use the \f[C]smallcaps\f[R] class:+.IP+.nf+\f[C]+[Small caps]{.smallcaps}+\f[R]+.fi+.PP+Or, without the \f[C]bracketed_spans\f[R] extension:+.IP+.nf+\f[C]+<span class=\[dq]smallcaps\[dq]>Small caps</span>+\f[R]+.fi+.PP+For compatibility with other Markdown flavors, CSS is also supported:+.IP+.nf+\f[C]+<span style=\[dq]font-variant:small-caps;\[dq]>Small caps</span>+\f[R]+.fi+.PP+This will work in all output formats that support small caps.+.SS Math+.SS Extension: \f[C]tex_math_dollars\f[R]+.PP+Anything between two \f[C]$\f[R] characters will be treated as TeX math.+The opening \f[C]$\f[R] must have a non-space character immediately to+its right, while the closing \f[C]$\f[R] must have a non-space character+immediately to its left, and must not be followed immediately by a+digit.+Thus, \f[C]$20,000 and $30,000\f[R] won\[aq]t parse as math.+If for some reason you need to enclose text in literal \f[C]$\f[R]+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+LaTeX+It will appear verbatim surrounded by \f[C]\[rs](...\[rs])\f[R] (for+inline math) or \f[C]\[rs][...\[rs]]\f[R] (for display math).+.TP+Markdown, Emacs Org mode, ConTeXt, ZimWiki+It will appear verbatim surrounded by \f[C]$...$\f[R] (for inline math)+or \f[C]$$...$$\f[R] (for display math).+.TP+XWiki+It will appear verbatim surrounded by+\f[C]{{formula}}..{{/formula}}\f[R].+.TP+reStructuredText+It will be rendered using an interpreted text role \f[C]:math:\f[R].+.TP+AsciiDoc+For AsciiDoc output format (\f[C]-t asciidoc\f[R]) it will appear+verbatim surrounded by \f[C]latexmath:[$...$]\f[R] (for inline math) or+\f[C][latexmath]++++\[rs][...\[rs]]+++\f[R] (for display math).+For AsciiDoctor output format (\f[C]-t asciidoctor\f[R]) the LaTex+delimiters (\f[C]$..$\f[R] and \f[C]\[rs][..\[rs]]\f[R]) are omitted.+.TP+Texinfo+It will be rendered inside a \f[C]\[at]math\f[R] command.+.TP+roff man, Jira markup+It will be rendered verbatim without \f[C]$\f[R]\[aq]s.+.TP+MediaWiki, DokuWiki+It will be rendered inside \f[C]<math>\f[R] tags.+.TP+Textile+It will be rendered inside \f[C]<span class=\[dq]math\[dq]>\f[R] tags.+.TP+RTF, OpenDocument+It will be rendered, if possible, using Unicode characters, and will+otherwise appear verbatim.+.TP+ODT+It will be rendered, if possible, using MathML.+.TP+DocBook+If the \f[C]--mathml\f[R] flag is used, it will be rendered using MathML+in an \f[C]inlineequation\f[R] or \f[C]informalequation\f[R] tag.+Otherwise it will be rendered, if possible, using Unicode characters.+.TP+Docx+It will be rendered using OMML math markup.+.TP+FictionBook2+If the \f[C]--webtex\f[R] option is used, formulas are rendered as+images using CodeCogs or other compatible web service, downloaded and+embedded in the e-book.+Otherwise, they will appear verbatim.+.TP+HTML, Slidy, DZSlides, S5, EPUB+The way math is rendered in HTML will depend on the command-line options+selected.+Therefore see Math rendering in HTML above.+.SS Raw HTML+.SS Extension: \f[C]raw_html\f[R]+.PP+Markdown allows you to insert raw HTML (or DocBook) anywhere in a+document (except verbatim contexts, where \f[C]<\f[R], \f[C]>\f[R], and+\f[C]&\f[R] are interpreted literally).+(Technically this is not an extension, since standard Markdown allows+it, but it has been made an extension so that it can be disabled if+desired.)+.PP+The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,+DZSlides, EPUB, Markdown, CommonMark, Emacs Org mode, and Textile+output, and suppressed in other formats.+.PP+For a more explicit way of including raw HTML in a Markdown document,+see the \f[C]raw_attribute\f[R] extension.+.PP+In the CommonMark format, if \f[C]raw_html\f[R] is enabled,+superscripts, subscripts, strikeouts and small capitals will be+represented as HTML.+Otherwise, plain-text fallbacks will be used.+Note that even if \f[C]raw_html\f[R] is disabled, tables will be+rendered with HTML syntax if they cannot use pipe syntax.+.SS Extension: \f[C]markdown_in_html_blocks\f[R]+.PP+Standard Markdown allows you to include HTML \[dq]blocks\[dq]: 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[R] does not signify emphasis.+.PP+Pandoc behaves this way when the \f[C]markdown_strict\f[R] format is+used; 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[R]+.fi+.PP+into+.IP+.nf+\f[C]+<table>+<tr>+<td><em>one</em></td>+<td><a href=\[dq]http://google.com\[dq]>a link</a></td>+</tr>+</table>+\f[R]+.fi+.PP+whereas \f[C]Markdown.pl\f[R] will preserve it as is.+.PP+There is one exception to this rule: text between \f[C]<script>\f[R] and+\f[C]<style>\f[R] 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[R] tags without preventing it from being interpreted as+Markdown.+.SS Extension: \f[C]native_divs\f[R]+.PP+Use native pandoc \f[C]Div\f[R] blocks for content inside+\f[C]<div>\f[R] tags.+For the most part this should give the same output as+\f[C]markdown_in_html_blocks\f[R], but it makes it easier to write+pandoc filters to manipulate groups of blocks.+.SS Extension: \f[C]native_spans\f[R]+.PP+Use native pandoc \f[C]Span\f[R] blocks for content inside+\f[C]<span>\f[R] tags.+For the most part this should give the same output as+\f[C]raw_html\f[R], but it makes it easier to write pandoc filters to+manipulate groups of inlines.+.SS Extension: \f[C]raw_tex\f[R]+.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 \[rs]cite{jones.1967}.+\f[R]+.fi+.PP+Note that in LaTeX environments, like+.IP+.nf+\f[C]+\[rs]begin{tabular}{|l|l|}\[rs]hline+Age & Frequency \[rs]\[rs] \[rs]hline+18--25  & 15 \[rs]\[rs]+26--35  & 33 \[rs]\[rs]+36--45  & 22 \[rs]\[rs] \[rs]hline+\[rs]end{tabular}+\f[R]+.fi+.PP+the material between the begin and end tags will be interpreted as raw+LaTeX, not as Markdown.+.PP+For a more explicit and flexible way of including raw TeX in a Markdown+document, see the \f[C]raw_attribute\f[R] extension.+.PP+Inline LaTeX is ignored in output formats other than Markdown, LaTeX,+Emacs Org mode, and ConTeXt.+.SS Generic raw attribute+.SS Extension: \f[C]raw_attribute\f[R]+.PP+Inline spans and fenced code blocks with a special kind of attribute+will be parsed as raw content with the designated format.+For example, the following produces a raw roff \f[C]ms\f[R] block:+.IP+.nf+\f[C]+\[ga]\[ga]\[ga]{=ms}+\&.MYMACRO+blah blah+\[ga]\[ga]\[ga]+\f[R]+.fi+.PP+And the following produces a raw \f[C]html\f[R] inline element:+.IP+.nf+\f[C]+This is \[ga]<a>html</a>\[ga]{=html}+\f[R]+.fi+.PP+This can be useful to insert raw xml into \f[C]docx\f[R] documents, e.g.+a pagebreak:+.IP+.nf+\f[C]+\[ga]\[ga]\[ga]{=openxml}+<w:p>+  <w:r>+    <w:br w:type=\[dq]page\[dq]/>+  </w:r>+</w:p>+\[ga]\[ga]\[ga]+\f[R]+.fi+.PP+The format name should match the target format name (see+\f[C]-t/--to\f[R], above, for a list, or use+\f[C]pandoc --list-output-formats\f[R]).+Use \f[C]openxml\f[R] for \f[C]docx\f[R] output, \f[C]opendocument\f[R]+for \f[C]odt\f[R] output, \f[C]html5\f[R] for \f[C]epub3\f[R] output,+\f[C]html4\f[R] for \f[C]epub2\f[R] output, and \f[C]latex\f[R],+\f[C]beamer\f[R], \f[C]ms\f[R], or \f[C]html5\f[R] for \f[C]pdf\f[R]+output (depending on what you use for \f[C]--pdf-engine\f[R]).+.PP+This extension presupposes that the relevant kind of inline code or+fenced code block is enabled.+Thus, for example, to use a raw attribute with a backtick code block,+\f[C]backtick_code_blocks\f[R] must be enabled.+.PP+The raw attribute cannot be combined with regular attributes.+.SS LaTeX macros+.SS Extension: \f[C]latex_macros\f[R]+.PP+When this extension is enabled, pandoc will parse LaTeX macro+definitions and apply the resulting macros to all LaTeX math and raw+LaTeX.+So, for example, the following will work in all output formats, not just+LaTeX:+.IP+.nf+\f[C]+\[rs]newcommand{\[rs]tuple}[1]{\[rs]langle #1 \[rs]rangle}++$\[rs]tuple{a, b, c}$+\f[R]+.fi+.PP+Note that LaTeX macros will not be applied if they occur inside a raw+span or block marked with the \f[C]raw_attribute\f[R] extension.+.PP+When \f[C]latex_macros\f[R] is disabled, the raw LaTeX and math will not+have macros applied.+This is usually a better approach when you are targeting LaTeX or PDF.+.PP+Macro definitions in LaTeX will be passed through as raw LaTeX only if+\f[C]latex_macros\f[R] is not enabled.+Macro definitions in Markdown source (or other formats allowing+\f[C]raw_tex\f[R]) will be passed through regardless of whether+\f[C]latex_macros\f[R] is enabled.+.SS 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\[at]green.eggs.ham>+\f[R]+.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 \[dq]click here for a good time!\[dq]).+\f[R]+.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.+.PP+Email addresses in inline links are not autodetected, so they have to be+prefixed with \f[C]mailto\f[R]:+.IP+.nf+\f[C]+[Write me!](mailto:sam\[at]green.eggs.ham)+\f[R]+.fi+.SS Reference links+.PP+An \f[I]explicit\f[R] 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 cannot be space between the two unless the+\f[C]spaced_reference_links\f[R] extension is enabled.) The link+definition 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.+The label must not be parseable as a citation (assuming the+\f[C]citations\f[R] extension is enabled): citations take precedence+over link labels.+.PP+Here are some examples:+.IP+.nf+\f[C]+[my label 1]: /foo/bar.html  \[dq]My title, optional\[dq]+[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[R]+.fi+.PP+The URL may optionally be surrounded by angle brackets:+.IP+.nf+\f[C]+[my label 5]: <http://foo.bar.baz>+\f[R]+.fi+.PP+The title may go on the next line:+.IP+.nf+\f[C]+[my label 3]: http://fsf.org+  \[dq]The free software foundation\[dq]+\f[R]+.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[R]+.fi+.PP+In an \f[I]implicit\f[R] reference link, the second pair of brackets is+empty:+.IP+.nf+\f[C]+See [my website][].++[my website]: http://foo.bar.baz+\f[R]+.fi+.PP+Note: In \f[C]Markdown.pl\f[R] and most other Markdown implementations,+reference link definitions cannot occur in nested constructions such as+list items or block quotes.+Pandoc lifts this arbitrary seeming restriction.+So the following is fine in pandoc, though not in most other+implementations:+.IP+.nf+\f[C]+> My block [quote].+>+> [quote]: /foo+\f[R]+.fi+.SS Extension: \f[C]shortcut_reference_links\f[R]+.PP+In a \f[I]shortcut\f[R] reference link, the second pair of brackets may+be omitted entirely:+.IP+.nf+\f[C]+See [my website].++[my website]: http://foo.bar.baz+\f[R]+.fi+.SS Internal links+.PP+To link to another section of the same document, use the automatically+generated identifier (see Heading identifiers).+For example:+.IP+.nf+\f[C]+See the [Introduction](#introduction).+\f[R]+.fi+.PP+or+.IP+.nf+\f[C]+See the [Introduction].++[Introduction]: #introduction+\f[R]+.fi+.PP+Internal links are currently supported for HTML formats (including HTML+slide shows and EPUB), LaTeX, and ConTeXt.+.SS Images+.PP+A link immediately preceded by a \f[C]!\f[R] 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 \[dq]Voyage to the moon\[dq])++![movie reel]++[movie reel]: movie.gif+\f[R]+.fi+.SS Extension: \f[C]implicit_figures\f[R]+.PP+An image with nonempty alt text, occurring by itself in a paragraph,+will be rendered as a figure with a caption.+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[R]+.fi+.PP+How this is rendered depends on the output format.+Some output formats (e.g.+RTF) do not yet support figures.+In those formats, you\[aq]ll just get an image in a paragraph by itself,+with no caption.+.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)\[rs]+\f[R]+.fi+.PP+Note that in reveal.js slide shows, an image in a paragraph by itself+that has the \f[C]stretch\f[R] class will fill the screen, and the+caption and figure tags will be omitted.+.SS Extension: \f[C]link_attributes\f[R]+.PP+Attributes can be set on links and images:+.IP+.nf+\f[C]+An inline ![image](foo.jpg){#id .class width=30 height=20px}+and a reference ![image][ref] with attributes.++[ref]: foo.jpg \[dq]optional title\[dq] {#id .class key=val key2=\[dq]val 2\[dq]}+\f[R]+.fi+.PP+(This syntax is compatible with PHP Markdown Extra when only+\f[C]#id\f[R] and \f[C].class\f[R] are used.)+.PP+For HTML and EPUB, all known HTML5 attributes except \f[C]width\f[R] and+\f[C]height\f[R] (but including \f[C]srcset\f[R] and \f[C]sizes\f[R])+are passed through as is.+Unknown attributes are passed through as custom attributes, with+\f[C]data-\f[R] prepended.+The other writers ignore attributes that are not specifically supported+by their output format.+.PP+The \f[C]width\f[R] and \f[C]height\f[R] attributes on images are+treated specially.+When used without a unit, the unit is assumed to be pixels.+However, any of the following unit identifiers can be used:+\f[C]px\f[R], \f[C]cm\f[R], \f[C]mm\f[R], \f[C]in\f[R], \f[C]inch\f[R]+and \f[C]%\f[R].+There must not be any spaces between the number and the unit.+For example:+.IP+.nf+\f[C]+![](file.jpg){ width=50% }+\f[R]+.fi+.IP \[bu] 2+Dimensions are converted to inches for output in page-based formats like+LaTeX.+Dimensions are converted to pixels for output in HTML-like formats.+Use the \f[C]--dpi\f[R] option to specify the number of pixels per inch.+The default is 96dpi.+.IP \[bu] 2+The \f[C]%\f[R] unit is generally relative to some available space.+For example the above example will render to the following.+.RS 2+.IP \[bu] 2+HTML:+\f[C]<img href=\[dq]file.jpg\[dq] style=\[dq]width: 50%;\[dq] />\f[R]+.IP \[bu] 2+LaTeX:+\f[C]\[rs]includegraphics[width=0.5\[rs]textwidth,height=\[rs]textheight]{file.jpg}\f[R]+(If you\[aq]re using a custom template, you need to configure+\f[C]graphicx\f[R] as in the default template.)+.IP \[bu] 2+ConTeXt:+\f[C]\[rs]externalfigure[file.jpg][width=0.5\[rs]textwidth]\f[R]+.RE+.IP \[bu] 2+Some output formats have a notion of a class (ConTeXt) or a unique+identifier (LaTeX \f[C]\[rs]caption\f[R]), or both (HTML).+.IP \[bu] 2+When no \f[C]width\f[R] or \f[C]height\f[R] attributes are specified,+the fallback is to look at the image resolution and the dpi metadata+embedded in the image file.+.SS Divs and Spans+.PP+Using the \f[C]native_divs\f[R] and \f[C]native_spans\f[R] extensions+(see above), HTML syntax can be used as part of markdown to create+native \f[C]Div\f[R] and \f[C]Span\f[R] elements in the pandoc AST (as+opposed to raw HTML).+However, there is also nicer syntax available:+.SS Extension: \f[C]fenced_divs\f[R]+.PP+Allow special fenced syntax for native \f[C]Div\f[R] blocks.+A Div starts with a fence containing at least three consecutive colons+plus some attributes.+The attributes may optionally be followed by another string of+consecutive colons.+The attribute syntax is exactly as in fenced code blocks (see Extension:+\f[C]fenced_code_attributes\f[R]).+As with fenced code blocks, one can use either attributes in curly+braces or a single unbraced word, which will be treated as a class name.+The Div ends with another line containing a string of at least three+consecutive colons.+The fenced Div should be separated by blank lines from preceding and+following blocks.+.PP+Example:+.IP+.nf+\f[C]+::::: {#special .sidebar}+Here is a paragraph.++And another.+:::::+\f[R]+.fi+.PP+Fenced divs can be nested.+Opening fences are distinguished because they \f[I]must\f[R] have+attributes:+.IP+.nf+\f[C]+::: Warning ::::::+This is a warning.++::: Danger+This is a warning within a warning.+:::+::::::::::::::::::+\f[R]+.fi+.PP+Fences without attributes are always closing fences.+Unlike with fenced code blocks, the number of colons in the closing+fence need not match the number in the opening fence.+However, it can be helpful for visual clarity to use fences of different+lengths to distinguish nested divs from their parents.+.SS Extension: \f[C]bracketed_spans\f[R]+.PP+A bracketed sequence of inlines, as one would use to begin a link, will+be treated as a \f[C]Span\f[R] with attributes if it is followed+immediately by attributes:+.IP+.nf+\f[C]+[This is *some text*]{.class key=\[dq]val\[dq]}+\f[R]+.fi+.SS Footnotes+.SS Extension: \f[C]footnotes\f[R]+.PP+Pandoc\[aq]s Markdown allows footnotes, using the following syntax:+.IP+.nf+\f[C]+Here is a footnote reference,[\[ha]1] and another.[\[ha]longnote]++[\[ha]1]: Here is the footnote.++[\[ha]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[R]+.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.).+Each footnote should be separated from surrounding content (including+other footnotes) by blank lines.+.SS Extension: \f[C]inline_notes\f[R]+.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.\[ha][Inlines notes are easier to write, since+you don\[aq]t have to pick an identifier and move down to type the+note.]+\f[R]+.fi+.PP+Inline and regular footnotes may be mixed freely.+.SS Citations+.SS Extension: \f[C]citations\f[R]+.PP+Using an external filter, \f[C]pandoc-citeproc\f[R], pandoc can+automatically generate citations and a bibliography in a number of+styles.+Basic usage is+.IP+.nf+\f[C]+pandoc --filter pandoc-citeproc myinput.txt+\f[R]+.fi+.PP+In order to use this feature, you will need to specify a bibliography+file using the \f[C]bibliography\f[R] metadata field in a YAML metadata+section, or \f[C]--bibliography\f[R] command line argument.+You can supply multiple \f[C]--bibliography\f[R] arguments or set+\f[C]bibliography\f[R] metadata field to YAML array, if you want to use+multiple bibliography files.+The bibliography may have any of these formats:+.PP+.TS+tab(@);+l l.+T{+Format+T}@T{+File extension+T}+_+T{+BibLaTeX+T}@T{+\&.bib+T}+T{+BibTeX+T}@T{+\&.bibtex+T}+T{+Copac+T}@T{+\&.copac+T}+T{+CSL JSON+T}@T{+\&.json+T}+T{+CSL YAML+T}@T{+\&.yaml+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{+MODS+T}@T{+\&.mods+T}+T{+RIS+T}@T{+\&.ris+T}+.TE+.PP+Note that \f[C].bib\f[R] can be used with both BibTeX and BibLaTeX+files; use \f[C].bibtex\f[R] to force BibTeX.+.PP+Note that \f[C]pandoc-citeproc --bib2json\f[R] and+\f[C]pandoc-citeproc --bib2yaml\f[R] can produce \f[C].json\f[R] and+\f[C].yaml\f[R] files from any of the supported formats.+.PP+In-field markup: In BibTeX and BibLaTeX databases, pandoc-citeproc+parses a subset of LaTeX markup; in CSL YAML databases, pandoc Markdown;+and in CSL JSON databases, an HTML-like markup:+.TP+\f[B]\f[CB]<i>...</i>\f[B]\f[R]+italics+.TP+\f[B]\f[CB]<b>...</b>\f[B]\f[R]+bold+.TP+\f[B]\f[CB]<span style=\[dq]font-variant:small-caps;\[dq]>...</span>\f[B]\f[R] or \f[B]\f[CB]<sc>...</sc>\f[B]\f[R]+small capitals+.TP+\f[B]\f[CB]<sub>...</sub>\f[B]\f[R]+subscript+.TP+\f[B]\f[CB]<sup>...</sup>\f[B]\f[R]+superscript+.TP+\f[B]\f[CB]<span class=\[dq]nocase\[dq]>...</span>\f[B]\f[R]+prevent a phrase from being capitalized as title case+.PP+\f[C]pandoc-citeproc -j\f[R] and \f[C]-y\f[R] interconvert the CSL JSON+and CSL YAML formats as far as possible.+.PP+As an alternative to specifying a bibliography file using+\f[C]--bibliography\f[R] or the YAML metadata field+\f[C]bibliography\f[R], you can include the citation data directly in+the \f[C]references\f[R] field of the document\[aq]s YAML metadata.+The field should contain an array of YAML-encoded references, for+example:+.IP+.nf+\f[C]+---+references:+- type: article-journal+  id: WatsonCrick1953+  author:+  - family: Watson+    given: J. D.+  - family: Crick+    given: F. H. C.+  issued:+    date-parts:+    - - 1953+      - 4+      - 25+  title: \[aq]Molecular structure of nucleic acids: a structure for deoxyribose+    nucleic acid\[aq]+  title-short: Molecular structure of nucleic acids+  container-title: Nature+  volume: 171+  issue: 4356+  page: 737-738+  DOI: 10.1038/171737a0+  URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html+  language: en-GB+\&...+\f[R]+.fi+.PP+(\f[C]pandoc-citeproc --bib2yaml\f[R] can produce these from a+bibliography file in one of the supported formats.)+.PP+Citations and references can be formatted using any style supported by+the Citation Style Language, listed in the Zotero Style Repository.+These files are specified using the \f[C]--csl\f[R] option or the+\f[C]csl\f[R] metadata field.+By default, \f[C]pandoc-citeproc\f[R] will use the Chicago Manual of+Style author-date format.+The CSL project provides further information on finding and editing+styles.+.PP+To make your citations hyperlinks to the corresponding bibliography+entries, add \f[C]link-citations: true\f[R] to your YAML metadata.+.PP+Citations go inside square brackets and are separated by semicolons.+Each citation must have a key, composed of \[aq]\[at]\[aq] + the+citation identifier from the database, and may optionally have a prefix,+a locator, and a suffix.+The citation key must begin with a letter, digit, or \f[C]_\f[R], and+may contain alphanumerics, \f[C]_\f[R], and internal punctuation+characters (\f[C]:.#$%&-+?<>\[ti]/\f[R]).+Here are some examples:+.IP+.nf+\f[C]+Blah blah [see \[at]doe99, pp. 33-35; also \[at]smith04, chap. 1].++Blah blah [\[at]doe99, pp. 33-35, 38-39 and *passim*].++Blah blah [\[at]smith04; \[at]doe99].+\f[R]+.fi+.PP+\f[C]pandoc-citeproc\f[R] detects locator terms in the CSL locale files.+Either abbreviated or unabbreviated forms are accepted.+In the \f[C]en-US\f[R] locale, locator terms can be written in either+singular or plural forms, as \f[C]book\f[R],+\f[C]bk.\f[R]/\f[C]bks.\f[R]; \f[C]chapter\f[R],+\f[C]chap.\f[R]/\f[C]chaps.\f[R]; \f[C]column\f[R],+\f[C]col.\f[R]/\f[C]cols.\f[R]; \f[C]figure\f[R],+\f[C]fig.\f[R]/\f[C]figs.\f[R]; \f[C]folio\f[R],+\f[C]fol.\f[R]/\f[C]fols.\f[R]; \f[C]number\f[R],+\f[C]no.\f[R]/\f[C]nos.\f[R]; \f[C]line\f[R],+\f[C]l.\f[R]/\f[C]ll.\f[R]; \f[C]note\f[R], \f[C]n.\f[R]/\f[C]nn.\f[R];+\f[C]opus\f[R], \f[C]op.\f[R]/\f[C]opp.\f[R]; \f[C]page\f[R],+\f[C]p.\f[R]/\f[C]pp.\f[R]; \f[C]paragraph\f[R],+\f[C]para.\f[R]/\f[C]paras.\f[R]; \f[C]part\f[R],+\f[C]pt.\f[R]/\f[C]pts.\f[R]; \f[C]section\f[R],+\f[C]sec.\f[R]/\f[C]secs.\f[R]; \f[C]sub verbo\f[R],+\f[C]s.v.\f[R]/\f[C]s.vv.\f[R]; \f[C]verse\f[R],+\f[C]v.\f[R]/\f[C]vv.\f[R]; \f[C]volume\f[R],+\f[C]vol.\f[R]/\f[C]vols.\f[R]; \f[C]\[ps]\f[R]/\f[C]\[ps]\[ps]\f[R];+\f[C]\[sc]\f[R]/\f[C]\[sc]\[sc]\f[R].+If no locator term is used, \[dq]page\[dq] is assumed.+.PP+\f[C]pandoc-citeproc\f[R] will use heuristics to distinguish the locator+from the suffix.+In complex cases, the locator can be enclosed in curly braces (using+\f[C]pandoc-citeproc\f[R] 0.15 and higher only):+.IP+.nf+\f[C]+[\[at]smith{ii, A, D-Z}, with a suffix]+[\[at]smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]+\f[R]+.fi+.PP+A minus sign (\f[C]-\f[R]) before the \f[C]\[at]\f[R] 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 [-\[at]smith04].+\f[R]+.fi+.PP+You can also write an in-text citation, as follows:+.IP+.nf+\f[C]+\[at]smith04 says blah.++\[at]smith04 [p. 33] says blah.+\f[R]+.fi+.PP+If the style calls for a list of works cited, it will be placed in a div+with id \f[C]refs\f[R], if one exists:+.IP+.nf+\f[C]+::: {#refs}+:::+\f[R]+.fi+.PP+Otherwise, it will be placed at the end of the document.+Generation of the bibliography can be suppressed by setting+\f[C]suppress-bibliography: true\f[R] in the YAML metadata.+.PP+If you wish the bibliography to have a section heading, you can set+\f[C]reference-section-title\f[R] in the metadata, or put the heading at+the beginning of the div with id \f[C]refs\f[R] (if you are using it) or+at the end of your document:+.IP+.nf+\f[C]+last paragraph...++# References+\f[R]+.fi+.PP+The bibliography will be inserted after this heading.+Note that the \f[C]unnumbered\f[R] class will be added to this heading,+so that the section will not be numbered.+.PP+If you want to include items in the bibliography without actually citing+them in the body text, you can define a dummy \f[C]nocite\f[R] metadata+field and put the citations there:+.IP+.nf+\f[C]+---+nocite: |+  \[at]item1, \[at]item2+\&...++\[at]item3+\f[R]+.fi+.PP+In this example, the document will contain a citation for+\f[C]item3\f[R] only, but the bibliography will contain entries for+\f[C]item1\f[R], \f[C]item2\f[R], and \f[C]item3\f[R].+.PP+It is possible to create a bibliography with all the citations, whether+or not they appear in the document, by using a wildcard:+.IP+.nf+\f[C]+---+nocite: |+  \[at]*+\&...+\f[R]+.fi+.PP+For LaTeX output, you can also use \f[C]natbib\f[R] or+\f[C]biblatex\f[R] to render the bibliography.+In order to do so, specify bibliography files as outlined above, and add+\f[C]--natbib\f[R] or \f[C]--biblatex\f[R] argument to \f[C]pandoc\f[R]+invocation.+Bear in mind that bibliography files have to be in respective format+(either BibTeX or BibLaTeX).+.PP+For more information, see the pandoc-citeproc man page.+.SS Non-pandoc extensions+.PP+The following Markdown syntax extensions are not enabled by default in+pandoc, but may be enabled by adding \f[C]+EXTENSION\f[R] to the format+name, where \f[C]EXTENSION\f[R] is the name of the extension.+Thus, for example, \f[C]markdown+hard_line_breaks\f[R] is Markdown with+hard line breaks.+.SS Extension: \f[C]old_dashes\f[R]+.PP+Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:+\f[C]-\f[R] before a numeral is an en-dash, and \f[C]--\f[R] is an+em-dash.+This option only has an effect if \f[C]smart\f[R] is enabled.+It is selected automatically for \f[C]textile\f[R] input.+.SS Extension: \f[C]angle_brackets_escapable\f[R]+.PP+Allow \f[C]<\f[R] and \f[C]>\f[R] to be backslash-escaped, as they can+be in GitHub flavored Markdown but not original Markdown.+This is implied by pandoc\[aq]s default \f[C]all_symbols_escapable\f[R].+.SS Extension: \f[C]lists_without_preceding_blankline\f[R]+.PP+Allow a list to occur right after a paragraph, with no intervening blank+space.+.SS Extension: \f[C]four_space_rule\f[R]+.PP+Selects the pandoc <= 2.0 behavior for parsing lists, so that four+spaces indent are needed for list item continuation paragraphs.+.SS Extension: \f[C]spaced_reference_links\f[R]+.PP+Allow whitespace between the two components of a reference link, for+example,+.IP+.nf+\f[C]+[foo] [bar].+\f[R]+.fi+.SS Extension: \f[C]hard_line_breaks\f[R]+.PP+Causes all newlines within a paragraph to be interpreted as hard line+breaks instead of spaces.+.SS Extension: \f[C]ignore_line_breaks\f[R]+.PP+Causes newlines within a paragraph to be ignored, rather than being+treated as spaces or as hard line breaks.+This option is intended for use with East Asian languages where spaces+are not used between words, but text is divided into lines for+readability.+.SS Extension: \f[C]east_asian_line_breaks\f[R]+.PP+Causes newlines within a paragraph to be ignored, rather than being+treated as spaces or as hard line breaks, when they occur between two+East Asian wide characters.+This is a better choice than \f[C]ignore_line_breaks\f[R] for texts that+include a mix of East Asian wide characters and other characters.+.SS Extension: \f[C]emoji\f[R]+.PP+Parses textual emojis like \f[C]:smile:\f[R] as Unicode emoticons.+.SS Extension: \f[C]tex_math_single_backslash\f[R]+.PP+Causes anything between \f[C]\[rs](\f[R] and \f[C]\[rs])\f[R] to be+interpreted as inline TeX math, and anything between \f[C]\[rs][\f[R]+and \f[C]\[rs]]\f[R] to be interpreted as display TeX math.+Note: a drawback of this extension is that it precludes escaping+\f[C](\f[R] and \f[C][\f[R].+.SS Extension: \f[C]tex_math_double_backslash\f[R]+.PP+Causes anything between \f[C]\[rs]\[rs](\f[R] and \f[C]\[rs]\[rs])\f[R]+to be interpreted as inline TeX math, and anything between+\f[C]\[rs]\[rs][\f[R] and \f[C]\[rs]\[rs]]\f[R] to be interpreted as+display TeX math.+.SS Extension: \f[C]markdown_attribute\f[R]+.PP+By default, pandoc interprets material inside block-level tags as+Markdown.+This extension changes the behavior so that Markdown is only parsed+inside block-level tags if the tags have the attribute+\f[C]markdown=1\f[R].+.SS Extension: \f[C]mmd_title_block\f[R]+.PP+Enables a MultiMarkdown style title block at the top of the document,+for example:+.IP+.nf+\f[C]+Title:   My title+Author:  John Doe+Date:    September 1, 2008+Comment: This is a sample mmd title block, with+         a field spanning multiple lines.+\f[R]+.fi+.PP+See the MultiMarkdown documentation for details.+If \f[C]pandoc_title_block\f[R] or \f[C]yaml_metadata_block\f[R] is+enabled, it will take precedence over \f[C]mmd_title_block\f[R].+.SS Extension: \f[C]abbreviations\f[R]+.PP+Parses PHP Markdown Extra abbreviation keys, like+.IP+.nf+\f[C]+*[HTML]: Hypertext Markup Language+\f[R]+.fi+.PP+Note that the pandoc document model does not support abbreviations, so+if this extension is enabled, abbreviation keys are simply skipped (as+opposed to being parsed as paragraphs).+.SS Extension: \f[C]autolink_bare_uris\f[R]+.PP+Makes all absolute URIs into links, even when not surrounded by pointy+braces \f[C]<...>\f[R].+.SS Extension: \f[C]mmd_link_attributes\f[R]+.PP+Parses multimarkdown style key-value attributes on link and image+references.+This extension should not be confused with the \f[C]link_attributes\f[R]+extension.+.IP+.nf+\f[C]+This is a reference ![image][ref] with multimarkdown attributes.++[ref]: http://path.to/image \[dq]Image title\[dq] width=20px height=30px+       id=myId class=\[dq]myClass1 myClass2\[dq]+\f[R]+.fi+.SS Extension: \f[C]mmd_header_identifiers\f[R]+.PP+Parses multimarkdown style heading identifiers (in square brackets,+after the heading but before any trailing \f[C]#\f[R]s in an ATX+heading).+.SS Extension: \f[C]compact_definition_lists\f[R]+.PP+Activates the definition list syntax of pandoc 1.12.x and earlier.+This syntax differs from the one described above under Definition lists+in several respects:+.IP \[bu] 2+No blank line is required between consecutive items of the definition+list.+.IP \[bu] 2+To get a \[dq]tight\[dq] or \[dq]compact\[dq] list, omit space between+consecutive items; the space between a term and its definition does not+affect anything.+.IP \[bu] 2+Lazy wrapping of paragraphs is not allowed: the entire definition must+be indented four spaces.+.SS Extension: \f[C]gutenberg\f[R]+.PP+Use Project Gutenberg conventions for \f[C]plain\f[R] output: all-caps+for strong emphasis, surround by underscores for regular emphasis, add+extra blank space around headings.+.SS Markdown variants+.PP+In addition to pandoc\[aq]s extended Markdown, the following Markdown+variants are supported:+.TP+\f[B]\f[CB]markdown_phpextra\f[B]\f[R] (PHP Markdown Extra)+\f[C]footnotes\f[R], \f[C]pipe_tables\f[R], \f[C]raw_html\f[R],+\f[C]markdown_attribute\f[R], \f[C]fenced_code_blocks\f[R],+\f[C]definition_lists\f[R], \f[C]intraword_underscores\f[R],+\f[C]header_attributes\f[R], \f[C]link_attributes\f[R],+\f[C]abbreviations\f[R], \f[C]shortcut_reference_links\f[R],+\f[C]spaced_reference_links\f[R].+.TP+\f[B]\f[CB]markdown_github\f[B]\f[R] (deprecated GitHub-Flavored Markdown)+\f[C]pipe_tables\f[R], \f[C]raw_html\f[R], \f[C]fenced_code_blocks\f[R],+\f[C]auto_identifiers\f[R], \f[C]gfm_auto_identifiers\f[R],+\f[C]backtick_code_blocks\f[R], \f[C]autolink_bare_uris\f[R],+\f[C]space_in_atx_header\f[R], \f[C]intraword_underscores\f[R],+\f[C]strikeout\f[R], \f[C]task_lists\f[R], \f[C]emoji\f[R],+\f[C]shortcut_reference_links\f[R], \f[C]angle_brackets_escapable\f[R],+\f[C]lists_without_preceding_blankline\f[R].+.TP+\f[B]\f[CB]markdown_mmd\f[B]\f[R] (MultiMarkdown)+\f[C]pipe_tables\f[R], \f[C]raw_html\f[R], \f[C]markdown_attribute\f[R],+\f[C]mmd_link_attributes\f[R], \f[C]tex_math_double_backslash\f[R],+\f[C]intraword_underscores\f[R], \f[C]mmd_title_block\f[R],+\f[C]footnotes\f[R], \f[C]definition_lists\f[R],+\f[C]all_symbols_escapable\f[R], \f[C]implicit_header_references\f[R],+\f[C]auto_identifiers\f[R], \f[C]mmd_header_identifiers\f[R],+\f[C]shortcut_reference_links\f[R], \f[C]implicit_figures\f[R],+\f[C]superscript\f[R], \f[C]subscript\f[R],+\f[C]backtick_code_blocks\f[R], \f[C]spaced_reference_links\f[R],+\f[C]raw_attribute\f[R].+.TP+\f[B]\f[CB]markdown_strict\f[B]\f[R] (Markdown.pl)+\f[C]raw_html\f[R], \f[C]shortcut_reference_links\f[R],+\f[C]spaced_reference_links\f[R].+.PP+We also support \f[C]commonmark\f[R] and \f[C]gfm\f[R] (GitHub-Flavored+Markdown, which is implemented as a set of extensions on+\f[C]commonmark\f[R]).+.PP+Note, however, that \f[C]commonmark\f[R] and \f[C]gfm\f[R] have limited+support for extensions.+Only those listed below (and \f[C]smart\f[R], \f[C]raw_tex\f[R], and+\f[C]hard_line_breaks\f[R]) will work.+The extensions can, however, all be individually disabled.+Also, \f[C]raw_tex\f[R] only affects \f[C]gfm\f[R] output, not input.+.TP+\f[B]\f[CB]gfm\f[B]\f[R] (GitHub-Flavored Markdown)+\f[C]pipe_tables\f[R], \f[C]raw_html\f[R], \f[C]fenced_code_blocks\f[R],+\f[C]auto_identifiers\f[R], \f[C]gfm_auto_identifiers\f[R],+\f[C]backtick_code_blocks\f[R], \f[C]autolink_bare_uris\f[R],+\f[C]space_in_atx_header\f[R], \f[C]intraword_underscores\f[R],+\f[C]strikeout\f[R], \f[C]task_lists\f[R], \f[C]emoji\f[R],+\f[C]shortcut_reference_links\f[R], \f[C]angle_brackets_escapable\f[R],+\f[C]lists_without_preceding_blankline\f[R].+.SH PRODUCING 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 five ways to do this, using S5, DZSlides, Slidy, Slideous, or+reveal.js.+You can also produce a PDF slide show using LaTeX \f[C]beamer\f[R], or+slides shows in Microsoft PowerPoint format.+.PP+Here\[aq]s the Markdown source for a simple slide show,+\f[C]habits.txt\f[R]:+.IP+.nf+\f[C]+% Habits+% John Doe+% March 22, 2005++# In the morning++## Getting up++- Turn off alarm+- Get out of bed++## Breakfast++- Eat eggs+- Drink coffee++# In the evening++## Dinner++- Eat spaghetti+- Drink wine++------------------++![picture of spaghetti](images/spaghetti.jpg)++## Going to sleep++- Get in bed+- Count sheep+\f[R]+.fi+.PP+To produce an HTML/JavaScript slide show, simply type+.IP+.nf+\f[C]+pandoc -t FORMAT -s habits.txt -o habits.html+\f[R]+.fi+.PP+where \f[C]FORMAT\f[R] is either \f[C]s5\f[R], \f[C]slidy\f[R],+\f[C]slideous\f[R], \f[C]dzslides\f[R], or \f[C]revealjs\f[R].+.PP+For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with+the \f[C]-s/--standalone\f[R] option embeds a link to JavaScript and CSS+files, which are assumed to be available at the relative path+\f[C]s5/default\f[R] (for S5), \f[C]slideous\f[R] (for Slideous),+\f[C]reveal.js\f[R] (for reveal.js), or at the Slidy website at+\f[C]w3.org\f[R] (for Slidy).+(These paths can be changed by setting the \f[C]slidy-url\f[R],+\f[C]slideous-url\f[R], \f[C]revealjs-url\f[R], or \f[C]s5-url\f[R]+variables; see Variables for HTML slides, above.) For DZSlides, the+(relatively short) JavaScript and CSS are included in the file by+default.+.PP+With all HTML slide formats, the \f[C]--self-contained\f[R] option can+be used to produce a single file that contains all of the data necessary+to display the slide show, including linked scripts, stylesheets,+images, and videos.+.PP+To produce a PDF slide show using beamer, type+.IP+.nf+\f[C]+pandoc -t beamer habits.txt -o habits.pdf+\f[R]+.fi+.PP+Note that a reveal.js slide show can also be converted to a PDF by+printing it to a file from the browser.+.PP+To produce a Powerpoint slide show, type+.IP+.nf+\f[C]+pandoc habits.txt -o habits.pptx+\f[R]+.fi+.SS Structuring the slide show+.PP+By default, the \f[I]slide level\f[R] is the highest heading level in+the hierarchy that is followed immediately by content, and not another+heading, somewhere in the document.+In the example above, level-1 headings are always followed by level-2+headings, which are followed by content, so the slide level is 2.+This default can be overridden using the \f[C]--slide-level\f[R] option.+.PP+The document is carved up into slides according to the following rules:+.IP \[bu] 2+A horizontal rule always starts a new slide.+.IP \[bu] 2+A heading at the slide level always starts a new slide.+.IP \[bu] 2+Headings \f[I]below\f[R] the slide level in the hierarchy create+headings \f[I]within\f[R] a slide.+.IP \[bu] 2+Headings \f[I]above\f[R] the slide level in the hierarchy create+\[dq]title slides,\[dq] which just contain the section title and help to+break the slide show into sections.+Non-slide content under these headings will be included on the title+slide (for HTML slide shows) or in a subsequent slide with the same+title (for beamer).+.IP \[bu] 2+A title page is constructed automatically from the document\[aq]s title+block, if present.+(In the case of beamer, this can be disabled by commenting out some+lines in the default template.)+.PP+These rules are designed to support many different styles of slide show.+If you don\[aq]t care about structuring your slides into sections and+subsections, you can just use level-1 headings for all each slide.+(In that case, level-1 will be the slide level.) But you can also+structure the slide show into sections, as in the example above.+.PP+Note: in reveal.js slide shows, if slide level is 2, a two-dimensional+layout will be produced, with level-1 headings building horizontally and+level-2 headings building vertically.+It is not recommended that you use deeper nesting of section levels with+reveal.js.+.SS Incremental lists+.PP+By default, these writers produce lists that display \[dq]all at+once.\[dq] If you want your lists to display incrementally (one item at+a time), use the \f[C]-i\f[R] option.+If you want a particular list to depart from the default, put it in a+\f[C]div\f[R] block with class \f[C]incremental\f[R] or+\f[C]nonincremental\f[R].+So, for example, using the \f[C]fenced div\f[R] syntax, the following+would be incremental regardless of the document default:+.IP+.nf+\f[C]+::: incremental++- Eat spaghetti+- Drink wine++:::+\f[R]+.fi+.PP+or+.IP+.nf+\f[C]+::: nonincremental++- Eat spaghetti+- Drink wine++:::+\f[R]+.fi+.PP+While using \f[C]incremental\f[R] and \f[C]nonincremental\f[R] divs are+the recommended method of setting incremental lists on a per-case basis,+an older method is also supported: putting lists inside a blockquote+will depart from the document default (that is, it will display+incrementally without the \f[C]-i\f[R] option and all at once with the+\f[C]-i\f[R] option):+.IP+.nf+\f[C]+> - Eat spaghetti+> - Drink wine+\f[R]+.fi+.PP+Both methods allow incremental and nonincremental lists to be mixed in a+single document.+.PP+Note: Neither the \f[C]-i/--incremental\f[R] option nor any of the+methods described here currently works for PowerPoint output.+.SS Inserting pauses+.PP+You can add \[dq]pauses\[dq] within a slide by including a paragraph+containing three dots, separated by spaces:+.IP+.nf+\f[C]+# Slide with a pause++content before the pause++\&. . .++content after the pause+\f[R]+.fi+.PP+Note: this feature is not yet implemented for PowerPoint output.+.SS Styling the slides+.PP+You can change the style of HTML slides by putting customized CSS files+in \f[C]$DATADIR/s5/default\f[R] (for S5), \f[C]$DATADIR/slidy\f[R] (for+Slidy), or \f[C]$DATADIR/slideous\f[R] (for Slideous), where+\f[C]$DATADIR\f[R] is the user data directory (see \f[C]--data-dir\f[R],+above).+The originals may be found in pandoc\[aq]s system data directory+(generally \f[C]$CABALDIR/pandoc-VERSION/s5/default\f[R]).+Pandoc will look there for any files it does not find in the user data+directory.+.PP+For dzslides, the CSS is included in the HTML file itself, and may be+modified there.+.PP+All reveal.js configuration options can be set through variables.+For example, themes can be used by setting the \f[C]theme\f[R] variable:+.IP+.nf+\f[C]+-V theme=moon+\f[R]+.fi+.PP+Or you can specify a custom stylesheet using the \f[C]--css\f[R] option.+.PP+To style beamer slides, you can specify a \f[C]theme\f[R],+\f[C]colortheme\f[R], \f[C]fonttheme\f[R], \f[C]innertheme\f[R], and+\f[C]outertheme\f[R], using the \f[C]-V\f[R] option:+.IP+.nf+\f[C]+pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf+\f[R]+.fi+.PP+Note that heading attributes will turn into slide attributes (on a+\f[C]<div>\f[R] or \f[C]<section>\f[R]) in HTML slide formats, allowing+you to style individual slides.+In beamer, the only heading attribute that affects slides is the+\f[C]allowframebreaks\f[R] class, which sets the+\f[C]allowframebreaks\f[R] option, causing multiple slides to be created+if the content overfills the frame.+This is recommended especially for bibliographies:+.IP+.nf+\f[C]+# References {.allowframebreaks}+\f[R]+.fi+.SS Speaker notes+.PP+Speaker notes are supported in reveal.js and PowerPoint (pptx) output.+You can add notes to your Markdown document thus:+.IP+.nf+\f[C]+::: notes++This is my note.++- It can contain Markdown+- like this list++:::+\f[R]+.fi+.PP+To show the notes window in reveal.js, press \f[C]s\f[R] while viewing+the presentation.+Speaker notes in PowerPoint will be available, as usual, in handouts and+presenter view.+.PP+Notes are not yet supported for other slide formats, but the notes will+not appear on the slides themselves.+.SS Columns+.PP+To put material in side by side columns, you can use a native div+container with class \f[C]columns\f[R], containing two or more div+containers with class \f[C]column\f[R] and a \f[C]width\f[R] attribute:+.IP+.nf+\f[C]+:::::::::::::: {.columns}+::: {.column width=\[dq]40%\[dq]}+contents...+:::+::: {.column width=\[dq]60%\[dq]}+contents...+:::+::::::::::::::+\f[R]+.fi+.SS Frame attributes in beamer+.PP+Sometimes it is necessary to add the LaTeX \f[C][fragile]\f[R] option to+a frame in beamer (for example, when using the \f[C]minted\f[R]+environment).+This can be forced by adding the \f[C]fragile\f[R] class to the heading+introducing the slide:+.IP+.nf+\f[C]+# Fragile slide {.fragile}+\f[R]+.fi+.PP+All of the other frame attributes described in Section 8.1 of the Beamer+User\[aq]s Guide may also be used: \f[C]allowdisplaybreaks\f[R],+\f[C]allowframebreaks\f[R], \f[C]b\f[R], \f[C]c\f[R], \f[C]t\f[R],+\f[C]environment\f[R], \f[C]label\f[R], \f[C]plain\f[R],+\f[C]shrink\f[R], \f[C]standout\f[R], \f[C]noframenumbering\f[R].+.SS Background in reveal.js and beamer+.PP+Background images can be added to self-contained reveal.js slideshows+and to beamer slideshows.+.PP+For the same image on every slide, use the configuration option+\f[C]background-image\f[R] either in the YAML metadata block or as a+command-line variable.+(There are no other options in beamer and the rest of this section+concerns reveal.js slideshows.)+.PP+For reveal.js, you can instead use the reveal.js-native option+\f[C]parallaxBackgroundImage\f[R].+You can also set \f[C]parallaxBackgroundHorizontal\f[R] and+\f[C]parallaxBackgroundVertical\f[R] the same way and must also set+\f[C]parallaxBackgroundSize\f[R] to have your values take effect.+.PP+To set an image for a particular reveal.js slide, add+\f[C]{data-background-image=\[dq]/path/to/image\[dq]}\f[R] to the first+slide-level heading on the slide (which may even be empty).+.PP+In reveal.js\[aq]s overview mode, the parallaxBackgroundImage will show+up only on the first slide.+.PP+Other reveal.js background settings also work on individual slides,+including \f[C]data-background-size\f[R],+\f[C]data-background-repeat\f[R], \f[C]data-background-color\f[R],+\f[C]data-transition\f[R], and \f[C]data-transition-speed\f[R].+.PP+See the reveal.js documentation for more details.+.PP+For example in reveal.js:+.IP+.nf+\f[C]+---+title: My Slideshow+parallaxBackgroundImage: /path/to/my/background_image.png+---++## Slide One++Slide 1 has background_image.png as its background.++## {data-background-image=\[dq]/path/to/special_image.jpg\[dq]}++Slide 2 has a special image for its background, even though the heading has no content.+\f[R]+.fi+.SH CREATING EPUBS WITH PANDOC+.SS EPUB Metadata+.PP+EPUB metadata may be specified using the \f[C]--epub-metadata\f[R]+option, but if the source document is Markdown, it is better to use a+YAML metadata block.+Here is an example:+.IP+.nf+\f[C]+---+title:+- type: main+  text: My Book+- type: subtitle+  text: An investigation of metadata+creator:+- role: author+  text: John Smith+- role: editor+  text: Sarah Jones+identifier:+- scheme: DOI+  text: doi:10.234234.234/33+publisher:  My Press+rights: \[co] 2007 John Smith, CC BY-NC+ibooks:+  version: 1.3.4+\&...+\f[R]+.fi+.PP+The following fields are recognized:+.TP+\f[B]\f[CB]identifier\f[B]\f[R]+Either a string value or an object with fields \f[C]text\f[R] and+\f[C]scheme\f[R].+Valid values for \f[C]scheme\f[R] are \f[C]ISBN-10\f[R],+\f[C]GTIN-13\f[R], \f[C]UPC\f[R], \f[C]ISMN-10\f[R], \f[C]DOI\f[R],+\f[C]LCCN\f[R], \f[C]GTIN-14\f[R], \f[C]ISBN-13\f[R],+\f[C]Legal deposit number\f[R], \f[C]URN\f[R], \f[C]OCLC\f[R],+\f[C]ISMN-13\f[R], \f[C]ISBN-A\f[R], \f[C]JP\f[R], \f[C]OLCC\f[R].+.TP+\f[B]\f[CB]title\f[B]\f[R]+Either a string value, or an object with fields \f[C]file-as\f[R] and+\f[C]type\f[R], or a list of such objects.+Valid values for \f[C]type\f[R] are \f[C]main\f[R], \f[C]subtitle\f[R],+\f[C]short\f[R], \f[C]collection\f[R], \f[C]edition\f[R],+\f[C]extended\f[R].+.TP+\f[B]\f[CB]creator\f[B]\f[R]+Either a string value, or an object with fields \f[C]role\f[R],+\f[C]file-as\f[R], and \f[C]text\f[R], or a list of such objects.+Valid values for \f[C]role\f[R] are MARC relators, but pandoc will+attempt to translate the human-readable versions (like \[dq]author\[dq]+and \[dq]editor\[dq]) to the appropriate marc relators.+.TP+\f[B]\f[CB]contributor\f[B]\f[R]+Same format as \f[C]creator\f[R].+.TP+\f[B]\f[CB]date\f[B]\f[R]+A string value in \f[C]YYYY-MM-DD\f[R] format.+(Only the year is necessary.) Pandoc will attempt to convert other+common date formats.+.TP+\f[B]\f[CB]lang\f[B]\f[R] (or legacy: \f[B]\f[CB]language\f[B]\f[R])+A string value in BCP 47 format.+Pandoc will default to the local language if nothing is specified.+.TP+\f[B]\f[CB]subject\f[B]\f[R]+A string value or a list of such values.+.TP+\f[B]\f[CB]description\f[B]\f[R]+A string value.+.TP+\f[B]\f[CB]type\f[B]\f[R]+A string value.+.TP+\f[B]\f[CB]format\f[B]\f[R]+A string value.+.TP+\f[B]\f[CB]relation\f[B]\f[R]+A string value.+.TP+\f[B]\f[CB]coverage\f[B]\f[R]+A string value.+.TP+\f[B]\f[CB]rights\f[B]\f[R]+A string value.+.TP+\f[B]\f[CB]cover-image\f[B]\f[R]+A string value (path to cover image).+.TP+\f[B]\f[CB]css\f[B]\f[R] (or legacy: \f[B]\f[CB]stylesheet\f[B]\f[R])+A string value (path to CSS stylesheet).+.TP+\f[B]\f[CB]page-progression-direction\f[B]\f[R]+Either \f[C]ltr\f[R] or \f[C]rtl\f[R].+Specifies the \f[C]page-progression-direction\f[R] attribute for the+\f[C]spine\f[R] element.+.TP+\f[B]\f[CB]ibooks\f[B]\f[R]+iBooks-specific metadata, with the following fields:+.RS+.IP \[bu] 2+\f[C]version\f[R]: (string)+.IP \[bu] 2+\f[C]specified-fonts\f[R]: \f[C]true\f[R]|\f[C]false\f[R] (default+\f[C]false\f[R])+.IP \[bu] 2+\f[C]ipad-orientation-lock\f[R]:+\f[C]portrait-only\f[R]|\f[C]landscape-only\f[R]+.IP \[bu] 2+\f[C]iphone-orientation-lock\f[R]:+\f[C]portrait-only\f[R]|\f[C]landscape-only\f[R]+.IP \[bu] 2+\f[C]binding\f[R]: \f[C]true\f[R]|\f[C]false\f[R] (default+\f[C]true\f[R])+.IP \[bu] 2+\f[C]scroll-axis\f[R]:+\f[C]vertical\f[R]|\f[C]horizontal\f[R]|\f[C]default\f[R]+.RE+.SS The \f[C]epub:type\f[R] attribute+.PP+For \f[C]epub3\f[R] output, you can mark up the heading that corresponds+to an EPUB chapter using the \f[C]epub:type\f[R] attribute.+For example, to set the attribute to the value \f[C]prologue\f[R], use+this markdown:+.IP+.nf+\f[C]+# My chapter {epub:type=prologue}+\f[R]+.fi+.PP+Which will result in:+.IP+.nf+\f[C]+<body epub:type=\[dq]frontmatter\[dq]>+  <section epub:type=\[dq]prologue\[dq]>+    <h1>My chapter</h1>+\f[R]+.fi+.PP+Pandoc will output \f[C]<body epub:type=\[dq]bodymatter\[dq]>\f[R],+unless you use one of the following values, in which case either+\f[C]frontmatter\f[R] or \f[C]backmatter\f[R] will be output.+.PP+.TS+tab(@);+l l.+T{+\f[C]epub:type\f[R] of first section+T}@T{+\f[C]epub:type\f[R] of body+T}+_+T{+prologue+T}@T{+frontmatter+T}+T{+abstract+T}@T{+frontmatter+T}+T{+acknowledgments+T}@T{+frontmatter+T}+T{+copyright-page+T}@T{+frontmatter+T}+T{+dedication+T}@T{+frontmatter+T}+T{+credits+T}@T{+frontmatter+T}+T{+keywords+T}@T{+frontmatter+T}+T{+imprint+T}@T{+frontmatter+T}+T{+contributors+T}@T{+frontmatter+T}+T{+other-credits+T}@T{+frontmatter+T}+T{+errata+T}@T{+frontmatter+T}+T{+revision-history+T}@T{+frontmatter+T}+T{+titlepage+T}@T{+frontmatter+T}+T{+halftitlepage+T}@T{+frontmatter+T}+T{+seriespage+T}@T{+frontmatter+T}+T{+foreword+T}@T{+frontmatter+T}+T{+preface+T}@T{+frontmatter+T}+T{+seriespage+T}@T{+frontmatter+T}+T{+titlepage+T}@T{+frontmatter+T}+T{+appendix+T}@T{+backmatter+T}+T{+colophon+T}@T{+backmatter+T}+T{+bibliography+T}@T{+backmatter+T}+T{+index+T}@T{+backmatter+T}+.TE+.SS Linked media+.PP+By default, pandoc will download media referenced from any+\f[C]<img>\f[R], \f[C]<audio>\f[R], \f[C]<video>\f[R] or+\f[C]<source>\f[R] element present in the generated EPUB, and include it+in the EPUB container, yielding a completely self-contained EPUB.+If you want to link to external media resources instead, use raw HTML in+your source and add \f[C]data-external=\[dq]1\[dq]\f[R] to the tag with+the \f[C]src\f[R] attribute.+For example:+.IP+.nf+\f[C]+<audio controls=\[dq]1\[dq]>+  <source src=\[dq]http://example.com/music/toccata.mp3\[dq]+          data-external=\[dq]1\[dq] type=\[dq]audio/mpeg\[dq]>+  </source>+</audio>+\f[R]+.fi+.SH CREATING JUPYTER NOTEBOOKS WITH PANDOC+.PP+When creating a Jupyter notebook, pandoc will try to infer the notebook+structure.+Code blocks with the class \f[C]code\f[R] will be taken as code cells,+and intervening content will be taken as Markdown cells.+Attachments will automatically be created for images in Markdown cells.+Metadata will be taken from the \f[C]jupyter\f[R] metadata field.+For example:+.IP+.nf+\f[C]+---+title: My notebook+jupyter:+  nbformat: 4+  nbformat_minor: 5+  kernelspec:+     display_name: Python 2+     language: python+     name: python2+  language_info:+     codemirror_mode:+       name: ipython+       version: 2+     file_extension: \[dq].py\[dq]+     mimetype: \[dq]text/x-python\[dq]+     name: \[dq]python\[dq]+     nbconvert_exporter: \[dq]python\[dq]+     pygments_lexer: \[dq]ipython2\[dq]+     version: \[dq]2.7.15\[dq]+---++# Lorem ipsum++**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus+bibendum felis dictum sodales.++\[ga]\[ga]\[ga] code+print(\[dq]hello\[dq])+\[ga]\[ga]\[ga]++## Pyout++\[ga]\[ga]\[ga] code+from IPython.display import HTML+HTML(\[dq]\[dq]\[dq]+<script>+console.log(\[dq]hello\[dq]);+</script>+<b>HTML</b>+\[dq]\[dq]\[dq])+\[ga]\[ga]\[ga]++## Image++This image ![image](myimage.png) will be+included as a cell attachment.+\f[R]+.fi+.PP+If you want to add cell attributes, group cells differently, or add+output to code cells, then you need to include divs to indicate the+structure.+You can use either fenced divs or native divs for this.+Here is an example:+.IP+.nf+\f[C]+:::::: {.cell .markdown}+# Lorem++**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus+bibendum felis dictum sodales.+::::::++:::::: {.cell .code execution_count=1}+\[ga]\[ga]\[ga] {.python}+print(\[dq]hello\[dq])+\[ga]\[ga]\[ga]++::: {.output .stream .stdout}+\[ga]\[ga]\[ga]+hello+\[ga]\[ga]\[ga]+:::+::::::++:::::: {.cell .code execution_count=2}+\[ga]\[ga]\[ga] {.python}+from IPython.display import HTML+HTML(\[dq]\[dq]\[dq]+<script>+console.log(\[dq]hello\[dq]);+</script>+<b>HTML</b>+\[dq]\[dq]\[dq])+\[ga]\[ga]\[ga]++::: {.output .execute_result execution_count=2}+\[ga]\[ga]\[ga]{=html}+<script>+console.log(\[dq]hello\[dq]);+</script>+<b>HTML</b>+hello+\[ga]\[ga]\[ga]+:::+::::::+\f[R]+.fi+.PP+If you include raw HTML or TeX in an output cell, use the [raw+attribute][Extension: \f[C]fenced_attribute\f[R]], as shown in the last+cell of the example above.+Although pandoc can process \[dq]bare\[dq] raw HTML and TeX, the result+is often interspersed raw elements and normal textual elements, and in+an output cell pandoc expects a single, connected raw block.+To avoid using raw HTML or TeX except when marked explicitly using raw+attributes, we recommend specifying the extensions+\f[C]-raw_html-raw_tex+raw_attribute\f[R] when translating between+Markdown and ipynb notebooks.+.PP+Note that options and extensions that affect reading and writing of+Markdown will also affect Markdown cells in ipynb notebooks.+For example, \f[C]--wrap=preserve\f[R] will preserve soft line breaks in+Markdown cells; \f[C]--atx-headers\f[R] will cause ATX-style headings to+be used; and \f[C]--preserve-tabs\f[R] will prevent tabs from being+turned to spaces.+.SH SYNTAX HIGHLIGHTING+.PP+Pandoc will automatically highlight syntax in fenced code blocks that+are marked with a language name.+The Haskell library skylighting is used for highlighting.+Currently highlighting is supported only for HTML, EPUB, Docx, Ms, and+LaTeX/PDF output.+To see a list of language names that pandoc will recognize, type+\f[C]pandoc --list-highlight-languages\f[R].+.PP+The color scheme can be selected using the \f[C]--highlight-style\f[R]+option.+The default color scheme is \f[C]pygments\f[R], which imitates the+default color scheme used by the Python library pygments (though+pygments is not actually used to do the highlighting).+To see a list of highlight styles, type+\f[C]pandoc --list-highlight-styles\f[R].+.PP+If you are not satisfied with the predefined styles, you can use+\f[C]--print-highlight-style\f[R] to generate a JSON \f[C].theme\f[R]+file which can be modified and used as the argument to+\f[C]--highlight-style\f[R].+To get a JSON version of the \f[C]pygments\f[R] style, for example:+.IP+.nf+\f[C]+pandoc --print-highlight-style pygments > my.theme+\f[R]+.fi+.PP+Then edit \f[C]my.theme\f[R] and use it like this:+.IP+.nf+\f[C]+pandoc --highlight-style my.theme+\f[R]+.fi+.PP+If you are not satisfied with the built-in highlighting, or you want+highlight a language that isn\[aq]t supported, you can use the+\f[C]--syntax-definition\f[R] option to load a KDE-style XML syntax+definition file.+Before writing your own, have a look at KDE\[aq]s repository of syntax+definitions.+.PP+To disable highlighting, use the \f[C]--no-highlight\f[R] option.+.SH CUSTOM STYLES+.PP+Custom styles can be used in the docx and ICML formats.+.SS Output+.PP+By default, pandoc\[aq]s docx and ICML output applies a predefined set+of styles for blocks such as paragraphs and block quotes, and uses+largely default formatting (italics, bold) for inlines.+This will work for most purposes, especially alongside a+\f[C]reference.docx\f[R] file.+However, if you need to apply your own styles to blocks, or match a+preexisting set of styles, pandoc allows you to define custom styles for+blocks and text using \f[C]div\f[R]s and \f[C]span\f[R]s, respectively.+.PP+If you define a \f[C]div\f[R] or \f[C]span\f[R] with the attribute+\f[C]custom-style\f[R], pandoc will apply your specified style to the+contained elements (with the exception of elements whose function+depends on a style, like headings, code blocks, block quotes, or links).+So, for example, using the \f[C]bracketed_spans\f[R] syntax,+.IP+.nf+\f[C]+[Get out]{custom-style=\[dq]Emphatically\[dq]}, he said.+\f[R]+.fi+.PP+would produce a docx file with \[dq]Get out\[dq] styled with character+style \f[C]Emphatically\f[R].+Similarly, using the \f[C]fenced_divs\f[R] syntax,+.IP+.nf+\f[C]+Dickinson starts the poem simply:++::: {custom-style=\[dq]Poetry\[dq]}+| A Bird came down the Walk---+| He did not know I saw---+:::+\f[R]+.fi+.PP+would style the two contained lines with the \f[C]Poetry\f[R] paragraph+style.+.PP+For docx output, styles will be defined in the output file as inheriting+from normal text, if the styles are not yet in your reference.docx.+If they are already defined, pandoc will not alter the definition.+.PP+This feature allows for greatest customization in conjunction with+pandoc filters.+If you want all paragraphs after block quotes to be indented, you can+write a filter to apply the styles necessary.+If you want all italics to be transformed to the \f[C]Emphasis\f[R]+character style (perhaps to change their color), you can write a filter+which will transform all italicized inlines to inlines within an+\f[C]Emphasis\f[R] custom-style \f[C]span\f[R].+.PP+For docx output, you don\[aq]t need to enable any extensions for custom+styles to work.+.SS Input+.PP+The docx reader, by default, only reads those styles that it can convert+into pandoc elements, either by direct conversion or interpreting the+derivation of the input document\[aq]s styles.+.PP+By enabling the \f[C]styles\f[R] extension in the docx reader+(\f[C]-f docx+styles\f[R]), you can produce output that maintains the+styles of the input document, using the \f[C]custom-style\f[R] class.+Paragraph styles are interpreted as divs, while character styles are+interpreted as spans.+.PP+For example, using the \f[C]custom-style-reference.docx\f[R] file in the+test directory, we have the following different outputs:+.PP+Without the \f[C]+styles\f[R] extension:+.IP+.nf+\f[C]+$ pandoc test/docx/custom-style-reference.docx -f docx -t markdown+This is some text.++This is text with an *emphasized* text style. And this is text with a+**strengthened** text style.++> Here is a styled paragraph that inherits from Block Text.+\f[R]+.fi+.PP+And with the extension:+.IP+.nf+\f[C]+$ pandoc test/docx/custom-style-reference.docx -f docx+styles -t markdown++::: {custom-style=\[dq]First Paragraph\[dq]}+This is some text.+:::++::: {custom-style=\[dq]Body Text\[dq]}+This is text with an [emphasized]{custom-style=\[dq]Emphatic\[dq]} text style.+And this is text with a [strengthened]{custom-style=\[dq]Strengthened\[dq]}+text style.+:::++::: {custom-style=\[dq]My Block Style\[dq]}+> Here is a styled paragraph that inherits from Block Text.+:::+\f[R]+.fi+.PP+With these custom styles, you can use your input document as a+reference-doc while creating docx output (see below), and maintain the+same styles in your input and output files.+.SH CUSTOM WRITERS+.PP+Pandoc can be extended with custom writers written in lua.+(Pandoc includes a lua interpreter, so lua need not be installed+separately.)+.PP+To use a custom writer, simply specify the path to the lua script in+place of the output format.+For example:+.IP+.nf+\f[C]+pandoc -t data/sample.lua+\f[R]+.fi+.PP+Creating a custom writer requires writing a lua function for each+possible element in a pandoc document.+To get a documented example which you can modify according to your+needs, do+.IP+.nf+\f[C]+pandoc --print-default-data-file sample.lua+\f[R]+.fi+.PP+Note that custom writers have no default template.+If you want to use \f[C]--standalone\f[R] with a custom writer, you will+need to specify a template manually using \f[C]--template\f[R] or add a+new default template with the name+\f[C]default.NAME_OF_CUSTOM_WRITER.lua\f[R] to the \f[C]templates\f[R]+subdirectory of your user data directory (see Templates). .SH A NOTE ON SECURITY .PP If you use pandoc to convert user-contributed content in a web
pandoc.cabal view
@@ -1,5 +1,5 @@ name:            pandoc-version:         2.7.3+version:         2.8 cabal-version:   2.0 build-type:      Simple license:         GPL-2@@ -41,6 +41,7 @@                  only adding a reader or writer. data-files:                  -- templates+                 data/templates/styles.html                  data/templates/default.html4                  data/templates/default.html5                  data/templates/default.docbook4@@ -180,9 +181,10 @@ extra-source-files:                  -- documentation                  INSTALL.md, AUTHORS.md, README.md,-                 CONTRIBUTING.md, BUGS, changelog,+                 CONTRIBUTING.md, BUGS, changelog.md,                  man/pandoc.1-                 -- stack build plan+                 -- cabal and stack build plans+                 cabal.project                  stack.yaml                  -- files needed to build man page                  man/manfilter.lua@@ -194,9 +196,17 @@                  test/bodybg.gif                  test/*.native                  test/command/*.md+                 test/command/A.txt+                 test/command/B.txt+                 test/command/C.txt+                 test/command/D.txt+                 test/command/defaults1.yaml+                 test/command/defaults2.yaml                  test/command/3533-rst-csv-tables.csv                  test/command/3880.txt                  test/command/5182.txt+                 test/command/5700-metadata-file-1.yml+                 test/command/5700-metadata-file-2.yml                  test/command/abbrevs                  test/command/SVG_logo-without-xml-declaration.svg                  test/command/SVG_logo.svg@@ -211,6 +221,7 @@                  test/command/3510-export.latex                  test/command/3510-src.hs                  test/command/3971b.tex+                 test/docbook-chapter.docbook                  test/docbook-reader.docbook                  test/docbook-xref.docbook                  test/html-reader.html@@ -355,11 +366,6 @@   Description:   Embed data files in binary for relocatable executable.   Default:       False -flag derive_json_via_th-  Description:   Use Template Haskell instead of GHC Generics to derive ToJSON-                 and FromJSON instances.-  Default:       True- flag trypandoc   Description:   Build trypandoc cgi executable.   Default:       False@@ -381,18 +387,19 @@                  safe >= 0.3 && < 0.4,                  zip-archive >= 0.2.3.4 && < 0.5,                  HTTP >= 4000.0.5 && < 4000.4,-                 texmath >= 0.11.2.1 && < 0.12,+                 texmath >= 0.12 && < 0.13,                  xml >= 1.3.12 && < 1.4,                  split >= 0.2 && < 0.3,                  random >= 1 && < 1.2,-                 pandoc-types >= 1.17.5 && < 1.18,+                 pandoc-types >= 1.20 && < 1.21,                  aeson >= 0.7 && < 1.5,                  scientific >= 0.3 && < 0.4,                  aeson-pretty >= 0.8.5 && < 0.9,                  tagsoup >= 0.14.6 && < 0.15,                  base64-bytestring >= 0.1 && < 1.1,                  zlib >= 0.5 && < 0.7,-                 skylighting >= 0.8.1 && < 0.9,+                 skylighting >= 0.8.2.3 && < 0.9,+                 skylighting-core >= 0.8.2.3 && < 0.9,                  data-default >= 0.4 && < 0.8,                  temporary >= 1.1 && < 1.4,                  blaze-html >= 0.9 && < 0.10,@@ -403,12 +410,12 @@                  hslua-module-text >= 0.2 && < 0.3,                  binary >= 0.5 && < 0.11,                  SHA >= 1.6 && < 1.7,-                 haddock-library >= 1.7 && < 1.8,+                 haddock-library >= 1.8 && < 1.9,                  deepseq >= 1.3 && < 1.5,                  JuicyPixels >= 3.1.6.1 && < 3.4,                  Glob >= 0.7 && < 0.11,                  cmark-gfm >= 0.2 && < 0.3,-                 doctemplates >= 0.2.1 && < 0.3,+                 doctemplates >= 0.7.1 && < 0.8,                  network-uri >= 2.6 && < 2.7,                  network >= 2.6,                  http-client >= 0.4.30 && < 0.7,@@ -416,16 +423,12 @@                  http-types >= 0.8 && < 0.13,                  case-insensitive >= 1.2 && < 1.3,                  unicode-transforms >= 0.3 && < 0.4,-                 HsYAML >= 0.1.1.1 && < 0.2,+                 HsYAML >= 0.2 && < 0.3,+                 doclayout >= 0.2.0.1 && < 0.3,                  ipynb >= 0.1 && < 0.2,-                 attoparsec >= 0.12 && < 0.14-  if impl(ghc < 8.0)-    build-depends: semigroups == 0.18.*,-                   -- basement 0.0.8 and foundation 0.0.21, transitive-                   -- dependencies, drop support for ghc 7.10.-                   basement < 0.0.8,-                   foundation < 0.0.21-  if impl(ghc >= 8.0) && os(windows) && arch(i386)+                 attoparsec >= 0.12 && < 0.14,+                 text-conversions >= 0.3 && < 0.4+  if os(windows) && arch(i386)      build-depends: basement >= 0.0.10,                     foundation >= 0.0.23                     -- basement 0.0.9 won't build on 32-bit windows.@@ -441,28 +444,31 @@      cpp-options:   -DEMBED_DATA_FILES      build-depends: file-embed >= 0.0 && < 0.1      other-modules: Text.Pandoc.Data-  if flag(derive_json_via_th)-     cpp-options:   -DDERIVE_JSON_VIA_TH   if os(windows)     cpp-options:      -D_WINDOWS   ghc-options:     -Wall -fno-warn-unused-do-bind-  if impl(ghc > 8.0)-    ghc-options:     -Wincomplete-record-updates-                     -Wnoncanonical-monad-instances-                     -Wnoncanonical-monadfail-instances-  if impl(ghc > 8.4)+                   -Wincomplete-record-updates+                   -Wnoncanonical-monad-instances+  -- Later:+  -- -Wpartial-fields        (currently used in Powerpoint writer)+  -- -Wmissing-export-lists  (currently some Odt modules violate this)+  -- -Wredundant-constraints (problematic if we want to support older base)+  if impl(ghc >= 8.2)+    ghc-options:     -Wcpp-undef+  if impl(ghc >= 8.4)     ghc-options:     -Wincomplete-uni-patterns                      -Widentities                      -Werror=missing-home-modules+                     -fhide-source-paths+   default-language: Haskell2010-  other-extensions: NoImplicitPrelude+  other-extensions: NoImplicitPrelude, TemplateHaskell   hs-source-dirs:  src    exposed-modules: Text.Pandoc,                    Text.Pandoc.App,                    Text.Pandoc.Options,                    Text.Pandoc.Extensions,-                   Text.Pandoc.Pretty,                    Text.Pandoc.Shared,                    Text.Pandoc.MediaBag,                    Text.Pandoc.Error,@@ -559,8 +565,8 @@                    Text.Pandoc.Readers.Docx.Lists,                    Text.Pandoc.Readers.Docx.Combine,                    Text.Pandoc.Readers.Docx.Parse,+                   Text.Pandoc.Readers.Docx.Parse.Styles,                    Text.Pandoc.Readers.Docx.Util,-                   Text.Pandoc.Readers.Docx.StyleMap,                    Text.Pandoc.Readers.Docx.Fields,                    Text.Pandoc.Readers.LaTeX.Parsing,                    Text.Pandoc.Readers.LaTeX.Lang,@@ -585,6 +591,7 @@                    Text.Pandoc.Readers.Org.Parsing,                    Text.Pandoc.Readers.Org.Shared,                    Text.Pandoc.Readers.Roff,+                   Text.Pandoc.Writers.Docx.StyleMap,                    Text.Pandoc.Writers.Roff,                    Text.Pandoc.Writers.Powerpoint.Presentation,                    Text.Pandoc.Writers.Powerpoint.Output,@@ -597,6 +604,7 @@                    Text.Pandoc.Lua.Marshaling.CommonState,                    Text.Pandoc.Lua.Marshaling.MediaBag,                    Text.Pandoc.Lua.Marshaling.ReaderOptions,+                   Text.Pandoc.Lua.Marshaling.Context,                    Text.Pandoc.Lua.Marshaling.Version,                    Text.Pandoc.Lua.Module.MediaBag,                    Text.Pandoc.Lua.Module.Pandoc,@@ -605,6 +613,7 @@                    Text.Pandoc.Lua.Module.Utils,                    Text.Pandoc.Lua.Packages,                    Text.Pandoc.Lua.Util,+                   Text.Pandoc.Lua.Walk,                    Text.Pandoc.CSS,                    Text.Pandoc.CSV,                    Text.Pandoc.RoffChar,@@ -617,13 +626,10 @@  executable pandoc   build-depends: pandoc, base >= 4.8 && < 5-  if impl(ghc < 8.0)-    build-depends: semigroups == 0.18.*   if impl(ghc < 8.4)      hs-source-dirs: prelude      other-modules:  Prelude      build-depends:  base-compat >= 0.9-  ghc-options:   -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind -threaded   if flag(static)     ld-options:     -static   default-language: Haskell2010@@ -632,6 +638,17 @@   main-is:         pandoc.hs   buildable:       True   other-modules:   Paths_pandoc+  ghc-options:     -rtsopts -with-rtsopts=-K16m -threaded+                   -Wall -fno-warn-unused-do-bind+                   -Wincomplete-record-updates+                   -Wnoncanonical-monad-instances+  if impl(ghc >= 8.2)+    ghc-options:     -Wcpp-undef+  if impl(ghc >= 8.4)+    ghc-options:     -Wincomplete-uni-patterns+                     -Widentities+                     -Werror=missing-home-modules+                     -fhide-source-paths  executable trypandoc   main-is:         trypandoc.hs@@ -644,12 +661,21 @@     buildable:     True   else     buildable:     False-  if impl(ghc < 8.0)-    build-depends: semigroups == 0.18.*   if impl(ghc < 8.4)      hs-source-dirs: prelude      other-modules:  Prelude      build-depends:  base-compat >= 0.9+  ghc-options:     -rtsopts -with-rtsopts=-K16m -threaded+                   -Wall -fno-warn-unused-do-bind+                   -Wincomplete-record-updates+                   -Wnoncanonical-monad-instances+  if impl(ghc >= 8.2)+    ghc-options:     -Wcpp-undef+  if impl(ghc >= 8.4)+    ghc-options:     -Wincomplete-uni-patterns+                     -Widentities+                     -Werror=missing-home-modules+                     -fhide-source-paths  benchmark weigh-pandoc   type:            exitcode-stdio-1.0@@ -660,23 +686,33 @@                    text,                    weigh >= 0.0 && < 0.1,                    mtl >= 2.2 && < 2.3-  if impl(ghc < 8.0)-    build-depends: semigroups == 0.18.*   if impl(ghc < 8.4)      hs-source-dirs: prelude      other-modules:  Prelude      build-depends:  base-compat >= 0.9-  ghc-options:   -rtsopts -Wall -fno-warn-unused-do-bind -threaded   default-language: Haskell2010   other-extensions: NoImplicitPrelude+  ghc-options:     -rtsopts -with-rtsopts=-K16m -threaded+                   -Wall -fno-warn-unused-do-bind+                   -Wincomplete-record-updates+                   -Wnoncanonical-monad-instances+  if impl(ghc >= 8.2)+    ghc-options:     -Wcpp-undef+  if impl(ghc >= 8.4)+    ghc-options:     -Wincomplete-uni-patterns+                     -Widentities+                     -Werror=missing-home-modules+                     -fhide-source-paths + test-suite test-pandoc   type:           exitcode-stdio-1.0   main-is:        test-pandoc.hs   hs-source-dirs: test   build-depends:  base >= 4.8 && < 5,                   pandoc,-                  pandoc-types >= 1.17.5 && < 1.18,+                  pandoc-types >= 1.20 && < 1.21,+                  mtl >= 2.2 && < 2.3,                   bytestring >= 0.9 && < 0.11,                   base64-bytestring >= 0.1 && < 1.1,                   text >= 1.1.1.0 && < 1.3,@@ -686,7 +722,7 @@                   hslua >= 1.0 && < 1.1,                   process >= 1.2.3 && < 1.7,                   temporary >= 1.1 && < 1.4,-                  Diff >= 0.2 && < 0.4,+                  Diff >= 0.2 && < 0.5,                   tasty >= 0.11 && < 1.3,                   tasty-hunit >= 0.9 && < 0.11,                   tasty-lua >= 0.2 && < 0.3,@@ -697,9 +733,8 @@                   executable-path >= 0.0 && < 0.1,                   zip-archive >= 0.2.3.4 && < 0.5,                   xml >= 1.3.12 && < 1.4,+                  doctemplates >= 0.7.1 && < 0.8,                   Glob >= 0.7 && < 0.11-  if impl(ghc < 8.0)-    build-depends: semigroups == 0.18.*   if impl(ghc < 8.4)      hs-source-dirs: prelude      other-modules:  Prelude@@ -757,10 +792,21 @@                   Tests.Writers.OOXML   if os(windows)     cpp-options:      -D_WINDOWS-  ghc-options:  -rtsopts -Wall -fno-warn-unused-do-bind -threaded   default-language: Haskell2010   other-extensions: NoImplicitPrelude+  ghc-options:     -rtsopts -with-rtsopts=-K16m -threaded+                   -Wall -fno-warn-unused-do-bind+                   -Wincomplete-record-updates+                   -Wnoncanonical-monad-instances+  if impl(ghc >= 8.2)+    ghc-options:     -Wcpp-undef+  if impl(ghc >= 8.4)+    ghc-options:     -Wincomplete-uni-patterns+                     -Widentities+                     -Werror=missing-home-modules+                     -fhide-source-paths + benchmark benchmark-pandoc   type:            exitcode-stdio-1.0   main-is:         benchmark-pandoc.hs@@ -771,12 +817,21 @@                    text >= 1.1.1.0 && < 1.3,                    mtl >= 2.2 && < 2.3,                    criterion >= 1.0 && < 1.6-  if impl(ghc < 8.0)-    build-depends: semigroups == 0.18.*   if impl(ghc < 8.4)      hs-source-dirs: prelude      other-modules:  Prelude      build-depends:  base-compat >= 0.9-  ghc-options:   -rtsopts -Wall -fno-warn-unused-do-bind -threaded   default-language: Haskell2010   other-extensions: NoImplicitPrelude+  ghc-options:     -rtsopts -with-rtsopts=-K16m -threaded+                   -Wall -fno-warn-unused-do-bind+                   -Wincomplete-record-updates+                   -Wnoncanonical-monad-instances+  if impl(ghc >= 8.2)+    ghc-options:     -Wcpp-undef+  if impl(ghc >= 8.4)+    ghc-options:     -Wincomplete-uni-patterns+                     -Widentities+                     -Werror=missing-home-modules+                     -fhide-source-paths+
src/Text/Pandoc.hs view
@@ -28,7 +28,6 @@ > mdToRST txt = runIOorExplode $ >   readMarkdown def txt >   >>= writeRST def{ writerReferenceLinks = True }- > > main :: IO () > main = do
src/Text/Pandoc/App.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-}+{-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE CPP                 #-} {-# LANGUAGE ScopedTypeVariables #-} {- |@@ -26,8 +27,9 @@ import qualified Control.Exception as E import Control.Monad import Control.Monad.Trans+import Control.Monad.Except (throwError) import qualified Data.ByteString as BS-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Lazy as BL import Data.Char (toLower) import Data.Maybe (fromMaybe, isJust, isNothing) import qualified Data.Set as Set@@ -45,25 +47,26 @@ import qualified System.IO as IO (Newline (..)) import Text.Pandoc import Text.Pandoc.App.FormatHeuristics (formatFromFilePaths)-import Text.Pandoc.App.Opt (Opt (..), LineEnding (..), defaultOpts)+import Text.Pandoc.App.Opt (Opt (..), LineEnding (..), defaultOpts,+                            IpynbOutput (..) ) import Text.Pandoc.App.CommandLineOptions (parseOptions, options) import Text.Pandoc.App.OutputSettings (OutputSettings (..), optToOutputSettings) import Text.Pandoc.BCP47 (Lang (..), parseBCP47)-import Text.Pandoc.Builder (setMeta, deleteMeta)+import Text.Pandoc.Builder (setMeta) import Text.Pandoc.Filter (Filter (JSONFilter, LuaFilter), applyFilters) import Text.Pandoc.PDF (makePDF) import Text.Pandoc.Readers.Markdown (yamlToMeta) import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained) import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs,          headerShift, isURI, tabFilter, uriPathToPath, filterIpynbOutput,-         defaultUserDataDirs)+         defaultUserDataDirs, tshow)+import Text.Pandoc.Writers.Shared (lookupMetaString) import qualified Text.Pandoc.UTF8 as UTF8 #ifndef _WINDOWS import System.Posix.IO (stdOutput) import System.Posix.Terminal (queryTerminal) #endif - convertWithOpts :: Opt -> IO () convertWithOpts opts = do   let outputFile = fromMaybe "-" (optOutputFile opts)@@ -72,22 +75,22 @@    when (optDumpArgs opts) $     do UTF8.hPutStrLn stdout outputFile-       mapM_ (UTF8.hPutStrLn stdout) (optInputFiles opts)+       mapM_ (UTF8.hPutStrLn stdout) (fromMaybe ["-"] $ optInputFiles opts)        exitSuccess    let isPandocCiteproc (JSONFilter f) = takeBaseName f == "pandoc-citeproc"       isPandocCiteproc _              = False   -- --bibliography implies -F pandoc-citeproc for backwards compatibility:-  let needsCiteproc = isJust (lookup "bibliography" (optMetadata opts)) &&+  let needsCiteproc = isJust (lookupMeta "bibliography"+                                (optMetadata opts)) &&                       optCiteMethod opts `notElem` [Natbib, Biblatex] &&                       all (not . isPandocCiteproc) filters-  let filters' = if needsCiteproc then JSONFilter "pandoc-citeproc" : filters-                                  else filters+  let filters' = filters ++ [ JSONFilter "pandoc-citeproc" | needsCiteproc ]    let sources = case optInputFiles opts of-                     []  -> ["-"]-                     xs | optIgnoreArgs opts -> ["-"]-                        | otherwise  -> xs+                     Nothing -> ["-"]+                     Just xs | optIgnoreArgs opts -> ["-"]+                             | otherwise  -> xs    datadir <- case optDataDir opts of                   Nothing   -> do@@ -101,39 +104,6 @@                     selectUserDataDir ds                   Just _    -> return $ optDataDir opts -  -- assign reader and writer based on options and filenames-  let readerName = case optReader opts of-                     Just f  -> f-                     Nothing -> formatFromFilePaths fallback sources-                       where fallback = if any isURI sources-                                           then "html"-                                           else "markdown"--  let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"--  -- TODO: we have to get the input and the output into the state for-  -- the sake of the text2tags reader.-  (reader, readerExts) <--           case getReader readerName of-                Right (r, es) -> return (r :: Reader PandocIO, es)-                Left e   -> E.throwIO $ PandocAppError e'-                  where e' = case readerName of-                                  "pdf" -> e ++-                                     "\nPandoc can convert to PDF, but not from PDF."-                                  "doc" -> e ++-                                     "\nPandoc can convert from DOCX, but not from DOC.\nTry using Word to save your DOC file as DOCX, and convert that with pandoc."-                                  _ -> e--  let convertTabs = tabFilter (if optPreserveTabs opts ||-                                    readerName == "t2t" ||-                                    readerName == "man"-                                  then 0-                                  else optTabStop opts)--      readSources :: [FilePath] -> PandocIO Text-      readSources srcs = convertTabs . T.intercalate (T.pack "\n") <$>-                            mapM readSource srcs-   let runIO' :: PandocIO a -> IO a       runIO' f = do         (res, reports) <- runIOorExplode $ do@@ -144,7 +114,7 @@                              return (x, rs)         case optLogFile opts of              Nothing      -> return ()-             Just logfile -> B.writeFile logfile (encodeLogMessages reports)+             Just logfile -> BL.writeFile logfile (encodeLogMessages reports)         let isWarning msg = messageVerbosity msg == WARNING         when (optFailIfWarnings opts && any isWarning reports) $             E.throwIO PandocFailOnWarningError@@ -154,12 +124,53 @@                  CRLF   -> IO.CRLF                  LF     -> IO.LF                  Native -> nativeNewline+#ifdef _WINDOWS+  let istty = True+#else+  istty <- liftIO $ queryTerminal stdOutput+#endif    runIO' $ do     setUserDataDir datadir-    setInputFiles (optInputFiles opts)+    setInputFiles (fromMaybe ["-"] (optInputFiles opts))     setOutputFile (optOutputFile opts) +    -- assign reader and writer based on options and filenames+    readerName <- case optFrom opts of+                       Just f  -> return f+                       Nothing -> case formatFromFilePaths sources of+                           Just f' -> return f'+                           Nothing | sources == ["-"] -> return "markdown"+                                   | any (isURI . T.pack) sources -> return "html"+                                   | otherwise -> do+                             report $ CouldNotDeduceFormat+                                 (map (T.pack . takeExtension) sources) "markdown"+                             return "markdown"++    let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"++    when (pdfOutput && readerName == "latex") $+      case (optInputFiles opts) of+        Just (inputFile:_) -> report $ UnusualConversion $ T.pack $+          "to convert a .tex file to PDF, you get better results by using pdflatex "+            <> "(or lualatex or xelatex) directly, try `pdflatex " <> inputFile+            <> "` instead of `pandoc " <> inputFile <> " -o " <> outputFile <> "`."+        _ -> return ()++    (reader :: Reader PandocIO, readerExts) <- getReader readerName++    let convertTabs = tabFilter (if optPreserveTabs opts ||+                                      readerName == "t2t" ||+                                      readerName == "man"+                                    then 0+                                    else optTabStop opts)+++    let readSources :: [FilePath] -> PandocIO Text+        readSources srcs = convertTabs . T.intercalate (T.pack "\n") <$>+                              mapM readSource srcs++     outputSettings <- optToOutputSettings opts     let format = outputFormat outputSettings     let writer = outputWriter outputSettings@@ -173,38 +184,35 @@     -- force this with '-o -'.  On posix systems, we detect     -- when stdout is being piped and allow output to stdout     -- in that case, but on Windows we can't.-#ifdef _WINDOWS-    let istty = True-#else-    istty <- liftIO $ queryTerminal stdOutput-#endif-    when (not (isTextFormat format) && istty && isNothing ( optOutputFile opts)) $-      liftIO $ E.throwIO $ PandocAppError $-              "Cannot write " ++ format ++ " output to terminal.\n" ++-              "Specify an output file using the -o option, or " +++    when ((pdfOutput || not (isTextFormat format)) &&+             istty && isNothing ( optOutputFile opts)) $+      throwError $ PandocAppError $+              "Cannot write " <> format <> " output to terminal.\n" <>+              "Specify an output file using the -o option, or " <>               "use '-o -' to force output to stdout."  -    abbrevs <- Set.fromList . filter (not . null) . lines <$>+    abbrevs <- Set.fromList . filter (not . T.null) . T.lines <$>                case optAbbreviations opts of-                    Nothing -> UTF8.toString <$> readDataFile "abbreviations"-                    Just f  -> UTF8.toString <$> readFileStrict f+                    Nothing -> UTF8.toText <$> readDataFile "abbreviations"+                    Just f  -> UTF8.toText <$> readFileStrict f      metadata <- if format == "jats" &&-                   isNothing (lookup "csl" (optMetadata opts)) &&-                   isNothing (lookup "citation-style" (optMetadata opts))+                   isNothing (lookupMeta "csl" (optMetadata opts)) &&+                   isNothing (lookupMeta "citation-style"+                                               (optMetadata opts))                    then do                      jatsCSL <- readDataFile "jats.csl"                      let jatsEncoded = makeDataURI                                          ("application/xml", jatsCSL)-                     return $ ("csl", jatsEncoded) : optMetadata opts+                     return $ setMeta "csl" jatsEncoded $ optMetadata opts                    else return $ optMetadata opts -    case lookup "lang" (optMetadata opts) of-           Just l  -> case parseBCP47 l of-                           Left _   -> return ()+    case lookupMetaString "lang" (optMetadata opts) of+           ""      -> setTranslations $ Lang "en" "" "US" []+           l       -> case parseBCP47 l of+                           Left _   -> report $ InvalidLang l                            Right l' -> setTranslations l'-           Nothing -> setTranslations $ Lang "en" "" "US" []      let readerOpts = def{             readerStandalone = standalone@@ -220,13 +228,14 @@           }      metadataFromFile <--      case optMetadataFile opts of-        Nothing   -> return mempty-        Just file -> readFileLazy file >>= yamlToMeta readerOpts+      case optMetadataFiles opts of+        []    -> return mempty+        paths -> mapM readFileLazy paths >>=+                    fmap mconcat . mapM (yamlToMeta readerOpts) -    let transforms = (case optBaseHeaderLevel opts of-                          x | x > 1     -> (headerShift (x - 1) :)-                            | otherwise -> id) .+    let transforms = (case optShiftHeadingLevelBy opts of+                          0             -> id+                          x             -> (headerShift x :)) .                      (if optStripEmptyParagraphs opts                          then (stripEmptyParagraphs :)                          else id) .@@ -238,17 +247,16 @@                          then (eastAsianLineBreakFilter :)                          else id) .                      (case optIpynbOutput opts of-                       "all"    -> id-                       "none"   -> (filterIpynbOutput Nothing :)-                       "best"   -> (filterIpynbOutput (Just $+                       IpynbOutputAll  -> id+                       IpynbOutputNone -> (filterIpynbOutput Nothing :)+                       IpynbOutputBest -> (filterIpynbOutput (Just $                                      if htmlFormat format                                         then Format "html"                                         else                                           case format of                                             "latex"  -> Format "latex"                                             "beamer" -> Format "latex"-                                            _        -> Format format) :)-                       _  -> id)  -- should not happen+                                            _        -> Format format) :))                      $ []      let sourceToDoc :: [FilePath] -> PandocIO Pandoc@@ -274,10 +282,10 @@               (   (if isJust (optExtractMedia opts)                       then fillMediaBag                       else return)-              >=> return . addNonPresentMetadata metadataFromFile-              >=> return . addMetadata metadata+              >=> return . adjustMetadata (metadataFromFile <>)+              >=> return . adjustMetadata (<> metadata)               >=> applyTransforms transforms-              >=> applyFilters readerOpts filters' [format]+              >=> applyFilters readerOpts filters' [T.unpack format]               >=> maybe return extractMedia (optExtractMedia opts)               ) @@ -285,62 +293,35 @@       ByteStringWriter f -> f writerOptions doc >>= writeFnBinary outputFile       TextWriter f -> case outputPdfProgram outputSettings of         Just pdfProg -> do-                res <- makePDF pdfProg (optPdfEngineArgs opts) f+                res <- makePDF pdfProg (optPdfEngineOpts opts) f                         writerOptions doc                 case res of                      Right pdf -> writeFnBinary outputFile pdf-                     Left err' -> liftIO $-                       E.throwIO $ PandocPDFError $-                                     TL.unpack (TE.decodeUtf8With TE.lenientDecode err')+                     Left err' -> throwError $ PandocPDFError $+                                     TL.toStrict (TE.decodeUtf8With TE.lenientDecode err')          Nothing -> do-                let addNl = if standalone-                               then id-                               else (<> T.singleton '\n')-                output <- addNl <$> f writerOptions doc+                let ensureNl t+                      | standalone = t+                      | T.null t || T.last t /= '\n' = t <> T.singleton '\n'+                      | otherwise = t+                output <- ensureNl <$> f writerOptions doc                 writerFn eol outputFile =<<                   if optSelfContained opts && htmlFormat format-                     -- TODO not maximally efficient; change type-                     -- of makeSelfContained so it works w/ Text-                     then T.pack <$> makeSelfContained (T.unpack output)+                     then makeSelfContained output                      else return output  type Transform = Pandoc -> Pandoc -htmlFormat :: String -> Bool+htmlFormat :: Text -> Bool htmlFormat = (`elem` ["html","html4","html5","s5","slidy",                       "slideous","dzslides","revealjs"]) -isTextFormat :: String -> Bool+isTextFormat :: Text -> Bool isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub","pptx"] -addNonPresentMetadata :: Text.Pandoc.Meta -> Pandoc -> Pandoc-addNonPresentMetadata newmeta (Pandoc meta bs) = Pandoc (meta <> newmeta) bs--addMetadata :: [(String, String)] -> Pandoc -> Pandoc-addMetadata kvs pdc = foldr addMeta (removeMetaKeys kvs pdc) kvs--addMeta :: (String, String) -> Pandoc -> Pandoc-addMeta (k, v) (Pandoc meta bs) = Pandoc meta' bs-  where meta' = case lookupMeta k meta of-                      Nothing -> setMeta k v' meta-                      Just (MetaList xs) ->-                                 setMeta k (MetaList (xs ++ [v'])) meta-                      Just x  -> setMeta k (MetaList [x, v']) meta-        v' = readMetaValue v--removeMetaKeys :: [(String,String)] -> Pandoc -> Pandoc-removeMetaKeys kvs pdc = foldr (deleteMeta . fst) pdc kvs--readMetaValue :: String -> MetaValue-readMetaValue s-  | s == "true"  = MetaBool True-  | s == "True"  = MetaBool True-  | s == "TRUE"  = MetaBool True-  | s == "false" = MetaBool False-  | s == "False" = MetaBool False-  | s == "FALSE" = MetaBool False-  | otherwise    = MetaString s+adjustMetadata :: (Meta -> Meta) -> Pandoc -> Pandoc+adjustMetadata f (Pandoc meta bs) = Pandoc (f meta) bs  -- Transformations of a Pandoc document post-parsing: @@ -352,7 +333,7 @@                       Just u | uriScheme u `elem` ["http:","https:"] ->                                  readURI src                              | uriScheme u == "file:" -> liftIO $-                                 readTextFile (uriPathToPath $ uriPath u)+                                 readTextFile (uriPathToPath $ T.pack $ uriPath u)                       _       -> liftIO $ readTextFile src   where readTextFile :: FilePath -> IO Text         readTextFile fp = do@@ -364,20 +345,20 @@                          TSE.DecodeError _ (Just w) -> do                            case BS.elemIndex w bs of                              Just offset -> E.throwIO $-                                  PandocUTF8DecodingError fp offset w-                             _ -> E.throwIO $ PandocUTF8DecodingError fp 0 w-                         _ -> E.throwIO $ PandocAppError (show e))+                                  PandocUTF8DecodingError (T.pack fp) offset w+                             _ -> E.throwIO $ PandocUTF8DecodingError (T.pack fp) 0 w+                         _ -> E.throwIO $ PandocAppError (tshow e))  readURI :: FilePath -> PandocIO Text-readURI src = UTF8.toText . fst <$> openURL src+readURI src = UTF8.toText . fst <$> openURL (T.pack src) -readFile' :: MonadIO m => FilePath -> m B.ByteString-readFile' "-" = liftIO B.getContents-readFile' f   = liftIO $ B.readFile f+readFile' :: MonadIO m => FilePath -> m BL.ByteString+readFile' "-" = liftIO BL.getContents+readFile' f   = liftIO $ BL.readFile f -writeFnBinary :: MonadIO m => FilePath -> B.ByteString -> m ()-writeFnBinary "-" = liftIO . B.putStr-writeFnBinary f   = liftIO . B.writeFile (UTF8.encodePath f)+writeFnBinary :: MonadIO m => FilePath -> BL.ByteString -> m ()+writeFnBinary "-" = liftIO . BL.putStr+writeFnBinary f   = liftIO . BL.writeFile (UTF8.encodePath f)  writerFn :: MonadIO m => IO.Newline -> FilePath -> Text -> m () -- TODO this implementation isn't maximally efficient:
src/Text/Pandoc/App/CommandLineOptions.hs view
@@ -2,9 +2,7 @@ {-# LANGUAGE CPP                 #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections       #-}-#ifdef DERIVE_JSON_VIA_TH-{-# LANGUAGE TemplateHaskell     #-}-#endif+{-# LANGUAGE OverloadedStrings   #-} {- |    Module      : Text.Pandoc.App.CommandLineOptions    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -20,33 +18,35 @@             parseOptions           , options           , engines+          , lookupHighlightStyle+          , setVariable           ) where import Prelude import Control.Monad import Control.Monad.Trans+import Control.Monad.Except (throwError) import Data.Aeson.Encode.Pretty (encodePretty', Config(..), keyOrder,          defConfig, Indent(..), NumberFormat(..))-import Data.Char (toLower, toUpper)+import Data.Char (toLower) import Data.List (intercalate, sort) #ifdef _WINDOWS #if MIN_VERSION_base(4,12,0) import Data.List (isPrefixOf) #endif #endif-import Data.Maybe (fromMaybe)-import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme,-                    pygments)+import Data.Maybe (fromMaybe, isJust)+import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme) import System.Console.GetOpt import System.Environment (getArgs, getProgName) import System.Exit (exitSuccess) import System.FilePath import System.IO (stdout) import Text.Pandoc-import Text.Pandoc.App.Opt (Opt (..), LineEnding (..))+import Text.Pandoc.Builder (setMeta)+import Text.Pandoc.App.Opt (Opt (..), LineEnding (..), IpynbOutput (..)) import Text.Pandoc.Filter (Filter (..)) import Text.Pandoc.Highlighting (highlightingStyles)-import Text.Pandoc.Writers.Math (defaultMathJaxURL, defaultKaTeXURL)-import Text.Pandoc.Shared (ordNub, safeRead, defaultUserDataDirs)+import Text.Pandoc.Shared (ordNub, elemText, safeStrRead, defaultUserDataDirs) import Text.Printf  #ifdef EMBED_DATA_FILES@@ -61,7 +61,10 @@ import qualified Data.ByteString.Lazy as B import qualified Data.Map as M import qualified Data.Text as T+import Data.Text (Text)+import Text.DocTemplates (ToContext(toVal), Context(..)) import qualified Text.Pandoc.UTF8 as UTF8+import qualified Data.YAML as Y  parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt parseOptions options' defaults = do@@ -76,13 +79,24 @@        unrecognizedOpts    unless (null errors && null unknownOptionErrors) $-     E.throwIO $ PandocOptionError $+     E.throwIO $ PandocOptionError $ T.pack $         concat errors ++ unlines unknownOptionErrors ++         ("Try " ++ prg ++ " --help for more information.")    -- thread option data structure through all supplied option actions   opts <- foldl (>>=) (return defaults) actions-  return (opts{ optInputFiles = map normalizePath args })+  let mbArgs = case args of+                 [] -> Nothing+                 xs -> Just xs+  return $ opts{ optInputFiles =+                   map normalizePath <$> (optInputFiles opts <> mbArgs)+               , optStandalone = -- certain other options imply standalone+                   optStandalone opts ||+                     isJust (optTemplate opts) ||+                     optSelfContained opts ||+                     not (null (optIncludeInHeader opts)) ||+                     not (null (optIncludeBeforeBody opts)) ||+                     not (null (optIncludeAfterBody opts)) }  latexEngines :: [String] latexEngines  = ["pdflatex", "lualatex", "xelatex", "latexmk", "tectonic"]@@ -90,7 +104,7 @@ htmlEngines :: [String] htmlEngines  = ["wkhtmltopdf", "weasyprint", "prince"] -engines :: [(String, String)]+engines :: [(Text, String)] engines = map ("html",) htmlEngines ++           map ("html5",) htmlEngines ++           map ("latex",) latexEngines ++@@ -102,19 +116,13 @@ pdfEngines :: [String] pdfEngines = ordNub $ map snd engines -lookupHighlightStyle :: String -> IO (Maybe Style)-lookupHighlightStyle s-  | takeExtension s == ".theme" = -- attempt to load KDE theme-    do contents <- B.readFile s-       case parseTheme contents of-            Left _    -> E.throwIO $ PandocOptionError $-                           "Could not read highlighting theme " ++ s-            Right sty -> return (Just sty)-  | otherwise =-  case lookup (map toLower s) highlightingStyles of-       Just sty -> return (Just sty)-       Nothing  -> E.throwIO $ PandocOptionError $-                      "Unknown highlight-style " ++ s+findFile :: PandocMonad m => [FilePath] -> m (Maybe FilePath)+findFile [] = return Nothing+findFile (f:fs) = do+  exists <- fileExists f+  if exists+     then return $ Just f+     else findFile fs  -- | A list of functions, each transforming the options data structure --   in response to a command-line option.@@ -122,14 +130,14 @@ options =     [ Option "fr" ["from","read"]                  (ReqArg-                  (\arg opt -> return opt { optReader =-                                              Just (map toLower arg) })+                  (\arg opt -> return opt { optFrom =+                                              Just (T.toLower $ T.pack arg) })                   "FORMAT")                  ""      , Option "tw" ["to","write"]                  (ReqArg-                  (\arg opt -> return opt { optWriter = Just arg })+                  (\arg opt -> return opt { optTo = Just $ T.pack arg })                   "FORMAT")                  "" @@ -140,29 +148,6 @@                   "FILE")                  "" -- "Name of output file" -    , Option "" ["wrap"]-                 (ReqArg-                  (\arg opt ->-                    case safeRead ("Wrap" ++ uppercaseFirstLetter arg) of-                          Just o   -> return opt { optWrapText = o }-                          Nothing  -> E.throwIO $ PandocOptionError-                                     "--wrap must be auto, none, or preserve")-                 "auto|none|preserve")-                 "" -- "Option for wrapping text in output"--    , Option "s" ["standalone"]-                 (NoArg-                  (\opt -> return opt { optStandalone = True }))-                 "" -- "Include needed header and footer on output"--    , Option "" ["template"]-                 (ReqArg-                  (\arg opt ->-                     return opt{ optTemplate = Just (normalizePath arg),-                                 optStandalone = True })-                  "FILE")-                 "" -- "Use custom template"-     , Option "" ["data-dir"]                  (ReqArg                   (\arg opt -> return opt { optDataDir =@@ -174,25 +159,63 @@                  (ReqArg                   (\arg opt -> do                      let (key, val) = splitField arg-                     return opt{ optMetadata = (key, val) : optMetadata opt })+                     return opt{ optMetadata = addMeta key val $+                                                 optMetadata opt })                   "KEY[:VALUE]")                  ""      , Option "" ["metadata-file"]                  (ReqArg-                  (\arg opt -> return opt{ optMetadataFile =-                                   Just (normalizePath arg) })+                  (\arg opt -> return opt{ optMetadataFiles =+                      optMetadataFiles opt ++ [normalizePath arg] })                   "FILE")                  "" +    , Option "d" ["defaults"]+                 (ReqArg+                  (\arg opt -> applyDefaults opt arg+                  )+                  "FILE")+                ""++    , Option "" ["file-scope"]+                 (NoArg+                  (\opt -> return opt { optFileScope = True }))+                 "" -- "Parse input files before combining"++    , Option "s" ["standalone"]+                 (NoArg+                  (\opt -> return opt { optStandalone = True }))+                 "" -- "Include needed header and footer on output"++    , Option "" ["template"]+                 (ReqArg+                  (\arg opt ->+                     return opt{ optTemplate = Just (normalizePath arg) })+                  "FILE")+                 "" -- "Use custom template"+     , Option "V" ["variable"]                  (ReqArg                   (\arg opt -> do                      let (key, val) = splitField arg-                     return opt{ optVariables = (key, val) : optVariables opt })+                     return opt{ optVariables =+                                  setVariable key val $ optVariables opt })                   "KEY[:VALUE]")                  "" +    , Option "" ["wrap"]+                 (ReqArg+                  (\arg opt ->+                    case arg of+                      "auto" -> return opt{ optWrap = WrapAuto }+                      "none" -> return opt{ optWrap = WrapNone }+                      "preserve" -> return opt{ optWrap = WrapPreserve }+                      _      -> E.throwIO $ PandocOptionError+                                 "--wrap must be auto, none, or preserve")+                 "auto|none|preserve")+                 "" -- "Option for wrapping text in output"+     , Option "" ["ascii"]                  (NoArg                   (\opt -> return opt { optAscii = True }))@@ -206,23 +229,23 @@     , Option "" ["toc-depth"]                  (ReqArg                   (\arg opt ->-                      case safeRead arg of+                      case safeStrRead arg of                            Just t | t >= 1 && t <= 6 ->                                     return opt { optTOCDepth = t }-                           _      -> E.throwIO $ PandocOptionError-                                    "TOC level must be a number between 1 and 6")+                           _ -> E.throwIO $ PandocOptionError+                                "TOC level must be a number 1-6")                  "NUMBER")                  "" -- "Number of levels to include in TOC"      , Option "N" ["number-sections"]                  (NoArg                   (\opt -> return opt { optNumberSections = True }))-                 "" -- "Number sections in LaTeX"+                 "" -- "Number sections"      , Option "" ["number-offset"]                  (ReqArg                   (\arg opt ->-                      case safeRead ('[':arg ++ "]") of+                      case safeStrRead ("[" <> arg <> "]") of                            Just ns -> return opt { optNumberOffset = ns,                                                    optNumberSections = True }                            _      -> E.throwIO $ PandocOptionError@@ -232,13 +255,19 @@      , Option "" ["top-level-division"]                  (ReqArg-                  (\arg opt -> do-                      let tldName = "TopLevel" ++ uppercaseFirstLetter arg-                      case safeRead tldName of-                        Just tlDiv -> return opt { optTopLevelDivision = tlDiv }-                        _       -> E.throwIO $ PandocOptionError-                                     ("Top-level division must be " ++-                                      "section,  chapter, part, or default"))+                  (\arg opt ->+                      case arg of+                        "section" -> return opt{ optTopLevelDivision =+                                        TopLevelSection }+                        "chapter" -> return opt{ optTopLevelDivision =+                                        TopLevelChapter }+                        "part"    -> return opt{ optTopLevelDivision =+                                        TopLevelPart }+                        "default" -> return opt{ optTopLevelDivision =+                                        TopLevelDefault }+                        _ -> E.throwIO $ PandocOptionError $+                                "Top-level division must be " <>+                                "section,  chapter, part, or default" )                    "section|chapter|part")                  "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook" @@ -260,24 +289,21 @@     , Option "H" ["include-in-header"]                  (ReqArg                   (\arg opt -> return opt{ optIncludeInHeader =-                                              arg : optIncludeInHeader opt,-                                            optStandalone = True })+                                             optIncludeInHeader opt ++ [arg] })                   "FILE")                  "" -- "File to include at end of header (implies -s)"      , Option "B" ["include-before-body"]                  (ReqArg                   (\arg opt -> return opt{ optIncludeBeforeBody =-                                              arg : optIncludeBeforeBody opt,-                                           optStandalone = True })+                                            optIncludeBeforeBody opt ++ [arg] })                   "FILE")                  "" -- "File to include before document body"      , Option "A" ["include-after-body"]                  (ReqArg                   (\arg opt -> return opt{ optIncludeAfterBody =-                                              arg : optIncludeAfterBody opt,-                                           optStandalone = True })+                                            optIncludeAfterBody opt ++ [arg] })                   "FILE")                  "" -- "File to include after document body" @@ -288,8 +314,8 @@      , Option "" ["highlight-style"]                 (ReqArg-                 (\arg opt -> lookupHighlightStyle arg >>= \style ->-                     return opt{ optHighlightStyle = style })+                 (\arg opt ->+                     return opt{ optHighlightStyle = Just $ T.pack arg })                  "STYLE|FILE")                  "" -- "Style for highlighted code" @@ -310,7 +336,7 @@     , Option "" ["dpi"]                  (ReqArg                   (\arg opt ->-                    case safeRead arg of+                    case safeStrRead arg of                          Just t | t > 0 -> return opt { optDpi = t }                          _              -> E.throwIO $ PandocOptionError                                         "dpi must be a number greater than 0")@@ -333,7 +359,7 @@     , Option "" ["columns"]                  (ReqArg                   (\arg opt ->-                      case safeRead arg of+                      case safeStrRead arg of                            Just t | t > 0 -> return opt { optColumns = t }                            _              -> E.throwIO $ PandocOptionError                                    "columns must be a number greater than 0")@@ -348,7 +374,7 @@     , Option "" ["tab-stop"]                  (ReqArg                   (\arg opt ->-                      case safeRead arg of+                      case safeStrRead arg of                            Just t | t > 0 -> return opt { optTabStop = t }                            _              -> E.throwIO $ PandocOptionError                                   "tab-stop must be a number greater than 0")@@ -361,7 +387,7 @@                      let b = takeBaseName arg                      if b `elem` pdfEngines                         then return opt { optPdfEngine = Just arg }-                        else E.throwIO $ PandocOptionError $ "pdf-engine must be one of "+                        else E.throwIO $ PandocOptionError $ T.pack $ "pdf-engine must be one of "                                ++ intercalate ", " pdfEngines)                   "PROGRAM")                  "" -- "Name of program to use in generating PDF"@@ -369,8 +395,8 @@     , Option "" ["pdf-engine-opt"]                  (ReqArg                   (\arg opt -> do-                      let oldArgs = optPdfEngineArgs opt-                      return opt { optPdfEngineArgs = oldArgs ++ [arg]})+                      let oldArgs = optPdfEngineOpts opt+                      return opt { optPdfEngineOpts = oldArgs ++ [arg]})                   "STRING")                  "" -- "Flags to pass to the PDF-engine, all instances of this option are accumulated and used" @@ -383,8 +409,7 @@      , Option "" ["self-contained"]                  (NoArg-                  (\opt -> return opt { optSelfContained = True,-                                        optStandalone = True }))+                  (\opt -> return opt { optSelfContained = True }))                  "" -- "Make slide shows include all the needed js and css"      , Option "" ["request-header"]@@ -392,15 +417,10 @@                   (\arg opt -> do                      let (key, val) = splitField arg                      return opt{ optRequestHeaders =-                       (key, val) : optRequestHeaders opt })+                       (T.pack key, T.pack val) : optRequestHeaders opt })                   "NAME:VALUE")                  "" -    , Option "" ["file-scope"]-                 (NoArg-                  (\opt -> return opt { optFileScope = True }))-                 "" -- "Parse input files before combining"-     , Option "" ["abbreviations"]                 (ReqArg                  (\arg opt -> return opt { optAbbreviations = Just arg })@@ -409,39 +429,51 @@      , Option "" ["indented-code-classes"]                   (ReqArg-                   (\arg opt -> return opt { optIndentedCodeClasses = words $-                                             map (\c -> if c == ',' then ' ' else c) arg })+                   (\arg opt -> return opt { optIndentedCodeClasses = T.words $+                                             T.map (\c -> if c == ',' then ' ' else c) $+                                             T.pack arg })                    "STRING")                   "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"      , Option "" ["default-image-extension"]                  (ReqArg-                  (\arg opt -> return opt { optDefaultImageExtension = arg })+                  (\arg opt -> return opt { optDefaultImageExtension = T.pack arg })                    "extension")                   "" -- "Default extension for extensionless images"      , Option "F" ["filter"]                  (ReqArg                   (\arg opt -> return opt { optFilters =-                                    JSONFilter (normalizePath arg) :-                                    optFilters opt })+                      optFilters opt ++ [JSONFilter (normalizePath arg)] })                   "PROGRAM")                  "" -- "External JSON filter" -    , Option "" ["lua-filter"]+    , Option "L" ["lua-filter"]                  (ReqArg                   (\arg opt -> return opt { optFilters =-                                    LuaFilter (normalizePath arg) :-                                    optFilters opt })+                      optFilters opt ++ [LuaFilter (normalizePath arg)] })                   "SCRIPTPATH")                  "" -- "Lua filter" -    , Option "" ["base-header-level"]+    , Option "" ["shift-heading-level-by"]                  (ReqArg                   (\arg opt ->-                      case safeRead arg of+                      case safeStrRead arg of+                           Just t ->+                               return opt{ optShiftHeadingLevelBy = t }+                           _              -> E.throwIO $ PandocOptionError+                                               "shift-heading-level-by takes an integer argument")+                  "NUMBER")+                 "" -- "Shift heading level"++    , Option "" ["base-header-level"]+                 (ReqArg+                  (\arg opt -> do+                      deprecatedOption "--base-header-level"+                        "Use --shift-heading-level-by instead."+                      case safeStrRead arg of                            Just t | t > 0 && t < 6 ->-                               return opt{ optBaseHeaderLevel = t }+                               return opt{ optShiftHeadingLevelBy = t - 1 }                            _              -> E.throwIO $ PandocOptionError                                                "base-header-level must be 1-5")                   "NUMBER")@@ -450,7 +482,7 @@     , Option "" ["strip-empty-paragraphs"]                  (NoArg                   (\opt -> do-                      deprecatedOption "--stripEmptyParagraphs"+                      deprecatedOption "--strip-empty-paragraphs"                         "Use +empty_paragraphs extension."                       return opt{ optStripEmptyParagraphs = True }))                  "" -- "Strip empty paragraphs"@@ -462,7 +494,7 @@                             "accept" -> return AcceptChanges                             "reject" -> return RejectChanges                             "all"    -> return AllChanges-                            _        -> E.throwIO $ PandocOptionError+                            _        -> E.throwIO $ PandocOptionError $ T.pack                                ("Unknown option for track-changes: " ++ arg)                      return opt { optTrackChanges = action })                   "accept|reject|all")@@ -485,7 +517,7 @@                             "block"    -> return EndOfBlock                             "section"  -> return EndOfSection                             "document" -> return EndOfDocument-                            _        -> E.throwIO $ PandocOptionError+                            _        -> E.throwIO $ PandocOptionError $ T.pack                                ("Unknown option for reference-location: " ++ arg)                      return opt { optReferenceLocation = action })                   "block|section|document")@@ -509,7 +541,7 @@     , Option "" ["slide-level"]                  (ReqArg                   (\arg opt ->-                      case safeRead arg of+                      case safeStrRead arg of                            Just t | t >= 1 && t <= 6 ->                                     return opt { optSlideLevel = Just t }                            _      -> E.throwIO $ PandocOptionError@@ -535,7 +567,7 @@                             "references" -> return ReferenceObfuscation                             "javascript" -> return JavascriptObfuscation                             "none"       -> return NoObfuscation-                            _            -> E.throwIO $ PandocOptionError+                            _            -> E.throwIO $ PandocOptionError $ T.pack                                ("Unknown obfuscation method: " ++ arg)                      return opt { optEmailObfuscation = method })                   "none|javascript|references")@@ -543,22 +575,23 @@       , Option "" ["id-prefix"]                   (ReqArg-                   (\arg opt -> return opt { optIdentifierPrefix = arg })+                   (\arg opt -> return opt { optIdentifierPrefix = T.pack arg })                    "STRING")                   "" -- "Prefix to add to automatically generated HTML identifiers"      , Option "T" ["title-prefix"]                  (ReqArg-                  (\arg opt -> do-                    let newvars = ("title-prefix", arg) : optVariables opt-                    return opt { optVariables = newvars,-                                 optStandalone = True })+                  (\arg opt ->+                    return opt {+                       optVariables =+                         setVariable "title-prefix" arg $ optVariables opt,+                       optStandalone = True })                   "STRING")                  "" -- "String to prefix to HTML window title"      , Option "c" ["css"]                  (ReqArg-                  (\arg opt -> return opt{ optCss = arg : optCss opt })+                  (\arg opt -> return opt{ optCss = optCss opt ++ [arg] })                   -- add new link to end, so it is included in proper order                   "URL")                  "" -- "Link to CSS style sheet"@@ -574,7 +607,8 @@                  (ReqArg                   (\arg opt ->                      return opt { optVariables =-                                 ("epub-cover-image", arg) : optVariables opt })+                       setVariable "epub-cover-image" arg $+                         optVariables opt })                   "FILE")                  "" -- "Path of epub cover image" @@ -594,7 +628,7 @@     , Option "" ["epub-chapter-level"]                  (ReqArg                   (\arg opt ->-                      case safeRead arg of+                      case safeStrRead arg of                            Just t | t >= 1 && t <= 6 ->                                     return opt { optEpubChapterLevel = t }                            _      -> E.throwIO $ PandocOptionError@@ -605,17 +639,20 @@     , Option "" ["ipynb-output"]                  (ReqArg                   (\arg opt ->-                    if arg `notElem` ["all","none","best"]-                       then E.throwIO $ PandocOptionError $-                             "ipynb-output must be all, none, or best"-                       else return opt { optIpynbOutput = arg })+                    case arg of+                      "all" -> return opt{ optIpynbOutput = IpynbOutputAll }+                      "best" -> return opt{ optIpynbOutput = IpynbOutputBest }+                      "none" -> return opt{ optIpynbOutput = IpynbOutputNone }+                      _ -> E.throwIO $ PandocOptionError $+                             "ipynb-output must be all, none, or best")                  "all|none|best")                  "" -- "Starting number for sections, subsections, etc."      , Option "" ["bibliography"]                  (ReqArg                   (\arg opt -> return opt{ optMetadata =-                                 ("bibliography", arg) : optMetadata opt })+                                            addMeta "bibliography" arg $+                                              optMetadata opt })                    "FILE")                  "" @@ -623,7 +660,7 @@                  (ReqArg                   (\arg opt ->                      return opt{ optMetadata =-                                   ("csl", arg) : optMetadata opt })+                                   addMeta "csl" arg $ optMetadata opt })                    "FILE")                  "" @@ -631,7 +668,8 @@                  (ReqArg                   (\arg opt ->                      return opt{ optMetadata =-                              ("citation-abbreviations", arg): optMetadata opt })+                                  addMeta "citation-abbreviations" arg $+                                    optMetadata opt })                    "FILE")                  "" @@ -655,15 +693,15 @@                  (OptArg                   (\arg opt -> do                       let url' = fromMaybe "https://latex.codecogs.com/png.latex?" arg-                      return opt { optHTMLMathMethod = WebTeX url' })+                      return opt { optHTMLMathMethod = WebTeX $ T.pack url' })                   "URL")                  "" -- "Use web service for HTML math"      , Option "" ["mathjax"]                  (OptArg                   (\arg opt -> do-                      let url' = fromMaybe (defaultMathJaxURL ++-                                  "MathJax.js?config=TeX-AMS_CHTML-full") arg+                      let url' = maybe (defaultMathJaxURL <>+                                  "tex-mml-chtml.js") T.pack arg                       return opt { optHTMLMathMethod = MathJax url'})                   "URL")                  "" -- "Use MathJax for HTML math"@@ -673,7 +711,7 @@                   (\arg opt ->                       return opt                         { optHTMLMathMethod = KaTeX $-                           fromMaybe defaultKaTeXURL arg })+                           maybe defaultKaTeXURL T.pack arg })                   "URL")                   "" -- Use KaTeX for HTML Math @@ -733,7 +771,7 @@                      UTF8.hPutStrLn stdout $ printf tpl allopts                          (unwords readersNames)                          (unwords writersNames)-                         (unwords $ map fst highlightingStyles)+                         (unwords $ map (T.unpack . fst) highlightingStyles)                          (unwords datafiles)                      exitSuccess ))                  "" -- "Print bash completion script"@@ -755,12 +793,25 @@     , Option "" ["list-extensions"]                  (OptArg                   (\arg _ -> do-                     let exts = getDefaultExtensions (fromMaybe "markdown" arg)-                     let showExt x = (if extensionEnabled x exts-                                         then '+'-                                         else '-') : drop 4 (show x)+                     let extList :: [Extension]+                         extList = [minBound..maxBound]+                     let allExts =+                           case arg of+                             Nothing  -> extensionsFromList extList+                             Just fmt -> getAllExtensions $ T.pack fmt+                     let defExts =+                           case arg of+                             Nothing   -> getDefaultExtensions+                                           "markdown"+                             Just fmt  -> getDefaultExtensions $ T.pack fmt+                     let showExt x =+                           (if extensionEnabled x defExts+                               then '+'+                               else if extensionEnabled x allExts+                                       then '-'+                                       else ' ') : drop 4 (show x)                      mapM_ (UTF8.hPutStrLn stdout . showExt)-                               ([minBound..maxBound] :: [Extension])+                       [ex | ex <- extList, extensionEnabled ex allExts]                      exitSuccess )                   "FORMAT")                  ""@@ -780,7 +831,7 @@     , Option "" ["list-highlight-styles"]                  (NoArg                   (\_ -> do-                     mapM_ (UTF8.hPutStrLn stdout . fst) highlightingStyles+                     mapM_ (UTF8.hPutStrLn stdout . T.unpack . fst) highlightingStyles                      exitSuccess ))                  "" @@ -792,12 +843,13 @@                                         Nothing -> UTF8.hPutStr stdout                      templ <- runIO $ do                                 setUserDataDir Nothing-                                getDefaultTemplate arg+                                getDefaultTemplate (T.pack arg)                      case templ of-                          Right "" -> -- e.g. for docx, odt, json:-                            E.throwIO $ PandocCouldNotFindDataFileError-                               ("templates/default." ++ arg)-                          Right t -> write t+                          Right t+                            | T.null t -> -- e.g. for docx, odt, json:+                                E.throwIO $ PandocCouldNotFindDataFileError $ T.pack+                                  ("templates/default." ++ arg)+                            | otherwise -> write . T.unpack $ t                           Left e  -> E.throwIO e                      exitSuccess)                   "FORMAT")@@ -821,7 +873,7 @@                      let write = case optOutputFile opt of                                         Just f  -> B.writeFile f                                         Nothing -> B.putStr-                     sty <- fromMaybe pygments <$> lookupHighlightStyle arg+                     sty <- runIOorExplode $ lookupHighlightStyle arg                      write $ encodePretty'                        defConfig{confIndent = Spaces 4                                 ,confCompare = keyOrder@@ -846,7 +898,7 @@                   (\_ -> do                      prg <- getProgName                      defaultDatadirs <- defaultUserDataDirs-                     UTF8.hPutStrLn stdout (prg ++ " " ++ pandocVersion +++                     UTF8.hPutStrLn stdout (prg ++ " " ++ T.unpack pandocVersion ++                        compileInfo ++ "\nDefault user data directory: " ++                        intercalate " or " defaultDatadirs ++                        ('\n':copyrightMessage))@@ -918,28 +970,86 @@ handleUnrecognizedOption x =   (("Unknown option " ++ x ++ ".") :) -uppercaseFirstLetter :: String -> String-uppercaseFirstLetter (c:cs) = toUpper c : cs-uppercaseFirstLetter []     = []- readersNames :: [String]-readersNames = sort (map fst (readers :: [(String, Reader PandocIO)]))+readersNames = sort (map (T.unpack . fst) (readers :: [(Text, Reader PandocIO)]))  writersNames :: [String]-writersNames = sort (map fst (writers :: [(String, Writer PandocIO)]))+writersNames = sort (map (T.unpack . fst) (writers :: [(Text, Writer PandocIO)]))  splitField :: String -> (String, String) splitField s =-  case break (`elem` ":=") s of+  case break (`elemText` ":=") s of        (k,_:v) -> (k,v)        (k,[])  -> (k,"true") +-- | Apply defaults from --defaults file.+applyDefaults :: Opt -> FilePath -> IO Opt+applyDefaults opt file = runIOorExplode $ do+  let fp = if null (takeExtension file)+              then addExtension file "yaml"+              else file+  setVerbosity $ optVerbosity opt+  dataDirs <- liftIO defaultUserDataDirs+  let fps = case optDataDir opt of+              Nothing -> (fp : map (</> ("defaults" </> fp))+                               dataDirs)+              Just dd -> [fp, dd </> "defaults" </> fp]+  fp' <- fromMaybe fp <$> findFile fps+  inp <- readFileLazy fp'+  case Y.decode1 inp of+      Right (f :: Opt -> Opt) -> return $ f opt+      Left (errpos, errmsg)  -> throwError $+         PandocParseError $ T.pack $+         "Error parsing " ++ fp' ++ " line " +++          show (Y.posLine errpos) ++ " column " +++          show (Y.posColumn errpos) ++ ":\n" ++ errmsg++lookupHighlightStyle :: PandocMonad m => String -> m Style+lookupHighlightStyle s+  | takeExtension s == ".theme" = -- attempt to load KDE theme+    do contents <- readFileLazy s+       case parseTheme contents of+            Left _    -> throwError $ PandocOptionError $ T.pack $+                           "Could not read highlighting theme " ++ s+            Right sty -> return sty+  | otherwise =+  case lookup (T.toLower $ T.pack s) highlightingStyles of+       Just sty -> return sty+       Nothing  -> throwError $ PandocOptionError $ T.pack $+                      "Unknown highlight-style " ++ s+ deprecatedOption :: String -> String -> IO () deprecatedOption o msg =-  runIO (report $ Deprecated o msg) >>=+  runIO (report $ Deprecated (T.pack o) (T.pack msg)) >>=     \r -> case r of        Right () -> return ()        Left e   -> E.throwIO e++-- | Set text value in text context.+setVariable :: String -> String -> Context Text -> Context Text+setVariable key val (Context ctx) =+  Context $ M.insert (T.pack key) (toVal (T.pack val)) ctx++addMeta :: String -> String -> Meta -> Meta+addMeta k v meta =+  case lookupMeta k' meta of+       Nothing -> setMeta k' v' meta+       Just (MetaList xs) ->+                  setMeta k' (MetaList (xs ++ [v'])) meta+       Just x  -> setMeta k' (MetaList [x, v']) meta+ where+  v' = readMetaValue v+  k' = T.pack k++readMetaValue :: String -> MetaValue+readMetaValue s+  | s == "true"  = MetaBool True+  | s == "True"  = MetaBool True+  | s == "TRUE"  = MetaBool True+  | s == "false" = MetaBool False+  | s == "False" = MetaBool False+  | s == "FALSE" = MetaBool False+  | otherwise    = MetaString $ T.pack s  -- On Windows with ghc 8.6+, we need to rewrite paths -- beginning with \\ to \\?\UNC\. -- See #5127.
src/Text/Pandoc/App/FormatHeuristics.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.App.FormatHeuristics    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -16,18 +17,19 @@  import Prelude import Data.Char (toLower)+import Data.Text (Text) import System.FilePath (takeExtension) --- Determine default reader based on source file extensions.-formatFromFilePaths :: String -> [FilePath] -> String-formatFromFilePaths fallback [] = fallback-formatFromFilePaths fallback (x:xs) =+-- Determine default format based on file extensions.+formatFromFilePaths :: [FilePath] -> Maybe Text+formatFromFilePaths [] = Nothing+formatFromFilePaths (x:xs) =   case formatFromFilePath x of-    Just f     -> f-    Nothing    -> formatFromFilePaths fallback xs+    Just f     -> Just f+    Nothing    -> formatFromFilePaths xs  -- Determine format based on file extension-formatFromFilePath :: FilePath -> Maybe String+formatFromFilePath :: FilePath -> Maybe Text formatFromFilePath x =   case takeExtension (map toLower x) of     ".adoc"     -> Just "asciidoc"
src/Text/Pandoc/App/Opt.hs view
@@ -1,9 +1,10 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE CPP                 #-} {-# LANGUAGE DeriveGeneric       #-}-#ifdef DERIVE_JSON_VIA_TH {-# LANGUAGE TemplateHaskell     #-}-#endif+{-# LANGUAGE FlexibleInstances   #-} {- |    Module      : Text.Pandoc.App.Opt    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -18,12 +19,13 @@ module Text.Pandoc.App.Opt (             Opt(..)           , LineEnding (..)+          , IpynbOutput (..)           , defaultOpts           ) where import Prelude-import GHC.Generics+import Data.Char (isLower, toLower)+import GHC.Generics hiding (Meta) import Text.Pandoc.Filter (Filter (..))-import Text.Pandoc.Highlighting (Style, pygments) import Text.Pandoc.Logging (Verbosity (WARNING)) import Text.Pandoc.Options (TopLevelDivision (TopLevelDefault),                             TrackChanges (AcceptChanges),@@ -31,39 +33,66 @@                             ReferenceLocation (EndOfDocument),                             ObfuscationMethod (NoObfuscation),                             CiteMethod (Citeproc))--#ifdef DERIVE_JSON_VIA_TH-import Data.Aeson.TH (deriveJSON, defaultOptions)-#else-import Data.Aeson (FromJSON (..), ToJSON (..),-                   defaultOptions, genericToEncoding)-#endif+import Text.Pandoc.Shared (camelCaseStrToHyphenated)+import Text.DocLayout (render)+import Text.DocTemplates (Context(..), Val(..))+import Data.Text (Text, unpack)+import qualified Data.Text as T+import qualified Data.Map as M+import Text.Pandoc.Definition (Meta(..), MetaValue(..))+import Data.Aeson (defaultOptions, Options(..))+import Data.Aeson.TH (deriveJSON)+import Control.Applicative ((<|>))+import Data.YAML  -- | The type of line-endings to be used when writing plain-text. data LineEnding = LF | CRLF | Native deriving (Show, Generic) +instance FromYAML LineEnding where+  parseYAML = withStr "LineEnding" $ \t ->+    case T.toLower t of+      "lf"     -> return LF+      "crlf"   -> return CRLF+      "native" -> return Native+      _        -> fail $ "Unknown line ending type " ++ show t++-- | How to handle output blocks in ipynb.+data IpynbOutput =+    IpynbOutputAll+  | IpynbOutputNone+  | IpynbOutputBest+  deriving (Show, Generic)++instance FromYAML IpynbOutput where+  parseYAML = withStr "LineEnding" $ \t ->+    case t of+      "none"  -> return IpynbOutputNone+      "all"   -> return IpynbOutputAll+      "best"  -> return IpynbOutputBest+      _       -> fail $ "Unknown ipynb output type " ++ show t+ -- | Data structure for command line options. data Opt = Opt     { optTabStop               :: Int     -- ^ Number of spaces per tab     , optPreserveTabs          :: Bool    -- ^ Preserve tabs instead of converting to spaces     , optStandalone            :: Bool    -- ^ Include header, footer-    , optReader                :: Maybe String  -- ^ Reader format-    , optWriter                :: Maybe String  -- ^ Writer format+    , optFrom                  :: Maybe Text  -- ^ Reader format+    , optTo                    :: Maybe Text  -- ^ Writer format     , optTableOfContents       :: Bool    -- ^ Include table of contents-    , optBaseHeaderLevel       :: Int     -- ^ Base header level+    , optShiftHeadingLevelBy   :: Int     -- ^ Shift heading level by     , optTemplate              :: Maybe FilePath  -- ^ Custom template-    , optVariables             :: [(String,String)] -- ^ Template variables to set-    , optMetadata              :: [(String, String)] -- ^ Metadata fields to set-    , optMetadataFile          :: Maybe FilePath  -- ^ Name of YAML metadata file+    , optVariables             :: Context Text    -- ^ Template variables to set+    , optMetadata              :: Meta -- ^ Metadata fields to set+    , optMetadataFiles         :: [FilePath]  -- ^ Name of YAML metadata files     , optOutputFile            :: Maybe FilePath  -- ^ Name of output file-    , optInputFiles            :: [FilePath] -- ^ Names of input files+    , optInputFiles            :: Maybe [FilePath] -- ^ Names of input files     , optNumberSections        :: Bool    -- ^ Number sections in LaTeX     , optNumberOffset          :: [Int]   -- ^ Starting number for sections     , optSectionDivs           :: Bool    -- ^ Put sections in div tags in HTML     , optIncremental           :: Bool    -- ^ Use incremental lists in Slidy/Slideous/S5     , optSelfContained         :: Bool    -- ^ Make HTML accessible offline     , optHtmlQTags             :: Bool    -- ^ Use <q> tags in HTML-    , optHighlightStyle        :: Maybe Style -- ^ Style to use for highlighted code+    , optHighlightStyle        :: Maybe Text -- ^ Style to use for highlighted code     , optSyntaxDefinitions     :: [FilePath]  -- ^ xml syntax defs to load     , optTopLevelDivision      :: TopLevelDivision -- ^ Type of the top-level divisions     , optHTMLMathMethod        :: HTMLMathMethod -- ^ Method to print HTML math@@ -84,60 +113,294 @@     , optReferenceLinks        :: Bool    -- ^ Use reference links in writing markdown, rst     , optReferenceLocation     :: ReferenceLocation -- ^ location for footnotes and link references in markdown output     , optDpi                   :: Int     -- ^ Dpi-    , optWrapText              :: WrapOption  -- ^ Options for wrapping text+    , optWrap                  :: WrapOption  -- ^ Options for wrapping text     , optColumns               :: Int     -- ^ Line length in characters     , optFilters               :: [Filter] -- ^ Filters to apply     , optEmailObfuscation      :: ObfuscationMethod-    , optIdentifierPrefix      :: String+    , optIdentifierPrefix      :: Text     , optStripEmptyParagraphs  :: Bool -- ^ Strip empty paragraphs-    , optIndentedCodeClasses   :: [String] -- ^ Default classes for indented code blocks+    , optIndentedCodeClasses   :: [Text] -- ^ Default classes for indented code blocks     , optDataDir               :: Maybe FilePath     , optCiteMethod            :: CiteMethod -- ^ Method to output cites     , optListings              :: Bool       -- ^ Use listings package for code blocks     , optPdfEngine             :: Maybe String -- ^ Program to use for latex/html -> pdf-    , optPdfEngineArgs         :: [String]   -- ^ Flags to pass to the engine+    , optPdfEngineOpts         :: [String]   -- ^ Flags to pass to the engine     , optSlideLevel            :: Maybe Int  -- ^ Header level that creates slides     , optSetextHeaders         :: Bool       -- ^ Use atx headers for markdown level 1-2     , optAscii                 :: Bool       -- ^ Prefer ascii output-    , optDefaultImageExtension :: String -- ^ Default image extension+    , optDefaultImageExtension :: Text       -- ^ Default image extension     , optExtractMedia          :: Maybe FilePath -- ^ Path to extract embedded media     , optTrackChanges          :: TrackChanges -- ^ Accept or reject MS Word track-changes.     , optFileScope             :: Bool         -- ^ Parse input files before combining-    , optTitlePrefix           :: Maybe String     -- ^ Prefix for title+    , optTitlePrefix           :: Maybe Text     -- ^ Prefix for title     , optCss                   :: [FilePath]       -- ^ CSS files to link to-    , optIpynbOutput           :: String           -- ^ Maybe f to use best data; Nothing to omit+    , optIpynbOutput           :: IpynbOutput      -- ^ How to treat ipynb output blocks     , optIncludeBeforeBody     :: [FilePath]       -- ^ Files to include before     , optIncludeAfterBody      :: [FilePath]       -- ^ Files to include after body     , optIncludeInHeader       :: [FilePath]       -- ^ Files to include in header     , optResourcePath          :: [FilePath] -- ^ Path to search for images etc-    , optRequestHeaders        :: [(String, String)] -- ^ Headers for HTTP requests+    , optRequestHeaders        :: [(Text, Text)] -- ^ Headers for HTTP requests     , optEol                   :: LineEnding -- ^ Style of line-endings to use     , optStripComments         :: Bool       -- ^ Skip HTML comments     } deriving (Generic, Show) +instance FromYAML (Opt -> Opt) where+  parseYAML (Mapping _ _ m) =+    foldr (.) id <$> mapM doOpt (M.toList m)+  parseYAML n = failAtNode n "Expected a mapping"++doOpt :: (Node Pos, Node Pos) -> Parser (Opt -> Opt)+doOpt (k',v) = do+  k <- case k' of+         Scalar _ (SStr t) -> return t+         Scalar _ _ -> failAtNode k' "Non-string key"+         _ -> failAtNode k' "Non-scalar key"+  case k of+    "tab-stop" ->+      parseYAML v >>= \x -> return (\o -> o{ optTabStop = x })+    "preserve-tabs" ->+      parseYAML v >>= \x -> return (\o -> o{ optPreserveTabs = x })+    "standalone" ->+      parseYAML v >>= \x -> return (\o -> o{ optStandalone = x })+    "table-of-contents" ->+      parseYAML v >>= \x -> return (\o -> o{ optTableOfContents = x })+    "toc" ->+      parseYAML v >>= \x -> return (\o -> o{ optTableOfContents = x })+    "from" ->+      parseYAML v >>= \x -> return (\o -> o{ optFrom = x })+    "reader" ->+      parseYAML v >>= \x -> return (\o -> o{ optFrom = x })+    "to" ->+      parseYAML v >>= \x -> return (\o -> o{ optTo = x })+    "writer" ->+      parseYAML v >>= \x -> return (\o -> o{ optTo = x })+    "shift-heading-level-by" ->+      parseYAML v >>= \x -> return (\o -> o{ optShiftHeadingLevelBy = x })+    "template" ->+      parseYAML v >>= \x -> return (\o -> o{ optTemplate = unpack <$> x })+    "variables" ->+      parseYAML v >>= \x -> return (\o -> o{ optVariables =+                                               optVariables o <> x })+    "metadata" ->+      parseYAML v >>= \x -> return (\o -> o{ optMetadata = optMetadata o <>+                                               contextToMeta x })+    "metadata-files" ->+      (parseYAML v >>= \x ->+                        return (\o -> o{ optMetadataFiles =+                                           optMetadataFiles o <>+                                           map unpack x }))+    "metadata-file" -> -- allow either a list or a single value+      (parseYAML v >>= \x -> return (\o -> o{ optMetadataFiles =+                                                optMetadataFiles o <>+                                                map unpack x }))+      <|>+      (parseYAML v >>= \x ->+                        return (\o -> o{ optMetadataFiles =+                                           optMetadataFiles o <>[unpack x] }))+    "output-file" ->+      parseYAML v >>= \x -> return (\o -> o{ optOutputFile = unpack <$> x })+    "input-files" ->+      parseYAML v >>= \x -> return (\o -> o{ optInputFiles =+                                              optInputFiles o <>+                                                (map unpack <$> x) })+    "input-file" -> -- allow either a list or a single value+      (parseYAML v >>= \x -> return (\o -> o{ optInputFiles =+                                                optInputFiles o <>+                                                  (map unpack <$> x) }))+      <|>+      (parseYAML v >>= \x -> return (\o -> o{ optInputFiles =+                                                optInputFiles o <>+                                                ((\z -> [unpack z]) <$> x)+                                            }))+    "number-sections" ->+      parseYAML v >>= \x -> return (\o -> o{ optNumberSections = x })+    "number-offset" ->+      parseYAML v >>= \x -> return (\o -> o{ optNumberOffset = x })+    "section-divs" ->+      parseYAML v >>= \x -> return (\o -> o{ optSectionDivs = x })+    "incremental" ->+      parseYAML v >>= \x -> return (\o -> o{ optIncremental = x })+    "self-contained" ->+      parseYAML v >>= \x -> return (\o -> o{ optSelfContained = x })+    "html-q-tags" ->+      parseYAML v >>= \x -> return (\o -> o{ optHtmlQTags = x })+    "highlight-style" ->+      parseYAML v >>= \x -> return (\o -> o{ optHighlightStyle = x })+    "syntax-definition" ->+      (parseYAML v >>= \x ->+                return (\o -> o{ optSyntaxDefinitions =+                                   optSyntaxDefinitions o <> map unpack x }))+      <|>+      (parseYAML v >>= \x ->+             return (\o -> o{ optSyntaxDefinitions =+                                 optSyntaxDefinitions o <> [unpack x] }))+    "syntax-definitions" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optSyntaxDefinitions =+                                optSyntaxDefinitions o <> map unpack x })+    "top-level-division" ->+      parseYAML v >>= \x -> return (\o -> o{ optTopLevelDivision = x })+    "html-math-method" ->+      parseYAML v >>= \x -> return (\o -> o{ optHTMLMathMethod = x })+    "abbreviations" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optAbbreviations = unpack <$> x })+    "reference-doc" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optReferenceDoc = unpack <$> x })+    "epub-subdirectory" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optEpubSubdirectory = unpack x })+    "epub-metadata" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optEpubMetadata = unpack <$> x })+    "epub-fonts" ->+      parseYAML v >>= \x -> return (\o -> o{ optEpubFonts = optEpubFonts o <>+                                               map unpack x })+    "epub-chapter-level" ->+      parseYAML v >>= \x -> return (\o -> o{ optEpubChapterLevel = x })+    "epub-cover-image" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optEpubCoverImage = unpack <$> x })+    "toc-depth" ->+      parseYAML v >>= \x -> return (\o -> o{ optTOCDepth = x })+    "dump-args" ->+      parseYAML v >>= \x -> return (\o -> o{ optDumpArgs = x })+    "ignore-args" ->+      parseYAML v >>= \x -> return (\o -> o{ optIgnoreArgs = x })+    "verbosity" ->+      parseYAML v >>= \x -> return (\o -> o{ optVerbosity = x })+    "trace" ->+      parseYAML v >>= \x -> return (\o -> o{ optTrace = x })+    "log-file" ->+      parseYAML v >>= \x -> return (\o -> o{ optLogFile = unpack <$> x })+    "fail-if-warnings" ->+      parseYAML v >>= \x -> return (\o -> o{ optFailIfWarnings = x })+    "reference-links" ->+      parseYAML v >>= \x -> return (\o -> o{ optReferenceLinks = x })+    "reference-location" ->+      parseYAML v >>= \x -> return (\o -> o{ optReferenceLocation = x })+    "dpi" ->+      parseYAML v >>= \x -> return (\o -> o{ optDpi = x })+    "wrap" ->+      parseYAML v >>= \x -> return (\o -> o{ optWrap = x })+    "columns" ->+      parseYAML v >>= \x -> return (\o -> o{ optColumns = x })+    "filters" ->+      parseYAML v >>= \x -> return (\o -> o{ optFilters = optFilters o <> x })+    "email-obfuscation" ->+      parseYAML v >>= \x -> return (\o -> o{ optEmailObfuscation = x })+    "identifier-prefix" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optIdentifierPrefix = x })+    "strip-empty-paragraphs" ->+      parseYAML v >>= \x -> return (\o -> o{ optStripEmptyParagraphs = x })+    "indented-code-classes" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optIndentedCodeClasses = x })+    "data-dir" ->+      parseYAML v >>= \x -> return (\o -> o{ optDataDir = unpack <$> x })+    "cite-method" ->+      parseYAML v >>= \x -> return (\o -> o{ optCiteMethod = x })+    "listings" ->+      parseYAML v >>= \x -> return (\o -> o{ optListings = x })+    "pdf-engine" ->+      parseYAML v >>= \x -> return (\o -> o{ optPdfEngine = unpack <$> x })+    "pdf-engine-opts" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optPdfEngineOpts = map unpack x })+    "pdf-engine-opt" ->+      (parseYAML v >>= \x ->+             return (\o -> o{ optPdfEngineOpts = map unpack x }))+      <|>+      (parseYAML v >>= \x ->+             return (\o -> o{ optPdfEngineOpts = [unpack x] }))+    "slide-level" ->+      parseYAML v >>= \x -> return (\o -> o{ optSlideLevel = x })+    "atx-headers" ->+      parseYAML v >>= \x -> return (\o -> o{ optSetextHeaders = not x })+    "ascii" ->+      parseYAML v >>= \x -> return (\o -> o{ optAscii = x })+    "default-image-extension" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optDefaultImageExtension = x })+    "extract-media" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optExtractMedia = unpack <$> x })+    "track-changes" ->+      parseYAML v >>= \x -> return (\o -> o{ optTrackChanges = x })+    "file-scope" ->+      parseYAML v >>= \x -> return (\o -> o{ optFileScope = x })+    "title-prefix" ->+      parseYAML v >>= \x -> return (\o -> o{ optTitlePrefix = x,+                                             optStandalone = True })+    "css" ->+      (parseYAML v >>= \x -> return (\o -> o{ optCss = optCss o <>+                                                 map unpack x }))+      <|>+      (parseYAML v >>= \x -> return (\o -> o{ optCss = optCss o <>+                                                [unpack x] }))+    "ipynb-output" ->+      parseYAML v >>= \x -> return (\o -> o{ optIpynbOutput = x })+    "include-before-body" ->+      (parseYAML v >>= \x ->+             return (\o -> o{ optIncludeBeforeBody =+                                optIncludeBeforeBody o <> map unpack x }))+      <|>+      (parseYAML v >>= \x ->+             return (\o -> o{ optIncludeBeforeBody =+                                optIncludeBeforeBody o <> [unpack x] }))+    "include-after-body" ->+      (parseYAML v >>= \x ->+             return (\o -> o{ optIncludeAfterBody =+                                optIncludeAfterBody o <> map unpack x }))+      <|>+      (parseYAML v >>= \x ->+             return (\o -> o{ optIncludeAfterBody =+                                optIncludeAfterBody o <> [unpack x] }))+    "include-in-header" ->+      (parseYAML v >>= \x ->+             return (\o -> o{ optIncludeInHeader =+                                optIncludeInHeader o <> map unpack x }))+      <|>+      (parseYAML v >>= \x ->+             return (\o -> o{ optIncludeInHeader =+                                optIncludeInHeader o <> [unpack x] }))+    "resource-path" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optResourcePath = map unpack x })+    "request-headers" ->+      parseYAML v >>= \x ->+             return (\o -> o{ optRequestHeaders = x })+    "eol" ->+      parseYAML v >>= \x -> return (\o -> o{ optEol = x })+    "strip-comments" ->+      parseYAML v >>= \x -> return (\o -> o  { optStripComments = x })+    _ -> failAtNode k' $ "Unknown option " ++ show k+ -- | Defaults for command-line options. defaultOpts :: Opt defaultOpts = Opt     { optTabStop               = 4     , optPreserveTabs          = False     , optStandalone            = False-    , optReader                = Nothing-    , optWriter                = Nothing+    , optFrom                  = Nothing+    , optTo                    = Nothing     , optTableOfContents       = False-    , optBaseHeaderLevel       = 1+    , optShiftHeadingLevelBy   = 0     , optTemplate              = Nothing-    , optVariables             = []-    , optMetadata              = []-    , optMetadataFile          = Nothing+    , optVariables             = mempty+    , optMetadata              = mempty+    , optMetadataFiles         = []     , optOutputFile            = Nothing-    , optInputFiles            = []+    , optInputFiles            = Nothing     , optNumberSections        = False     , optNumberOffset          = [0,0,0,0,0,0]     , optSectionDivs           = False     , optIncremental           = False     , optSelfContained         = False     , optHtmlQTags             = False-    , optHighlightStyle        = Just pygments+    , optHighlightStyle        = Just "pygments"     , optSyntaxDefinitions     = []     , optTopLevelDivision      = TopLevelDefault     , optHTMLMathMethod        = PlainMath@@ -158,7 +421,7 @@     , optReferenceLinks        = False     , optReferenceLocation     = EndOfDocument     , optDpi                   = 96-    , optWrapText              = WrapAuto+    , optWrap                  = WrapAuto     , optColumns               = 72     , optFilters               = []     , optEmailObfuscation      = NoObfuscation@@ -169,7 +432,7 @@     , optCiteMethod            = Citeproc     , optListings              = False     , optPdfEngine             = Nothing-    , optPdfEngineArgs         = []+    , optPdfEngineOpts         = []     , optSlideLevel            = Nothing     , optSetextHeaders         = True     , optAscii                 = False@@ -179,27 +442,34 @@     , optFileScope             = False     , optTitlePrefix           = Nothing     , optCss                   = []-    , optIpynbOutput           = "best"+    , optIpynbOutput           = IpynbOutputBest     , optIncludeBeforeBody     = []     , optIncludeAfterBody      = []     , optIncludeInHeader       = []     , optResourcePath          = ["."]     , optRequestHeaders        = []     , optEol                   = Native-    , optStripComments          = False+    , optStripComments         = False     } -#ifdef DERIVE_JSON_VIA_TH+contextToMeta :: Context Text -> Meta+contextToMeta (Context m) =+  Meta . M.map valToMetaVal $ m++valToMetaVal :: Val Text -> MetaValue+valToMetaVal (MapVal (Context m)) =+  MetaMap . M.map valToMetaVal $ m+valToMetaVal (ListVal xs) = MetaList $ map valToMetaVal xs+valToMetaVal (SimpleVal d) = MetaString $ render Nothing d+valToMetaVal NullVal = MetaString ""+ -- see https://github.com/jgm/pandoc/pull/4083 -- using generic deriving caused long compilation times-$(deriveJSON defaultOptions ''LineEnding)-$(deriveJSON defaultOptions ''Opt)-#else-instance ToJSON LineEnding where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON LineEnding--instance ToJSON Opt where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON Opt-#endif+$(deriveJSON+   defaultOptions{ fieldLabelModifier = drop 11 . map toLower } ''IpynbOutput)+$(deriveJSON+   defaultOptions{ fieldLabelModifier = map toLower } ''LineEnding)+$(deriveJSON+   defaultOptions{ fieldLabelModifier =+                      camelCaseStrToHyphenated . dropWhile isLower+                 } ''Opt)
src/Text/Pandoc/App/OutputSettings.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP                 #-} {-# LANGUAGE FlexibleContexts    #-} {-# LANGUAGE NoImplicitPrelude   #-}+{-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections       #-} {- |@@ -19,12 +20,15 @@   , optToOutputSettings   ) where import Prelude+import qualified Data.Map as M+import qualified Data.Text as T+import Text.DocTemplates (toVal, Context(..), Val(..)) import qualified Control.Exception as E import Control.Monad import Control.Monad.Except (catchError, throwError) import Control.Monad.Trans import Data.Char (toLower)-import Data.List (find, isPrefixOf, isSuffixOf)+import Data.List (find, isPrefixOf) import Data.Maybe (fromMaybe) import Skylighting (defaultSyntaxMap) import Skylighting.Parser (addSyntaxDefinition, parseSyntaxDefinition)@@ -32,25 +36,26 @@ import System.Exit (exitSuccess) import System.FilePath import System.IO (stdout)+import Data.String import Text.Pandoc import Text.Pandoc.App.FormatHeuristics (formatFromFilePaths) import Text.Pandoc.App.Opt (Opt (..))-import Text.Pandoc.App.CommandLineOptions (engines)-import Text.Pandoc.BCP47 (Lang (..), parseBCP47)+import Text.Pandoc.App.CommandLineOptions (engines, lookupHighlightStyle,+                                          setVariable) import qualified Text.Pandoc.UTF8 as UTF8 +readUtf8File :: PandocMonad m => FilePath -> m T.Text+readUtf8File = fmap UTF8.toText . readFileStrict+ -- | Settings specifying how document output should be produced. data OutputSettings = OutputSettings-  { outputFormat :: String+  { outputFormat :: T.Text   , outputWriter :: Writer PandocIO-  , outputWriterName :: String+  , outputWriterName :: T.Text   , outputWriterOptions :: WriterOptions   , outputPdfProgram :: Maybe String   } -readUtf8File :: PandocMonad m => FilePath -> m String-readUtf8File = fmap UTF8.toString . readFileStrict- -- | Get output settings from command line options. optToOutputSettings :: Opt -> PandocIO OutputSettings optToOutputSettings opts = do@@ -58,92 +63,102 @@    when (optDumpArgs opts) . liftIO $ do     UTF8.hPutStrLn stdout outputFile-    mapM_ (UTF8.hPutStrLn stdout) (optInputFiles opts)+    mapM_ (UTF8.hPutStrLn stdout) (fromMaybe [] $ optInputFiles opts)     exitSuccess    epubMetadata <- case optEpubMetadata opts of                          Nothing -> return Nothing                          Just fp -> Just <$> readUtf8File fp -  let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"+  let pdfOutput = map toLower (takeExtension outputFile) == ".pdf" ||+                  optTo opts == Just "pdf"   (writerName, maybePdfProg) <-     if pdfOutput-       then liftIO $ pdfWriterAndProg (optWriter opts) (optPdfEngine opts)-       else case optWriter opts of-              Nothing  ->-                return (formatFromFilePaths "html" [outputFile], Nothing)-              Just f   -> return (f, Nothing)+       then liftIO $ pdfWriterAndProg+               (case optTo opts of+                  Just "pdf" -> Nothing+                  x          -> x)+               (optPdfEngine opts)+       else case optTo opts of+              Just f -> return (f, Nothing)+              Nothing+               | outputFile == "-" -> return ("html", Nothing)+               | otherwise ->+                     case formatFromFilePaths [outputFile] of+                           Nothing -> do+                             report $ CouldNotDeduceFormat+                                [T.pack $ takeExtension outputFile] "html"+                             return ("html", Nothing)+                           Just f  -> return (f, Nothing) -  let format = if ".lua" `isSuffixOf` writerName+  let format = if ".lua" `T.isSuffixOf` writerName                   then writerName-                  else map toLower $ baseWriterName writerName+                  else T.toLower $ baseWriterName writerName -  (writer, writerExts) <--            if ".lua" `isSuffixOf` format+  (writer :: Writer PandocIO, writerExts) <-+            if ".lua" `T.isSuffixOf` format                then return (TextWriter-                       (\o d -> writeCustom writerName o d)+                       (\o d -> writeCustom (T.unpack writerName) o d)                                :: Writer PandocIO, mempty)-               else case getWriter (map toLower writerName) of-                         Left e  -> throwError $ PandocAppError $-                           if format == "pdf"-                              then e ++ "\n" ++ pdfIsNoWriterErrorMsg-                              else e-                         Right (w, es) -> return (w :: Writer PandocIO, es)-+               else getWriter (T.toLower writerName)    let standalone = optStandalone opts || not (isTextFormat format) || pdfOutput -  let addStringAsVariable varname s vars = return $ (varname, s) : vars-   let addSyntaxMap existingmap f = do         res <- liftIO (parseSyntaxDefinition f)         case res of-              Left errstr -> throwError $ PandocSyntaxMapError errstr+              Left errstr -> throwError $ PandocSyntaxMapError $ T.pack errstr               Right syn   -> return $ addSyntaxDefinition syn existingmap    syntaxMap <- foldM addSyntaxMap defaultSyntaxMap                      (optSyntaxDefinitions opts) -  -- note: this reverses the list constructed in option parsing,-  -- which in turn was reversed from the command-line order,-  -- so we end up with the correct order in the variable list:-  let withList _ [] vars     = return vars-      withList f (x:xs) vars = f x vars >>= withList f xs+  hlStyle <- maybe (return Nothing) (fmap Just . lookupHighlightStyle . T.unpack)+                (optHighlightStyle opts) -  let addContentsAsVariable varname fp vars = do-        s <- UTF8.toString . fst <$> fetchItem fp-        return $ (varname, s) : vars+  let setVariableM k v = return . setVariable k (fromString v) +  let setListVariableM _ [] ctx = return ctx+      setListVariableM k vs ctx = do+        let ctxMap = unContext ctx+        return $ Context $+          case M.lookup k ctxMap of+              Just (ListVal xs) -> M.insert k+                                  (ListVal $ xs ++ map toVal vs) ctxMap+              Just v -> M.insert k+                         (ListVal $ v : map toVal vs) ctxMap+              Nothing -> M.insert k (toVal vs) ctxMap++  let getTextContents fp = UTF8.toText . fst <$> fetchItem (T.pack fp)++  let setFilesVariableM k fps ctx = do+        xs <- mapM getTextContents fps+        setListVariableM k xs ctx+   curdir <- liftIO getCurrentDirectory    variables <--    withList (addStringAsVariable "sourcefile")-             (reverse $ optInputFiles opts)-             (("outputfile", fromMaybe "-" (optOutputFile opts))-              : optVariables opts)-             -- we reverse this list because, unlike-             -- the other option lists here, it is-             -- not reversed when parsed from CLI arguments.-             -- See withList, above.+    return (optVariables opts)     >>=-    withList (addContentsAsVariable "include-before")-             (optIncludeBeforeBody opts)+    setListVariableM "sourcefile"+      (maybe ["-"] (fmap T.pack) (optInputFiles opts))     >>=-    withList (addContentsAsVariable "include-after")-             (optIncludeAfterBody opts)+    setVariableM "outputfile" outputFile     >>=-    withList (addContentsAsVariable "header-includes")-             (optIncludeInHeader opts)+    setFilesVariableM "include-before" (optIncludeBeforeBody opts)     >>=-    withList (addStringAsVariable "css") (optCss opts)+    setFilesVariableM "include-after" (optIncludeAfterBody opts)     >>=-    maybe return (addStringAsVariable "title-prefix")-                 (optTitlePrefix opts)+    setFilesVariableM "header-includes" (optIncludeInHeader opts)     >>=-    maybe return (addStringAsVariable "epub-cover-image")+    setListVariableM "css" (map T.pack $ optCss opts)+    >>=+    maybe return (setVariableM "title-prefix" . T.unpack) (optTitlePrefix opts)+    >>=+    maybe return (setVariableM "epub-cover-image")                  (optEpubCoverImage opts)     >>=-    addStringAsVariable "curdir" curdir+    setVariableM "curdir" curdir     >>=     (\vars ->  if format == "dzslides"                   then do@@ -153,31 +168,44 @@                       let dzcore = unlines                                  $ dropWhile (not . (dzline `isPrefixOf`))                                  $ lines dztempl-                      return $ ("dzslides-core", dzcore) : vars+                      setVariableM "dzslides-core" dzcore vars                   else return vars) -  templ <- case optTemplate opts of+  templStr <- case optTemplate opts of                   _ | not standalone -> return Nothing                   Nothing -> Just <$> getDefaultTemplate format                   Just tp -> do                     -- strip off extensions                     let tp' = case takeExtension tp of-                                   "" -> tp <.> format+                                   "" -> tp <.> T.unpack format                                    _  -> tp-                    Just . UTF8.toString <$>-                          ((fst <$> fetchItem tp') `catchError`+                    Just . UTF8.toText <$>+                          ((do surl <- stSourceURL <$> getCommonState+                               -- we don't want to look for templates remotely+                               -- unless the full URL is specified:+                               modifyCommonState $ \st -> st{+                                  stSourceURL = Nothing }+                               (bs, _) <- fetchItem $ T.pack tp'+                               modifyCommonState $ \st -> st{+                                  stSourceURL = surl }+                               return bs)+                           `catchError`                            (\e ->                                case e of                                     PandocResourceNotFound _ ->                                        readDataFile ("templates" </> tp')                                     _ -> throwError e)) -  case lookup "lang" (optMetadata opts) of-         Just l  -> case parseBCP47 l of-                         Left _   -> return ()-                         Right l' -> setTranslations l'-         Nothing -> setTranslations $ Lang "en" "" "US" []+  let templatePath = fromMaybe "" $ optTemplate opts +  templ <- case templStr of+             Nothing -> return Nothing+             Just ts -> do+               res <- compileTemplate templatePath ts+               case res of+                 Left  e -> throwError $ PandocTemplateError $ T.pack e+                 Right t -> return $ Just t+   let writerOpts = def {           writerTemplate         = templ         , writerVariables        = variables@@ -193,7 +221,7 @@         , writerReferenceLinks   = optReferenceLinks opts         , writerReferenceLocation = optReferenceLocation opts         , writerDpi              = optDpi opts-        , writerWrapText         = optWrapText opts+        , writerWrapText         = optWrap opts         , writerColumns          = optColumns opts         , writerEmailObfuscation = optEmailObfuscation opts         , writerIdentifierPrefix = optIdentifierPrefix opts@@ -201,9 +229,9 @@         , writerTopLevelDivision = optTopLevelDivision opts         , writerListings         = optListings opts         , writerSlideLevel       = optSlideLevel opts-        , writerHighlightStyle   = optHighlightStyle opts+        , writerHighlightStyle   = hlStyle         , writerSetextHeaders    = optSetextHeaders opts-        , writerEpubSubdirectory = optEpubSubdirectory opts+        , writerEpubSubdirectory = T.pack $ optEpubSubdirectory opts         , writerEpubMetadata     = epubMetadata         , writerEpubFonts        = optEpubFonts opts         , writerEpubChapterLevel = optEpubChapterLevel opts@@ -220,24 +248,16 @@     , outputPdfProgram = maybePdfProg     } -baseWriterName :: String -> String-baseWriterName = takeWhile (\c -> c /= '+' && c /= '-')--pdfIsNoWriterErrorMsg :: String-pdfIsNoWriterErrorMsg =-  "To create a pdf using pandoc, use " ++-  "-t latex|beamer|context|ms|html5" ++-  "\nand specify an output file with " ++-  ".pdf extension (-o filename.pdf)."+baseWriterName :: T.Text -> T.Text+baseWriterName = T.takeWhile (\c -> c /= '+' && c /= '-') -pdfWriterAndProg :: Maybe String              -- ^ user-specified writer name+pdfWriterAndProg :: Maybe T.Text              -- ^ user-specified writer name                  -> Maybe String              -- ^ user-specified pdf-engine-                 -> IO (String, Maybe String) -- ^ IO (writerName, maybePdfEngineProg)-pdfWriterAndProg mWriter mEngine = do-  let panErr msg = liftIO $ E.throwIO $ PandocAppError msg+                 -> IO (T.Text, Maybe String) -- ^ IO (writerName, maybePdfEngineProg)+pdfWriterAndProg mWriter mEngine =   case go mWriter mEngine of       Right (writ, prog) -> return (writ, Just prog)-      Left err           -> panErr err+      Left err           -> liftIO $ E.throwIO $ PandocAppError err     where       go Nothing Nothing       = Right ("latex", "pdflatex")       go (Just writer) Nothing = (writer,) <$> engineForWriter writer@@ -245,19 +265,20 @@       go (Just writer) (Just engine) =            case find (== (baseWriterName writer, takeBaseName engine)) engines of                 Just _  -> Right (writer, engine)-                Nothing -> Left $ "pdf-engine " ++ engine ++-                           " is not compatible with output format " ++ writer+                Nothing -> Left $ "pdf-engine " <> T.pack engine <>+                           " is not compatible with output format " <> writer        writerForEngine eng = case [f | (f,e) <- engines, e == eng] of                                  fmt : _ -> Right fmt                                  []      -> Left $-                                   "pdf-engine " ++ eng ++ " not known"+                                   "pdf-engine " <> T.pack eng <> " not known" -      engineForWriter "pdf" = Left pdfIsNoWriterErrorMsg+      engineForWriter "pdf" = Left "pdf writer"       engineForWriter w = case [e |  (f,e) <- engines, f == baseWriterName w] of                                 eng : _ -> Right eng                                 []      -> Left $-                                   "cannot produce pdf output from " ++ w+                                   "cannot produce pdf output from " <> w -isTextFormat :: String -> Bool-isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub","pptx"]+isTextFormat :: T.Text -> Bool+isTextFormat s =+  s `notElem` ["odt","docx","epub2","epub3","epub","pptx","pdf"]
src/Text/Pandoc/BCP47.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} {- |    Module      : Text.Pandoc.BCP47@@ -19,29 +20,29 @@ where import Prelude import Control.Monad (guard)-import Data.Char (isAlphaNum, isAscii, isLetter, isLower, isUpper, toLower,-                  toUpper)-import Data.List (intercalate)+import Data.Char (isAlphaNum, isAscii, isLetter, isLower, isUpper) import Text.Pandoc.Definition import Text.Pandoc.Options+import Text.DocTemplates (FromContext(..))+import qualified Data.Text as T import qualified Text.Parsec as P  -- | Represents BCP 47 language/country code.-data Lang = Lang{ langLanguage :: String-                , langScript   :: String-                , langRegion   :: String-                , langVariants :: [String] }+data Lang = Lang{ langLanguage :: T.Text+                , langScript   :: T.Text+                , langRegion   :: T.Text+                , langVariants :: [T.Text] }                 deriving (Eq, Ord, Show)  -- | Render a Lang as BCP 47.-renderLang :: Lang -> String-renderLang lang = intercalate "-" (langLanguage lang : filter (not . null)+renderLang :: Lang -> T.Text+renderLang lang = T.intercalate "-" (langLanguage lang : filter (not . T.null)                     ([langScript lang, langRegion lang] ++ langVariants lang))  -- | Get the contents of the `lang` metadata field or variable.-getLang :: WriterOptions -> Meta -> Maybe String+getLang :: WriterOptions -> Meta -> Maybe T.Text getLang opts meta =-  case lookup "lang" (writerVariables opts) of+  case lookupContext "lang" (writerVariables opts) of         Just s -> Just s         _      ->           case lookupMeta "lang" meta of@@ -52,11 +53,11 @@ -- | Parse a BCP 47 string as a Lang.  Currently we parse -- extensions and private-use fields as "variants," even -- though officially they aren't.-parseBCP47 :: String -> Either String Lang+parseBCP47 :: T.Text -> Either T.Text Lang parseBCP47 lang =   case P.parse bcp47 "lang" lang of        Right r -> Right r-       Left e  -> Left $ show e+       Left e  -> Left $ T.pack $ show e   where bcp47 = do           language <- pLanguage           script <- P.option "" pScript@@ -72,19 +73,19 @@           cs <- P.many1 asciiLetter           let lcs = length cs           guard $ lcs == 2 || lcs == 3-          return $ map toLower cs+          return $ T.toLower $ T.pack $ cs         pScript = P.try $ do           P.char '-'           x <- P.satisfy (\c -> isAscii c && isLetter c && isUpper c)           xs <- P.count 3                  (P.satisfy (\c -> isAscii c && isLetter c && isLower c))-          return $ map toLower (x:xs)+          return $ T.toLower $ T.pack (x:xs)         pRegion = P.try $ do           P.char '-'           cs <- P.many1 asciiLetter           let lcs = length cs           guard $ lcs == 2 || lcs == 3-          return $ map toUpper cs+          return $ T.toUpper $ T.pack cs         pVariant = P.try $ do           P.char '-'           ds <- P.option "" (P.count 1 P.digit)@@ -93,12 +94,12 @@           guard $ if null ds                      then length var >= 5 && length var <= 8                      else length var == 4-          return $ map toLower var+          return $ T.toLower $ T.pack var         pExtension = P.try $ do           P.char '-'           cs <- P.many1 $ P.satisfy (\c -> isAscii c && isAlphaNum c)           guard $ length cs >= 2 && length cs <= 8-          return $ map toLower cs+          return $ T.toLower $ T.pack cs         pPrivateUse = P.try $ do           P.char '-'           P.char 'x'@@ -106,4 +107,4 @@           cs <- P.many1 $ P.satisfy (\c -> isAscii c && isAlphaNum c)           guard $ not (null cs) && length cs <= 8           let var = "x-" ++ cs-          return $ map toLower var+          return $ T.toLower $ T.pack var
src/Text/Pandoc/CSS.hs view
@@ -19,17 +19,18 @@ where  import Prelude+import qualified Data.Text as T import Text.Pandoc.Shared (trim) import Text.Parsec-import Text.Parsec.String+import Text.Parsec.Text -ruleParser :: Parser (String, String)+ruleParser :: Parser (T.Text, T.Text) ruleParser = do     p <- many1 (noneOf ":")  <* char ':'     v <- many1 (noneOf ":;") <* optional (char ';') <* spaces-    return (trim p, trim v)+    return (trim $ T.pack p, trim $ T.pack v) -styleAttrParser :: Parser [(String, String)]+styleAttrParser :: Parser [(T.Text, T.Text)] styleAttrParser = many1 ruleParser  orElse :: Eq a => a -> a -> a -> a@@ -44,7 +45,7 @@  -- | takes a list of keys/properties and a CSS string and -- returns the corresponding key-value-pairs.-pickStylesToKVs :: [String] -> String -> [(String, String)]+pickStylesToKVs :: [T.Text] -> T.Text -> [(T.Text, T.Text)] pickStylesToKVs props styleAttr =   case parse styleAttrParser "" styleAttr of     Left _       -> []@@ -52,7 +53,7 @@  -- | takes a list of key/property synonyms and a CSS string and maybe -- returns the value of the first match (in order of the supplied list)-pickStyleAttrProps :: [String] -> String -> Maybe String+pickStyleAttrProps :: [T.Text] -> T.Text -> Maybe T.Text pickStyleAttrProps lookupProps styleAttr = do     styles <- eitherToMaybe $ parse styleAttrParser "" styleAttr     foldOrElse Nothing $ map (`lookup` styles) lookupProps
src/Text/Pandoc/Class.hs view
@@ -9,6 +9,8 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns #-} {- |    Module      : Text.Pandoc.Class    Copyright   : Copyright (C) 2016-17 Jesse Rosenthal, John MacFarlane@@ -79,7 +81,6 @@ import Codec.Archive.Zip import qualified Data.CaseInsensitive as CI import Data.Unique (hashUnique)-import Data.List (stripPrefix) import qualified Data.Unique as IO (newUnique) import qualified Text.Pandoc.UTF8 as UTF8 import qualified System.Directory as Directory@@ -90,6 +91,7 @@ import qualified Data.Time as IO (getCurrentTime) import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType) import Text.Pandoc.Definition+import Text.DocTemplates (TemplateMonad(..)) import Data.Digest.Pure.SHA (sha1, showDigest) import Data.Maybe (fromMaybe) import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds@@ -126,7 +128,6 @@ import qualified System.FilePath.Glob as IO (glob) import qualified System.FilePath.Posix as Posix import qualified System.Directory as IO (getModificationTime)-import Control.Monad as M (fail) import Control.Monad.State.Strict import Control.Monad.Except import Data.Word (Word8)@@ -134,6 +135,7 @@ import System.IO.Error import System.IO (stderr) import qualified Data.Map as M+import qualified Data.Text as T import Text.Pandoc.Error import Text.Pandoc.BCP47 (Lang(..), parseBCP47, renderLang) import Text.Pandoc.Translations (Term(..), Translations, lookupTerm,@@ -153,7 +155,7 @@ class (Functor m, Applicative m, Monad m, MonadError PandocError m)       => PandocMonad m where   -- | Lookup an environment variable.-  lookupEnv :: String -> m (Maybe String)+  lookupEnv :: T.Text -> m (Maybe T.Text)   -- | Get the current (UTC) time.   getCurrentTime :: m UTCTime   -- | Get the locale's time zone.@@ -164,7 +166,7 @@   newUniqueHash :: m Int   -- | Retrieve contents and mime type from a URL, raising   -- an error on failure.-  openURL :: String -> m (B.ByteString, Maybe MimeType)+  openURL :: T.Text -> m (B.ByteString, Maybe MimeType)   -- | Read the lazy ByteString contents from a file path,   -- raising an error on failure.   readFileLazy :: FilePath -> m BL.ByteString@@ -199,10 +201,10 @@   -- Output a debug message to sterr, using 'Debug.Trace.trace',   -- if tracing is enabled.  Note: this writes to stderr even in   -- pure instances.-  trace :: String -> m ()+  trace :: T.Text -> m ()   trace msg = do     tracing <- getsCommonState stTrace-    when tracing $ Debug.Trace.trace ("[trace] " ++ msg) (return ())+    when tracing $ Debug.Trace.trace ("[trace] " ++ T.unpack msg) (return ())  -- * Functions defined for all PandocMonad instances @@ -238,8 +240,8 @@  -- | Set request header to use in HTTP requests. setRequestHeader :: PandocMonad m-                 => String  -- ^ Header name-                 -> String  -- ^ Value+                 => T.Text  -- ^ Header name+                 -> T.Text  -- ^ Value                  -> m () setRequestHeader name val = modifyCommonState $ \st ->   st{ stRequestHeaders =@@ -277,7 +279,7 @@                                 _ -> Nothing    modifyCommonState $ \st -> st{ stInputFiles = fs-                               , stSourceURL = sourceURL }+                               , stSourceURL = T.pack <$> sourceURL }  -- Retrieve the output filename. getOutputFile :: PandocMonad m => m (Maybe FilePath)@@ -307,14 +309,22 @@   return $ utcToZonedTime tz t  -- | Read file, checking in any number of directories.-readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m (Maybe String)+readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m (Maybe T.Text) readFileFromDirs [] _ = return Nothing readFileFromDirs (d:ds) f = catchError-    ((Just . UTF8.toStringLazy) <$> readFileLazy (d </> f))+    ((Just . T.pack . UTF8.toStringLazy) <$> readFileLazy (d </> f))     (\_ -> readFileFromDirs ds f) ---+instance TemplateMonad PandocIO where+  getPartial fp = UTF8.toText <$> catchError+                      (readFileStrict fp)+                      (\_ -> readDataFile ("templates" </> fp)) +instance TemplateMonad PandocPure where+  getPartial fp = UTF8.toText <$> catchError+                      (readFileStrict fp)+                      (\_ -> readDataFile ("templates" </> fp))+ -- | 'CommonState' represents state that is used by all -- instances of 'PandocMonad'.  Normally users should not -- need to interact with it directly; instead, auxiliary@@ -323,9 +333,9 @@                                  -- ^ A list of log messages in reverse order                                , stUserDataDir  :: Maybe FilePath                                  -- ^ Directory to search for data files-                               , stSourceURL    :: Maybe String+                               , stSourceURL    :: Maybe T.Text                                  -- ^ Absolute URL + dir of 1st source file-                               , stRequestHeaders :: [(String, String)]+                               , stRequestHeaders :: [(T.Text, T.Text)]                                  -- ^ Headers to add for HTTP requests                                , stMediaBag     :: MediaBag                                  -- ^ Media parsed from binary containers@@ -362,7 +372,7 @@  -- | Convert BCP47 string to a Lang, issuing warning -- if there are problems.-toLang :: PandocMonad m => Maybe String -> m (Maybe Lang)+toLang :: PandocMonad m => Maybe T.Text -> m (Maybe Lang) toLang Nothing = return Nothing toLang (Just s) =   case parseBCP47 s of@@ -387,14 +397,14 @@        Nothing -> return mempty  -- no language defined        Just (_, Just t) -> return t        Just (lang, Nothing) -> do  -- read from file-         let translationFile = "translations/" ++ renderLang lang ++ ".yaml"-         let fallbackFile = "translations/" ++ langLanguage lang ++ ".yaml"+         let translationFile = "translations/" <> renderLang lang <> ".yaml"+         let fallbackFile = "translations/" <> langLanguage lang <> ".yaml"          let getTrans fp = do                bs <- readDataFile fp-               case readTranslations (UTF8.toString bs) of+               case readTranslations (UTF8.toText bs) of                     Left e   -> do                       report $ CouldNotLoadTranslations (renderLang lang)-                        (fp ++ ": " ++ e)+                        (T.pack fp <> ": " <> e)                       -- make sure we don't try again...                       modifyCommonState $ \st ->                         st{ stTranslations = Nothing }@@ -403,14 +413,14 @@                       modifyCommonState $ \st ->                                   st{ stTranslations = Just (lang, Just t) }                       return t-         catchError (getTrans translationFile)+         catchError (getTrans $ T.unpack translationFile)            (\_ ->-             catchError (getTrans fallbackFile)+             catchError (getTrans $ T.unpack fallbackFile)                (\e -> do                  report $ CouldNotLoadTranslations (renderLang lang)                           $ case e of                                PandocCouldNotFindDataFileError _ ->-                                 "data file " ++ fallbackFile ++ " not found"+                                 "data file " <> fallbackFile <> " not found"                                _ -> ""                  -- make sure we don't try again...                  modifyCommonState $ \st -> st{ stTranslations = Nothing }@@ -418,13 +428,13 @@  -- | Get a translation from the current term map. -- Issue a warning if the term is not defined.-translateTerm :: PandocMonad m => Term -> m String+translateTerm :: PandocMonad m => Term -> m T.Text translateTerm term = do   translations <- getTranslations   case lookupTerm term translations of        Just s -> return s        Nothing -> do-         report $ NoTranslation (show term)+         report $ NoTranslation $ T.pack $ show term          return ""  -- | Evaluate a 'PandocIO' operation.@@ -450,7 +460,7 @@ liftIOError f u = do   res <- liftIO $ tryIOError $ f u   case res of-         Left e  -> throwError $ PandocIOError u e+         Left e  -> throwError $ PandocIOError (T.pack u) e          Right r -> return r  -- | Show potential IO errors to the user continuing execution anyway@@ -458,24 +468,24 @@ logIOError f = do   res <- liftIO $ tryIOError f   case res of-    Left e -> report $ IgnoredIOError (E.displayException e)+    Left e -> report $ IgnoredIOError $ T.pack $ E.displayException e     Right _ -> pure ()  instance PandocMonad PandocIO where-  lookupEnv = liftIO . IO.lookupEnv+  lookupEnv = fmap (fmap T.pack) . liftIO . IO.lookupEnv . T.unpack   getCurrentTime = liftIO IO.getCurrentTime   getCurrentTimeZone = liftIO IO.getCurrentTimeZone   newStdGen = liftIO IO.newStdGen   newUniqueHash = hashUnique <$> liftIO IO.newUnique    openURL u-   | Just u'' <- stripPrefix "data:" u = do-       let mime     = takeWhile (/=',') u''+   | Just u'' <- T.stripPrefix "data:" u = do+       let mime     = T.takeWhile (/=',') u''        let contents = UTF8.fromString $-                       unEscapeString $ drop 1 $ dropWhile (/=',') u''+                       unEscapeString $ T.unpack $ T.drop 1 $ T.dropWhile (/=',') u''        return (decodeLenient contents, Just mime)    | otherwise = do-       let toReqHeader (n, v) = (CI.mk (UTF8.fromString n), UTF8.fromString v)+       let toReqHeader (n, v) = (CI.mk (UTF8.fromText n), UTF8.fromText v)        customHeaders <- map toReqHeader <$> getsCommonState stRequestHeaders        report $ Fetching u        res <- liftIO $ E.try $ withSocketsDo $ do@@ -485,11 +495,11 @@                               Left _ -> return x                               Right pr -> parseReq pr >>= \r ->                                   return (addProxy (host r) (port r) x)-         req <- parseReq u >>= addProxy'+         req <- parseReq (T.unpack u) >>= addProxy'          let req' = req{requestHeaders = customHeaders ++ requestHeaders req}          resp <- newManager tlsManagerSettings >>= httpLbs req'          return (B.concat $ toChunks $ responseBody resp,-                 UTF8.toString `fmap` lookup hContentType (responseHeaders resp))+                 UTF8.toText `fmap` lookup hContentType (responseHeaders resp))         case res of             Right r -> return r@@ -511,22 +521,22 @@   logOutput msg = liftIO $ do     UTF8.hPutStr stderr $         "[" ++ show (messageVerbosity msg) ++ "] "-    alertIndent $ lines $ showLogMessage msg+    alertIndent $ T.lines $ showLogMessage msg -alertIndent :: [String] -> IO ()+alertIndent :: [T.Text] -> IO () alertIndent [] = return () alertIndent (l:ls) = do-  UTF8.hPutStrLn stderr l+  UTF8.hPutStrLn stderr $ T.unpack l   mapM_ go ls   where go l' = do UTF8.hPutStr stderr "  "-                   UTF8.hPutStrLn stderr l'+                   UTF8.hPutStrLn stderr $ T.unpack l'  -- | Specialized version of parseURIReference that disallows -- single-letter schemes.  Reason:  these are usually windows absolute -- paths.-parseURIReference' :: String -> Maybe URI+parseURIReference' :: T.Text -> Maybe URI parseURIReference' s =-  case parseURIReference s of+  case parseURIReference (T.unpack s) of        Just u          | length (uriScheme u) > 2  -> Just u          | null (uriScheme u)        -> Just u  -- protocol-relative@@ -546,16 +556,16 @@ -- | Fetch an image or other item from the local filesystem or the net. -- Returns raw content and maybe mime type. fetchItem :: PandocMonad m-          => String+          => T.Text           -> m (B.ByteString, Maybe MimeType) fetchItem s = do   mediabag <- getMediaBag-  case lookupMedia s mediabag of+  case lookupMedia (T.unpack s) mediabag of     Just (mime, bs) -> return (BL.toStrict bs, Just mime)     Nothing -> downloadOrRead s  downloadOrRead :: PandocMonad m-               => String+               => T.Text                -> m (B.ByteString, Maybe MimeType) downloadOrRead s = do   sourceURL <- getsCommonState stSourceURL@@ -563,19 +573,19 @@                        ensureEscaped, ensureEscaped s) of     (Just u, s') -> -- try fetching from relative path at source        case parseURIReference' s' of-            Just u' -> openURL $ show $ u' `nonStrictRelativeTo` u+            Just u' -> openURL $ T.pack $ show $ u' `nonStrictRelativeTo` u             Nothing -> openURL s' -- will throw error-    (Nothing, s'@('/':'/':c:_)) | c /= '?' ->  -- protocol-relative URI+    (Nothing, s'@(T.unpack -> ('/':'/':c:_))) | c /= '?' ->  -- protocol-relative URI                 -- we exclude //? because of //?UNC/ on Windows        case parseURIReference' s' of-            Just u' -> openURL $ show $ u' `nonStrictRelativeTo` httpcolon+            Just u' -> openURL $ T.pack $ show $ u' `nonStrictRelativeTo` httpcolon             Nothing -> openURL s' -- will throw error     (Nothing, s') ->-       case parseURI s' of  -- requires absolute URI+       case parseURI (T.unpack s') of  -- requires absolute URI             Just u' | uriScheme u' == "file:" ->-                 readLocalFile $ uriPathToPath (uriPath u')+                 readLocalFile $ uriPathToPath (T.pack $ uriPath u')             -- We don't want to treat C:/ as a scheme:-            Just u' | length (uriScheme u') > 2 -> openURL (show u')+            Just u' | length (uriScheme u') > 2 -> openURL (T.pack $ show u')             _ -> readLocalFile fp -- get from local file system    where readLocalFile f = do              resourcePath <- getResourcePath@@ -588,13 +598,13 @@                           uriPath = "",                           uriQuery = "",                           uriFragment = "" }-         dropFragmentAndQuery = takeWhile (\c -> c /= '?' && c /= '#')-         fp = unEscapeString $ dropFragmentAndQuery s+         dropFragmentAndQuery = T.takeWhile (\c -> c /= '?' && c /= '#')+         fp = unEscapeString $ T.unpack $ dropFragmentAndQuery s          mime = case takeExtension fp of                      ".gz" -> getMimeType $ dropExtension fp                      ".svgz" -> getMimeType $ dropExtension fp ++ ".svg"                      x     -> getMimeType x-         ensureEscaped = escapeURIString isAllowedInURI . map convertSlash+         ensureEscaped = T.pack . escapeURIString isAllowedInURI . T.unpack . T.map convertSlash          convertSlash '\\' = '/'          convertSlash x    = x @@ -762,7 +772,7 @@ readDefaultDataFile fname = #ifdef EMBED_DATA_FILES   case lookup (makeCanonical fname) dataFiles of-    Nothing       -> throwError $ PandocCouldNotFindDataFileError fname+    Nothing       -> throwError $ PandocCouldNotFindDataFileError $ T.pack fname     Just contents -> return contents #else   getDataFileName fname' >>= checkExistence >>= readFileStrict@@ -773,7 +783,7 @@   exists <- fileExists fn   if exists      then return fn-     else throwError $ PandocCouldNotFindDataFileError fn+     else throwError $ PandocCouldNotFindDataFileError $ T.pack fn #endif  makeCanonical :: FilePath -> FilePath@@ -784,7 +794,7 @@         go as     x    = x : as  withPaths :: PandocMonad m => [FilePath] -> (FilePath -> m a) -> FilePath -> m a-withPaths [] _ fp = throwError $ PandocResourceNotFound fp+withPaths [] _ fp = throwError $ PandocResourceNotFound $ T.pack fp withPaths (p:ps) action fp =   catchError (action (p </> fp))              (\_ -> withPaths ps action fp)@@ -792,14 +802,14 @@ -- | Fetch local or remote resource (like an image) and provide data suitable -- for adding it to the MediaBag. fetchMediaResource :: PandocMonad m-              => String -> m (FilePath, Maybe MimeType, BL.ByteString)+              => T.Text -> m (FilePath, Maybe MimeType, BL.ByteString) fetchMediaResource src = do   (bs, mt) <- downloadOrRead src-  let ext = fromMaybe (takeExtension src)+  let ext = fromMaybe (T.pack $ takeExtension $ T.unpack src)                       (mt >>= extensionFromMimeType)   let bs' = BL.fromChunks [bs]   let basename = showDigest $ sha1 bs'-  let fname = basename <.> ext+  let fname = basename <.> T.unpack ext   return (fname, mt, bs')  -- | Traverse tree, filling media bag for any images that@@ -809,12 +819,12 @@   where handleImage :: PandocMonad m => Inline -> m Inline         handleImage (Image attr lab (src, tit)) = catchError           (do mediabag <- getMediaBag-              case lookupMedia src mediabag of+              case lookupMedia (T.unpack src) mediabag of                 Just (_, _) -> return $ Image attr lab (src, tit)                 Nothing -> do                   (fname, mt, bs) <- fetchMediaResource src                   insertMedia fname mt bs-                  return $ Image attr lab (fname, tit))+                  return $ Image attr lab (T.pack fname, tit))           (\e ->               case e of                 PandocResourceNotFound _ -> do@@ -824,7 +834,7 @@                   return $ Span ("",["image"],[]) lab                 PandocHttpError u er -> do                   report $ CouldNotFetchResource u-                            (show er ++ "\rReplacing image with description.")+                            (T.pack $ show er ++ "\rReplacing image with description.")                   -- emit alt text                   return $ Span ("",["image"],[]) lab                 _ -> throwError e)@@ -848,15 +858,15 @@   let fullpath = dir </> unEscapeString (normalise subpath)   let mbcontents = lookupMedia subpath mediabag   case mbcontents of-       Nothing -> throwError $ PandocResourceNotFound subpath+       Nothing -> throwError $ PandocResourceNotFound $ T.pack subpath        Just (_, bs) -> do-         report $ Extracting fullpath+         report $ Extracting $ T.pack fullpath          liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)          logIOError $ BL.writeFile fullpath bs  adjustImagePath :: FilePath -> [FilePath] -> Inline -> Inline adjustImagePath dir paths (Image attr lab (src, tit))-   | src `elem` paths = Image attr lab (dir ++ "/" ++ src, tit)+   | T.unpack src `elem` paths = Image attr lab (T.pack dir <> "/" <> src, tit) adjustImagePath _ _ x = x  -- | The 'PureState' contains ersatz representations@@ -870,7 +880,7 @@                                                    -- contain every                                                    -- element at most                                                    -- once, e.g. [1..]-                           , stEnv :: [(String, String)]+                           , stEnv :: [(T.Text, T.Text)]                            , stTime :: UTCTime                            , stTimeZone :: TimeZone                            , stReferenceDocx :: Archive@@ -981,18 +991,19 @@       u : us -> do         modifyPureState $ \st -> st { stUniqStore = us }         return u-      _ -> M.fail "uniq store ran out of elements"+      _ -> throwError $ PandocShouldNeverHappenError+                        "uniq store ran out of elements"   openURL u = throwError $ PandocResourceNotFound u   readFileLazy fp = do     fps <- getsPureState stFiles     case infoFileContents <$> getFileInfo fp fps of       Just bs -> return (BL.fromStrict bs)-      Nothing -> throwError $ PandocResourceNotFound fp+      Nothing -> throwError $ PandocResourceNotFound $ T.pack fp   readFileStrict fp = do     fps <- getsPureState stFiles     case infoFileContents <$> getFileInfo fp fps of       Just bs -> return bs-      Nothing -> throwError $ PandocResourceNotFound fp+      Nothing -> throwError $ PandocResourceNotFound $ T.pack fp    glob s = do     FileTree ftmap <- getsPureState stFiles@@ -1010,7 +1021,7 @@     fps <- getsPureState stFiles     case infoFileMTime <$> getFileInfo fp fps of       Just tm -> return tm-      Nothing -> throwError $ PandocIOError fp+      Nothing -> throwError $ PandocIOError (T.pack fp)                     (userError "Can't get modification time")    getCommonState = PandocPure $ lift get@@ -1061,7 +1072,7 @@     when tracing $ do       pos <- getPosition       Debug.Trace.trace-        ("[trace] Parsed " ++ msg ++ " at line " +++        ("[trace] Parsed " ++ T.unpack msg ++ " at line " ++             show (sourceLine pos) ++             if sourceName pos == "chunk"                then " of chunk"
src/Text/Pandoc/Emoji.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Emoji    Copyright   : Copyright (C) 2015 John MacFarlane@@ -13,34 +14,55 @@ module Text.Pandoc.Emoji ( emojis, emojiToInline ) where import Prelude import qualified Data.Map as M+import qualified Data.Text as T import Text.Pandoc.Definition (Inline (Span, Str)) -emojis :: M.Map String String+emojis :: M.Map T.Text T.Text emojis = M.fromList   [("+1","\128077")   ,("-1","\128078")   ,("100","\128175")   ,("1234","\128290")+  ,("1st_place_medal","\129351")+  ,("2nd_place_medal","\129352")+  ,("3rd_place_medal","\129353")   ,("8ball","\127921")   ,("a","\127344\65039")   ,("ab","\127374")+  ,("abacus","\129518")   ,("abc","\128292")   ,("abcd","\128289")   ,("accept","\127569")+  ,("adhesive_bandage","\129657")+  ,("adult","\129489")   ,("aerial_tramway","\128673")+  ,("afghanistan","\127462\127467")   ,("airplane","\9992\65039")+  ,("aland_islands","\127462\127485")   ,("alarm_clock","\9200")+  ,("albania","\127462\127473")+  ,("alembic","\9879")+  ,("algeria","\127465\127487")   ,("alien","\128125")   ,("ambulance","\128657")+  ,("american_samoa","\127462\127480")+  ,("amphora","\127994")   ,("anchor","\9875")+  ,("andorra","\127462\127465")   ,("angel","\128124")   ,("anger","\128162")+  ,("angola","\127462\127476")   ,("angry","\128544")+  ,("anguilla","\127462\127470")   ,("anguished","\128551")   ,("ant","\128028")+  ,("antarctica","\127462\127478")+  ,("antigua_barbuda","\127462\127468")   ,("apple","\127822")   ,("aquarius","\9810")+  ,("argentina","\127462\127479")   ,("aries","\9800")+  ,("armenia","\127462\127474")   ,("arrow_backward","\9664\65039")   ,("arrow_double_down","\9196")   ,("arrow_double_up","\9195")@@ -63,43 +85,90 @@   ,("arrows_counterclockwise","\128260")   ,("art","\127912")   ,("articulated_lorry","\128667")+  ,("artificial_satellite","\128752")+  ,("aruba","\127462\127484")+  ,("ascension_island","\127462\127464")+  ,("asterisk","*\65039\8419")   ,("astonished","\128562")   ,("athletic_shoe","\128095")   ,("atm","\127975")+  ,("atom_symbol","\9883")+  ,("australia","\127462\127482")+  ,("austria","\127462\127481")+  ,("auto_rickshaw","\128762")+  ,("avocado","\129361")+  ,("axe","\129683")+  ,("azerbaijan","\127462\127487")   ,("b","\127345\65039")   ,("baby","\128118")   ,("baby_bottle","\127868")   ,("baby_chick","\128036")   ,("baby_symbol","\128700")   ,("back","\128281")+  ,("bacon","\129363")+  ,("badger","\129441")+  ,("badminton","\127992")+  ,("bagel","\129391")   ,("baggage_claim","\128708")+  ,("baguette_bread","\129366")+  ,("bahamas","\127463\127480")+  ,("bahrain","\127463\127469")+  ,("balance_scale","\9878")+  ,("bald_man","\128104\8205\129458")+  ,("bald_woman","\128105\8205\129458")+  ,("ballet_shoes","\129648")   ,("balloon","\127880")+  ,("ballot_box","\128499")   ,("ballot_box_with_check","\9745\65039")   ,("bamboo","\127885")   ,("banana","\127820")   ,("bangbang","\8252\65039")+  ,("bangladesh","\127463\127465")+  ,("banjo","\129685")   ,("bank","\127974")   ,("bar_chart","\128202")+  ,("barbados","\127463\127463")   ,("barber","\128136")-  ,("baseball","\9918\65039")+  ,("baseball","\9918")+  ,("basket","\129530")   ,("basketball","\127936")+  ,("basketball_man","\9977\65039\8205\9794\65039")+  ,("basketball_woman","\9977\65039\8205\9792\65039")+  ,("bat","\129415")   ,("bath","\128704")   ,("bathtub","\128705")   ,("battery","\128267")+  ,("beach_umbrella","\127958")   ,("bear","\128059")+  ,("bearded_person","\129492")+  ,("bed","\128719")   ,("bee","\128029")   ,("beer","\127866")   ,("beers","\127867")   ,("beetle","\128030")   ,("beginner","\128304")+  ,("belarus","\127463\127486")+  ,("belgium","\127463\127466")+  ,("belize","\127463\127487")   ,("bell","\128276")+  ,("bellhop_bell","\128718")+  ,("benin","\127463\127471")   ,("bento","\127857")+  ,("bermuda","\127463\127474")+  ,("beverage_box","\129475")+  ,("bhutan","\127463\127481")   ,("bicyclist","\128692")   ,("bike","\128690")+  ,("biking_man","\128692\8205\9794")+  ,("biking_woman","\128692\8205\9792")   ,("bikini","\128089")+  ,("billed_cap","\129506")+  ,("biohazard","\9763")   ,("bird","\128038")   ,("birthday","\127874")   ,("black_circle","\9899")+  ,("black_flag","\127988")+  ,("black_heart","\128420")   ,("black_joker","\127183")   ,("black_large_square","\11035")   ,("black_medium_small_square","\9726")@@ -107,74 +176,150 @@   ,("black_nib","\10002\65039")   ,("black_small_square","\9642\65039")   ,("black_square_button","\128306")+  ,("blond_haired_man","\128113\8205\9794")+  ,("blond_haired_person","\128113")+  ,("blond_haired_woman","\128113\8205\9792")+  ,("blonde_woman","\128113\8205\9792")   ,("blossom","\127804")   ,("blowfish","\128033")   ,("blue_book","\128216")   ,("blue_car","\128665")   ,("blue_heart","\128153")+  ,("blue_square","\128998")   ,("blush","\128522")   ,("boar","\128023")   ,("boat","\9973")+  ,("bolivia","\127463\127476")   ,("bomb","\128163")+  ,("bone","\129460")   ,("book","\128214")   ,("bookmark","\128278")   ,("bookmark_tabs","\128209")   ,("books","\128218")   ,("boom","\128165")   ,("boot","\128098")+  ,("bosnia_herzegovina","\127463\127462")+  ,("botswana","\127463\127484")+  ,("bouncing_ball_man","\9977\65039\8205\9794\65039")+  ,("bouncing_ball_person","\9977")+  ,("bouncing_ball_woman","\9977\65039\8205\9792\65039")   ,("bouquet","\128144")+  ,("bouvet_island","\127463\127483")   ,("bow","\128583")+  ,("bow_and_arrow","\127993")+  ,("bowing_man","\128583\8205\9794")+  ,("bowing_woman","\128583\8205\9792")+  ,("bowl_with_spoon","\129379")   ,("bowling","\127923")+  ,("boxing_glove","\129354")   ,("boy","\128102")+  ,("brain","\129504")+  ,("brazil","\127463\127479")   ,("bread","\127838")+  ,("breast_feeding","\129329")+  ,("bricks","\129521")   ,("bride_with_veil","\128112")   ,("bridge_at_night","\127753")   ,("briefcase","\128188")+  ,("british_indian_ocean_territory","\127470\127476")+  ,("british_virgin_islands","\127483\127468")+  ,("broccoli","\129382")   ,("broken_heart","\128148")+  ,("broom","\129529")+  ,("brown_circle","\128996")+  ,("brown_heart","\129294")+  ,("brown_square","\129003")+  ,("brunei","\127463\127475")   ,("bug","\128027")+  ,("building_construction","\127959")   ,("bulb","\128161")+  ,("bulgaria","\127463\127468")   ,("bullettrain_front","\128645")   ,("bullettrain_side","\128644")+  ,("burkina_faso","\127463\127467")+  ,("burrito","\127791")+  ,("burundi","\127463\127470")   ,("bus","\128652")+  ,("business_suit_levitating","\128372")   ,("busstop","\128655")   ,("bust_in_silhouette","\128100")   ,("busts_in_silhouette","\128101")+  ,("butter","\129480")+  ,("butterfly","\129419")   ,("cactus","\127797")   ,("cake","\127856")   ,("calendar","\128198")+  ,("call_me_hand","\129305")   ,("calling","\128242")+  ,("cambodia","\127472\127469")   ,("camel","\128043")   ,("camera","\128247")+  ,("camera_flash","\128248")+  ,("cameroon","\127464\127474")+  ,("camping","\127957")+  ,("canada","\127464\127462")+  ,("canary_islands","\127470\127464")   ,("cancer","\9803")+  ,("candle","\128367")   ,("candy","\127852")+  ,("canned_food","\129387")+  ,("canoe","\128758")+  ,("cape_verde","\127464\127483")   ,("capital_abcd","\128288")   ,("capricorn","\9809")   ,("car","\128663")+  ,("card_file_box","\128451")   ,("card_index","\128199")+  ,("card_index_dividers","\128450")+  ,("caribbean_netherlands","\127463\127478")   ,("carousel_horse","\127904")+  ,("carrot","\129365")+  ,("cartwheeling","\129336")   ,("cat","\128049")   ,("cat2","\128008")+  ,("cayman_islands","\127472\127486")   ,("cd","\128191")+  ,("central_african_republic","\127464\127467")+  ,("ceuta_melilla","\127466\127462")+  ,("chad","\127481\127465")+  ,("chains","\9939")+  ,("chair","\129681")+  ,("champagne","\127870")   ,("chart","\128185")   ,("chart_with_downwards_trend","\128201")   ,("chart_with_upwards_trend","\128200")   ,("checkered_flag","\127937")+  ,("cheese","\129472")   ,("cherries","\127826")   ,("cherry_blossom","\127800")+  ,("chess_pawn","\9823")   ,("chestnut","\127792")   ,("chicken","\128020")+  ,("child","\129490")   ,("children_crossing","\128696")+  ,("chile","\127464\127473")+  ,("chipmunk","\128063")   ,("chocolate_bar","\127851")+  ,("chopsticks","\129378")+  ,("christmas_island","\127464\127485")   ,("christmas_tree","\127876")   ,("church","\9962")   ,("cinema","\127910")   ,("circus_tent","\127914")   ,("city_sunrise","\127751")   ,("city_sunset","\127750")+  ,("cityscape","\127961")   ,("cl","\127377")+  ,("clamp","\128476")   ,("clap","\128079")   ,("clapper","\127916")+  ,("classical_building","\127963")+  ,("climbing","\129495")+  ,("climbing_man","\129495\8205\9794")+  ,("climbing_woman","\129495\8205\9792")+  ,("clinking_glasses","\129346")   ,("clipboard","\128203")+  ,("clipperton_island","\127464\127477")   ,("clock1","\128336")   ,("clock10","\128345")   ,("clock1030","\128357")@@ -203,112 +348,286 @@   ,("closed_lock_with_key","\128272")   ,("closed_umbrella","\127746")   ,("cloud","\9729\65039")+  ,("cloud_with_lightning","\127785")+  ,("cloud_with_lightning_and_rain","\9928")+  ,("cloud_with_rain","\127783")+  ,("cloud_with_snow","\127784")+  ,("clown_face","\129313")   ,("clubs","\9827\65039")   ,("cn","\127464\127475")+  ,("coat","\129509")   ,("cocktail","\127864")+  ,("coconut","\129381")+  ,("cocos_islands","\127464\127464")   ,("coffee","\9749")+  ,("coffin","\9904")+  ,("cold_face","\129398")   ,("cold_sweat","\128560")   ,("collision","\128165")+  ,("colombia","\127464\127476")+  ,("comet","\9732")+  ,("comoros","\127472\127474")+  ,("compass","\129517")   ,("computer","\128187")+  ,("computer_mouse","\128433")   ,("confetti_ball","\127882")   ,("confounded","\128534")   ,("confused","\128533")+  ,("congo_brazzaville","\127464\127468")+  ,("congo_kinshasa","\127464\127465")   ,("congratulations","\12951\65039")   ,("construction","\128679")   ,("construction_worker","\128119")+  ,("construction_worker_man","\128119\8205\9794")+  ,("construction_worker_woman","\128119\8205\9792")+  ,("control_knobs","\127899")   ,("convenience_store","\127978")+  ,("cook_islands","\127464\127472")   ,("cookie","\127850")   ,("cool","\127378")   ,("cop","\128110")   ,("copyright","\169\65039")   ,("corn","\127805")+  ,("costa_rica","\127464\127479")+  ,("cote_divoire","\127464\127470")+  ,("couch_and_lamp","\128715")   ,("couple","\128107")   ,("couple_with_heart","\128145")+  ,("couple_with_heart_man_man"+   , "\128104\8205\10084\65039\8205\128104"+   )+  ,("couple_with_heart_woman_man"+   , "\128105\8205\10084\65039\8205\128104"+   )+  ,("couple_with_heart_woman_woman"+   , "\128105\8205\10084\65039\8205\128105"+   )   ,("couplekiss","\128143")+  ,("couplekiss_man_man"+   , "\128104\8205\10084\65039\8205\128139\8205\128104"+   )+  ,("couplekiss_man_woman"+   , "\128105\8205\10084\65039\8205\128139\8205\128104"+   )+  ,("couplekiss_woman_woman"+   , "\128105\8205\10084\65039\8205\128139\8205\128105"+   )   ,("cow","\128046")   ,("cow2","\128004")+  ,("cowboy_hat_face","\129312")+  ,("crab","\129408")+  ,("crayon","\128397")   ,("credit_card","\128179")   ,("crescent_moon","\127769")+  ,("cricket","\129431")+  ,("cricket_game","\127951")+  ,("croatia","\127469\127479")   ,("crocodile","\128010")+  ,("croissant","\129360")+  ,("crossed_fingers","\129310")   ,("crossed_flags","\127884")+  ,("crossed_swords","\9876")   ,("crown","\128081")   ,("cry","\128546")   ,("crying_cat_face","\128575")   ,("crystal_ball","\128302")+  ,("cuba","\127464\127482")+  ,("cucumber","\129362")+  ,("cup_with_straw","\129380")+  ,("cupcake","\129473")   ,("cupid","\128152")+  ,("curacao","\127464\127484")+  ,("curling_stone","\129356")+  ,("curly_haired_man","\128104\8205\129457")+  ,("curly_haired_woman","\128105\8205\129457")   ,("curly_loop","\10160")   ,("currency_exchange","\128177")   ,("curry","\127835")+  ,("cursing_face","\129324")   ,("custard","\127854")   ,("customs","\128707")+  ,("cut_of_meat","\129385")   ,("cyclone","\127744")+  ,("cyprus","\127464\127486")+  ,("czech_republic","\127464\127487")+  ,("dagger","\128481")   ,("dancer","\128131")   ,("dancers","\128111")+  ,("dancing_men","\128111\8205\9794")+  ,("dancing_women","\128111\8205\9792")   ,("dango","\127841")+  ,("dark_sunglasses","\128374")   ,("dart","\127919")   ,("dash","\128168")   ,("date","\128197")   ,("de","\127465\127466")+  ,("deaf_man","\129487\8205\9794")+  ,("deaf_person","\129487")+  ,("deaf_woman","\129487\8205\9792")   ,("deciduous_tree","\127795")+  ,("deer","\129420")+  ,("denmark","\127465\127472")   ,("department_store","\127980")+  ,("derelict_house","\127962")+  ,("desert","\127964")+  ,("desert_island","\127965")+  ,("desktop_computer","\128421")+  ,("detective","\128373")   ,("diamond_shape_with_a_dot_inside","\128160")   ,("diamonds","\9830\65039")+  ,("diego_garcia","\127465\127468")   ,("disappointed","\128542")   ,("disappointed_relieved","\128549")+  ,("diving_mask","\129343")+  ,("diya_lamp","\129684")   ,("dizzy","\128171")   ,("dizzy_face","\128565")+  ,("djibouti","\127465\127471")+  ,("dna","\129516")   ,("do_not_litter","\128687")   ,("dog","\128054")   ,("dog2","\128021")   ,("dollar","\128181")   ,("dolls","\127886")   ,("dolphin","\128044")+  ,("dominica","\127465\127474")+  ,("dominican_republic","\127465\127476")   ,("door","\128682")   ,("doughnut","\127849")+  ,("dove","\128330")   ,("dragon","\128009")   ,("dragon_face","\128050")   ,("dress","\128087")   ,("dromedary_camel","\128042")+  ,("drooling_face","\129316")+  ,("drop_of_blood","\129656")   ,("droplet","\128167")+  ,("drum","\129345")+  ,("duck","\129414")+  ,("dumpling","\129375")   ,("dvd","\128192")   ,("e-mail","\128231")+  ,("eagle","\129413")   ,("ear","\128066")   ,("ear_of_rice","\127806")+  ,("ear_with_hearing_aid","\129467")   ,("earth_africa","\127757")   ,("earth_americas","\127758")   ,("earth_asia","\127759")-  ,("egg","\127859")+  ,("ecuador","\127466\127464")+  ,("egg","\129370")   ,("eggplant","\127814")+  ,("egypt","\127466\127468")   ,("eight","8\65039\8419")   ,("eight_pointed_black_star","\10036\65039")   ,("eight_spoked_asterisk","\10035\65039")+  ,("eject_button","\9167\65039")+  ,("el_salvador","\127480\127483")   ,("electric_plug","\128268")   ,("elephant","\128024")+  ,("elf","\129501")+  ,("elf_man","\129501\8205\9794")+  ,("elf_woman","\129501\8205\9792")   ,("email","\9993\65039")   ,("end","\128282")+  ,("england"+   , "\127988\917607\917602\917605\917614\917607\917631"+   )   ,("envelope","\9993\65039")   ,("envelope_with_arrow","\128233")+  ,("equatorial_guinea","\127468\127478")+  ,("eritrea","\127466\127479")   ,("es","\127466\127480")+  ,("estonia","\127466\127466")+  ,("ethiopia","\127466\127481")+  ,("eu","\127466\127482")   ,("euro","\128182")   ,("european_castle","\127984")   ,("european_post_office","\127972")+  ,("european_union","\127466\127482")   ,("evergreen_tree","\127794")   ,("exclamation","\10071")+  ,("exploding_head","\129327")   ,("expressionless","\128529")+  ,("eye","\128065")+  ,("eye_speech_bubble","\128065\65039\8205\128488\65039")   ,("eyeglasses","\128083")   ,("eyes","\128064")+  ,("face_with_head_bandage","\129301")+  ,("face_with_thermometer","\129298")+  ,("facepalm","\129318")   ,("facepunch","\128074")   ,("factory","\127981")+  ,("fairy","\129498")+  ,("fairy_man","\129498\8205\9794")+  ,("fairy_woman","\129498\8205\9792")+  ,("falafel","\129478")+  ,("falkland_islands","\127467\127472")   ,("fallen_leaf","\127810")   ,("family","\128106")+  ,("family_man_boy","\128104\8205\128102")+  ,("family_man_boy_boy","\128104\8205\128102\8205\128102")+  ,("family_man_girl","\128104\8205\128103")+  ,("family_man_girl_boy","\128104\8205\128103\8205\128102")+  ,("family_man_girl_girl","\128104\8205\128103\8205\128103")+  ,("family_man_man_boy","\128104\8205\128104\8205\128102")+  ,("family_man_man_boy_boy"+   , "\128104\8205\128104\8205\128102\8205\128102"+   )+  ,("family_man_man_girl","\128104\8205\128104\8205\128103")+  ,("family_man_man_girl_boy"+   , "\128104\8205\128104\8205\128103\8205\128102"+   )+  ,("family_man_man_girl_girl"+   , "\128104\8205\128104\8205\128103\8205\128103"+   )+  ,("family_man_woman_boy","\128104\8205\128105\8205\128102")+  ,("family_man_woman_boy_boy"+   , "\128104\8205\128105\8205\128102\8205\128102"+   )+  ,("family_man_woman_girl","\128104\8205\128105\8205\128103")+  ,("family_man_woman_girl_boy"+   , "\128104\8205\128105\8205\128103\8205\128102"+   )+  ,("family_man_woman_girl_girl"+   , "\128104\8205\128105\8205\128103\8205\128103"+   )+  ,("family_woman_boy","\128105\8205\128102")+  ,("family_woman_boy_boy","\128105\8205\128102\8205\128102")+  ,("family_woman_girl","\128105\8205\128103")+  ,("family_woman_girl_boy","\128105\8205\128103\8205\128102")+  ,("family_woman_girl_girl","\128105\8205\128103\8205\128103")+  ,("family_woman_woman_boy","\128105\8205\128105\8205\128102")+  ,("family_woman_woman_boy_boy"+   , "\128105\8205\128105\8205\128102\8205\128102"+   )+  ,("family_woman_woman_girl","\128105\8205\128105\8205\128103")+  ,("family_woman_woman_girl_boy"+   , "\128105\8205\128105\8205\128103\8205\128102"+   )+  ,("family_woman_woman_girl_girl"+   , "\128105\8205\128105\8205\128103\8205\128103"+   )+  ,("faroe_islands","\127467\127476")   ,("fast_forward","\9193")   ,("fax","\128224")   ,("fearful","\128552")   ,("feet","\128062")+  ,("female_detective","\128373\65039\8205\9792\65039")+  ,("female_sign","\9792\65039")   ,("ferris_wheel","\127905")+  ,("ferry","\9972")+  ,("field_hockey","\127953")+  ,("fiji","\127467\127471")+  ,("file_cabinet","\128452")   ,("file_folder","\128193")+  ,("film_projector","\128253")+  ,("film_strip","\127902")+  ,("finland","\127467\127470")   ,("fire","\128293")   ,("fire_engine","\128658")+  ,("fire_extinguisher","\129519")+  ,("firecracker","\129512")   ,("fireworks","\127878")   ,("first_quarter_moon","\127763")   ,("first_quarter_moon_with_face","\127771")@@ -316,64 +635,134 @@   ,("fish_cake","\127845")   ,("fishing_pole_and_fish","\127907")   ,("fist","\9994")+  ,("fist_left","\129307")+  ,("fist_oncoming","\128074")+  ,("fist_raised","\9994")+  ,("fist_right","\129308")   ,("five","5\65039\8419")   ,("flags","\127887")+  ,("flamingo","\129449")   ,("flashlight","\128294")+  ,("flat_shoe","\129407")+  ,("fleur_de_lis","\9884")+  ,("flight_arrival","\128748")+  ,("flight_departure","\128747")   ,("flipper","\128044")   ,("floppy_disk","\128190")   ,("flower_playing_cards","\127924")   ,("flushed","\128563")+  ,("flying_disc","\129359")+  ,("flying_saucer","\128760")+  ,("fog","\127787")   ,("foggy","\127745")+  ,("foot","\129462")   ,("football","\127944")   ,("footprints","\128099")   ,("fork_and_knife","\127860")+  ,("fortune_cookie","\129376")   ,("fountain","\9970")+  ,("fountain_pen","\128395")   ,("four","4\65039\8419")   ,("four_leaf_clover","\127808")+  ,("fox_face","\129418")   ,("fr","\127467\127479")+  ,("framed_picture","\128444")   ,("free","\127379")+  ,("french_guiana","\127468\127467")+  ,("french_polynesia","\127477\127467")+  ,("french_southern_territories","\127481\127467")+  ,("fried_egg","\127859")   ,("fried_shrimp","\127844")   ,("fries","\127839")   ,("frog","\128056")   ,("frowning","\128550")+  ,("frowning_face","\9785")+  ,("frowning_man","\128589\8205\9794")+  ,("frowning_person","\128589")+  ,("frowning_woman","\128589\8205\9792")+  ,("fu","\128405")   ,("fuelpump","\9981")   ,("full_moon","\127765")   ,("full_moon_with_face","\127773")+  ,("funeral_urn","\9905")+  ,("gabon","\127468\127462")+  ,("gambia","\127468\127474")   ,("game_die","\127922")+  ,("garlic","\129476")   ,("gb","\127468\127463")+  ,("gear","\9881")   ,("gem","\128142")   ,("gemini","\9802")+  ,("genie","\129502")+  ,("genie_man","\129502\8205\9794")+  ,("genie_woman","\129502\8205\9792")+  ,("georgia","\127468\127466")+  ,("ghana","\127468\127469")   ,("ghost","\128123")+  ,("gibraltar","\127468\127470")   ,("gift","\127873")   ,("gift_heart","\128157")+  ,("giraffe","\129426")   ,("girl","\128103")   ,("globe_with_meridians","\127760")+  ,("gloves","\129508")+  ,("goal_net","\129349")   ,("goat","\128016")+  ,("goggles","\129405")   ,("golf","\9971")+  ,("golfing","\127948")+  ,("golfing_man","\127948\65039\8205\9794\65039")+  ,("golfing_woman","\127948\65039\8205\9792\65039")+  ,("gorilla","\129421")   ,("grapes","\127815")+  ,("greece","\127468\127479")   ,("green_apple","\127823")   ,("green_book","\128215")+  ,("green_circle","\128994")   ,("green_heart","\128154")+  ,("green_salad","\129367")+  ,("green_square","\129001")+  ,("greenland","\127468\127473")+  ,("grenada","\127468\127465")   ,("grey_exclamation","\10069")   ,("grey_question","\10068")   ,("grimacing","\128556")   ,("grin","\128513")   ,("grinning","\128512")-  ,("guardsman","\128130")+  ,("guadeloupe","\127468\127477")+  ,("guam","\127468\127482")+  ,("guard","\128130")+  ,("guardsman","\128130\8205\9794")+  ,("guardswoman","\128130\8205\9792")+  ,("guatemala","\127468\127481")+  ,("guernsey","\127468\127468")+  ,("guide_dog","\129454")+  ,("guinea","\127468\127475")+  ,("guinea_bissau","\127468\127484")   ,("guitar","\127928")   ,("gun","\128299")+  ,("guyana","\127468\127486")   ,("haircut","\128135")+  ,("haircut_man","\128135\8205\9794")+  ,("haircut_woman","\128135\8205\9792")+  ,("haiti","\127469\127481")   ,("hamburger","\127828")   ,("hammer","\128296")+  ,("hammer_and_pick","\9874")+  ,("hammer_and_wrench","\128736")   ,("hamster","\128057")   ,("hand","\9995")+  ,("hand_over_mouth","\129325")   ,("handbag","\128092")+  ,("handball_person","\129342")+  ,("handshake","\129309")   ,("hankey","\128169")   ,("hash","#\65039\8419")   ,("hatched_chick","\128037")   ,("hatching_chick","\128035")   ,("headphones","\127911")   ,("hear_no_evil","\128585")+  ,("heard_mcdonald_islands","\127469\127474")   ,("heart","\10084\65039")   ,("heart_decoration","\128159")   ,("heart_eyes","\128525")@@ -385,162 +774,354 @@   ,("heavy_division_sign","\10135")   ,("heavy_dollar_sign","\128178")   ,("heavy_exclamation_mark","\10071")+  ,("heavy_heart_exclamation","\10083\65039")   ,("heavy_minus_sign","\10134")   ,("heavy_multiplication_x","\10006\65039")   ,("heavy_plus_sign","\10133")+  ,("hedgehog","\129428")   ,("helicopter","\128641")   ,("herb","\127807")   ,("hibiscus","\127802")   ,("high_brightness","\128262")   ,("high_heel","\128096")+  ,("hiking_boot","\129406")+  ,("hindu_temple","\128725")+  ,("hippopotamus","\129435")   ,("hocho","\128298")+  ,("hole","\128371")+  ,("honduras","\127469\127475")   ,("honey_pot","\127855")   ,("honeybee","\128029")+  ,("hong_kong","\127469\127472")   ,("horse","\128052")   ,("horse_racing","\127943")   ,("hospital","\127973")+  ,("hot_face","\129397")+  ,("hot_pepper","\127798")+  ,("hotdog","\127789")   ,("hotel","\127976")   ,("hotsprings","\9832\65039")   ,("hourglass","\8987")   ,("hourglass_flowing_sand","\9203")   ,("house","\127968")   ,("house_with_garden","\127969")+  ,("houses","\127960")+  ,("hugs","\129303")+  ,("hungary","\127469\127482")   ,("hushed","\128559")   ,("ice_cream","\127848")+  ,("ice_cube","\129482")+  ,("ice_hockey","\127954")+  ,("ice_skate","\9976")   ,("icecream","\127846")+  ,("iceland","\127470\127480")   ,("id","\127380")   ,("ideograph_advantage","\127568")   ,("imp","\128127")   ,("inbox_tray","\128229")   ,("incoming_envelope","\128232")+  ,("india","\127470\127475")+  ,("indonesia","\127470\127465")+  ,("infinity","\9854")   ,("information_desk_person","\128129")   ,("information_source","\8505\65039")   ,("innocent","\128519")   ,("interrobang","\8265\65039")   ,("iphone","\128241")+  ,("iran","\127470\127479")+  ,("iraq","\127470\127478")+  ,("ireland","\127470\127466")+  ,("isle_of_man","\127470\127474")+  ,("israel","\127470\127473")   ,("it","\127470\127481")   ,("izakaya_lantern","\127982")   ,("jack_o_lantern","\127875")+  ,("jamaica","\127471\127474")   ,("japan","\128510")   ,("japanese_castle","\127983")   ,("japanese_goblin","\128122")   ,("japanese_ogre","\128121")   ,("jeans","\128086")+  ,("jersey","\127471\127466")+  ,("jigsaw","\129513")+  ,("jordan","\127471\127476")   ,("joy","\128514")   ,("joy_cat","\128569")+  ,("joystick","\128377")   ,("jp","\127471\127477")+  ,("juggling_person","\129337")+  ,("kaaba","\128331")+  ,("kangaroo","\129432")+  ,("kazakhstan","\127472\127487")+  ,("kenya","\127472\127466")   ,("key","\128273")+  ,("keyboard","\9000")   ,("keycap_ten","\128287")+  ,("kick_scooter","\128756")   ,("kimono","\128088")+  ,("kiribati","\127472\127470")   ,("kiss","\128139")   ,("kissing","\128535")   ,("kissing_cat","\128573")   ,("kissing_closed_eyes","\128538")   ,("kissing_heart","\128536")   ,("kissing_smiling_eyes","\128537")+  ,("kite","\129665")+  ,("kiwi_fruit","\129373")+  ,("kneeling_man","\129486\8205\9794")+  ,("kneeling_person","\129486")+  ,("kneeling_woman","\129486\8205\9792")   ,("knife","\128298")   ,("koala","\128040")   ,("koko","\127489")+  ,("kosovo","\127485\127472")   ,("kr","\127472\127479")+  ,("kuwait","\127472\127484")+  ,("kyrgyzstan","\127472\127468")+  ,("lab_coat","\129404")+  ,("label","\127991")+  ,("lacrosse","\129357")   ,("lantern","\127982")+  ,("laos","\127473\127462")   ,("large_blue_circle","\128309")   ,("large_blue_diamond","\128311")   ,("large_orange_diamond","\128310")   ,("last_quarter_moon","\127767")   ,("last_quarter_moon_with_face","\127772")+  ,("latin_cross","\10013\65039")+  ,("latvia","\127473\127483")   ,("laughing","\128518")+  ,("leafy_green","\129388")   ,("leaves","\127811")+  ,("lebanon","\127473\127463")   ,("ledger","\128210")   ,("left_luggage","\128709")   ,("left_right_arrow","\8596\65039")+  ,("left_speech_bubble","\128488")   ,("leftwards_arrow_with_hook","\8617\65039")+  ,("leg","\129461")   ,("lemon","\127819")   ,("leo","\9804")   ,("leopard","\128006")+  ,("lesotho","\127473\127480")+  ,("level_slider","\127898")+  ,("liberia","\127473\127479")   ,("libra","\9806")+  ,("libya","\127473\127486")+  ,("liechtenstein","\127473\127470")   ,("light_rail","\128648")   ,("link","\128279")+  ,("lion","\129409")   ,("lips","\128068")   ,("lipstick","\128132")+  ,("lithuania","\127473\127481")+  ,("lizard","\129422")+  ,("llama","\129433")+  ,("lobster","\129438")   ,("lock","\128274")   ,("lock_with_ink_pen","\128271")   ,("lollipop","\127853")   ,("loop","\10175")+  ,("lotion_bottle","\129524")+  ,("lotus_position","\129496")+  ,("lotus_position_man","\129496\8205\9794")+  ,("lotus_position_woman","\129496\8205\9792")   ,("loud_sound","\128266")   ,("loudspeaker","\128226")   ,("love_hotel","\127977")   ,("love_letter","\128140")+  ,("love_you_gesture","\129311")   ,("low_brightness","\128261")+  ,("luggage","\129523")+  ,("luxembourg","\127473\127482")+  ,("lying_face","\129317")   ,("m","\9410\65039")+  ,("macau","\127474\127476")+  ,("macedonia","\127474\127472")+  ,("madagascar","\127474\127468")   ,("mag","\128269")   ,("mag_right","\128270")+  ,("mage","\129497")+  ,("mage_man","\129497\8205\9794")+  ,("mage_woman","\129497\8205\9792")+  ,("magnet","\129522")   ,("mahjong","\126980")   ,("mailbox","\128235")   ,("mailbox_closed","\128234")   ,("mailbox_with_mail","\128236")   ,("mailbox_with_no_mail","\128237")+  ,("malawi","\127474\127484")+  ,("malaysia","\127474\127486")+  ,("maldives","\127474\127483")+  ,("male_detective","\128373\65039\8205\9794\65039")+  ,("male_sign","\9794\65039")+  ,("mali","\127474\127473")+  ,("malta","\127474\127481")   ,("man","\128104")+  ,("man_artist","\128104\8205\127912")+  ,("man_astronaut","\128104\8205\128640")+  ,("man_cartwheeling","\129336\8205\9794")+  ,("man_cook","\128104\8205\127859")+  ,("man_dancing","\128378")+  ,("man_facepalming","\129318\8205\9794")+  ,("man_factory_worker","\128104\8205\127981")+  ,("man_farmer","\128104\8205\127806")+  ,("man_firefighter","\128104\8205\128658")+  ,("man_health_worker","\128104\8205\9877")+  ,("man_in_manual_wheelchair","\128104\8205\129469")+  ,("man_in_motorized_wheelchair","\128104\8205\129468")+  ,("man_in_tuxedo","\129333")+  ,("man_judge","\128104\8205\9878")+  ,("man_juggling","\129337\8205\9794")+  ,("man_mechanic","\128104\8205\128295")+  ,("man_office_worker","\128104\8205\128188")+  ,("man_pilot","\128104\8205\9992")+  ,("man_playing_handball","\129342\8205\9794")+  ,("man_playing_water_polo","\129341\8205\9794")+  ,("man_scientist","\128104\8205\128300")+  ,("man_shrugging","\129335\8205\9794")+  ,("man_singer","\128104\8205\127908")+  ,("man_student","\128104\8205\127891")+  ,("man_teacher","\128104\8205\127979")+  ,("man_technologist","\128104\8205\128187")   ,("man_with_gua_pi_mao","\128114")-  ,("man_with_turban","\128115")+  ,("man_with_probing_cane","\128104\8205\129455")+  ,("man_with_turban","\128115\8205\9794")+  ,("mandarin","\127818")+  ,("mango","\129389")   ,("mans_shoe","\128094")+  ,("mantelpiece_clock","\128368")+  ,("manual_wheelchair","\129469")   ,("maple_leaf","\127809")+  ,("marshall_islands","\127474\127469")+  ,("martial_arts_uniform","\129355")+  ,("martinique","\127474\127478")   ,("mask","\128567")   ,("massage","\128134")+  ,("massage_man","\128134\8205\9794")+  ,("massage_woman","\128134\8205\9792")+  ,("mate","\129481")+  ,("mauritania","\127474\127479")+  ,("mauritius","\127474\127482")+  ,("mayotte","\127486\127481")   ,("meat_on_bone","\127830")+  ,("mechanical_arm","\129470")+  ,("mechanical_leg","\129471")+  ,("medal_military","\127894")+  ,("medal_sports","\127941")+  ,("medical_symbol","\9877")   ,("mega","\128227")   ,("melon","\127816")   ,("memo","\128221")+  ,("men_wrestling","\129340\8205\9794")+  ,("menorah","\128334")   ,("mens","\128697")+  ,("mermaid","\129500\8205\9792")+  ,("merman","\129500\8205\9794")+  ,("merperson","\129500")+  ,("metal","\129304")   ,("metro","\128647")+  ,("mexico","\127474\127485")+  ,("microbe","\129440")+  ,("micronesia","\127467\127474")   ,("microphone","\127908")   ,("microscope","\128300")+  ,("middle_finger","\128405")+  ,("milk_glass","\129371")   ,("milky_way","\127756")   ,("minibus","\128656")   ,("minidisc","\128189")   ,("mobile_phone_off","\128244")+  ,("moldova","\127474\127465")+  ,("monaco","\127474\127464")+  ,("money_mouth_face","\129297")   ,("money_with_wings","\128184")   ,("moneybag","\128176")+  ,("mongolia","\127474\127475")   ,("monkey","\128018")   ,("monkey_face","\128053")+  ,("monocle_face","\129488")   ,("monorail","\128669")+  ,("montenegro","\127474\127466")+  ,("montserrat","\127474\127480")   ,("moon","\127764")+  ,("moon_cake","\129390")+  ,("morocco","\127474\127462")   ,("mortar_board","\127891")+  ,("mosque","\128332")+  ,("mosquito","\129439")+  ,("motor_boat","\128741")+  ,("motor_scooter","\128757")+  ,("motorcycle","\127949")+  ,("motorized_wheelchair","\129468")+  ,("motorway","\128739")   ,("mount_fuji","\128507")+  ,("mountain","\9968")   ,("mountain_bicyclist","\128693")+  ,("mountain_biking_man","\128693\8205\9794")+  ,("mountain_biking_woman","\128693\8205\9792")   ,("mountain_cableway","\128672")   ,("mountain_railway","\128670")+  ,("mountain_snow","\127956")   ,("mouse","\128045")   ,("mouse2","\128001")   ,("movie_camera","\127909")   ,("moyai","\128511")+  ,("mozambique","\127474\127487")+  ,("mrs_claus","\129334")   ,("muscle","\128170")   ,("mushroom","\127812")   ,("musical_keyboard","\127929")   ,("musical_note","\127925")   ,("musical_score","\127932")   ,("mute","\128263")+  ,("myanmar","\127474\127474")   ,("nail_care","\128133")   ,("name_badge","\128219")+  ,("namibia","\127475\127462")+  ,("national_park","\127966")+  ,("nauru","\127475\127479")+  ,("nauseated_face","\129314")+  ,("nazar_amulet","\129535")   ,("necktie","\128084")   ,("negative_squared_cross_mark","\10062")+  ,("nepal","\127475\127477")+  ,("nerd_face","\129299")+  ,("netherlands","\127475\127473")   ,("neutral_face","\128528")   ,("new","\127381")+  ,("new_caledonia","\127475\127464")   ,("new_moon","\127761")   ,("new_moon_with_face","\127770")+  ,("new_zealand","\127475\127487")   ,("newspaper","\128240")+  ,("newspaper_roll","\128478")+  ,("next_track_button","\9197")   ,("ng","\127382")+  ,("ng_man","\128581\8205\9794")+  ,("ng_woman","\128581\8205\9792")+  ,("nicaragua","\127475\127470")+  ,("niger","\127475\127466")+  ,("nigeria","\127475\127468")   ,("night_with_stars","\127747")   ,("nine","9\65039\8419")+  ,("niue","\127475\127482")   ,("no_bell","\128277")   ,("no_bicycles","\128691")   ,("no_entry","\9940")   ,("no_entry_sign","\128683")   ,("no_good","\128581")+  ,("no_good_man","\128581\8205\9794")+  ,("no_good_woman","\128581\8205\9792")   ,("no_mobile_phones","\128245")   ,("no_mouth","\128566")   ,("no_pedestrians","\128695")   ,("no_smoking","\128685")   ,("non-potable_water","\128689")+  ,("norfolk_island","\127475\127467")+  ,("north_korea","\127472\127477")+  ,("northern_mariana_islands","\127474\127477")+  ,("norway","\127475\127476")   ,("nose","\128067")   ,("notebook","\128211")   ,("notebook_with_decorative_cover","\128212")@@ -552,136 +1133,264 @@   ,("octopus","\128025")   ,("oden","\127842")   ,("office","\127970")+  ,("oil_drum","\128738")   ,("ok","\127383")   ,("ok_hand","\128076")-  ,("ok_woman","\128582")+  ,("ok_man","\128582\8205\9794")+  ,("ok_person","\128582")+  ,("ok_woman","\128582\8205\9792")+  ,("old_key","\128477")+  ,("older_adult","\129491")   ,("older_man","\128116")   ,("older_woman","\128117")+  ,("om","\128329")+  ,("oman","\127476\127474")   ,("on","\128283")   ,("oncoming_automobile","\128664")   ,("oncoming_bus","\128653")   ,("oncoming_police_car","\128660")   ,("oncoming_taxi","\128662")   ,("one","1\65039\8419")+  ,("one_piece_swimsuit","\129649")+  ,("onion","\129477")   ,("open_book","\128214")   ,("open_file_folder","\128194")   ,("open_hands","\128080")   ,("open_mouth","\128558")+  ,("open_umbrella","\9730\65039")   ,("ophiuchus","\9934")+  ,("orange","\127818")   ,("orange_book","\128217")+  ,("orange_circle","\128992")+  ,("orange_heart","\129505")+  ,("orange_square","\128999")+  ,("orangutan","\129447")+  ,("orthodox_cross","\9766")+  ,("otter","\129446")   ,("outbox_tray","\128228")+  ,("owl","\129417")   ,("ox","\128002")+  ,("oyster","\129450")   ,("package","\128230")   ,("page_facing_up","\128196")   ,("page_with_curl","\128195")   ,("pager","\128223")+  ,("paintbrush","\128396")+  ,("pakistan","\127477\127472")+  ,("palau","\127477\127484")+  ,("palestinian_territories","\127477\127480")   ,("palm_tree","\127796")+  ,("palms_up_together","\129330")+  ,("panama","\127477\127462")+  ,("pancakes","\129374")   ,("panda_face","\128060")   ,("paperclip","\128206")+  ,("paperclips","\128391")+  ,("papua_new_guinea","\127477\127468")+  ,("parachute","\129666")+  ,("paraguay","\127477\127486")+  ,("parasol_on_ground","\9969")   ,("parking","\127359\65039")+  ,("parrot","\129436")   ,("part_alternation_mark","\12349\65039")   ,("partly_sunny","\9925")+  ,("partying_face","\129395")+  ,("passenger_ship","\128755")   ,("passport_control","\128706")+  ,("pause_button","\9208")   ,("paw_prints","\128062")+  ,("peace_symbol","\9774")   ,("peach","\127825")+  ,("peacock","\129434")+  ,("peanuts","\129372")   ,("pear","\127824")+  ,("pen","\128394")   ,("pencil","\128221")   ,("pencil2","\9999\65039")   ,("penguin","\128039")   ,("pensive","\128532")+  ,("people_holding_hands","\129489\8205\129309\8205\129489")   ,("performing_arts","\127917")   ,("persevere","\128547")-  ,("person_frowning","\128589")-  ,("person_with_blond_hair","\128113")-  ,("person_with_pouting_face","\128590")+  ,("person_fencing","\129338")+  ,("person_with_turban","\128115")+  ,("peru","\127477\127466")+  ,("petri_dish","\129515")+  ,("philippines","\127477\127469")   ,("phone","\9742\65039")+  ,("pick","\9935")+  ,("pie","\129383")   ,("pig","\128055")   ,("pig2","\128022")   ,("pig_nose","\128061")   ,("pill","\128138")+  ,("pinching_hand","\129295")   ,("pineapple","\127821")+  ,("ping_pong","\127955")+  ,("pirate_flag","\127988\8205\9760")   ,("pisces","\9811")+  ,("pitcairn_islands","\127477\127475")   ,("pizza","\127829")+  ,("place_of_worship","\128720")+  ,("plate_with_cutlery","\127869")+  ,("play_or_pause_button","\9199")+  ,("pleading_face","\129402")   ,("point_down","\128071")   ,("point_left","\128072")   ,("point_right","\128073")   ,("point_up","\9757\65039")   ,("point_up_2","\128070")+  ,("poland","\127477\127473")   ,("police_car","\128659")+  ,("police_officer","\128110")+  ,("policeman","\128110\8205\9794")+  ,("policewoman","\128110\8205\9792")   ,("poodle","\128041")   ,("poop","\128169")+  ,("popcorn","\127871")+  ,("portugal","\127477\127481")   ,("post_office","\127971")   ,("postal_horn","\128239")   ,("postbox","\128238")   ,("potable_water","\128688")+  ,("potato","\129364")   ,("pouch","\128093")   ,("poultry_leg","\127831")   ,("pound","\128183")+  ,("pout","\128545")   ,("pouting_cat","\128574")+  ,("pouting_face","\128590")+  ,("pouting_man","\128590\8205\9794")+  ,("pouting_woman","\128590\8205\9792")   ,("pray","\128591")+  ,("prayer_beads","\128255")+  ,("pregnant_woman","\129328")+  ,("pretzel","\129384")+  ,("previous_track_button","\9198")+  ,("prince","\129332")   ,("princess","\128120")+  ,("printer","\128424")+  ,("probing_cane","\129455")+  ,("puerto_rico","\127477\127479")   ,("punch","\128074")+  ,("purple_circle","\128995")   ,("purple_heart","\128156")+  ,("purple_square","\129002")   ,("purse","\128091")   ,("pushpin","\128204")   ,("put_litter_in_its_place","\128686")+  ,("qatar","\127478\127462")   ,("question","\10067")   ,("rabbit","\128048")   ,("rabbit2","\128007")+  ,("raccoon","\129437")   ,("racehorse","\128014")+  ,("racing_car","\127950")   ,("radio","\128251")   ,("radio_button","\128280")+  ,("radioactive","\9762")   ,("rage","\128545")   ,("railway_car","\128643")+  ,("railway_track","\128740")   ,("rainbow","\127752")+  ,("rainbow_flag","\127987\65039\8205\127752")+  ,("raised_back_of_hand","\129306")+  ,("raised_eyebrow","\129320")   ,("raised_hand","\9995")+  ,("raised_hand_with_fingers_splayed","\128400")   ,("raised_hands","\128588")   ,("raising_hand","\128587")+  ,("raising_hand_man","\128587\8205\9794")+  ,("raising_hand_woman","\128587\8205\9792")   ,("ram","\128015")   ,("ramen","\127836")   ,("rat","\128000")+  ,("razor","\129682")+  ,("receipt","\129534")+  ,("record_button","\9210")   ,("recycle","\9851\65039")   ,("red_car","\128663")   ,("red_circle","\128308")+  ,("red_envelope","\129511")+  ,("red_haired_man","\128104\8205\129456")+  ,("red_haired_woman","\128105\8205\129456")+  ,("red_square","\128997")   ,("registered","\174\65039")   ,("relaxed","\9786\65039")   ,("relieved","\128524")+  ,("reminder_ribbon","\127895")   ,("repeat","\128257")   ,("repeat_one","\128258")+  ,("rescue_worker_helmet","\9937")   ,("restroom","\128699")+  ,("reunion","\127479\127466")   ,("revolving_hearts","\128158")   ,("rewind","\9194")+  ,("rhinoceros","\129423")   ,("ribbon","\127872")   ,("rice","\127834")   ,("rice_ball","\127833")   ,("rice_cracker","\127832")   ,("rice_scene","\127889")+  ,("right_anger_bubble","\128495")   ,("ring","\128141")+  ,("ringed_planet","\129680")+  ,("robot","\129302")   ,("rocket","\128640")+  ,("rofl","\129315")+  ,("roll_eyes","\128580")+  ,("roll_of_paper","\129531")   ,("roller_coaster","\127906")+  ,("romania","\127479\127476")   ,("rooster","\128019")   ,("rose","\127801")+  ,("rosette","\127989")   ,("rotating_light","\128680")   ,("round_pushpin","\128205")   ,("rowboat","\128675")+  ,("rowing_man","\128675\8205\9794")+  ,("rowing_woman","\128675\8205\9792")   ,("ru","\127479\127482")   ,("rugby_football","\127945")   ,("runner","\127939")   ,("running","\127939")+  ,("running_man","\127939\8205\9794")   ,("running_shirt_with_sash","\127933")+  ,("running_woman","\127939\8205\9792")+  ,("rwanda","\127479\127484")   ,("sa","\127490\65039")+  ,("safety_pin","\129527")+  ,("safety_vest","\129466")   ,("sagittarius","\9808")   ,("sailboat","\9973")   ,("sake","\127862")+  ,("salt","\129474")+  ,("samoa","\127484\127480")+  ,("san_marino","\127480\127474")   ,("sandal","\128097")+  ,("sandwich","\129386")   ,("santa","\127877")+  ,("sao_tome_principe","\127480\127481")+  ,("sari","\129403")+  ,("sassy_man","\128129\8205\9794")+  ,("sassy_woman","\128129\8205\9792")   ,("satellite","\128225")   ,("satisfied","\128518")+  ,("saudi_arabia","\127480\127462")+  ,("sauna_man","\129494\8205\9794")+  ,("sauna_person","\129494")+  ,("sauna_woman","\129494\8205\9792")+  ,("sauropod","\129429")   ,("saxophone","\127927")+  ,("scarf","\129507")   ,("school","\127979")   ,("school_satchel","\127890")   ,("scissors","\9986\65039")+  ,("scorpion","\129410")   ,("scorpius","\9807")+  ,("scotland"+   , "\127988\917607\917602\917619\917603\917620\917631"+   )   ,("scream","\128561")   ,("scream_cat","\128576")   ,("scroll","\128220")@@ -689,23 +1398,54 @@   ,("secret","\12953\65039")   ,("see_no_evil","\128584")   ,("seedling","\127793")+  ,("selfie","\129331")+  ,("senegal","\127480\127475")+  ,("serbia","\127479\127480")+  ,("service_dog","\128021\8205\129466")   ,("seven","7\65039\8419")+  ,("seychelles","\127480\127464")+  ,("shallow_pan_of_food","\129368")+  ,("shamrock","\9752")+  ,("shark","\129416")   ,("shaved_ice","\127847")   ,("sheep","\128017")   ,("shell","\128026")+  ,("shield","\128737")+  ,("shinto_shrine","\9961")   ,("ship","\128674")   ,("shirt","\128085")   ,("shit","\128169")   ,("shoe","\128094")+  ,("shopping","\128717")+  ,("shopping_cart","\128722")+  ,("shorts","\129651")   ,("shower","\128703")+  ,("shrimp","\129424")+  ,("shrug","\129335")+  ,("shushing_face","\129323")+  ,("sierra_leone","\127480\127473")   ,("signal_strength","\128246")+  ,("singapore","\127480\127468")+  ,("sint_maarten","\127480\127485")   ,("six","6\65039\8419")   ,("six_pointed_star","\128303")+  ,("skateboard","\128761")   ,("ski","\127935")+  ,("skier","\9975")   ,("skull","\128128")+  ,("skull_and_crossbones","\9760")+  ,("skunk","\129448")+  ,("sled","\128759")   ,("sleeping","\128564")+  ,("sleeping_bed","\128716")   ,("sleepy","\128554")+  ,("slightly_frowning_face","\128577")+  ,("slightly_smiling_face","\128578")   ,("slot_machine","\127920")+  ,("sloth","\129445")+  ,("slovakia","\127480\127472")+  ,("slovenia","\127480\127470")+  ,("small_airplane","\128745")   ,("small_blue_diamond","\128313")   ,("small_orange_diamond","\128312")   ,("small_red_triangle","\128314")@@ -714,20 +1454,31 @@   ,("smile_cat","\128568")   ,("smiley","\128515")   ,("smiley_cat","\128570")+  ,("smiling_face_with_three_hearts","\129392")   ,("smiling_imp","\128520")   ,("smirk","\128527")   ,("smirk_cat","\128572")   ,("smoking","\128684")   ,("snail","\128012")   ,("snake","\128013")+  ,("sneezing_face","\129319")   ,("snowboarder","\127938")   ,("snowflake","\10052\65039")   ,("snowman","\9924")+  ,("snowman_with_snow","\9731\65039")+  ,("soap","\129532")   ,("sob","\128557")   ,("soccer","\9917")+  ,("socks","\129510")+  ,("softball","\129358")+  ,("solomon_islands","\127480\127463")+  ,("somalia","\127480\127476")   ,("soon","\128284")   ,("sos","\127384")   ,("sound","\128265")+  ,("south_africa","\127487\127462")+  ,("south_georgia_south_sandwich_islands","\127468\127480")+  ,("south_sudan","\127480\127480")   ,("space_invader","\128126")   ,("spades","\9824\65039")   ,("spaghetti","\127837")@@ -737,62 +1488,140 @@   ,("sparkling_heart","\128150")   ,("speak_no_evil","\128586")   ,("speaker","\128264")+  ,("speaking_head","\128483")   ,("speech_balloon","\128172")   ,("speedboat","\128676")+  ,("spider","\128375")+  ,("spider_web","\128376")+  ,("spiral_calendar","\128467")+  ,("spiral_notepad","\128466")+  ,("sponge","\129533")+  ,("spoon","\129348")+  ,("squid","\129425")+  ,("sri_lanka","\127473\127472")+  ,("st_barthelemy","\127463\127473")+  ,("st_helena","\127480\127469")+  ,("st_kitts_nevis","\127472\127475")+  ,("st_lucia","\127473\127464")+  ,("st_martin","\127474\127467")+  ,("st_pierre_miquelon","\127477\127474")+  ,("st_vincent_grenadines","\127483\127464")+  ,("stadium","\127967")+  ,("standing_man","\129485\8205\9794")+  ,("standing_person","\129485")+  ,("standing_woman","\129485\8205\9792")   ,("star","\11088")   ,("star2","\127775")+  ,("star_and_crescent","\9770")+  ,("star_of_david","\10017\65039")+  ,("star_struck","\129321")   ,("stars","\127776")   ,("station","\128649")   ,("statue_of_liberty","\128509")   ,("steam_locomotive","\128642")+  ,("stethoscope","\129658")   ,("stew","\127858")+  ,("stop_button","\9209")+  ,("stop_sign","\128721")+  ,("stopwatch","\9201")   ,("straight_ruler","\128207")   ,("strawberry","\127827")   ,("stuck_out_tongue","\128539")   ,("stuck_out_tongue_closed_eyes","\128541")   ,("stuck_out_tongue_winking_eye","\128540")+  ,("studio_microphone","\127897")+  ,("stuffed_flatbread","\129369")+  ,("sudan","\127480\127465")+  ,("sun_behind_large_cloud","\127781")+  ,("sun_behind_rain_cloud","\127782")+  ,("sun_behind_small_cloud","\127780")   ,("sun_with_face","\127774")   ,("sunflower","\127803")   ,("sunglasses","\128526")   ,("sunny","\9728\65039")   ,("sunrise","\127749")   ,("sunrise_over_mountains","\127748")+  ,("superhero","\129464")+  ,("superhero_man","\129464\8205\9794")+  ,("superhero_woman","\129464\8205\9792")+  ,("supervillain","\129465")+  ,("supervillain_man","\129465\8205\9794")+  ,("supervillain_woman","\129465\8205\9792")   ,("surfer","\127940")+  ,("surfing_man","\127940\8205\9794")+  ,("surfing_woman","\127940\8205\9792")+  ,("suriname","\127480\127479")   ,("sushi","\127843")   ,("suspension_railway","\128671")+  ,("svalbard_jan_mayen","\127480\127471")+  ,("swan","\129442")+  ,("swaziland","\127480\127487")   ,("sweat","\128531")   ,("sweat_drops","\128166")   ,("sweat_smile","\128517")+  ,("sweden","\127480\127466")   ,("sweet_potato","\127840")+  ,("swim_brief","\129650")   ,("swimmer","\127946")+  ,("swimming_man","\127946\8205\9794")+  ,("swimming_woman","\127946\8205\9792")+  ,("switzerland","\127464\127469")   ,("symbols","\128291")+  ,("synagogue","\128333")+  ,("syria","\127480\127486")   ,("syringe","\128137")+  ,("t-rex","\129430")+  ,("taco","\127790")   ,("tada","\127881")+  ,("taiwan","\127481\127484")+  ,("tajikistan","\127481\127471")+  ,("takeout_box","\129377")   ,("tanabata_tree","\127883")   ,("tangerine","\127818")+  ,("tanzania","\127481\127487")   ,("taurus","\9801")   ,("taxi","\128661")   ,("tea","\127861")+  ,("teddy_bear","\129528")   ,("telephone","\9742\65039")   ,("telephone_receiver","\128222")   ,("telescope","\128301")   ,("tennis","\127934")   ,("tent","\9978")+  ,("test_tube","\129514")+  ,("thailand","\127481\127469")+  ,("thermometer","\127777")+  ,("thinking","\129300")   ,("thought_balloon","\128173")+  ,("thread","\129525")   ,("three","3\65039\8419")   ,("thumbsdown","\128078")   ,("thumbsup","\128077")   ,("ticket","\127915")+  ,("tickets","\127903")   ,("tiger","\128047")   ,("tiger2","\128005")+  ,("timer_clock","\9202")+  ,("timor_leste","\127481\127473")+  ,("tipping_hand_man","\128129\8205\9794")+  ,("tipping_hand_person","\128129")+  ,("tipping_hand_woman","\128129\8205\9792")   ,("tired_face","\128555")   ,("tm","\8482\65039")+  ,("togo","\127481\127468")   ,("toilet","\128701")+  ,("tokelau","\127481\127472")   ,("tokyo_tower","\128508")   ,("tomato","\127813")+  ,("tonga","\127481\127476")   ,("tongue","\128069")+  ,("toolbox","\129520")+  ,("tooth","\129463")   ,("top","\128285")   ,("tophat","\127913")+  ,("tornado","\127786")+  ,("tr","\127481\127479")+  ,("trackball","\128434")   ,("tractor","\128668")   ,("traffic_light","\128677")   ,("train","\128651")@@ -801,6 +1630,8 @@   ,("triangular_flag_on_post","\128681")   ,("triangular_ruler","\128208")   ,("trident","\128305")+  ,("trinidad_tobago","\127481\127481")+  ,("tristan_da_cunha","\127481\127462")   ,("triumph","\128548")   ,("trolleybus","\128654")   ,("trophy","\127942")@@ -810,7 +1641,13 @@   ,("trumpet","\127930")   ,("tshirt","\128085")   ,("tulip","\127799")+  ,("tumbler_glass","\129347")+  ,("tunisia","\127481\127475")+  ,("turkey","\129411")+  ,("turkmenistan","\127481\127474")+  ,("turks_caicos_islands","\127481\127464")   ,("turtle","\128034")+  ,("tuvalu","\127481\127483")   ,("tv","\128250")   ,("twisted_rightwards_arrows","\128256")   ,("two","2\65039\8419")@@ -828,29 +1665,56 @@   ,("u7533","\127544")   ,("u7981","\127538")   ,("u7a7a","\127539")+  ,("uganda","\127482\127468")   ,("uk","\127468\127463")+  ,("ukraine","\127482\127462")   ,("umbrella","\9748")   ,("unamused","\128530")   ,("underage","\128286")+  ,("unicorn","\129412")+  ,("united_arab_emirates","\127462\127466")+  ,("united_nations","\127482\127475")   ,("unlock","\128275")   ,("up","\127385")+  ,("upside_down_face","\128579")+  ,("uruguay","\127482\127486")   ,("us","\127482\127480")+  ,("us_outlying_islands","\127482\127474")+  ,("us_virgin_islands","\127483\127470")+  ,("uzbekistan","\127482\127487")   ,("v","\9996\65039")+  ,("vampire","\129499")+  ,("vampire_man","\129499\8205\9794")+  ,("vampire_woman","\129499\8205\9792")+  ,("vanuatu","\127483\127482")+  ,("vatican_city","\127483\127462")+  ,("venezuela","\127483\127466")   ,("vertical_traffic_light","\128678")   ,("vhs","\128252")   ,("vibration_mode","\128243")   ,("video_camera","\128249")   ,("video_game","\127918")+  ,("vietnam","\127483\127475")   ,("violin","\127931")   ,("virgo","\9805")   ,("volcano","\127755")+  ,("volleyball","\127952")+  ,("vomiting_face","\129326")   ,("vs","\127386")+  ,("vulcan_salute","\128406")+  ,("waffle","\129479")+  ,("wales","\127988\917607\917602\917623\917612\917619\917631")   ,("walking","\128694")+  ,("walking_man","\128694\8205\9794")+  ,("walking_woman","\128694\8205\9792")+  ,("wallis_futuna","\127484\127467")   ,("waning_crescent_moon","\127768")   ,("waning_gibbous_moon","\127766")   ,("warning","\9888\65039")+  ,("wastebasket","\128465")   ,("watch","\8986")   ,("water_buffalo","\128003")+  ,("water_polo","\129341")   ,("watermelon","\127817")   ,("wave","\128075")   ,("wavy_dash","\12336\65039")@@ -859,36 +1723,95 @@   ,("wc","\128702")   ,("weary","\128553")   ,("wedding","\128146")+  ,("weight_lifting","\127947")+  ,("weight_lifting_man","\127947\65039\8205\9794\65039")+  ,("weight_lifting_woman","\127947\65039\8205\9792\65039")+  ,("western_sahara","\127466\127469")   ,("whale","\128051")   ,("whale2","\128011")+  ,("wheel_of_dharma","\9784")   ,("wheelchair","\9855")   ,("white_check_mark","\9989")   ,("white_circle","\9898")+  ,("white_flag","\127987")   ,("white_flower","\128174")+  ,("white_haired_man","\128104\8205\129459")+  ,("white_haired_woman","\128105\8205\129459")+  ,("white_heart","\129293")   ,("white_large_square","\11036")   ,("white_medium_small_square","\9725")   ,("white_medium_square","\9723\65039")   ,("white_small_square","\9643\65039")   ,("white_square_button","\128307")+  ,("wilted_flower","\129344")   ,("wind_chime","\127888")+  ,("wind_face","\127788")   ,("wine_glass","\127863")   ,("wink","\128521")   ,("wolf","\128058")   ,("woman","\128105")+  ,("woman_artist","\128105\8205\127912")+  ,("woman_astronaut","\128105\8205\128640")+  ,("woman_cartwheeling","\129336\8205\9792")+  ,("woman_cook","\128105\8205\127859")+  ,("woman_dancing","\128131")+  ,("woman_facepalming","\129318\8205\9792")+  ,("woman_factory_worker","\128105\8205\127981")+  ,("woman_farmer","\128105\8205\127806")+  ,("woman_firefighter","\128105\8205\128658")+  ,("woman_health_worker","\128105\8205\9877")+  ,("woman_in_manual_wheelchair","\128105\8205\129469")+  ,("woman_in_motorized_wheelchair","\128105\8205\129468")+  ,("woman_judge","\128105\8205\9878")+  ,("woman_juggling","\129337\8205\9792")+  ,("woman_mechanic","\128105\8205\128295")+  ,("woman_office_worker","\128105\8205\128188")+  ,("woman_pilot","\128105\8205\9992")+  ,("woman_playing_handball","\129342\8205\9792")+  ,("woman_playing_water_polo","\129341\8205\9792")+  ,("woman_scientist","\128105\8205\128300")+  ,("woman_shrugging","\129335\8205\9792")+  ,("woman_singer","\128105\8205\127908")+  ,("woman_student","\128105\8205\127891")+  ,("woman_teacher","\128105\8205\127979")+  ,("woman_technologist","\128105\8205\128187")+  ,("woman_with_headscarf","\129493")+  ,("woman_with_probing_cane","\128105\8205\129455")+  ,("woman_with_turban","\128115\8205\9792")   ,("womans_clothes","\128090")   ,("womans_hat","\128082")+  ,("women_wrestling","\129340\8205\9792")   ,("womens","\128698")+  ,("woozy_face","\129396")+  ,("world_map","\128506")   ,("worried","\128543")   ,("wrench","\128295")+  ,("wrestling","\129340")+  ,("writing_hand","\9997\65039")   ,("x","\10060")+  ,("yarn","\129526")+  ,("yawning_face","\129393")+  ,("yellow_circle","\128993")   ,("yellow_heart","\128155")+  ,("yellow_square","\129000")+  ,("yemen","\127486\127466")   ,("yen","\128180")+  ,("yin_yang","\9775\65039")+  ,("yo_yo","\129664")   ,("yum","\128523")+  ,("zambia","\127487\127474")+  ,("zany_face","\129322")   ,("zap","\9889")+  ,("zebra","\129427")   ,("zero","0\65039\8419")+  ,("zimbabwe","\127487\127484")+  ,("zipper_mouth_face","\129296")+  ,("zombie","\129503")+  ,("zombie_man","\129503\8205\9794")+  ,("zombie_woman","\129503\8205\9792")   ,("zzz","\128164")   ] -emojiToInline :: String -> Maybe Inline+emojiToInline :: T.Text -> Maybe Inline emojiToInline emojikey = makeSpan <$> M.lookup emojikey emojis   where makeSpan = Span ("", ["emoji"], [("data-emoji", emojikey)]) . (:[]) . Str
src/Text/Pandoc/Error.hs view
@@ -1,6 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude  #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE OverloadedStrings  #-} {- |    Module      : Text.Pandoc.Error    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -22,6 +23,8 @@ import Control.Exception (Exception) import Data.Typeable (Typeable) import Data.Word (Word8)+import Data.Text (Text)+import qualified Data.Text as T import GHC.Generics (Generic) import Network.HTTP.Client (HttpException) import System.Exit (ExitCode (..), exitWith)@@ -31,29 +34,32 @@ import Text.Parsec.Error import Text.Parsec.Pos hiding (Line) -type Input = String+type Input = Text -data PandocError = PandocIOError String IOError-                 | PandocHttpError String HttpException-                 | PandocShouldNeverHappenError String-                 | PandocSomeError String-                 | PandocParseError String+data PandocError = PandocIOError Text IOError+                 | PandocHttpError Text HttpException+                 | PandocShouldNeverHappenError Text+                 | PandocSomeError Text+                 | PandocParseError Text                  | PandocParsecError Input ParseError-                 | PandocMakePDFError String-                 | PandocOptionError String-                 | PandocSyntaxMapError String+                 | PandocMakePDFError Text+                 | PandocOptionError Text+                 | PandocSyntaxMapError Text                  | PandocFailOnWarningError-                 | PandocPDFProgramNotFoundError String-                 | PandocPDFError String-                 | PandocFilterError String String-                 | PandocCouldNotFindDataFileError String-                 | PandocResourceNotFound String-                 | PandocTemplateError String-                 | PandocAppError String-                 | PandocEpubSubdirectoryError String-                 | PandocMacroLoop String-                 | PandocUTF8DecodingError String Int Word8-                 | PandocIpynbDecodingError String+                 | PandocPDFProgramNotFoundError Text+                 | PandocPDFError Text+                 | PandocFilterError Text Text+                 | PandocCouldNotFindDataFileError Text+                 | PandocResourceNotFound Text+                 | PandocTemplateError Text+                 | PandocAppError Text+                 | PandocEpubSubdirectoryError Text+                 | PandocMacroLoop Text+                 | PandocUTF8DecodingError Text Int Word8+                 | PandocIpynbDecodingError Text+                 | PandocUnknownReaderError Text+                 | PandocUnknownWriterError Text+                 | PandocUnsupportedExtensionError Text Text                  deriving (Show, Typeable, Generic)  instance Exception PandocError@@ -65,54 +71,79 @@   case e of     PandocIOError _ err' -> ioError err'     PandocHttpError u err' -> err 61 $-      "Could not fetch " ++ u ++ "\n" ++ show err'-    PandocShouldNeverHappenError s -> err 62 s+      "Could not fetch " <> u <> "\n" <> tshow err'+    PandocShouldNeverHappenError s -> err 62 $+      "Something we thought was impossible happened!\n" <>+      "Please report this to pandoc's developers: " <> s     PandocSomeError s -> err 63 s     PandocParseError s -> err 64 s     PandocParsecError input err' ->         let errPos = errorPos err'             errLine = sourceLine errPos             errColumn = sourceColumn errPos-            ls = lines input ++ [""]+            ls = T.lines input <> [""]             errorInFile = if length ls > errLine - 1-                            then concat ["\n", ls !! (errLine - 1)-                                        ,"\n", replicate (errColumn - 1) ' '-                                        ,"^"]+                            then T.concat ["\n", ls !! (errLine - 1)+                                          ,"\n", T.replicate (errColumn - 1) " "+                                          ,"^"]                         else ""-        in  err 65 $ "\nError at " ++ show  err' +++        in  err 65 $ "\nError at " <> tshow  err' <>                      -- if error comes from a chunk or included file,                      -- then we won't get the right text this way:                      if sourceName errPos == "source"                         then errorInFile                         else ""-    PandocMakePDFError s -> err 65 s-    PandocOptionError s -> err 2 s+    PandocMakePDFError s -> err 66 s+    PandocOptionError s -> err 6 s     PandocSyntaxMapError s -> err 67 s     PandocFailOnWarningError -> err 3 "Failing because there were warnings."     PandocPDFProgramNotFoundError pdfprog -> err 47 $-        pdfprog ++ " not found. Please select a different --pdf-engine or install " ++ pdfprog-    PandocPDFError logmsg -> err 43 $ "Error producing PDF.\n" ++ logmsg-    PandocFilterError filtername msg -> err 83 $ "Error running filter " ++-        filtername ++ ":\n" ++ msg+        pdfprog <> " not found. Please select a different --pdf-engine or install " <> pdfprog+    PandocPDFError logmsg -> err 43 $ "Error producing PDF.\n" <> logmsg+    PandocFilterError filtername msg -> err 83 $ "Error running filter " <>+        filtername <> ":\n" <> msg     PandocCouldNotFindDataFileError fn -> err 97 $-        "Could not find data file " ++ fn+        "Could not find data file " <> fn     PandocResourceNotFound fn -> err 99 $-        "File " ++ fn ++ " not found in resource path"-    PandocTemplateError s -> err 5 s-    PandocAppError s -> err 1 s+        "File " <> fn <> " not found in resource path"+    PandocTemplateError s -> err 5 $ "Error compiling template " <> s+    PandocAppError s -> err 4 s     PandocEpubSubdirectoryError s -> err 31 $-      "EPUB subdirectory name '" ++ s ++ "' contains illegal characters"+      "EPUB subdirectory name '" <> s <> "' contains illegal characters"     PandocMacroLoop s -> err 91 $-      "Loop encountered in expanding macro " ++ s+      "Loop encountered in expanding macro " <> s     PandocUTF8DecodingError f offset w -> err 92 $-      "UTF-8 decoding error in " ++ f ++ " at byte offset " ++ show offset ++-      " (" ++ printf "%2x" w ++ ").\n" +++      "UTF-8 decoding error in " <> f <> " at byte offset " <> tshow offset <>+      " (" <> T.pack (printf "%2x" w) <> ").\n" <>       "The input must be a UTF-8 encoded text."     PandocIpynbDecodingError w -> err 93 $-      "ipynb decoding error: " ++ w+      "ipynb decoding error: " <> w+    PandocUnknownReaderError r -> err 21 $+      "Unknown input format " <> r <>+      case r of+        "doc" -> "\nPandoc can convert from DOCX, but not from DOC." <>+                 "\nTry using Word to save your DOC file as DOCX," <>+                 " and convert that with pandoc."+        "pdf" -> "\nPandoc can convert to PDF, but not from PDF."+        _     -> ""+    PandocUnknownWriterError w -> err 22 $+       "Unknown output format " <> w <>+       case w of+         "pdf" -> "To create a pdf using pandoc, use" <>+                  " -t latex|beamer|context|ms|html5" <>+                 "\nand specify an output file with " <>+                 ".pdf extension (-o filename.pdf)."+         "doc" -> "\nPandoc can convert to DOCX, but not from DOC."+         _     -> ""+    PandocUnsupportedExtensionError ext f -> err 23 $+      "The extension " <> ext <> " is not supported " <>+      "for " <> f -err :: Int -> String -> IO a+err :: Int -> Text -> IO a err exitCode msg = do-  UTF8.hPutStrLn stderr msg+  UTF8.hPutStrLn stderr (T.unpack msg)   exitWith $ ExitFailure exitCode   return undefined++tshow :: Show a => a -> Text+tshow = T.pack . show
src/Text/Pandoc/Extensions.hs view
@@ -2,10 +2,9 @@ {-# LANGUAGE NoImplicitPrelude          #-} {-# LANGUAGE DeriveDataTypeable         #-} {-# LANGUAGE DeriveGeneric              #-}-#ifdef DERIVE_JSON_VIA_TH {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TemplateHaskell            #-}-#endif+{-# LANGUAGE OverloadedStrings          #-} {- |    Module      : Text.Pandoc.Extensions    Copyright   : Copyright (C) 2012-2019 John MacFarlane@@ -26,6 +25,7 @@                               , enableExtension                               , disableExtension                               , getDefaultExtensions+                              , getAllExtensions                               , pandocExtensions                               , plainExtensions                               , strictExtensions@@ -36,17 +36,12 @@ import Prelude import Data.Bits (clearBit, setBit, testBit, (.|.)) import Data.Data (Data)+import qualified Data.Text as T import Data.Typeable (Typeable) import GHC.Generics (Generic) import Safe (readMay) import Text.Parsec--#ifdef DERIVE_JSON_VIA_TH import Data.Aeson.TH (deriveJSON, defaultOptions)-#else-import Data.Aeson (FromJSON (..), ToJSON (..),-                   defaultOptions, genericToEncoding)-#endif  newtype Extensions = Extensions Integer   deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)@@ -132,6 +127,7 @@     | Ext_multiline_tables    -- ^ Pandoc-style multiline tables     | Ext_native_divs             -- ^ Use Div blocks for contents of <div> tags     | Ext_native_spans            -- ^ Use Span inlines for contents of <span>+    | Ext_native_numbering    -- ^ Use output format's native numbering for figures and tables     | Ext_ntb                 -- ^ ConTeXt Natural Tables     | Ext_old_dashes          -- ^ -- = em, - before number = en     | Ext_pandoc_title_block  -- ^ Pandoc title block@@ -155,6 +151,7 @@     | Ext_tex_math_double_backslash  -- ^ TeX math btw \\(..\\) \\[..\\]     | Ext_tex_math_single_backslash  -- ^ TeX math btw \(..\) \[..\]     | Ext_yaml_metadata_block -- ^ YAML metadata block+    | Ext_gutenberg           -- ^ Use Project Gutenberg conventions for plain     deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)  -- | Extensions to be used with pandoc-flavored markdown.@@ -227,7 +224,7 @@   , Ext_strikeout   ] --- | Extensions to be used with github-flavored markdown.+-- | Extensions to be used with PHP Markdown Extra. phpMarkdownExtraExtensions :: Extensions phpMarkdownExtraExtensions = extensionsFromList   [ Ext_footnotes@@ -309,13 +306,13 @@   ]  -- | Default extensions from format-describing string.-getDefaultExtensions :: String -> Extensions-getDefaultExtensions "markdown_strict" = strictExtensions+getDefaultExtensions :: T.Text -> Extensions+getDefaultExtensions "markdown_strict"   = strictExtensions getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions-getDefaultExtensions "markdown_mmd" = multimarkdownExtensions-getDefaultExtensions "markdown_github" = githubMarkdownExtensions-getDefaultExtensions "markdown"        = pandocExtensions-getDefaultExtensions "ipynb"           =+getDefaultExtensions "markdown_mmd"      = multimarkdownExtensions+getDefaultExtensions "markdown_github"   = githubMarkdownExtensions+getDefaultExtensions "markdown"          = pandocExtensions+getDefaultExtensions "ipynb"             =   extensionsFromList     [ Ext_all_symbols_escapable     , Ext_pipe_tables@@ -377,16 +374,150 @@ getDefaultExtensions _                 = extensionsFromList                                           [Ext_auto_identifiers] --- | Parse a format-specifying string into a markup format and a function that--- takes Extensions and enables and disables extensions as defined in the format--- spec.-parseFormatSpec :: String-                -> Either ParseError (String, Extensions -> Extensions)+allMarkdownExtensions :: Extensions+allMarkdownExtensions =+  pandocExtensions <>+    extensionsFromList+     [ Ext_old_dashes+     , Ext_angle_brackets_escapable+     , Ext_lists_without_preceding_blankline+     , Ext_four_space_rule+     , Ext_spaced_reference_links+     , Ext_hard_line_breaks+     , Ext_ignore_line_breaks+     , Ext_east_asian_line_breaks+     , Ext_emoji+     , Ext_tex_math_single_backslash+     , Ext_tex_math_double_backslash+     , Ext_markdown_attribute+     , Ext_mmd_title_block+     , Ext_abbreviations+     , Ext_autolink_bare_uris+     , Ext_mmd_link_attributes+     , Ext_mmd_header_identifiers+     , Ext_compact_definition_lists+     , Ext_gutenberg+     , Ext_smart+     , Ext_literate_haskell+     ]+++-- | Get all valid extensions for a format. This is used+-- mainly in checking format specifications for validity.+getAllExtensions :: T.Text -> Extensions+getAllExtensions f = universalExtensions <> getAll f+ where+  autoIdExtensions           = extensionsFromList+    [ Ext_auto_identifiers+    , Ext_gfm_auto_identifiers+    , Ext_ascii_identifiers+    ]+  universalExtensions        = extensionsFromList+    [ Ext_east_asian_line_breaks ]+  getAll "markdown_strict"   = allMarkdownExtensions+  getAll "markdown_phpextra" = allMarkdownExtensions+  getAll "markdown_mmd"      = allMarkdownExtensions+  getAll "markdown_github"   = allMarkdownExtensions+  getAll "markdown"          = allMarkdownExtensions+  getAll "ipynb"             = allMarkdownExtensions+  getAll "docx"            = extensionsFromList+    [ Ext_empty_paragraphs+    , Ext_styles+    ]+  getAll "opendocument"    = extensionsFromList+    [ Ext_empty_paragraphs+    , Ext_native_numbering+    ]+  getAll "odt"             = getAll "opendocument" <> autoIdExtensions+  getAll "muse"            = autoIdExtensions <>+    extensionsFromList+    [ Ext_amuse ]+  getAll "asciidoc"        = autoIdExtensions+  getAll "plain"           = allMarkdownExtensions+  getAll "gfm"             = githubMarkdownExtensions <>+    autoIdExtensions <>+    extensionsFromList+    [ Ext_raw_html+    , Ext_raw_tex            -- only supported in writer (for math)+    , Ext_hard_line_breaks+    , Ext_smart+    ]+  getAll "commonmark"      = getAll "gfm"+  getAll "org"             = autoIdExtensions <>+    extensionsFromList+    [ Ext_citations+    , Ext_smart+    ]+  getAll "html"            = autoIdExtensions <>+    extensionsFromList+    [ Ext_native_divs+    , Ext_line_blocks+    , Ext_native_spans+    , Ext_empty_paragraphs+    , Ext_raw_html+    , Ext_raw_tex+    , Ext_task_lists+    , Ext_tex_math_dollars+    , Ext_tex_math_single_backslash+    , Ext_tex_math_double_backslash+    , Ext_literate_haskell+    , Ext_epub_html_exts+    , Ext_smart+    ]+  getAll "html4"           = getAll "html"+  getAll "html5"           = getAll "html"+  getAll "epub"            = getAll "html"+  getAll "epub2"           = getAll "epub"+  getAll "epub3"           = getAll "epub"+  getAll "latex"           = autoIdExtensions <>+    extensionsFromList+    [ Ext_smart+    , Ext_latex_macros+    , Ext_raw_tex+    , Ext_task_lists+    , Ext_literate_haskell+    ]+  getAll "beamer"          = getAll "latex"+  getAll "context"         = autoIdExtensions <>+    extensionsFromList+    [ Ext_smart+    , Ext_raw_tex+    , Ext_ntb+    ]+  getAll "textile"         = autoIdExtensions <>+    extensionsFromList+    [ Ext_old_dashes+    , Ext_smart+    , Ext_raw_tex+    ]+  getAll "opml"            = allMarkdownExtensions -- affects notes+  getAll "twiki"           = autoIdExtensions <>+    extensionsFromList+    [ Ext_smart ]+  getAll "vimwiki"         = autoIdExtensions+  getAll "dokuwiki"        = autoIdExtensions+  getAll "tikiwiki"        = autoIdExtensions+  getAll "rst"             = autoIdExtensions <>+    extensionsFromList+    [ Ext_smart+    , Ext_literate_haskell+    ]+  getAll "mediawiki"       = autoIdExtensions <>+    extensionsFromList+    [ Ext_smart ]+  getAll _                 = mempty+++-- | Parse a format-specifying string into a markup format,+-- a set of extensions to enable, and a set of extensions to disable.+parseFormatSpec :: T.Text+                -> Either ParseError (T.Text, [Extension], [Extension]) parseFormatSpec = parse formatSpec ""   where formatSpec = do           name <- formatName-          extMods <- many extMod-          return (name, \x -> foldl (flip ($)) x extMods)+          (extsToEnable, extsToDisable) <- foldl (flip ($)) ([],[]) <$>+                                             many extMod+          return (T.pack name, reverse extsToEnable, reverse extsToDisable)         formatName = many1 $ noneOf "-+"         extMod = do           polarity <- oneOf "-+"@@ -395,20 +526,12 @@                        Just n  -> return n                        Nothing                          | name == "lhs" -> return Ext_literate_haskell-                         | otherwise -> fail $ "Unknown extension: " ++ name-          return $ case polarity of-                        '-' -> disableExtension ext-                        _   -> enableExtension ext+                         | otherwise -> Prelude.fail $+                                          "Unknown extension: " ++ name+          return $ \(extsToEnable, extsToDisable) ->+                    case polarity of+                        '+' -> (ext : extsToEnable, extsToDisable)+                        _   -> (extsToEnable, ext : extsToDisable) -#ifdef DERIVE_JSON_VIA_TH $(deriveJSON defaultOptions ''Extension) $(deriveJSON defaultOptions ''Extensions)-#else-instance ToJSON Extension where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON Extension--instance ToJSON Extensions where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON Extensions-#endif
src/Text/Pandoc/Filter.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE CPP               #-} {-# LANGUAGE DeriveGeneric     #-} {-# LANGUAGE NoImplicitPrelude #-}-#ifdef DERIVE_JSON_VIA_TH {-# LANGUAGE TemplateHaskell   #-}-#endif+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Filter    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -21,13 +20,7 @@   ) where  import Prelude-#ifdef DERIVE_JSON_VIA_TH import Data.Aeson.TH (deriveJSON, defaultOptions)-#else-import Data.Aeson (FromJSON (..), ToJSON (..),-                   defaultOptions, genericToEncoding)-#endif-import Data.Foldable (foldrM) import GHC.Generics (Generic) import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition (Pandoc)@@ -35,12 +28,33 @@ import qualified Text.Pandoc.Filter.JSON as JSONFilter import qualified Text.Pandoc.Filter.Lua as LuaFilter import qualified Text.Pandoc.Filter.Path as Path+import Data.YAML+import qualified Data.Text as T+import System.FilePath (takeExtension)+import Control.Applicative ((<|>))+import Control.Monad (foldM)  -- | Type of filter and path to filter file. data Filter = LuaFilter FilePath             | JSONFilter FilePath             deriving (Show, Generic) +instance FromYAML Filter where+ parseYAML node =+  (withMap "Filter" $ \m -> do+    ty <- m .: "type"+    fp <- m .: "path"+    case ty of+      "lua"  -> return $ LuaFilter $ T.unpack fp+      "json" -> return $ JSONFilter $ T.unpack fp+      _      -> fail $ "Unknown filter type " ++ show (ty :: T.Text)) node+  <|>+  (withStr "Filter" $ \t -> do+    let fp = T.unpack t+    case takeExtension fp of+      ".lua"  -> return $ LuaFilter fp+      _       -> return $ JSONFilter fp) node+ -- | Modify the given document using a filter. applyFilters :: ReaderOptions              -> [Filter]@@ -49,20 +63,14 @@              -> PandocIO Pandoc applyFilters ropts filters args d = do   expandedFilters <- mapM expandFilterPath filters-  foldrM ($) d $ map applyFilter expandedFilters+  foldM applyFilter d expandedFilters  where-  applyFilter (JSONFilter f) = JSONFilter.apply ropts args f-  applyFilter (LuaFilter f)  = LuaFilter.apply ropts args f+  applyFilter doc (JSONFilter f) = JSONFilter.apply ropts args f doc+  applyFilter doc (LuaFilter f)  = LuaFilter.apply ropts args f doc  -- | Expand paths of filters, searching the data directory. expandFilterPath :: Filter -> PandocIO Filter expandFilterPath (LuaFilter fp) = LuaFilter <$> Path.expandFilterPath fp expandFilterPath (JSONFilter fp) = JSONFilter <$> Path.expandFilterPath fp -#ifdef DERIVE_JSON_VIA_TH $(deriveJSON defaultOptions ''Filter)-#else-instance ToJSON Filter where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON Filter-#endif
src/Text/Pandoc/Filter/JSON.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Filter    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -18,6 +19,7 @@ import Data.Aeson (eitherDecode', encode) import Data.Char (toLower) import Data.Maybe (isNothing)+import qualified Data.Text as T import System.Directory (executable, doesFileExist, findExecutable,                          getPermissions) import System.Environment (getEnvironment)@@ -28,7 +30,7 @@ import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Options (ReaderOptions) import Text.Pandoc.Process (pipeProcess)-import Text.Pandoc.Shared (pandocVersion)+import Text.Pandoc.Shared (pandocVersion, tshow) import qualified Control.Exception as E import qualified Text.Pandoc.UTF8 as UTF8 @@ -61,18 +63,20 @@   unless (exists && isExecutable) $ do     mbExe <- findExecutable f'     when (isNothing mbExe) $-      E.throwIO $ PandocFilterError f ("Could not find executable " ++ f')+      E.throwIO $ PandocFilterError fText (T.pack $ "Could not find executable " <> f')   env <- getEnvironment   let env' = Just-           ( ("PANDOC_VERSION", pandocVersion)+           ( ("PANDOC_VERSION", T.unpack pandocVersion)            : ("PANDOC_READER_OPTIONS", UTF8.toStringLazy (encode ropts))            : env )   (exitcode, outbs) <- E.handle filterException $                               pipeProcess env' f' args'' $ encode d   case exitcode of-       ExitSuccess    -> either (E.throwIO . PandocFilterError f)+       ExitSuccess    -> either (E.throwIO . PandocFilterError fText . T.pack)                                    return $ eitherDecode' outbs-       ExitFailure ec -> E.throwIO $ PandocFilterError f-                           ("Filter returned error status " ++ show ec)- where filterException :: E.SomeException -> IO a-       filterException e = E.throwIO $ PandocFilterError f (show e)+       ExitFailure ec -> E.throwIO $ PandocFilterError fText+                           ("Filter returned error status " <> tshow ec)+ where fText = T.pack f++       filterException :: E.SomeException -> IO a+       filterException e = E.throwIO $ PandocFilterError fText $ tshow e
src/Text/Pandoc/Filter/Lua.hs view
@@ -15,6 +15,7 @@ import Prelude import Control.Exception (throw) import Control.Monad ((>=>))+import qualified Data.Text as T import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Error (PandocError (PandocFilterError))@@ -35,7 +36,7 @@                  (x:_) -> x                  _     -> error "Format not supplied for Lua filter"   runLua >=> forceResult fp $ do-    setGlobals [ FORMAT format+    setGlobals [ FORMAT $ T.pack format                , PANDOC_READER_OPTIONS ropts                , PANDOC_SCRIPT_FILE fp                ]@@ -44,4 +45,4 @@ forceResult :: FilePath -> Either LuaException Pandoc -> PandocIO Pandoc forceResult fp eitherResult = case eitherResult of   Right x               -> return x-  Left (LuaException s) -> throw (PandocFilterError fp s)+  Left (LuaException s) -> throw (PandocFilterError (T.pack fp) s)
src/Text/Pandoc/Highlighting.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Highlighting    Copyright   : Copyright (C) 2008-2019 John MacFarlane@@ -35,7 +36,6 @@                                 ) where import Prelude import Control.Monad-import Data.Char (toLower) import qualified Data.Map as M import Data.Maybe (fromMaybe) import qualified Data.Text as T@@ -43,7 +43,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Shared (safeRead) -highlightingStyles :: [(String, Style)]+highlightingStyles :: [(T.Text, Style)] highlightingStyles =   [("pygments", pygments),    ("tango", tango),@@ -54,18 +54,18 @@    ("breezedark", breezeDark),    ("haddock", haddock)] -languages :: [String]-languages = [T.unpack (T.toLower (sName s)) | s <- M.elems defaultSyntaxMap]+languages :: [T.Text]+languages = [T.toLower (sName s) | s <- M.elems defaultSyntaxMap] -languagesByExtension :: String -> [String]+languagesByExtension :: T.Text -> [T.Text] languagesByExtension ext =-  [T.unpack (T.toLower (sName s)) | s <- syntaxesByExtension defaultSyntaxMap ext]+  [T.toLower (sName s) | s <- syntaxesByExtension defaultSyntaxMap (T.unpack ext)]  highlight :: SyntaxMap           -> (FormatOptions -> [SourceLine] -> a) -- ^ Formatter           -> Attr   -- ^ Attributes of the CodeBlock-          -> String -- ^ Raw contents of the CodeBlock-          -> Either String a+          -> T.Text -- ^ Raw contents of the CodeBlock+          -> Either T.Text a highlight syntaxmap formatter (ident, classes, keyvals) rawCode =   let firstNum = fromMaybe 1 (safeRead (fromMaybe "1" $ lookup "startFrom" keyvals))       fmtOpts = defaultFormatOpts{@@ -74,38 +74,36 @@                         ["line-anchors", "lineAnchors"]) classes,                   numberLines = any (`elem`                         ["number","numberLines", "number-lines"]) classes,-                  lineIdPrefix = if null ident+                  lineIdPrefix = if T.null ident                                     then mempty-                                    else T.pack (ident ++ "-") }+                                    else ident <> "-" }       tokenizeOpts = TokenizerConfig{ syntaxMap = syntaxmap                                     , traceOutput = False }-      classes' = map T.pack classes-      rawCode' = T.pack rawCode-  in  case msum (map (`lookupSyntax` syntaxmap) classes') of+  in  case msum (map (`lookupSyntax` syntaxmap) classes) of             Nothing               | numberLines fmtOpts -> Right                               $ formatter fmtOpts{ codeClasses = [],-                                                   containerClasses = classes' }+                                                   containerClasses = classes }                               $ map (\ln -> [(NormalTok, ln)])-                              $ T.lines rawCode'+                              $ T.lines rawCode               | otherwise  -> Left ""-            Just syntax  ->+            Just syntax  -> either (Left . T.pack) Right $               formatter fmtOpts{ codeClasses =                                    [T.toLower (sShortname syntax)],-                                  containerClasses = classes' } <$>-                tokenize tokenizeOpts syntax rawCode'+                                  containerClasses = classes } <$>+                tokenize tokenizeOpts syntax rawCode  -- Functions for correlating latex listings package's language names -- with skylighting language names: -langToListingsMap :: M.Map String String+langToListingsMap :: M.Map T.Text T.Text langToListingsMap = M.fromList langsList -listingsToLangMap :: M.Map String String+listingsToLangMap :: M.Map T.Text T.Text listingsToLangMap = M.fromList $ map switch langsList   where switch (a,b) = (b,a) -langsList :: [(String, String)]+langsList :: [(T.Text, T.Text)] langsList =   [("abap","ABAP"),   ("acm","ACM"),@@ -121,6 +119,8 @@   ("monobasic","Basic"),   ("purebasic","Basic"),   ("c","C"),+  ("cs","C"),+  ("objectivec","C"),   ("cpp","C++"),   ("c++","C++"),   ("ocaml","Caml"),@@ -132,7 +132,9 @@   ("comsol","Comsol"),   ("csh","csh"),   ("delphi","Delphi"),+  ("eiffel","Eiffel"),   ("elan","Elan"),+  ("elisp","elisp"),   ("erlang","erlang"),   ("euphoria","Euphoria"),   ("fortran","Fortran"),@@ -169,6 +171,7 @@   ("oberon2","Oberon-2"),   ("ocl","OCL"),   ("octave","Octave"),+  ("oorexx","OORexx"),   ("oz","Oz"),   ("pascal","Pascal"),   ("perl","Perl"),@@ -195,6 +198,7 @@   ("simula","Simula"),   ("sparql","SPARQL"),   ("sql","SQL"),+  ("swift","Swift"),   ("tcl","tcl"),   ("tex","TeX"),   ("latex","TeX"),@@ -206,9 +210,9 @@   ("xslt","XSLT")]  -- | Determine listings language name from skylighting language name.-toListingsLanguage :: String -> Maybe String-toListingsLanguage lang = M.lookup (map toLower lang) langToListingsMap+toListingsLanguage :: T.Text -> Maybe T.Text+toListingsLanguage lang = M.lookup (T.toLower lang) langToListingsMap  -- | Determine skylighting language name from listings language name.-fromListingsLanguage :: String -> Maybe String+fromListingsLanguage :: T.Text -> Maybe T.Text fromListingsLanguage lang = M.lookup lang listingsToLangMap
src/Text/Pandoc/ImageSize.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-}+{-# LANGUAGE ViewPatterns      #-} {-# OPTIONS_GHC -fno-warn-type-defaults #-} {- | Module      : Text.Pandoc.ImageSize@@ -49,6 +50,8 @@ import qualified Text.Pandoc.UTF8 as UTF8 import qualified Text.XML.Light as Xml import qualified Data.Map as M+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE import Control.Monad.Except import Control.Applicative import Data.Maybe (fromMaybe)@@ -72,12 +75,12 @@                deriving Eq  instance Show Dimension where-  show (Pixel a)      = show   a ++ "px"-  show (Centimeter a) = showFl a ++ "cm"-  show (Millimeter a) = showFl a ++ "mm"-  show (Inch a)       = showFl a ++ "in"-  show (Percent a)    = show   a ++ "%"-  show (Em a)         = showFl a ++ "em"+  show (Pixel a)      = show a              ++ "px"+  show (Centimeter a) = T.unpack (showFl a) ++ "cm"+  show (Millimeter a) = T.unpack (showFl a) ++ "mm"+  show (Inch a)       = T.unpack (showFl a) ++ "in"+  show (Percent a)    = show a              ++ "%"+  show (Em a)         = T.unpack (showFl a) ++ "em"  data ImageSize = ImageSize{                      pxX   :: Integer@@ -88,14 +91,13 @@ instance Default ImageSize where   def = ImageSize 300 200 72 72 -showFl :: (RealFloat a) => a -> String-showFl a = removeExtra0s $ showFFloat (Just 5) a ""+showFl :: (RealFloat a) => a -> T.Text+showFl a = removeExtra0s $ T.pack $ showFFloat (Just 5) a "" -removeExtra0s :: String -> String-removeExtra0s s =-  case dropWhile (=='0') $ reverse s of-       '.':xs -> reverse xs-       xs     -> reverse xs+removeExtra0s :: T.Text -> T.Text+removeExtra0s s = case T.dropWhileEnd (=='0') s of+  (T.unsnoc -> Just (xs, '.')) -> xs+  xs                           -> xs  imageType :: ByteString -> Maybe ImageType imageType img = case B.take 4 img of@@ -119,7 +121,7 @@ findSvgTag :: ByteString -> Bool findSvgTag img = "<svg" `B.isInfixOf` img || "<SVG" `B.isInfixOf` img -imageSize :: WriterOptions -> ByteString -> Either String ImageSize+imageSize :: WriterOptions -> ByteString -> Either T.Text ImageSize imageSize opts img =   case imageType img of        Just Png  -> mbToEither "could not determine PNG size" $ pngSize img@@ -194,22 +196,22 @@   where     dpi = fromIntegral $ writerDpi opts --- | Convert a Dimension to a String denoting its equivalent in inches, for example "2.00000".+-- | Convert a Dimension to Text denoting its equivalent in inches, for example "2.00000". -- Note: Dimensions in percentages are converted to the empty string.-showInInch :: WriterOptions -> Dimension -> String+showInInch :: WriterOptions -> Dimension -> T.Text showInInch _ (Percent _) = "" showInInch opts dim = showFl $ inInch opts dim --- | Convert a Dimension to a String denoting its equivalent in pixels, for example "600".+-- | Convert a Dimension to Text denoting its equivalent in pixels, for example "600". -- Note: Dimensions in percentages are converted to the empty string.-showInPixel :: WriterOptions -> Dimension -> String+showInPixel :: WriterOptions -> Dimension -> T.Text showInPixel _ (Percent _) = ""-showInPixel opts dim = show $ inPixel opts dim+showInPixel opts dim = T.pack $ show $ inPixel opts dim  -- | Maybe split a string into a leading number and trailing unit, e.g. "3cm" to Just (3.0, "cm")-numUnit :: String -> Maybe (Double, String)+numUnit :: T.Text -> Maybe (Double, T.Text) numUnit s =-  let (nums, unit) = span (\c -> isDigit c || ('.'==c)) s+  let (nums, unit) = T.span (\c -> isDigit c || ('.'==c)) s   in  case safeRead nums of         Just n  -> Just (n, unit)         Nothing -> Nothing@@ -235,7 +237,7 @@   where     extractDim key = lookup key kvs >>= lengthToDim -lengthToDim :: String -> Maybe Dimension+lengthToDim :: T.Text -> Maybe Dimension lengthToDim s = numUnit s >>= uncurry toDim   where     toDim a "cm"   = Just $ Centimeter a@@ -258,8 +260,8 @@        []    -> mzero        (x:_) -> case B.words x of                      [_, _, _, ux, uy] -> do-                        ux' <- safeRead $ B.unpack ux-                        uy' <- safeRead $ B.unpack uy+                        ux' <- safeRead $ TE.decodeUtf8 ux+                        uy' <- safeRead $ TE.decodeUtf8 uy                         return ImageSize{                             pxX  = ux'                           , pxY  = uy'@@ -284,7 +286,7 @@       [x1,y1,x2,y2] <- A.count 4 $ do         A.skipSpace         raw <- A.many1 $ A.satisfy (\c -> isDigit c || c == '.')-        case safeRead raw of+        case safeRead $ T.pack raw of           Just (r :: Double) -> return $ floor r           Nothing            -> mzero       A.skipSpace@@ -345,7 +347,7 @@   doc <- Xml.parseXMLDoc $ UTF8.toString img   let dpi = fromIntegral $ writerDpi opts   let dirToInt dir = do-        dim <- Xml.findAttrBy (== Xml.QName dir Nothing Nothing) doc >>= lengthToDim+        dim <- Xml.findAttrBy (== Xml.QName dir Nothing Nothing) doc >>= lengthToDim . T.pack         return $ inPixel opts dim   w <- dirToInt "width"   h <- dirToInt "height"@@ -388,7 +390,7 @@       Right (_, _, size) -> Just size  -jpegSize :: ByteString -> Either String ImageSize+jpegSize :: ByteString -> Either T.Text ImageSize jpegSize img =   let (hdr, rest) = B.splitAt 4 img   in if B.length rest < 14@@ -398,7 +400,7 @@                "\xff\xd8\xff\xe1" -> exifSize rest                _                  -> Left "unable to determine JPEG size" -jfifSize :: ByteString -> Either String ImageSize+jfifSize :: ByteString -> Either T.Text ImageSize jfifSize rest =   case map fromIntegral $ unpack $ B.take 5 $ B.drop 9 rest of     [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] ->@@ -416,7 +418,7 @@                                         , dpiY = dpiy }     _ -> Left "unable to determine JFIF size" -findJfifSize :: ByteString -> Either String (Integer,Integer)+findJfifSize :: ByteString -> Either T.Text (Integer,Integer) findJfifSize bs =   let bs' = B.dropWhile (=='\xff') $ B.dropWhile (/='\xff') bs   in case B.uncons bs' of@@ -433,19 +435,18 @@               _       -> Left "JFIF parse error"        Nothing -> Left "Did not find JFIF length record" -runGet' :: Get (Either String a) -> BL.ByteString -> Either String a+runGet' :: Get (Either T.Text a) -> BL.ByteString -> Either T.Text a runGet' p bl = #if MIN_VERSION_binary(0,7,0)   case runGetOrFail p bl of-       Left (_,_,msg) -> Left msg+       Left (_,_,msg) -> Left $ T.pack msg        Right (_,_,x)  -> x #else   runGet p bl #endif --exifSize :: ByteString -> Either String ImageSize-exifSize bs =runGet' header bl+exifSize :: ByteString -> Either T.Text ImageSize+exifSize bs = runGet' header bl   where bl = BL.fromChunks [bs]         header = runExceptT $ exifHeader bl -- NOTE:  It would be nicer to do@@ -454,7 +455,7 @@ -- be parsed.  But we only get an Alternative instance for Get in binary 0.6, -- and binary 0.5 ships with ghc 7.6. -exifHeader :: BL.ByteString -> ExceptT String Get ImageSize+exifHeader :: BL.ByteString -> ExceptT T.Text Get ImageSize exifHeader hdr = do   _app1DataSize <- lift getWord16be   exifHdr <- lift getWord32be@@ -479,7 +480,7 @@   ifdOffset <- lift getWord32   lift $ skip (fromIntegral ifdOffset - 8) -- skip to IDF   numentries <- lift  getWord16-  let ifdEntry :: ExceptT String Get (TagType, DataFormat)+  let ifdEntry :: ExceptT T.Text Get (TagType, DataFormat)       ifdEntry = do        tag <- fromMaybe UnknownTagType . flip M.lookup tagTypeTable                 <$> lift getWord16@@ -502,7 +503,7 @@                   10 -> return (SignedRational <$> getRational, 8)                   11 -> return (SingleFloat <$> getWord32 {- TODO -}, 4)                   12 -> return (DoubleFloat <$> getWord64 {- TODO -}, 8)-                  _  -> throwError $ "Unknown data format " ++ show dataFormat+                  _  -> throwError $ "Unknown data format " <> T.pack (show dataFormat)        let totalBytes = fromIntegral $ numComponents * bytesPerComponent        payload <- if totalBytes <= 4 -- data is right here                      then lift $ fmt <* skip (4 - totalBytes)
src/Text/Pandoc/Logging.hs view
@@ -25,12 +25,12 @@  import Prelude import Control.Monad (mzero)+import Data.YAML (withStr, FromYAML(..)) import Data.Aeson import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',                                  keyOrder) import qualified Data.ByteString.Lazy as BL import Data.Data (Data, toConstr)-import Data.List (isSuffixOf) import qualified Data.Text as Text import Data.Typeable (Typeable) import GHC.Generics (Generic)@@ -52,42 +52,52 @@          _         -> mzero   parseJSON _      =  mzero +instance FromYAML Verbosity where+  parseYAML = withStr "Verbosity" $ \t ->+    case t of+         "ERROR"   -> return ERROR+         "WARNING" -> return WARNING+         "INFO"    -> return INFO+         _         -> mzero+ data LogMessage =-    SkippedContent String SourcePos-  | IgnoredElement String-  | CouldNotParseYamlMetadata String SourcePos-  | DuplicateLinkReference String SourcePos-  | DuplicateNoteReference String SourcePos-  | NoteDefinedButNotUsed String SourcePos-  | DuplicateIdentifier String SourcePos-  | ReferenceNotFound String SourcePos-  | CircularReference String SourcePos-  | UndefinedToggle String SourcePos-  | ParsingUnescaped String SourcePos-  | CouldNotLoadIncludeFile String SourcePos-  | MacroAlreadyDefined String SourcePos+    SkippedContent Text.Text SourcePos+  | IgnoredElement Text.Text+  | CouldNotParseYamlMetadata Text.Text SourcePos+  | DuplicateLinkReference Text.Text SourcePos+  | DuplicateNoteReference Text.Text SourcePos+  | NoteDefinedButNotUsed Text.Text SourcePos+  | DuplicateIdentifier Text.Text SourcePos+  | ReferenceNotFound Text.Text SourcePos+  | CircularReference Text.Text SourcePos+  | UndefinedToggle Text.Text SourcePos+  | ParsingUnescaped Text.Text SourcePos+  | CouldNotLoadIncludeFile Text.Text SourcePos+  | MacroAlreadyDefined Text.Text SourcePos   | InlineNotRendered Inline   | BlockNotRendered Block-  | DocxParserWarning String-  | IgnoredIOError String-  | CouldNotFetchResource String String-  | CouldNotDetermineImageSize String String-  | CouldNotConvertImage String String-  | CouldNotDetermineMimeType String-  | CouldNotConvertTeXMath String String-  | CouldNotParseCSS String-  | Fetching String-  | Extracting String-  | NoTitleElement String+  | DocxParserWarning Text.Text+  | IgnoredIOError Text.Text+  | CouldNotFetchResource Text.Text Text.Text+  | CouldNotDetermineImageSize Text.Text Text.Text+  | CouldNotConvertImage Text.Text Text.Text+  | CouldNotDetermineMimeType Text.Text+  | CouldNotConvertTeXMath Text.Text Text.Text+  | CouldNotParseCSS Text.Text+  | Fetching Text.Text+  | Extracting Text.Text+  | NoTitleElement Text.Text   | NoLangSpecified-  | InvalidLang String-  | CouldNotHighlight String-  | MissingCharacter String-  | Deprecated String String-  | NoTranslation String-  | CouldNotLoadTranslations String String-  | UnexpectedXmlElement String String-  | UnknownOrgExportOption String+  | InvalidLang Text.Text+  | CouldNotHighlight Text.Text+  | MissingCharacter Text.Text+  | Deprecated Text.Text Text.Text+  | NoTranslation Text.Text+  | CouldNotLoadTranslations Text.Text Text.Text+  | UnusualConversion Text.Text+  | UnexpectedXmlElement Text.Text Text.Text+  | UnknownOrgExportOption Text.Text+  | CouldNotDeduceFormat [Text.Text] Text.Text   deriving (Show, Eq, Data, Ord, Typeable, Generic)  instance ToJSON LogMessage where@@ -96,65 +106,65 @@     "type" .= toJSON (show $ toConstr x) :     case x of       SkippedContent s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= sourceLine pos,             "column" .= sourceColumn pos]       IgnoredElement s ->-           ["contents" .= Text.pack s]+           ["contents" .= s]       CouldNotParseYamlMetadata s pos ->-           ["message" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["message" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       DuplicateLinkReference s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       NoteDefinedButNotUsed s pos ->-           ["key" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["key" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       DuplicateNoteReference s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       DuplicateIdentifier s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       ReferenceNotFound s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       CircularReference s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       UndefinedToggle s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       ParsingUnescaped s pos ->-           ["contents" .= Text.pack s,-            "source" .= Text.pack (sourceName pos),+           ["contents" .= s,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       CouldNotLoadIncludeFile fp pos ->-           ["path" .= Text.pack fp,-            "source" .= Text.pack (sourceName pos),+           ["path" .= fp,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       MacroAlreadyDefined name pos ->-           ["name" .= Text.pack name,-            "source" .= Text.pack (sourceName pos),+           ["name" .= name,+            "source" .= sourceName pos,             "line" .= toJSON (sourceLine pos),             "column" .= toJSON (sourceColumn pos)]       InlineNotRendered il ->@@ -162,55 +172,60 @@       BlockNotRendered bl ->            ["contents" .= toJSON bl]       DocxParserWarning s ->-           ["contents" .= Text.pack s]+           ["contents" .= s]       IgnoredIOError s ->-           ["contents" .= Text.pack s]+           ["contents" .= s]       CouldNotFetchResource fp s ->-           ["path" .= Text.pack fp,-            "message" .= Text.pack s]+           ["path" .= fp,+            "message" .= s]       CouldNotDetermineImageSize fp s ->-           ["path" .= Text.pack fp,-            "message" .= Text.pack s]+           ["path" .= fp,+            "message" .= s]       CouldNotConvertImage fp s ->-           ["path" .= Text.pack fp,-            "message" .= Text.pack s]+           ["path" .= fp,+            "message" .= s]       CouldNotDetermineMimeType fp ->-           ["path" .= Text.pack fp]+           ["path" .= fp]       CouldNotConvertTeXMath s msg ->-           ["contents" .= Text.pack s,-            "message" .= Text.pack msg]+           ["contents" .= s,+            "message" .= msg]       CouldNotParseCSS msg ->-           ["message" .= Text.pack msg]+           ["message" .= msg]       Fetching fp ->-           ["path" .= Text.pack fp]+           ["path" .= fp]       Extracting fp ->-           ["path" .= Text.pack fp]+           ["path" .= fp]       NoTitleElement fallback ->-           ["fallback" .= Text.pack fallback]+           ["fallback" .= fallback]       NoLangSpecified -> []       InvalidLang s ->-           ["lang" .= Text.pack s]+           ["lang" .= s]       CouldNotHighlight msg ->-           ["message" .= Text.pack msg]+           ["message" .= msg]       MissingCharacter msg ->-           ["message" .= Text.pack msg]+           ["message" .= msg]       Deprecated thing msg ->-           ["thing" .= Text.pack thing,-            "message" .= Text.pack msg]+           ["thing" .= thing,+            "message" .= msg]       NoTranslation term ->-           ["term" .= Text.pack term]+           ["term" .= term]       CouldNotLoadTranslations lang msg ->-           ["lang" .= Text.pack lang,-            "message" .= Text.pack msg]+           ["lang" .= lang,+            "message" .= msg]+      UnusualConversion msg ->+           ["message" .= msg]       UnexpectedXmlElement element parent ->-           ["element" .= Text.pack element,-            "parent" .= Text.pack parent]+           ["element" .= element,+            "parent" .= parent]       UnknownOrgExportOption option ->-           ["option" .= Text.pack option]+           ["option" .= option]+      CouldNotDeduceFormat exts format ->+           ["extensions" .= exts+           ,"format" .= format]  -showPos :: SourcePos -> String-showPos pos = sn ++ "line " +++showPos :: SourcePos -> Text.Text+showPos pos = Text.pack $ sn ++ "line " ++      show (sourceLine pos) ++ " column " ++ show (sourceColumn pos)   where sn = if sourceName pos == "source" || sourceName pos == ""                 then ""@@ -222,132 +237,140 @@       keyOrder [ "type", "verbosity", "contents", "message", "path",                  "source", "line", "column" ] } ms -showLogMessage :: LogMessage -> String+showLogMessage :: LogMessage -> Text.Text showLogMessage msg =   case msg of        SkippedContent s pos ->-         "Skipped '" ++ s ++ "' at " ++ showPos pos+         "Skipped '" <> s <> "' at " <> showPos pos        IgnoredElement s ->-         "Ignored element " ++ s+         "Ignored element " <> s        CouldNotParseYamlMetadata s pos ->-         "Could not parse YAML metadata at " ++ showPos pos ++-           if null s then "" else ": " ++ s+         "Could not parse YAML metadata at " <> showPos pos <>+           if Text.null s then "" else ": " <> s        DuplicateLinkReference s pos ->-         "Duplicate link reference '" ++ s ++ "' at " ++ showPos pos+         "Duplicate link reference '" <> s <> "' at " <> showPos pos        DuplicateNoteReference s pos ->-         "Duplicate note reference '" ++ s ++ "' at " ++ showPos pos+         "Duplicate note reference '" <> s <> "' at " <> showPos pos        NoteDefinedButNotUsed s pos ->-         "Note with key '" ++ s ++ "' defined at " ++ showPos pos +++         "Note with key '" <> s <> "' defined at " <> showPos pos <>            " but not used."        DuplicateIdentifier s pos ->-         "Duplicate identifier '" ++ s ++ "' at " ++ showPos pos+         "Duplicate identifier '" <> s <> "' at " <> showPos pos        ReferenceNotFound s pos ->-         "Reference not found for '" ++ s ++ "' at " ++ showPos pos+         "Reference not found for '" <> s <> "' at " <> showPos pos        CircularReference s pos ->-         "Circular reference '" ++ s ++ "' at " ++ showPos pos+         "Circular reference '" <> s <> "' at " <> showPos pos        UndefinedToggle s pos ->-         "Undefined toggle '" ++ s ++ "' at " ++ showPos pos+         "Undefined toggle '" <> s <> "' at " <> showPos pos        ParsingUnescaped s pos ->-         "Parsing unescaped '" ++ s ++ "' at " ++ showPos pos+         "Parsing unescaped '" <> s <> "' at " <> showPos pos        CouldNotLoadIncludeFile fp pos ->-         "Could not load include file '" ++ fp ++ "' at " ++ showPos pos+         "Could not load include file '" <> fp <> "' at " <> showPos pos        MacroAlreadyDefined name pos ->-         "Macro '" ++ name ++ "' already defined, ignoring at " ++ showPos pos+         "Macro '" <> name <> "' already defined, ignoring at " <> showPos pos        InlineNotRendered il ->-         "Not rendering " ++ show il+         "Not rendering " <> Text.pack (show il)        BlockNotRendered bl ->-         "Not rendering " ++ show bl+         "Not rendering " <> Text.pack (show bl)        DocxParserWarning s ->-         "Docx parser warning: " ++ s+         "Docx parser warning: " <> s        IgnoredIOError s ->-         "IO Error (ignored): " ++ s+         "IO Error (ignored): " <> s        CouldNotFetchResource fp s ->-         "Could not fetch resource '" ++ fp ++ "'" ++-           if null s then "" else ": " ++ s+         "Could not fetch resource '" <> fp <> "'" <>+           if Text.null s then "" else ": " <> s        CouldNotDetermineImageSize fp s ->-         "Could not determine image size for '" ++ fp ++ "'" ++-           if null s then "" else ": " ++ s+         "Could not determine image size for '" <> fp <> "'" <>+           if Text.null s then "" else ": " <> s        CouldNotConvertImage fp s ->-         "Could not convert image '" ++ fp ++ "'" ++-           if null s then "" else ": " ++ s+         "Could not convert image '" <> fp <> "'" <>+           if Text.null s then "" else ": " <> s        CouldNotDetermineMimeType fp ->-         "Could not determine mime type for '" ++ fp ++ "'"+         "Could not determine mime type for '" <> fp <> "'"        CouldNotConvertTeXMath s m ->-         "Could not convert TeX math '" ++ s ++ "', rendering as TeX" ++-           if null m then "" else ':' : '\n' : m+         "Could not convert TeX math '" <> s <> "', rendering as TeX" <>+           if Text.null m then "" else ":\n" <> m        CouldNotParseCSS m ->-         "Could not parse CSS" ++ if null m then "" else ':' : '\n' : m+         "Could not parse CSS" <> if Text.null m then "" else ":\n" <> m        Fetching fp ->-         "Fetching " ++ fp ++ "..."+         "Fetching " <> fp <> "..."        Extracting fp ->-         "Extracting " ++ fp ++ "..."+         "Extracting " <> fp <> "..."        NoTitleElement fallback ->-         "This document format requires a nonempty <title> element.\n" ++-         "Please specify either 'title' or 'pagetitle' in the metadata,\n" ++-         "e.g. by using --metadata pagetitle=\"...\" on the command line.\n" ++-         "Falling back to '" ++ fallback ++ "'"+         "This document format requires a nonempty <title> element.\n" <>+         "Defaulting to '" <> fallback <> "' as the title.\n" <>+         "To specify a title, use 'title' in metadata or " <>+         "--metadata title=\"...\"."        NoLangSpecified ->-         "No value for 'lang' was specified in the metadata.\n" +++         "No value for 'lang' was specified in the metadata.\n" <>          "It is recommended that lang be specified for this format."        InvalidLang s ->-         "Invalid 'lang' value '" ++ s ++ "'.\n" +++         "Invalid 'lang' value '" <> s <> "'.\n" <>          "Use an IETF language tag like 'en-US'."        CouldNotHighlight m ->-         "Could not highlight code block:\n" ++ m+         "Could not highlight code block:\n" <> m        MissingCharacter m ->-         "Missing character: " ++ m+         "Missing character: " <> m        Deprecated t m ->-         "Deprecated: " ++ t ++-         if null m+         "Deprecated: " <> t <>+         if Text.null m             then ""-            else ". " ++ m+            else ". " <> m        NoTranslation t ->-         "The term " ++ t ++ " has no translation defined."+         "The term " <> t <> " has no translation defined."        CouldNotLoadTranslations lang m ->-         "Could not load translations for " ++ lang ++-           if null m then "" else '\n' : m+         "Could not load translations for " <> lang <>+           if Text.null m then "" else "\n" <> m+       UnusualConversion m ->+         "Unusual conversion: " <> m        UnexpectedXmlElement element parent ->-         "Unexpected XML element " ++ element ++ " in " ++ parent+         "Unexpected XML element " <> element <> " in " <> parent        UnknownOrgExportOption option ->-         "Ignoring unknown Org export option: " ++ option+         "Ignoring unknown Org export option: " <> option+       CouldNotDeduceFormat exts format ->+         "Could not deduce format from file extension " <>+         Text.intercalate " or " exts <> "\n" <>+         "Defaulting to " <> format -messageVerbosity:: LogMessage -> Verbosity+messageVerbosity :: LogMessage -> Verbosity messageVerbosity msg =   case msg of-       SkippedContent{}             -> INFO-       IgnoredElement{}             -> INFO-       CouldNotParseYamlMetadata{}  -> WARNING-       DuplicateLinkReference{}     -> WARNING-       DuplicateNoteReference{}     -> WARNING-       NoteDefinedButNotUsed{}      -> WARNING-       DuplicateIdentifier{}        -> WARNING-       ReferenceNotFound{}          -> WARNING-       CircularReference{}          -> WARNING-       UndefinedToggle{}            -> WARNING+       SkippedContent{}              -> INFO+       IgnoredElement{}              -> INFO+       CouldNotParseYamlMetadata{}   -> WARNING+       DuplicateLinkReference{}      -> WARNING+       DuplicateNoteReference{}      -> WARNING+       NoteDefinedButNotUsed{}       -> WARNING+       DuplicateIdentifier{}         -> WARNING+       ReferenceNotFound{}           -> WARNING+       CircularReference{}           -> WARNING+       UndefinedToggle{}             -> WARNING        CouldNotLoadIncludeFile f _-        | ".sty" `isSuffixOf` f     -> INFO-        | otherwise                 -> WARNING-       MacroAlreadyDefined{}        -> WARNING-       ParsingUnescaped{}           -> INFO-       InlineNotRendered{}          -> INFO-       BlockNotRendered{}           -> INFO-       DocxParserWarning{}          -> INFO-       IgnoredIOError{}             -> WARNING-       CouldNotFetchResource{}      -> WARNING-       CouldNotDetermineImageSize{} -> WARNING-       CouldNotConvertImage{}       -> WARNING-       CouldNotDetermineMimeType{}  -> WARNING-       CouldNotConvertTeXMath{}     -> WARNING-       CouldNotParseCSS{}           -> WARNING-       Fetching{}                   -> INFO-       Extracting{}                 -> INFO-       NoTitleElement{}             -> WARNING-       NoLangSpecified              -> INFO-       InvalidLang{}                -> WARNING-       CouldNotHighlight{}          -> WARNING-       MissingCharacter{}           -> WARNING-       Deprecated{}                 -> WARNING-       NoTranslation{}              -> WARNING-       CouldNotLoadTranslations{}   -> WARNING-       UnexpectedXmlElement {}      -> WARNING-       UnknownOrgExportOption {}    -> WARNING+        | ".sty" `Text.isSuffixOf` f -> INFO+        | otherwise                  -> WARNING+       MacroAlreadyDefined{}         -> WARNING+       ParsingUnescaped{}            -> INFO+       InlineNotRendered{}           -> INFO+       BlockNotRendered{}            -> INFO+       DocxParserWarning{}           -> INFO+       IgnoredIOError{}              -> WARNING+       CouldNotFetchResource{}       -> WARNING+       CouldNotDetermineImageSize{}  -> WARNING+       CouldNotConvertImage{}        -> WARNING+       CouldNotDetermineMimeType{}   -> WARNING+       CouldNotConvertTeXMath{}      -> WARNING+       CouldNotParseCSS{}            -> WARNING+       Fetching{}                    -> INFO+       Extracting{}                  -> INFO+       NoTitleElement{}              -> WARNING+       NoLangSpecified               -> INFO+       InvalidLang{}                 -> WARNING+       CouldNotHighlight{}           -> WARNING+       MissingCharacter{}            -> WARNING+       Deprecated{}                  -> WARNING+       NoTranslation{}               -> WARNING+       CouldNotLoadTranslations{}    -> WARNING+       UnusualConversion {}          -> WARNING+       UnexpectedXmlElement {}       -> WARNING+       UnknownOrgExportOption {}     -> WARNING+       CouldNotDeduceFormat{}        -> WARNING
src/Text/Pandoc/Lua/Filter.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE NoImplicitPrelude #-} {- | Module      : Text.Pandoc.Lua.Filter@@ -20,6 +20,7 @@                               , walkBlocks                               , blockElementNames                               , inlineElementNames+                              , module Text.Pandoc.Lua.Walk                               ) where import Prelude import Control.Monad (mplus, (>=>))@@ -31,7 +32,8 @@ import Foreign.Lua (Lua, Peekable, Pushable) import Text.Pandoc.Definition import Text.Pandoc.Lua.Marshaling ()-import Text.Pandoc.Walk (walkM, Walkable)+import Text.Pandoc.Lua.Walk (SingletonsList (..))+import Text.Pandoc.Walk (Walkable (walkM))  import qualified Data.Map.Strict as Map import qualified Foreign.Lua as Lua@@ -91,7 +93,10 @@ pushFilterFunction (LuaFilterFunction fnRef) =   Lua.getref Lua.registryindex fnRef -+-- | Fetch either a list of elements from the stack. If there is a single+-- element instead of a list, fetch that element as a singleton list. If the top+-- of the stack is nil, return the default element that was passed to this+-- function. If none of these apply, raise an error. elementOrList :: Peekable a => a -> Lua [a] elementOrList x = do   let topOfStack = Lua.stackTop@@ -115,6 +120,12 @@     Just fn -> runFilterFunction fn x *> elementOrList x     Nothing -> return [x] +-- | Apply filter on a sequence of AST elements.+runOnSequence :: (Data a, Peekable a, Pushable a)+              => LuaFilter -> SingletonsList a -> Lua (SingletonsList a)+runOnSequence lf (SingletonsList xs) =+  SingletonsList <$> mconcatMapM (tryFilter lf) xs+ -- | Push a value to the stack via a lua filter function. The filter function is -- called with given element as argument and is expected to return an element. -- Alternatively, the function can return nothing or nil, in which case the@@ -129,22 +140,26 @@ walkMWithLuaFilter f =   walkInlines f >=> walkBlocks f >=> walkMeta f >=> walkPandoc f -mconcatMapM :: (Monad m, Functor m) => (a -> m [a]) -> [a] -> m [a]+mconcatMapM :: (Monad m) => (a -> m [a]) -> [a] -> m [a] mconcatMapM f = fmap mconcat . mapM f  hasOneOf :: LuaFilter -> [String] -> Bool hasOneOf (LuaFilter fnMap) = any (\k -> Map.member k fnMap) -walkInlines :: Walkable [Inline] a => LuaFilter -> a -> Lua a-walkInlines f =-  if f `hasOneOf` inlineElementNames-     then walkM (mconcatMapM (tryFilter f :: Inline -> Lua [Inline]))+walkInlines :: Walkable (SingletonsList Inline) a => LuaFilter -> a -> Lua a+walkInlines lf =+  let f :: SingletonsList Inline -> Lua (SingletonsList Inline)+      f = runOnSequence lf+  in if lf `hasOneOf` inlineElementNames+     then walkM f      else return -walkBlocks :: Walkable [Block] a => LuaFilter -> a -> Lua a-walkBlocks f =-  if f `hasOneOf` blockElementNames-     then walkM (mconcatMapM (tryFilter f :: Block -> Lua [Block]))+walkBlocks :: Walkable (SingletonsList Block) a => LuaFilter -> a -> Lua a+walkBlocks lf =+  let f :: SingletonsList Block -> Lua (SingletonsList Block)+      f = runOnSequence lf+  in if lf `hasOneOf` blockElementNames+     then walkM f      else return  walkMeta :: LuaFilter -> Pandoc -> Lua Pandoc@@ -165,7 +180,7 @@ constructorsFor x = map show (dataTypeConstrs x)  inlineElementNames :: [String]-inlineElementNames = "Inline" : constructorsFor (dataTypeOf (Str []))+inlineElementNames = "Inline" : constructorsFor (dataTypeOf (Str mempty))  blockElementNames :: [String] blockElementNames = "Block" : constructorsFor (dataTypeOf (Para []))
src/Text/Pandoc/Lua/Global.hs view
@@ -27,11 +27,12 @@ import Text.Pandoc.Lua.Util (addFunction) import Text.Pandoc.Options (ReaderOptions) +import qualified Data.Text as Text import qualified Foreign.Lua as Lua  -- | Permissible global Lua variables. data Global =-    FORMAT String+    FORMAT Text.Text   | PANDOC_API_VERSION   | PANDOC_DOCUMENT Pandoc   | PANDOC_READER_OPTIONS ReaderOptions
src/Text/Pandoc/Lua/Init.hs view
@@ -28,13 +28,14 @@                                  installPandocPackageSearcher) import Text.Pandoc.Lua.Util (loadScriptFromDataDir) +import qualified Data.Text as Text import qualified Foreign.Lua as Lua import qualified Foreign.Lua.Module.Text as Lua import qualified Text.Pandoc.Definition as Pandoc import qualified Text.Pandoc.Lua.Module.Pandoc as ModulePandoc  -- | Lua error message-newtype LuaException = LuaException String deriving (Show)+newtype LuaException = LuaException Text.Text deriving (Show)  -- | Run the lua interpreter, using pandoc's default way of environment -- initialization.@@ -56,7 +57,7 @@     return (opResult, st)   liftIO $ setForeignEncoding enc   case res of-    Left (Lua.Exception msg) -> return $ Left (LuaException msg)+    Left (Lua.Exception msg) -> return $ Left (LuaException $ Text.pack msg)     Right (x, newState) -> do       putCommonState newState       return $ Right x
src/Text/Pandoc/Lua/Marshaling.hs view
@@ -14,4 +14,5 @@ import Text.Pandoc.Lua.Marshaling.AST () import Text.Pandoc.Lua.Marshaling.CommonState () import Text.Pandoc.Lua.Marshaling.ReaderOptions ()+import Text.Pandoc.Lua.Marshaling.Context () import Text.Pandoc.Lua.Marshaling.Version ()
src/Text/Pandoc/Lua/Marshaling/AST.hs view
@@ -14,17 +14,17 @@  Marshaling/unmarshaling instances for document AST elements. -}-module Text.Pandoc.Lua.Marshaling.AST () where+module Text.Pandoc.Lua.Marshaling.AST+  ( LuaAttr (..)+  , LuaListAttributes (..)+  ) where  import Prelude import Control.Applicative ((<|>)) import Foreign.Lua (Lua, Peekable, Pushable, StackIndex)-import Foreign.Lua.Userdata ( ensureUserdataMetatable, pushAnyWithMetatable-                            , metatableName) import Text.Pandoc.Definition import Text.Pandoc.Lua.Util (defineHowTo, pushViaConstructor) import Text.Pandoc.Lua.Marshaling.CommonState ()-import Text.Pandoc.Shared (Element (Blk, Sec))  import qualified Foreign.Lua as Lua import qualified Text.Pandoc.Lua.Util as LuaUtil@@ -282,31 +282,3 @@ instance Peekable LuaListAttributes where   peek = defineHowTo "get ListAttributes value" .          fmap LuaListAttributes . Lua.peek------- Hierarchical elements----instance Pushable Element where-  push (Blk blk) = Lua.push blk-  push sec = pushAnyWithMetatable pushElementMetatable sec-   where-    pushElementMetatable = ensureUserdataMetatable (metatableName sec) $-                           LuaUtil.addFunction "__index" indexElement--instance Peekable Element where-  peek idx = Lua.ltype idx >>= \case-    Lua.TypeUserdata -> Lua.peekAny idx-    _                -> Blk <$> Lua.peek idx--indexElement :: Element -> String -> Lua Lua.NumResults-indexElement = \case-  (Blk _) -> const (1 <$ Lua.pushnil) -- this shouldn't happen-  (Sec lvl num attr label contents) -> fmap (return 1) . \case-    "level"     -> Lua.push lvl-    "numbering" -> Lua.push num-    "attr"      -> Lua.push (LuaAttr attr)-    "label"     -> Lua.push label-    "contents"  -> Lua.push contents-    "tag"       -> Lua.push "Sec"-    "t"         -> Lua.push "Sec"-    _           -> Lua.pushnil
src/Text/Pandoc/Lua/Marshaling/CommonState.hs view
@@ -1,6 +1,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE LambdaCase           #-} {-# LANGUAGE NoImplicitPrelude    #-}+{-# LANGUAGE OverloadedStrings    #-} {- |    Module      : Text.Pandoc.Lua.Marshaling.CommonState    Copyright   : © 2012-2019 John MacFarlane@@ -23,6 +24,7 @@ import Text.Pandoc.Lua.Marshaling.AnyValue (AnyValue (..))  import qualified Data.Map as Map+import qualified Data.Text as Text import qualified Foreign.Lua as Lua import qualified Text.Pandoc.Lua.Util as LuaUtil @@ -46,7 +48,7 @@   Lua.TypeString -> 1 <$ (Lua.peek idx >>= pushField)   _ -> 1 <$ Lua.pushnil  where-  pushField :: String -> Lua ()+  pushField :: Text.Text -> Lua ()   pushField name = case lookup name commonStateFields of     Just pushValue -> pushValue st     Nothing -> Lua.pushnil@@ -71,7 +73,7 @@           (nextKey, pushValue):_ -> 2 <$ (Lua.push nextKey *> pushValue st)       _ -> 2 <$ (Lua.pushnil *> Lua.pushnil) -commonStateFields :: [(String, CommonState -> Lua ())]+commonStateFields :: [(Text.Text, CommonState -> Lua ())] commonStateFields =   [ ("input_files", Lua.push . stInputFiles)   , ("output_file", Lua.push . Lua.Optional . stOutputFile)@@ -98,5 +100,5 @@     pushLogMessageMetatable = ensureUserdataMetatable logMessageTypeName $       LuaUtil.addFunction "__tostring" tostringLogMessage -tostringLogMessage :: LogMessage -> Lua String+tostringLogMessage :: LogMessage -> Lua Text.Text tostringLogMessage = return . showLogMessage
+ src/Text/Pandoc/Lua/Marshaling/Context.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE NoImplicitPrelude    #-}+{-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE ScopedTypeVariables  #-}+{-# LANGUAGE LambdaCase           #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{- |+   Module      : Text.Pandoc.Lua.Marshaling.Context+   Copyright   : © 2012-2019 John MacFarlane+                 © 2017-2019 Albert Krewinkel+   License     : GNU GPL, version 2 or above++   Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>+   Stability   : alpha++Marshaling instance for doctemplates Context and its components.+-}+module Text.Pandoc.Lua.Marshaling.Context () where++import Prelude+import qualified Foreign.Lua as Lua+import Foreign.Lua (Pushable)+import Text.DocTemplates (Context(..), Val(..), TemplateTarget)+import Text.DocLayout (render)++instance (TemplateTarget a, Pushable a) => Pushable (Context a) where+  push (Context m) = Lua.push m++instance (TemplateTarget a, Pushable a) => Pushable (Val a) where+  push NullVal = Lua.push ()+  push (MapVal ctx) = Lua.push ctx+  push (ListVal xs) = Lua.push xs+  push (SimpleVal d) = Lua.push $ render Nothing d+
src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs view
@@ -25,6 +25,7 @@ import Text.Pandoc.Options (ReaderOptions (..), TrackChanges)  import qualified Data.Set as Set+import qualified Data.Text as Text import qualified Foreign.Lua as Lua import qualified Text.Pandoc.Lua.Util as LuaUtil @@ -44,9 +45,9 @@           (standalone            :: Bool)           (columns               :: Int)           (tabStop               :: Int)-          (indentedCodeClasses   :: [String])-          (abbreviations         :: Set.Set String)-          (defaultImageExtension :: String)+          (indentedCodeClasses   :: [Text.Text])+          (abbreviations         :: Set.Set Text.Text)+          (defaultImageExtension :: Text.Text)           (trackChanges          :: TrackChanges)           (stripComments         :: Bool)           = ro
src/Text/Pandoc/Lua/Module/MediaBag.hs view
@@ -15,7 +15,6 @@  import Prelude import Control.Monad (zipWithM_)-import Data.Maybe (fromMaybe) import Foreign.Lua (Lua, NumResults, Optional, liftIO) import Text.Pandoc.Class (CommonState (..), fetchItem, putCommonState,                           runIOorExplode, setMediaBag)@@ -25,6 +24,7 @@ import Text.Pandoc.MIME (MimeType)  import qualified Data.ByteString.Lazy as BL+import qualified Data.Text as T import qualified Foreign.Lua as Lua import qualified Text.Pandoc.MediaBag as MB @@ -113,7 +113,7 @@     Lua.push "length" *> Lua.push contentLength *> Lua.rawset (-3)     Lua.rawseti (-2) idx -fetch :: String+fetch :: T.Text       -> Lua NumResults fetch src = do   commonState <- getCommonState@@ -122,6 +122,6 @@     putCommonState commonState     setMediaBag mediaBag     fetchItem src-  Lua.push $ fromMaybe "" mimeType+  Lua.push $ maybe "" T.unpack mimeType   Lua.push bs   return 2 -- returns 2 values: contents, mimetype
src/Text/Pandoc/Lua/Module/Pandoc.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Lua.Module.Pandoc    Copyright   : Copyright © 2017-2019 Albert Krewinkel@@ -16,14 +17,14 @@  import Prelude import Control.Monad (when)+import Control.Monad.Except (throwError) import Data.Default (Default (..)) import Data.Maybe (fromMaybe)-import Data.Text (pack) import Foreign.Lua (Lua, NumResults, Optional, Peekable, Pushable) import System.Exit (ExitCode (..)) import Text.Pandoc.Class (runIO) import Text.Pandoc.Definition (Block, Inline)-import Text.Pandoc.Lua.Filter (walkInlines, walkBlocks, LuaFilter)+import Text.Pandoc.Lua.Filter (walkInlines, walkBlocks, LuaFilter, SingletonsList (..)) import Text.Pandoc.Lua.Marshaling () import Text.Pandoc.Walk (Walkable) import Text.Pandoc.Options (ReaderOptions (readerExtensions))@@ -32,8 +33,10 @@  import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BSL+import qualified Data.Text as T import qualified Foreign.Lua as Lua import qualified Text.Pandoc.Lua.Util as LuaUtil+import Text.Pandoc.Error  -- | Push the "pandoc" on the lua stack. Requires the `list` module to be -- loaded.@@ -46,7 +49,8 @@   LuaUtil.addFunction "walk_inline" walkInline   return 1 -walkElement :: (Pushable a, Walkable [Inline] a, Walkable [Block] a)+walkElement :: (Walkable (SingletonsList Inline) a,+                Walkable (SingletonsList Block) a)             => a -> LuaFilter -> Lua a walkElement x f = walkInlines f x >>= walkBlocks f @@ -56,20 +60,23 @@ walkBlock :: Block -> LuaFilter -> Lua Block walkBlock = walkElement -readDoc :: String -> Optional String -> Lua NumResults+readDoc :: T.Text -> Optional T.Text -> Lua NumResults readDoc content formatSpecOrNil = do   let formatSpec = fromMaybe "markdown" (Lua.fromOptional formatSpecOrNil)-  case getReader formatSpec of-    Left  s      -> Lua.raiseError s -- Unknown reader-    Right (reader, es) ->-      case reader of-        TextReader r -> do-          res <- Lua.liftIO . runIO $-                 r def{ readerExtensions = es } (pack content)-          case res of-            Right pd -> (1 :: NumResults) <$ Lua.push pd -- success, push Pandoc-            Left s   -> Lua.raiseError (show s)          -- error while reading-        _  -> Lua.raiseError "Only string formats are supported at the moment."+  res <- Lua.liftIO . runIO $+           getReader formatSpec >>= \(rdr,es) ->+             case rdr of+               TextReader r ->+                 r def{ readerExtensions = es } content+               _ -> throwError $ PandocSomeError $+                      "Only textual formats are supported"+  case res of+    Right pd -> (1 :: NumResults) <$ Lua.push pd -- success, push Pandoc+    Left  (PandocUnknownReaderError f) -> Lua.raiseError $+       "Unknown reader: " <> f+    Left  (PandocUnsupportedExtensionError e f) -> Lua.raiseError $+       "Extension " <> e <> " not supported for " <> f+    Left  e      -> Lua.raiseError $ show e  -- | Pipes input through a command. pipeFn :: String@@ -80,10 +87,10 @@   (ec, output) <- Lua.liftIO $ pipeProcess Nothing command args input   case ec of     ExitSuccess -> 1 <$ Lua.push output-    ExitFailure n -> Lua.raiseError (PipeError command n output)+    ExitFailure n -> Lua.raiseError (PipeError (T.pack command) n output)  data PipeError = PipeError-  { pipeErrorCommand :: String+  { pipeErrorCommand :: T.Text   , pipeErrorCode :: Int   , pipeErrorOutput :: BL.ByteString   }@@ -112,7 +119,7 @@         pipeErrorMessage :: PipeError -> Lua BL.ByteString         pipeErrorMessage (PipeError cmd errorCode output) = return $ mconcat           [ BSL.pack "Error running "-          , BSL.pack cmd+          , BSL.pack $ T.unpack cmd           , BSL.pack " (error code "           , BSL.pack $ show errorCode           , BSL.pack "): "
src/Text/Pandoc/Lua/Module/System.hs view
@@ -27,8 +27,8 @@   addField "arch" arch   addField "os" os   addFunction "environment" env-  addFunction "get_current_directory" getwd+  addFunction "get_working_directory" getwd   addFunction "with_environment" with_env-  addFunction "with_temp_directory" with_tmpdir+  addFunction "with_temporary_directory" with_tmpdir   addFunction "with_working_directory" with_wd   return 1
src/Text/Pandoc/Lua/Module/Types.hs view
@@ -15,6 +15,8 @@ import Prelude import Data.Version (Version) import Foreign.Lua (Lua, NumResults)+import Text.Pandoc.Definition+import Text.Pandoc.Lua.Marshaling.AST (LuaAttr, LuaListAttributes) import Text.Pandoc.Lua.Marshaling.Version () import Text.Pandoc.Lua.Util (addFunction) @@ -25,4 +27,43 @@ pushModule = do   Lua.newtable   addFunction "Version" (return :: Version -> Lua Version)+  pushCloneTable+  Lua.setfield (Lua.nthFromTop 2) "clone"   return 1++pushCloneTable :: Lua NumResults+pushCloneTable = do+  Lua.newtable+  addFunction "Attr" cloneAttr+  addFunction "Block" cloneBlock+  addFunction "Citation" cloneCitation+  addFunction "Inline" cloneInline+  addFunction "Meta" cloneMeta+  addFunction "MetaValue" cloneMetaValue+  addFunction "ListAttributes" cloneListAttributes+  addFunction "Pandoc" clonePandoc+  return 1++cloneAttr :: LuaAttr -> Lua LuaAttr+cloneAttr = return++cloneBlock :: Block -> Lua Block+cloneBlock = return++cloneCitation :: Citation -> Lua Citation+cloneCitation = return++cloneInline :: Inline -> Lua Inline+cloneInline = return++cloneListAttributes :: LuaListAttributes -> Lua LuaListAttributes+cloneListAttributes = return++cloneMeta :: Meta -> Lua Meta+cloneMeta = return++cloneMetaValue :: MetaValue -> Lua MetaValue+cloneMetaValue = return++clonePandoc :: Pandoc -> Lua Pandoc+clonePandoc = return
src/Text/Pandoc/Lua/Module/Utils.hs view
@@ -15,7 +15,6 @@  import Prelude import Control.Applicative ((<|>))-import Data.Char (toLower) import Data.Default (def) import Data.Version (Version) import Foreign.Lua (Peekable, Lua, NumResults)@@ -27,6 +26,7 @@  import qualified Data.Digest.Pure.SHA as SHA import qualified Data.ByteString.Lazy as BSL+import qualified Data.Text as T import qualified Foreign.Lua as Lua import qualified Text.Pandoc.Builder as B import qualified Text.Pandoc.Filter.JSON as JSONFilter@@ -38,7 +38,7 @@   Lua.newtable   addFunction "blocks_to_inlines" blocksToInlines   addFunction "equals" equals-  addFunction "hierarchicalize" hierarchicalize+  addFunction "make_sections" makeSections   addFunction "normalize_date" normalizeDate   addFunction "run_json_filter" (runJSONFilter mbDatadir)   addFunction "sha1" sha1@@ -55,15 +55,16 @@               Nothing -> Shared.defaultBlocksSeparator   return $ B.toList (Shared.blocksToInlinesWithSep sep blks) --- | Convert list of Pandoc blocks into (hierarchical) list of Elements.-hierarchicalize :: [Block] -> Lua [Shared.Element]-hierarchicalize = return . Shared.hierarchicalize+-- | Convert list of Pandoc blocks into sections using Divs.+makeSections :: Bool -> Lua.Optional Int -> [Block] -> Lua [Block]+makeSections number baselevel =+  return . Shared.makeSections number (Lua.fromOptional baselevel)  -- | Parse a date and convert (if possible) to "YYYY-MM-DD" format. We -- limit years to the range 1601-9999 (ISO 8601 accepts greater than -- or equal to 1583, but MS Word only accepts dates starting 1601). -- Returns nil instead of a string if the conversion failed.-normalizeDate :: String -> Lua (Lua.Optional String)+normalizeDate :: T.Text -> Lua (Lua.Optional T.Text) normalizeDate = return . Lua.Optional . Shared.normalizeDate  -- | Run a JSON filter on the given document.@@ -87,13 +88,13 @@  -- | Calculate the hash of the given contents. sha1 :: BSL.ByteString-     -> Lua String-sha1 = return . SHA.showDigest . SHA.sha1+     -> Lua T.Text+sha1 = return . T.pack . SHA.showDigest . SHA.sha1  -- | Convert pandoc structure to a string with formatting removed. -- Footnotes are skipped (since we don't want their contents in link -- labels).-stringify :: AstElement -> Lua String+stringify :: AstElement -> Lua T.Text stringify el = return $ case el of   PandocElement pd -> Shared.stringify pd   InlineElement i  -> Shared.stringify i@@ -101,11 +102,11 @@   MetaElement m    -> Shared.stringify m   CitationElement c  -> Shared.stringify c   MetaValueElement m -> stringifyMetaValue m-  _                  -> ""+  _                  -> mempty -stringifyMetaValue :: MetaValue -> String+stringifyMetaValue :: MetaValue -> T.Text stringifyMetaValue mv = case mv of-  MetaBool b   -> map toLower (show b)+  MetaBool b   -> T.toLower $ T.pack (show b)   MetaString s -> s   _            -> Shared.stringify mv @@ -138,5 +139,5 @@         "Expected an AST element, but could not parse value as such."  -- | Convert a number < 4000 to uppercase roman numeral.-toRomanNumeral :: Lua.Integer -> Lua String+toRomanNumeral :: Lua.Integer -> Lua T.Text toRomanNumeral = return . Shared.toRomanNumeral . fromIntegral
+ src/Text/Pandoc/Lua/Walk.hs view
@@ -0,0 +1,112 @@+{-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{- |+Module      : Text.Pandoc.Lua.Walk+Copyright   : © 2012–2019 John MacFarlane,+              © 2017-2019 Albert Krewinkel+License     : GNU GPL, version 2 or above+Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>+Stability   : alpha++Walking documents in a filter-suitable way.+-}+module Text.Pandoc.Lua.Walk+  ( SingletonsList (..)+  )+where++import Prelude+import Control.Monad ((<=<))+import Text.Pandoc.Definition+import Text.Pandoc.Walk++-- | Helper type which allows to traverse trees in order, while splicing in+-- trees.+--+-- The only interesting use of this type is via it's '@Walkable@' instance. That+-- instance makes it possible to walk a Pandoc document (or a subset thereof),+-- while applying a function on each element of an AST element /list/, and have+-- the resulting list spliced back in place of the original element. This is the+-- traversal/splicing method used for Lua filters.+newtype SingletonsList a = SingletonsList { singletonsList :: [a] }+  deriving (Functor, Foldable, Traversable)++--+-- SingletonsList Inline+--+instance {-# OVERLAPPING #-} Walkable (SingletonsList Inline) [Inline] where+  walkM = walkSingletonsListM+  query = querySingletonsList++instance Walkable (SingletonsList Inline) Pandoc where+  walkM = walkPandocM+  query = queryPandoc++instance Walkable (SingletonsList Inline) Citation where+  walkM = walkCitationM+  query = queryCitation++instance Walkable (SingletonsList Inline) Inline where+  walkM = walkInlineM+  query = queryInline++instance Walkable (SingletonsList Inline) Block where+  walkM = walkBlockM+  query = queryBlock++instance Walkable (SingletonsList Inline) MetaValue where+  walkM = walkMetaValueM+  query = queryMetaValue++instance Walkable (SingletonsList Inline) Meta where+  walkM f (Meta metamap) = Meta <$> walkM f metamap+  query f (Meta metamap) = query f metamap++--+-- SingletonsList Block+--+instance {-# OVERLAPPING #-} Walkable (SingletonsList Block) [Block] where+  walkM = walkSingletonsListM+  query = querySingletonsList++instance Walkable (SingletonsList Block) Pandoc where+  walkM = walkPandocM+  query = queryPandoc++instance Walkable (SingletonsList Block) Citation where+  walkM = walkCitationM+  query = queryCitation++instance Walkable (SingletonsList Block) Inline where+  walkM = walkInlineM+  query = queryInline++instance Walkable (SingletonsList Block) Block where+  walkM = walkBlockM+  query = queryBlock++instance Walkable (SingletonsList Block) MetaValue where+  walkM = walkMetaValueM+  query = queryMetaValue++instance Walkable (SingletonsList Block) Meta where+  walkM f (Meta metamap) = Meta <$> walkM f metamap+  query f (Meta metamap) = query f metamap+++walkSingletonsListM :: (Monad m, Walkable (SingletonsList a) a)+                    => (SingletonsList a -> m (SingletonsList a))+                    -> [a] -> m [a]+walkSingletonsListM f =+  let f' = fmap singletonsList . f . SingletonsList . (:[]) <=< walkM f+  in fmap mconcat . mapM f'++querySingletonsList :: (Monoid c, Walkable (SingletonsList a) a)+                    => (SingletonsList a -> c)+                    -> [a] -> c+querySingletonsList f =+  let f' x = f (SingletonsList [x]) `mappend` query f x+  in mconcat . map f'
src/Text/Pandoc/MIME.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.MIME    Copyright   : Copyright (C) 2011-2019 John MacFarlane@@ -13,14 +14,13 @@ module Text.Pandoc.MIME ( MimeType, getMimeType, getMimeTypeDef,                           extensionFromMimeType, mediaCategory ) where import Prelude-import Data.Char (toLower) import Data.List (isPrefixOf, isSuffixOf)-import Data.List.Split (splitOn) import qualified Data.Map as M+import qualified Data.Text as T import Data.Maybe (fromMaybe, listToMaybe) import System.FilePath -type MimeType = String+type MimeType = T.Text  -- | Determine mime type appropriate for file path. getMimeType :: FilePath -> Maybe MimeType@@ -31,34 +31,34 @@   | "Formula-" `isPrefixOf` fp && "/" `isSuffixOf` fp =         Just "application/vnd.oasis.opendocument.formula"   -- generic-  | otherwise = M.lookup (map toLower $ drop 1 $ takeExtension fp) mimeTypes+  | otherwise = M.lookup (T.toLower $ T.drop 1 $ T.pack $ takeExtension fp) mimeTypes  -- | Determime mime type appropriate for file path, defaulting to -- “application/octet-stream” if nothing else fits. getMimeTypeDef :: FilePath -> MimeType getMimeTypeDef = fromMaybe "application/octet-stream" . getMimeType -extensionFromMimeType :: MimeType -> Maybe String+extensionFromMimeType :: MimeType -> Maybe T.Text extensionFromMimeType mimetype =-  M.lookup (takeWhile (/=';') mimetype) reverseMimeTypes+  M.lookup (T.takeWhile (/=';') mimetype) reverseMimeTypes   -- note:  we just look up the basic mime type, dropping the content-encoding etc.  -- | Determine general media category for file path, e.g. -- -- prop> mediaCategory "foo.jpg" = Just "image"-mediaCategory :: FilePath -> Maybe String-mediaCategory fp = getMimeType fp >>= listToMaybe . splitOn "/"+mediaCategory :: FilePath -> Maybe T.Text+mediaCategory fp = getMimeType fp >>= listToMaybe . T.splitOn "/" -reverseMimeTypes :: M.Map MimeType String+reverseMimeTypes :: M.Map MimeType T.Text reverseMimeTypes = M.fromList $ map (\(k,v) -> (v,k)) mimeTypesList -mimeTypes :: M.Map String MimeType+mimeTypes :: M.Map T.Text MimeType mimeTypes = M.fromList mimeTypesList  -- | Collection of common mime types. -- Except for first entry, list borrowed from -- <https://github.com/Happstack/happstack-server/blob/master/src/Happstack/Server/FileServe/BuildingBlocks.hs happstack-server>-mimeTypesList :: [(String, MimeType)]+mimeTypesList :: [(T.Text, MimeType)] mimeTypesList =            [("cpt","image/x-corelphotopaint")            ,("gz","application/x-gzip")
src/Text/Pandoc/MediaBag.hs view
@@ -36,7 +36,7 @@ -- mime types.  Note that a 'MediaBag' is a Monoid, so 'mempty' -- can be used for an empty 'MediaBag', and '<>' can be used to append -- two 'MediaBag's.-newtype MediaBag = MediaBag (M.Map [String] (MimeType, BL.ByteString))+newtype MediaBag = MediaBag (M.Map [FilePath] (MimeType, BL.ByteString))         deriving (Semigroup, Monoid, Data, Typeable)  instance Show MediaBag where@@ -72,12 +72,12 @@  -- | Get a list of the file paths stored in a 'MediaBag', with -- their corresponding mime types and the lengths in bytes of the contents.-mediaDirectory :: MediaBag -> [(String, MimeType, Int)]+mediaDirectory :: MediaBag -> [(FilePath, MimeType, Int)] mediaDirectory (MediaBag mediamap) =   M.foldrWithKey (\fp (mime,contents) ->       ((Posix.joinPath fp, mime, fromIntegral $ BL.length contents):)) [] mediamap -mediaItems :: MediaBag -> [(String, MimeType, BL.ByteString)]+mediaItems :: MediaBag -> [(FilePath, MimeType, BL.ByteString)] mediaItems (MediaBag mediamap) =   M.foldrWithKey (\fp (mime,contents) ->       ((Posix.joinPath fp, mime, contents):)) [] mediamap
src/Text/Pandoc/Options.hs view
@@ -2,9 +2,8 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric      #-} {-# LANGUAGE NoImplicitPrelude  #-}-#ifdef DERIVE_JSON_VIA_TH {-# LANGUAGE TemplateHaskell    #-}-#endif+{-# LANGUAGE OverloadedStrings  #-} {- |    Module      : Text.Pandoc.Options    Copyright   : Copyright (C) 2012-2019 John MacFarlane@@ -31,23 +30,28 @@                            , ReferenceLocation (..)                            , def                            , isEnabled+                           , defaultMathJaxURL+                           , defaultKaTeXURL                            ) where import Prelude+import Control.Applicative ((<|>))+import Data.Char (toLower)+import Data.Maybe (fromMaybe) import Data.Data (Data) import Data.Default+import Data.Text (Text)+import Text.DocTemplates (Context(..)) import qualified Data.Set as Set import Data.Typeable (Typeable) import GHC.Generics (Generic) import Skylighting (SyntaxMap, defaultSyntaxMap) import Text.Pandoc.Extensions import Text.Pandoc.Highlighting (Style, pygments)--#ifdef DERIVE_JSON_VIA_TH-import Data.Aeson.TH (deriveJSON, defaultOptions)-#else-import Data.Aeson (FromJSON (..), ToJSON (..),-                   defaultOptions, genericToEncoding)-#endif+import Text.Pandoc.Shared (camelCaseStrToHyphenated)+import Text.DocTemplates (Template)+import Data.Aeson.TH (deriveJSON, defaultOptions, Options(..),+                      SumEncoding(..))+import Data.YAML  class HasSyntaxExtensions a where   getExtensions :: a -> Extensions@@ -57,10 +61,10 @@        , readerStandalone            :: Bool -- ^ Standalone document with header        , readerColumns               :: Int  -- ^ Number of columns in terminal        , readerTabStop               :: Int  -- ^ Tab stop-       , readerIndentedCodeClasses   :: [String] -- ^ Default classes for+       , readerIndentedCodeClasses   :: [Text] -- ^ Default classes for                                        -- indented code blocks-       , readerAbbreviations         :: Set.Set String -- ^ Strings to treat as abbreviations-       , readerDefaultImageExtension :: String -- ^ Default extension for images+       , readerAbbreviations         :: Set.Set Text -- ^ Strings to treat as abbreviations+       , readerDefaultImageExtension :: Text -- ^ Default extension for images        , readerTrackChanges          :: TrackChanges -- ^ Track changes setting for docx        , readerStripComments         :: Bool -- ^ Strip HTML comments instead of parsing as raw HTML } deriving (Show, Read, Data, Typeable, Generic)@@ -81,7 +85,7 @@                , readerStripComments         = False                } -defaultAbbrevs :: Set.Set String+defaultAbbrevs :: Set.Set Text defaultAbbrevs = Set.fromList                  [ "Mr.", "Mrs.", "Ms.", "Capt.", "Dr.", "Prof.",                    "Gen.", "Gov.", "e.g.", "i.e.", "Sgt.", "St.",@@ -96,24 +100,65 @@ data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read, Data, Typeable, Generic)  data HTMLMathMethod = PlainMath-                    | WebTeX String               -- url of TeX->image script.+                    | WebTeX Text               -- url of TeX->image script.                     | GladTeX                     | MathML-                    | MathJax String              -- url of MathJax.js-                    | KaTeX String                -- url of KaTeX files+                    | MathJax Text              -- url of MathJax.js+                    | KaTeX Text                -- url of KaTeX files                     deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML HTMLMathMethod where+   parseYAML node =+     (withMap "HTMLMathMethod" $ \m -> do+        method <- m .: "method"+        mburl <- m .:? "url"+        case method :: Text of+          "plain" -> return PlainMath+          "webtex" -> return $ WebTeX $ fromMaybe "" mburl+          "gladtex" -> return GladTeX+          "mathml" -> return MathML+          "mathjax" -> return $ MathJax $+                         fromMaybe defaultMathJaxURL mburl+          "katex" -> return $ KaTeX $+                         fromMaybe defaultKaTeXURL mburl+          _ -> fail $ "Unknown HTML math method " ++ show method) node+       <|> (withStr "HTMLMathMethod" $ \method ->+             case method of+               "plain" -> return PlainMath+               "webtex" -> return $ WebTeX ""+               "gladtex" -> return GladTeX+               "mathml" -> return MathML+               "mathjax" -> return $ MathJax defaultMathJaxURL+               "katex" -> return $ KaTeX defaultKaTeXURL+               _  -> fail $ "Unknown HTML math method " ++ show method) node+ data CiteMethod = Citeproc                        -- use citeproc to render them                   | Natbib                        -- output natbib cite commands                   | Biblatex                      -- output biblatex cite commands                 deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML CiteMethod where+  parseYAML = withStr "Citeproc" $ \t ->+    case t of+      "citeproc" -> return Citeproc+      "natbib"   -> return Natbib+      "biblatex" -> return Biblatex+      _          -> fail $ "Unknown citation method " ++ show t+ -- | Methods for obfuscating email addresses in HTML. data ObfuscationMethod = NoObfuscation                        | ReferenceObfuscation                        | JavascriptObfuscation                        deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML ObfuscationMethod where+  parseYAML = withStr "Citeproc" $ \t ->+    case t of+      "none"       -> return NoObfuscation+      "references" -> return ReferenceObfuscation+      "javascript" -> return JavascriptObfuscation+      _            -> fail $ "Unknown obfuscation method " ++ show t+ -- | Varieties of HTML slide shows. data HTMLSlideVariant = S5Slides                       | SlidySlides@@ -129,12 +174,29 @@                   | AllChanges                   deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML TrackChanges where+  parseYAML = withStr "TrackChanges" $ \t ->+    case t of+      "accept"     -> return AcceptChanges+      "reject"     -> return RejectChanges+      "all"        -> return AllChanges+      _            -> fail $ "Unknown track changes method " ++ show t+ -- | Options for wrapping text in the output. data WrapOption = WrapAuto        -- ^ Automatically wrap to width                 | WrapNone        -- ^ No non-semantic newlines                 | WrapPreserve    -- ^ Preserve wrapping of input source                 deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML WrapOption where+  parseYAML = withStr "WrapOption" $ \t ->+    case t of+      "auto"     -> return WrapAuto+      "none"     -> return WrapNone+      "preserve" -> return WrapPreserve+      _          -> fail $ "Unknown wrap method " ++ show t++ -- | Options defining the type of top-level headers. data TopLevelDivision = TopLevelPart      -- ^ Top-level headers become parts                       | TopLevelChapter   -- ^ Top-level headers become chapters@@ -143,16 +205,35 @@                                           --   heuristics                       deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML TopLevelDivision where+  parseYAML = withStr "TopLevelDivision" $ \t ->+    case t of+      "part"     -> return TopLevelPart+      "chapter"  -> return TopLevelChapter+      "section"  -> return TopLevelSection+      "default"  -> return TopLevelDefault+      _          -> fail $ "Unknown top level division " ++ show t++ -- | Locations for footnotes and references in markdown output data ReferenceLocation = EndOfBlock    -- ^ End of block                        | EndOfSection  -- ^ prior to next section header (or end of document)                        | EndOfDocument -- ^ at end of document                        deriving (Show, Read, Eq, Data, Typeable, Generic) +instance FromYAML ReferenceLocation where+  parseYAML = withStr "ReferenceLocation" $ \t ->+    case t of+      "block"    -> return EndOfBlock+      "section"  -> return EndOfSection+      "document" -> return EndOfDocument+      _          -> fail $ "Unknown reference location " ++ show t++ -- | Options for writers data WriterOptions = WriterOptions-  { writerTemplate          :: Maybe String -- ^ Template to use-  , writerVariables         :: [(String, String)] -- ^ Variables to set in template+  { writerTemplate          :: Maybe (Template Text) -- ^ Template to use+  , writerVariables         :: Context Text -- ^ Variables to set in template   , writerTabStop           :: Int    -- ^ Tabstop for conversion btw spaces and tabs   , writerTableOfContents   :: Bool   -- ^ Include table of contents   , writerIncremental       :: Bool   -- ^ True if lists should be incremental@@ -166,7 +247,7 @@   , writerWrapText          :: WrapOption  -- ^ Option for wrapping text   , writerColumns           :: Int    -- ^ Characters in a line (for text wrapping)   , writerEmailObfuscation  :: ObfuscationMethod -- ^ How to obfuscate emails-  , writerIdentifierPrefix  :: String -- ^ Prefix for section & note ids in HTML+  , writerIdentifierPrefix  :: Text -- ^ Prefix for section & note ids in HTML                                      -- and for footnote marks in markdown   , writerCiteMethod        :: CiteMethod -- ^ How to print cites   , writerHtmlQTags         :: Bool       -- ^ Use @<q>@ tags for quotes in HTML@@ -176,8 +257,8 @@   , writerHighlightStyle    :: Maybe Style  -- ^ Style to use for highlighting                                            -- (Nothing = no highlighting)   , writerSetextHeaders     :: Bool       -- ^ Use setext headers for levels 1-2 in markdown-  , writerEpubSubdirectory  :: String       -- ^ Subdir for epub in OCF-  , writerEpubMetadata      :: Maybe String -- ^ Metadata to include in EPUB+  , writerEpubSubdirectory  :: Text       -- ^ Subdir for epub in OCF+  , writerEpubMetadata      :: Maybe Text -- ^ Metadata to include in EPUB   , writerEpubFonts         :: [FilePath] -- ^ Paths to fonts to embed   , writerEpubChapterLevel  :: Int            -- ^ Header level for chapters (separate files)   , writerTOCDepth          :: Int            -- ^ Number of levels to include in TOC@@ -189,7 +270,7 @@  instance Default WriterOptions where   def = WriterOptions { writerTemplate         = Nothing-                      , writerVariables        = []+                      , writerVariables        = mempty                       , writerTabStop          = 4                       , writerTableOfContents  = False                       , writerIncremental      = False@@ -229,50 +310,47 @@ isEnabled :: HasSyntaxExtensions a => Extension -> a -> Bool isEnabled ext opts = ext `extensionEnabled` getExtensions opts -#ifdef DERIVE_JSON_VIA_TH+defaultMathJaxURL :: Text+defaultMathJaxURL = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/"++defaultKaTeXURL :: Text+defaultKaTeXURL = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/"+ $(deriveJSON defaultOptions ''ReaderOptions)-$(deriveJSON defaultOptions ''HTMLMathMethod)-$(deriveJSON defaultOptions ''CiteMethod)-$(deriveJSON defaultOptions ''ObfuscationMethod)-$(deriveJSON defaultOptions ''HTMLSlideVariant)-$(deriveJSON defaultOptions ''TrackChanges)-$(deriveJSON defaultOptions ''WrapOption)-$(deriveJSON defaultOptions ''TopLevelDivision)-$(deriveJSON defaultOptions ''ReferenceLocation)-#else-instance ToJSON CiteMethod where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON CiteMethod -instance ToJSON ReaderOptions where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON ReaderOptions+$(deriveJSON defaultOptions{+   constructorTagModifier = map toLower,+   sumEncoding = TaggedObject{+                    tagFieldName = "method",+                    contentsFieldName = "url" }+                           } ''HTMLMathMethod) -instance ToJSON ObfuscationMethod where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON ObfuscationMethod+$(deriveJSON defaultOptions{ constructorTagModifier =+                               camelCaseStrToHyphenated+                           } ''CiteMethod) -instance ToJSON WrapOption where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON WrapOption+$(deriveJSON defaultOptions{ constructorTagModifier =+                            \t -> case t of+                                    "NoObfuscation"         -> "none"+                                    "ReferenceObfuscation"  -> "references"+                                    "JavascriptObfuscation" -> "javascript"+                                    _                       -> "none"+                           } ''ObfuscationMethod) -instance ToJSON HTMLMathMethod where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON HTMLMathMethod+$(deriveJSON defaultOptions ''HTMLSlideVariant) -instance ToJSON HTMLSlideVariant where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON HTMLSlideVariant+$(deriveJSON defaultOptions{ constructorTagModifier =+                               camelCaseStrToHyphenated+                           } ''TrackChanges) -instance ToJSON TopLevelDivision where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON TopLevelDivision+$(deriveJSON defaultOptions{ constructorTagModifier =+                               camelCaseStrToHyphenated+                           } ''WrapOption) -instance ToJSON ReferenceLocation where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON ReferenceLocation+$(deriveJSON defaultOptions{ constructorTagModifier =+                               camelCaseStrToHyphenated . drop 8+                           } ''TopLevelDivision) -instance ToJSON TrackChanges where-  toEncoding = genericToEncoding defaultOptions-instance FromJSON TrackChanges-#endif+$(deriveJSON defaultOptions{ constructorTagModifier =+                               camelCaseStrToHyphenated+                           } ''ReferenceLocation)
src/Text/Pandoc/PDF.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE CPP                 #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -27,25 +27,29 @@ import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T+import qualified Data.Text.Lazy as TL+import Data.Text.Lazy.Encoding (decodeUtf8') import Text.Printf (printf)-import Data.Char (ord, isAscii)+import Data.Char (ord, isAscii, isSpace) import System.Directory import System.Environment import System.Exit (ExitCode (..)) import System.FilePath-import System.IO (stdout)+import System.IO (stdout, hClose) import System.IO.Temp (withSystemTempDirectory, withTempDirectory,                        withTempFile)-import System.IO.Error (IOError, isDoesNotExistError)+import qualified System.IO.Error as IE+import Text.DocLayout (literal) import Text.Pandoc.Definition import Text.Pandoc.Error (PandocError (PandocPDFProgramNotFoundError)) import Text.Pandoc.MIME (getMimeType) import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..)) import Text.Pandoc.Process (pipeProcess)-import Text.Pandoc.Shared (inDirectory, stringify)+import System.Process (readProcessWithExitCode)+import Text.Pandoc.Shared (inDirectory, stringify, tshow) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Walk (walkM)-import Text.Pandoc.Writers.Shared (getField, metaToJSON)+import Text.Pandoc.Writers.Shared (getField, metaToContext) #ifdef _WINDOWS import Data.List (intercalate) #endif@@ -89,7 +93,13 @@       -- user names (see #777)       let withTempDir templ action = do             tmp <- getTemporaryDirectory-            if '~' `elem` tmp+            uname <- E.catch+              (do (ec, sout, _) <- readProcessWithExitCode "uname" ["-o"] ""+                  if ec == ExitSuccess+                     then return $ Just $ filter (not . isSpace) sout+                     else return Nothing)+              (\(_ :: E.SomeException) -> return Nothing)+            if '~' `elem` tmp || uname == Just "Cygwin" -- see #5451                    then withTempDirectory "." templ action                    else withSystemTempDirectory templ action       (newCommonState, res) <- liftIO $ withTempDir "tex2pdf." $ \tmpdir' -> do@@ -101,7 +111,7 @@ #endif         runIOorExplode $ do           putCommonState commonState-          doc' <- handleImages tmpdir doc+          doc' <- handleImages opts tmpdir doc           source <- writer opts doc'           res <- case baseProg of             "context" -> context2pdf verbosity program pdfargs tmpdir source@@ -127,51 +137,57 @@                       MathJax _ -> ["--run-script", "MathJax.Hub.Register.StartupHook('End Typeset', function() { window.status = 'mathjax_loaded' });",                                     "--window-status", "mathjax_loaded"]                       _ -> []-  meta' <- metaToJSON opts (return . stringify) (return . stringify) meta-  let toArgs (f, mbd) = maybe [] (\d -> ['-':'-':f, d]) mbd+  meta' <- metaToContext opts+             (return . literal . stringify)+             (return . literal . stringify)+             meta+  let toArgs (f, mbd) = maybe [] (\d -> ["--" <> f, T.unpack d]) mbd   let args   = pdfargs ++ mathArgs ++ concatMap toArgs                  [("page-size", getField "papersize" meta')                  ,("title", getField "title" meta')-                 ,("margin-bottom", fromMaybe (Just "1.2in")+                 ,("margin-bottom", maybe (Just "1.2in") Just                             (getField "margin-bottom" meta'))-                 ,("margin-top", fromMaybe (Just "1.25in")+                 ,("margin-top", maybe (Just "1.25in") Just                             (getField "margin-top" meta'))-                 ,("margin-right", fromMaybe (Just "1.25in")+                 ,("margin-right", maybe (Just "1.25in") Just                             (getField "margin-right" meta'))-                 ,("margin-left", fromMaybe (Just "1.25in")+                 ,("margin-left", maybe (Just "1.25in") Just                             (getField "margin-left" meta'))-                 ,("footer-html", fromMaybe Nothing+                 ,("footer-html", maybe Nothing Just                             (getField "footer-html" meta'))-                 ,("header-html", fromMaybe Nothing+                 ,("header-html", maybe Nothing Just                             (getField "header-html" meta'))                  ]   source <- writer opts doc   verbosity <- getVerbosity   liftIO $ html2pdf verbosity program args source -handleImages :: FilePath      -- ^ temp dir to store images+handleImages :: WriterOptions+             -> FilePath      -- ^ temp dir to store images              -> Pandoc        -- ^ document              -> PandocIO Pandoc-handleImages tmpdir doc =+handleImages opts tmpdir doc =   fillMediaBag doc >>=     extractMedia tmpdir >>=-    walkM (convertImages tmpdir)+    walkM (convertImages opts tmpdir) -convertImages :: FilePath -> Inline -> PandocIO Inline-convertImages tmpdir (Image attr ils (src, tit)) = do-  img <- liftIO $ convertImage tmpdir src+convertImages :: WriterOptions -> FilePath -> Inline -> PandocIO Inline+convertImages opts tmpdir (Image attr ils (src, tit)) = do+  img <- liftIO $ convertImage opts tmpdir $ T.unpack src   newPath <-     case img of       Left e -> do         report $ CouldNotConvertImage src e         return src-      Right fp -> return fp+      Right fp -> return $ T.pack fp   return (Image attr ils (newPath, tit))-convertImages _ x = return x+convertImages _ _ x = return x  -- Convert formats which do not work well in pdf to png-convertImage :: FilePath -> FilePath -> IO (Either String FilePath)-convertImage tmpdir fname =+convertImage :: WriterOptions -> FilePath -> FilePath+             -> IO (Either Text FilePath)+convertImage opts tmpdir fname = do+  let dpi = show $ writerDpi opts   case mime of     Just "image/png" -> doNothing     Just "image/jpeg" -> doNothing@@ -180,19 +196,20 @@     Just "application/eps" -> doNothing     Just "image/svg+xml" -> E.catch (do       (exit, _) <- pipeProcess Nothing "rsvg-convert"-                     ["-f","pdf","-a","-o",pdfOut,fname] BL.empty+                     ["-f","pdf","-a","--dpi-x",dpi,"--dpi-y",dpi,+                      "-o",pdfOut,fname] BL.empty       if exit == ExitSuccess          then return $ Right pdfOut          else return $ Left "conversion from SVG failed")       (\(e :: E.SomeException) -> return $ Left $-          "check that rsvg-convert is in path.\n" ++-          show e)+          "check that rsvg-convert is in path.\n" <>+          tshow e)     _ -> JP.readImage fname >>= \res ->           case res of-               Left e    -> return $ Left e+               Left e    -> return $ Left $ T.pack e                Right img ->                  E.catch (Right pngOut <$ JP.savePngImage pngOut img) $-                     \(e :: E.SomeException) -> return (Left (show e))+                     \(e :: E.SomeException) -> return (Left (tshow e))   where     pngOut = replaceDirectory (replaceExtension fname ".png") tmpdir     pdfOut = replaceDirectory (replaceExtension fname ".pdf") tmpdir@@ -245,12 +262,11 @@ missingCharacterWarnings verbosity log' = do   let ls = BC.lines log'   let isMissingCharacterWarning = BC.isPrefixOf "Missing character: "-  let addCodePoint [] = []-      addCodePoint (c:cs)-        | isAscii c   = c : addCodePoint cs-        | otherwise   = c : " (U+" ++ printf "%04X" (ord c) ++ ")" ++-                            addCodePoint cs-  let warnings = [ addCodePoint (UTF8.toStringLazy (BC.drop 19 l))+  let toCodePoint c+        | isAscii c   = T.singleton c+        | otherwise   = T.pack $ c : " (U+" ++ printf "%04X" (ord c) ++ ")"+  let addCodePoint = T.concatMap toCodePoint+  let warnings = [ addCodePoint (T.pack $ utf8ToString (BC.drop 19 l))                  | l <- ls                  , isMissingCharacterWarning l                  ]@@ -293,13 +309,11 @@     let programArgs = ["--outdir", tmpDir] ++ args ++ ["-"]     env <- liftIO getEnvironment     when (verbosity >= INFO) $ liftIO $-      showVerboseInfo (Just tmpDir) program programArgs env (UTF8.toStringLazy sourceBL)+      showVerboseInfo (Just tmpDir) program programArgs env+         (utf8ToString sourceBL)     (exit, out) <- liftIO $ E.catch       (pipeProcess (Just env) program programArgs sourceBL)-      (\(e :: IOError) -> if isDoesNotExistError e-                             then E.throwIO $ PandocPDFProgramNotFoundError-                                   program-                             else E.throwIO e)+      (handlePDFProgramNotFound program)     when (verbosity >= INFO) $ liftIO $ do       putStrLn "[makePDF] Running"       BL.hPutStr stdout out@@ -365,10 +379,7 @@        showVerboseInfo (Just tmpDir) program programArgs env''     (exit, out) <- liftIO $ E.catch       (pipeProcess (Just env'') program programArgs BL.empty)-      (\(e :: IOError) -> if isDoesNotExistError e-                             then E.throwIO $ PandocPDFProgramNotFoundError-                                   program-                             else E.throwIO e)+      (handlePDFProgramNotFound program)     when (verbosity >= INFO) $ liftIO $ do       putStrLn $ "[makePDF] Run #" ++ show runNumber       BL.hPutStr stdout out@@ -393,10 +404,7 @@   (exit, out) <- E.catch     (pipeProcess (Just env') program args                      (BL.fromStrict $ UTF8.fromText source))-    (\(e :: IOError) -> if isDoesNotExistError e-                           then E.throwIO $-                                  PandocPDFProgramNotFoundError program-                           else E.throwIO e)+    (handlePDFProgramNotFound program)   return $ case exit of              ExitFailure _ -> Left out              ExitSuccess   -> Right out@@ -411,39 +419,37 @@   -- write HTML to temp file so we don't have to rewrite   -- all links in `a`, `img`, `style`, `script`, etc. tags,   -- and piping to weasyprint didn't work on Windows either.-  file    <- withTempFile "." "html2pdf.html" $ \fp _ -> return fp-  pdfFile <- withTempFile "." "html2pdf.pdf" $ \fp _ -> return fp-  BS.writeFile file $ UTF8.fromText source-  let pdfFileArgName = ["-o" | takeBaseName program == "prince"]-  let programArgs = args ++ [file] ++ pdfFileArgName ++ [pdfFile]-  env' <- getEnvironment-  when (verbosity >= INFO) $-    UTF8.readFile file >>=-      showVerboseInfo Nothing program programArgs env'-  (exit, out) <- E.catch-    (pipeProcess (Just env') program programArgs BL.empty)-    (\(e :: IOError) -> if isDoesNotExistError e-                           then E.throwIO $-                                  PandocPDFProgramNotFoundError program-                           else E.throwIO e)-  removeFile file-  when (verbosity >= INFO) $ do-    BL.hPutStr stdout out-    putStr "\n"-  pdfExists <- doesFileExist pdfFile-  mbPdf <- if pdfExists-            -- We read PDF as a strict bytestring to make sure that the-            -- temp directory is removed on Windows.-            -- See https://github.com/jgm/pandoc/issues/1192.-            then do-              res <- (Just . BL.fromChunks . (:[])) `fmap` BS.readFile pdfFile-              removeFile pdfFile-              return res-            else return Nothing-  return $ case (exit, mbPdf) of-             (ExitFailure _, _)      -> Left out-             (ExitSuccess, Nothing)  -> Left ""-             (ExitSuccess, Just pdf) -> Right pdf+  withTempFile "." "html2pdf.html" $ \file h1 ->+    withTempFile "." "html2pdf.pdf" $ \pdfFile h2 -> do+      hClose h1+      hClose h2+      BS.writeFile file $ UTF8.fromText source+      let pdfFileArgName = ["-o" | takeBaseName program == "prince"]+      let programArgs = args ++ [file] ++ pdfFileArgName ++ [pdfFile]+      env' <- getEnvironment+      when (verbosity >= INFO) $+        UTF8.readFile file >>=+          showVerboseInfo Nothing program programArgs env'+      (exit, out) <- E.catch+        (pipeProcess (Just env') program programArgs BL.empty)+        (handlePDFProgramNotFound program)+      when (verbosity >= INFO) $ do+        BL.hPutStr stdout out+        putStr "\n"+      pdfExists <- doesFileExist pdfFile+      mbPdf <- if pdfExists+                -- We read PDF as a strict bytestring to make sure that the+                -- temp directory is removed on Windows.+                -- See https://github.com/jgm/pandoc/issues/1192.+                then do+                  res <- Just . BL.fromChunks . (:[]) <$>+                            BS.readFile pdfFile+                  return res+                else return Nothing+      return $ case (exit, mbPdf) of+                 (ExitFailure _, _)      -> Left out+                 (ExitSuccess, Nothing)  -> Left ""+                 (ExitSuccess, Just pdf) -> Right pdf  context2pdf :: Verbosity    -- ^ Verbosity level             -> String       -- ^ "context" or path to it@@ -462,10 +468,7 @@         showVerboseInfo (Just tmpDir) program programArgs env'     (exit, out) <- E.catch       (pipeProcess (Just env') program programArgs BL.empty)-      (\(e :: IOError) -> if isDoesNotExistError e-                             then E.throwIO $-                                    PandocPDFProgramNotFoundError "context"-                             else E.throwIO e)+      (handlePDFProgramNotFound program)     when (verbosity >= INFO) $ do       BL.hPutStr stdout out       putStr "\n"@@ -505,3 +508,15 @@   putStr "\n"   putStrLn $ "[makePDF] Source:"   putStrLn source++handlePDFProgramNotFound :: String -> IE.IOError -> IO a+handlePDFProgramNotFound program e+  | IE.isDoesNotExistError e =+      E.throwIO $ PandocPDFProgramNotFoundError $ T.pack program+  | otherwise = E.throwIO e++utf8ToString :: ByteString -> String+utf8ToString lbs =+  case decodeUtf8' lbs of+    Left _  -> BC.unpack lbs  -- if decoding fails, treat as latin1+    Right t -> TL.unpack t
src/Text/Pandoc/Parsing.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude          #-} {-# LANGUAGE CPP                        #-} {-# LANGUAGE ExplicitForAll             #-} {-# LANGUAGE FlexibleContexts           #-}@@ -7,6 +7,8 @@ {-# LANGUAGE IncoherentInstances        #-} {-# LANGUAGE MultiParamTypeClasses      #-} {-# LANGUAGE TypeSynonymInstances       #-}+{-# LANGUAGE ViewPatterns               #-}+{-# LANGUAGE OverloadedStrings          #-} {- |    Module      : Text.Pandoc.Parsing    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -18,13 +20,21 @@  A utility library with parsers used in pandoc readers. -}-module Text.Pandoc.Parsing ( takeWhileP,++module Text.Pandoc.Parsing ( take1WhileP,                              takeP,+                             countChar,+                             textStr,                              anyLine,                              anyLineNewline,                              indentWith,+                             manyChar,+                             many1Char,+                             manyTillChar,+                             many1TillChar,                              many1Till,                              manyUntil,+                             manyUntilChar,                              sepBy1',                              notFollowedBy',                              oneOfStrings,@@ -183,12 +193,14 @@ import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper,                   isPunctuation, isSpace, ord, toLower, toUpper) import Data.Default-import Data.List (intercalate, isSuffixOf, transpose)+import Data.Functor (($>))+import Data.List (intercalate, transpose) import qualified Data.Map as M import Data.Maybe (mapMaybe, fromMaybe) import qualified Data.Set as Set import Data.String import Data.Text (Text)+import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Asciify (toAsciiChar) import Text.Pandoc.Builder (Blocks, HasMeta (..), Inlines, trimInlines)@@ -240,45 +252,58 @@   mempty = return mempty   mappend = (<>) +-- | Like @count@, but packs its result+countChar :: (Stream s m Char, Monad m)+          => Int+          -> ParsecT s st m Char+          -> ParsecT s st m Text+countChar n = fmap T.pack . count n++-- | Like @string@, but uses @Text@.+textStr :: Stream s m Char => Text -> ParsecT s u m Text+textStr t = string (T.unpack t) $> t+ -- | Parse characters while a predicate is true.-takeWhileP :: Monad m+take1WhileP :: Monad m            => (Char -> Bool)-           -> ParserT [Char] st m [Char]-takeWhileP f = do-  -- faster than 'many (satisfy f)'+           -> ParserT Text st m Text+take1WhileP f = do+  -- needed to persuade parsec that this won't match an empty string:+  c <- satisfy f   inp <- getInput   pos <- getPosition-  let (xs, rest) = span f inp-  -- needed to persuade parsec that this won't match an empty string:-  anyChar+  let (t, rest) = T.span f inp   setInput rest-  setPosition $ updatePosString pos xs-  return xs+  setPosition $+    if f '\t' || f '\n'+       then updatePosString pos $ T.unpack t+       else incSourceColumn pos (T.length t)+  return $ T.singleton c <> t  -- Parse n characters of input (or the rest of the input if -- there aren't n characters).-takeP :: Monad m => Int -> ParserT [Char] st m [Char]+takeP :: Monad m => Int -> ParserT Text st m Text takeP n = do   guard (n > 0)   -- faster than 'count n anyChar'   inp <- getInput   pos <- getPosition-  let (xs, rest) = splitAt n inp+  let (xs, rest) = T.splitAt n inp   -- needed to persuade parsec that this won't match an empty string:   anyChar   setInput rest-  setPosition $ updatePosString pos xs+  setPosition $ updatePosString pos $ T.unpack xs   return xs  -- | Parse any line of text-anyLine :: Monad m => ParserT [Char] st m [Char]+anyLine :: Monad m => ParserT Text st m Text anyLine = do   -- This is much faster than:   -- manyTill anyChar newline   inp <- getInput   pos <- getPosition-  case break (=='\n') inp of-       (this, '\n':rest) -> do+  case T.break (=='\n') inp of+       (this, T.uncons -> Just ('\n', rest)) -> do          -- needed to persuade parsec that this won't match an empty string:          anyChar          setInput rest@@ -287,20 +312,39 @@        _ -> mzero  -- | Parse any line, include the final newline in the output-anyLineNewline :: Monad m => ParserT [Char] st m [Char]-anyLineNewline = (++ "\n") <$> anyLine+anyLineNewline :: Monad m => ParserT Text st m Text+anyLineNewline = (<> "\n") <$> anyLine  -- | Parse indent by specified number of spaces (or equiv. tabs) indentWith :: Stream s m Char            => HasReaderOptions st-           => Int -> ParserT s st m [Char]+           => Int -> ParserT s st m Text indentWith num = do   tabStop <- getOption readerTabStop   if num < tabStop-     then count num (char ' ')-     else choice [ try (count num (char ' '))+     then countChar num (char ' ')+     else choice [ try (countChar num (char ' '))                  , try (char '\t' >> indentWith (num - tabStop)) ] +-- | Like @many@, but packs its result.+manyChar :: Stream s m t+         => ParserT s st m Char+         -> ParserT s st m Text+manyChar = fmap T.pack . many++-- | Like @many1@, but packs its result.+many1Char :: Stream s m t+          => ParserT s st m Char+          -> ParserT s st m Text+many1Char = fmap T.pack . many1++-- | Like @manyTill@, but packs its result.+manyTillChar :: Stream s m t+             => ParserT s st m Char+             -> ParserT s st m a+             -> ParserT s st m Text+manyTillChar p = fmap T.pack . manyTill p+ -- | Like @manyTill@, but reads at least one item. many1Till :: (Show end, Stream s m t)           => ParserT s st m a@@ -312,9 +356,15 @@          rest <- manyTill p end          return (first:rest) +-- | Like @many1Till@, but packs its result+many1TillChar :: (Show end, Stream s m t)+              => ParserT s st m Char+              -> ParserT s st m end+              -> ParserT s st m Text+many1TillChar p = fmap T.pack . many1Till p+ -- | Like @manyTill@, but also returns the result of end parser.-manyUntil :: (Stream s m t)-          => ParserT s u m a+manyUntil :: ParserT s u m a           -> ParserT s u m b           -> ParserT s u m ([a], b) manyUntil p end = scan@@ -326,10 +376,17 @@               (xs, e) <- scan               return (x:xs, e)) +-- | Like @manyUntil@, but also packs its result.+manyUntilChar :: ParserT s u m Char+              -> ParserT s u m b+              -> ParserT s u m (Text, b)+manyUntilChar p = fmap go . manyUntil p+  where+    go (x, y) = (T.pack x, y)+ -- | Like @sepBy1@ from Parsec, -- but does not fail if it @sep@ succeeds and @p@ fails.-sepBy1' :: (Stream s m t)-        => ParsecT s u m a+sepBy1' :: ParsecT s u m a         -> ParsecT s u m sep         -> ParsecT s u m [a] sepBy1' p sep = (:) <$> p <*> many (try $ sep >> p)@@ -344,26 +401,33 @@                                   return (return ()) -- (This version due to Andrew Pimlott on the Haskell mailing list.) -oneOfStrings' :: Stream s m Char => (Char -> Char -> Bool) -> [String] -> ParserT s st m String-oneOfStrings' _ []   = fail "no strings"-oneOfStrings' matches strs = try $ do+oneOfStrings' :: Stream s m Char => (Char -> Char -> Bool) -> [Text] -> ParserT s st m Text+oneOfStrings' f = fmap T.pack . oneOfStrings'' f . fmap T.unpack++-- TODO: This should be re-implemented in a Text-aware way+oneOfStrings'' :: Stream s m Char => (Char -> Char -> Bool) -> [String] -> ParserT s st m String+oneOfStrings'' _ []   = Prelude.fail "no strings"+oneOfStrings'' matches strs = try $ do   c <- anyChar   let strs' = [xs | (x:xs) <- strs, x `matches` c]   case strs' of-       []  -> fail "not found"-       _   -> (c:) <$> oneOfStrings' matches strs'+       []  -> Prelude.fail "not found"+       _   -> (c:) <$> oneOfStrings'' matches strs'                <|> if "" `elem` strs'                       then return [c]-                      else fail "not found"+                      else Prelude.fail "not found"  -- | Parses one of a list of strings.  If the list contains -- two strings one of which is a prefix of the other, the longer -- string will be matched if possible.-oneOfStrings :: Stream s m Char => [String] -> ParserT s st m String+oneOfStrings :: Stream s m Char => [Text] -> ParserT s st m Text oneOfStrings = oneOfStrings' (==)  -- | Parses one of a list of strings (tried in order), case insensitive.-oneOfStringsCI :: Stream s m Char => [String] -> ParserT s st m String++-- TODO: This will not be accurate with general Unicode (neither+-- Text.toLower nor Text.toCaseFold can be implemented with a map)+oneOfStringsCI :: Stream s m Char => [Text] -> ParserT s st m Text oneOfStringsCI = oneOfStrings' ciMatch   where ciMatch x y = toLower' x == toLower' y         -- this optimizes toLower by checking common ASCII case@@ -390,13 +454,13 @@ blankline = try $ skipSpaces >> newline  -- | Parses one or more blank lines and returns a string of newlines.-blanklines :: Stream s m Char => ParserT s st m [Char]-blanklines = many1 blankline+blanklines :: Stream s m Char => ParserT s st m Text+blanklines = T.pack <$> many1 blankline  -- | Gobble n spaces; if tabs are encountered, expand them -- and gobble some or all of their spaces, leaving the rest. gobbleSpaces :: (HasReaderOptions st, Monad m)-             => Int -> ParserT [Char] st m ()+             => Int -> ParserT Text st m () gobbleSpaces 0 = return () gobbleSpaces n   | n < 0     = error "gobbleSpaces called with negative number"@@ -404,18 +468,18 @@       char ' ' <|> eatOneSpaceOfTab       gobbleSpaces (n - 1) -eatOneSpaceOfTab :: (HasReaderOptions st, Monad m) => ParserT [Char] st m Char+eatOneSpaceOfTab :: (HasReaderOptions st, Monad m) => ParserT Text st m Char eatOneSpaceOfTab = do   char '\t'   tabstop <- getOption readerTabStop   inp <- getInput-  setInput $ replicate (tabstop - 1) ' ' ++ inp+  setInput $ T.replicate (tabstop - 1) " " <> inp   return ' '  -- | Gobble up to n spaces; if tabs are encountered, expand them -- and gobble some or all of their spaces, leaving the rest. gobbleAtMostSpaces :: (HasReaderOptions st, Monad m)-                   => Int -> ParserT [Char] st m Int+                   => Int -> ParserT Text st m Int gobbleAtMostSpaces 0 = return 0 gobbleAtMostSpaces n   | n < 0     = error "gobbleAtMostSpaces called with negative number"@@ -432,23 +496,26 @@   start >> notFollowedBy space >> many1Till parser end  -- | Parse string, case insensitive.-stringAnyCase :: Stream s m Char => [Char] -> ParserT s st m String-stringAnyCase [] = string ""-stringAnyCase (x:xs) = do+stringAnyCase :: Stream s m Char => Text -> ParserT s st m Text+stringAnyCase = fmap T.pack . stringAnyCase' . T.unpack++stringAnyCase' :: Stream s m Char => String -> ParserT s st m String+stringAnyCase' [] = string ""+stringAnyCase' (x:xs) = do   firstChar <- char (toUpper x) <|> char (toLower x)-  rest <- stringAnyCase xs+  rest <- stringAnyCase' xs   return (firstChar:rest)  -- | Parse contents of 'str' using 'parser' and return result.-parseFromString :: (Monad m, Stream s m Char, IsString s)+parseFromString :: (Stream s m Char, IsString s)                 => ParserT s st m r-                -> String+                -> Text                 -> ParserT s st m r parseFromString parser str = do   oldPos <- getPosition   setPosition $ initialPos "chunk"   oldInput <- getInput-  setInput $ fromString str+  setInput $ fromString $ T.unpack str   result <- parser   spaces   eof@@ -458,20 +525,21 @@  -- | Like 'parseFromString' but specialized for 'ParserState'. -- This resets 'stateLastStrPos', which is almost always what we want.-parseFromString' :: (Monad m, Stream s m Char, IsString s)-                 => ParserT s ParserState m a-                 -> String-                 -> ParserT s ParserState m a+parseFromString' :: (Stream s m Char, IsString s, HasLastStrPosition u)+                 => ParserT s u m a+                 -> Text+                 -> ParserT s u m a parseFromString' parser str = do-  oldStrPos <- stateLastStrPos <$> getState+  oldLastStrPos <- getLastStrPos <$> getState+  updateState $ setLastStrPos Nothing   res <- parseFromString parser str-  updateState $ \st -> st{ stateLastStrPos = oldStrPos }+  updateState $ setLastStrPos oldLastStrPos   return res  -- | Parse raw line block up to and including blank lines.-lineClump :: Monad m => ParserT [Char] st m String+lineClump :: Monad m => ParserT Text st m Text lineClump = blanklines-          <|> (unlines <$> many1 (notFollowedBy blankline >> anyLine))+          <|> (T.unlines <$> many1 (notFollowedBy blankline >> anyLine))  -- | Parse a string of characters between an open character -- and a close character, including text between balanced@@ -479,15 +547,15 @@ -- @charsInBalanced '(' ')' anyChar@ will parse "(hello (there))" -- and return "hello (there)". charsInBalanced :: Stream s m Char => Char -> Char -> ParserT s st m Char-                -> ParserT s st m String+                -> ParserT s st m Text charsInBalanced open close parser = try $ do   char open   let isDelim c = c == open || c == close-  raw <- many $  many1 (notFollowedBy (satisfy isDelim) >> parser)+  raw <- many $  T.pack <$> many1 (notFollowedBy (satisfy isDelim) >> parser)              <|> (do res <- charsInBalanced open close parser-                     return $ [open] ++ res ++ [close])+                     return $ T.singleton open <> res <> T.singleton close)   char close-  return $ concat raw+  return $ T.concat raw  -- old charsInBalanced would be: -- charsInBalanced open close (noneOf "\n" <|> char '\n' >> notFollowedBy blankline)@@ -526,17 +594,17 @@                 hundreds + nineties + fifties + forties + tens + nines +                 fives + fours + ones     if total == 0-       then fail "not a roman numeral"+       then Prelude.fail "not a roman numeral"        else return total  -- Parsers for email addresses and URIs  -- | Parses an email address; returns original and corresponding -- escaped mailto: URI.-emailAddress :: Stream s m Char => ParserT s st m (String, String)+emailAddress :: Stream s m Char => ParserT s st m (Text, Text) emailAddress = try $ toResult <$> mailbox <*> (char '@' *> domain)- where toResult mbox dom = let full = fromEntities $ mbox ++ '@':dom-                           in  (full, escapeURI $ "mailto:" ++ full)+ where toResult mbox dom = let full = fromEntities $ T.pack $ mbox ++ '@':dom+                           in  (full, escapeURI $ "mailto:" <> full)        mailbox           = intercalate "." <$> (emailWord `sepBy1'` dot)        domain            = intercalate "." <$> (subdomain `sepBy1'` dot)        dot               = char '.'@@ -554,14 +622,14 @@                               xs <- many (satisfy isEmailChar)                               return (x:xs)        isEmailChar c     = isAlphaNum c || isEmailPunct c-       isEmailPunct c    = c `elem` "!\"#$%&'*+-/=?^_{|}~;"+       isEmailPunct c    = T.any (== c) "!\"#$%&'*+-/=?^_{|}~;"  -uriScheme :: Stream s m Char => ParserT s st m String+uriScheme :: Stream s m Char => ParserT s st m Text uriScheme = oneOfStringsCI (Set.toList schemes)  -- | Parses a URI. Returns pair of original and URI-escaped version.-uri :: Stream s m Char => ParserT s st m (String, String)+uri :: Stream s m Char => ParserT s st m (Text, Text) uri = try $ do   scheme <- uriScheme   char ':'@@ -572,12 +640,12 @@   -- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation)   -- as a URL, while NOT picking up the closing paren in   -- (http://wikipedia.org). So we include balanced parens in the URL.-  str <- concat <$> many1 (uriChunkBetween '(' ')'-                       <|> uriChunkBetween '{' '}'-                       <|> uriChunkBetween '[' ']'-                       <|> uriChunk)-  str' <- option str $ char '/' >> return (str ++ "/")-  let uri' = scheme ++ ":" ++ fromEntities str'+  str <- T.concat <$> many1 (uriChunkBetween '(' ')'+                        <|> uriChunkBetween '{' '}'+                        <|> uriChunkBetween '[' ']'+                        <|> T.pack <$> uriChunk)+  str' <- option str $ char '/' >> return (str <> "/")+  let uri' = scheme <> ":" <> fromEntities str'   return (uri', escapeURI uri')   where     wordChar = alphaNum <|> oneOf "#$%+/@\\_-&="@@ -589,51 +657,54 @@            <|> entity            <|> try (punct <* lookAhead (void wordChar <|> void percentEscaped))     uriChunkBetween l r = try $ do chunk <- between (char l) (char r) uriChunk-                                   return ([l] ++ chunk ++ [r])+                                   return (T.pack $ [l] ++ chunk ++ [r]) -mathInlineWith :: Stream s m Char  => String -> String -> ParserT s st m String+mathInlineWith :: Stream s m Char  => Text -> Text -> ParserT s st m Text mathInlineWith op cl = try $ do-  string op+  textStr op   when (op == "$") $ notFollowedBy space-  words' <- many1Till (count 1 (noneOf " \t\n\\")+  words' <- many1Till (countChar 1 (noneOf " \t\n\\")                    <|> (char '\\' >>                            -- This next clause is needed because \text{..} can                            -- contain $, \(\), etc.                            (try (string "text" >>-                                 (("\\text" ++) <$> inBalancedBraces 0 ""))-                            <|>  (\c -> ['\\',c]) <$> anyChar))+                                 (("\\text" <>) <$> inBalancedBraces 0 ""))+                            <|>  (\c -> T.pack ['\\',c]) <$> anyChar))                    <|> do (blankline <* notFollowedBy' blankline) <|>                              (oneOf " \t" <* skipMany (oneOf " \t"))                           notFollowedBy (char '$')                           return " "-                    ) (try $ string cl)+                    ) (try $ textStr cl)   notFollowedBy digit  -- to prevent capture of $5-  return $ trimMath $ concat words'+  return $ trimMath $ T.concat words'  where-  inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String-  inBalancedBraces 0 "" = do+  inBalancedBraces :: Stream s m Char => Int -> Text -> ParserT s st m Text+  inBalancedBraces n = fmap T.pack . inBalancedBraces' n . T.unpack+  +  inBalancedBraces' :: Stream s m Char => Int -> String -> ParserT s st m String+  inBalancedBraces' 0 "" = do     c <- anyChar     if c == '{'-       then inBalancedBraces 1 "{"+       then inBalancedBraces' 1 "{"        else mzero-  inBalancedBraces 0 s = return $ reverse s-  inBalancedBraces numOpen ('\\':xs) = do+  inBalancedBraces' 0 s = return $ reverse s+  inBalancedBraces' numOpen ('\\':xs) = do     c <- anyChar-    inBalancedBraces numOpen (c:'\\':xs)-  inBalancedBraces numOpen xs = do+    inBalancedBraces' numOpen (c:'\\':xs)+  inBalancedBraces' numOpen xs = do     c <- anyChar     case c of-         '}' -> inBalancedBraces (numOpen - 1) (c:xs)-         '{' -> inBalancedBraces (numOpen + 1) (c:xs)-         _   -> inBalancedBraces numOpen (c:xs)+         '}' -> inBalancedBraces' (numOpen - 1) (c:xs)+         '{' -> inBalancedBraces' (numOpen + 1) (c:xs)+         _   -> inBalancedBraces' numOpen (c:xs) -mathDisplayWith :: Stream s m Char => String -> String -> ParserT s st m String-mathDisplayWith op cl = try $ do-  string op-  many1Till (noneOf "\n" <|> (newline <* notFollowedBy' blankline)) (try $ string cl)+mathDisplayWith :: Stream s m Char => Text -> Text -> ParserT s st m Text+mathDisplayWith op cl = try $ fmap T.pack $ do+  textStr op+  many1Till (noneOf "\n" <|> (newline <* notFollowedBy' blankline)) (try $ textStr cl)  mathDisplay :: (HasReaderOptions st, Stream s m Char)-            => ParserT s st m String+            => ParserT s st m Text mathDisplay =       (guardEnabled Ext_tex_math_dollars >> mathDisplayWith "$$" "$$")   <|> (guardEnabled Ext_tex_math_single_backslash >>@@ -642,7 +713,7 @@        mathDisplayWith "\\\\[" "\\\\]")  mathInline :: (HasReaderOptions st , Stream s m Char)-           => ParserT s st m String+           => ParserT s st m Text mathInline =       (guardEnabled Ext_tex_math_dollars >> mathInlineWith "$" "$")   <|> (guardEnabled Ext_tex_math_single_backslash >>@@ -666,8 +737,8 @@ -- | Applies a parser and returns the raw string that was parsed, -- along with the value produced by the parser. withRaw :: Monad m-        => ParsecT [Char] st m a-        -> ParsecT [Char] st m (a, [Char])+        => ParsecT Text st m a+        -> ParsecT Text st m (a, Text) withRaw parser = do   pos1 <- getPosition   inp <- getInput@@ -675,11 +746,11 @@   pos2 <- getPosition   let (l1,c1) = (sourceLine pos1, sourceColumn pos1)   let (l2,c2) = (sourceLine pos2, sourceColumn pos2)-  let inplines = take ((l2 - l1) + 1) $ lines inp+  let inplines = take ((l2 - l1) + 1) $ T.lines inp   let raw = case inplines of                 []  -> ""-                [l] -> take (c2 - c1) l-                ls  -> unlines (init ls) ++ take (c2 - 1) (last ls)+                [l] -> T.take (c2 - c1) l+                ls  -> T.unlines (init ls) <> T.take (c2 - 1) (last ls)   return (result, raw)  -- | Parses backslash, then applies character parser.@@ -699,7 +770,7 @@                   _          -> ent ++ ";"   case lookupEntity ent' of        Just (c : _) -> return c-       _            -> fail "entity not found"+       _            -> Prelude.fail "entity not found"  -- | Parses an uppercase roman numeral and returns (UpperRoman, number). upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)@@ -717,7 +788,7 @@ decimal :: Stream s m Char => ParserT s st m (ListNumberStyle, Int) decimal = do   num <- many1 digit-  return (Decimal, fromMaybe 1 $ safeRead num)+  return (Decimal, fromMaybe 1 $ safeRead $ T.pack num)  -- | Parses a '@' and optional label and -- returns (DefaultStyle, [next example number]).  The next@@ -727,10 +798,10 @@            => ParserT s ParserState m (ListNumberStyle, Int) exampleNum = do   char '@'-  lab <- many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))+  lab <- T.pack <$> many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))   st <- getState   let num = stateNextExample st-  let newlabels = if null lab+  let newlabels = if T.null lab                      then stateExamples st                      else M.insert lab num $ stateExamples st   updateState $ \s -> s{ stateNextExample = num + 1@@ -826,25 +897,25 @@ charRef :: Stream s m Char => ParserT s st m Inline charRef = do   c <- characterReference-  return $ Str [c]+  return $ Str $ T.singleton c -lineBlockLine :: Monad m => ParserT [Char] st m String+lineBlockLine :: Monad m => ParserT Text st m Text lineBlockLine = try $ do   char '|'   char ' '-  white <- many (spaceChar >> return '\160')+  white <- T.pack <$> many (spaceChar >> return '\160')   notFollowedBy newline   line <- anyLine   continuations <- many (try $ char ' ' >> anyLine)-  return $ white ++ unwords (line : continuations)+  return $ white <> T.unwords (line : continuations)  blankLineBlockLine :: Stream s m Char => ParserT s st m Char blankLineBlockLine = try (char '|' >> blankline)  -- | Parses an RST-style line block and returns a list of strings.-lineBlockLines :: Monad m => ParserT [Char] st m [String]+lineBlockLines :: Monad m => ParserT Text st m [Text] lineBlockLines = try $ do-  lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))+  lines' <- many1 (lineBlockLine <|> (T.singleton <$> blankLineBlockLine))   skipMany blankline   return lines' @@ -910,7 +981,8 @@ -- (which may be grid), then the rows, -- which may be grid, separated by blank lines, and -- ending with a footer (dashed line followed by blank line).-gridTableWith :: (Stream s m Char, HasReaderOptions st, Monad mf, IsString s)+gridTableWith :: (Stream s m Char, HasReaderOptions st, HasLastStrPosition st,+                  Monad mf, IsString s)               => ParserT s st m (mf Blocks)  -- ^ Block list parser               -> Bool                        -- ^ Headerless table               -> ParserT s st m (mf Blocks)@@ -918,7 +990,8 @@   tableWith (gridTableHeader headless blocks) (gridTableRow blocks)             (gridTableSep '-') gridTableFooter -gridTableWith' :: (Stream s m Char, HasReaderOptions st, Monad mf, IsString s)+gridTableWith' :: (Stream s m Char, HasReaderOptions st, HasLastStrPosition st,+                   Monad mf, IsString s)                => ParserT s st m (mf Blocks)  -- ^ Block list parser                -> Bool                        -- ^ Headerless table                -> ParserT s st m (TableComponents mf)@@ -926,9 +999,9 @@   tableWith' (gridTableHeader headless blocks) (gridTableRow blocks)              (gridTableSep '-') gridTableFooter -gridTableSplitLine :: [Int] -> String -> [String]+gridTableSplitLine :: [Int] -> Text -> [Text] gridTableSplitLine indices line = map removeFinalBar $ tail $-  splitStringByIndices (init indices) $ trimr line+  splitTextByIndices (init indices) $ trimr line  gridPart :: Stream s m Char => Char -> ParserT s st m ((Int, Int), Alignment) gridPart ch = do@@ -948,16 +1021,17 @@ gridDashedLines :: Stream s m Char => Char -> ParserT s st m [((Int, Int), Alignment)] gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline -removeFinalBar :: String -> String-removeFinalBar =-  reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse+removeFinalBar :: Text -> Text+removeFinalBar = T.dropWhileEnd go . T.dropWhileEnd (=='|')+  where+    go c = T.any (== c) " \t"  -- | Separator between rows of grid table. gridTableSep :: Stream s m Char => Char -> ParserT s st m Char gridTableSep ch = try $ gridDashedLines ch >> return '\n'  -- | Parse header for a grid table.-gridTableHeader :: (Stream s m Char, Monad mf, IsString s)+gridTableHeader :: (Stream s m Char, Monad mf, IsString s, HasLastStrPosition st)                 => Bool -- ^ Headerless table                 -> ParserT s st m (mf Blocks)                 -> ParserT s st m (mf [Blocks], [Alignment], [Int])@@ -968,7 +1042,7 @@                     then return $ repeat ""                     else many1                          (notFollowedBy (gridTableSep '=') >> char '|' >>-                           many1Till anyChar newline)+                           T.pack <$> many1Till anyChar newline)   underDashes <- if headless                     then return dashes                     else gridDashedLines '='@@ -978,66 +1052,67 @@   let aligns   = map snd underDashes   let rawHeads = if headless                     then replicate (length underDashes) ""-                    else map (unlines . map trim) $ transpose+                    else map (T.unlines . map trim) $ transpose                        $ map (gridTableSplitLine indices) rawContent-  heads <- sequence <$> mapM (parseFromString blocks . trim) rawHeads+  heads <- sequence <$> mapM (parseFromString' blocks . trim) rawHeads   return (heads, aligns, indices) -gridTableRawLine :: Stream s m Char => [Int] -> ParserT s st m [String]+gridTableRawLine :: Stream s m Char => [Int] -> ParserT s st m [Text] gridTableRawLine indices = do   char '|'   line <- many1Till anyChar newline-  return (gridTableSplitLine indices line)+  return (gridTableSplitLine indices $ T.pack line)  -- | Parse row of grid table.-gridTableRow :: (Stream s m Char, Monad mf, IsString s)+gridTableRow :: (Stream s m Char, Monad mf, IsString s, HasLastStrPosition st)              => ParserT s st m (mf Blocks)              -> [Int]              -> ParserT s st m (mf [Blocks]) gridTableRow blocks indices = do   colLines <- many1 (gridTableRawLine indices)-  let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $+  let cols = map ((<> "\n") . T.unlines . removeOneLeadingSpace) $                transpose colLines       compactifyCell bs = case compactify [bs] of                             []  -> mempty                             x:_ -> x-  cells <- sequence <$> mapM (parseFromString blocks) cols+  cells <- sequence <$> mapM (parseFromString' blocks) cols   return $ fmap (map compactifyCell) cells -removeOneLeadingSpace :: [String] -> [String]+removeOneLeadingSpace :: [Text] -> [Text] removeOneLeadingSpace xs =   if all startsWithSpace xs-     then map (drop 1) xs+     then map (T.drop 1) xs      else xs-   where startsWithSpace ""    = True-         startsWithSpace (y:_) = y == ' '+   where startsWithSpace t = case T.uncons t of+           Nothing     -> True+           Just (c, _) -> c == ' '  -- | Parse footer for a grid table.-gridTableFooter :: Stream s m Char => ParserT s st m [Char]+gridTableFooter :: Stream s m Char => ParserT s st m Text gridTableFooter = blanklines  ---  -- | Removes the ParsecT layer from the monad transformer stack-readWithM :: (Monad m, Stream s m Char, ToString s)+readWithM :: (Stream s m Char, ToText s)           => ParserT s st m a    -- ^ parser           -> st                  -- ^ initial state           -> s                   -- ^ input           -> m (Either PandocError a) readWithM parser state input =-    mapLeft (PandocParsecError $ toString input) `liftM` runParserT parser state "source" input+    mapLeft (PandocParsecError $ toText input) `liftM` runParserT parser state "source" input  -- | Parse a string with a given parser and state-readWith :: Parser [Char] st a+readWith :: Parser Text st a          -> st-         -> String+         -> Text          -> Either PandocError a readWith p t inp = runIdentity $ readWithM p t inp  -- | Parse a string with @parser@ (for testing). testStringWith :: Show a-               => ParserT [Char] ParserState Identity a-               -> [Char]+               => ParserT Text ParserState Identity a+               -> Text                -> IO () testStringWith parser str = UTF8.putStrLn $ show $                             readWith parser defaultParserState str@@ -1048,6 +1123,7 @@       stateParserContext     :: ParserContext, -- ^ Inside list?       stateQuoteContext      :: QuoteContext,  -- ^ Inside quoted environment?       stateAllowLinks        :: Bool,          -- ^ Allow parsing of links+      stateAllowLineBreaks   :: Bool,          -- ^ Allow parsing of line breaks       stateMaxNestingLevel   :: Int,           -- ^ Max # of nested Strong/Emph       stateLastStrPos        :: Maybe SourcePos, -- ^ Position after last str parsed       stateKeys              :: KeyTable,      -- ^ List of reference keys@@ -1055,23 +1131,23 @@       stateSubstitutions     :: SubstTable,    -- ^ List of substitution references       stateNotes             :: NoteTable,     -- ^ List of notes (raw bodies)       stateNotes'            :: NoteTable',    -- ^ List of notes (parsed bodies)-      stateNoteRefs          :: Set.Set String, -- ^ List of note references used+      stateNoteRefs          :: Set.Set Text, -- ^ List of note references used       stateMeta              :: Meta,          -- ^ Document metadata       stateMeta'             :: F Meta,        -- ^ Document metadata-      stateCitations         :: M.Map String String, -- ^ RST-style citations+      stateCitations         :: M.Map Text Text, -- ^ RST-style citations       stateHeaderTable       :: [HeaderType],  -- ^ Ordered list of header types used-      stateIdentifiers       :: Set.Set String, -- ^ Header identifiers used+      stateIdentifiers       :: Set.Set Text, -- ^ Header identifiers used       stateNextExample       :: Int,           -- ^ Number of next example-      stateExamples          :: M.Map String Int, -- ^ Map from example labels to numbers+      stateExamples          :: M.Map Text Int, -- ^ Map from example labels to numbers       stateMacros            :: M.Map Text Macro, -- ^ Table of macros defined so far-      stateRstDefaultRole    :: String,        -- ^ Current rST default interpreted text role-      stateRstCustomRoles    :: M.Map String (String, Maybe String, Attr), -- ^ Current rST custom text roles+      stateRstDefaultRole    :: Text,        -- ^ Current rST default interpreted text role+      stateRstCustomRoles    :: M.Map Text (Text, Maybe Text, Attr), -- ^ Current rST custom text roles       -- Triple represents: 1) Base role, 2) Optional format (only for :raw:       -- roles), 3) Additional classes (rest of Attr is unused)).       stateCaption           :: Maybe Inlines, -- ^ Caption in current environment-      stateInHtmlBlock       :: Maybe String,  -- ^ Tag type of HTML block being parsed+      stateInHtmlBlock       :: Maybe Text,  -- ^ Tag type of HTML block being parsed       stateFencedDivLevel    :: Int,           -- ^ Depth of fenced div-      stateContainers        :: [String],      -- ^ parent include files+      stateContainers        :: [Text],      -- ^ parent include files       stateLogMessages       :: [LogMessage],  -- ^ log messages       stateMarkdownAttribute :: Bool         -- ^ True if in markdown=1 context     }@@ -1110,8 +1186,8 @@     return result  class HasIdentifierList st where-  extractIdentifierList  :: st -> Set.Set String-  updateIdentifierList   :: (Set.Set String -> Set.Set String) -> st -> st+  extractIdentifierList  :: st -> Set.Set Text+  updateIdentifierList   :: (Set.Set Text -> Set.Set Text) -> st -> st  instance HasIdentifierList ParserState where   extractIdentifierList     = stateIdentifiers@@ -1126,11 +1202,11 @@   updateMacros f st    = st{ stateMacros = f $ stateMacros st }  class HasLastStrPosition st where-  setLastStrPos  :: SourcePos -> st -> st+  setLastStrPos  :: Maybe SourcePos -> st -> st   getLastStrPos  :: st -> Maybe SourcePos  instance HasLastStrPosition ParserState where-  setLastStrPos pos st = st{ stateLastStrPos = Just pos }+  setLastStrPos pos st = st{ stateLastStrPos = pos }   getLastStrPos st     = stateLastStrPos st  class HasLogMessages st where@@ -1142,8 +1218,8 @@   getLogMessages st = reverse $ stateLogMessages st  class HasIncludeFiles st where-  getIncludeFiles :: st -> [String]-  addIncludeFile :: String -> st -> st+  getIncludeFiles :: st -> [Text]+  addIncludeFile :: Text -> st -> st   dropLatestIncludeFile :: st -> st  instance HasIncludeFiles ParserState where@@ -1157,6 +1233,7 @@                   stateParserContext   = NullState,                   stateQuoteContext    = NoQuote,                   stateAllowLinks      = True,+                  stateAllowLineBreaks = True,                   stateMaxNestingLevel = 6,                   stateLastStrPos      = Nothing,                   stateKeys            = M.empty,@@ -1204,7 +1281,7 @@  -- | Update the position on which the last string ended. updateLastStrPos :: (Stream s m a, HasLastStrPosition st) => ParserT s st m ()-updateLastStrPos = getPosition >>= updateState . setLastStrPos+updateLastStrPos = getPosition >>= updateState . setLastStrPos . Just  -- | Whether we are right after the end of a string. notAfterString :: (Stream s m a, HasLastStrPosition st) => ParserT s st m Bool@@ -1229,17 +1306,21 @@     | NoQuote         -- ^ Used when not parsing inside quotes     deriving (Eq, Show) -type NoteTable = [(String, String)]+type NoteTable = [(Text, Text)] -type NoteTable' = M.Map String (SourcePos, F Blocks)+type NoteTable' = M.Map Text (SourcePos, F Blocks) -- used in markdown reader -newtype Key = Key String deriving (Show, Read, Eq, Ord)+newtype Key = Key Text deriving (Show, Read, Eq, Ord) -toKey :: String -> Key-toKey = Key . map toLower . unwords . words . unbracket-  where unbracket ('[':xs) | "]" `isSuffixOf` xs = take (length xs - 1) xs-        unbracket xs       = xs+toKey :: Text -> Key+toKey = Key . T.toLower . T.unwords . T.words . unbracket+  where unbracket t+          | Just ('[', t') <- T.uncons t+          , Just (t'', ']') <- T.unsnoc t'+          = t''+          | otherwise+          = t  type KeyTable = M.Map Key (Target, Attr) @@ -1247,7 +1328,7 @@  --  | Add header to the list of headers in state, together --  with its associated identifier.  If the identifier is null---  and the auto_identifers extension is set, generate a new+--  and the auto_identifiers extension is set, generate a new --  unique identifier, and update the list of identifiers --  in state.  Issue a warning if an explicit identifier --  is encountered that duplicates an earlier identifier@@ -1258,17 +1339,17 @@ registerHeader (ident,classes,kvs) header' = do   ids <- extractIdentifierList <$> getState   exts <- getOption readerExtensions-  if null ident && Ext_auto_identifiers `extensionEnabled` exts+  if T.null ident && Ext_auto_identifiers `extensionEnabled` exts      then do        let id' = uniqueIdent exts (B.toList header') ids        let id'' = if Ext_ascii_identifiers `extensionEnabled` exts-                     then mapMaybe toAsciiChar id'+                     then T.pack $ mapMaybe toAsciiChar $ T.unpack id'                      else id'        updateState $ updateIdentifierList $ Set.insert id'        updateState $ updateIdentifierList $ Set.insert id''        return (id'',classes,kvs)      else do-        unless (null ident) $ do+        unless (T.null ident) $ do           when (ident `Set.member` ids) $ do             pos <- getPosition             logMessage $ DuplicateIdentifier ident pos@@ -1309,9 +1390,9 @@                      -> ParserT s st m () failIfInQuoteContext context = do   context' <- getQuoteContext-  when (context' == context) $ fail "already inside quotes"+  when (context' == context) $ Prelude.fail "already inside quotes" -charOrRef :: Stream s m Char => String -> ParserT s st m Char+charOrRef :: Stream s m Char => [Char] -> ParserT s st m Char charOrRef cs =   oneOf cs <|> try (do c <- characterReference                        guard (c `elem` cs)@@ -1376,7 +1457,7 @@   return res  citeKey :: (Stream s m Char, HasLastStrPosition st)-        => ParserT s st m (Bool, String)+        => ParserT s st m (Bool, Text) citeKey = try $ do   guard =<< notAfterString   suppress_author <- option False (True <$ char '-')@@ -1387,15 +1468,15 @@   rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/") <|>                  try (oneOf ":/" <* lookAhead (char '/'))   let key = firstChar:rest-  return (suppress_author, key)+  return (suppress_author, T.pack key)   token :: (Stream s m t)-      => (t -> String)+      => (t -> Text)       -> (t -> SourcePos)       -> (t -> Maybe a)       -> ParsecT s st m a-token pp pos match = tokenPrim pp (\_ t _ -> pos t) match+token pp pos match = tokenPrim (T.unpack . pp) (\_ t _ -> pos t) match  infixr 5 <+?> (<+?>) :: (Monoid a) => ParserT s st m a -> ParserT s st m a -> ParserT s st m a@@ -1406,27 +1487,27 @@   where     ident' = fromMaybe ident (lookup "id" kvs)     cls'   = case lookup "class" kvs of-               Just cl -> words cl+               Just cl -> T.words cl                Nothing -> cls     kvs'  = filter (\(k,_) -> k /= "id" || k /= "class") kvs -insertIncludedFile' :: (PandocMonad m, HasIncludeFiles st, Monad mf)-                    => ParserT [a] st m (mf Blocks)-                    -> (String -> [a])+insertIncludedFile' :: (PandocMonad m, HasIncludeFiles st)+                    => ParserT a st m (mf Blocks)+                    -> (Text -> a)                     -> [FilePath] -> FilePath-                    -> ParserT [a] st m (mf Blocks)+                    -> ParserT a st m (mf Blocks) insertIncludedFile' blocks totoks dirs f = do   oldPos <- getPosition   oldInput <- getInput   containers <- getIncludeFiles <$> getState-  when (f `elem` containers) $-    throwError $ PandocParseError $ "Include file loop at " ++ show oldPos-  updateState $ addIncludeFile f+  when (T.pack f `elem` containers) $+    throwError $ PandocParseError $ T.pack $ "Include file loop at " ++ show oldPos+  updateState $ addIncludeFile $ T.pack f   mbcontents <- readFileFromDirs dirs f   contents <- case mbcontents of                    Just s -> return s                    Nothing -> do-                     report $ CouldNotLoadIncludeFile f oldPos+                     report $ CouldNotLoadIncludeFile (T.pack f) oldPos                      return ""   setPosition $ newPos f 1 1   setInput $ totoks contents@@ -1440,7 +1521,7 @@ -- @PandocParseError@. insertIncludedFile :: (PandocMonad m, HasIncludeFiles st)                    => ParserT [a] st m Blocks-                   -> (String -> [a])+                   -> (Text -> [a])                    -> [FilePath] -> FilePath                    -> ParserT [a] st m Blocks insertIncludedFile blocks totoks dirs f =@@ -1449,7 +1530,7 @@ -- | Parse content of include file as future blocks. Circular includes result in -- an @PandocParseError@. insertIncludedFileF :: (PandocMonad m, HasIncludeFiles st)-                    => ParserT String st m (Future st Blocks)+                    => ParserT Text st m (Future st Blocks)                     -> [FilePath] -> FilePath-                    -> ParserT String st m (Future st Blocks)+                    -> ParserT Text st m (Future st Blocks) insertIncludedFileF p = insertIncludedFile' p id
− src/Text/Pandoc/Pretty.hs
@@ -1,543 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP                        #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{- |-   Module      : Text.Pandoc.Pretty-   Copyright   : Copyright (C) 2010-2019 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-     , blanklines-     , space-     , text-     , char-     , prefixed-     , flush-     , nest-     , hang-     , beforeNonBlank-     , nowrap-     , afterBreak-     , offset-     , minOffset-     , height-     , lblock-     , cblock-     , rblock-     , (<>)-     , (<+>)-     , ($$)-     , ($+$)-     , isEmpty-     , empty-     , cat-     , hcat-     , hsep-     , vcat-     , vsep-     , nestle-     , chomp-     , inside-     , braces-     , brackets-     , parens-     , quotes-     , doubleQuotes-     , charWidth-     , realLength-     )--where-import Prelude-import Control.Monad-import Control.Monad.State.Strict-import Data.Char (isSpace)-import Data.Foldable (toList)-import Data.List (intersperse, foldl')-import Data.Sequence (Seq, ViewL (..), fromList, mapWithIndex, singleton, viewl,-                      (<|))-import qualified Data.Sequence as Seq-import Data.String--data 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-       | BeforeNonBlank Doc-       | Flush Doc-       | BreakingSpace-       | AfterBreak String-       | CarriageReturn-       | NewLine-       | BlankLines Int  -- number of blank lines-       deriving (Show, Eq)--newtype Doc = Doc { unDoc :: Seq D }-              deriving (Semigroup, Monoid, Show, Eq)--instance IsString Doc where-  fromString = text--isBlank :: D -> Bool-isBlank BreakingSpace  = True-isBlank CarriageReturn = True-isBlank NewLine        = True-isBlank (BlankLines _) = True-isBlank (Text _ (c:_)) = isSpace c-isBlank _              = False---- | True if the document is empty.-isEmpty :: Doc -> Bool-isEmpty = Seq.null . unDoc---- | The empty document.-empty :: Doc-empty = mempty---- | 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.-infixr 6 <+>-(<+>) :: Doc -> Doc -> Doc-(<+>) x y-  | isEmpty x = y-  | isEmpty y = x-  | otherwise = x <> space <> y---- | Same as 'cat', but putting breakable spaces between the--- 'Doc's.-hsep :: [Doc] -> Doc-hsep = foldr (<+>) empty--infixr 5 $$--- | @a $$ b@ puts @a@ above @b@.-($$) :: Doc -> Doc -> Doc-($$) x y-  | isEmpty x = y-  | isEmpty y = x-  | otherwise = x <> cr <> y--infixr 5 $+$--- | @a $+$ b@ puts @a@ above @b@, with a blank line between.-($+$) :: Doc -> Doc -> Doc-($+$) x y-  | isEmpty x = y-  | isEmpty y = x-  | otherwise = x <> blankline <> y---- | List version of '$$'.-vcat :: [Doc] -> Doc-vcat = foldr ($$) empty---- | List version of '$+$'.-vsep :: [Doc] -> Doc-vsep = foldr ($+$) empty---- | Removes leading blank lines from a 'Doc'.-nestle :: Doc -> Doc-nestle (Doc d) = Doc $ go d-  where go x = case viewl x of-               (BlankLines _ :< rest) -> go rest-               (NewLine :< rest)      -> go rest-               _                      -> x---- | Chomps trailing blank space off of a 'Doc'.-chomp :: Doc -> Doc-chomp d = Doc (fromList dl')-  where dl = toList (unDoc d)-        dl' = reverse $ go $ reverse dl-        go []                    = []-        go (BreakingSpace : xs)  = go xs-        go (CarriageReturn : xs) = go xs-        go (NewLine : xs)        = go xs-        go (BlankLines _ : xs)   = go xs-        go (Prefixed s d' : xs)  = Prefixed s (chomp d') : xs-        go xs                    = xs--outp :: (IsString a) => Int -> String -> DocState a-outp off s | off < 0 = do  -- offset < 0 means newline characters-  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 + realLength pref }-  let numnewlines = length $ takeWhile (=='\n') $ reverse s-  modify $ \st -> st { output = fromString s : output st-                     , column = 0-                     , newlines = newlines st + numnewlines }-outp off s = do           -- offset >= 0 (0 might be combining char)-  st' <- get-  let pref = prefix st'-  when (column st' == 0 && usePrefix st' && not (null pref)) $-    modify $ \st -> st{ output = fromString pref : output st-                    , column = column st + realLength 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 :: (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 . dropWhile (== BreakingSpace) . toList . unDoc--data IsBlock = IsBlock Int [String]---- This would be nicer with a pattern synonym--- pattern VBlock i s <- mkIsBlock -> Just (IsBlock ..)--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 (BeforeNonBlank d : xs) =-  case xs of-    (x:_) | isBlank x -> renderList xs-          | otherwise -> renderDoc d >> renderList xs-    []                -> renderList xs--renderList [BlankLines _] = return ()--renderList (BlankLines m : BlankLines n : xs) =-  renderList (BlankLines (max m n) : xs)--renderList (BlankLines num : BreakingSpace : xs) =-  renderList (BlankLines num : xs)--renderList (BlankLines num : xs) = do-  st <- get-  case output st of-     _ | newlines st > num -> return ()-       | otherwise -> replicateM_ (1 + num - newlines st) (outp (-1) "\n")-  renderList xs--renderList (CarriageReturn : BlankLines m : xs) =-  renderList (BlankLines m : xs)--renderList (CarriageReturn : BreakingSpace : xs) =-  renderList (CarriageReturn : 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 : BlankLines n : xs) = renderList (BlankLines n:xs)-renderList (BreakingSpace : BreakingSpace : xs) = renderList (BreakingSpace:xs)-renderList (BreakingSpace : xs) = do-  let isText (Text _ _)     = True-      isText (Block _ _)    = True-      isText (AfterBreak _) = True-      isText _              = False-  let isBreakingSpace BreakingSpace = True-      isBreakingSpace _             = False-  let xs' = dropWhile isBreakingSpace xs-  let next = takeWhile isText xs'-  st <- get-  let off = foldl' (+) 0 $ 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 (AfterBreak s : xs) = do-  st <- get-  when (newlines st > 0) $ outp (realLength s) s-  renderList xs--renderList (Block i1 s1 : Block i2 s2  : xs) =-  renderList (mergeBlocks False (IsBlock i1 s1) (IsBlock i2 s2) : xs)--renderList (Block i1 s1 : BreakingSpace : Block i2 s2 : xs) =-  renderList (mergeBlocks True (IsBlock i1 s1) (IsBlock i2 s2) : xs)--renderList (Block _width lns : xs) = do-  st <- get-  let oldPref = prefix st-  case column st - realLength oldPref of-        n | n > 0 -> modify $ \s -> s{ prefix = oldPref ++ replicate n ' ' }-        _ -> return ()-  renderList $ intersperse CarriageReturn (map (Text 0) lns)-  modify $ \s -> s{ prefix = oldPref }-  renderList xs--mergeBlocks :: Bool -> IsBlock -> IsBlock -> D-mergeBlocks addSpace (IsBlock w1 lns1) (IsBlock w2 lns2) =-  Block (w1 + w2 + if addSpace then 1 else 0) $-     zipWith (\l1 l2 -> pad w1 l1 ++ l2) lns1' (map sp lns2')-    where (lns1', lns2') = case (length lns1, length lns2) of-                                (x, y) | x > y -> (lns1,-                                                   lns2 ++ replicate (x - y) "")-                                       | x < y -> (lns1 ++ replicate (y - x) "",-                                                   lns2)-                                       | otherwise -> (lns1, lns2)-          pad n s = s ++ replicate (n - realLength s) ' '-          sp "" = ""-          sp xs = if addSpace then ' ' : xs else xs--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 -> Seq D-        toChunks [] = mempty-        toChunks s = case break (=='\n') s of-                          ([], _:ys) -> NewLine <| toChunks ys-                          (xs, _:ys) -> Text (realLength xs) xs <|-                                            (NewLine <| toChunks ys)-                          (xs, [])      -> singleton $ Text (realLength 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@.-blankline :: Doc-blankline = Doc $ singleton (BlankLines 1)---- | Inserts blank lines unless they exist already.--- (@blanklines m <> blanklines n@ has the same effect as @blanklines (max m n)@.-blanklines :: Int -> Doc-blanklines n = Doc $ singleton (BlankLines n)---- | 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---- | @beforeNonBlank d@ conditionally includes @d@ unless it is--- followed by blank space.-beforeNonBlank :: Doc -> Doc-beforeNonBlank d = Doc $ singleton (BeforeNonBlank d)---- | Makes a 'Doc' non-reflowable.-nowrap :: Doc -> Doc-nowrap doc = Doc $ mapWithIndex replaceSpace $ unDoc doc-  where replaceSpace _ BreakingSpace = Text 1 " "-        replaceSpace _ x             = x---- | Content to print only if it comes at the beginning of a line,--- to be used e.g. for escaping line-initial `.` in roff man.-afterBreak :: String -> Doc-afterBreak s = Doc $ singleton (AfterBreak s)---- | Returns the width of a 'Doc'.-offset :: Doc -> Int-offset d = maximum (0: map realLength (lines $ render Nothing d))---- | Returns the minimal width of a 'Doc' when reflowed at breakable spaces.-minOffset :: Doc -> Int-minOffset d = maximum (0: map realLength (lines $ render (Just 0) d))---- | @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 - realLength s) ' ' ++ s) w---- | Like 'lblock' but aligned centered.-cblock :: Int -> Doc -> Doc-cblock w = block (\s -> replicate ((w - realLength s) `div` 2) ' ' ++ s) w---- | Returns the height of a block or other 'Doc'.-height :: Doc -> Int-height = length . lines . render Nothing--block :: (String -> String) -> Int -> Doc -> Doc-block filler width d-  | width < 1 && not (isEmpty d) = block filler 1 d-  | otherwise                    = Doc $ singleton $ Block width $ map filler-                                 $ chop width $ render (Just width) d--chop :: Int -> String -> [String]-chop _ [] = []-chop n cs = case break (=='\n') cs of-                  (xs, ys)     -> if len <= n-                                     then case ys of-                                             []     -> [xs]-                                             ['\n'] -> [xs]-                                             (_:zs) -> xs : chop n zs-                                     else take n xs : chop n (drop n xs ++ ys)-                                   where len = realLength 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 '"')---- | Returns width of a character in a monospace font:  0 for a combining--- character, 1 for a regular character, 2 for an East Asian wide character.-charWidth :: Char -> Int-charWidth c =-  case c of-      _ | c <  '\x0300'                    -> 1-        | c >= '\x0300' && c <= '\x036F'   -> 0  -- combining-        | c >= '\x0370' && c <= '\x10FC'   -> 1-        | c >= '\x1100' && c <= '\x115F'   -> 2-        | c >= '\x1160' && c <= '\x11A2'   -> 1-        | c >= '\x11A3' && c <= '\x11A7'   -> 2-        | c >= '\x11A8' && c <= '\x11F9'   -> 1-        | c >= '\x11FA' && c <= '\x11FF'   -> 2-        | c >= '\x1200' && c <= '\x2328'   -> 1-        | c >= '\x2329' && c <= '\x232A'   -> 2-        | c >= '\x232B' && c <= '\x2E31'   -> 1-        | c >= '\x2E80' && c <= '\x303E'   -> 2-        | c == '\x303F'                    -> 1-        | c >= '\x3041' && c <= '\x3247'   -> 2-        | c >= '\x3248' && c <= '\x324F'   -> 1 -- ambiguous-        | c >= '\x3250' && c <= '\x4DBF'   -> 2-        | c >= '\x4DC0' && c <= '\x4DFF'   -> 1-        | c >= '\x4E00' && c <= '\xA4C6'   -> 2-        | c >= '\xA4D0' && c <= '\xA95F'   -> 1-        | c >= '\xA960' && c <= '\xA97C'   -> 2-        | c >= '\xA980' && c <= '\xABF9'   -> 1-        | c >= '\xAC00' && c <= '\xD7FB'   -> 2-        | c >= '\xD800' && c <= '\xDFFF'   -> 1-        | c >= '\xE000' && c <= '\xF8FF'   -> 1 -- ambiguous-        | c >= '\xF900' && c <= '\xFAFF'   -> 2-        | c >= '\xFB00' && c <= '\xFDFD'   -> 1-        | c >= '\xFE00' && c <= '\xFE0F'   -> 1 -- ambiguous-        | c >= '\xFE10' && c <= '\xFE19'   -> 2-        | c >= '\xFE20' && c <= '\xFE26'   -> 1-        | c >= '\xFE30' && c <= '\xFE6B'   -> 2-        | c >= '\xFE70' && c <= '\xFEFF'   -> 1-        | c >= '\xFF01' && c <= '\xFF60'   -> 2-        | c >= '\xFF61' && c <= '\x16A38'  -> 1-        | c >= '\x1B000' && c <= '\x1B001' -> 2-        | c >= '\x1D000' && c <= '\x1F1FF' -> 1-        | c >= '\x1F200' && c <= '\x1F251' -> 2-        | c >= '\x1F300' && c <= '\x1F773' -> 1-        | c >= '\x20000' && c <= '\x3FFFD' -> 2-        | otherwise                        -> 1---- | Get real length of string, taking into account combining and double-wide--- characters.-realLength :: String -> Int-realLength = foldl' (+) 0 . map charWidth
src/Text/Pandoc/Readers.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE MonoLocalBinds      #-} {-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings   #-} {- |    Module      : Text.Pandoc.Readers    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -55,11 +56,12 @@   ) where  import Prelude+import Control.Monad (unless) import Control.Monad.Except (throwError) import Data.Aeson import qualified Data.ByteString.Lazy as BL-import Data.List (intercalate) import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class import Text.Pandoc.Definition import Text.Pandoc.Error@@ -98,7 +100,7 @@               | ByteStringReader (ReaderOptions -> BL.ByteString -> m Pandoc)  -- | Association list of formats and readers.-readers :: PandocMonad m => [(String, Reader m)]+readers :: PandocMonad m => [(Text, Reader m)] readers = [ ("native"       , TextReader readNative)            ,("json"         , TextReader readJSON)            ,("markdown"     , TextReader readMarkdown)@@ -134,15 +136,28 @@            ]  -- | Retrieve reader, extensions based on formatSpec (format+extensions).-getReader :: PandocMonad m => String -> Either String (Reader m, Extensions)+getReader :: PandocMonad m => Text -> m (Reader m, Extensions) getReader s =   case parseFormatSpec s of-       Left e  -> Left $ intercalate "\n" [m | Message m <- errorMessages e]-       Right (readerName, setExts) ->+       Left e  -> throwError $ PandocAppError+                    $ T.intercalate "\n" [T.pack m | Message m <- errorMessages e]+       Right (readerName, extsToEnable, extsToDisable) ->            case lookup readerName readers of-                   Nothing  -> Left $ "Unknown reader: " ++ readerName-                   Just  r  -> Right (r, setExts $-                                        getDefaultExtensions readerName)+                   Nothing  -> throwError $ PandocUnknownReaderError+                                             readerName+                   Just  r  -> do+                     let allExts = getAllExtensions readerName+                     let exts = foldr disableExtension+                           (foldr enableExtension+                             (getDefaultExtensions readerName)+                                   extsToEnable) extsToDisable+                     mapM_ (\ext ->+                              unless (extensionEnabled ext allExts) $+                                throwError $+                                   PandocUnsupportedExtensionError+                                   (T.drop 4 $ T.pack $ show ext) readerName)+                          (extsToEnable ++ extsToDisable)+                     return (r, exts)  -- | Read pandoc document from JSON format. readJSON :: PandocMonad m
src/Text/Pandoc/Readers/CommonMark.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Readers.CommonMark    Copyright   : Copyright (C) 2015-2019 John MacFarlane@@ -18,9 +20,9 @@ import Prelude import CMarkGFM import Control.Monad.State-import Data.List (groupBy) import qualified Data.Set as Set-import Data.Text (Text, unpack)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Emoji (emojiToInline)@@ -40,24 +42,24 @@                [ extTable | isEnabled Ext_pipe_tables opts ] ++                [ extAutolink | isEnabled Ext_autolink_bare_uris opts ] -convertEmojis :: String -> [Inline]-convertEmojis s@(':':xs) =-   case break (==':') xs of-        (ys,':':zs) ->+convertEmojis :: Text -> [Inline]+convertEmojis s@(T.uncons -> Just (':',xs)) =+   case T.break (==':') xs of+        (ys, T.uncons -> Just (':',zs)) ->            case emojiToInline ys of                 Just em -> em : convertEmojis zs-                Nothing -> Str (':' : ys) : convertEmojis (':':zs)+                Nothing -> Str (":" <> ys) : convertEmojis (":" <> zs)         _ -> [Str s] convertEmojis s =-  case break (==':') s of+  case T.break (==':') s of     ("","") -> []     (_,"") -> [Str s]-    (xs,ys) -> Str xs:convertEmojis ys+    (xs,ys) -> Str xs : convertEmojis ys  addHeaderIdentifiers :: ReaderOptions -> Pandoc -> Pandoc addHeaderIdentifiers opts doc = evalState (walkM (addHeaderId opts) doc) mempty -addHeaderId :: ReaderOptions -> Block -> State (Set.Set String) Block+addHeaderId :: ReaderOptions -> Block -> State (Set.Set Text) Block addHeaderId opts (Header lev (_,classes,kvs) ils) = do   ids <- get   let ident = uniqueIdent (readerExtensions opts) ils ids@@ -82,14 +84,14 @@ addBlock opts (Node _ BLOCK_QUOTE nodes) =   (BlockQuote (addBlocks opts nodes) :) addBlock opts (Node _ (HTML_BLOCK t) _)-  | isEnabled Ext_raw_html opts = (RawBlock (Format "html") (unpack t) :)+  | isEnabled Ext_raw_html opts = (RawBlock (Format "html") t :)   | otherwise                 = id -- Note:  the cmark parser will never generate CUSTOM_BLOCK, -- so we don't need to handle it: addBlock _ (Node _ (CUSTOM_BLOCK _onEnter _onExit) _nodes) =   id addBlock _ (Node _ (CODE_BLOCK info t) _) =-  (CodeBlock ("", take 1 (words (unpack info)), []) (unpack t) :)+  (CodeBlock ("", take 1 (T.words info), []) t :) addBlock opts (Node _ (HEADING lev) nodes) =   (Header lev ("",[],[]) (addInlines opts nodes) :) addBlock opts (Node _ (LIST listAttrs) nodes) =@@ -176,29 +178,28 @@  addInline :: ReaderOptions -> Node -> [Inline] -> [Inline] addInline opts (Node _ (TEXT t) _) = (foldr ((++) . toinl) [] clumps ++)-  where raw = unpack t-        clumps = groupBy samekind raw+  where clumps = T.groupBy samekind t         samekind ' ' ' ' = True         samekind ' ' _   = False         samekind _   ' ' = False         samekind _  _    = True-        toinl (' ':_) = [Space]-        toinl xs      = if isEnabled Ext_emoji opts-                        then convertEmojis xs-                        else [Str xs]+        toinl (T.uncons -> Just (' ', _)) = [Space]+        toinl xs = if isEnabled Ext_emoji opts+                   then convertEmojis xs+                   else [Str xs] addInline _ (Node _ LINEBREAK _) = (LineBreak :) addInline opts (Node _ SOFTBREAK _)   | isEnabled Ext_hard_line_breaks opts = (LineBreak :)   | otherwise                           = (SoftBreak :) addInline opts (Node _ (HTML_INLINE t) _)-  | isEnabled Ext_raw_html opts = (RawInline (Format "html") (unpack t) :)+  | isEnabled Ext_raw_html opts = (RawInline (Format "html") t :)   | otherwise                 = id -- Note:  the cmark parser will never generate CUSTOM_BLOCK, -- so we don't need to handle it: addInline _ (Node _ (CUSTOM_INLINE _onEnter _onExit) _nodes) =   id addInline _ (Node _ (CODE t) _) =-  (Code ("",[],[]) (unpack t) :)+  (Code ("",[],[]) t :) addInline opts (Node _ EMPH nodes) =   (Emph (addInlines opts nodes) :) addInline opts (Node _ STRONG nodes) =@@ -206,7 +207,7 @@ addInline opts (Node _ STRIKETHROUGH nodes) =   (Strikeout (addInlines opts nodes) :) addInline opts (Node _ (LINK url title) nodes) =-  (Link nullAttr (addInlines opts nodes) (unpack url, unpack title) :)+  (Link nullAttr (addInlines opts nodes) (url, title) :) addInline opts (Node _ (IMAGE url title) nodes) =-  (Image nullAttr (addInlines opts nodes) (unpack url, unpack title) :)+  (Image nullAttr (addInlines opts nodes) (url, title) :) addInline _ _ = id
src/Text/Pandoc/Readers/Creole.hs view
@@ -19,6 +19,7 @@ import qualified Data.Foldable as F import Data.Maybe (fromMaybe) import Data.Text (Text)+import qualified Data.Text as T import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad (..)) import Text.Pandoc.Definition@@ -70,7 +71,6 @@   eof   return $ B.doc bs - -- -- block parsers --@@ -92,9 +92,9 @@                                              >> manyTill content nowikiEnd)   where     content = brackets <|> line-    brackets = try $ option "" ((:[]) <$> newline)-               <+> (char ' ' >> (many (char ' ') <+> string "}}}") <* eol)-    line = option "" ((:[]) <$> newline) <+> manyTill anyChar eol+    brackets = try $ option "" (T.singleton <$> newline)+               <+> (char ' ' >> (manyChar (char ' ') <+> textStr "}}}") <* eol)+    line = option "" (T.singleton <$> newline) <+> manyTillChar anyChar eol     eol = lookAhead $ try $ nowikiEnd <|> newline     nowikiStart = optional newline >> string "{{{" >> skipMany spaceChar >> newline     nowikiEnd = try $ linebreak >> string "}}}" >> skipMany spaceChar >> newline@@ -106,7 +106,7 @@     fmap length (many1 (char '='))   guard $ level <= 6   skipSpaces-  content <- B.str <$> manyTill (noneOf "\n") headerEnd+  content <- B.str <$> manyTillChar (noneOf "\n") headerEnd   return $ B.header level content   where     headerEnd = try $ skipSpaces >> many (char '=') >> skipSpaces >> newline@@ -204,7 +204,7 @@  escapedChar :: PandocMonad m => CRLParser m B.Inlines escapedChar =-  fmap (B.str . (:[])) (try $ char '~' >> noneOf "\t\n ")+  fmap (B.str . T.singleton) (try $ char '~' >> noneOf "\t\n ")  escapedLink :: PandocMonad m => CRLParser m B.Inlines escapedLink = try $ do@@ -217,8 +217,8 @@   (orig, src) <- wikiImg   return $ B.image src "" (B.str orig)   where-    linkSrc = many $ noneOf "|}\n\r\t"-    linkDsc = char '|' >> many (noneOf "}\n\r\t")+    linkSrc = manyChar $ noneOf "|}\n\r\t"+    linkDsc = char '|' >> manyChar (noneOf "}\n\r\t")     wikiImg = try $ do       string "{{"       src <- linkSrc@@ -231,11 +231,11 @@   (orig, src) <- uriLink <|> wikiLink   return $ B.link src "" orig   where-    linkSrc = many $ noneOf "|]\n\r\t"-    linkDsc :: PandocMonad m => String -> CRLParser m B.Inlines+    linkSrc = manyChar $ noneOf "|]\n\r\t"+    linkDsc :: PandocMonad m => Text -> CRLParser m B.Inlines     linkDsc otxt = B.str                    <$> try (option otxt-                         (char '|' >> many (noneOf "]\n\r\t")))+                         (char '|' >> manyChar (noneOf "]\n\r\t")))     linkImg = try $ char '|' >> image     wikiLink = try $ do       string "[["@@ -248,7 +248,7 @@       return (B.str orig, src)  inlineNowiki :: PandocMonad m => CRLParser m B.Inlines-inlineNowiki = B.code <$> (start >> manyTill (noneOf "\n\r") end)+inlineNowiki = B.code <$> (start >> manyTillChar (noneOf "\n\r") end)   where     start = try $ string "{{{"     end = try $ string "}}}" >> lookAhead (noneOf "}")@@ -271,11 +271,11 @@         innerNewline = return B.space  symbol :: PandocMonad m => CRLParser m B.Inlines-symbol = fmap (B.str . (:[])) (oneOf specialChars)+symbol = fmap (B.str . T.singleton) (oneOf specialChars)  str :: PandocMonad m => CRLParser m B.Inlines str = let strChar = noneOf ("\t\n " ++ specialChars) in-        fmap B.str (many1 strChar)+        fmap B.str (many1Char strChar)  bold :: PandocMonad m => CRLParser m B.Inlines bold = B.strong . mconcat <$>
src/Text/Pandoc/Readers/DocBook.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.DocBook    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -536,20 +537,22 @@  readDocBook :: PandocMonad m => ReaderOptions -> Text -> m Pandoc readDocBook _ inp = do-  let tree = normalizeTree . parseXML . handleInstructions-               $ T.unpack $ crFilter inp+  let tree = normalizeTree . parseXML . handleInstructions $ crFilter inp   (bs, st') <- flip runStateT (def{ dbContent = tree }) $ mapM parseBlock tree   return $ Pandoc (dbMeta st') (toList . mconcat $ bs)  -- We treat <?asciidoc-br?> specially (issue #1236), converting it -- to <br/>, since xml-light doesn't parse the instruction correctly. -- Other xml instructions are simply removed from the input stream.-handleInstructions :: String -> String-handleInstructions ('<':'?':'a':'s':'c':'i':'i':'d':'o':'c':'-':'b':'r':'?':'>':xs) = '<':'b':'r':'/':'>': handleInstructions xs-handleInstructions xs = case break (=='<') xs of+handleInstructions :: Text -> Text+handleInstructions = T.pack . handleInstructions' . T.unpack++handleInstructions' :: String -> String+handleInstructions' ('<':'?':'a':'s':'c':'i':'i':'d':'o':'c':'-':'b':'r':'?':'>':xs) = '<':'b':'r':'/':'>': handleInstructions' xs+handleInstructions' xs = case break (=='<') xs of                              (ys, [])     -> ys-                             ([], '<':zs) -> '<' : handleInstructions zs-                             (ys, zs)     -> ys ++ handleInstructions zs+                             ([], '<':zs) -> '<' : handleInstructions' zs+                             (ys, zs)     -> ys ++ handleInstructions' zs  getFigure :: PandocMonad m => Element -> DB m Blocks getFigure e = do@@ -580,13 +583,13 @@ convertEntity e = Data.Maybe.fromMaybe (map toUpper e) (lookupEntity e)  -- convenience function to get an attribute value, defaulting to ""-attrValue :: String -> Element -> String+attrValue :: String -> Element -> Text attrValue attr elt =-  fromMaybe "" (lookupAttrBy (\x -> qName x == attr) (elAttribs elt))+  maybe "" T.pack (lookupAttrBy (\x -> qName x == attr) (elAttribs elt))  -- convenience function-named :: String -> Element -> Bool-named s e = qName (elName e) == s+named :: Text -> Element -> Bool+named s e = qName (elName e) == T.unpack s  -- @@ -611,7 +614,7 @@                    [z] -> getInlines z >>= addMeta fieldname                    zs  -> mapM getInlines zs >>= addMeta fieldname -addMeta :: PandocMonad m => ToMetaValue a => String -> a -> DB m ()+addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> DB m () addMeta field val = modify (setMeta field val)  instance HasMeta DBState where@@ -619,25 +622,27 @@   deleteMeta field s = s {dbMeta = deleteMeta field (dbMeta s)}  isBlockElement :: Content -> Bool-isBlockElement (Elem e) = qName (elName e) `elem` blocktags-  where blocktags = ["toc","index","para","formalpara","simpara",+isBlockElement (Elem e) = qName (elName e) `elem` blockTags+isBlockElement _ = False++blockTags :: [String]+blockTags = ["toc","index","para","formalpara","simpara",            "ackno","epigraph","blockquote","bibliography","bibliodiv",            "biblioentry","glossee","glosseealso","glossary",            "glossdiv","glosslist","chapter","appendix","preface",            "bridgehead","sect1","sect2","sect3","sect4","sect5","section",-           "refsect1","refsect2","refsect3","refsection",-           "important","caution","note","tip","warning","qandadiv",+           "refsect1","refsect2","refsect3","refsection", "qandadiv",            "question","answer","abstract","itemizedlist","orderedlist",            "variablelist","article","book","table","informaltable",            "informalexample", "linegroup",-           "screen","programlisting","example","calloutlist"]-isBlockElement _ = False+           "screen","programlisting","example","calloutlist"] ++ admonitionTags +admonitionTags :: [String]+admonitionTags = ["important","caution","note","tip","warning"]+ -- Trim leading and trailing newline characters-trimNl :: String -> String-trimNl = reverse . go . reverse . go-  where go ('\n':xs) = xs-        go xs        = xs+trimNl :: Text -> Text+trimNl = T.dropAround (== '\n')  -- meld text into beginning of first paragraph of Blocks. -- assumes Blocks start with a Para; if not, does nothing.@@ -664,7 +669,7 @@                                    h = case atVal "depth" of                                          "" -> []                                          d  -> [("height", d)]-                                   atr = (atVal "id", words $ atVal "role", w ++ h)+                                   atr = (atVal "id", T.words $ atVal "role", w ++ h)                                in  return (atVal "fileref", atr)   let getCaption el = case filterChild (\x -> named "caption" x                                             || named "textobject" x@@ -687,8 +692,8 @@ parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE parseBlock (Text (CData _ s _)) = if all isSpace s                                      then return mempty-                                     else return $ plain $ trimInlines $ text s-parseBlock (CRef x) = return $ plain $ str $ map toUpper x+                                     else return $ plain $ trimInlines $ text $ T.pack s+parseBlock (CRef x) = return $ plain $ str $ T.toUpper $ T.pack x parseBlock (Elem e) =   case qName (elName e) of         "toc"   -> skip -- skip TOC, since in pandoc it's autogenerated@@ -722,7 +727,7 @@                   mapM parseGlossEntry (filterChildren (named "glossentry") e)         "glosslist" -> definitionList <$>                   mapM parseGlossEntry (filterChildren (named "glossentry") e)-        "chapter" -> sect 0+        "chapter" -> modify (\st -> st{ dbBook = True}) >> sect 0         "appendix" -> sect 0         "preface" -> sect 0         "bridgehead" -> para . strong <$> getInlines e@@ -736,16 +741,7 @@         "refsect2" -> sect 2         "refsect3" -> sect 3         "refsection" -> gets dbSectionLevel >>= sect . (+1)-        "important" -> blockQuote . (para (strong $ str "Important") <>)-                        <$> getBlocks e-        "caution" -> blockQuote . (para (strong $ str "Caution") <>)-                        <$> getBlocks e-        "note" -> blockQuote . (para (strong $ str "Note") <>)-                        <$> getBlocks e-        "tip" -> blockQuote . (para (strong $ str "Tip") <>)-                        <$> getBlocks e-        "warning" -> blockQuote . (para (strong $ str "Warning") <>)-                        <$> getBlocks e+        l@_ | l `elem` admonitionTags -> parseAdmonition $ T.pack l         "area" -> skip         "areaset" -> skip         "areaspec" -> skip@@ -805,7 +801,7 @@         "subtitle" -> return mempty  -- handled in parent element         _       -> skip >> getBlocks e    where skip = do-           lift $ report $ IgnoredElement $ qName (elName e)+           lift $ report $ IgnoredElement $ T.pack $ qName (elName e)            return mempty           parseMixed container conts = do@@ -823,7 +819,7 @@                                 "" -> []                                 x  -> [x]            return $ codeBlockWith (attrValue "id" e, classes', [])-                  $ trimNl $ strContentRecursive e+                  $ trimNl $ T.pack $ strContentRecursive e          parseBlockquote = do             attrib <- case filterChild (named "attribution") e of                              Nothing  -> return mempty@@ -876,9 +872,9 @@                                                 _             -> AlignDefault                       let toWidth c = case findAttr (unqual "colwidth") c of                                                 Just w -> fromMaybe 0-                                                   $ safeRead $ '0': filter (\x ->+                                                   $ safeRead $ "0" <> T.filter (\x ->                                                      (x >= '0' && x <= '9')-                                                      || x == '.') w+                                                      || x == '.') (T.pack w)                                                 Nothing -> 0 :: Double                       let numrows = case bodyrows of                                          [] -> 0@@ -913,6 +909,22 @@                      modify $ \st -> st{ dbSectionLevel = n - 1 }                      return $ headerWith (ident,[],[]) n' headerText <> b          lineItems = mapM getInlines $ filterChildren (named "line") e+         -- | Admonitions are parsed into a div. Following other Docbook tools that output HTML,+         -- we parse the optional title as a div with the @title@ class, and give the+         -- block itself a class corresponding to the admonition name.+         parseAdmonition label = do+           -- <title> elements can be directly nested inside an admonition block, use+           -- it if it's there. It is unclear whether we should include the label in+           -- the title: docbook references are ambiguous on that, and some implementations of admonitions+           -- (e.g. asciidoctor) just use an icon in all cases. To be conservative, we don't+           -- include the label and leave it to styling.+           title <- case filterChild (named "title") e of+                        Just t  -> divWith ("", ["title"], []) . plain <$> getInlines t+                        Nothing -> return $ mempty+           -- this will ignore the title element if it is present+           b <- getBlocks e+           -- we also attach the label as a class, so it can be styled properly+           return $ divWith (attrValue "id" e,[label],[]) (title <> b)  getInlines :: PandocMonad m => Element -> DB m Inlines getInlines e' = (trimInlines . mconcat) <$>@@ -927,9 +939,9 @@ elementToStr x = x  parseInline :: PandocMonad m => Content -> DB m Inlines-parseInline (Text (CData _ s _)) = return $ text s+parseInline (Text (CData _ s _)) = return $ text $ T.pack s parseInline (CRef ref) =-  return $ maybe (text $ map toUpper ref) text $ lookupEntity ref+  return $ maybe (text $ T.toUpper $ T.pack ref) (text . T.pack) $ lookupEntity ref parseInline (Elem e) =   case qName (elName e) of         "equation" -> equation e displayMath@@ -969,7 +981,7 @@         "constant" -> codeWithLang         "userinput" -> codeWithLang         "varargs" -> return $ code "(...)"-        "keycap" -> return (str $ strContent e)+        "keycap" -> return (str $ T.pack $ strContent e)         "keycombo" -> keycombo <$>                          mapM parseInline (elContent e)         "menuchoice" -> menuchoice <$>@@ -981,20 +993,20 @@             let title = case attrValue "endterm" e of                             ""      -> maybe "???" xrefTitleByElem                                          (findElementById linkend content)-                            endterm -> maybe "???" strContent+                            endterm -> maybe "???" (T.pack . strContent)                                          (findElementById endterm content)-            return $ link ('#' : linkend) "" (text title)-        "email" -> return $ link ("mailto:" ++ strContent e) ""-                          $ str $ strContent e-        "uri" -> return $ link (strContent e) "" $ str $ strContent e+            return $ link ("#" <> linkend) "" (text title)+        "email" -> return $ link ("mailto:" <> T.pack (strContent e)) ""+                          $ str $ T.pack $ strContent e+        "uri" -> return $ link (T.pack $ strContent e) "" $ str $ T.pack $ strContent e         "ulink" -> link (attrValue "url" e) "" <$> innerInlines         "link" -> do              ils <- innerInlines              let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of-                               Just h -> h-                               _      -> '#' : attrValue "linkend" e+                               Just h -> T.pack h+                               _      -> "#" <> attrValue "linkend" e              let ils' = if ils == mempty then str href else ils-             let attr = (attrValue "id" e, words $ attrValue "role" e, [])+             let attr = (attrValue "id" e, T.words $ attrValue "role" e, [])              return $ linkWith attr href "" ils'         "foreignphrase" -> emph <$> innerInlines         "emphasis" -> case attrValue "role" e of@@ -1012,7 +1024,7 @@         "br" -> return linebreak         _          -> skip >> innerInlines    where skip = do-           lift $ report $ IgnoredElement $ qName (elName e)+           lift $ report $ IgnoredElement $ T.pack $ qName (elName e)            return mempty           innerInlines = (trimInlines . mconcat) <$>@@ -1021,7 +1033,7 @@            let classes' = case attrValue "language" e of                                "" -> []                                l  -> [l]-           return $ codeWith (attrValue "id" e,classes',[]) $ strContentRecursive e+           return $ codeWith (attrValue "id" e,classes',[]) $ T.pack $ strContentRecursive e          simpleList = (mconcat . intersperse (str "," <> space)) <$> mapM getInlines                          (filterChildren (named "member") e)          segmentedList = do@@ -1051,8 +1063,8 @@          -- if there's no such attribute, employ some heuristics based on what          -- docbook-xsl does.          xrefTitleByElem el-             | not (null xrefLabel) = xrefLabel-             | otherwise            = case qName (elName el) of+             | not (T.null xrefLabel) = xrefLabel+             | otherwise              = case qName (elName el) of                   "chapter"      -> descendantContent "title" el                   "section"      -> descendantContent "title" el                   "sect1"        -> descendantContent "title" el@@ -1062,10 +1074,10 @@                   "sect5"        -> descendantContent "title" el                   "cmdsynopsis"  -> descendantContent "command" el                   "funcsynopsis" -> descendantContent "function" el-                  _              -> qName (elName el) ++ "_title"+                  _              -> T.pack $ qName (elName el) ++ "_title"           where             xrefLabel = attrValue "xreflabel" el-            descendantContent name = maybe "???" strContent+            descendantContent name = maybe "???" (T.pack . strContent)                                    . filterElementName (\n -> qName n == name)  -- | Extract a math equation from an element@@ -1077,20 +1089,20 @@   :: Monad m   => Element   -- ^ The element from which to extract a mathematical equation-  -> (String -> Inlines)+  -> (Text -> Inlines)   -- ^ A constructor for some Inlines, taking the TeX code as input   -> m Inlines equation e constructor =-  return $ mconcat $ map constructor $ mathMLEquations ++ latexEquations+  return $ mconcat $ map constructor $ mathMLEquations <> latexEquations   where-    mathMLEquations :: [String]+    mathMLEquations :: [Text]     mathMLEquations = map writeTeX $ rights $ readMath       (\x -> qName (elName x) == "math" && qPrefix (elName x) == Just "mml")-      (readMathML . showElement)+      (readMathML . T.pack . showElement) -    latexEquations :: [String]+    latexEquations :: [Text]     latexEquations = readMath (\x -> qName (elName x) == "mathphrase")-                              (concat . fmap showVerbatimCData . elContent)+                              (T.concat . fmap showVerbatimCData . elContent)      readMath :: (Element -> Bool) -> (Element -> b) -> [b]     readMath childPredicate fromElement =@@ -1098,13 +1110,12 @@       $ filterChildren childPredicate e       ) --- | Get the actual text stored in a verbatim CData block. 'showContent'+-- | Get the actual text stored in a CData block. 'showContent' -- returns the text still surrounded by the [[CDATA]] tags.------ Returns 'showContent' if this is not a verbatim CData-showVerbatimCData :: Content -> String-showVerbatimCData (Text (CData CDataVerbatim d _)) = d-showVerbatimCData c = showContent c+showVerbatimCData :: Content -> Text+showVerbatimCData (Text (CData _ d _)) = T.pack d+showVerbatimCData c = T.pack $ showContent c+  -- | Set the prefix of a name to 'Nothing' removePrefix :: QName -> QName
src/Text/Pandoc/Readers/Docx.hs view
@@ -2,6 +2,9 @@ {-# LANGUAGE CPP               #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE MultiWayIf        #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Readers.Docx    Copyright   : Copyright (C) 2014-2019 Jesse Rosenthal@@ -64,13 +67,14 @@ import qualified Data.ByteString.Lazy as B import Data.Default (Default) import Data.List (delete, intersect)+import Data.Char (isSpace) import qualified Data.Map as M+import qualified Data.Text as T import Data.Maybe (isJust, fromMaybe) import Data.Sequence (ViewL (..), viewl) import qualified Data.Sequence as Seq import qualified Data.Set as Set import Text.Pandoc.Builder--- import Text.Pandoc.Definition import Text.Pandoc.MediaBag (MediaBag) import Text.Pandoc.Options import Text.Pandoc.Readers.Docx.Combine@@ -98,14 +102,14 @@ readDocx _ _ =   throwError $ PandocSomeError "couldn't parse docx file" -data DState = DState { docxAnchorMap :: M.Map String String-                     , docxAnchorSet :: Set.Set String-                     , docxImmedPrevAnchor :: Maybe String+data DState = DState { docxAnchorMap :: M.Map T.Text T.Text+                     , docxAnchorSet :: Set.Set T.Text+                     , docxImmedPrevAnchor :: Maybe T.Text                      , docxMediaBag  :: MediaBag                      , docxDropCap   :: Inlines                      -- keep track of (numId, lvl) values for                      -- restarting-                     , docxListState :: M.Map (String, String) Integer+                     , docxListState :: M.Map (T.Text, T.Text) Integer                      , docxPrevPara  :: Inlines                      } @@ -121,24 +125,25 @@  data DEnv = DEnv { docxOptions       :: ReaderOptions                  , docxInHeaderBlock :: Bool+                 , docxInBidi        :: Bool                  }  instance Default DEnv where-  def = DEnv def False+  def = DEnv def False False  type DocxContext m = ReaderT DEnv (StateT DState m)  evalDocxContext :: PandocMonad m => DocxContext m a -> DEnv -> DState -> m a-evalDocxContext ctx env st = flip evalStateT st $flip runReaderT env ctx+evalDocxContext ctx env st = flip evalStateT st $ runReaderT ctx env  -- This is empty, but we put it in for future-proofing.-spansToKeep :: [String]+spansToKeep :: [CharStyleName] spansToKeep = [] -divsToKeep :: [String]-divsToKeep = ["list-item", "Definition", "DefinitionTerm"]+divsToKeep :: [ParaStyleName]+divsToKeep = ["Definition", "Definition Term"] -metaStyles :: M.Map String String+metaStyles :: M.Map ParaStyleName T.Text metaStyles = M.fromList [ ("Title", "title")                         , ("Subtitle", "subtitle")                         , ("Author", "author")@@ -150,7 +155,7 @@  isMetaPar :: BodyPart -> Bool isMetaPar (Paragraph pPr _) =-  not $ null $ intersect (pStyle pPr) (M.keys metaStyles)+  not $ null $ intersect (getStyleNames $ pStyle pPr) (M.keys metaStyles) isMetaPar _ = False  isEmptyPar :: BodyPart -> Bool@@ -163,11 +168,11 @@     isEmptyElem _           = True isEmptyPar _ = False -bodyPartsToMeta' :: PandocMonad m => [BodyPart] -> DocxContext m (M.Map String MetaValue)+bodyPartsToMeta' :: PandocMonad m => [BodyPart] -> DocxContext m (M.Map T.Text MetaValue) bodyPartsToMeta' [] = return M.empty bodyPartsToMeta' (bp : bps)   | (Paragraph pPr parParts) <- bp-  , (c : _)<- (pStyle pPr) `intersect` (M.keys metaStyles)+  , (c : _)<- getStyleNames (pStyle pPr) `intersect` M.keys metaStyles   , (Just metaField) <- M.lookup c metaStyles = do     inlines <- smushInlines <$> mapM parPartToInlines parParts     remaining <- bodyPartsToMeta' bps@@ -197,12 +202,30 @@           g _          = MetaInlines [] fixAuthors mv = mv -codeStyles :: [String]-codeStyles = ["VerbatimChar"]+isInheritedFromStyles :: (Eq (StyleName s), HasStyleName s, HasParentStyle s) => [StyleName s] -> s -> Bool+isInheritedFromStyles names sty+  | getStyleName sty `elem` names = True+  | Just psty <- getParentStyle sty = isInheritedFromStyles names psty+  | otherwise = False -codeDivs :: [String]-codeDivs = ["SourceCode"]+hasStylesInheritedFrom :: [ParaStyleName] -> ParagraphStyle -> Bool+hasStylesInheritedFrom ns s = any (isInheritedFromStyles ns) $ pStyle s +removeStyleNamed :: ParaStyleName -> ParagraphStyle -> ParagraphStyle+removeStyleNamed sn ps = ps{pStyle = filter (\psd -> getStyleName psd /= sn) $ pStyle ps}++isCodeCharStyle :: CharStyle -> Bool+isCodeCharStyle = isInheritedFromStyles ["Verbatim Char"]++isCodeDiv :: ParagraphStyle -> Bool+isCodeDiv = hasStylesInheritedFrom ["Source Code"]++isBlockQuote :: ParStyle -> Bool+isBlockQuote =+  isInheritedFromStyles [+    "Quote", "Block Text", "Block Quote", "Block Quotation"+    ]+ runElemToInlines :: RunElem -> Inlines runElemToInlines (TextRun s)   = text s runElemToInlines LnBrk         = linebreak@@ -210,74 +233,48 @@ runElemToInlines SoftHyphen    = text "\xad" runElemToInlines NoBreakHyphen = text "\x2011" -runElemToString :: RunElem -> String-runElemToString (TextRun s)   = s-runElemToString LnBrk         = ['\n']-runElemToString Tab           = ['\t']-runElemToString SoftHyphen    = ['\xad']-runElemToString NoBreakHyphen = ['\x2011']+runElemToText :: RunElem -> T.Text+runElemToText (TextRun s)   = s+runElemToText LnBrk         = T.singleton '\n'+runElemToText Tab           = T.singleton '\t'+runElemToText SoftHyphen    = T.singleton '\xad'+runElemToText NoBreakHyphen = T.singleton '\x2011' -runToString :: Run -> String-runToString (Run _ runElems) = concatMap runElemToString runElems-runToString _                = ""+runToText :: Run -> T.Text+runToText (Run _ runElems) = T.concat $ map runElemToText runElems+runToText _                = "" -parPartToString :: ParPart -> String-parPartToString (PlainRun run)             = runToString run-parPartToString (InternalHyperLink _ runs) = concatMap runToString runs-parPartToString (ExternalHyperLink _ runs) = concatMap runToString runs-parPartToString _                          = ""+parPartToText :: ParPart -> T.Text+parPartToText (PlainRun run)             = runToText run+parPartToText (InternalHyperLink _ runs) = T.concat $ map runToText runs+parPartToText (ExternalHyperLink _ runs) = T.concat $ map runToText runs+parPartToText _                          = "" -blacklistedCharStyles :: [String]+blacklistedCharStyles :: [CharStyleName] blacklistedCharStyles = ["Hyperlink"]  resolveDependentRunStyle :: PandocMonad m => RunStyle -> DocxContext m RunStyle resolveDependentRunStyle rPr-  | Just (s, _)  <- rStyle rPr, s `elem` blacklistedCharStyles =+  | Just s  <- rParentStyle rPr+  , getStyleName s `elem` blacklistedCharStyles =     return rPr-  | Just (_, cs) <- rStyle rPr = do+  | Just s  <- rParentStyle rPr = do       opts <- asks docxOptions       if isEnabled Ext_styles opts         then return rPr-        else do rPr' <- resolveDependentRunStyle cs-                return $-                  RunStyle { isBold = case isBold rPr of-                               Just bool -> Just bool-                               Nothing   -> isBold rPr'-                           , isItalic = case isItalic rPr of-                               Just bool -> Just bool-                               Nothing   -> isItalic rPr'-                           , isSmallCaps = case isSmallCaps rPr of-                               Just bool -> Just bool-                               Nothing   -> isSmallCaps rPr'-                           , isStrike = case isStrike rPr of-                               Just bool -> Just bool-                               Nothing   -> isStrike rPr'-                           , isRTL = case isRTL rPr of-                               Just bool -> Just bool-                               Nothing   -> isRTL rPr'-                           , rVertAlign = case rVertAlign rPr of-                               Just valign -> Just valign-                               Nothing     -> rVertAlign rPr'-                           , rUnderline = case rUnderline rPr of-                               Just ulstyle -> Just ulstyle-                               Nothing      -> rUnderline rPr'-                           , rStyle = rStyle rPr-                           }+        else leftBiasedMergeRunStyle rPr <$> resolveDependentRunStyle (cStyleData s)   | otherwise = return rPr  runStyleToTransform :: PandocMonad m => RunStyle -> DocxContext m (Inlines -> Inlines) runStyleToTransform rPr-  | Just (s, _) <- rStyle rPr-  , s `elem` spansToKeep = do-      transform <- runStyleToTransform rPr{rStyle = Nothing}-      return $ spanWith ("", [s], []) . transform-  | Just (s, _) <- rStyle rPr = do-      opts <- asks docxOptions-      let extraInfo = if isEnabled Ext_styles opts-                      then spanWith ("", [], [("custom-style", s)])-                      else id-      transform <- runStyleToTransform rPr{rStyle = Nothing}-      return $ extraInfo . transform+  | Just sn <- getStyleName <$> rParentStyle rPr+  , sn `elem` spansToKeep = do+      transform <- runStyleToTransform rPr{rParentStyle = Nothing}+      return $ spanWith ("", [normalizeToClassName sn], []) . transform+  | Just s <- rParentStyle rPr = do+      ei <- extraInfo spanWith s+      transform <- runStyleToTransform rPr{rParentStyle = Nothing}+      return $ ei . transform   | Just True <- isItalic rPr = do       transform <- runStyleToTransform rPr{isItalic = Nothing}       return $ emph  . transform@@ -295,7 +292,10 @@       return $ spanWith ("",[],[("dir","rtl")]) . transform   | Just False <- isRTL rPr = do       transform <- runStyleToTransform rPr{isRTL = Nothing}-      return $ spanWith ("",[],[("dir","ltr")]) . transform+      inBidi <- asks docxInBidi+      return $ if inBidi+               then spanWith ("",[],[("dir","ltr")]) . transform+               else transform   | Just SupScrpt <- rVertAlign rPr = do       transform <- runStyleToTransform rPr{rVertAlign = Nothing}       return $ superscript . transform@@ -309,10 +309,9 @@  runToInlines :: PandocMonad m => Run -> DocxContext m Inlines runToInlines (Run rs runElems)-  | Just (s, _) <- rStyle rs-  , s `elem` codeStyles = do+  | maybe False isCodeCharStyle $ rParentStyle rs = do       rPr <- resolveDependentRunStyle rs-      let codeString = code $ concatMap runElemToString runElems+      let codeString = code $ T.concat $ map runElemToText runElems       return $ case rVertAlign rPr of         Just SupScrpt -> superscript codeString         Just SubScrpt -> subscript codeString@@ -330,17 +329,17 @@   return $ note blksList runToInlines (InlineDrawing fp title alt bs ext) = do   (lift . lift) $ P.insertMedia fp Nothing bs-  return $ imageWith (extentToAttr ext) fp title $ text alt+  return $ imageWith (extentToAttr ext) (T.pack fp) title $ text alt runToInlines InlineChart = return $ spanWith ("", ["chart"], []) $ text "[CHART]"  extentToAttr :: Extent -> Attr extentToAttr (Just (w, h)) =   ("", [], [("width", showDim w), ("height", showDim h)] )   where-    showDim d = show (d / 914400) ++ "in"+    showDim d = tshow (d / 914400) <> "in" extentToAttr _ = nullAttr -blocksToInlinesWarn :: PandocMonad m => String -> Blocks -> DocxContext m Inlines+blocksToInlinesWarn :: PandocMonad m => T.Text -> Blocks -> DocxContext m Inlines blocksToInlinesWarn cmtId blks = do   let blkList = toList blks       notParaOrPlain :: Block -> Bool@@ -349,7 +348,7 @@       notParaOrPlain _         = True   unless ( not (any notParaOrPlain blkList)) $     lift $ P.report $ DocxParserWarning $-      "Docx comment " ++ cmtId ++ " will not retain formatting"+      "Docx comment " <> cmtId <> " will not retain formatting"   return $ blocksToInlines' blkList  -- The majority of work in this function is done in the primed@@ -442,12 +441,12 @@         return $ spanWith (newAnchor, ["anchor"], []) mempty parPartToInlines' (Drawing fp title alt bs ext) = do   (lift . lift) $ P.insertMedia fp Nothing bs-  return $ imageWith (extentToAttr ext) fp title $ text alt+  return $ imageWith (extentToAttr ext) (T.pack fp) title $ text alt parPartToInlines' Chart =   return $ spanWith ("", ["chart"], []) $ text "[CHART]" parPartToInlines' (InternalHyperLink anchor runs) = do   ils <- smushInlines <$> mapM runToInlines runs-  return $ link ('#' : anchor) "" ils+  return $ link ("#" <> anchor) "" ils parPartToInlines' (ExternalHyperLink target runs) = do   ils <- smushInlines <$> mapM runToInlines runs   return $ link target "" ils@@ -465,7 +464,7 @@   null kvs isAnchorSpan _ = False -dummyAnchors :: [String]+dummyAnchors :: [T.Text] dummyAnchors = ["_GoBack"]  makeHeaderAnchor :: PandocMonad m => Blocks -> DocxContext m Blocks@@ -479,7 +478,7 @@   , (Span (anchIdent, ["anchor"], _) cIls) <- c = do     hdrIDMap <- gets docxAnchorMap     exts <- readerExtensions <$> asks docxOptions-    let newIdent = if null ident+    let newIdent = if T.null ident                    then uniqueIdent exts ils (Set.fromList $ M.elems hdrIDMap)                    else ident         newIls = concatMap f ils where f il | il == c   = cIls@@ -492,7 +491,7 @@   do     hdrIDMap <- gets docxAnchorMap     exts <- readerExtensions <$> asks docxOptions-    let newIdent = if null ident+    let newIdent = if T.null ident                    then uniqueIdent exts ils (Set.fromList $ M.elems hdrIDMap)                    else ident     modify $ \s -> s {docxAnchorMap = M.insert newIdent newIdent hdrIDMap}@@ -525,120 +524,117 @@         isSp LineBreak = True         isSp _         = False +extraInfo :: (Eq (StyleName a), PandocMonad m, HasStyleName a)+          => (Attr -> i -> i) -> a -> DocxContext m (i -> i)+extraInfo f s = do+  opts <- asks docxOptions+  return $ if | isEnabled Ext_styles opts+              -> f ("", [], [("custom-style", fromStyleName $ getStyleName s)])+              | otherwise -> id+ parStyleToTransform :: PandocMonad m => ParagraphStyle -> DocxContext m (Blocks -> Blocks) parStyleToTransform pPr   | (c:cs) <- pStyle pPr-  , c `elem` divsToKeep = do+  , getStyleName c `elem` divsToKeep = do       let pPr' = pPr { pStyle = cs }       transform <- parStyleToTransform pPr'-      return $ divWith ("", [c], []) . transform+      return $ divWith ("", [normalizeToClassName $ getStyleName c], []) . transform   | (c:cs) <- pStyle pPr,-    c `elem` listParagraphDivs = do+    getStyleName c `elem` listParagraphStyles = do       let pPr' = pPr { pStyle = cs, indentation = Nothing}       transform <- parStyleToTransform pPr'-      return $ divWith ("", [c], []) . transform-  | (c:cs) <- pStyle pPr-  , Just True <- pBlockQuote pPr = do-      opts <- asks docxOptions-      let pPr' = pPr { pStyle = cs }-      transform <- parStyleToTransform pPr'-      let extraInfo = if isEnabled Ext_styles opts-                      then divWith ("", [], [("custom-style", c)])-                      else id-      return $ extraInfo . blockQuote . transform+      return $ divWith ("", [normalizeToClassName $ getStyleName c], []) . transform   | (c:cs) <- pStyle pPr = do-      opts <- asks docxOptions-      let pPr' = pPr { pStyle = cs}+      let pPr' = pPr { pStyle = cs }       transform <- parStyleToTransform pPr'-      let extraInfo = if isEnabled Ext_styles opts-                      then divWith ("", [], [("custom-style", c)])-                      else id-      return $ extraInfo . transform+      ei <- extraInfo divWith c+      return $ ei . (if isBlockQuote c then blockQuote else id) . transform   | null (pStyle pPr)-  , Just left <- indentation pPr >>= leftParIndent-  , Just hang <- indentation pPr >>= hangingParIndent = do+  , Just left <- indentation pPr >>= leftParIndent = do     let pPr' = pPr { indentation = Nothing }+        hang = fromMaybe 0 $ indentation pPr >>= hangingParIndent     transform <- parStyleToTransform pPr'-    return $ case (left - hang) > 0 of-               True  -> blockQuote . transform-               False -> transform-  | null (pStyle pPr),-    Just left <- indentation pPr >>= leftParIndent = do-      let pPr' = pPr { indentation = Nothing }-      transform <- parStyleToTransform pPr'-      return $ case left > 0 of-         True  -> blockQuote . transform-         False -> transform+    return $ if (left - hang) > 0+             then blockQuote . transform+             else transform parStyleToTransform _ = return id +normalizeToClassName :: (FromStyleName a) => a -> T.Text+normalizeToClassName = T.map go . fromStyleName+  where go c | isSpace c = '-'+             | otherwise = c+ bodyPartToBlocks :: PandocMonad m => BodyPart -> DocxContext m Blocks bodyPartToBlocks (Paragraph pPr parparts)-  | not $ null $ codeDivs `intersect` (pStyle pPr) = do+  | Just True <- pBidi pPr = do+      let pPr' = pPr { pBidi = Nothing }+      local (\s -> s{ docxInBidi = True })+        (bodyPartToBlocks (Paragraph pPr' parparts))+  | isCodeDiv pPr = do       transform <- parStyleToTransform pPr       return $         transform $         codeBlock $-        concatMap parPartToString parparts+        T.concat $+        map parPartToText parparts   | Just (style, n) <- pHeading pPr = do     ils <-local (\s-> s{docxInHeaderBlock=True})            (smushInlines <$> mapM parPartToInlines parparts)     makeHeaderAnchor $-      headerWith ("", delete style (pStyle pPr), []) n ils+      headerWith ("", map normalizeToClassName . delete style $ getStyleNames (pStyle pPr), []) n ils   | otherwise = do-    ils <- (trimSps . smushInlines) <$> mapM parPartToInlines parparts+    ils <- trimSps . smushInlines <$> mapM parPartToInlines parparts     prevParaIls <- gets docxPrevPara     dropIls <- gets docxDropCap     let ils' = dropIls <> ils-    if dropCap pPr+    let (paraOrPlain, pPr')+          | hasStylesInheritedFrom ["Compact"] pPr = (plain, removeStyleNamed "Compact" pPr)+          | otherwise = (para, pPr)+    if dropCap pPr'       then do modify $ \s -> s { docxDropCap = ils' }               return mempty       else do modify $ \s -> s { docxDropCap = mempty }               let ils'' = prevParaIls <>                           (if isNull prevParaIls then mempty else space) <>                           ils'+                  handleInsertion = do+                    modify $ \s -> s {docxPrevPara = mempty}+                    transform <- parStyleToTransform pPr'+                    return $ transform $ paraOrPlain ils''               opts <- asks docxOptions-              case () of--                _ | isNull ils'' && not (isEnabled Ext_empty_paragraphs opts) ->+              if  | isNull ils'' && not (isEnabled Ext_empty_paragraphs opts) ->                     return mempty-                _ | Just (TrackedChange Insertion _) <- pChange pPr-                  , AcceptChanges <- readerTrackChanges opts -> do-                      modify $ \s -> s {docxPrevPara = mempty}-                      transform <- parStyleToTransform pPr-                      return $ transform $ para ils''-                _ | Just (TrackedChange Insertion _) <- pChange pPr+                  | Just (TrackedChange Insertion _) <- pChange pPr'+                  , AcceptChanges <- readerTrackChanges opts ->+                      handleInsertion+                  | Just (TrackedChange Insertion _) <- pChange pPr'                   , RejectChanges <- readerTrackChanges opts -> do                       modify $ \s -> s {docxPrevPara = ils''}                       return mempty-                _ | Just (TrackedChange Insertion cInfo) <- pChange pPr+                  | Just (TrackedChange Insertion cInfo) <- pChange pPr'                   , AllChanges <- readerTrackChanges opts                   , ChangeInfo _ cAuthor cDate <- cInfo -> do                       let attr = ("", ["paragraph-insertion"], [("author", cAuthor), ("date", cDate)])                           insertMark = spanWith attr mempty-                      transform <- parStyleToTransform pPr+                      transform <- parStyleToTransform pPr'                       return $ transform $-                        para $ ils'' <> insertMark-                _ | Just (TrackedChange Deletion _) <- pChange pPr+                        paraOrPlain $ ils'' <> insertMark+                  | Just (TrackedChange Deletion _) <- pChange pPr'                   , AcceptChanges <- readerTrackChanges opts -> do                       modify $ \s -> s {docxPrevPara = ils''}                       return mempty-                _ | Just (TrackedChange Deletion _) <- pChange pPr-                  , RejectChanges <- readerTrackChanges opts -> do-                      modify $ \s -> s {docxPrevPara = mempty}-                      transform <- parStyleToTransform pPr-                      return $ transform $ para ils''-                _ | Just (TrackedChange Deletion cInfo) <- pChange pPr+                  | Just (TrackedChange Deletion _) <- pChange pPr'+                  , RejectChanges <- readerTrackChanges opts ->+                      handleInsertion+                  | Just (TrackedChange Deletion cInfo) <- pChange pPr'                   , AllChanges <- readerTrackChanges opts                   , ChangeInfo _ cAuthor cDate <- cInfo -> do                       let attr = ("", ["paragraph-deletion"], [("author", cAuthor), ("date", cDate)])                           insertMark = spanWith attr mempty-                      transform <- parStyleToTransform pPr+                      transform <- parStyleToTransform pPr'                       return $ transform $-                        para $ ils'' <> insertMark-                _ | otherwise -> do-                      modify $ \s -> s {docxPrevPara = mempty}-                      transform <- parStyleToTransform pPr-                      return $ transform $ para ils''+                        paraOrPlain $ ils'' <> insertMark+                  | otherwise -> handleInsertion bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do   -- We check whether this current numId has previously been used,   -- since Docx expects us to pick up where we left off.@@ -652,13 +648,20 @@             , ("num-id", numId)             , ("format", fmt)             , ("text", txt)-            , ("start", show start)+            , ("start", tshow start)             ]-  modify $ \st -> st{ docxListState = M.insert (numId, lvl) start listState}+  modify $ \st -> st{ docxListState =+    -- expire all the continuation data for lists of level > this one:+    -- a new level 1 list item resets continuation for level 2++    let expireKeys = [ (numid', lvl')+                     |  (numid', lvl') <- M.keys listState+                     , lvl' > lvl+                     ]+    in foldr M.delete (M.insert (numId, lvl) start listState) expireKeys }   blks <- bodyPartToBlocks (Paragraph pPr parparts)   return $ divWith ("", ["list-item"], kvs) blks bodyPartToBlocks (ListItem pPr _ _ _ parparts) =-  let pPr' = pPr {pStyle = "ListParagraph": pStyle pPr}+  let pPr' = pPr {pStyle = constructBogusParStyleData "list-paragraph": pStyle pPr}   in     bodyPartToBlocks $ Paragraph pPr' parparts bodyPartToBlocks (Tbl _ _ _ []) =@@ -704,12 +707,12 @@  -- replace targets with generated anchors. rewriteLink' :: PandocMonad m => Inline -> DocxContext m Inline-rewriteLink' l@(Link attr ils ('#':target, title)) = do+rewriteLink' l@(Link attr ils (T.uncons -> Just ('#',target), title)) = do   anchorMap <- gets docxAnchorMap   case M.lookup target anchorMap of     Just newTarget -> do       modify $ \s -> s{docxAnchorSet = Set.insert newTarget (docxAnchorSet s)}-      return $ Link attr ils ('#':newTarget, title)+      return $ Link attr ils ("#" <> newTarget, title)     Nothing        -> do       modify $ \s -> s{docxAnchorSet = Set.insert target (docxAnchorSet s)}       return l
src/Text/Pandoc/Readers/Docx/Combine.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude    #-} {-# LANGUAGE FlexibleInstances    #-} {-# LANGUAGE PatternGuards        #-} {-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE OverloadedStrings    #-} {- |    Module      : Text.Pandoc.Readers.Docx.Combine    Copyright   : © 2014-2019 Jesse Rosenthal <jrosenthal@jhu.edu>,
src/Text/Pandoc/Readers/Docx/Fields.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Docx.Fields    Copyright   : Copyright (C) 2014-2019 Jesse Rosenthal@@ -16,16 +17,18 @@                                        ) where  import Prelude+import Data.Functor (($>))+import qualified Data.Text as T import Text.Parsec-import Text.Parsec.String (Parser)+import Text.Parsec.Text (Parser) -type URL = String+type URL = T.Text  data FieldInfo = HyperlinkField URL                | UnknownField                deriving (Show) -parseFieldInfo :: String -> Either ParseError FieldInfo+parseFieldInfo :: T.Text -> Either ParseError FieldInfo parseFieldInfo = parse fieldInfo ""  fieldInfo :: Parser FieldInfo@@ -34,31 +37,31 @@   <|>   return UnknownField -escapedQuote :: Parser String-escapedQuote = string "\\\""+escapedQuote :: Parser T.Text+escapedQuote = string "\\\"" $> "\\\"" -inQuotes :: Parser String+inQuotes :: Parser T.Text inQuotes =-  (try escapedQuote) <|> (anyChar >>= (\c -> return [c]))+  (try escapedQuote) <|> (anyChar >>= (\c -> return $ T.singleton c)) -quotedString :: Parser String+quotedString :: Parser T.Text quotedString = do   char '"'-  concat <$> manyTill inQuotes (try (char '"'))+  T.concat <$> manyTill inQuotes (try (char '"')) -unquotedString :: Parser String-unquotedString = manyTill anyChar (try $ lookAhead space *> return () <|> eof)+unquotedString :: Parser T.Text+unquotedString = T.pack <$> manyTill anyChar (try $ lookAhead space *> return () <|> eof) -fieldArgument :: Parser String+fieldArgument :: Parser T.Text fieldArgument = quotedString <|> unquotedString  -- there are other switches, but this is the only one I've seen in the wild so far, so it's the first one I'll implement. See §17.16.5.25-hyperlinkSwitch :: Parser (String, String)+hyperlinkSwitch :: Parser (T.Text, T.Text) hyperlinkSwitch = do   sw <- string "\\l"   spaces   farg <- fieldArgument-  return (sw, farg)+  return (T.pack sw, farg)  hyperlink :: Parser URL hyperlink = do@@ -68,6 +71,6 @@   farg <- fieldArgument   switches <- spaces *> many hyperlinkSwitch   let url = case switches of-              ("\\l", s) : _ -> farg ++ ('#': s)+              ("\\l", s) : _ -> farg <> "#" <> s               _              -> farg   return url
src/Text/Pandoc/Readers/Docx/Lists.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Docx.Lists    Copyright   : Copyright (C) 2014-2019 Jesse Rosenthal@@ -14,13 +15,17 @@ module Text.Pandoc.Readers.Docx.Lists ( blocksToBullets                                       , blocksToDefinitions                                       , listParagraphDivs+                                      , listParagraphStyles                                       ) where  import Prelude import Data.List import Data.Maybe+import Data.String (fromString)+import qualified Data.Text as T import Text.Pandoc.Generic (bottomUp) import Text.Pandoc.JSON+import Text.Pandoc.Readers.Docx.Parse (ParaStyleName) import Text.Pandoc.Shared (trim, safeRead)  isListItem :: Block -> Bool@@ -41,20 +46,20 @@ getNumIdN :: Block -> Integer getNumIdN b = fromMaybe (-1) (getNumId b) -getText :: Block -> Maybe String+getText :: Block -> Maybe T.Text getText (Div (_, _, kvs) _) = lookup "text" kvs getText _                   = Nothing  data ListType = Itemized | Enumerated ListAttributes -listStyleMap :: [(String, ListNumberStyle)]+listStyleMap :: [(T.Text, ListNumberStyle)] listStyleMap = [("upperLetter", UpperAlpha),                 ("lowerLetter", LowerAlpha),                 ("upperRoman", UpperRoman),                 ("lowerRoman", LowerRoman),                 ("decimal", Decimal)] -listDelimMap :: [(String, ListNumberDelim)]+listDelimMap :: [(T.Text, ListNumberDelim)] listDelimMap = [("%1)", OneParen),                 ("(%1)", TwoParens),                 ("%1.", Period)]@@ -78,9 +83,12 @@      _ -> Nothing getListType _ = Nothing -listParagraphDivs :: [String]-listParagraphDivs = ["ListParagraph"]+listParagraphDivs :: [T.Text]+listParagraphDivs = ["list-paragraph"] +listParagraphStyles :: [ParaStyleName]+listParagraphStyles = map (fromString . T.unpack) listParagraphDivs+ -- This is a first stab at going through and attaching meaning to list -- paragraphs, without an item marker, following a list item. We -- assume that these are paragraphs in the same item.@@ -160,7 +168,7 @@   reverse $ DefinitionList (reverse defAcc) : acc blocksToDefinitions' defAcc acc   (Div (_, classes1, _) blks1 : Div (ident2, classes2, kvs2) blks2 : blks)-  | "DefinitionTerm" `elem` classes1 && "Definition"  `elem` classes2 =+  | "Definition-Term" `elem` classes1 && "Definition"  `elem` classes2 =     let remainingAttr2 = (ident2, delete "Definition" classes2, kvs2)         pair = if remainingAttr2 == ("", [], []) then (concatMap plainParaInlines blks1, [blks2]) else (concatMap plainParaInlines blks1, [[Div remainingAttr2 blks2]])     in@@ -169,12 +177,12 @@   (Div (ident2, classes2, kvs2) blks2 : blks)   | "Definition"  `elem` classes2 =     let remainingAttr2 = (ident2, delete "Definition" classes2, kvs2)-        defItems2 = case remainingAttr2 == ("", [], []) of-          True  -> blks2-          False -> [Div remainingAttr2 blks2]-        defAcc' = case null defItems of-          True -> (defTerm, [defItems2]) : defs-          False -> (defTerm, init defItems ++ [last defItems ++ defItems2]) : defs+        defItems2 = if remainingAttr2 == ("", [], [])+          then blks2+          else [Div remainingAttr2 blks2]+        defAcc' = if null defItems+          then (defTerm, [defItems2]) : defs+          else (defTerm, init defItems ++ [last defItems ++ defItems2]) : defs     in      blocksToDefinitions' defAcc' acc blks blocksToDefinitions' [] acc (b:blks) =@@ -197,8 +205,6 @@  removeListDivs :: [Block] -> [Block] removeListDivs = concatMap removeListDivs'--  blocksToDefinitions :: [Block] -> [Block] blocksToDefinitions = blocksToDefinitions' [] []
src/Text/Pandoc/Readers/Docx/Parse.hs view
@@ -1,10 +1,10 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE PatternGuards     #-} {-# LANGUAGE ViewPatterns      #-}+{-# LANGUAGE OverloadedStrings #-} {- |  Module : Text.Pandoc.Readers.Docx.Parse  Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+                           2019 Nikolay Yakimov <root@livid.pp.ru>  License : GNU GPL, version 2 or above   Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -31,6 +31,8 @@                                       , VertAlign(..)                                       , ParIndentation(..)                                       , ParagraphStyle(..)+                                      , ParStyle+                                      , CharStyle(cStyleData)                                       , Row(..)                                       , Cell(..)                                       , TrackedChange(..)@@ -38,10 +40,20 @@                                       , ChangeInfo(..)                                       , FieldInfo(..)                                       , Level(..)+                                      , ParaStyleName+                                      , CharStyleName+                                      , FromStyleName(..)+                                      , HasStyleName(..)+                                      , HasParentStyle(..)                                       , archiveToDocx                                       , archiveToDocxWithWarnings+                                      , getStyleNames+                                      , pHeading+                                      , constructBogusParStyleData+                                      , leftBiasedMergeRunStyle                                       ) where import Prelude+import Text.Pandoc.Readers.Docx.Parse.Styles import Codec.Archive.Zip import Control.Applicative ((<|>)) import Control.Monad.Except@@ -52,6 +64,7 @@ import Data.Char (chr, ord, readLitChar) import Data.List import qualified Data.Map as M+import qualified Data.Text as T import Data.Maybe import System.FilePath import Text.Pandoc.Readers.Docx.Util@@ -60,7 +73,7 @@ import qualified Text.Pandoc.UTF8 as UTF8 import Text.TeXMath (Exp) import Text.TeXMath.Readers.OMML (readOMML)-import Text.TeXMath.Unicode.Fonts (Font (..), getUnicode, stringToFont)+import Text.TeXMath.Unicode.Fonts (Font (..), getUnicode, textToFont) import Text.XML.Light import qualified Text.XML.Light.Cursor as XMLC @@ -77,7 +90,7 @@                            }                deriving Show -data ReaderState = ReaderState { stateWarnings :: [String]+data ReaderState = ReaderState { stateWarnings :: [T.Text]                                , stateFldCharState :: FldCharState                                }                  deriving Show@@ -108,7 +121,6 @@ concatMapM        :: (Monad m) => (a -> m [b]) -> [a] -> m [b] concatMapM f xs   =  liftM concat (mapM f xs) - -- This is similar to `mapMaybe`: it maps a function returning the D -- monad over a list, and only keeps the non-erroring return values. mapD :: (a -> D b) -> [a] -> D [b]@@ -121,9 +133,9 @@ unwrap ns (Elem element)   | isElem ns "w" "sdt" element   , Just sdtContent <- findChildByName ns "w" "sdtContent" element-  = concatMap ((unwrap ns) . Elem) (elChildren sdtContent)+  = concatMap (unwrap ns . Elem) (elChildren sdtContent)   | isElem ns "w" "smartTag" element-  = concatMap ((unwrap ns) . Elem) (elChildren element)+  = concatMap (unwrap ns . Elem) (elChildren element) unwrap _ content = [content]  unwrapChild :: NameSpaces -> Content -> Content@@ -149,40 +161,36 @@       _             -> Nothing  -data Docx = Docx Document+newtype Docx = Docx Document           deriving Show  data Document = Document NameSpaces Body           deriving Show -data Body = Body [BodyPart]+newtype Body = Body [BodyPart]           deriving Show  type Media = [(FilePath, B.ByteString)] -type CharStyle = (String, RunStyle)--type ParStyle = (String, ParStyleData)--type CharStyleMap = M.Map String RunStyle+type CharStyleMap = M.Map CharStyleId CharStyle -type ParStyleMap = M.Map String ParStyleData+type ParStyleMap = M.Map ParaStyleId ParStyle  data Numbering = Numbering NameSpaces [Numb] [AbstractNumb]                  deriving Show -data Numb = Numb String String [LevelOverride]+data Numb = Numb T.Text T.Text [LevelOverride]             deriving Show  --                                 ilvl    startOverride   lvl-data LevelOverride = LevelOverride String (Maybe Integer) (Maybe Level)+data LevelOverride = LevelOverride T.Text (Maybe Integer) (Maybe Level)   deriving Show -data AbstractNumb = AbstractNumb String [Level]+data AbstractNumb = AbstractNumb T.Text [Level]                     deriving Show  --                 ilvl   format string  start-data Level = Level String String String (Maybe Integer)+data Level = Level T.Text T.Text T.Text (Maybe Integer)   deriving Show  data DocumentLocation = InDocument | InFootnote | InEndnote@@ -192,11 +200,11 @@                   deriving Show  data Notes = Notes NameSpaces-             (Maybe (M.Map String Element))-             (Maybe (M.Map String Element))+             (Maybe (M.Map T.Text Element))+             (Maybe (M.Map T.Text Element))            deriving Show -data Comments = Comments NameSpaces (M.Map String Element)+data Comments = Comments NameSpaces (M.Map T.Text Element)               deriving Show  data ParIndentation = ParIndentation { leftParIndent    :: Maybe Integer@@ -213,13 +221,11 @@ data TrackedChange = TrackedChange ChangeType ChangeInfo                    deriving Show -data ParagraphStyle = ParagraphStyle { pStyle      :: [String]+data ParagraphStyle = ParagraphStyle { pStyle      :: [ParStyle]                                      , indentation :: Maybe ParIndentation                                      , dropCap     :: Bool-                                     , pHeading    :: Maybe (String, Int)-                                     , pNumInfo    :: Maybe (String, String)-                                     , pBlockQuote :: Maybe Bool                                      , pChange     :: Maybe TrackedChange+                                     , pBidi       :: Maybe Bool                                      }                       deriving Show @@ -227,33 +233,43 @@ defaultParagraphStyle = ParagraphStyle { pStyle = []                                        , indentation = Nothing                                        , dropCap     = False-                                       , pHeading    = Nothing-                                       , pNumInfo    = Nothing-                                       , pBlockQuote = Nothing                                        , pChange     = Nothing+                                       , pBidi       = Just False                                        }   data BodyPart = Paragraph ParagraphStyle [ParPart]-              | ListItem ParagraphStyle String String (Maybe Level) [ParPart]-              | Tbl String TblGrid TblLook [Row]+              | ListItem ParagraphStyle T.Text T.Text (Maybe Level) [ParPart]+              | Tbl T.Text TblGrid TblLook [Row]               | OMathPara [Exp]               deriving Show  type TblGrid = [Integer] -data TblLook = TblLook {firstRowFormatting::Bool}+newtype TblLook = TblLook {firstRowFormatting::Bool}               deriving Show  defaultTblLook :: TblLook defaultTblLook = TblLook{firstRowFormatting = False} -data Row = Row [Cell]+newtype Row = Row [Cell]            deriving Show -data Cell = Cell [BodyPart]+newtype Cell = Cell [BodyPart]             deriving Show +leftBiasedMergeRunStyle :: RunStyle -> RunStyle -> RunStyle+leftBiasedMergeRunStyle a b = RunStyle+    { isBold = isBold a <|> isBold b+    , isItalic = isItalic a <|> isItalic b+    , isSmallCaps = isSmallCaps a <|> isSmallCaps b+    , isStrike = isStrike a <|> isStrike b+    , isRTL = isRTL a <|> isRTL b+    , rVertAlign = rVertAlign a <|> rVertAlign b+    , rUnderline = rUnderline a <|> rUnderline b+    , rParentStyle = rParentStyle a+    }+ -- (width, height) in EMUs type Extent = Maybe (Double, Double) @@ -264,7 +280,7 @@              | BookMark BookMarkId Anchor              | InternalHyperLink Anchor [Run]              | ExternalHyperLink URL [Run]-             | Drawing FilePath String String B.ByteString Extent -- title, alt+             | Drawing FilePath T.Text T.Text B.ByteString Extent -- title, alt              | Chart                                              -- placeholder for now              | PlainOMath [Exp]              | Field FieldInfo [Run]@@ -275,59 +291,28 @@ data Run = Run RunStyle [RunElem]          | Footnote [BodyPart]          | Endnote [BodyPart]-         | InlineDrawing FilePath String String B.ByteString Extent -- title, alt+         | InlineDrawing FilePath T.Text T.Text B.ByteString Extent -- title, alt          | InlineChart          -- placeholder            deriving Show -data RunElem = TextRun String | LnBrk | Tab | SoftHyphen | NoBreakHyphen+data RunElem = TextRun T.Text | LnBrk | Tab | SoftHyphen | NoBreakHyphen              deriving Show -data VertAlign = BaseLn | SupScrpt | SubScrpt-               deriving Show--data RunStyle = RunStyle { isBold      :: Maybe Bool-                         , isItalic    :: Maybe Bool-                         , isSmallCaps :: Maybe Bool-                         , isStrike    :: Maybe Bool-                         , isRTL       :: Maybe Bool-                         , rVertAlign  :: Maybe VertAlign-                         , rUnderline  :: Maybe String-                         , rStyle      :: Maybe CharStyle-                         }-                deriving Show--data ParStyleData = ParStyleData { headingLev   :: Maybe (String, Int)-                                 , isBlockQuote :: Maybe Bool-                                 , numInfo      :: Maybe (String, String)-                                 , psStyle      :: Maybe ParStyle}-                    deriving Show--defaultRunStyle :: RunStyle-defaultRunStyle = RunStyle { isBold = Nothing-                           , isItalic = Nothing-                           , isSmallCaps = Nothing-                           , isStrike = Nothing-                           , isRTL = Nothing-                           , rVertAlign = Nothing-                           , rUnderline = Nothing-                           , rStyle = Nothing-                           }--type Target = String-type Anchor = String-type URL = String-type BookMarkId = String-type RelId = String-type ChangeId = String-type CommentId = String-type Author = String-type ChangeDate = String-type CommentDate = String+type Target = T.Text+type Anchor = T.Text+type URL = T.Text+type BookMarkId = T.Text+type RelId = T.Text+type ChangeId = T.Text+type CommentId = T.Text+type Author = T.Text+type ChangeDate = T.Text+type CommentDate = T.Text  archiveToDocx :: Archive -> Either DocxError Docx archiveToDocx archive = fst <$> archiveToDocxWithWarnings archive -archiveToDocxWithWarnings :: Archive -> Either DocxError (Docx, [String])+archiveToDocxWithWarnings :: Archive -> Either DocxError (Docx, [T.Text]) archiveToDocxWithWarnings archive = do   docXmlPath <- case getDocumentXmlPath archive of     Just fp -> Right fp@@ -357,7 +342,7 @@     Right doc -> Right (Docx doc, stateWarnings st)     Left e    -> Left e -getDocumentXmlPath :: Archive -> Maybe String+getDocumentXmlPath :: Archive -> Maybe FilePath getDocumentXmlPath zf = do   entry <- findEntryByPath "_rels/.rels" zf   relsElem <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry@@ -390,73 +375,28 @@ elemToBody _ _ = throwError WrongElem  archiveToStyles :: Archive -> (CharStyleMap, ParStyleMap)-archiveToStyles zf =-  let stylesElem = findEntryByPath "word/styles.xml" zf >>=-                   (parseXMLDoc . UTF8.toStringLazy . fromEntry)-  in-   case stylesElem of-     Nothing -> (M.empty, M.empty)-     Just styElem ->-       let namespaces = elemToNameSpaces styElem-       in-        ( M.fromList $ buildBasedOnList namespaces styElem-            (Nothing :: Maybe CharStyle),-          M.fromList $ buildBasedOnList namespaces styElem-            (Nothing :: Maybe ParStyle) )--isBasedOnStyle :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> Bool-isBasedOnStyle ns element parentStyle-  | isElem ns "w" "style" element-  , Just styleType <- findAttrByName ns "w" "type" element-  , styleType == cStyleType parentStyle-  , Just basedOnVal <- findChildByName ns "w" "basedOn" element >>=-                       findAttrByName ns "w" "val"-  , Just ps <- parentStyle = basedOnVal == getStyleId ps-  | isElem ns "w" "style" element-  , Just styleType <- findAttrByName ns "w" "type" element-  , styleType == cStyleType parentStyle-  , Nothing <- findChildByName ns "w" "basedOn" element-  , Nothing <- parentStyle = True-  | otherwise = False+archiveToStyles = archiveToStyles' getStyleId getStyleId -class ElemToStyle a where-  cStyleType  :: Maybe a -> String-  elemToStyle :: NameSpaces -> Element -> Maybe a -> Maybe a-  getStyleId     :: a -> String+class HasParentStyle a where+  getParentStyle :: a -> Maybe a -instance ElemToStyle CharStyle where-  cStyleType _ = "character"-  elemToStyle ns element parentStyle-    | isElem ns "w" "style" element-    , Just "character" <- findAttrByName ns "w" "type" element-    , Just styleId <- findAttrByName ns "w" "styleId" element =-      Just (styleId, elemToRunStyle ns element parentStyle)-    | otherwise = Nothing-  getStyleId s = fst s+instance HasParentStyle CharStyle where+  getParentStyle = rParentStyle . cStyleData -instance ElemToStyle ParStyle where-  cStyleType _ = "paragraph"-  elemToStyle ns element parentStyle-    | isElem ns "w" "style" element-    , Just "paragraph" <- findAttrByName ns "w" "type" element-    , Just styleId <- findAttrByName ns "w" "styleId" element =-      Just (styleId, elemToParStyleData ns element parentStyle)-    | otherwise = Nothing-  getStyleId s = fst s+instance HasParentStyle ParStyle where+  getParentStyle = psParentStyle -getStyleChildren :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> [a]-getStyleChildren ns element parentStyle-  | isElem ns "w" "styles" element =-    mapMaybe (\e -> elemToStyle ns e parentStyle) $-    filterChildren (\e' -> isBasedOnStyle ns e' parentStyle) element-  | otherwise = []+getStyleNames :: (Functor t, HasStyleName a) => t a -> t (StyleName a)+getStyleNames = fmap getStyleName -buildBasedOnList :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> [a]-buildBasedOnList ns element rootStyle =-  case getStyleChildren ns element rootStyle of-    [] -> []-    stys -> stys ++-            concatMap (buildBasedOnList ns element . Just) stys+constructBogusParStyleData :: ParaStyleName -> ParStyle+constructBogusParStyleData stName = ParStyle+  { headingLev = Nothing+  , numInfo = Nothing+  , psParentStyle = Nothing+  , pStyleName = stName+  , pStyleId = ParaStyleId . T.filter (/=' ') . fromStyleName $ stName+  }  archiveToNotes :: Archive -> Notes archiveToNotes zf =@@ -495,15 +435,15 @@ -- -- to see if it's a documentPath, we have to check against the dynamic -- -- docPath specified in "_rels/.rels" filePathToRelType path docXmlPath =-  if path == "word/_rels/" ++ (takeFileName docXmlPath) ++ ".rels"+  if path == "word/_rels/" ++ takeFileName docXmlPath ++ ".rels"   then Just InDocument   else Nothing  relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship relElemToRelationship relType element | qName (elName element) == "Relationship" =   do-    relId <- findAttr (QName "Id" Nothing Nothing) element-    target <- findAttr (QName "Target" Nothing Nothing) element+    relId <- findAttrText (QName "Id" Nothing Nothing) element+    target <- findAttrText (QName "Target" Nothing Nothing) element     return $ Relationship relType relId target relElemToRelationship _ _ = Nothing @@ -525,7 +465,7 @@   in    (dir == "word/media/") -lookupLevel :: String -> String -> Numbering -> Maybe Level+lookupLevel :: T.Text -> T.Text -> Numbering -> Maybe Level lookupLevel numId ilvl (Numbering _ numbs absNumbs) = do   (absNumId, ovrrides) <- lookup numId $                           map (\(Numb nid absnumid ovrRides) -> (nid, (absnumid, ovrRides))) numbs@@ -537,14 +477,14 @@   case lvlOverride of     Just (LevelOverride _ _ (Just lvl')) -> Just lvl'     Just (LevelOverride _ (Just strt) _) ->-      lookup ilvl $ map (\(Level i fmt s _) -> (i, (Level i fmt s (Just strt)))) lvls+      lookup ilvl $ map (\(Level i fmt s _) -> (i, Level i fmt s (Just strt))) lvls     _ ->       lookup ilvl $ map (\l@(Level i _ _ _) -> (i, l)) lvls  loElemToLevelOverride :: NameSpaces -> Element -> Maybe LevelOverride loElemToLevelOverride ns element   | isElem ns "w" "lvlOverride" element = do-      ilvl <- findAttrByName ns "w" "ilvl" element+      ilvl <- findAttrTextByName ns "w" "ilvl" element       let startOverride = findChildByName ns "w" "startOverride" element                           >>= findAttrByName ns "w" "val"                           >>= (\s -> listToMaybe (map fst (reads s :: [(Integer, String)])))@@ -556,9 +496,9 @@ numElemToNum :: NameSpaces -> Element -> Maybe Numb numElemToNum ns element   | isElem ns "w" "num" element = do-      numId <- findAttrByName ns "w" "numId" element+      numId <- findAttrTextByName ns "w" "numId" element       absNumId <- findChildByName ns "w" "abstractNumId" element-                  >>= findAttrByName ns "w" "val"+                  >>= findAttrTextByName ns "w" "val"       let lvlOverrides = mapMaybe                          (loElemToLevelOverride ns)                          (findChildrenByName ns "w" "lvlOverride" element)@@ -568,7 +508,7 @@ absNumElemToAbsNum :: NameSpaces -> Element -> Maybe AbstractNumb absNumElemToAbsNum ns element   | isElem ns "w" "abstractNum" element = do-      absNumId <- findAttrByName ns "w" "abstractNumId" element+      absNumId <- findAttrTextByName ns "w" "abstractNumId" element       let levelElems = findChildrenByName ns "w" "lvl" element           levels = mapMaybe (levelElemToLevel ns) levelElems       return $ AbstractNumb absNumId levels@@ -577,11 +517,11 @@ levelElemToLevel :: NameSpaces -> Element -> Maybe Level levelElemToLevel ns element   | isElem ns "w" "lvl" element = do-      ilvl <- findAttrByName ns "w" "ilvl" element+      ilvl <- findAttrTextByName ns "w" "ilvl" element       fmt <- findChildByName ns "w" "numFmt" element-             >>= findAttrByName ns "w" "val"+             >>= findAttrTextByName ns "w" "val"       txt <- findChildByName ns "w" "lvlText" element-             >>= findAttrByName ns "w" "val"+             >>= findAttrTextByName ns "w" "val"       let start = findChildByName ns "w" "start" element                   >>= findAttrByName ns "w" "val"                   >>= (\s -> listToMaybe (map fst (reads s :: [(Integer, String)])))@@ -605,11 +545,11 @@ archiveToNumbering archive =   fromMaybe (Numbering [] [] []) (archiveToNumbering' archive) -elemToNotes :: NameSpaces -> String -> Element -> Maybe (M.Map String Element)+elemToNotes :: NameSpaces -> String -> Element -> Maybe (M.Map T.Text Element) elemToNotes ns notetype element-  | isElem ns "w" (notetype ++ "s") element =+  | isElem ns "w" (notetype <> "s") element =       let pairs = mapMaybe-                  (\e -> findAttrByName ns "w" "id" e >>=+                  (\e -> findAttrTextByName ns "w" "id" e >>=                          (\a -> Just (a, e)))                   (findChildrenByName ns "w" notetype element)       in@@ -617,11 +557,11 @@        M.fromList pairs elemToNotes _ _ _ = Nothing -elemToComments :: NameSpaces -> Element -> M.Map String Element+elemToComments :: NameSpaces -> Element -> M.Map T.Text Element elemToComments ns element   | isElem ns "w" "comments" element =       let pairs = mapMaybe-                  (\e -> findAttrByName ns "w" "id" e >>=+                  (\e -> findAttrTextByName ns "w" "id" e >>=                          (\a -> Just (a, e)))                   (findChildrenByName ns "w" "comment" element)       in@@ -690,44 +630,43 @@     []            -> False     ((n', _) : _) -> (n' .|. n) /= 0 -stringToInteger :: String -> Maybe Integer-stringToInteger s = listToMaybe $ map fst (reads s :: [(Integer, String)])+pHeading :: ParagraphStyle -> Maybe (ParaStyleName, Int)+pHeading = getParStyleField headingLev . pStyle +pNumInfo :: ParagraphStyle -> Maybe (T.Text, T.Text)+pNumInfo = getParStyleField numInfo . pStyle+ elemToBodyPart :: NameSpaces -> Element -> D BodyPart elemToBodyPart ns element   | isElem ns "w" "p" element   , (c:_) <- findChildrenByName ns "m" "oMathPara" element =       do-        expsLst <- eitherToD $ readOMML $ showElement c+        expsLst <- eitherToD $ readOMML $ T.pack $ showElement c         return $ OMathPara expsLst elemToBodyPart ns element   | isElem ns "w" "p" element   , Just (numId, lvl) <- getNumInfo ns element = do-    sty <- asks envParStyles-    let parstyle = elemToParagraphStyle ns element sty+    parstyle <- elemToParagraphStyle ns element <$> asks envParStyles     parparts <- mapD (elemToParPart ns) (elChildren element)-    num <- asks envNumbering-    let levelInfo = lookupLevel numId lvl num+    levelInfo <- lookupLevel numId lvl <$> asks envNumbering     return $ ListItem parstyle numId lvl levelInfo parparts elemToBodyPart ns element   | isElem ns "w" "p" element = do-      sty <- asks envParStyles-      let parstyle = elemToParagraphStyle ns element sty+      parstyle <- elemToParagraphStyle ns element <$> asks envParStyles       parparts <- mapD (elemToParPart ns) (elChildren element)       -- Word uses list enumeration for numbered headings, so we only       -- want to infer a list from the styles if it is NOT a heading.       case pHeading parstyle of         Nothing | Just (numId, lvl) <- pNumInfo parstyle -> do-                    num <- asks envNumbering-                    let levelInfo = lookupLevel numId lvl num+                    levelInfo <- lookupLevel numId lvl <$> asks envNumbering                     return $ ListItem parstyle numId lvl levelInfo parparts         _ -> return $ Paragraph parstyle parparts elemToBodyPart ns element   | isElem ns "w" "tbl" element = do     let caption' = findChildByName ns "w" "tblPr" element                    >>= findChildByName ns "w" "tblCaption"-                   >>= findAttrByName ns "w" "val"-        caption = (fromMaybe "" caption')+                   >>= findAttrTextByName ns "w" "val"+        caption = fromMaybe "" caption'         grid' = case findChildByName ns "w" "tblGrid" element of           Just g  -> elemToTblGrid ns g           Nothing -> return []@@ -749,10 +688,10 @@   where     pairs = map (\(Relationship loc relid' target) -> ((loc, relid'), target)) rels -expandDrawingId :: String -> D (FilePath, B.ByteString)+expandDrawingId :: T.Text -> D (FilePath, B.ByteString) expandDrawingId s = do   location <- asks envLocation-  target <- asks (lookupRelationship location s . envRelationships)+  target <- asks (fmap T.unpack . lookupRelationship location s . envRelationships)   case target of     Just filepath -> do       bytes <- asks (lookup ("word/" ++ filepath) . envMedia)@@ -761,12 +700,12 @@         Nothing -> throwError DocxError     Nothing -> throwError DocxError -getTitleAndAlt :: NameSpaces -> Element -> (String, String)+getTitleAndAlt :: NameSpaces -> Element -> (T.Text, T.Text) getTitleAndAlt ns element =   let mbDocPr = findChildByName ns "wp" "inline" element >>=                 findChildByName ns "wp" "docPr"-      title = fromMaybe "" (mbDocPr >>= findAttrByName ns "" "title")-      alt = fromMaybe "" (mbDocPr >>= findAttrByName ns "" "descr")+      title = fromMaybe "" (mbDocPr >>= findAttrTextByName ns "" "title")+      alt = fromMaybe "" (mbDocPr >>= findAttrTextByName ns "" "descr")   in (title, alt)  elemToParPart :: NameSpaces -> Element -> D ParPart@@ -778,7 +717,7 @@   = let (title, alt) = getTitleAndAlt ns drawingElem         a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"         drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem-                  >>= findAttrByName ns "r" "embed"+                  >>= findAttrTextByName ns "r" "embed"     in      case drawing of        Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp title alt bs $ elemToExtent drawingElem)@@ -788,7 +727,7 @@   | isElem ns "w" "r" element   , Just _ <- findChildByName ns "w" "pict" element =     let drawing = findElement (elemName ns "v" "imagedata") element-                  >>= findAttrByName ns "r" "id"+                  >>= findAttrTextByName ns "r" "id"     in      case drawing of        -- Todo: check out title and attr for deprecated format.@@ -857,7 +796,7 @@       fldCharState <- gets stateFldCharState       case fldCharState of         FldCharOpen -> do-          info <- eitherToD $ parseFieldInfo $ strContent instrText+          info <- eitherToD $ parseFieldInfo $ T.pack $ strContent instrText           modify $ \st -> st{stateFldCharState = FldCharFieldInfo info}           return NullParPart         _ -> return NullParPart@@ -878,56 +817,56 @@       return $ ChangedRuns change runs elemToParPart ns element   | isElem ns "w" "bookmarkStart" element-  , Just bmId <- findAttrByName ns "w" "id" element-  , Just bmName <- findAttrByName ns "w" "name" element =+  , Just bmId <- findAttrTextByName ns "w" "id" element+  , Just bmName <- findAttrTextByName ns "w" "name" element =     return $ BookMark bmId bmName elemToParPart ns element   | isElem ns "w" "hyperlink" element-  , Just relId <- findAttrByName ns "r" "id" element = do+  , Just relId <- findAttrTextByName ns "r" "id" element = do     location <- asks envLocation     runs <- mapD (elemToRun ns) (elChildren element)     rels <- asks envRelationships     case lookupRelationship location relId rels of       Just target ->-         case findAttrByName ns "w" "anchor" element of-             Just anchor -> return $ ExternalHyperLink (target ++ '#':anchor) runs+         case findAttrTextByName ns "w" "anchor" element of+             Just anchor -> return $ ExternalHyperLink (target <> "#" <> anchor) runs              Nothing -> return $ ExternalHyperLink target runs       Nothing     -> return $ ExternalHyperLink "" runs elemToParPart ns element   | isElem ns "w" "hyperlink" element-  , Just anchor <- findAttrByName ns "w" "anchor" element = do+  , Just anchor <- findAttrTextByName ns "w" "anchor" element = do     runs <- mapD (elemToRun ns) (elChildren element)     return $ InternalHyperLink anchor runs elemToParPart ns element   | isElem ns "w" "commentRangeStart" element-  , Just cmtId <- findAttrByName ns "w" "id" element = do+  , Just cmtId <- findAttrTextByName ns "w" "id" element = do       (Comments _ commentMap) <- asks envComments       case M.lookup cmtId commentMap of         Just cmtElem -> elemToCommentStart ns cmtElem         Nothing      -> throwError WrongElem elemToParPart ns element   | isElem ns "w" "commentRangeEnd" element-  , Just cmtId <- findAttrByName ns "w" "id" element =+  , Just cmtId <- findAttrTextByName ns "w" "id" element =     return $ CommentEnd cmtId elemToParPart ns element   | isElem ns "m" "oMath" element =-    fmap PlainOMath (eitherToD $ readOMML $ showElement element)+    fmap PlainOMath (eitherToD $ readOMML $ T.pack $ showElement element) elemToParPart _ _ = throwError WrongElem  elemToCommentStart :: NameSpaces -> Element -> D ParPart elemToCommentStart ns element   | isElem ns "w" "comment" element-  , Just cmtId <- findAttrByName ns "w" "id" element-  , Just cmtAuthor <- findAttrByName ns "w" "author" element-  , Just cmtDate <- findAttrByName ns "w" "date" element = do+  , Just cmtId <- findAttrTextByName ns "w" "id" element+  , Just cmtAuthor <- findAttrTextByName ns "w" "author" element+  , Just cmtDate <- findAttrTextByName ns "w" "date" element = do       bps <- mapD (elemToBodyPart ns) (elChildren element)       return $ CommentStart cmtId cmtAuthor cmtDate bps elemToCommentStart _ _ = throwError WrongElem -lookupFootnote :: String -> Notes -> Maybe Element+lookupFootnote :: T.Text -> Notes -> Maybe Element lookupFootnote s (Notes _ fns _) = fns >>= M.lookup s -lookupEndnote :: String -> Notes -> Maybe Element+lookupEndnote :: T.Text -> Notes -> Maybe Element lookupEndnote s (Notes _ _ ens) = ens >>= M.lookup s  elemToExtent :: Element -> Extent@@ -938,7 +877,7 @@     where       wp_ns  = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"       getDim at = findElement (QName "extent" (Just wp_ns) (Just "wp")) drawingElem-                    >>= findAttr (QName at Nothing Nothing) >>= safeRead+                    >>= findAttr (QName at Nothing Nothing) >>= safeRead . T.pack   childElemToRun :: NameSpaces -> Element -> D Run@@ -949,7 +888,7 @@   = let (title, alt) = getTitleAndAlt ns element         a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"         drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem-                  >>= findAttr (QName "embed" (lookup "r" ns) (Just "r"))+                  >>= findAttrText (QName "embed" (lookup "r" ns) (Just "r"))     in      case drawing of        Just s -> expandDrawingId s >>=@@ -962,7 +901,7 @@   = return InlineChart childElemToRun ns element   | isElem ns "w" "footnoteReference" element-  , Just fnId <- findAttrByName ns "w" "id" element = do+  , Just fnId <- findAttrTextByName ns "w" "id" element = do     notes <- asks envNotes     case lookupFootnote fnId notes of       Just e -> do bps <- local (\r -> r {envLocation=InFootnote}) $ mapD (elemToBodyPart ns) (elChildren e)@@ -970,7 +909,7 @@       Nothing  -> return $ Footnote [] childElemToRun ns element   | isElem ns "w" "endnoteReference" element-  , Just enId <- findAttrByName ns "w" "id" element = do+  , Just enId <- findAttrTextByName ns "w" "id" element = do     notes <- asks envNotes     case lookupEndnote enId notes of       Just e -> do bps <- local (\r -> r {envLocation=InEndnote}) $ mapD (elemToBodyPart ns) (elChildren e)@@ -1007,33 +946,31 @@     return $ Run runStyle runElems elemToRun _ _ = throwError WrongElem -getParentStyleValue :: (ParStyleData -> Maybe a) -> ParStyleData -> Maybe a+getParentStyleValue :: (ParStyle -> Maybe a) -> ParStyle -> Maybe a getParentStyleValue field style   | Just value <- field style = Just value-  | Just parentStyle <- psStyle style-                      = getParentStyleValue field (snd parentStyle)+  | Just parentStyle <- psParentStyle style+                      = getParentStyleValue field parentStyle getParentStyleValue _ _ = Nothing -getParStyleField :: (ParStyleData -> Maybe a) -> ParStyleMap -> [String] ->-                                                                        Maybe a-getParStyleField field stylemap styles-  | x     <- mapMaybe (\x -> M.lookup x stylemap) styles-  , (y:_) <- mapMaybe (getParentStyleValue field) x+getParStyleField :: (ParStyle -> Maybe a) -> [ParStyle] -> Maybe a+getParStyleField field styles+  | (y:_) <- mapMaybe (getParentStyleValue field) styles            = Just y-getParStyleField _ _ _ = Nothing+getParStyleField _ _ = Nothing  getTrackedChange :: NameSpaces -> Element -> Maybe TrackedChange getTrackedChange ns element   | isElem ns "w" "ins" element || isElem ns "w" "moveTo" element-  , Just cId <- findAttrByName ns "w" "id" element-  , Just cAuthor <- findAttrByName ns "w" "author" element-  , Just cDate <- findAttrByName ns "w" "date" element =+  , Just cId <- findAttrTextByName ns "w" "id" element+  , Just cAuthor <- findAttrTextByName ns "w" "author" element+  , Just cDate <- findAttrTextByName ns "w" "date" element =       Just $ TrackedChange Insertion (ChangeInfo cId cAuthor cDate) getTrackedChange ns element   | isElem ns "w" "del" element || isElem ns "w" "moveFrom" element-  , Just cId <- findAttrByName ns "w" "id" element-  , Just cAuthor <- findAttrByName ns "w" "author" element-  , Just cDate <- findAttrByName ns "w" "date" element =+  , Just cId <- findAttrTextByName ns "w" "id" element+  , Just cAuthor <- findAttrTextByName ns "w" "author" element+  , Just cDate <- findAttrTextByName ns "w" "date" element =       Just $ TrackedChange Deletion (ChangeInfo cId cAuthor cDate) getTrackedChange _ _ = Nothing @@ -1042,10 +979,10 @@   | Just pPr <- findChildByName ns "w" "pPr" element =     let style =           mapMaybe-          (findAttrByName ns "w" "val")+          (fmap ParaStyleId . findAttrTextByName ns "w" "val")           (findChildrenByName ns "w" "pStyle" pPr)     in ParagraphStyle-      {pStyle = style+      {pStyle = mapMaybe (`M.lookup` sty) style       , indentation =           findChildByName ns "w" "ind" pPr >>=           elemToParIndentation ns@@ -1057,9 +994,6 @@             Just "none" -> False             Just _      -> True             Nothing     -> False-      , pHeading = getParStyleField headingLev sty style-      , pNumInfo = getParStyleField numInfo sty style-      , pBlockQuote = getParStyleField isBlockQuote sty style       , pChange     = findChildByName ns "w" "rPr" pPr >>=                       filterChild (\e -> isElem ns "w" "ins" e ||                                          isElem ns "w" "moveTo" e ||@@ -1067,127 +1001,32 @@                                          isElem ns "w" "moveFrom" e                                   ) >>=                       getTrackedChange ns+      , pBidi = checkOnOff ns pPr (elemName ns "w" "bidi")       } elemToParagraphStyle _ _ _ =  defaultParagraphStyle -checkOnOff :: NameSpaces -> Element -> QName -> Maybe Bool-checkOnOff ns rPr tag-  | Just t <-  findChild tag rPr-  , Just val <- findAttrByName ns "w" "val" t =-    Just $ case val of-      "true"  -> True-      "false" -> False-      "on"    -> True-      "off"   -> False-      "1"     -> True-      "0"     -> False-      _       -> False-  | Just _ <- findChild tag rPr = Just True-checkOnOff _ _ _ = Nothing- elemToRunStyleD :: NameSpaces -> Element -> D RunStyle elemToRunStyleD ns element   | Just rPr <- findChildByName ns "w" "rPr" element = do     charStyles <- asks envCharStyles-    let parentSty = case+    let parentSty =           findChildByName ns "w" "rStyle" rPr >>=-          findAttrByName ns "w" "val"-          of-            Just styName | Just style <- M.lookup styName charStyles ->-              Just (styName, style)-            _            -> Nothing+          findAttrTextByName ns "w" "val" >>=+          flip M.lookup charStyles . CharStyleId     return $ elemToRunStyle ns element parentSty elemToRunStyleD _ _ = return defaultRunStyle -elemToRunStyle :: NameSpaces -> Element -> Maybe CharStyle -> RunStyle-elemToRunStyle ns element parentStyle-  | Just rPr <- findChildByName ns "w" "rPr" element =-    RunStyle-      {-        isBold = checkOnOff ns rPr (elemName ns "w" "b") `mplus`-                 checkOnOff ns rPr (elemName ns "w" "bCs")-      , isItalic = checkOnOff ns rPr (elemName ns "w" "i") `mplus`-                   checkOnOff ns rPr (elemName ns "w" "iCs")-      , isSmallCaps = checkOnOff ns rPr (elemName ns "w" "smallCaps")-      , isStrike = checkOnOff ns rPr (elemName ns "w" "strike")-      , isRTL = checkOnOff ns rPr (elemName ns "w" "rtl")-      , rVertAlign =-           findChildByName ns "w" "vertAlign" rPr >>=-           findAttrByName ns "w" "val" >>=-           \v -> Just $ case v of-             "superscript" -> SupScrpt-             "subscript"   -> SubScrpt-             _             -> BaseLn-      , rUnderline =-          findChildByName ns "w" "u" rPr >>=-          findAttrByName ns "w" "val"-      , rStyle = parentStyle-      }-elemToRunStyle _ _ _ = defaultRunStyle--getHeaderLevel :: NameSpaces -> Element -> Maybe (String,Int)-getHeaderLevel ns element-  | Just styleId <- findAttrByName ns "w" "styleId" element-  , Just index   <- stripPrefix "Heading" styleId-  , Just n       <- stringToInteger index-  , n > 0 = Just (styleId, fromInteger n)-  | Just styleId <- findAttrByName ns "w" "styleId" element-  , Just index   <- findChildByName ns "w" "name" element >>=-                    findAttrByName ns "w" "val" >>=-                    stripPrefix "heading "-  , Just n <- stringToInteger index-  , n > 0 = Just (styleId, fromInteger n)-getHeaderLevel _ _ = Nothing--blockQuoteStyleIds :: [String]-blockQuoteStyleIds = ["Quote", "BlockQuote", "BlockQuotation"]--blockQuoteStyleNames :: [String]-blockQuoteStyleNames = ["Quote", "Block Text"]--getBlockQuote :: NameSpaces -> Element -> Maybe Bool-getBlockQuote ns element-  | Just styleId <- findAttrByName ns "w" "styleId" element-  , styleId `elem` blockQuoteStyleIds = Just True-  | Just styleName <- findChildByName ns "w" "name" element >>=-                      findAttrByName ns "w" "val"-  , styleName `elem` blockQuoteStyleNames = Just True-getBlockQuote _ _ = Nothing--getNumInfo :: NameSpaces -> Element -> Maybe (String, String)-getNumInfo ns element = do-  let numPr = findChildByName ns "w" "pPr" element >>=-              findChildByName ns "w" "numPr"-      lvl = fromMaybe "0" (numPr >>=-                           findChildByName ns "w" "ilvl" >>=-                           findAttrByName ns "w" "val")-  numId <- numPr >>=-           findChildByName ns "w" "numId" >>=-           findAttrByName ns "w" "val"-  return (numId, lvl)---elemToParStyleData :: NameSpaces -> Element -> Maybe ParStyle -> ParStyleData-elemToParStyleData ns element parentStyle =-    ParStyleData-      {-        headingLev = getHeaderLevel ns element-      , isBlockQuote = getBlockQuote ns element-      , numInfo = getNumInfo ns element-      , psStyle = parentStyle-        }- elemToRunElem :: NameSpaces -> Element -> D RunElem elemToRunElem ns element   | isElem ns "w" "t" element     || isElem ns "w" "delText" element     || isElem ns "m" "t" element = do-    let str = strContent element+    let str = T.pack $ strContent element     font <- asks envFont     case font of       Nothing -> return $ TextRun str       Just f  -> return . TextRun $-                  map (\x -> fromMaybe x . getUnicode f . lowerFromPrivate $ x) str+                  T.map (\x -> fromMaybe x . getUnicode f . lowerFromPrivate $ x) str   | isElem ns "w" "br" element = return LnBrk   | isElem ns "w" "tab" element = return Tab   | isElem ns "w" "softHyphen" element = return SoftHyphen@@ -1205,11 +1044,11 @@   | Just s <- lowerFromPrivate <$> getCodepoint   , Just font <- getFont =     case readLitChar ("\\x" ++ s) of-         [(char, _)] -> TextRun . maybe "" (:[]) $ getUnicode font char+         [(char, _)] -> TextRun . maybe "" T.singleton $ getUnicode font char          _           -> TextRun ""   where     getCodepoint = findAttrByName ns "w" "char" element-    getFont = stringToFont =<< findAttrByName ns "w" "font" element+    getFont = textToFont . T.pack =<< findAttrByName ns "w" "font" element     lowerFromPrivate ('F':xs) = '0':xs     lowerFromPrivate xs       = xs getSymChar _ _ = TextRun ""@@ -1221,7 +1060,7 @@        let qualName = elemName ns "w"        let font = do                     fontElem <- findElement (qualName "rFonts") element-                    stringToFont =<<+                    textToFont . T.pack =<<                        foldr ((<|>) . (flip findAttr fontElem . qualName)) Nothing ["ascii", "hAnsi"]        local (setFont font) (mapD (elemToRunElem ns) (elChildren element)) elemToRunElems _ _ = throwError WrongElem
+ src/Text/Pandoc/Readers/Docx/Parse/Styles.hs view
@@ -0,0 +1,311 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE TypeFamilies      #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}+{- |+ Module : Text.Pandoc.Readers.Docx.Parse.Styles+ Copyright : Copyright (C) 2014-2019 Jesse Rosenthal+                           2019 Nikolay Yakimov <root@livid.pp.ru>+ License : GNU GPL, version 2 or above++ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>+ Stability : alpha+ Portability : portable++Type machinery and code for extraction and manipulation of docx styles+-}++module Text.Pandoc.Readers.Docx.Parse.Styles (+    CharStyleId(..)+  , CharStyle+  , ParaStyleId(..)+  , ParStyle(..)+  , RunStyle(..)+  , HasStyleName+  , StyleName+  , ParaStyleName+  , CharStyleName+  , FromStyleName+  , VertAlign(..)+  , StyleId+  , HasStyleId+  , archiveToStyles'+  , getStyleId+  , getStyleName+  , cStyleData+  , fromStyleName+  , fromStyleId+  , stringToInteger+  , getNumInfo+  , elemToRunStyle+  , defaultRunStyle+  , checkOnOff+  ) where+import Prelude+import Codec.Archive.Zip+import Control.Applicative ((<|>))+import Control.Monad.Except+import Data.Function (on)+import Data.String (IsString(..))+import qualified Data.Map as M+import qualified Data.Text as T+import Data.Maybe+import Data.Coerce+import Text.Pandoc.Readers.Docx.Util+import qualified Text.Pandoc.UTF8 as UTF8+import Text.XML.Light++newtype CharStyleId   = CharStyleId T.Text+  deriving (Show, Eq, Ord, IsString, FromStyleId)+newtype ParaStyleId   = ParaStyleId T.Text+  deriving (Show, Eq, Ord, IsString, FromStyleId)++newtype CharStyleName = CharStyleName CIString+  deriving (Show, Eq, Ord, IsString, FromStyleName)+newtype ParaStyleName = ParaStyleName CIString+  deriving (Show, Eq, Ord, IsString, FromStyleName)++-- Case-insensitive comparisons+newtype CIString = CIString T.Text deriving (Show, IsString, FromStyleName)++class FromStyleName a where+  fromStyleName :: a -> T.Text++instance FromStyleName String where+  fromStyleName = T.pack++instance FromStyleName T.Text where+  fromStyleName = id++class FromStyleId a where+  fromStyleId :: a -> T.Text++instance FromStyleId String where+  fromStyleId = T.pack++instance FromStyleId T.Text where+  fromStyleId = id++instance Eq CIString where+   (==) = (==) `on` T.toCaseFold . coerce++instance Ord CIString where+  compare = compare `on` T.toCaseFold . coerce++data VertAlign = BaseLn | SupScrpt | SubScrpt+               deriving Show++data CharStyle = CharStyle { cStyleId   :: CharStyleId+                           , cStyleName :: CharStyleName+                           , cStyleData :: RunStyle+                           } deriving (Show)++data RunStyle = RunStyle { isBold       :: Maybe Bool+                         , isItalic     :: Maybe Bool+                         , isSmallCaps  :: Maybe Bool+                         , isStrike     :: Maybe Bool+                         , isRTL        :: Maybe Bool+                         , rVertAlign   :: Maybe VertAlign+                         , rUnderline   :: Maybe String+                         , rParentStyle :: Maybe CharStyle+                         }+                deriving Show++data ParStyle = ParStyle { headingLev    :: Maybe (ParaStyleName, Int)+                         , numInfo       :: Maybe (T.Text, T.Text)+                         , psParentStyle :: Maybe ParStyle+                         , pStyleName    :: ParaStyleName+                         , pStyleId      :: ParaStyleId+                         }+                    deriving Show++defaultRunStyle :: RunStyle+defaultRunStyle = RunStyle { isBold = Nothing+                           , isItalic = Nothing+                           , isSmallCaps = Nothing+                           , isStrike = Nothing+                           , isRTL = Nothing+                           , rVertAlign = Nothing+                           , rUnderline = Nothing+                           , rParentStyle = Nothing+                           }++archiveToStyles' :: (Ord k1, Ord k2, ElemToStyle a1, ElemToStyle a2) =>+                    (a1 -> k1) -> (a2 -> k2) -> Archive -> (M.Map k1 a1, M.Map k2 a2)+archiveToStyles' conv1 conv2 zf =+  let stylesElem = findEntryByPath "word/styles.xml" zf >>=+                   (parseXMLDoc . UTF8.toStringLazy . fromEntry)+  in+   case stylesElem of+     Nothing -> (M.empty, M.empty)+     Just styElem ->+       let namespaces = elemToNameSpaces styElem+       in+        ( M.fromList $ map (\r -> (conv1 r, r)) $ buildBasedOnList namespaces styElem Nothing,+          M.fromList $ map (\p -> (conv2 p, p)) $ buildBasedOnList namespaces styElem Nothing)++isBasedOnStyle :: (ElemToStyle a, FromStyleId (StyleId a)) => NameSpaces -> Element -> Maybe a -> Bool+isBasedOnStyle ns element parentStyle+  | isElem ns "w" "style" element+  , Just styleType <- findAttrByName ns "w" "type" element+  , styleType == cStyleType parentStyle+  , Just basedOnVal <- findChildByName ns "w" "basedOn" element >>=+                       findAttrTextByName ns "w" "val"+  , Just ps <- parentStyle = basedOnVal == fromStyleId (getStyleId ps)+  | isElem ns "w" "style" element+  , Just styleType <- findAttrByName ns "w" "type" element+  , styleType == cStyleType parentStyle+  , Nothing <- findChildByName ns "w" "basedOn" element+  , Nothing <- parentStyle = True+  | otherwise = False++class HasStyleId a => ElemToStyle a where+  cStyleType  :: Maybe a -> String+  elemToStyle :: NameSpaces -> Element -> Maybe a -> Maybe a++class FromStyleId (StyleId a) => HasStyleId a where+  type StyleId a+  getStyleId :: a -> StyleId a++class FromStyleName (StyleName a) => HasStyleName a where+  type StyleName a+  getStyleName :: a -> StyleName a++instance ElemToStyle CharStyle where+  cStyleType _ = "character"+  elemToStyle ns element parentStyle+    | isElem ns "w" "style" element+    , Just "character" <- findAttrByName ns "w" "type" element =+      elemToCharStyle ns element parentStyle+    | otherwise = Nothing++instance HasStyleId CharStyle where+  type StyleId CharStyle = CharStyleId+  getStyleId = cStyleId++instance HasStyleName CharStyle where+  type StyleName CharStyle = CharStyleName+  getStyleName = cStyleName++instance ElemToStyle ParStyle where+  cStyleType _ = "paragraph"+  elemToStyle ns element parentStyle+    | isElem ns "w" "style" element+    , Just "paragraph" <- findAttrByName ns "w" "type" element+    = elemToParStyleData ns element parentStyle+    | otherwise = Nothing++instance HasStyleId ParStyle where+  type StyleId ParStyle = ParaStyleId+  getStyleId = pStyleId++instance HasStyleName ParStyle where+  type StyleName ParStyle = ParaStyleName+  getStyleName = pStyleName++getStyleChildren :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> [a]+getStyleChildren ns element parentStyle+  | isElem ns "w" "styles" element =+    mapMaybe (\e -> elemToStyle ns e parentStyle) $+    filterChildren (\e' -> isBasedOnStyle ns e' parentStyle) element+  | otherwise = []++buildBasedOnList :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> [a]+buildBasedOnList ns element rootStyle =+  case getStyleChildren ns element rootStyle of+    [] -> []+    stys -> stys +++            concatMap (buildBasedOnList ns element . Just) stys++stringToInteger :: String -> Maybe Integer+stringToInteger s = listToMaybe $ map fst (reads s :: [(Integer, String)])++checkOnOff :: NameSpaces -> Element -> QName -> Maybe Bool+checkOnOff ns rPr tag+  | Just t <-  findChild tag rPr+  , Just val <- findAttrByName ns "w" "val" t =+    Just $ case val of+      "true"  -> True+      "false" -> False+      "on"    -> True+      "off"   -> False+      "1"     -> True+      "0"     -> False+      _       -> False+  | Just _ <- findChild tag rPr = Just True+checkOnOff _ _ _ = Nothing++elemToCharStyle :: NameSpaces+                -> Element -> Maybe CharStyle -> Maybe CharStyle+elemToCharStyle ns element parentStyle+  = CharStyle <$> (CharStyleId <$> findAttrTextByName ns "w" "styleId" element)+              <*> getElementStyleName ns element+              <*> (Just $ elemToRunStyle ns element parentStyle)++elemToRunStyle :: NameSpaces -> Element -> Maybe CharStyle -> RunStyle+elemToRunStyle ns element parentStyle+  | Just rPr <- findChildByName ns "w" "rPr" element =+    RunStyle+      {+        isBold = checkOnOff ns rPr (elemName ns "w" "b") `mplus`+                 checkOnOff ns rPr (elemName ns "w" "bCs")+      , isItalic = checkOnOff ns rPr (elemName ns "w" "i") `mplus`+                   checkOnOff ns rPr (elemName ns "w" "iCs")+      , isSmallCaps = checkOnOff ns rPr (elemName ns "w" "smallCaps")+      , isStrike = checkOnOff ns rPr (elemName ns "w" "strike")+      , isRTL = checkOnOff ns rPr (elemName ns "w" "rtl")+      , rVertAlign =+           findChildByName ns "w" "vertAlign" rPr >>=+           findAttrByName ns "w" "val" >>=+           \v -> Just $ case v of+             "superscript" -> SupScrpt+             "subscript"   -> SubScrpt+             _             -> BaseLn+      , rUnderline =+          findChildByName ns "w" "u" rPr >>=+          findAttrByName ns "w" "val"+      , rParentStyle = parentStyle+      }+elemToRunStyle _ _ _ = defaultRunStyle++getHeaderLevel :: NameSpaces -> Element -> Maybe (ParaStyleName, Int)+getHeaderLevel ns element+  | Just styleName <- getElementStyleName ns element+  , Just n <- stringToInteger . T.unpack =<<+              (T.stripPrefix "heading " . T.toLower $+                fromStyleName styleName)+  , n > 0 = Just (styleName, fromInteger n)+getHeaderLevel _ _ = Nothing++getElementStyleName :: Coercible T.Text a => NameSpaces -> Element -> Maybe a+getElementStyleName ns el = coerce <$>+  ((findChildByName ns "w" "name" el >>= findAttrTextByName ns "w" "val")+  <|> findAttrTextByName ns "w" "styleId" el)++getNumInfo :: NameSpaces -> Element -> Maybe (T.Text, T.Text)+getNumInfo ns element = do+  let numPr = findChildByName ns "w" "pPr" element >>=+              findChildByName ns "w" "numPr"+      lvl = fromMaybe "0" (numPr >>=+                           findChildByName ns "w" "ilvl" >>=+                           findAttrTextByName ns "w" "val")+  numId <- numPr >>=+           findChildByName ns "w" "numId" >>=+           findAttrTextByName ns "w" "val"+  return (numId, lvl)++elemToParStyleData :: NameSpaces -> Element -> Maybe ParStyle -> Maybe ParStyle+elemToParStyleData ns element parentStyle+  | Just styleId <- findAttrTextByName ns "w" "styleId" element+  , Just styleName <- getElementStyleName ns element+  = Just $ ParStyle+      {+        headingLev = getHeaderLevel ns element+      , numInfo = getNumInfo ns element+      , psParentStyle = parentStyle+      , pStyleName = styleName+      , pStyleId = ParaStyleId styleId+      }+elemToParStyleData _ _ _ = Nothing
− src/Text/Pandoc/Readers/Docx/StyleMap.hs
@@ -1,123 +0,0 @@-{-# LANGUAGE NoImplicitPrelude #-}-{- |-   Module      : Text.Pandoc.Readers.Docx.StyleMaps-   Copyright   : © 2014-2019 Jesse Rosenthal <jrosenthal@jhu.edu>,-                   2014-2019 John MacFarlane <jgm@berkeley.edu>,-                   2015 Nikolay Yakimov <root@livid.pp.ru>-   License     : GNU GPL, version 2 or above--   Maintainer  : Jesse Rosenthal <jrosenthal@jhu.edu>-   Stability   : alpha-   Portability : portable--Mappings of element styles (word to pandoc-internal).--}-module Text.Pandoc.Readers.Docx.StyleMap (  StyleMaps(..)-                                          , alterMap-                                          , getMap-                                          , defaultStyleMaps-                                          , getStyleMaps-                                          , getStyleId-                                          , hasStyleName-                                          ) where--import Prelude-import Control.Monad.State.Strict-import Data.Char (toLower)-import qualified Data.Map as M-import Text.Pandoc.Readers.Docx.Util-import Text.XML.Light--newtype ParaStyleMap = ParaStyleMap ( M.Map String String )-newtype CharStyleMap = CharStyleMap ( M.Map String String )--class StyleMap a where-  alterMap :: (M.Map String String -> M.Map String String) -> a -> a-  getMap :: a -> M.Map String String--instance StyleMap ParaStyleMap where-  alterMap f (ParaStyleMap m) = ParaStyleMap $ f m-  getMap (ParaStyleMap m) = m--instance StyleMap CharStyleMap where-  alterMap f (CharStyleMap m) = CharStyleMap $ f m-  getMap (CharStyleMap m) = m--insert :: (StyleMap a) => Maybe String -> Maybe String -> a -> a-insert (Just k) (Just v) m = alterMap (M.insert k v) m-insert _ _ m               = m--getStyleId :: (StyleMap a) => String -> a -> String-getStyleId s = M.findWithDefault (filter (/=' ') s) (map toLower s) . getMap--hasStyleName :: (StyleMap a) => String -> a -> Bool-hasStyleName styleName = M.member (map toLower styleName) . getMap--data StyleMaps = StyleMaps { sNameSpaces   :: NameSpaces-                           , sParaStyleMap :: ParaStyleMap-                           , sCharStyleMap :: CharStyleMap-                           }--data StyleType = ParaStyle | CharStyle--defaultStyleMaps :: StyleMaps-defaultStyleMaps = StyleMaps { sNameSpaces = []-                             , sParaStyleMap = ParaStyleMap M.empty-                             , sCharStyleMap = CharStyleMap M.empty-                             }--type StateM a = State StyleMaps a--getStyleMaps :: Element -> StyleMaps-getStyleMaps docElem = execState genStyleMap state'-    where-    state' = defaultStyleMaps {sNameSpaces = elemToNameSpaces docElem}-    genStyleItem e = do-      styleType <- getStyleType e-      styleId <- getAttrStyleId e-      nameValLowercase <- fmap (map toLower) `fmap` getNameVal e-      case styleType of-        Just ParaStyle -> modParaStyleMap $ insert nameValLowercase styleId-        Just CharStyle -> modCharStyleMap $ insert nameValLowercase styleId-        _              -> return ()-    genStyleMap = do-      style <- elemName' "style"-      let styles = findChildren style docElem-      forM_ styles genStyleItem--modParaStyleMap :: (ParaStyleMap -> ParaStyleMap) -> StateM ()-modParaStyleMap f = modify $ \s ->-  s {sParaStyleMap = f $ sParaStyleMap s}--modCharStyleMap :: (CharStyleMap -> CharStyleMap) -> StateM ()-modCharStyleMap f = modify $ \s ->-  s {sCharStyleMap = f $ sCharStyleMap s}--getStyleType :: Element -> StateM (Maybe StyleType)-getStyleType e = do-  styleTypeStr <- getAttrType e-  case styleTypeStr of-    Just "paragraph" -> return $ Just ParaStyle-    Just "character" -> return $ Just CharStyle-    _                -> return   Nothing--getAttrType :: Element -> StateM (Maybe String)-getAttrType el = do-  name <- elemName' "type"-  return $ findAttr name el--getAttrStyleId :: Element -> StateM (Maybe String)-getAttrStyleId el = do-  name <- elemName' "styleId"-  return $ findAttr name el--getNameVal :: Element -> StateM (Maybe String)-getNameVal el = do-  name <- elemName' "name"-  val <- elemName' "val"-  return $ findChild name el >>= findAttr val--elemName' :: String -> StateM QName-elemName' name = do-  namespaces <- gets sNameSpaces-  return $ elemName namespaces "w" name
src/Text/Pandoc/Readers/Docx/Util.hs view
@@ -19,11 +19,14 @@                                       , elemToNameSpaces                                       , findChildByName                                       , findChildrenByName+                                      , findAttrText                                       , findAttrByName+                                      , findAttrTextByName                                       ) where  import Prelude import Data.Maybe (mapMaybe)+import qualified Data.Text as T import Text.XML.Light  type NameSpaces = [(String, String)]@@ -55,7 +58,13 @@   let ns' = ns ++ elemToNameSpaces el   in  findChildren (elemName ns' pref name) el +findAttrText :: QName -> Element -> Maybe T.Text+findAttrText x = fmap T.pack . findAttr x+ findAttrByName :: NameSpaces -> String -> String -> Element -> Maybe String findAttrByName ns pref name el =   let ns' = ns ++ elemToNameSpaces el   in  findAttr (elemName ns' pref name) el++findAttrTextByName :: NameSpaces -> String -> String -> Element -> Maybe T.Text+findAttrTextByName a b c = fmap T.pack . findAttrByName a b c
src/Text/Pandoc/Readers/DokuWiki.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections     #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Readers.DokuWiki    Copyright   : Copyright (C) 2018-2019 Alexander Krotov@@ -20,8 +21,7 @@ import Control.Monad.Except (throwError) import Data.Char (isAlphaNum, isDigit) import qualified Data.Foldable as F-import Data.List (intercalate, transpose, isPrefixOf, isSuffixOf)-import Data.List.Split (splitOn)+import Data.List (transpose) import Data.Maybe (fromMaybe, catMaybes) import Data.Text (Text) import qualified Data.Text as T@@ -31,7 +31,7 @@ import Text.Pandoc.Error (PandocError (PandocParsecError)) import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (enclosed, nested)-import Text.Pandoc.Shared (crFilter, trim, underlineSpan)+import Text.Pandoc.Shared (crFilter, trim, underlineSpan, stringify, tshow)  -- | Read DokuWiki from an input string and return a Pandoc document. readDokuWiki :: PandocMonad m@@ -42,7 +42,7 @@   let input = crFilter s   res <- runParserT parseDokuWiki def {stateOptions = opts } "source" input   case res of-       Left e  -> throwError $ PandocParsecError (T.unpack input) e+       Left e  -> throwError $ PandocParsecError input e        Right d -> return d  type DWParser = ParserT Text ParserState@@ -71,9 +71,9 @@   B.doc . mconcat <$> many block <* spaces <* eof  -- | Parse <code> and <file> attributes-codeLanguage :: PandocMonad m => DWParser m (String, [String], [(String, String)])+codeLanguage :: PandocMonad m => DWParser m (Text, [Text], [(Text, Text)]) codeLanguage = try $ do-  rawLang <- option "-" (spaceChar *> manyTill anyChar (lookAhead (spaceChar <|> char '>')))+  rawLang <- option "-" (spaceChar *> manyTillChar anyChar (lookAhead (spaceChar <|> char '>')))   let attr = case rawLang of                "-" -> []                l -> [l]@@ -81,16 +81,16 @@  -- | Generic parser for <code> and <file> tags codeTag :: PandocMonad m-        => ((String, [String], [(String, String)]) -> String -> a)-        -> String+        => ((Text, [Text], [(Text, Text)]) -> Text -> a)+        -> Text         -> DWParser m a codeTag f tag = try $ f   <$  char '<'-  <*  string tag+  <*  textStr tag   <*> codeLanguage   <*  manyTill anyChar (char '>')   <*  optional (manyTill spaceChar eol)-  <*> manyTill anyChar (try $ string "</" <* string tag <* char '>')+  <*> manyTillChar anyChar (try $ string "</" <* textStr tag <* char '>')  -- * Inline parsers @@ -167,19 +167,19 @@ underlined = try $ underlineSpan <$> enclosed (string "__") nestedInlines  nowiki :: PandocMonad m => DWParser m B.Inlines-nowiki = try $ B.text <$ string "<nowiki>" <*> manyTill anyChar (try $ string "</nowiki>")+nowiki = try $ B.text <$ string "<nowiki>" <*> manyTillChar anyChar (try $ string "</nowiki>")  percent :: PandocMonad m => DWParser m B.Inlines-percent = try $ B.text <$> enclosed (string "%%") nestedString+percent = try $ B.text <$> enclosed (string "%%") nestedText -nestedString :: (Show a, PandocMonad m)-             => DWParser m a -> DWParser m String-nestedString end = innerSpace <|> count 1 nonspaceChar+nestedText :: (Show a, PandocMonad m)+             => DWParser m a -> DWParser m Text+nestedText end = innerSpace <|> countChar 1 nonspaceChar   where-    innerSpace = try $ many1 spaceChar <* notFollowedBy end+    innerSpace = try $ many1Char spaceChar <* notFollowedBy end  monospaced :: PandocMonad m => DWParser m B.Inlines-monospaced = try $ B.code <$> enclosed (string "''") nestedString+monospaced = try $ B.code . (T.concat . map stringify . B.toList) <$> enclosed (string "''") nestedInlines  subscript :: PandocMonad m => DWParser m B.Inlines subscript = try $ B.subscript <$> between (string "<sub>") (try $ string "</sub>") nestedInlines@@ -201,12 +201,12 @@ inlineFile = codeTag B.codeWith "file"  inlineHtml :: PandocMonad m => DWParser m B.Inlines-inlineHtml = try $ B.rawInline "html" <$ string "<html>" <*> manyTill anyChar (try $ string "</html>")+inlineHtml = try $ B.rawInline "html" <$ string "<html>" <*> manyTillChar anyChar (try $ string "</html>")  inlinePhp :: PandocMonad m => DWParser m B.Inlines-inlinePhp = try $ B.codeWith ("", ["php"], []) <$ string "<php>" <*> manyTill anyChar (try $ string "</php>")+inlinePhp = try $ B.codeWith ("", ["php"], []) <$ string "<php>" <*> manyTillChar anyChar (try $ string "</php>") -makeLink :: (String, String) -> B.Inlines+makeLink :: (Text, Text) -> B.Inlines makeLink (text, url) = B.link url "" $ B.str text  autoEmail :: PandocMonad m => DWParser m B.Inlines@@ -220,7 +220,7 @@   state <- getState   guard $ stateAllowLinks state   (text, url) <- uri-  guard $ checkLink (last url)+  guard $ checkLink (T.last url)   return $ makeLink (text, url)   where     checkLink c@@ -234,10 +234,10 @@ nocache = try $ mempty <$ string "~~NOCACHE~~"  str :: PandocMonad m => DWParser m B.Inlines-str = B.str <$> (many1 alphaNum <|> count 1 characterReference)+str = B.str <$> (many1Char alphaNum <|> countChar 1 characterReference)  symbol :: PandocMonad m => DWParser m B.Inlines-symbol = B.str <$> count 1 nonspaceChar+symbol = B.str <$> countChar 1 nonspaceChar  link :: PandocMonad m => DWParser m B.Inlines link = try $ do@@ -248,77 +248,78 @@   setState $ st{ stateAllowLinks = True }   return l -isExternalLink :: String -> Bool-isExternalLink s =-  case dropWhile (\c -> isAlphaNum c || (c `elem` ['-', '.', '+'])) s of-    (':':'/':'/':_) -> True-    _ -> False+isExternalLink :: Text -> Bool+isExternalLink s = "://" `T.isPrefixOf` sSuff+  where+    sSuff = T.dropWhile (\c -> isAlphaNum c || (c `elem` ['-', '.', '+'])) s -isAbsolutePath :: String -> Bool-isAbsolutePath ('.':_) = False-isAbsolutePath s = ':' `elem` s+isAbsolutePath :: Text -> Bool+isAbsolutePath (T.uncons -> Just ('.', _)) = False+isAbsolutePath s = T.any (== ':') s -normalizeDots :: String -> String-normalizeDots path@('.':_) =-  case dropWhile (== '.') path of-    ':':_ -> path-    _ -> takeWhile (== '.') path ++ ':':dropWhile (== '.') path-normalizeDots path = path+normalizeDots :: Text -> Text+normalizeDots path+  | not (T.null pref) = case T.uncons suff of+      Just (':', _) -> path+      _             -> pref <> ":" <> suff+  | otherwise = path+  where+    (pref, suff) = T.span (== '.') path -normalizeInternalPath :: String -> String+normalizeInternalPath :: Text -> Text normalizeInternalPath path =   if isAbsolutePath path     then ensureAbsolute normalizedPath     else normalizedPath   where-    normalizedPath = intercalate "/" $ dropWhile (== ".") $ splitOn ":" $ normalizeDots path-    ensureAbsolute s@('/':_) = s-    ensureAbsolute s = '/':s+    normalizedPath = T.intercalate "/" $ dropWhile (== ".") $ T.splitOn ":" $ normalizeDots path+    ensureAbsolute s@(T.uncons -> Just ('/', _)) = s+    ensureAbsolute s = "/" <> s -normalizePath :: String -> String+normalizePath :: Text -> Text normalizePath path =   if isExternalLink path     then path     else normalizeInternalPath path -urlToText :: String -> String+urlToText :: Text -> Text urlToText url =   if isExternalLink url     then url-    else reverse $ takeWhile (/= ':') $ reverse url+    else T.takeWhileEnd (/= ':') url  -- Parse link or image parseLink :: PandocMonad m-          => (String -> Maybe B.Inlines -> B.Inlines)-          -> String-          -> String+          => (Text -> Maybe B.Inlines -> B.Inlines)+          -> Text+          -> Text           -> DWParser m B.Inlines parseLink f l r = f-  <$  string l-  <*> many1Till anyChar (lookAhead (void (char '|') <|> try (void $ string r)))-  <*> optionMaybe (B.trimInlines . mconcat <$> (char '|' *> manyTill inline (try $ lookAhead $ string r)))-  <*  string r+  <$  textStr l+  <*> many1TillChar anyChar (lookAhead (void (char '|') <|> try (void $ textStr r)))+  <*> optionMaybe (B.trimInlines . mconcat <$> (char '|' *> manyTill inline (try $ lookAhead $ textStr r)))+  <*  textStr r  -- | Split Interwiki link into left and right part -- | Return Nothing if it is not Interwiki link-splitInterwiki :: String -> Maybe (String, String)+splitInterwiki :: Text -> Maybe (Text, Text) splitInterwiki path =-  case span (\c -> isAlphaNum c || c == '.') path of-    (l, '>':r) -> Just (l, r)+  case T.span (\c -> isAlphaNum c || c == '.') path of+    (l, T.uncons -> Just ('>', r)) -> Just (l, r)     _ -> Nothing -interwikiToUrl :: String -> String -> String-interwikiToUrl "callto" page = "callto://" ++ page-interwikiToUrl "doku" page = "https://www.dokuwiki.org/" ++ page-interwikiToUrl "phpfn" page = "https://secure.php.net/" ++ page-interwikiToUrl "tel" page = "tel:" ++ page-interwikiToUrl "wp" page = "https://en.wikipedia.org/wiki/" ++ page-interwikiToUrl "wpde" page = "https://de.wikipedia.org/wiki/" ++ page-interwikiToUrl "wpes" page = "https://es.wikipedia.org/wiki/" ++ page-interwikiToUrl "wpfr" page = "https://fr.wikipedia.org/wiki/" ++ page-interwikiToUrl "wpjp" page = "https://jp.wikipedia.org/wiki/" ++ page-interwikiToUrl "wppl" page = "https://pl.wikipedia.org/wiki/" ++ page-interwikiToUrl _ page = "https://www.google.com/search?q=" ++ page ++ "&btnI=lucky"+interwikiToUrl :: Text -> Text -> Text+interwikiToUrl "callto" page = "callto://" <> page+interwikiToUrl "doku" page = "https://www.dokuwiki.org/" <> page+interwikiToUrl "phpfn" page = "https://secure.php.net/" <> page+interwikiToUrl "tel" page = "tel:" <> page+interwikiToUrl "wp" page = "https://en.wikipedia.org/wiki/" <> page+interwikiToUrl "wpde" page = "https://de.wikipedia.org/wiki/" <> page+interwikiToUrl "wpes" page = "https://es.wikipedia.org/wiki/" <> page+interwikiToUrl "wpfr" page = "https://fr.wikipedia.org/wiki/" <> page+interwikiToUrl "wpjp" page = "https://jp.wikipedia.org/wiki/" <> page+interwikiToUrl "wppl" page = "https://pl.wikipedia.org/wiki/" <> page+interwikiToUrl _ page = "https://www.google.com/search?q=" <> page <> "&btnI=lucky"  linkText :: PandocMonad m => DWParser m B.Inlines linkText = parseLink fromRaw "[[" "]]"@@ -338,23 +339,23 @@             Just (_, r) -> r  -- Matches strings like "100x100" (width x height) and "50" (width)-isWidthHeightParameter :: String -> Bool+isWidthHeightParameter :: Text -> Bool isWidthHeightParameter s =-  case s of-    (x:xs) ->-      isDigit x && case dropWhile isDigit xs of-                     ('x':ys@(_:_)) -> all isDigit ys-                     "" -> True+  case T.uncons s of+    Just (x, xs) ->+      isDigit x && case T.uncons $ T.dropWhile isDigit xs of+                     Just ('x', ys) | not (T.null ys) -> T.all isDigit ys+                     Nothing -> True                      _ -> False     _ -> False -parseWidthHeight :: String -> (Maybe String, Maybe String)+parseWidthHeight :: Text -> (Maybe Text, Maybe Text) parseWidthHeight s = (width, height)   where-    width = Just $ takeWhile isDigit s+    width = Just $ T.takeWhile isDigit s     height =-      case dropWhile isDigit s of-        ('x':xs) -> Just xs+      case T.uncons $ T.dropWhile isDigit s of+        Just ('x', xs) -> Just xs         _ -> Nothing  image :: PandocMonad m => DWParser m B.Inlines@@ -365,17 +366,17 @@         then B.link normalizedPath "" (fromMaybe defaultDescription description)         else B.imageWith ("", classes, attributes) normalizedPath "" (fromMaybe defaultDescription description)       where-        (path', parameters) = span (/= '?') $ trim path+        (path', parameters) = T.span (/= '?') $ trim path         normalizedPath = normalizePath path'-        leftPadding = " " `isPrefixOf` path-        rightPadding = " " `isSuffixOf` path+        leftPadding = " " `T.isPrefixOf` path+        rightPadding = " " `T.isSuffixOf` path         classes =           case (leftPadding, rightPadding) of             (False, False) -> []             (False, True) -> ["align-left"]             (True, False) -> ["align-right"]             (True, True) -> ["align-center"]-        parameterList = splitOn "&" $ drop 1 parameters+        parameterList = T.splitOn "&" $ T.drop 1 parameters         linkOnly = "linkonly" `elem` parameterList         (width, height) = maybe (Nothing, Nothing) parseWidthHeight (F.find isWidthHeightParameter parameterList)         attributes = catMaybes [fmap ("width",) width, fmap ("height",) height]@@ -389,7 +390,7 @@          <|> blockElements          <|> para   skipMany blankline-  trace (take 60 $ show $ B.toList res)+  trace (T.take 60 $ tshow $ B.toList res)   return res  blockElements :: PandocMonad m => DWParser m B.Blocks@@ -417,30 +418,30 @@   attr <- registerHeader nullAttr contents   return $ B.headerWith attr (7 - lev) contents -list :: PandocMonad m => String -> DWParser m B.Blocks+list :: PandocMonad m => Text -> DWParser m B.Blocks list prefix = bulletList prefix <|> orderedList prefix -bulletList :: PandocMonad m => String -> DWParser m B.Blocks+bulletList :: PandocMonad m => Text -> DWParser m B.Blocks bulletList prefix = try $ B.bulletList <$> parseList prefix '*' -orderedList :: PandocMonad m => String -> DWParser m B.Blocks+orderedList :: PandocMonad m => Text -> DWParser m B.Blocks orderedList prefix = try $ B.orderedList <$> parseList prefix '-'  parseList :: PandocMonad m-          => String+          => Text           -> Char           -> DWParser m [B.Blocks] parseList prefix marker =   many1 ((<>) <$> item <*> fmap mconcat (many continuation))   where-    continuation = try $ list ("  " ++ prefix)-    item = try $ string prefix *> char marker *> char ' ' *> itemContents+    continuation = try $ list ("  " <> prefix)+    item = try $ textStr prefix *> char marker *> char ' ' *> itemContents     itemContents = B.plain . mconcat <$> many1Till inline' eol  indentedCode :: PandocMonad m => DWParser m B.Blocks-indentedCode = try $ B.codeBlock . unlines <$> many1 indentedLine+indentedCode = try $ B.codeBlock . T.unlines <$> many1 indentedLine  where-   indentedLine = try $ string "  " *> manyTill anyChar eol+   indentedLine = try $ string "  " *> manyTillChar anyChar eol  quote :: PandocMonad m => DWParser m B.Blocks quote = try $ nestedQuote 0@@ -456,13 +457,13 @@ blockHtml = try $ B.rawBlock "html"   <$  string "<HTML>"   <*  optional (manyTill spaceChar eol)-  <*> manyTill anyChar (try $ string "</HTML>")+  <*> manyTillChar anyChar (try $ string "</HTML>")  blockPhp :: PandocMonad m => DWParser m B.Blocks blockPhp = try $ B.codeBlockWith ("", ["php"], [])   <$  string "<PHP>"   <*  optional (manyTill spaceChar eol)-  <*> manyTill anyChar (try $ string "</PHP>")+  <*> manyTillChar anyChar (try $ string "</PHP>")  table :: PandocMonad m => DWParser m B.Blocks table = do
src/Text/Pandoc/Readers/EPUB.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TupleSections     #-} {-# LANGUAGE ViewPatterns      #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.EPUB    Copyright   : Copyright (C) 2014-2019 Matthew Pickering@@ -21,10 +22,11 @@ import Codec.Archive.Zip (Archive (..), Entry, findEntryByPath, fromEntry,                           toArchiveOrFail) import Control.DeepSeq (NFData, deepseq)-import Control.Monad (guard, liftM)+import Control.Monad (guard, liftM, liftM2, mplus) import Control.Monad.Except (throwError) import qualified Data.ByteString.Lazy as BL (ByteString)-import Data.List (isInfixOf, isPrefixOf)+import Data.List (isInfixOf)+import qualified Data.Text as T import qualified Data.Map as M (Map, elems, fromList, lookup) import Data.Maybe (fromMaybe, mapMaybe) import qualified Data.Text.Lazy as TL@@ -62,14 +64,14 @@ archiveToEPUB os archive = do   -- root is path to folder with manifest file in   (root, content) <- getManifest archive-  meta  <- parseMeta content-  (cover, items) <- parseManifest content+  (coverId, meta) <- parseMeta content+  (cover, items)  <- parseManifest content coverId   -- No need to collapse here as the image path is from the manifest file   let coverDoc = fromMaybe mempty (imageToPandoc <$> cover)   spine <- parseSpine items content-  let escapedSpine = map (escapeURI . takeFileName . fst) spine+  let escapedSpine = map (escapeURI . T.pack . takeFileName . fst) spine   Pandoc _ bs <--      foldM' (\a b -> ((a <>) . walk (prependHash escapedSpine))+      foldM' (\a b -> ((a <>) . walk (prependHash $ escapedSpine))         `liftM` parseSpineElem root b) mempty spine   let ast = coverDoc <> Pandoc meta bs   fetchImages (M.elems items) root archive ast@@ -79,7 +81,7 @@     parseSpineElem :: PandocMonad m => FilePath -> (FilePath, MimeType) -> m Pandoc     parseSpineElem (normalise -> r) (normalise -> path, mime) = do       doc <- mimeToReader mime r path-      let docSpan = B.doc $ B.para $ B.spanWith (takeFileName path, [], []) mempty+      let docSpan = B.doc $ B.para $ B.spanWith (T.pack $ takeFileName path, [], []) mempty       return $ docSpan <> doc     mimeToReader :: PandocMonad m => MimeType -> FilePath -> FilePath -> m Pandoc     mimeToReader "application/xhtml+xml" (unEscapeString -> root)@@ -108,39 +110,44 @@           <$> findEntryByPath abslink arc  iq :: Inline -> [FilePath]-iq (Image _ _ (url, _)) = [url]+iq (Image _ _ (url, _)) = [T.unpack url] iq _                    = []  -- Remove relative paths renameImages :: FilePath -> Inline -> Inline renameImages root img@(Image attr a (url, b))-  | "data:" `isPrefixOf` url = img-  | otherwise                = Image attr a (collapseFilePath (root </> url), b)+  | "data:" `T.isPrefixOf` url = img+  | otherwise                  = Image attr a ( T.pack $ collapseFilePath (root </> T.unpack url)+                                              , b) renameImages _ x = x  imageToPandoc :: FilePath -> Pandoc-imageToPandoc s = B.doc . B.para $ B.image s "" mempty+imageToPandoc s = B.doc . B.para $ B.image (T.pack s) "" mempty  imageMimes :: [MimeType] imageMimes = ["image/gif", "image/jpeg", "image/png"] +type CoverId = String+ type CoverImage = FilePath -parseManifest :: (PandocMonad m) => Element -> m (Maybe CoverImage, Items)-parseManifest content = do+parseManifest :: (PandocMonad m) => Element -> Maybe CoverId -> m (Maybe CoverImage, Items)+parseManifest content coverId = do   manifest <- findElementE (dfName "manifest") content   let items = findChildren (dfName "item") manifest   r <- mapM parseItem items   let cover = findAttr (emptyName "href") =<< filterChild findCover manifest-  return (cover, M.fromList r)+  return (cover `mplus` coverId, M.fromList r)   where     findCover e = maybe False (isInfixOf "cover-image")                   (findAttr (emptyName "properties") e)+               || fromMaybe False+                  (liftM2 (==) coverId (findAttr (emptyName "id") e))     parseItem e = do       uid <- findAttrE (emptyName "id") e       href <- findAttrE (emptyName "href") e       mime <- findAttrE (emptyName "media-type") e-      return (uid, (href, mime))+      return (uid, (href, T.pack mime))  parseSpine :: PandocMonad m => Items -> Element -> m [(FilePath, MimeType)] parseSpine is e = do@@ -153,23 +160,26 @@       guard linear       findAttr (emptyName "idref") ref -parseMeta :: PandocMonad m => Element -> m Meta+parseMeta :: PandocMonad m => Element -> m (Maybe CoverId, Meta) parseMeta content = do   meta <- findElementE (dfName "metadata") content   let dcspace (QName _ (Just "http://purl.org/dc/elements/1.1/") (Just "dc")) = True       dcspace _ = False   let dcs = filterChildrenName dcspace meta   let r = foldr parseMetaItem nullMeta dcs-  return r+  let coverId = findAttr (emptyName "content") =<< filterChild findCover meta+  return (coverId, r)+  where+    findCover e = maybe False (== "cover") (findAttr (emptyName "name") e)  -- http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-metadata-elem parseMetaItem :: Element -> Meta -> Meta parseMetaItem e@(stripNamespace . elName -> field) meta =-  addMetaField (renameMeta field) (B.str $ strContent e) meta+  addMetaField (renameMeta field) (B.str $ T.pack $ strContent e) meta -renameMeta :: String -> String+renameMeta :: String -> T.Text renameMeta "creator" = "author"-renameMeta s         = s+renameMeta s         = T.pack s  getManifest :: PandocMonad m => Archive -> m (String, Element) getManifest archive = do@@ -190,26 +200,26 @@ fixInternalReferences :: FilePath -> Pandoc -> Pandoc fixInternalReferences pathToFile =    walk (renameImages root)-  .  walk (fixBlockIRs filename)+  . walk (fixBlockIRs filename)   . walk (fixInlineIRs filename)   where-    (root, escapeURI -> filename) = splitFileName pathToFile+    (root, T.unpack . escapeURI . T.pack -> filename) = splitFileName pathToFile  fixInlineIRs :: String -> Inline -> Inline fixInlineIRs s (Span as v) =   Span (fixAttrs s as) v fixInlineIRs s (Code as code) =   Code (fixAttrs s as) code-fixInlineIRs s (Link as is ('#':url, tit)) =+fixInlineIRs s (Link as is (T.uncons -> Just ('#', url), tit)) =   Link (fixAttrs s as) is (addHash s url, tit) fixInlineIRs s (Link as is t) =   Link (fixAttrs s as) is t fixInlineIRs _ v = v -prependHash :: [String] -> Inline -> Inline+prependHash :: [T.Text] -> Inline -> Inline prependHash ps l@(Link attr is (url, tit))-  | or [s `isPrefixOf` url | s <- ps] =-    Link attr is ('#':url, tit)+  | or [s `T.isPrefixOf` url | s <- ps] =+    Link attr is ("#" <> url, tit)   | otherwise = l prependHash _ i = i @@ -223,17 +233,17 @@ fixBlockIRs _ b = b  fixAttrs :: FilePath -> B.Attr -> B.Attr-fixAttrs s (ident, cs, kvs) = (addHash s ident, filter (not . null) cs, removeEPUBAttrs kvs)+fixAttrs s (ident, cs, kvs) = (addHash s ident, filter (not . T.null) cs, removeEPUBAttrs kvs) -addHash :: String -> String -> String+addHash :: String -> T.Text -> T.Text addHash _ ""    = ""-addHash s ident = takeFileName s ++ "#" ++ ident+addHash s ident = T.pack (takeFileName s) <> "#" <> ident -removeEPUBAttrs :: [(String, String)] -> [(String, String)]+removeEPUBAttrs :: [(T.Text, T.Text)] -> [(T.Text, T.Text)] removeEPUBAttrs kvs = filter (not . isEPUBAttr) kvs -isEPUBAttr :: (String, String) -> Bool-isEPUBAttr (k, _) = "epub:" `isPrefixOf` k+isEPUBAttr :: (T.Text, a) -> Bool+isEPUBAttr (k, _) = "epub:" `T.isPrefixOf` k  -- Library @@ -284,4 +294,4 @@ findElementE e x = mkE ("Unable to find element: " ++ show e) $ findElement e x  mkE :: PandocMonad m => String -> Maybe a -> m a-mkE s = maybe (throwError . PandocParseError $ s) return+mkE s = maybe (throwError . PandocParseError $ T.pack $ s) return
src/Text/Pandoc/Readers/FB2.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TupleSections #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.FB2    Copyright   : Copyright (C) 2018-2019 Alexander Krotov@@ -27,12 +28,11 @@ import Control.Monad.State.Strict import Data.ByteString.Lazy.Char8 ( pack ) import Data.ByteString.Base64.Lazy-import Data.Char (isSpace, toUpper) import Data.Functor-import Data.List (dropWhileEnd, intersperse)-import Data.List.Split (splitOn)+import Data.List (intersperse) import qualified Data.Map as M import Data.Text (Text)+import qualified Data.Text as T import Data.Default import Data.Maybe import Text.HTML.TagSoup.Entity (lookupEntity)@@ -48,8 +48,8 @@  data FB2State = FB2State{ fb2SectionLevel :: Int                         , fb2Meta :: Meta-                        , fb2Authors :: [String]-                        , fb2Notes :: M.Map String Blocks+                        , fb2Authors :: [Text]+                        , fb2Notes :: M.Map Text Blocks                         } deriving Show  instance Default FB2State where@@ -76,19 +76,20 @@  -- * Utility functions -trim :: String -> String-trim = dropWhileEnd isSpace . dropWhile isSpace+trim :: Text -> Text+trim = T.strip -removeHash :: String -> String-removeHash ('#':xs) = xs-removeHash xs = xs+removeHash :: Text -> Text+removeHash t = case T.uncons t of+  Just ('#', xs) -> xs+  _              -> t -convertEntity :: String -> String-convertEntity e = fromMaybe (map toUpper e) (lookupEntity e)+convertEntity :: String -> Text+convertEntity e = maybe (T.toUpper $ T.pack e) T.pack $ lookupEntity e  parseInline :: PandocMonad m => Content -> FB2 m Inlines parseInline (Elem e) =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "strong" -> strong <$> parseStyleType e     "emphasis" -> emph <$> parseStyleType e     "style" -> parseNamedStyle e@@ -96,12 +97,12 @@     "strikethrough" -> strikeout <$> parseStyleType e     "sub" -> subscript <$> parseStyleType e     "sup" -> superscript <$> parseStyleType e-    "code" -> pure $ code $ strContent e+    "code" -> pure $ code $ T.pack $ strContent e     "image" -> parseInlineImageElement e     name -> do       report $ IgnoredElement name       pure mempty-parseInline (Text x) = pure $ text $ cdData x+parseInline (Text x) = pure $ text $ T.pack $ cdData x parseInline (CRef r) = pure $ str $ convertEntity r  parseSubtitle :: PandocMonad m => Element -> FB2 m Blocks@@ -111,7 +112,7 @@  parseRootElement :: PandocMonad m => Element -> FB2 m Blocks parseRootElement e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "FictionBook" -> do       -- Parse notes before parsing the rest of the content.       case filterChild isNotesBody e of@@ -144,19 +145,19 @@     Just sectionId -> do       content <- mconcat <$> mapM parseSectionChild (dropTitle $ elChildren e)       oldNotes <- gets fb2Notes-      modify $ \s -> s { fb2Notes = M.insert ("#" ++ sectionId) content oldNotes }+      modify $ \s -> s { fb2Notes = M.insert ("#" <> T.pack sectionId) content oldNotes }       pure ()   where     isTitle x = qName (elName x) == "title"     dropTitle (x:xs) = if isTitle x                          then xs -- Drop note section <title> if present-                         else (x:xs)+                         else x:xs     dropTitle [] = []  -- | Parse a child of @\<FictionBook>@ element. parseFictionBookChild :: PandocMonad m => Element -> FB2 m Blocks parseFictionBookChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "stylesheet" -> pure mempty -- stylesheet is ignored     "description" -> mempty <$ mapM_ parseDescriptionChild (elChildren e)     "body" -> if isNotesBody e@@ -168,7 +169,7 @@ -- | Parse a child of @\<description>@ element. parseDescriptionChild :: PandocMonad m => Element -> FB2 m () parseDescriptionChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "title-info" -> mapM_ parseTitleInfoChild (elChildren e)     "src-title-info" -> pure () -- ignore     "document-info" -> pure ()@@ -176,13 +177,13 @@     "custom-info" -> pure ()     "output" -> pure ()     name -> do-      report $ IgnoredElement $ name ++ " in description"+      report $ IgnoredElement $ name <> " in description"       pure mempty  -- | Parse a child of @\<body>@ element. parseBodyChild :: PandocMonad m => Element -> FB2 m Blocks parseBodyChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "image" -> parseImageElement e     "title" -> header <$> gets fb2SectionLevel <*> parseTitleType (elContent e)     "epigraph" -> parseEpigraph e@@ -196,25 +197,25 @@     (Nothing, _) -> report $ IgnoredElement "binary without id attribute"     (Just _, Nothing) ->       report $ IgnoredElement "binary without content-type attribute"-    (Just filename, contentType) -> insertMedia filename contentType (decodeLenient (pack (strContent e)))+    (Just filename, contentType) -> insertMedia filename (T.pack <$> contentType) (decodeLenient (pack (strContent e)))  -- * Type parsers  -- | Parse @authorType@-parseAuthor :: PandocMonad m => Element -> FB2 m String-parseAuthor e = unwords . catMaybes <$> mapM parseAuthorChild (elChildren e)+parseAuthor :: PandocMonad m => Element -> FB2 m Text+parseAuthor e = T.unwords . catMaybes <$> mapM parseAuthorChild (elChildren e) -parseAuthorChild :: PandocMonad m => Element -> FB2 m (Maybe String)+parseAuthorChild :: PandocMonad m => Element -> FB2 m (Maybe Text) parseAuthorChild e =-  case qName $ elName e of-    "first-name" -> pure $ Just $ strContent e-    "middle-name" -> pure $ Just $ strContent e-    "last-name" -> pure $ Just $ strContent e-    "nickname" -> pure $ Just $ strContent e-    "home-page" -> pure $ Just $ strContent e-    "email" -> pure $ Just $ strContent e+  case T.pack $ qName $ elName e of+    "first-name" -> pure $ Just $ T.pack $ strContent e+    "middle-name" -> pure $ Just $ T.pack $ strContent e+    "last-name" -> pure $ Just $ T.pack $ strContent e+    "nickname" -> pure $ Just $ T.pack $ strContent e+    "home-page" -> pure $ Just $ T.pack $ strContent e+    "email" -> pure $ Just $ T.pack $ strContent e     name -> do-      report $ IgnoredElement $ name ++ " in author"+      report $ IgnoredElement $ name <> " in author"       pure Nothing  -- | Parse @titleType@@@ -236,13 +237,13 @@ parseImageElement :: PandocMonad m => Element -> FB2 m Blocks parseImageElement e =   case href of-    Just src -> pure $ para $ imageWith (imgId, [], []) (removeHash src) title alt+    Just src -> pure $ para $ imageWith (imgId, [], []) (removeHash $ T.pack src) title alt     Nothing -> do       report $ IgnoredElement " image without href"       pure mempty-  where alt = maybe mempty str $ findAttr (unqual "alt") e-        title = fromMaybe "" $ findAttr (unqual "title") e-        imgId = fromMaybe "" $ findAttr (unqual "id") e+  where alt = maybe mempty (str . T.pack) $ findAttr (unqual "alt") e+        title = maybe "" T.pack $ findAttr (unqual "title") e+        imgId = maybe "" T.pack $ findAttr (unqual "id") e         href = findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e  -- | Parse @pType@@@ -256,7 +257,7 @@ -- | Parse @citeType@ child parseCiteChild :: PandocMonad m => Element -> FB2 m Blocks parseCiteChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "p" -> para <$> parsePType e     "poem" -> parsePoem e     "empty-line" -> pure horizontalRule@@ -271,13 +272,13 @@  parsePoemChild :: PandocMonad m => Element -> FB2 m Blocks parsePoemChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "title" -> parseTitle e     "subtitle" -> parseSubtitle e     "epigraph" -> parseEpigraph e     "stanza" -> parseStanza e     "text-author" -> para <$> parsePType e-    "date" -> pure $ para $ text $ strContent e+    "date" -> pure $ para $ text $ T.pack $ strContent e     name -> report (UnexpectedXmlElement name "poem") $> mempty  parseStanza :: PandocMonad m => Element -> FB2 m Blocks@@ -290,7 +291,7 @@  parseStanzaChild :: PandocMonad m => Element -> FB2 m Blocks parseStanzaChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "title" -> parseTitle e     "subtitle" -> parseSubtitle e     "v" -> lineBlock . (:[]) <$> parsePType e@@ -300,11 +301,11 @@ parseEpigraph :: PandocMonad m => Element -> FB2 m Blocks parseEpigraph e =   divWith (divId, ["epigraph"], []) . mconcat <$> mapM parseEpigraphChild (elChildren e)-  where divId = fromMaybe "" $ findAttr (unqual "id") e+  where divId = maybe "" T.pack $ findAttr (unqual "id") e  parseEpigraphChild :: PandocMonad m => Element -> FB2 m Blocks parseEpigraphChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "p" -> para <$> parsePType e     "poem" -> parsePoem e     "cite" -> parseCite e@@ -318,7 +319,7 @@  parseAnnotationChild :: PandocMonad m => Element -> FB2 m Blocks parseAnnotationChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "p" -> para <$> parsePType e     "poem" -> parsePoem e     "cite" -> parseCite e@@ -332,14 +333,14 @@ parseSection e = do   n <- gets fb2SectionLevel   modify $ \st -> st{ fb2SectionLevel = n + 1 }-  let sectionId = fromMaybe "" $ findAttr (unqual "id") e+  let sectionId = maybe "" T.pack $ findAttr (unqual "id") e   bs <- divWith (sectionId, ["section"], []) . mconcat <$> mapM parseSectionChild (elChildren e)   modify $ \st -> st{ fb2SectionLevel = n }   pure bs  parseSectionChild :: PandocMonad m => Element -> FB2 m Blocks parseSectionChild e =-  case qName $ elName e of+  case T.pack $ qName $ elName e of     "title" -> parseBodyChild e     "epigraph" -> parseEpigraph e     "image" -> parseImageElement e@@ -361,16 +362,16 @@ parseNamedStyle :: PandocMonad m => Element -> FB2 m Inlines parseNamedStyle e = do   content <- mconcat <$> mapM parseNamedStyleChild (elContent e)-  let lang = maybeToList $ ("lang",) <$> findAttr (QName "lang" Nothing (Just "xml")) e+  let lang = maybeToList $ ("lang",) . T.pack <$> findAttr (QName "lang" Nothing (Just "xml")) e   case findAttr (unqual "name") e of-    Just name -> pure $ spanWith ("", [name], lang) content+    Just name -> pure $ spanWith ("", [T.pack name], lang) content     Nothing -> do       report $ IgnoredElement "link without required name"       pure mempty  parseNamedStyleChild :: PandocMonad m => Content -> FB2 m Inlines parseNamedStyleChild (Elem e) =-  case qName (elName e) of+  case T.pack $ qName (elName e) of     "strong" -> strong <$> parseStyleType e     "emphasis" -> emph <$> parseStyleType e     "style" -> parseNamedStyle e@@ -378,10 +379,10 @@     "strikethrough" -> strikeout <$> parseStyleType e     "sub" -> subscript <$> parseStyleType e     "sup" -> superscript <$> parseStyleType e-    "code" -> pure $ code $ strContent e+    "code" -> pure $ code $ T.pack $ strContent e     "image" -> parseInlineImageElement e     name -> do-      report $ IgnoredElement $ name ++ " in style"+      report $ IgnoredElement $ name <> " in style"       pure mempty parseNamedStyleChild x = parseInline x @@ -390,7 +391,7 @@ parseLinkType e = do   content <- mconcat <$> mapM parseStyleLinkType (elContent e)   notes <- gets fb2Notes-  case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of+  case T.pack <$> findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of     Just href -> case findAttr (QName "type" Nothing Nothing) e of                    Just "note" -> case M.lookup href notes of                                     Nothing -> pure $ link href "" content@@ -417,19 +418,21 @@ -- | Parse @title-infoType@ parseTitleInfoChild :: PandocMonad m => Element -> FB2 m () parseTitleInfoChild e =-  case qName (elName e) of+  case T.pack $ qName (elName e) of     "genre" -> pure ()     "author" -> parseAuthor e >>= \author -> modify (\st -> st {fb2Authors = author:fb2Authors st})-    "book-title" -> modify (setMeta "title" (text $ strContent e))+    "book-title" -> modify (setMeta "title" (text $ T.pack $ strContent e))     "annotation" -> parseAnnotation e >>= modify . setMeta "abstract"-    "keywords" -> modify (setMeta "keywords" (map (MetaString . trim) $ splitOn "," $ strContent e))-    "date" -> modify (setMeta "date" (text $ strContent e))+    "keywords" -> modify (setMeta "keywords" (map (MetaString . trim) $ T.splitOn ","+                                                                      $ T.pack+                                                                      $ strContent e))+    "date" -> modify (setMeta "date" (text $ T.pack $ strContent e))     "coverpage" -> parseCoverPage e     "lang" -> pure ()     "src-lang" -> pure ()     "translator" -> pure ()     "sequence" -> pure ()-    name -> report $ IgnoredElement $ name ++ " in title-info"+    name -> report $ IgnoredElement $ name <> " in title-info"  parseCoverPage :: PandocMonad m => Element -> FB2 m () parseCoverPage e =@@ -437,7 +440,7 @@     Just img -> case href of                   Just src -> modify (setMeta "cover-image" (MetaString $ removeHash src))                   Nothing -> pure ()-                where href = findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) img+                where href = T.pack <$> findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) img     Nothing -> pure ()  -- | Parse @inlineImageType@ element@@ -450,5 +453,5 @@     Nothing -> do       report $ IgnoredElement "inline image without href"       pure mempty-  where alt = maybe mempty str $ findAttr (unqual "alt") e-        href = findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e+  where alt = maybe mempty (str . T.pack) $ findAttr (unqual "alt") e+        href = T.pack <$> findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e
src/Text/Pandoc/Readers/HTML.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE LambdaCase        #-}+{-# LANGUAGE NoImplicitPrelude     #-}+{-# LANGUAGE LambdaCase            #-} {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -35,8 +35,7 @@ import Data.Char (isAlphaNum, isLetter) import Data.Default (Default (..), def) import Data.Foldable (for_)-import Data.List (isPrefixOf)-import Data.List.Split (wordsBy, splitWhen)+import Data.List.Split (splitWhen) import qualified Data.Map as M import Data.Maybe (fromMaybe, isJust, isNothing) import Data.Monoid (First (..))@@ -62,7 +61,8 @@     extensionEnabled) import Text.Pandoc.Parsing hiding ((<|>)) import Text.Pandoc.Shared (addMetaField, blocksToInlines', crFilter, escapeURI,-    extractSpaces, onlySimpleTableCells, safeRead, underlineSpan)+                           extractSpaces, htmlSpanLikeElements, elemText, splitTextBy,+                           onlySimpleTableCells, safeRead, underlineSpan, tshow) import Text.Pandoc.Walk import Text.Parsec.Error import Text.TeXMath (readMathML, writeTeX)@@ -92,14 +92,14 @@        "source" tags   case result of     Right doc -> return doc-    Left  err -> throwError $ PandocParseError $ getError err+    Left  err -> throwError $ PandocParseError $ T.pack $ getError err  replaceNotes :: PandocMonad m => [Block] -> TagParser m [Block] replaceNotes bs = do   st <- getState   return $ walk (replaceNotes' (noteTable st)) bs -replaceNotes' :: [(String, Blocks)] -> Inline -> Inline+replaceNotes' :: [(Text, Blocks)] -> Inline -> Inline replaceNotes' noteTbl (RawInline (Format "noteref") ref) =   maybe (Str "") (Note . B.toList) $ lookup ref noteTbl replaceNotes' _ x = x@@ -107,9 +107,9 @@ data HTMLState =   HTMLState   {  parserState :: ParserState,-     noteTable   :: [(String, Blocks)],+     noteTable   :: [(Text, Blocks)],      baseHref    :: Maybe URI,-     identifiers :: Set.Set String,+     identifiers :: Set.Set Text,      logMessages :: [LogMessage],      macros      :: M.Map Text Macro   }@@ -133,7 +133,7 @@ pHtml = try $ do   (TagOpen "html" attr) <- lookAhead pAny   for_ (lookup "lang" attr) $-    updateState . B.setMeta "lang" . B.text . T.unpack+    updateState . B.setMeta "lang" . B.text   pInTags "html" block  pBody :: PandocMonad m => TagParser m Blocks@@ -145,11 +145,11 @@         setTitle t = mempty <$ updateState (B.setMeta "title" t)         pMetaTag = do           mt <- pSatisfy (matchTagOpen "meta" [])-          let name = T.unpack $ fromAttrib "name" mt-          if null name+          let name = fromAttrib "name" mt+          if T.null name              then return mempty              else do-               let content = T.unpack $ fromAttrib "content" mt+               let content = fromAttrib "content" mt                updateState $ \s ->                  let ps = parserState s in                  s{ parserState = ps{@@ -186,13 +186,13 @@             , pFigure             , pRawHtmlBlock             ]-  trace (take 60 $ show $ B.toList res)+  trace (T.take 60 $ tshow $ B.toList res)   return res -namespaces :: PandocMonad m => [(String, TagParser m Inlines)]+namespaces :: PandocMonad m => [(Text, TagParser m Inlines)] namespaces = [(mathMLNamespace, pMath True)] -mathMLNamespace :: String+mathMLNamespace :: Text mathMLNamespace = "http://www.w3.org/1998/Math/MathML"  eSwitch :: (PandocMonad m, Monoid a)@@ -232,7 +232,7 @@   content <- pInTags tag block   addNote ident content -addNote :: PandocMonad m => String -> Blocks -> TagParser m ()+addNote :: PandocMonad m => Text -> Blocks -> TagParser m () addNote uid cont = updateState (\s -> s {noteTable = (uid, cont) : noteTable s})  eNoteref :: PandocMonad m => TagParser m Inlines@@ -244,8 +244,8 @@                     -> (lookup "type" as <|> lookup "epub:type" as)                         == Just "noteref"                  _  -> False)-  ident <- case T.unpack <$> lookup "href" attr of-             Just ('#':rest) -> return rest+  ident <- case lookup "href" attr >>= T.uncons of+             Just ('#', rest) -> return rest              _ -> mzero   _ <- manyTill pAny (pSatisfy (\case                                    TagClose t -> t == tag@@ -286,7 +286,7 @@   maybe id addId (lookup "id" attr) <$>     pInTags "li" block <* skipMany nonItem -parseListStyleType :: String -> ListNumberStyle+parseListStyleType :: Text -> ListNumberStyle parseListStyleType "lower-roman" = LowerRoman parseListStyleType "upper-roman" = UpperRoman parseListStyleType "lower-alpha" = LowerAlpha@@ -294,7 +294,7 @@ parseListStyleType "decimal"     = Decimal parseListStyleType _             = DefaultStyle -parseTypeAttr :: String -> ListNumberStyle+parseTypeAttr :: Text -> ListNumberStyle parseTypeAttr "i" = LowerRoman parseTypeAttr "I" = UpperRoman parseTypeAttr "a" = LowerAlpha@@ -403,20 +403,19 @@  pRawHtmlBlock :: PandocMonad m => TagParser m Blocks pRawHtmlBlock = do-  raw <- T.unpack <$>-    (pHtmlBlock "script" <|> pHtmlBlock "style" <|> pHtmlBlock "textarea"-      <|> pRawTag)+  raw <- (pHtmlBlock "script" <|> pHtmlBlock "style" <|> pHtmlBlock "textarea"+          <|> pRawTag)   exts <- getOption readerExtensions-  if extensionEnabled Ext_raw_html exts && not (null raw)+  if extensionEnabled Ext_raw_html exts && not (T.null raw)      then return $ B.rawBlock "html" raw      else ignore raw -ignore :: (Monoid a, PandocMonad m) => String -> TagParser m a+ignore :: (Monoid a, PandocMonad m) => Text -> TagParser m a ignore raw = do   pos <- getPosition   -- raw can be null for tags like <!DOCTYPE>; see paRawTag   -- in this case we don't want a warning:-  unless (null raw) $+  unless (T.null raw) $     logMessage $ SkippedContent raw pos   return mempty @@ -435,9 +434,9 @@   TagOpen tag _ <- lookAhead $ pSatisfy sectTag   setInChapter (pInTags tag block) -headerLevel :: PandocMonad m => Text -> TagParser m Int+headerLevel :: Text -> TagParser m Int headerLevel tagtype =-  case safeRead (T.unpack (T.drop 1 tagtype)) of+  case safeRead (T.drop 1 tagtype) of         Just level -> --          try (do --            guardEnabled Ext_epub_html_exts@@ -445,7 +444,7 @@ --            return (level - 1)) --            <|>               return level-        Nothing -> fail "Could not retrieve header level"+        Nothing -> Prelude.fail "Could not retrieve header level"  eTitlePage :: PandocMonad m => TagParser m () eTitlePage = try $ do@@ -467,7 +466,7 @@   level <- headerLevel tagtype   contents <- trimInlines . mconcat <$> manyTill inline (pCloses tagtype <|> eof)   let ident = fromMaybe "" $ lookup "id" attr-  let classes = maybe [] words $ lookup "class" attr+  let classes = maybe [] T.words $ lookup "class" attr   let keyvals = [(k,v) | (k,v) <- attr, k /= "class", k /= "id"]   attr'' <- registerHeader (ident, classes, keyvals) contents   return $ if bodyTitle@@ -528,14 +527,14 @@   optional $ pSatisfy (matchTagClose "col")   skipMany pBlank   let width = case lookup "width" attribs of-           Nothing -> case lookup "style" attribs of-               Just ('w':'i':'d':'t':'h':':':xs) | '%' `elem` xs ->-                 fromMaybe 0.0 $ safeRead (filter-                   (`notElem` (" \t\r\n%'\";" :: [Char])) xs)-               _ -> 0.0-           Just x | not (null x) && last x == '%' ->-             fromMaybe 0.0 $ safeRead (init x)-           _ -> 0.0+                Nothing -> case lookup "style" attribs of+                  Just (T.stripPrefix "width:" -> Just xs) | T.any (== '%') xs ->+                    fromMaybe 0.0 $ safeRead (T.filter+                      (`notElem` (" \t\r\n%'\";" :: [Char])) xs)+                  _ -> 0.0+                Just (T.unsnoc -> Just (xs, '%')) ->+                  fromMaybe 0.0 $ safeRead xs+                _ -> 0.0   if width > 0.0     then return $ width / 100.0     else return 0.0@@ -561,7 +560,7 @@   let extractAlign' []                 = ""       extractAlign' ("text-align":x:_) = x       extractAlign' (_:xs)             = extractAlign' xs-  let extractAlign = extractAlign' . wordsBy (`elem` [' ','\t',';',':'])+  let extractAlign = extractAlign' . splitTextBy (`elemText` " \t;:")   let align = case maybeFromAttrib "align" tag `mplus`                    (extractAlign <$> maybeFromAttrib "style" tag) of                    Just "left"   -> AlignLeft@@ -609,7 +608,7 @@   let caption = fromMaybe mempty mbcap   case B.toList <$> mbimg of        Just [Image attr _ (url, tit)] ->-         return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption+         return $ B.para $ B.imageWith attr url ("fig:" <> tit) caption        _ -> mzero  pCodeBlock :: PandocMonad m => TagParser m Blocks@@ -617,21 +616,21 @@   TagOpen _ attr' <- pSatisfy (matchTagOpen "pre" [])   let attr = toStringAttr attr'   contents <- manyTill pAny (pCloses "pre" <|> eof)-  let rawText = concatMap tagToString contents+  let rawText = T.concat $ map tagToText contents   -- drop leading newline if any-  let result' = case rawText of-                     '\n':xs -> xs-                     _       -> rawText+  let result' = case T.uncons rawText of+                     Just ('\n', xs) -> xs+                     _               -> rawText   -- drop trailing newline if any-  let result = case reverse result' of-                    '\n':_ -> init result'-                    _      -> result'+  let result = case T.unsnoc result' of+                    Just (result'', '\n') -> result''+                    _                     -> result'   return $ B.codeBlockWith (mkAttr attr) result -tagToString :: Tag Text -> String-tagToString (TagText s)      = T.unpack s-tagToString (TagOpen "br" _) = "\n"-tagToString _                = ""+tagToText :: Tag Text -> Text+tagToText (TagText s)      = s+tagToText (TagOpen "br" _) = "\n"+tagToText _                = ""  inline :: PandocMonad m => TagParser m Inlines inline = choice@@ -643,6 +642,7 @@            , pStrong            , pSuperscript            , pSubscript+           , pSpanLike            , pSmall            , pStrikeout            , pUnderline@@ -650,6 +650,7 @@            , pLink            , pImage            , pCode+           , pCodeWithClass [("samp","sample"),("var","variable")]            , pSpan            , pMath False            , pScriptMath@@ -664,7 +665,7 @@ pSat :: PandocMonad m => (Tag Text -> Bool) -> TagParser m (Tag Text) pSat f = do   pos <- getPosition-  token show (const pos) (\x -> if f x then Just x else Nothing)+  token tshow (const pos) (\x -> if f x then Just x else Nothing)  pSatisfy :: PandocMonad m => (Tag Text -> Bool) -> TagParser m (Tag Text) pSatisfy f = try $ optional pLocation >> pSat f@@ -681,20 +682,28 @@   return open  pQ :: PandocMonad m => TagParser m Inlines-pQ = do-  context <- asks quoteContext-  let quoteType = case context of-                       InDoubleQuote -> SingleQuote-                       _             -> DoubleQuote-  let innerQuoteContext = if quoteType == SingleQuote-                             then InSingleQuote-                             else InDoubleQuote-  let constructor = case quoteType of-                            SingleQuote -> B.singleQuoted-                            DoubleQuote -> B.doubleQuoted-  withQuoteContext innerQuoteContext $-    pInlinesInTags "q" constructor+pQ = choice $ map try [citedQuote, normalQuote]+  where citedQuote = do+          tag <- pSatisfy $ tagOpenLit "q" (any ((=="cite") . fst)) +          url <- canonicalizeUrl $ fromAttrib "cite" tag+          let uid = fromMaybe (fromAttrib "name" tag) $+                       maybeFromAttrib "id" tag+          let cls = T.words $ fromAttrib "class" tag++          makeQuote $ B.spanWith (uid, cls, [("cite", escapeURI url)])+        normalQuote = do+          pSatisfy $ tagOpenLit "q" (const True)+          makeQuote id+        makeQuote wrapper = do+          ctx <- asks quoteContext+          let (constructor, innerContext) = case ctx of+                        InDoubleQuote -> (B.singleQuoted, InSingleQuote)+                        _             -> (B.doubleQuoted, InDoubleQuote)++          content <- withQuoteContext innerContext (mconcat <$> manyTill inline (pCloses "q"))+          return $ extractSpaces (constructor . wrapper) content+ pEmph :: PandocMonad m => TagParser m Inlines pEmph = pInlinesInTags "em" B.emph <|> pInlinesInTags "i" B.emph @@ -707,6 +716,19 @@ pSubscript :: PandocMonad m => TagParser m Inlines pSubscript = pInlinesInTags "sub" B.subscript +pSpanLike :: PandocMonad m => TagParser m Inlines+pSpanLike =+  Set.foldr+    (\tagName acc -> acc <|> parseTag tagName)+    mzero+    htmlSpanLikeElements+  where+    parseTag tagName = do+      TagOpen _ attrs <- pSatisfy $ tagOpenLit tagName (const True)+      let (ids, cs, kvs) = mkAttr . toStringAttr $ attrs+      content <- mconcat <$> manyTill inline (pCloses tagName <|> eof)+      return $ B.spanWith (ids, tagName : cs, kvs) content+ pSmall :: PandocMonad m => TagParser m Inlines pSmall = pInlinesInTags "small" (B.spanWith ("",["small"],[])) @@ -729,57 +751,57 @@  -- Unlike fromAttrib from tagsoup, this distinguishes -- between a missing attribute and an attribute with empty content.-maybeFromAttrib :: String -> Tag Text -> Maybe String-maybeFromAttrib name (TagOpen _ attrs) =-  T.unpack <$> lookup (T.pack name) attrs+maybeFromAttrib :: Text -> Tag Text -> Maybe Text+maybeFromAttrib name (TagOpen _ attrs) = lookup name attrs maybeFromAttrib _ _ = Nothing  pLink :: PandocMonad m => TagParser m Inlines pLink = try $ do   tag <- pSatisfy $ tagOpenLit "a" (const True)-  let title = T.unpack $ fromAttrib "title" tag+  let title = fromAttrib "title" tag   -- take id from id attribute if present, otherwise name-  let uid = fromMaybe (T.unpack $ fromAttrib "name" tag) $+  let uid = fromMaybe (fromAttrib "name" tag) $                maybeFromAttrib "id" tag-  let cls = words $ T.unpack $ fromAttrib "class" tag+  let cls = T.words $ fromAttrib "class" tag   lab <- mconcat <$> manyTill inline (pCloses "a")   -- check for href; if href, then a link, otherwise a span   case maybeFromAttrib "href" tag of        Nothing   ->          return $ extractSpaces (B.spanWith (uid, cls, [])) lab        Just url' -> do-         mbBaseHref <- baseHref <$> getState-         let url = case (parseURIReference url', mbBaseHref) of-                        (Just rel, Just bs) ->-                          show (rel `nonStrictRelativeTo` bs)-                        _                   -> url'+         url <- canonicalizeUrl url'          return $ extractSpaces (B.linkWith (uid, cls, []) (escapeURI url) title) lab  pImage :: PandocMonad m => TagParser m Inlines pImage = do   tag <- pSelfClosing (=="img") (isJust . lookup "src")-  mbBaseHref <- baseHref <$> getState-  let url' = T.unpack $ fromAttrib "src" tag-  let url = case (parseURIReference url', mbBaseHref) of-                 (Just rel, Just bs) -> show (rel `nonStrictRelativeTo` bs)-                 _                   -> url'-  let title = T.unpack $ fromAttrib "title" tag-  let alt = T.unpack $ fromAttrib "alt" tag-  let uid = T.unpack $ fromAttrib "id" tag-  let cls = words $ T.unpack $ fromAttrib "class" tag+  url <- canonicalizeUrl $ fromAttrib "src" tag+  let title = fromAttrib "title" tag+  let alt = fromAttrib "alt" tag+  let uid = fromAttrib "id" tag+  let cls = T.words $ fromAttrib "class" tag   let getAtt k = case fromAttrib k tag of                    "" -> []-                   v  -> [(T.unpack k, T.unpack v)]+                   v  -> [(k, v)]   let kvs = concatMap getAtt ["width", "height", "sizes", "srcset"]   return $ B.imageWith (uid, cls, kvs) (escapeURI url) title (B.text alt) +pCodeWithClass :: PandocMonad m => [(T.Text,Text)] -> TagParser m Inlines+pCodeWithClass elemToClass = try $ do+  let tagTest = flip elem . fmap fst $ elemToClass+  TagOpen open attr' <- pSatisfy $ tagOpen tagTest (const True)+  result <- manyTill pAny (pCloses open)+  let (ids,cs,kvs) = mkAttr . toStringAttr $ attr'+      cs'          = maybe cs (:cs) . lookup open $ elemToClass+  return . B.codeWith (ids,cs',kvs) .+    T.unwords . T.lines . innerText $ result+ pCode :: PandocMonad m => TagParser m Inlines pCode = try $ do   (TagOpen open attr') <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)   let attr = toStringAttr attr'   result <- manyTill pAny (pCloses open)-  return $ B.codeWith (mkAttr attr) $ unwords $ lines $ T.unpack $-           innerText result+  return $ B.codeWith (mkAttr attr) $ T.unwords $ T.lines $ innerText result  pSpan :: PandocMonad m => TagParser m Inlines pSpan = try $ do@@ -791,7 +813,7 @@                     where styleAttr   = fromMaybe "" $ lookup "style" attr                           fontVariant = fromMaybe "" $ pickStyleAttrProps ["font-variant"] styleAttr                           classes     = fromMaybe [] $-                                          words <$> lookup "class" attr+                                          T.words <$> lookup "class" attr   let tag = if isSmallCaps then B.smallcaps else B.spanWith (mkAttr attr)   return $ tag contents @@ -803,18 +825,17 @@                    then pSatisfy (not . isBlockTag)                    else pSatisfy isInlineTag   exts <- getOption readerExtensions-  let raw = T.unpack $ renderTags' [result]+  let raw = renderTags' [result]   if extensionEnabled Ext_raw_html exts      then return $ B.rawInline "html" raw      else ignore raw -mathMLToTeXMath :: String -> Either String String+mathMLToTeXMath :: Text -> Either Text Text mathMLToTeXMath s = writeTeX <$> readMathML s -toStringAttr :: [(Text, Text)] -> [(String, String)]+toStringAttr :: [(Text, Text)] -> [(Text, Text)] toStringAttr = map go-  where go (x,y) = (T.unpack (fromMaybe x $ T.stripPrefix "data-" x),-                    T.unpack y)+  where go (x,y) = (fromMaybe x $ T.stripPrefix "data-" x, y)  pScriptMath :: PandocMonad m => TagParser m Inlines pScriptMath = try $ do@@ -823,8 +844,7 @@                     Just x | "math/tex" `T.isPrefixOf` x                       -> return $ "display" `T.isSuffixOf` x                     _ -> mzero-  contents <- T.unpack . innerText <$>-                manyTill pAny (pSatisfy (matchTagClose "script"))+  contents <- innerText <$> manyTill pAny (pSatisfy (matchTagClose "script"))   return $ (if isdisplay then B.displayMath else B.math) contents  pMath :: PandocMonad m => Bool -> TagParser m Inlines@@ -836,11 +856,11 @@   unless inCase $     guard (maybe True (== mathMLNamespace) (lookup "xmlns" attr))   contents <- manyTill pAny (pSatisfy (matchTagClose "math"))-  case mathMLToTeXMath (T.unpack $ renderTags $+  case mathMLToTeXMath (renderTags $           [open] <> contents <> [TagClose "math"]) of        Left _   -> return $ B.spanWith ("",["math"],attr) $ B.text $-                             T.unpack $ innerText contents-       Right [] -> return mempty+                             innerText contents+       Right "" -> return mempty        Right x  -> return $ case lookup "display" attr of                                  Just "block" -> B.displayMath x                                  _            -> B.math x@@ -899,7 +919,7 @@   parsed <- lift $ lift $             flip runReaderT qu $ runParserT (many pTagContents) st "text" str   case parsed of-       Left _        -> throwError $ PandocParseError $ "Could not parse `" <> T.unpack str <> "'"+       Left _        -> throwError $ PandocParseError $ "Could not parse `" <> str <> "'"        Right result  -> return $ mconcat result  pBlank :: PandocMonad m => TagParser m ()@@ -928,11 +948,11 @@   guardEnabled Ext_raw_tex   inp <- getInput   st <- getState-  res <- lift $ runParserT (withRaw rawLaTeXInline) st "chunk" (T.unpack inp)+  res <- lift $ runParserT (withRaw rawLaTeXInline) st "chunk" inp   case res of        Left _                -> mzero        Right (contents, raw) -> do-         _ <- count (length raw) anyChar+         _ <- count (T.length raw) anyChar          return $ B.rawInline "tex" contents  pStr :: PandocMonad m => InlinesParser m Inlines@@ -940,7 +960,7 @@   result <- many1 $ satisfy $ \c ->                      not (isSpace c) && not (isSpecial c) && not (isBad c)   updateLastStrPos-  return $ B.str result+  return $ B.str $ T.pack result  isSpecial :: Char -> Bool isSpecial '"'     = True@@ -956,7 +976,7 @@ isSpecial _       = False  pSymbol :: PandocMonad m => InlinesParser m Inlines-pSymbol = satisfy isSpecial >>= return . B.str . (:[])+pSymbol = satisfy isSpecial >>= return . B.str . T.singleton  isBad :: Char -> Bool isBad c = c >= '\128' && c <= '\159' -- not allowed in HTML@@ -993,7 +1013,7 @@                 '\158' -> '\382'                 '\159' -> '\376'                 _      -> '?'-  return $ B.str [c']+  return $ B.str $ T.singleton c'  pSpace :: PandocMonad m => InlinesParser m Inlines pSpace = many1 (satisfy isSpace) >>= \xs ->@@ -1129,9 +1149,9 @@ --- parsers for use in markdown, textile readers  -- | Matches a stretch of HTML in balanced tags.-htmlInBalanced :: (HasReaderOptions st, Monad m)-               => (Tag String -> Bool)-               -> ParserT String st m String+htmlInBalanced :: Monad m+               => (Tag Text -> Bool)+               -> ParserT Text st m Text htmlInBalanced f = try $ do   lookAhead (char '<')   inp <- getInput@@ -1148,21 +1168,21 @@                         (TagClose _ : TagPosition er ec : _) -> do                           let ls = er - sr                           let cs = ec - sc-                          lscontents <- unlines <$> count ls anyLine+                          lscontents <- T.unlines <$> count ls anyLine                           cscontents <- count cs anyChar                           closetag <- do                             x <- many (satisfy (/='>'))                             char '>'                             return (x <> ">")-                          return (lscontents <> cscontents <> closetag)+                          return $ lscontents <> T.pack cscontents <> T.pack closetag                         _ -> mzero     _ -> mzero -htmlInBalanced' :: String-                -> [Tag String]-                -> [Tag String]+htmlInBalanced' :: Text+                -> [Tag Text]+                -> [Tag Text] htmlInBalanced' tagname ts = fromMaybe [] $ go 0 ts-  where go :: Int -> [Tag String] -> Maybe [Tag String]+  where go :: Int -> [Tag Text] -> Maybe [Tag Text]         go n (t@(TagOpen tn' _):rest) | tn' == tagname =               (t :) <$> go (n + 1) rest         go 1 (t@(TagClose tn'):_) | tn' == tagname =@@ -1178,8 +1198,8 @@  -- | Matches a tag meeting a certain condition. htmlTag :: (HasReaderOptions st, Monad m)-        => (Tag String -> Bool)-        -> ParserT [Char] st m (Tag String, String)+        => (Tag Text -> Bool)+        -> ParserT Text st m (Tag Text, Text) htmlTag f = try $ do   lookAhead (char '<')   startpos <- getPosition@@ -1187,7 +1207,7 @@   let ts = canonicalizeTags $ parseTagsOptions                                parseOptions{ optTagWarning = False                                            , optTagPosition = True }-                               (inp ++ " ") -- add space to ensure that+                               (inp <> " ") -- add space to ensure that                                -- we get a TagPosition after the tag   (next, ln, col) <- case ts of                       (TagPosition{} : next : TagPosition ln col : _)@@ -1199,13 +1219,12 @@   -- so we exclude . even though it's a valid character   -- in XML element names   let isNameChar c = isAlphaNum c || c == ':' || c == '-' || c == '_'-  let isName s = case s of-                      []      -> False-                      (c:cs)  -> isLetter c && all isNameChar cs-  let isPI s = case s of-                      ('?':_) -> True -- processing instruction-                      _       -> False-+  let isName s = case T.uncons s of+                   Nothing      -> False+                   Just (c, cs) -> isLetter c && T.all isNameChar cs+  let isPI s = case T.uncons s of+                 Just ('?', _) -> True -- processing instruction+                 _             -> False   let endpos = if ln == 1                   then setSourceColumn startpos                          (sourceColumn startpos + (col - 1))@@ -1221,24 +1240,24 @@        -- basic sanity check, since the parser is very forgiving        -- and finds tags in stuff like x<y)        guard $ isName tagname || isPI tagname-       guard $ not $ null tagname+       guard $ not $ T.null tagname        -- <https://example.org> should NOT be a tag either.        -- tagsoup will parse it as TagOpen "https:" [("example.org","")]-       guard $ last tagname /= ':'+       guard $ T.last tagname /= ':'        char '<'        rendered <- manyTill anyChar endAngle-       return (next, "<" ++ rendered ++ ">")+       return (next, T.pack $ "<" ++ rendered ++ ">")   case next of        TagComment s-         | "<!--" `isPrefixOf` inp -> do+         | "<!--" `T.isPrefixOf` inp -> do           string "<!--"-          count (length s) anyChar+          count (T.length s) anyChar           string "-->"           stripComments <- getOption readerStripComments           if stripComments              then return (next, "")              else return (next, "<!--" <> s <> "-->")-         | otherwise -> fail "bogus comment mode, HTML5 parse error"+         | otherwise -> Prelude.fail "bogus comment mode, HTML5 parse error"        TagOpen tagname attr -> do          guard $ isPI tagname || all (isName . fst) attr          handleTag tagname@@ -1246,12 +1265,12 @@          handleTag tagname        _ -> mzero -mkAttr :: [(String, String)] -> Attr+mkAttr :: [(Text, Text)] -> Attr mkAttr attr = (attribsId, attribsClasses, attribsKV)   where attribsId = fromMaybe "" $ lookup "id" attr-        attribsClasses = words (fromMaybe "" $ lookup "class" attr) <> epubTypes+        attribsClasses = T.words (fromMaybe "" $ lookup "class" attr) <> epubTypes         attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr-        epubTypes = words $ fromMaybe "" $ lookup "epub:type" attr+        epubTypes = T.words $ fromMaybe "" $ lookup "epub:type" attr  -- Strip namespace prefixes stripPrefixes :: [Tag Text] -> [Tag Text]@@ -1274,6 +1293,17 @@ isSpace '\n' = True isSpace '\r' = True isSpace _    = False++-- Utilities++-- | Adjusts a url according to the document's base URL.+canonicalizeUrl :: PandocMonad m => Text -> TagParser m Text+canonicalizeUrl url = do+  mbBaseHref <- baseHref <$> getState+  return $ case (parseURIReference (T.unpack url), mbBaseHref) of+                (Just rel, Just bs) -> tshow (rel `nonStrictRelativeTo` bs)+                _                   -> url+  -- Instances 
src/Text/Pandoc/Readers/Haddock.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP               #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Haddock    Copyright   : Copyright (C) 2013 David Lazar@@ -17,9 +18,10 @@  import Prelude import Control.Monad.Except (throwError)-import Data.List (intersperse, stripPrefix)+import Data.List (intersperse) import Data.Maybe (fromMaybe) import Data.Text (Text, unpack)+import qualified Data.Text as T import Documentation.Haddock.Parser import Documentation.Haddock.Types as H import Text.Pandoc.Builder (Blocks, Inlines)@@ -28,7 +30,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Options-import Text.Pandoc.Shared (crFilter, splitBy, trim)+import Text.Pandoc.Shared (crFilter, splitTextBy, trim)   -- | Parse Haddock markup and return a 'Pandoc' document.@@ -51,7 +53,7 @@   case d' of     DocEmpty -> mempty     DocAppend (DocParagraph (DocHeader h)) (DocParagraph (DocAName ident)) ->-         B.headerWith (ident,[],[]) (headerLevel h)+         B.headerWith (T.pack ident,[],[]) (headerLevel h)             (docHToInlines False $ headerTitle h)     DocAppend d1 d2 -> mappend (docHToBlocks d1) (docHToBlocks d2)     DocString _ -> inlineFallback@@ -73,12 +75,12 @@     DocDefList items -> B.definitionList (map (\(d,t) ->                                (docHToInlines False d,                                 [consolidatePlains $ docHToBlocks t])) items)-    DocCodeBlock (DocString s) -> B.codeBlockWith ("",[],[]) s+    DocCodeBlock (DocString s) -> B.codeBlockWith ("",[],[]) $ T.pack s     DocCodeBlock d -> B.para $ docHToInlines True d     DocHyperlink _ -> inlineFallback     DocPic _ -> inlineFallback     DocAName _ -> inlineFallback-    DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)+    DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim $ T.pack s)     DocExamples es -> mconcat $ map (\e ->        makeExample ">>>" (exampleExpression e) (exampleResult e)) es     DocTable H.Table{ tableHeaderRows = headerRows@@ -114,54 +116,58 @@                                (docHToInlines isCode d2)     DocString s       | isCode -> mconcat $ intersperse B.linebreak-                              $ map B.code $ splitBy (=='\n') s-      | otherwise  -> B.text s+                              $ map B.code $ splitTextBy (=='\n') $ T.pack s+      | otherwise  -> B.text $ T.pack s     DocParagraph _ -> mempty-    DocIdentifier (_,s,_) -> B.codeWith ("",["haskell","identifier"],[]) s-    DocIdentifierUnchecked s -> B.codeWith ("",["haskell","identifier"],[]) s-    DocModule s -> B.codeWith ("",["haskell","module"],[]) s+    DocIdentifier ident ->+        case toRegular (DocIdentifier ident) of+          DocIdentifier s -> B.codeWith ("",["haskell","identifier"],[]) $ T.pack s+          _               -> mempty+    DocIdentifierUnchecked s -> B.codeWith ("",["haskell","identifier"],[]) $ T.pack s+    DocModule s -> B.codeWith ("",["haskell","module"],[]) $ T.pack s     DocWarning _ -> mempty -- TODO     DocEmphasis d -> B.emph (docHToInlines isCode d)-    DocMonospaced (DocString s) -> B.code s+    DocMonospaced (DocString s) -> B.code $ T.pack s     DocMonospaced d -> docHToInlines True d     DocBold d -> B.strong (docHToInlines isCode d)-    DocMathInline s -> B.math s-    DocMathDisplay s -> B.displayMath s+    DocMathInline s -> B.math $ T.pack s+    DocMathDisplay s -> B.displayMath $ T.pack s     DocHeader _ -> mempty     DocUnorderedList _ -> mempty     DocOrderedList _ -> mempty     DocDefList _ -> mempty     DocCodeBlock _ -> mempty-    DocHyperlink h -> B.link (hyperlinkUrl h) (hyperlinkUrl h)-             (maybe (B.text $ hyperlinkUrl h) B.text $ hyperlinkLabel h)-    DocPic p -> B.image (pictureUri p) (fromMaybe (pictureUri p) $ pictureTitle p)-                        (maybe mempty B.text $ pictureTitle p)-    DocAName s -> B.spanWith (s,["anchor"],[]) mempty+    DocHyperlink h -> B.link (T.pack $ hyperlinkUrl h) (T.pack $ hyperlinkUrl h)+             (maybe (B.text $ T.pack $ hyperlinkUrl h) (docHToInlines isCode)+               (hyperlinkLabel h))+    DocPic p -> B.image (T.pack $ pictureUri p) (T.pack $ fromMaybe (pictureUri p) $ pictureTitle p)+                        (maybe mempty (B.text . T.pack) $ pictureTitle p)+    DocAName s -> B.spanWith (T.pack s,["anchor"],[]) mempty     DocProperty _ -> mempty     DocExamples _ -> mempty     DocTable _ -> mempty  -- | Create an 'Example', stripping superfluous characters as appropriate-makeExample :: String -> String -> [String] -> Blocks+makeExample :: T.Text -> String -> [String] -> Blocks makeExample prompt expression result =     B.para $ B.codeWith ("",["prompt"],[]) prompt         <> B.space-        <> B.codeWith ([], ["haskell","expr"], []) (trim expression)+        <> B.codeWith ("", ["haskell","expr"], []) (trim $ T.pack expression)         <> B.linebreak         <> mconcat (intersperse B.linebreak $ map coder result')   where     -- 1. drop trailing whitespace from the prompt, remember the prefix-    prefix = takeWhile (`elem` " \t") prompt+    prefix = T.takeWhile (`elem` (" \t" :: String)) prompt      -- 2. drop, if possible, the exact same sequence of whitespace     -- characters from each result line     --     -- 3. interpret lines that only contain the string "<BLANKLINE>" as an     -- empty line-    result' = map (substituteBlankLine . tryStripPrefix prefix) result+    result' = map (substituteBlankLine . tryStripPrefix prefix . T.pack) result       where-        tryStripPrefix xs ys = fromMaybe ys $ stripPrefix xs ys+        tryStripPrefix xs ys = fromMaybe ys $ T.stripPrefix xs ys          substituteBlankLine "<BLANKLINE>" = ""         substituteBlankLine line          = line-    coder = B.codeWith ([], ["result"], [])+    coder = B.codeWith ("", ["result"], [])
src/Text/Pandoc/Readers/Ipynb.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Ipynb    Copyright   : Copyright (C) 2019 John MacFarlane@@ -19,7 +20,6 @@ where import Prelude import Data.Char (isDigit)-import Data.List (isPrefixOf) import Data.Maybe (fromMaybe) import Data.Digest.Pure.SHA (sha1, showDigest) import Text.Pandoc.Options@@ -30,6 +30,7 @@ import Data.Ipynb as Ipynb import Text.Pandoc.Class import Text.Pandoc.MIME (extensionFromMimeType)+import Text.Pandoc.Shared (tshow) import Text.Pandoc.UTF8 import Text.Pandoc.Walk (walk) import Text.Pandoc.Error@@ -51,15 +52,15 @@     Left _ ->       case eitherDecode src of         Right (notebook3 :: Notebook NbV3) -> notebookToPandoc opts notebook3-        Left err -> throwError $ PandocIpynbDecodingError err+        Left err -> throwError $ PandocIpynbDecodingError $ T.pack err -notebookToPandoc :: (PandocMonad m, FromJSON (Notebook a))+notebookToPandoc :: PandocMonad m                  => ReaderOptions -> Notebook a -> m Pandoc notebookToPandoc opts notebook = do   let cells = notebookCells notebook   let (fmt,fmtminor) = notebookFormat notebook-  let m = M.insert "nbformat" (MetaString $ show fmt) $-          M.insert "nbformat_minor" (MetaString $ show fmtminor) $+  let m = M.insert "nbformat" (MetaString $ tshow fmt) $+          M.insert "nbformat_minor" (MetaString $ tshow fmtminor) $           jsonMetaToMeta (notebookMetadata notebook)   let lang = case M.lookup "kernelspec" m of                    Just (MetaMap ks) ->@@ -72,7 +73,7 @@   return $ Pandoc (Meta $ M.insert "jupyter" (MetaMap m) mempty) blocks  cellToBlocks :: PandocMonad m-             => ReaderOptions -> String -> Cell a -> m B.Blocks+             => ReaderOptions -> Text -> Cell a -> m B.Blocks cellToBlocks opts lang c = do   let Source ts = cellSource c   let source = mconcat ts@@ -100,19 +101,18 @@               "text/markdown"   -> "markdown"               "text/x-rsrt"     -> "rst"               _                 -> format-      return $ B.divWith ("",["cell","raw"],kvs) $ B.rawBlock format'-             $ T.unpack source+      return $ B.divWith ("",["cell","raw"],kvs) $ B.rawBlock format' source     Ipynb.Code{ codeOutputs = outputs, codeExecutionCount = ec } -> do       outputBlocks <- mconcat <$> mapM outputToBlock outputs-      let kvs' = maybe kvs (\x -> ("execution_count", show x):kvs) ec+      let kvs' = maybe kvs (\x -> ("execution_count", tshow x):kvs) ec       return $ B.divWith ("",["cell","code"],kvs') $-        B.codeBlockWith ("",[lang],[]) (T.unpack source)+        B.codeBlockWith ("",[lang],[]) source         <> outputBlocks  -- Remove attachment: prefix from images... fixImage :: Inline -> Inline fixImage (Image attr lab (src,tit))-  | "attachment:" `isPrefixOf` src = Image attr lab (drop 11 src, tit)+  | "attachment:" `T.isPrefixOf` src = Image attr lab (T.drop 11 src, tit) fixImage x = x  addAttachment :: PandocMonad m => (Text, MimeBundle) -> m ()@@ -120,19 +120,19 @@   let fp = T.unpack fname   case M.toList (unMimeBundle mimeBundle) of     (mimeType, BinaryData bs):_ ->-      insertMedia fp (Just $ T.unpack mimeType) (BL.fromStrict bs)+      insertMedia fp (Just mimeType) (BL.fromStrict bs)     (mimeType, TextualData t):_ ->-      insertMedia fp (Just $ T.unpack mimeType)+      insertMedia fp (Just mimeType)           (BL.fromStrict $ TE.encodeUtf8 t)     (mimeType, JsonData v):_ ->-      insertMedia fp (Just $ T.unpack mimeType) (encode v)-    [] -> report $ CouldNotFetchResource fp "no attachment"+      insertMedia fp (Just mimeType) (encode v)+    [] -> report $ CouldNotFetchResource fname "no attachment"  outputToBlock :: PandocMonad m => Output a -> m B.Blocks outputToBlock Stream{ streamName = sName,                       streamText = Source text } = do-  return $ B.divWith ("",["output","stream",T.unpack sName],[])-         $ B.codeBlock $ T.unpack . mconcat $ text+  return $ B.divWith ("",["output","stream",sName],[])+         $ B.codeBlock $ T.concat $ text outputToBlock DisplayData{ displayData = data',                             displayMetadata = metadata' } =   B.divWith ("",["output", "display_data"],[]) <$>@@ -140,15 +140,15 @@ outputToBlock ExecuteResult{ executeCount = ec,                               executeData = data',                               executeMetadata = metadata' } =-  B.divWith ("",["output", "execute_result"],[("execution_count",show ec)])+  B.divWith ("",["output", "execute_result"],[("execution_count",tshow ec)])     <$> handleData metadata' data' outputToBlock Err{ errName = ename,                    errValue = evalue,                    errTraceback = traceback } = do   return $ B.divWith ("",["output","error"],-                         [("ename",T.unpack ename),-                          ("evalue",T.unpack evalue)])-         $ B.codeBlock $ T.unpack . T.unlines $ traceback+                         [("ename",ename),+                          ("evalue",evalue)])+         $ B.codeBlock $ T.unlines $ traceback  -- We want to display the richest output possible given -- the output format.@@ -174,54 +174,53 @@       let metaPairs = jsonMetaToPairs meta       let bl = BL.fromStrict bs       -- SHA1 hash for filename-      let mt' = T.unpack mt-      let fname = showDigest (sha1 bl) ++-            case extensionFromMimeType mt' of+      let fname = T.pack (showDigest (sha1 bl)) <>+            case extensionFromMimeType mt of               Nothing  -> ""-              Just ext -> '.':ext-      insertMedia fname (Just mt') bl+              Just ext -> "." <> ext+      insertMedia (T.unpack fname) (Just mt) bl       return $ B.para $ B.imageWith ("",[],metaPairs) fname "" mempty      | otherwise = return mempty      dataBlock ("text/html", TextualData t)-      = return $ B.rawBlock "html" $ T.unpack t+      = return $ B.rawBlock "html" $ t      dataBlock ("text/latex", TextualData t)-      = return $ B.rawBlock "latex" $ T.unpack t+      = return $ B.rawBlock "latex" $ t      dataBlock ("text/plain", TextualData t) =-      return $ B.codeBlock $ T.unpack t+      return $ B.codeBlock $ t      dataBlock (_, JsonData v) =-      return $ B.codeBlockWith ("",["json"],[]) $ toStringLazy $ encode v+      return $ B.codeBlockWith ("",["json"],[]) $ T.pack $ toStringLazy $ encode v      dataBlock _ = return mempty -jsonMetaToMeta :: JSONMeta -> M.Map String MetaValue-jsonMetaToMeta = M.mapKeys T.unpack . M.map valueToMetaValue+jsonMetaToMeta :: JSONMeta -> M.Map Text MetaValue+jsonMetaToMeta = M.map valueToMetaValue   where     valueToMetaValue :: Value -> MetaValue     valueToMetaValue x@(Object{}) =       case fromJSON x of-        Error s -> MetaString s+        Error s -> MetaString $ T.pack s         Success jm' -> MetaMap $ jsonMetaToMeta jm'     valueToMetaValue x@(Array{}) =       case fromJSON x of-        Error s -> MetaString s+        Error s -> MetaString $ T.pack s         Success xs -> MetaList $ map valueToMetaValue xs     valueToMetaValue (Bool b) = MetaBool b-    valueToMetaValue (String t) = MetaString (T.unpack t)+    valueToMetaValue (String t) = MetaString t     valueToMetaValue (Number n)-      | Scientific.isInteger n = MetaString (show (floor n :: Integer))-      | otherwise              = MetaString (show n)+      | Scientific.isInteger n = MetaString (tshow (floor n :: Integer))+      | otherwise              = MetaString (tshow n)     valueToMetaValue Aeson.Null = MetaString "" -jsonMetaToPairs :: JSONMeta -> [(String, String)]-jsonMetaToPairs = M.toList . M.mapKeys T.unpack . M.map+jsonMetaToPairs :: JSONMeta -> [(Text, Text)]+jsonMetaToPairs = M.toList . M.map   (\case       String t         | not (T.all isDigit t)         , t /= "true"         , t /= "false"-                 -> T.unpack t-      x          -> UTF8.toStringLazy $ Aeson.encode x)+                 -> t+      x          -> T.pack $ UTF8.toStringLazy $ Aeson.encode x)
src/Text/Pandoc/Readers/JATS.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TupleSections #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.JATS    Copyright   : Copyright (C) 2017-2019 Hamish Mackenzie@@ -76,13 +77,13 @@ convertEntity e = Data.Maybe.fromMaybe (map toUpper e) (lookupEntity e)  -- convenience function to get an attribute value, defaulting to ""-attrValue :: String -> Element -> String+attrValue :: String -> Element -> Text attrValue attr =   fromMaybe "" . maybeAttrValue attr -maybeAttrValue :: String -> Element -> Maybe String+maybeAttrValue :: String -> Element -> Maybe Text maybeAttrValue attr elt =-  lookupAttrBy (\x -> qName x == attr) (elAttribs elt)+  T.pack <$> lookupAttrBy (\x -> qName x == attr) (elAttribs elt)  -- convenience function named :: String -> Element -> Bool@@ -90,7 +91,7 @@  -- -addMeta :: PandocMonad m => ToMetaValue a => String -> a -> JATS m ()+addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> JATS m () addMeta field val = modify (setMeta field val)  instance HasMeta JATSState where@@ -126,15 +127,13 @@ isBlockElement _ = False  -- Trim leading and trailing newline characters-trimNl :: String -> String-trimNl = reverse . go . reverse . go-  where go ('\n':xs) = xs-        go xs        = xs+trimNl :: Text -> Text+trimNl = T.dropAround (== '\n')  -- function that is used by both graphic (in parseBlock) -- and inline-graphic (in parseInline) getGraphic :: PandocMonad m-           => Maybe (Inlines, String) -> Element -> JATS m Inlines+           => Maybe (Inlines, Text) -> Element -> JATS m Inlines getGraphic mbfigdata e = do   let atVal a = attrValue a e       (ident, title, caption) =@@ -142,7 +141,7 @@            Just (capt, i) -> (i, "fig:" <> atVal "title", capt)            Nothing        -> (atVal "id", atVal "title",                               text (atVal "alt-text"))-      attr = (ident, words $ atVal "role", [])+      attr = (ident, T.words $ atVal "role", [])       imageUrl = atVal "href"   return $ imageWith attr imageUrl title caption @@ -155,8 +154,8 @@ parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE parseBlock (Text (CData _ s _)) = if all isSpace s                                      then return mempty-                                     else return $ plain $ trimInlines $ text s-parseBlock (CRef x) = return $ plain $ str $ map toUpper x+                                     else return $ plain $ trimInlines $ text $ T.pack s+parseBlock (CRef x) = return $ plain $ str $ T.toUpper $ T.pack x parseBlock (Elem e) =   case qName (elName e) of         "p" -> parseMixed para (elContent e)@@ -167,7 +166,7 @@                     "bullet" -> bulletList <$> listitems                     listType -> do                       let start = fromMaybe 1 $-                                  (strContent <$> (filterElement (named "list-item") e+                                  (textContent <$> (filterElement (named "list-item") e                                                >>= filterElement (named "label")))                                    >>= safeRead                       orderedListWith (start, parseListStyleType listType, DefaultDelim)@@ -204,7 +203,7 @@                                 "" -> []                                 x  -> [x]            return $ codeBlockWith (attrValue "id" e, classes', [])-                  $ trimNl $ strContentRecursive e+                  $ trimNl $ textContentRecursive e          parseBlockquote = do             attrib <- case filterChild (named "attribution") e of                              Nothing  -> return mempty@@ -267,9 +266,9 @@                                                 Just "right"  -> AlignRight                                                 Just "center" -> AlignCenter                                                 _             -> AlignDefault-                      let toWidth c = case findAttr (unqual "colwidth") c of+                      let toWidth c = case findAttrText (unqual "colwidth") c of                                                 Just w -> fromMaybe 0-                                                   $ safeRead $ '0': filter (\x ->+                                                   $ safeRead $ "0" <> T.filter (\x ->                                                      isDigit x || x == '.') w                                                 Nothing -> 0 :: Double                       let numrows = foldl' max 0 $ map length bodyrows@@ -363,7 +362,7 @@   return mempty  parseRef :: PandocMonad m-         => Element -> JATS m (Map.Map String MetaValue)+         => Element -> JATS m (Map.Map Text MetaValue) parseRef e = do   let refId = text $ attrValue "id" e   let getInlineText n = maybe (return mempty) getInlines . filterChild (named n)@@ -396,7 +395,7 @@                family <- maybe (return mempty) getInlines                          $ filterChild (named "surname") nm                return $ toMetaValue $ Map.fromList [-                   ("given", given)+                   ("given" :: Text, given)                  , ("family", family)                  ]          personGroups <- mapM (\pg ->@@ -406,7 +405,7 @@                                            toMetaValue names))                          personGroups'          return $ Map.fromList $-           [ ("id", toMetaValue refId)+           [ ("id" :: Text, toMetaValue refId)            , ("type", toMetaValue refType)            , ("title", toMetaValue refTitle)            , ("container-title", toMetaValue refContainerTitle)@@ -415,7 +414,7 @@            , ("title", toMetaValue refTitle)            , ("issued", toMetaValue                         $ Map.fromList [-                            ("year", refYear)+                            ("year" :: Text, refYear)                           ])            , ("volume", toMetaValue refVolume)            , ("page", toMetaValue refPages)@@ -424,6 +423,15 @@        Nothing -> return $ Map.insert "id" (toMetaValue refId) mempty        -- TODO handle mixed-citation +findAttrText :: QName -> Element -> Maybe Text+findAttrText x = fmap T.pack . findAttr x++textContent :: Element -> Text+textContent = T.pack . strContent++textContentRecursive :: Element -> Text+textContentRecursive = T.pack . strContentRecursive+ strContentRecursive :: Element -> String strContentRecursive = strContent .   (\e' -> e'{ elContent = map elementToStr $ elContent e' })@@ -433,9 +441,9 @@ elementToStr x = x  parseInline :: PandocMonad m => Content -> JATS m Inlines-parseInline (Text (CData _ s _)) = return $ text s+parseInline (Text (CData _ s _)) = return $ text $ T.pack s parseInline (CRef ref) =-  return $ maybe (text $ map toUpper ref) text $ lookupEntity ref+  return $ maybe (text $ T.toUpper $ T.pack ref) text $ T.pack <$> lookupEntity ref parseInline (Elem e) =   case qName (elName e) of         "italic" -> emph <$> innerInlines@@ -464,7 +472,7 @@         "xref" -> do             ils <- innerInlines             let rid = attrValue "rid" e-            let rids = words rid+            let rids = T.words rid             let refType = ("ref-type",) <$> maybeAttrValue "ref-type" e             let attr = (attrValue "id" e, [], maybeToList refType)             return $ if refType == Just ("ref-type","bibr")@@ -477,13 +485,13 @@                                              , citationNoteNum = 0                                              , citationHash = 0}) rids)                              ils-                        else linkWith attr ('#' : rid) "" ils+                        else linkWith attr ("#" <> rid) "" ils         "ext-link" -> do              ils <- innerInlines-             let title = fromMaybe "" $ findAttr (QName "title" (Just "http://www.w3.org/1999/xlink") Nothing) e+             let title = fromMaybe "" $ findAttrText (QName "title" (Just "http://www.w3.org/1999/xlink") Nothing) e              let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of-                               Just h -> h-                               _      -> '#' : attrValue "rid" e+                               Just h -> T.pack h+                               _      -> "#" <> attrValue "rid" e              let ils' = if ils == mempty then str href else ils              let attr = (attrValue "id" e, [], [])              return $ linkWith attr href title ils'@@ -491,23 +499,23 @@         "disp-formula" -> formula displayMath         "inline-formula" -> formula math         "math" | qPrefix (elName e) == Just "mml" -> return . math $ mathML e-        "tex-math" -> return . math $ strContent e+        "tex-math" -> return . math $ textContent e -        "email" -> return $ link ("mailto:" ++ strContent e) ""-                          $ str $ strContent e-        "uri" -> return $ link (strContent e) "" $ str $ strContent e+        "email" -> return $ link ("mailto:" <> textContent e) ""+                          $ str $ textContent e+        "uri" -> return $ link (textContent e) "" $ str $ textContent e         "fn" -> (note . mconcat) <$>                          mapM parseBlock (elContent e)         _          -> innerInlines    where innerInlines = (trimInlines . mconcat) <$>                           mapM parseInline (elContent e)          mathML x =-            case readMathML . showElement $ everywhere (mkT removePrefix) x of+            case readMathML . T.pack . showElement $ everywhere (mkT removePrefix) x of                 Left _ -> mempty                 Right m -> writeTeX m          formula constructor = do             let whereToLook = fromMaybe e $ filterElement (named "alternatives") e-                texMaths = map strContent $+                texMaths = map textContent $                             filterChildren (named  "tex-math") whereToLook                 mathMLs = map mathML $                             filterChildren isMathML whereToLook@@ -520,4 +528,4 @@            let classes' = case attrValue "language" e of                                "" -> []                                l  -> [l]-           return $ codeWith (attrValue "id" e,classes',[]) $ strContentRecursive e+           return $ codeWith (attrValue "id" e,classes',[]) $ textContentRecursive e
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -1,9 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude     #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings     #-} {-# LANGUAGE PatternGuards         #-} {-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE ViewPatterns          #-} {- |    Module      : Text.Pandoc.Readers.LaTeX    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -29,9 +30,9 @@ import Control.Applicative (many, optional, (<|>)) import Control.Monad import Control.Monad.Except (throwError)-import Data.Char (isDigit, isLetter, toLower, toUpper)+import Data.Char (isDigit, isLetter, toUpper, chr) import Data.Default-import Data.List (intercalate, isPrefixOf)+import Data.List (intercalate) import qualified Data.Map as M import Data.Maybe (fromMaybe, maybeToList) import qualified Data.Set as Set@@ -43,8 +44,8 @@ import Text.Pandoc.Builder import Text.Pandoc.Class (PandocMonad, PandocPure, getResourcePath, lookupEnv,                           readFileFromDirs, report, setResourcePath,-                          setTranslations, translateTerm, trace)-import Text.Pandoc.Error (PandocError ( PandocParseError, PandocParsecError))+                          setTranslations, translateTerm, trace, fileExists)+import Text.Pandoc.Error (PandocError (PandocParseError, PandocParsecError)) import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension) import Text.Pandoc.ImageSize (numUnit, showFl) import Text.Pandoc.Logging@@ -77,7 +78,7 @@                (tokenize "source" (crFilter ltx))   case parsed of     Right result -> return result-    Left e       -> throwError $ PandocParsecError (T.unpack ltx) e+    Left e       -> throwError $ PandocParsecError ltx e  parseLaTeX :: PandocMonad m => LP m Pandoc parseLaTeX = do@@ -99,13 +100,13 @@        walk (resolveRefs (sLabels st)) doc'   return $ Pandoc meta bs' -resolveRefs :: M.Map String [Inline] -> Inline -> Inline+resolveRefs :: M.Map Text [Inline] -> Inline -> Inline resolveRefs labels x@(Link (ident,classes,kvs) _ _) =   case (lookup "reference-type" kvs,         lookup "reference" kvs) of         (Just "ref", Just lab) ->           case M.lookup lab labels of-               Just txt -> Link (ident,classes,kvs) txt ('#':lab, "")+               Just txt -> Link (ident,classes,kvs) txt ("#" <> lab, "")                Nothing  -> x         _ -> x resolveRefs _ x = x@@ -123,17 +124,19 @@   rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s)-              => ParserT String s m String+              => ParserT Text s m Text rawLaTeXBlock = do   lookAhead (try (char '\\' >> letter))-  snd <$> (rawLaTeXParser False macroDef blocks-      <|> (rawLaTeXParser True+  inp <- getInput+  let toks = tokenize "source" inp+  snd <$> (rawLaTeXParser toks False (macroDef (const mempty)) blocks+      <|> (rawLaTeXParser toks True              (do choice (map controlSeq                    ["include", "input", "subfile", "usepackage"])                  skipMany opt                  braced                  return mempty) blocks)-      <|> rawLaTeXParser True+      <|> rawLaTeXParser toks True            (environment <|> blockCommand)            (mconcat <$> (many (block <|> beginOrEndCommand)))) @@ -149,34 +152,39 @@       (inlineEnvironments :: M.Map Text (LP PandocPure Inlines))      then mzero      else return $ rawBlock "latex"-                    (T.unpack (txt <> untokenize rawargs))+                    (txt <> untokenize rawargs)  rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)-               => ParserT String s m String+               => ParserT Text s m Text rawLaTeXInline = do   lookAhead (try (char '\\' >> letter))+  inp <- getInput+  let toks = tokenize "source" inp   raw <- snd <$>-          (   rawLaTeXParser True+          (   rawLaTeXParser toks True               (mempty <$ (controlSeq "input" >> skipMany opt >> braced))               inlines-          <|> rawLaTeXParser True (inlineEnvironment <|> inlineCommand')+          <|> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')               inlines           )   finalbraces <- mconcat <$> many (try (string "{}")) -- see #5439-  return $ raw <> finalbraces+  return $ raw <> T.pack finalbraces -inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines+inlineCommand :: PandocMonad m => ParserT Text ParserState m Inlines inlineCommand = do   lookAhead (try (char '\\' >> letter))-  fst <$> rawLaTeXParser True (inlineEnvironment <|> inlineCommand') inlines+  inp <- getInput+  let toks = tokenize "source" inp+  fst <$> rawLaTeXParser toks True (inlineEnvironment <|> inlineCommand')+          inlines  -- inline elements:  word :: PandocMonad m => LP m Inlines-word = (str . T.unpack . untoken) <$> satisfyTok isWordTok+word = (str . untoken) <$> satisfyTok isWordTok  regularSymbol :: PandocMonad m => LP m Inlines-regularSymbol = (str . T.unpack . untoken) <$> satisfyTok isRegularSymbol+regularSymbol = (str . untoken) <$> satisfyTok isRegularSymbol   where isRegularSymbol (Tok _ Symbol t) = not $ T.any isSpecial t         isRegularSymbol _                = False         isSpecial c = c `Set.member` specialChars@@ -192,24 +200,34 @@  doLHSverb :: PandocMonad m => LP m Inlines doLHSverb =-  (codeWith ("",["haskell"],[]) . T.unpack . untokenize)+  (codeWith ("",["haskell"],[]) . untokenize)     <$> manyTill (satisfyTok (not . isNewlineTok)) (symbol '|') -mkImage :: PandocMonad m => [(String, String)] -> String -> LP m Inlines-mkImage options src = do+mkImage :: PandocMonad m => [(Text, Text)] -> Text -> LP m Inlines+mkImage options (T.unpack -> src) = do    let replaceTextwidth (k,v) =          case numUnit v of-              Just (num, "\\textwidth") -> (k, showFl (num * 100) ++ "%")+              Just (num, "\\textwidth") -> (k, showFl (num * 100) <> "%")               _                         -> (k, v)    let kvs = map replaceTextwidth              $ filter (\(k,_) -> k `elem` ["width", "height"]) options    let attr = ("",[], kvs)    let alt = str "image"-   case takeExtension src of-        "" -> do-              defaultExt <- getOption readerDefaultImageExtension-              return $ imageWith attr (addExtension src defaultExt) "" alt-        _  -> return $ imageWith attr src "" alt+   defaultExt <- getOption readerDefaultImageExtension+   let exts' = [".pdf", ".png", ".jpg", ".mps", ".jpeg", ".jbig2", ".jb2"]+   let exts  = exts' ++ map (map toUpper) exts'+   let findFile s [] = return s+       findFile s (e:es) = do+         let s' = addExtension s e+         exists <- fileExists s'+         if exists+            then return s'+            else findFile s es+   src' <- case takeExtension src of+               "" | not (T.null defaultExt) -> return $ addExtension src $ T.unpack defaultExt+                  | otherwise -> findFile src exts+               _  -> return src+   return $ imageWith attr (T.pack src') "" alt  doxspace :: PandocMonad m => LP m Inlines doxspace =@@ -386,6 +404,7 @@   , ("mega", str "M")   , ("meter", str "m")   , ("metre", str "m")+  , ("micro", str "μ")   , ("milli", str "m")   , ("minute", str "min")   , ("mmHg", str "mmHg")@@ -418,7 +437,7 @@   , ("zetta", str "Z")   ] -lit :: String -> LP m Inlines+lit :: Text -> LP m Inlines lit = pure . str  removeDoubleQuotes :: Text -> Text@@ -454,7 +473,7 @@         -> LP m ()         -> LP m Inlines quoted' f starter ender = do-  startchs <- (T.unpack . untokenize) <$> starter+  startchs <- untokenize <$> starter   smart <- extensionEnabled Ext_smart <$> getOption readerExtensions   if smart      then do@@ -470,7 +489,7 @@ enquote :: PandocMonad m => Bool -> Maybe Text -> LP m Inlines enquote starred mblang = do   skipopts-  let lang = (T.unpack <$> mblang) >>= babelLangToBCP47+  let lang = mblang >>= babelLangToBCP47   let langspan = case lang of                       Nothing -> id                       Just l  -> spanWith ("",[],[("lang", renderLang l)])@@ -486,27 +505,27 @@                   cs <- cites NormalCitation False                   return $ para (cite cs mempty)                 else return mempty-  let lang = (T.unpack <$> mblang) >>= babelLangToBCP47+  let lang = mblang >>= babelLangToBCP47   let langdiv = case lang of                       Nothing -> id                       Just l  -> divWith ("",[],[("lang", renderLang l)])   bs <- grouped block   return $ blockQuote . langdiv $ (bs <> citePar) -doAcronym :: PandocMonad m => String -> LP m Inlines+doAcronym :: PandocMonad m => Text -> LP m Inlines doAcronym form = do   acro <- braced-  return . mconcat $ [spanWith ("",[],[("acronym-label", toksToString acro),-    ("acronym-form", "singular+" ++ form)])-    $ str $ toksToString acro]+  return . mconcat $ [spanWith ("",[],[("acronym-label", untokenize acro),+    ("acronym-form", "singular+" <> form)])+    $ str $ untokenize acro] -doAcronymPlural :: PandocMonad m => String -> LP m Inlines+doAcronymPlural :: PandocMonad m => Text -> LP m Inlines doAcronymPlural form = do   acro <- braced   plural <- lit "s"-  return . mconcat $ [spanWith ("",[],[("acronym-label", toksToString acro),-    ("acronym-form", "plural+" ++ form)]) $-   mconcat [str $ toksToString acro, plural]]+  return . mconcat $ [spanWith ("",[],[("acronym-label", untokenize acro),+    ("acronym-form", "plural+" <> form)]) $+   mconcat [str $ untokenize acro, plural]]  doverb :: PandocMonad m => LP m Inlines doverb = do@@ -515,7 +534,7 @@               Just (c, ts) | T.null ts -> return c               _            -> mzero   withVerbatimMode $-    (code . T.unpack . untokenize) <$>+    (code . untokenize) <$>       manyTill (notFollowedBy newlineTok >> verbTok marker) (symbol marker)  verbTok :: PandocMonad m => Char -> LP m Tok@@ -530,7 +549,7 @@                   : totoks (incSourceColumn pos (i + 1)) (T.drop 1 t2) ++ inp          return $ Tok pos toktype t1 -listingsLanguage :: [(String, String)] -> Maybe String+listingsLanguage :: [(Text, Text)] -> Maybe Text listingsLanguage opts =   case lookup "language" opts of     Nothing  -> Nothing@@ -545,10 +564,10 @@ domintinline :: PandocMonad m => LP m Inlines domintinline = do   skipopts-  cls <- toksToString <$> braced+  cls <- untokenize <$> braced   doinlinecode [cls] -doinlinecode :: PandocMonad m => [String] -> LP m Inlines+doinlinecode :: PandocMonad m => [Text] -> LP m Inlines doinlinecode classes = do   Tok _ Symbol t <- anySymbol   marker <- case T.uncons t of@@ -556,14 +575,14 @@               _            -> mzero   let stopchar = if marker == '{' then '}' else marker   withVerbatimMode $-    (codeWith ("",classes,[]) . map nlToSpace . T.unpack . untokenize) <$>+    (codeWith ("",classes,[]) . T.map nlToSpace . untokenize) <$>       manyTill (verbTok stopchar) (symbol stopchar)  nlToSpace :: Char -> Char nlToSpace '\n' = ' ' nlToSpace x    = x -keyval :: PandocMonad m => LP m (String, String)+keyval :: PandocMonad m => LP m (Text, Text) keyval = try $ do   Tok _ Word key <- satisfyTok isWordTok   optional sp@@ -584,55 +603,55 @@                                 _                -> True))))))   optional (symbol ',')   optional sp-  return (T.unpack key, T.unpack $ T.strip val)+  return (key, T.strip val) -keyvals :: PandocMonad m => LP m [(String, String)]+keyvals :: PandocMonad m => LP m [(Text, Text)] keyvals = try $ symbol '[' >> manyTill keyval (symbol ']')  accent :: PandocMonad m => Char -> Maybe Char -> LP m Inlines accent combiningAccent fallBack = try $ do   ils <- tok   case toList ils of-       (Str (x:xs) : ys) -> return $ fromList $+       (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $          -- try to normalize to the combined character:-         Str (T.unpack-           (Normalize.normalize Normalize.NFC-             (T.pack [x, combiningAccent])) ++ xs) : ys-       [Space]           -> return $ str [fromMaybe combiningAccent fallBack]-       []                -> return $ str [fromMaybe combiningAccent fallBack]+         Str (Normalize.normalize Normalize.NFC+               (T.pack [x, combiningAccent]) <> xs) : ys+       [Space]           -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack+       []                -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack        _                 -> return ils-mathDisplay :: String -> Inlines++mathDisplay :: Text -> Inlines mathDisplay = displayMath . trimMath -mathInline :: String -> Inlines+mathInline :: Text -> Inlines mathInline = math . trimMath  dollarsMath :: PandocMonad m => LP m Inlines dollarsMath = do   symbol '$'   display <- option False (True <$ symbol '$')-  (do contents <- try $ T.unpack <$> pDollarsMath 0+  (do contents <- try $ untokenize <$> pDollarsMath 0       if display          then (mathDisplay contents <$ symbol '$')          else return $ mathInline contents)    <|> (guard display >> return (mathInline ""))  -- Int is number of embedded groupings-pDollarsMath :: PandocMonad m => Int -> LP m Text+pDollarsMath :: PandocMonad m => Int -> LP m [Tok] pDollarsMath n = do-  Tok _ toktype t <- anyTok+  tk@(Tok _ toktype t) <- anyTok   case toktype of        Symbol | t == "$"-              , n == 0 -> return mempty+              , n == 0 -> return []               | t == "\\" -> do-                  Tok _ _ t' <- anyTok-                  return (t <> t')-              | t == "{" -> (t <>) <$> pDollarsMath (n+1)+                  tk' <- anyTok+                  ((tk :) . (tk' :)) <$> pDollarsMath n+              | t == "{" -> (tk :) <$> pDollarsMath (n+1)               | t == "}" ->                 if n > 0-                then (t <>) <$> pDollarsMath (n-1)+                then (tk :) <$> pDollarsMath (n-1)                 else mzero-       _ -> (t <>) <$> pDollarsMath n+       _ -> (tk :) <$> pDollarsMath n  -- citations @@ -664,10 +683,10 @@                         }   return $ addPrefix pre $ addSuffix suf $ map conv keys -citationLabel :: PandocMonad m => LP m String+citationLabel :: PandocMonad m => LP m Text citationLabel  = do   optional spaces-  toksToString <$>+  untokenize <$>     (many1 (satisfyTok isWordTok <|> symbolIn bibtexKeyChar)           <* optional spaces           <* optional (symbol ',')@@ -711,10 +730,10 @@         addMprenote _ _ = []         addMpostnote = addSuffix . mpostnote -citation :: PandocMonad m => String -> CitationMode -> Bool -> LP m Inlines+citation :: PandocMonad m => Text -> CitationMode -> Bool -> LP m Inlines citation name mode multi = do   (c,raw) <- withRaw $ cites mode multi-  return $ cite c (rawInline "latex" $ "\\" ++ name ++ toksToString raw)+  return $ cite c (rawInline "latex" $ "\\" <> name <> untokenize raw)  handleCitationPart :: Inlines -> [Citation] handleCitationPart ils =@@ -738,7 +757,7 @@   case cs of        []       -> mzero        (c:cits) -> return $ cite (c{ citationMode = mode }:cits)-                      (rawInline "latex" $ "\\citetext" ++ toksToString raw)+                      (rawInline "latex" $ "\\citetext" <> untokenize raw)  inNote :: Inlines -> Inlines inNote ils =@@ -762,10 +781,10 @@ tok = try $ spaces >> grouped inline <|> inlineCommand' <|> singleChar'   where singleChar' = do           Tok _ _ t <- singleChar-          return (str (T.unpack t))+          return $ str t  opt :: PandocMonad m => LP m Inlines-opt = bracketed inline <|> (str . T.unpack <$> rawopt)+opt = bracketed inline <|> (str <$> rawopt)  paropt :: PandocMonad m => LP m Inlines paropt = parenWrapped inline@@ -804,26 +823,31 @@ inBrackets :: Inlines -> Inlines inBrackets x = str "[" <> x <> str "]" -unescapeURL :: String -> String-unescapeURL ('\\':x:xs) | isEscapable x = x:unescapeURL xs-  where isEscapable c = c `elem` ("#$%&~_^\\{}" :: String)-unescapeURL (x:xs) = x:unescapeURL xs-unescapeURL [] = ""+unescapeURL :: Text -> Text+unescapeURL = T.concat . go . T.splitOn "\\"+  where+    isEscapable c = c `elemText` "#$%&~_^\\{}"+    go (x:xs) = x : map unescapeInterior xs+    go []     = []+    unescapeInterior t+      | Just (c, _) <- T.uncons t+      , isEscapable c = t+      | otherwise = "\\" <> t  mathEnvWith :: PandocMonad m             => (Inlines -> a) -> Maybe Text -> Text -> LP m a mathEnvWith f innerEnv name = f . mathDisplay . inner <$> mathEnv name    where inner x = case innerEnv of                         Nothing -> x-                        Just y  -> "\\begin{" ++ T.unpack y ++ "}\n" ++ x ++-                                   "\\end{" ++ T.unpack y ++ "}"+                        Just y  -> "\\begin{" <> y <> "}\n" <> x <>+                                   "\\end{" <> y <> "}" -mathEnv :: PandocMonad m => Text -> LP m String+mathEnv :: PandocMonad m => Text -> LP m Text mathEnv name = do   skipopts   optional blankline   res <- manyTill anyTok (end_ name)-  return $ stripTrailingNewlines $ T.unpack $ untokenize res+  return $ stripTrailingNewlines $ untokenize res  inlineEnvironment :: PandocMonad m => LP m Inlines inlineEnvironment = try $ do@@ -893,10 +917,12 @@   , ("cref", rawInlineOr "cref" $ doref "ref")       -- from cleveref.sty   , ("vref", rawInlineOr "vref" $ doref "ref+page")  -- from varioref.sty   , ("eqref", rawInlineOr "eqref" $ doref "eqref")   -- from amsmath.sty+  , ("mbox", rawInlineOr "mbox" $ processHBox <$> tok)+  , ("hbox", rawInlineOr "hbox" $ processHBox <$> tok)   , ("lettrine", optional opt >> extractSpaces (spanWith ("",["lettrine"],[])) <$> tok)-  , ("(", mathInline . toksToString <$> manyTill anyTok (controlSeq ")"))-  , ("[", mathDisplay . toksToString <$> manyTill anyTok (controlSeq "]"))-  , ("ensuremath", mathInline . toksToString <$> braced)+  , ("(", mathInline . untokenize <$> manyTill anyTok (controlSeq ")"))+  , ("[", mathDisplay . untokenize <$> manyTill anyTok (controlSeq "]"))+  , ("ensuremath", mathInline . untokenize <$> braced)   , ("texorpdfstring", const <$> tok <*> tok)   , ("P", lit "¶")   , ("S", lit "§")@@ -912,6 +938,7 @@   , ("it", extractSpaces emph <$> inlines)   , ("sl", extractSpaces emph <$> inlines)   , ("bf", extractSpaces strong <$> inlines)+  , ("tt", code . stringify . toList <$> inlines)   , ("rm", inlines)   , ("itshape", extractSpaces emph <$> inlines)   , ("slshape", extractSpaces emph <$> inlines)@@ -981,20 +1008,21 @@   , ("textgreater", lit ">")   , ("thanks", skipopts >> note <$> grouped block)   , ("footnote", skipopts >> note <$> grouped block)+  , ("passthrough", tok) -- \passthrough macro used by latex writer+                         -- for listings   , ("verb", doverb)   , ("lstinline", dolstinline)   , ("mintinline", domintinline)   , ("Verb", doverb)-  , ("url", ((unescapeURL . T.unpack . untokenize) <$> bracedUrl) >>= \url ->+  , ("url", ((unescapeURL . untokenize) <$> bracedUrl) >>= \url ->                   pure (link url "" (str url)))-  , ("nolinkurl", ((unescapeURL . T.unpack . untokenize) <$> bracedUrl) >>= \url ->+  , ("nolinkurl", ((unescapeURL . untokenize) <$> bracedUrl) >>= \url ->                   pure (code url))-  , ("href", (unescapeURL . toksToString <$>+  , ("href", (unescapeURL . untokenize <$>                  bracedUrl <* optional sp) >>= \url ->                    tok >>= \lab -> pure (link url "" lab))   , ("includegraphics", do options <- option [] keyvals-                           src <- unescapeURL . T.unpack .-                                    removeDoubleQuotes . untokenize <$> braced+                           src <- unescapeURL . removeDoubleQuotes . untokenize <$> braced                            mkImage options src)   , ("enquote*", enquote True Nothing)   , ("enquote", enquote False Nothing)@@ -1137,7 +1165,7 @@   -- babel   , ("foreignlanguage", foreignlanguage)   -- include-  , ("input", include "input")+  , ("input", rawInlineOr "input" $ include "input")   -- soul package   , ("ul", underlineSpan <$> tok)   -- ulem package@@ -1149,22 +1177,21 @@ ifdim :: PandocMonad m => LP m Inlines ifdim = do   contents <- manyTill anyTok (controlSeq "fi")-  return $ rawInline "latex" $ T.unpack $-           "\\ifdim" <> untokenize contents <> "\\fi"+  return $ rawInline "latex" $ "\\ifdim" <> untokenize contents <> "\\fi"  makeUppercase :: Inlines -> Inlines-makeUppercase = fromList . walk (alterStr (map toUpper)) . toList+makeUppercase = fromList . walk (alterStr T.toUpper) . toList  makeLowercase :: Inlines -> Inlines-makeLowercase = fromList . walk (alterStr (map toLower)) . toList+makeLowercase = fromList . walk (alterStr T.toLower) . toList -alterStr :: (String -> String) -> Inline -> Inline+alterStr :: (Text -> Text) -> Inline -> Inline alterStr f (Str xs) = Str (f xs) alterStr _ x = x  foreignlanguage :: PandocMonad m => LP m Inlines foreignlanguage = do-  babelLang <- T.unpack . untokenize <$> braced+  babelLang <- untokenize <$> braced   case babelLangToBCP47 babelLang of        Just lang -> spanWith ("", [], [("lang",  renderLang lang)]) <$> tok        _ -> tok@@ -1173,24 +1200,24 @@ inlineLanguageCommands = M.fromList $ mk <$> M.toList polyglossiaLangToBCP47   where     mk (polyglossia, bcp47Func) =-      ("text" <> T.pack polyglossia, inlineLanguage bcp47Func)+      ("text" <> polyglossia, inlineLanguage bcp47Func) -inlineLanguage :: PandocMonad m => (String -> Lang) -> LP m Inlines+inlineLanguage :: PandocMonad m => (Text -> Lang) -> LP m Inlines inlineLanguage bcp47Func = do-  o <- option "" $ (T.unpack . T.filter (\c -> c /= '[' && c /= ']'))+  o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')                 <$> rawopt   let lang = renderLang $ bcp47Func o   extractSpaces (spanWith ("", [], [("lang", lang)])) <$> tok  hyperlink :: PandocMonad m => LP m Inlines hyperlink = try $ do-  src <- toksToString <$> braced+  src <- untokenize <$> braced   lab <- tok-  return $ link ('#':src) "" lab+  return $ link ("#" <> src) "" lab  hypertargetBlock :: PandocMonad m => LP m Blocks hypertargetBlock = try $ do-  ref <- toksToString <$> braced+  ref <- untokenize <$> braced   bs <- grouped block   case toList bs of        [Header 1 (ident,_,_) _] | ident == ref -> return bs@@ -1198,7 +1225,7 @@  hypertargetInline :: PandocMonad m => LP m Inlines hypertargetInline = try $ do-  ref <- toksToString <$> braced+  ref <- untokenize <$> braced   ils <- grouped inline   return $ spanWith (ref, [], []) ils @@ -1208,7 +1235,7 @@  romanNumeralLower :: (PandocMonad m) => LP m Inlines romanNumeralLower =-  str . map toLower . toRomanNumeral <$> romanNumeralArg+  str . T.toLower . toRomanNumeral <$> romanNumeralArg  romanNumeralArg :: (PandocMonad m) => LP m Int romanNumeralArg = spaces *> (parser <|> inBraces)@@ -1224,19 +1251,19 @@       Tok _ Word s <- satisfyTok isWordTok       let (digits, rest) = T.span isDigit s       unless (T.null rest) $-        fail "Non-digits in argument to \\Rn or \\RN"-      safeRead $ T.unpack digits+        Prelude.fail "Non-digits in argument to \\Rn or \\RN"+      safeRead digits  newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a newToggle name = do   updateState $ \st ->-    st{ sToggles = M.insert (toksToString name) False (sToggles st) }+    st{ sToggles = M.insert (untokenize name) False (sToggles st) }   return mempty  setToggle :: (Monoid a, PandocMonad m) => Bool -> [Tok] -> LP m a setToggle on name = do   updateState $ \st ->-    st{ sToggles = M.adjust (const on) (toksToString name) (sToggles st) }+    st{ sToggles = M.adjust (const on) (untokenize name) (sToggles st) }   return mempty  ifToggle :: PandocMonad m => LP m ()@@ -1248,7 +1275,7 @@   no <- braced   toggles <- sToggles <$> getState   inp <- getInput-  let name' = toksToString name+  let name' = untokenize name   case M.lookup name' toggles of                 Just True  -> setInput (yes ++ inp)                 Just False -> setInput (no  ++ inp)@@ -1271,11 +1298,11 @@      else getInput >>= setInput . (ifnotequal ++)   return mempty -coloredInline :: PandocMonad m => String -> LP m Inlines+coloredInline :: PandocMonad m => Text -> LP m Inlines coloredInline stylename = do   skipopts   color <- braced-  spanWith ("",[],[("style",stylename ++ ": " ++ toksToString color)]) <$> tok+  spanWith ("",[],[("style",stylename <> ": " <> untokenize color)]) <$> tok  ttfamily :: PandocMonad m => LP m Inlines ttfamily = (code . stringify . toList) <$> tok@@ -1287,7 +1314,15 @@      then rawInline "latex" <$> getRawCommand name' ("\\" <> name')      else fallback -getRawCommand :: PandocMonad m => Text -> Text -> LP m String+processHBox :: Inlines -> Inlines+processHBox = walk convert+  where+    convert Space     = Str $ T.singleton $ chr 160 -- non-breakable space+    convert SoftBreak = Str $ T.singleton $ chr 160 -- non-breakable space+    convert LineBreak = Str ""+    convert x         = x++getRawCommand :: PandocMonad m => Text -> Text -> LP m Text getRawCommand name txt = do   (_, rawargs) <- withRaw $       case name of@@ -1305,7 +1340,7 @@                skipopts                option "" (try dimenarg)                void $ many braced-  return $ T.unpack (txt <> untokenize rawargs)+  return $ txt <> untokenize rawargs  isFontSizeCommand :: Text -> Bool isFontSizeCommand "tiny" = True@@ -1365,21 +1400,21 @@ dolabel :: PandocMonad m => LP m Inlines dolabel = do   v <- braced-  let refstr = toksToString v+  let refstr = untokenize v   return $ spanWith (refstr,[],[("label", refstr)])-    $ inBrackets $ str $ toksToString v+    $ inBrackets $ str $ untokenize v -doref :: PandocMonad m => String -> LP m Inlines+doref :: PandocMonad m => Text -> LP m Inlines doref cls = do   v <- braced-  let refstr = toksToString v+  let refstr = untokenize v   return $ linkWith ("",[],[ ("reference-type", cls)                            , ("reference", refstr)])-                    ('#':refstr)+                    ("#" <> refstr)                     ""                     (inBrackets $ str refstr) -lookupListDefault :: (Show k, Ord k) => v -> [k] -> M.Map k v -> v+lookupListDefault :: (Ord k) => v -> [k] -> M.Map k v -> v lookupListDefault d = (fromMaybe d .) . lookupList   where lookupList l m = msum $ map (`M.lookup` m) l @@ -1388,7 +1423,7 @@      <|> (space  <$ whitespace)      <|> (softbreak <$ endline)      <|> word-     <|> macroDef+     <|> macroDef (rawInline "latex")      <|> inlineCommand'      <|> inlineEnvironment      <|> inlineGroup@@ -1404,11 +1439,11 @@      <|> (str "\160" <$ symbol '~')      <|> dollarsMath      <|> (guardEnabled Ext_literate_haskell *> symbol '|' *> doLHSverb)-     <|> (str . (:[]) <$> primEscape)+     <|> (str . T.singleton <$> primEscape)      <|> regularSymbol      <|> (do res <- symbolIn "#^'`\"[]&"              pos <- getPosition-             let s = T.unpack (untoken res)+             let s = untoken res              report $ ParsingUnescaped s pos              return $ str s) @@ -1432,11 +1467,14 @@   guard $ t == txt) <?> ("\\end{" ++ T.unpack t ++ "}")  preamble :: PandocMonad m => LP m Blocks-preamble = mempty <$ many preambleBlock-  where preambleBlock =  spaces1-                     <|> void (macroDef <|> blockCommand)-                     <|> void braced-                     <|> (notFollowedBy (begin_ "document") >> void anyTok)+preamble = mconcat <$> many preambleBlock+  where preambleBlock =  (mempty <$ spaces1)+                     <|> macroDef (rawBlock "latex")+                     <|> (mempty <$ blockCommand)+                     <|> (mempty <$ braced)+                     <|> (do notFollowedBy (begin_ "document")+                             anyTok+                             return mempty)  paragraph :: PandocMonad m => LP m Blocks paragraph = do@@ -1445,6 +1483,14 @@      then return mempty      else return $ para x +rawBlockOr :: PandocMonad m => Text -> LP m Blocks -> LP m Blocks+rawBlockOr name fallback = do+  -- if raw_tex allowed, don't process+  parseRaw <- extensionEnabled Ext_raw_tex <$> getOption readerExtensions+  if parseRaw+     then rawBlock "latex" <$> getRawCommand name ("\\" <> name)+     else fallback+ include :: (PandocMonad m, Monoid a) => Text -> LP m a include name = do   skipMany opt@@ -1456,7 +1502,7 @@                       -- note, we can have cc_by_4.0 for example...                       _ | name == "usepackage" -> addExtension f ".sty"                         | otherwise -> addExtension f ".tex"-  dirs <- (splitBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"+  dirs <- (map T.unpack . splitTextBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"   mapM_ (insertIncluded dirs) (map addExt fs)   return mempty @@ -1467,19 +1513,19 @@ insertIncluded dirs f = do   pos <- getPosition   containers <- getIncludeFiles <$> getState-  when (f `elem` containers) $-    throwError $ PandocParseError $ "Include file loop at " ++ show pos-  updateState $ addIncludeFile f+  when (T.pack f `elem` containers) $+    throwError $ PandocParseError $ T.pack $ "Include file loop at " ++ show pos+  updateState $ addIncludeFile $ T.pack f   mbcontents <- readFileFromDirs dirs f   contents <- case mbcontents of                    Just s -> return s                    Nothing -> do-                     report $ CouldNotLoadIncludeFile f pos+                     report $ CouldNotLoadIncludeFile (T.pack f) pos                      return ""-  getInput >>= setInput . (tokenize f (T.pack contents) ++)+  getInput >>= setInput . (tokenize f contents ++)   updateState dropLatestIncludeFile -addMeta :: PandocMonad m => ToMetaValue a => String -> a -> LP m ()+addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> LP m () addMeta field val = updateState $ \st ->    st{ sMeta = addMetaField field val $ sMeta st } @@ -1494,20 +1540,26 @@   egroup   addMeta "author" (map trimInlines auths) -macroDef :: (Monoid a, PandocMonad m) => LP m a-macroDef =-  mempty <$ (commandDef <|> environmentDef)+macroDef :: (PandocMonad m, Monoid a) => (Text -> a) -> LP m a+macroDef constructor = do+    (_, s) <- withRaw (commandDef <|> environmentDef)+    (constructor (untokenize s) <$+      guardDisabled Ext_latex_macros)+     <|> return mempty   where commandDef = do           (name, macro') <- newcommand <|> letmacro <|> defmacro           guardDisabled Ext_latex_macros <|>            updateState (\s -> s{ sMacros = M.insert name macro' (sMacros s) })         environmentDef = do-          (name, macro1, macro2) <- newenvironment-          guardDisabled Ext_latex_macros <|>-            do updateState $ \s -> s{ sMacros =-                M.insert name macro1 (sMacros s) }-               updateState $ \s -> s{ sMacros =-                M.insert ("end" <> name) macro2 (sMacros s) }+          mbenv <- newenvironment+          case mbenv of+            Nothing -> return ()+            Just (name, macro1, macro2) -> do+              guardDisabled Ext_latex_macros <|>+                do updateState $ \s -> s{ sMacros =+                    M.insert name macro1 (sMacros s) }+                   updateState $ \s -> s{ sMacros =+                    M.insert ("end" <> name) macro2 (sMacros s) }         -- @\newenvironment{envname}[n-args][default]{begin}{end}@         -- is equivalent to         -- @\newcommand{\envname}[n-args][default]{begin}@@@ -1565,7 +1617,7 @@         (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')     spaces     numargs <- option 0 $ try bracketedNum-    let argspecs = map (\i -> ArgNum i) [1..numargs]+    let argspecs = map ArgNum [1..numargs]     spaces     optarg <- option Nothing $ Just <$> try bracketedToks     spaces@@ -1580,14 +1632,16 @@                  : (contents' ++                    [ Tok pos Symbol "}", Tok pos Symbol "}" ])               _                     -> contents'-    when (mtype == "newcommand") $ do-      macros <- sMacros <$> getState-      case M.lookup name macros of-           Just _  -> report $ MacroAlreadyDefined (T.unpack txt) pos-           Nothing -> return ()-    return (name, Macro ExpandWhenUsed argspecs optarg contents)+    macros <- sMacros <$> getState+    case M.lookup name macros of+        Just macro+          | mtype == "newcommand" -> do+              report $ MacroAlreadyDefined txt pos+              return (name, macro)+          | mtype == "providecommand" -> return (name, macro)+        _ -> return (name, Macro ExpandWhenUsed argspecs optarg contents) -newenvironment :: PandocMonad m => LP m (Text, Macro, Macro)+newenvironment :: PandocMonad m => LP m (Maybe (Text, Macro, Macro)) newenvironment = do   pos <- getPosition   Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|>@@ -1604,18 +1658,22 @@     let argspecs = map (\i -> ArgNum i) [1..numargs]     startcontents <- spaces >> bracedOrToken     endcontents <- spaces >> bracedOrToken-    when (mtype == "newenvironment") $ do-      macros <- sMacros <$> getState-      case M.lookup name macros of-           Just _  -> report $ MacroAlreadyDefined (T.unpack name) pos-           Nothing -> return ()-    return (name, Macro ExpandWhenUsed argspecs optarg startcontents,-             Macro ExpandWhenUsed [] Nothing endcontents)+    macros <- sMacros <$> getState+    case M.lookup name macros of+         Just _+           | mtype == "newenvironment" -> do+               report $ MacroAlreadyDefined name pos+               return Nothing+           | mtype == "provideenvironment" -> do+               return Nothing+         _ -> return $ Just (name,+                      Macro ExpandWhenUsed argspecs optarg startcontents,+                      Macro ExpandWhenUsed [] Nothing endcontents)  bracketedNum :: PandocMonad m => LP m Int bracketedNum = do   ds <- untokenize <$> bracketedToks-  case safeRead (T.unpack ds) of+  case safeRead ds of        Just i -> return i        _      -> return 0 @@ -1640,6 +1698,12 @@   skipopts   return mempty +epigraph :: PandocMonad m => LP m Blocks+epigraph = do+  p1 <- grouped block+  p2 <- grouped block+  return $ divWith ("", ["epigraph"], []) (p1 <> p2)+ resetCaption :: PandocMonad m => LP m () resetCaption = updateState $ \st -> st{ sCaption = (Nothing, Nothing) } @@ -1649,7 +1713,7 @@   contents <- grouped inline   lab <- option ident $           try (spaces >> controlSeq "label"-               >> spaces >> toksToString <$> braced)+               >> spaces >> untokenize <$> braced)   when (lvl == 0) $     updateState $ \st -> st{ sHasChapters = True }   unless ("unnumbered" `elem` classes) $ do@@ -1711,10 +1775,21 @@                   _ -> mempty   return $ para (trimInlines contents) <> sigs +parbox :: PandocMonad m => LP m Blocks+parbox = try $ do+  skipopts+  braced -- size+  oldInTableCell <- sInTableCell <$> getState+  -- see #5711+  updateState $ \st -> st{ sInTableCell = False }+  res <- grouped block+  updateState $ \st -> st{ sInTableCell = oldInTableCell }+  return res+ blockCommands :: PandocMonad m => M.Map Text (LP m Blocks) blockCommands = M.fromList    [ ("par", mempty <$ skipopts)-   , ("parbox",  skipopts >> braced >> grouped blocks)+   , ("parbox",  parbox)    , ("title", mempty <$ (skipopts *>                              (grouped inline >>= addMeta "title")                          <|> (grouped block >>= addMeta "title")))@@ -1724,7 +1799,14 @@    , ("address", mempty <$ (skipopts *> tok >>= addMeta "address"))    , ("signature", mempty <$ (skipopts *> authors))    , ("date", mempty <$ (skipopts *> tok >>= addMeta "date"))-   -- Koma-script metadata commands+   -- KOMA-Script metadata commands+   , ("extratitle", mempty <$ (skipopts *> tok >>= addMeta "extratitle"))+   , ("frontispiece", mempty <$ (skipopts *> tok >>= addMeta "frontispiece"))+   , ("titlehead", mempty <$ (skipopts *> tok >>= addMeta "titlehead"))+   , ("subject", mempty <$ (skipopts *> tok >>= addMeta "subject"))+   , ("publishers", mempty <$ (skipopts *> tok >>= addMeta "publishers"))+   , ("uppertitleback", mempty <$ (skipopts *> tok >>= addMeta "uppertitleback"))+   , ("lowertitleback", mempty <$ (skipopts *> tok >>= addMeta "lowertitleback"))    , ("dedication", mempty <$ (skipopts *> tok >>= addMeta "dedication"))    -- sectioning    , ("part", section nullAttr (-1))@@ -1765,9 +1847,9 @@    , ("centerline", (para . trimInlines) <$> (skipopts *> tok))    , ("caption", skipopts *> setCaption)    , ("bibliography", mempty <$ (skipopts *> braced >>=-         addMeta "bibliography" . splitBibs . toksToString))+         addMeta "bibliography" . splitBibs . untokenize))    , ("addbibresource", mempty <$ (skipopts *> braced >>=-         addMeta "bibliography" . splitBibs . toksToString))+         addMeta "bibliography" . splitBibs . untokenize))    , ("endinput", mempty <$ skipMany tok)    -- includes    , ("lstinputlisting", inputListing)@@ -1789,12 +1871,14 @@    , ("hyphenblockquote", braced >>= blockquote False . Just . untokenize)    , ("hyphenblockcquote", braced >>= blockquote True . Just . untokenize)    -- include-   , ("include", include "include")-   , ("input", include "input")-   , ("subfile", include "subfile")-   , ("usepackage", include "usepackage")+   , ("include", rawBlockOr "include" $ include "include")+   , ("input", rawBlockOr "input" $ include "input")+   , ("subfile", rawBlockOr "subfile" $ include "subfile")+   , ("usepackage", rawBlockOr "usepackage" $ include "usepackage")    -- preamble    , ("PackageError", mempty <$ (braced >> braced >> braced))+   -- epigraph package+   , ("epigraph", epigraph)    ]  @@ -1834,7 +1918,9 @@    , ("minted", minted)    , ("obeylines", obeylines)    , ("tikzpicture", rawVerbEnv "tikzpicture")+   , ("tikzcd", rawVerbEnv "tikzcd")    , ("lilypond", rawVerbEnv "lilypond")+   , ("ly", rawVerbEnv "ly")    -- etoolbox    , ("ifstrequal", ifstrequal)    , ("newtoggle", braced >>= newToggle)@@ -1866,18 +1952,18 @@   (bs, raw) <- withRaw $ env name blocks   if parseRaw      then return $ rawBlock "latex"-                 $ T.unpack $ beginCommand <> untokenize raw+                 $ beginCommand <> untokenize raw      else do-       report $ SkippedContent (T.unpack beginCommand) pos1+       report $ SkippedContent beginCommand pos1        pos2 <- getPosition-       report $ SkippedContent ("\\end{" ++ T.unpack name ++ "}") pos2+       report $ SkippedContent ("\\end{" <> name <> "}") pos2        return bs  rawVerbEnv :: PandocMonad m => Text -> LP m Blocks rawVerbEnv name = do   pos <- getPosition   (_, raw) <- withRaw $ verbEnv name-  let raw' = "\\begin{" ++ T.unpack name ++ "}" ++ toksToString raw+  let raw' = "\\begin{" <> name <> "}" <> untokenize raw   exts <- getOption readerExtensions   let parseRaw = extensionEnabled Ext_raw_tex exts   if parseRaw@@ -1886,12 +1972,11 @@        report $ SkippedContent raw' pos        return mempty -verbEnv :: PandocMonad m => Text -> LP m String+verbEnv :: PandocMonad m => Text -> LP m Text verbEnv name = withVerbatimMode $ do   optional blankline   res <- manyTill anyTok (end_ name)-  return $ T.unpack-         $ stripTrailingNewline+  return $ stripTrailingNewline          $ untokenize          $ res @@ -1935,11 +2020,11 @@ mintedAttr :: PandocMonad m => LP m Attr mintedAttr = do   options <- option [] keyvals-  lang <- toksToString <$> braced+  lang <- untokenize <$> braced   let kvs = [ (if k == "firstnumber"                   then "startFrom"                   else k, v) | (k,v) <- options ]-  let classes = [ lang | not (null lang) ] +++  let classes = [ lang | not (T.null lang) ] ++                 [ "numberLines" |                   lookup "linenos" options == Just "true" ]   return ("",classes,kvs)@@ -1948,14 +2033,14 @@ inputMinted = do   pos <- getPosition   attr <- mintedAttr-  f <- filter (/='"') . toksToString <$> braced-  dirs <- (splitBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"-  mbCode <- readFileFromDirs dirs f+  f <- T.filter (/='"') . untokenize <$> braced+  dirs <- (map T.unpack . splitTextBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"+  mbCode <- readFileFromDirs dirs (T.unpack f)   rawcode <- case mbCode of                   Just s -> return s                   Nothing -> do                     report $ CouldNotLoadIncludeFile f pos-                    return []+                    return ""   return $ B.codeBlockWith attr rawcode  letterContents :: PandocMonad m => LP m Blocks@@ -1977,10 +2062,10 @@ addImageCaption :: PandocMonad m => Blocks -> LP m Blocks addImageCaption = walkM go   where go (Image attr@(_, cls, kvs) alt (src,tit))-            | not ("fig:" `isPrefixOf` tit) = do+            | not ("fig:" `T.isPrefixOf` tit) = do           (mbcapt, mblab) <- sCaption <$> getState           let (alt', tit') = case mbcapt of-                               Just ils -> (toList ils, "fig:" ++ tit)+                               Just ils -> (toList ils, "fig:" <> tit)                                Nothing  -> (alt, tit)               attr' = case mblab of                         Just lab -> (lab, cls, kvs)@@ -2015,23 +2100,23 @@           return $ Image attr' alt' (src, tit')         go x = return x -coloredBlock :: PandocMonad m => String -> LP m Blocks+coloredBlock :: PandocMonad m => Text -> LP m Blocks coloredBlock stylename = try $ do   skipopts   color <- braced   notFollowedBy (grouped inline)-  let constructor = divWith ("",[],[("style",stylename ++ ": " ++ toksToString color)])+  let constructor = divWith ("",[],[("style",stylename <> ": " <> untokenize color)])   constructor <$> grouped block  graphicsPath :: PandocMonad m => LP m Blocks graphicsPath = do-  ps <- map toksToString <$>+  ps <- map (T.unpack . untokenize) <$>           (bgroup *> spaces *> manyTill (braced <* spaces) egroup)-  getResourcePath >>= setResourcePath . (++ ps)+  getResourcePath >>= setResourcePath . (<> ps)   return mempty -splitBibs :: String -> [Inlines]-splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',')+splitBibs :: Text -> [Inlines]+splitBibs = map (str . T.pack . flip replaceExtension "bib" . T.unpack . trim) . splitTextBy (==',')  alltt :: Blocks -> Blocks alltt = walk strToCode@@ -2040,7 +2125,7 @@         strToCode SoftBreak = LineBreak         strToCode x         = x -parseListingsOptions :: [(String, String)] -> Attr+parseListingsOptions :: [(Text, Text)] -> Attr parseListingsOptions options =   let kvs = [ (if k == "firstnumber"                   then "startFrom"@@ -2054,23 +2139,23 @@ inputListing = do   pos <- getPosition   options <- option [] keyvals-  f <- filter (/='"') . toksToString <$> braced-  dirs <- (splitBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"-  mbCode <- readFileFromDirs dirs f+  f <- T.filter (/='"') . untokenize <$> braced+  dirs <- (map T.unpack . splitTextBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"+  mbCode <- readFileFromDirs dirs (T.unpack f)   codeLines <- case mbCode of-                      Just s -> return $ lines s+                      Just s -> return $ T.lines s                       Nothing -> do                         report $ CouldNotLoadIncludeFile f pos                         return []   let (ident,classes,kvs) = parseListingsOptions options   let classes' =         (case listingsLanguage options of-           Nothing -> (take 1 (languagesByExtension (takeExtension f)) ++)+           Nothing -> (take 1 (languagesByExtension (T.pack $ takeExtension $ T.unpack f)) <>)            Just _  -> id) classes   let firstline = fromMaybe 1 $ lookup "firstline" options >>= safeRead   let lastline = fromMaybe (length codeLines) $                        lookup "lastline" options >>= safeRead-  let codeContents = intercalate "\n" $ take (1 + lastline - firstline) $+  let codeContents = T.intercalate "\n" $ take (1 + lastline - firstline) $                        drop (firstline - 1) codeLines   return $ codeBlockWith (ident,classes',kvs) codeContents @@ -2101,12 +2186,12 @@   spaces   let markerSpec = do         symbol '['-        ts <- toksToString <$> manyTill anyTok (symbol ']')+        ts <- untokenize <$> manyTill anyTok (symbol ']')         case runParser anyOrderedListMarker def "option" ts of              Right r -> return r              Left _  -> do                pos <- getPosition-               report $ SkippedContent ("[" ++ ts ++ "]") pos+               report $ SkippedContent ("[" <> ts <> "]") pos                return (1, DefaultStyle, DefaultDelim)   (_, style, delim) <- option (1, DefaultStyle, DefaultDelim) markerSpec   spaces@@ -2116,17 +2201,17 @@   spaces   start <- option 1 $ try $ do pos <- getPosition                                controlSeq "setcounter"-                               ctr <- toksToString <$> braced-                               guard $ "enum" `isPrefixOf` ctr-                               guard $ all (`elem` ['i','v']) (drop 4 ctr)+                               ctr <- untokenize <$> braced+                               guard $ "enum" `T.isPrefixOf` ctr+                               guard $ T.all (`elem` ['i','v']) (T.drop 4 ctr)                                optional sp-                               num <- toksToString <$> braced+                               num <- untokenize <$> braced                                case safeRead num of                                     Just i -> return (i + 1 :: Int)                                     Nothing -> do                                       report $ SkippedContent-                                        ("\\setcounter{" ++ ctr ++-                                         "}{" ++ num ++ "}") pos+                                        ("\\setcounter{" <> ctr <>+                                         "}{" <> num <> "}") pos                                       return 1   bs <- listenv "enumerate" (many item)   return $ orderedListWith (start, style, delim) bs@@ -2160,7 +2245,7 @@   inp <- getInput   case inp of        (Tok spos Word t : rest) ->-         setInput $ map (Tok spos Symbol . T.singleton) (T.unpack t) ++ rest+         setInput $ map (Tok spos Symbol . T.singleton) (T.unpack t) <> rest        _ -> return ()  parseAligns :: PandocMonad m => LP m [(Alignment, Double, ([Tok], [Tok]))]@@ -2181,7 +2266,7 @@   let alignSuffix = symbol '<' >> braced   let colWidth = try $ do         symbol '{'-        ds <- trim . toksToString <$> manyTill anyTok (controlSeq "linewidth")+        ds <- trim . untokenize <$> manyTill anyTok (controlSeq "linewidth")         spaces         symbol '}'         case safeRead ds of@@ -2191,7 +2276,7 @@         pref <- option [] alignPrefix         spaces         al <- alignChar-        width <- colWidth <|> option 0.0 (do s <- toksToString <$> braced+        width <- colWidth <|> option 0.0 (do s <- untokenize <$> braced                                              pos <- getPosition                                              report $ SkippedContent s pos                                              return 0.0)@@ -2201,13 +2286,13 @@   let starAlign = do -- '*{2}{r}' == 'rr', we just expand like a macro         symbol '*'         spaces-        ds <- trim . toksToString <$> braced+        ds <- trim . untokenize <$> braced         spaces         spec <- braced         case safeRead ds of              Just n  ->                getInput >>= setInput . (mconcat (replicate n spec) ++)-             Nothing -> fail $ "Could not parse " ++ ds ++ " as number"+             Nothing -> Prelude.fail $ "Could not parse " <> T.unpack ds <> " as number"   bgroup   spaces   maybeBar@@ -2228,9 +2313,13 @@   -- add prefixes and suffixes in token stream:   let celltoks (pref, suff) = do         prefpos <- getPosition-        contents <- many (notFollowedBy+        contents <- mconcat <$>+            many ( snd <$> withRaw (controlSeq "parbox" >> parbox) -- #5711+                  <|>+                   (do notFollowedBy                          (() <$ amp <|> () <$ lbreak <|> end_ envname)-                         >> anyTok)+                       count 1 anyTok) )+         suffpos <- getPosition         option [] (count 1 amp)         return $ map (setpos prefpos) pref ++ contents ++ map (setpos suffpos) suff@@ -2296,11 +2385,11 @@ block = do   res <- (mempty <$ spaces1)     <|> environment-    <|> macroDef+    <|> macroDef (rawBlock "latex")     <|> blockCommand     <|> paragraph     <|> grouped block-  trace (take 60 $ show $ B.toList res)+  trace (T.take 60 $ tshow $ B.toList res)   return res  blocks :: PandocMonad m => LP m Blocks@@ -2308,9 +2397,9 @@  setDefaultLanguage :: PandocMonad m => LP m Blocks setDefaultLanguage = do-  o <- option "" $ (T.unpack . T.filter (\c -> c /= '[' && c /= ']'))+  o <- option "" $ T.filter (\c -> c /= '[' && c /= ']')                 <$> rawopt-  polylang <- toksToString <$> braced+  polylang <- untokenize <$> braced   case M.lookup polylang polyglossiaLangToBCP47 of        Nothing -> return mempty -- TODO mzero? warning?        Just langFunc -> do
src/Text/Pandoc/Readers/LaTeX/Lang.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.LaTeX.Lang    Copyright   : Copyright (C) 2018-2019 John MacFarlane@@ -18,11 +19,12 @@ where import Prelude import qualified Data.Map as M+import qualified Data.Text as T import Text.Pandoc.BCP47 (Lang(..)) -polyglossiaLangToBCP47 :: M.Map String (String -> Lang)+polyglossiaLangToBCP47 :: M.Map T.Text (T.Text -> Lang) polyglossiaLangToBCP47 = M.fromList-  [ ("arabic", \o -> case filter (/=' ') o of+  [ ("arabic", \o -> case T.filter (/=' ') o of        "locale=algeria"    -> Lang "ar" "" "DZ" []        "locale=mashriq"    -> Lang "ar" "" "SY" []        "locale=libya"      -> Lang "ar" "" "LY" []@@ -30,7 +32,7 @@        "locale=mauritania" -> Lang "ar" "" "MR" []        "locale=tunisia"    -> Lang "ar" "" "TN" []        _                   -> Lang "ar" "" "" [])-  , ("german", \o -> case filter (/=' ') o of+  , ("german", \o -> case T.filter (/=' ') o of        "spelling=old" -> Lang "de" "" "DE" ["1901"]        "variant=austrian,spelling=old"                        -> Lang "de" "" "AT" ["1901"]@@ -40,11 +42,11 @@        "variant=swiss" -> Lang "de" "" "CH" []        _ -> Lang "de" "" "" [])   , ("lsorbian", \_ -> Lang "dsb" "" "" [])-  , ("greek", \o -> case filter (/=' ') o of+  , ("greek", \o -> case T.filter (/=' ') o of        "variant=poly"    -> Lang "el" "" "polyton" []        "variant=ancient" -> Lang "grc" "" "" []        _                 -> Lang "el" "" "" [])-  , ("english", \o -> case filter (/=' ') o of+  , ("english", \o -> case T.filter (/=' ') o of        "variant=australian" -> Lang "en" "" "AU" []        "variant=canadian"   -> Lang "en" "" "CA" []        "variant=british"    -> Lang "en" "" "GB" []@@ -52,7 +54,7 @@        "variant=american"   -> Lang "en" "" "US" []        _                    -> Lang "en" "" "" [])   , ("usorbian", \_ -> Lang "hsb" "" "" [])-  , ("latin", \o -> case filter (/=' ') o of+  , ("latin", \o -> case T.filter (/=' ') o of        "variant=classic" -> Lang "la" "" "" ["x-classic"]        _                 -> Lang "la" "" "" [])   , ("slovenian", \_ -> Lang "sl" "" "" [])@@ -133,7 +135,7 @@   , ("vietnamese", \_ -> Lang "vi" "" "" [])   ] -babelLangToBCP47 :: String -> Maybe Lang+babelLangToBCP47 :: T.Text -> Maybe Lang babelLangToBCP47 s =   case s of        "austrian" -> Just $ Lang "de" "" "AT" ["1901"]
src/Text/Pandoc/Readers/LaTeX/Parsing.hs view
@@ -92,14 +92,13 @@                                         ArgSpec (..), Tok (..), TokType (..)) import Text.Pandoc.Shared import Text.Parsec.Pos---- import Debug.Trace (traceShowId)+-- import Debug.Trace  newtype DottedNum = DottedNum [Int]   deriving (Show) -renderDottedNum :: DottedNum -> String-renderDottedNum (DottedNum xs) =+renderDottedNum :: DottedNum -> T.Text+renderDottedNum (DottedNum xs) = T.pack $   intercalate "." (map show xs)  incrementDottedNum :: Int -> DottedNum -> DottedNum@@ -112,18 +111,18 @@                             , sMeta          :: Meta                             , sQuoteContext  :: QuoteContext                             , sMacros        :: M.Map Text Macro-                            , sContainers    :: [String]+                            , sContainers    :: [Text]                             , sLogMessages   :: [LogMessage]-                            , sIdentifiers   :: Set.Set String+                            , sIdentifiers   :: Set.Set Text                             , sVerbatimMode  :: Bool-                            , sCaption       :: (Maybe Inlines, Maybe String)+                            , sCaption       :: (Maybe Inlines, Maybe Text)                             , sInListItem    :: Bool                             , sInTableCell   :: Bool                             , sLastHeaderNum :: DottedNum                             , sLastFigureNum :: DottedNum-                            , sLabels        :: M.Map String [Inline]+                            , sLabels        :: M.Map Text [Inline]                             , sHasChapters   :: Bool-                            , sToggles       :: M.Map String Bool+                            , sToggles       :: M.Map Text Bool                             , sExpanded      :: Bool                             }      deriving Show@@ -202,10 +201,9 @@        return result  rawLaTeXParser :: (PandocMonad m, HasMacros s, HasReaderOptions s)-               => Bool -> LP m a -> LP m a -> ParserT String s m (a, String)-rawLaTeXParser retokenize parser valParser = do-  inp <- getInput-  let toks = tokenize "source" $ T.pack inp+               => [Tok] -> Bool -> LP m a -> LP m a+               -> ParserT Text s m (a, Text)+rawLaTeXParser toks retokenize parser valParser = do   pstate <- getState   let lstate = def{ sOptions = extractReaderOptions pstate }   let lstate' = lstate { sMacros = extractMacros pstate }@@ -226,18 +224,27 @@               Right ((val, raw), st) -> do                 updateState (updateMacros (sMacros st <>))                 _ <- takeP (T.length (untokenize toks'))-                return (val, T.unpack (untokenize raw))+                let result = untokenize raw+                -- ensure we end with space if input did, see #4442+                let result' =+                      case reverse toks' of+                        (Tok _ (CtrlSeq _) t : _)+                         | " " `T.isSuffixOf` t+                         , not (" " `T.isSuffixOf` result)+                          -> result <> " "+                        _ -> result+                return (val, result')  applyMacros :: (PandocMonad m, HasMacros s, HasReaderOptions s)-            => String -> ParserT String s m String+            => Text -> ParserT Text s m Text applyMacros s = (guardDisabled Ext_latex_macros >> return s) <|>-   do let retokenize = toksToString <$> many (satisfyTok (const True))+   do let retokenize = untokenize <$> many (satisfyTok (const True))       pstate <- getState       let lstate = def{ sOptions = extractReaderOptions pstate                       , sMacros  = extractMacros pstate }-      res <- runParserT retokenize lstate "math" (tokenize "math" (T.pack s))+      res <- runParserT retokenize lstate "math" (tokenize "math" s)       case res of-           Left e   -> fail (show e)+           Left e   -> Prelude.fail (show e)            Right s' -> return s'  tokenize :: SourceName -> Text -> [Tok]@@ -300,7 +307,7 @@                       : totoks (incSourceColumn pos 2) rest'          | c == '#' ->            let (t1, t2) = T.span (\d -> d >= '0' && d <= '9') rest-           in  case safeRead (T.unpack t1) of+           in  case safeRead t1 of                     Just i ->                        Tok pos (Arg i) ("#" <> t1)                        : totoks (incSourceColumn pos (1 + T.length t1)) t2@@ -344,10 +351,21 @@ isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'  untokenize :: [Tok] -> Text-untokenize = mconcat . map untoken+untokenize = foldr untokenAccum mempty +untokenAccum :: Tok -> Text -> Text+untokenAccum (Tok _ (CtrlSeq _) t) accum =+  -- insert space to prevent breaking a control sequence; see #5836+  case (T.unsnoc t, T.uncons accum) of+    (Just (_,c), Just (d,_))+      | isLetter c+      , isLetter d+      -> t <> " " <> accum+    _ -> t <> accum+untokenAccum (Tok _ _ t) accum = t <> accum+ untoken :: Tok -> Text-untoken (Tok _ _ t) = t+untoken t = untokenAccum t mempty  toksToString :: [Tok] -> String toksToString = T.unpack . untokenize@@ -429,7 +447,7 @@      handleMacros n' spos name ts = do       when (n' > 20)  -- detect macro expansion loops-        $ throwError $ PandocMacroLoop (T.unpack name)+        $ throwError $ PandocMacroLoop name       macros <- sMacros <$> getState       case M.lookup name macros of            Nothing -> mzero@@ -438,14 +456,14 @@                    args <- case optarg of                              Nothing -> getargs M.empty argspecs                              Just o  -> do-                                x <- option o bracketedToks-                                getargs (M.singleton 1 x) argspecs+                                x <- option o $ bracketedToks+                                getargs (M.singleton 1 x) $ drop 1 argspecs                    rest <- getInput                    return (args, rest)              lstate <- getState              res <- lift $ runParserT getargs' lstate "args" ts              case res of-               Left _ -> fail $ "Could not parse arguments for " +++               Left _ -> Prelude.fail $ "Could not parse arguments for " ++                                 T.unpack name                Right (args, rest) -> do                  -- first boolean param is true if we're tokenizing@@ -569,11 +587,11 @@                     Just (c, _)                       | c >= '\64' && c <= '\127' -> return (chr (ord c - 64))                       | otherwise                 -> return (chr (ord c + 64))-                    Nothing -> fail "Empty content of Esc1"-       Esc2 -> case safeRead ('0':'x':T.unpack (T.drop 2 t)) of+                    Nothing -> Prelude.fail "Empty content of Esc1"+       Esc2 -> case safeRead ("0x" <> T.drop 2 t) of                     Just x  -> return (chr x)-                    Nothing -> fail $ "Could not read: " ++ T.unpack t-       _    -> fail "Expected an Esc1 or Esc2 token" -- should not happen+                    Nothing -> Prelude.fail $ "Could not read: " ++ T.unpack t+       _    -> Prelude.fail "Expected an Esc1 or Esc2 token" -- should not happen  bgroup :: PandocMonad m => LP m Tok bgroup = try $ do@@ -635,7 +653,8 @@ bracketedToks :: PandocMonad m => LP m [Tok] bracketedToks = do   symbol '['-  mconcat <$> manyTill (braced <|> (:[]) <$> anyTok) (symbol ']')+  concat <$> manyTill ((snd <$> withRaw (try braced)) <|> count 1 anyTok)+                      (symbol ']')  parenWrapped :: PandocMonad m => Monoid a => LP m a -> LP m a parenWrapped parser = try $ do@@ -646,20 +665,19 @@ dimenarg = try $ do   optional sp   ch  <- option False $ True <$ symbol '='+  minus <- option "" $ "-" <$ symbol '-'   Tok _ _ s1 <- satisfyTok isWordTok   s2 <- option "" $ try $ do           symbol '.'           Tok _ _ t <-  satisfyTok isWordTok           return ("." <> t)   let s = s1 <> s2-  guard $ T.takeEnd 2 s `elem`-           ["pt","pc","in","bp","cm","mm","dd","cc","sp"]-  let num = T.dropEnd 2 s+  let (num, rest) = T.span (\c -> isDigit c || c == '.') s   guard $ T.length num > 0-  guard $ T.all (\c -> isDigit c || c == '.') num-  return $ T.pack ['=' | ch] <> s+  guard $ rest `elem` ["", "pt","pc","in","bp","cm","mm","dd","cc","sp"]+  return $ T.pack ['=' | ch] <> minus <> s -ignore :: (Monoid a, PandocMonad m) => String -> ParserT s u m a+ignore :: (Monoid a, PandocMonad m) => Text -> ParserT s u m a ignore raw = do   pos <- getPosition   report $ SkippedContent raw pos@@ -669,6 +687,7 @@ withRaw parser = do   inp <- getInput   result <- parser-  nxt <- option (Tok (initialPos "source") Word "") (lookAhead anyTok)-  let raw = takeWhile (/= nxt) inp+  nxtpos <- option Nothing ((\(Tok pos' _ _) -> Just pos') <$> lookAhead anyTok)+  let raw = takeWhile (\(Tok pos _ _) -> maybe True+                  (\p -> sourceName p /= sourceName pos || pos < p) nxtpos) inp   return (result, raw)
src/Text/Pandoc/Readers/Man.hs view
@@ -1,4 +1,6 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE ViewPatterns      #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Man    Copyright   : Copyright (C) 2018-2019 Yan Pashkovsky and John MacFarlane@@ -63,7 +65,7 @@         -> [RoffToken]                       -- ^ input         -> m (Either PandocError a) readWithMTokens parser state input =-  let leftF = PandocParsecError . intercalate "\n" $ show <$> input+  let leftF = PandocParsecError . T.pack . intercalate "\n" $ show <$> input   in mapLeft leftF `liftM` runParserT parser state "source" input  parseMan :: PandocMonad m => ManParser m Pandoc@@ -131,7 +133,7 @@       Left _  -> do         res' <- lift $ readWithMTokens blockstcell st ts'         case res' of-          Left _  -> fail "Could not parse table cell"+          Left _  -> Prelude.fail "Could not parse table cell"           Right x -> do             modifyState $ \s -> s{ tableCellsPlain = False }             return x@@ -141,7 +143,7 @@   isHrule ([cellfmt], _) = columnType cellfmt `elem` ['_','-','=']   isHrule (_, [RoffTokens ss]) =     case Foldable.toList ss of-      [TextLine [RoffStr [c]]] -> c `elem` ['_','-','=']+      [TextLine [RoffStr (T.unpack -> [c])]] -> c `elem` ['_','-','=']       _                     -> False   isHrule _ = False @@ -191,7 +193,7 @@   isEmptyLine EmptyLine = True   isEmptyLine _ = False -mmacro :: PandocMonad m => String -> ManParser m RoffToken+mmacro :: PandocMonad m => T.Text -> ManParser m RoffToken mmacro mk = msatisfy isControlLine where   isControlLine (ControlLine mk' _ _) | mk == mk' = True                             | otherwise = False@@ -284,7 +286,7 @@     _ -> mzero  handleInlineMacro :: PandocMonad m-                  => String -> [Arg] -> SourcePos -> ManParser m Inlines+                  => T.Text -> [Arg] -> SourcePos -> ManParser m Inlines handleInlineMacro mname args _pos = do   case mname of     "UR" -> parseLink args@@ -323,8 +325,7 @@ parseItalic args = return $   emph $ mconcat $ intersperse B.space $ map linePartsToInlines args -parseAlternatingFonts :: PandocMonad m-                      => [Inlines -> Inlines]+parseAlternatingFonts :: [Inlines -> Inlines]                       -> [Arg]                       -> ManParser m Inlines parseAlternatingFonts constructors args = return $ mconcat $@@ -340,7 +341,7 @@   isBareIP (ControlLine "IP" [] _) = True   isBareIP _                  = False -endmacro :: PandocMonad m => String -> ManParser m ()+endmacro :: PandocMonad m => T.Text -> ManParser m () endmacro name = void (mmacro name)              <|> lookAhead (void newBlockMacro)              <|> lookAhead eof@@ -357,7 +358,7 @@   toks <- (mmacro "nf" *> manyTill codeline (endmacro "fi"))       <|> (mmacro "EX" *> manyTill codeline (endmacro "EE"))   optional (mmacro "in")-  return $ codeBlock (intercalate "\n" $ catMaybes toks)+  return $ codeBlock (T.intercalate "\n" $ catMaybes toks)    where @@ -367,7 +368,7 @@       ControlLine "PP" _ _ -> return $ Just "" -- .PP sometimes used for blank line       ControlLine mname args pos -> do         (Just . query getText <$> handleInlineMacro mname args pos) <|>-          do report $ SkippedContent ('.':mname) pos+          do report $ SkippedContent ("." <> mname) pos              return Nothing       Tbl _ _ pos     -> do         report $ SkippedContent "TABLE" pos@@ -376,12 +377,12 @@       TextLine ss         | not (null ss)         , all isFontToken ss -> return Nothing-        | otherwise -> return $ Just $ linePartsToString ss+        | otherwise -> return $ Just $ linePartsToText ss    isFontToken Font{}     = True   isFontToken _            = False -  getText :: Inline -> String+  getText :: Inline -> T.Text   getText (Str s)    = s   getText Space      = " "   getText (Code _ s) = s@@ -417,8 +418,8 @@   (ControlLine _ args _) <- mmacro "IP"   case args of     (arg1 : _)  -> do-      let cs = linePartsToString arg1-      let cs' = if not ('.' `elem` cs || ')' `elem` cs) then cs ++ "." else cs+      let cs = linePartsToText arg1+      let cs' = if not (T.any (== '.') cs || T.any (== ')') cs) then cs <> "." else cs       let lt = case Parsec.runParser anyOrderedListMarker defaultParserState                      "list marker" cs' of                   Right (start, listtype, listdelim)@@ -468,7 +469,7 @@   ControlLine _ endargs _ <- mmacro "UE"   let url = case args of               [] -> ""-              (x:_) -> linePartsToString x+              (x:_) -> linePartsToText x   return $ link url "" contents <>     case endargs of       []    -> mempty@@ -480,7 +481,7 @@   ControlLine _ endargs _ <- mmacro "ME"   let url = case args of               [] -> ""-              (x:_) -> "mailto:" ++ linePartsToString x+              (x:_) -> "mailto:" <> linePartsToText x   return $ link url "" contents <>     case endargs of       []    -> mempty@@ -491,6 +492,6 @@   tok <- mmacroAny   case tok of     ControlLine mkind _ pos -> do-      report $ SkippedContent ('.':mkind) pos+      report $ SkippedContent ("." <> mkind) pos       return mempty-    _                 -> fail "the impossible happened"+    _                 -> Prelude.fail "the impossible happened"
src/Text/Pandoc/Readers/Markdown.hs view
@@ -1,7 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE RelaxedPolyRec      #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE TupleSections       #-}+{-# LANGUAGE OverloadedStrings   #-}+{-# LANGUAGE ViewPatterns        #-} {- |    Module      : Text.Pandoc.Readers.Markdown    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -19,15 +21,17 @@ import Control.Monad import Control.Monad.Except (throwError) import qualified Data.ByteString.Lazy as BS-import Data.Char (isAlphaNum, isPunctuation, isSpace, toLower)-import Data.List (intercalate, sortBy, transpose, elemIndex)+import Data.Char (isAlphaNum, isPunctuation, isSpace)+import Data.List (sortBy, transpose, elemIndex) import qualified Data.Map as M import Data.Maybe import Data.Ord (comparing) import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T+import qualified Data.Text.Lazy as TL import qualified Data.YAML as YAML+import qualified Data.YAML.Event as YE import System.FilePath (addExtension, takeExtension) import Text.HTML.TagSoup import Text.Pandoc.Builder (Blocks, Inlines)@@ -46,7 +50,7 @@ import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.XML (fromEntities) -type MarkdownParser m = ParserT [Char] ParserState m+type MarkdownParser m = ParserT Text ParserState m  -- | Read markdown from an input string and return a Pandoc document. readMarkdown :: PandocMonad m@@ -55,7 +59,7 @@              -> m Pandoc readMarkdown opts s = do   parsed <- readWithM parseMarkdown def{ stateOptions = opts }-               (T.unpack (crFilter s) ++ "\n\n")+               (crFilter s <> "\n\n")   case parsed of     Right result -> return result     Left e       -> throwError e@@ -76,7 +80,7 @@ isHruleChar '_' = True isHruleChar _   = False -setextHChars :: String+setextHChars :: [Char] setextHChars = "=-"  isBlank :: Char -> Bool@@ -95,30 +99,30 @@   ctx <- stateParserContext <$> getState   guard (ctx == ListItemState) -spnl :: PandocMonad m => ParserT [Char] st m ()+spnl :: PandocMonad m => ParserT Text st m () spnl = try $ do   skipSpaces   optional newline   skipSpaces   notFollowedBy (char '\n') -spnl' :: PandocMonad m => ParserT [Char] st m String+spnl' :: PandocMonad m => ParserT Text st m Text spnl' = try $ do   xs <- many spaceChar   ys <- option "" $ try $ (:) <$> newline                               <*> (many spaceChar <* notFollowedBy (char '\n'))-  return (xs ++ ys)+  return $ T.pack $ xs ++ ys -indentSpaces :: PandocMonad m => MarkdownParser m String+indentSpaces :: PandocMonad m => MarkdownParser m Text indentSpaces = try $ do   tabStop <- getOption readerTabStop-  count tabStop (char ' ') <|>-    string "\t" <?> "indentation"+  countChar tabStop (char ' ') <|>+    textStr "\t" <?> "indentation" -nonindentSpaces :: PandocMonad m => MarkdownParser m String+nonindentSpaces :: PandocMonad m => MarkdownParser m Text nonindentSpaces = do   n <- skipNonindentSpaces-  return $ replicate n ' '+  return $ T.replicate n " "  -- returns number of spaces parsed skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int@@ -138,8 +142,9 @@ inlinesInBalancedBrackets =   try $ char '[' >> withRaw (go 1) >>=           parseFromString inlines . stripBracket . snd-  where stripBracket [] = []-        stripBracket xs = if last xs == ']' then init xs else xs+  where stripBracket t = case T.unsnoc t of+          Just (t', ']') -> t'+          _              -> t         go :: PandocMonad m => Int -> MarkdownParser m ()         go 0 = return ()         go openBrackets =@@ -159,7 +164,7 @@ -- document structure -- -rawTitleBlockLine :: PandocMonad m => MarkdownParser m String+rawTitleBlockLine :: PandocMonad m => MarkdownParser m Text rawTitleBlockLine = do   char '%'   skipSpaces@@ -168,7 +173,7 @@                           notFollowedBy blankline                           skipSpaces                           anyLine-  return $ trim $ unlines (first:rest)+  return $ trim $ T.unlines (first:rest)  titleLine :: PandocMonad m => MarkdownParser m (F Inlines) titleLine = try $ do@@ -221,9 +226,9 @@   notFollowedBy blankline  -- if --- is followed by a blank it's an HRULE   rawYamlLines <- manyTill anyLine stopLine   -- by including --- and ..., we allow yaml blocks with just comments:-  let rawYaml = unlines ("---" : (rawYamlLines ++ ["..."]))+  let rawYaml = T.unlines ("---" : (rawYamlLines ++ ["..."]))   optional blanklines-  newMetaF <- yamlBsToMeta $ UTF8.fromStringLazy rawYaml+  newMetaF <- yamlBsToMeta $ UTF8.fromTextLazy $ TL.fromStrict rawYaml   -- Since `<>` is left-biased, existing values are not touched:   updateState $ \st -> st{ stateMeta' = (stateMeta' st) <> newMetaF }   return mempty@@ -244,23 +249,24 @@ yamlBsToMeta bstr = do   pos <- getPosition   case YAML.decodeNode' YAML.failsafeSchemaResolver False False bstr of-       Right ((YAML.Doc (YAML.Mapping _ o)):_) -> (fmap Meta) <$> yamlMap o+       Right ((YAML.Doc (YAML.Mapping _ _ o)):_) -> (fmap Meta) <$> yamlMap o        Right [] -> return . return $ mempty-       Right [YAML.Doc (YAML.Scalar YAML.SNull)] -> return . return $ mempty+       Right [YAML.Doc (YAML.Scalar _ YAML.SNull)] -> return . return $ mempty        Right _ -> do                   logMessage $                      CouldNotParseYamlMetadata "not an object"                      pos                   return . return $ mempty-       Left err' -> do+       Left (_pos, err') -> do                     logMessage $ CouldNotParseYamlMetadata-                                 err' pos+                                 (T.pack err') pos                     return . return $ mempty -nodeToKey :: Monad m => YAML.Node -> m Text-nodeToKey (YAML.Scalar (YAML.SStr t))       = return t-nodeToKey (YAML.Scalar (YAML.SUnknown _ t)) = return t-nodeToKey _                                 = fail "Non-string key in YAML mapping"+nodeToKey :: PandocMonad m => YAML.Node YE.Pos -> m Text+nodeToKey (YAML.Scalar _ (YAML.SStr t))       = return t+nodeToKey (YAML.Scalar _ (YAML.SUnknown _ t)) = return t+nodeToKey _  = throwError $ PandocParseError+                              "Non-string key in YAML mapping"  toMetaValue :: PandocMonad m             => Text -> MarkdownParser m (F MetaValue)@@ -268,11 +274,11 @@    -- Note: a standard quoted or unquoted YAML value will    -- not end in a newline, but a "block" set off with    -- `|` or `>` will.-   if (T.pack "\n") `T.isSuffixOf` x-      then parseFromString' (asBlocks <$> parseBlocks) (xstring <> "\n")+   if "\n" `T.isSuffixOf` x+      then parseFromString' (asBlocks <$> parseBlocks) (x <> "\n")       else parseFromString'              ((asInlines <$> try pInlines) <|> (asBlocks <$> parseBlocks))-             xstring+             x   where pInlines = trimInlinesF . mconcat <$> manyTill inline eof         asBlocks p = do           p' <- p@@ -280,7 +286,6 @@         asInlines p = do           p' <- p           return $ MetaInlines (B.toList p')-        xstring = T.unpack x  checkBoolean :: Text -> Maybe Bool checkBoolean t =@@ -291,29 +296,29 @@              else Nothing  yamlToMetaValue :: PandocMonad m-                => YAML.Node -> MarkdownParser m (F MetaValue)-yamlToMetaValue (YAML.Scalar x) =+                => YAML.Node YE.Pos-> MarkdownParser m (F MetaValue)+yamlToMetaValue (YAML.Scalar _ x) =   case x of        YAML.SStr t       -> toMetaValue t        YAML.SBool b      -> return $ return $ MetaBool b-       YAML.SFloat d     -> return $ return $ MetaString (show d)-       YAML.SInt i       -> return $ return $ MetaString (show i)+       YAML.SFloat d     -> return $ return $ MetaString $ tshow d+       YAML.SInt i       -> return $ return $ MetaString $ tshow i        YAML.SUnknown _ t ->          case checkBoolean t of            Just b        -> return $ return $ MetaBool b            Nothing       -> toMetaValue t        YAML.SNull        -> return $ return $ MetaString ""-yamlToMetaValue (YAML.Sequence _ xs) = do+yamlToMetaValue (YAML.Sequence _ _ xs) = do   xs' <- mapM yamlToMetaValue xs   return $ do     xs'' <- sequence xs'     return $ B.toMetaValue xs''-yamlToMetaValue (YAML.Mapping _ o) = fmap B.toMetaValue <$> yamlMap o+yamlToMetaValue (YAML.Mapping _ _ o) = fmap B.toMetaValue <$> yamlMap o yamlToMetaValue _ = return $ return $ MetaString ""  yamlMap :: PandocMonad m-        => M.Map YAML.Node YAML.Node-        -> MarkdownParser m (F (M.Map String MetaValue))+        => M.Map (YAML.Node YE.Pos) (YAML.Node YE.Pos)+        -> MarkdownParser m (F (M.Map Text MetaValue)) yamlMap o = do     kvs <- forM (M.toList o) $ \(key, v) -> do              k <- nodeToKey key@@ -321,12 +326,12 @@     let kvs' = filter (not . ignorable . fst) kvs     (fmap M.fromList . sequence) <$> mapM toMeta kvs'   where-    ignorable t = (T.pack "_") `T.isSuffixOf` t+    ignorable t = "_" `T.isSuffixOf` t     toMeta (k, v) = do       fv <- yamlToMetaValue v       return $ do         v' <- fv-        return (T.unpack k, v')+        return (k, v')  stopLine :: PandocMonad m => MarkdownParser m () stopLine = try $ (string "---" <|> string "...") >> blankline >> return ()@@ -341,14 +346,14 @@   updateState $ \st -> st{ stateMeta' = stateMeta' st <>                              return (Meta $ M.fromList kvPairs) } -kvPair :: PandocMonad m => Bool -> MarkdownParser m (String, MetaValue)+kvPair :: PandocMonad m => Bool -> MarkdownParser m (Text, MetaValue) kvPair allowEmpty = try $ do-  key <- many1Till (alphaNum <|> oneOf "_- ") (char ':')-  val <- trim <$> manyTill anyChar+  key <- many1TillChar (alphaNum <|> oneOf "_- ") (char ':')+  val <- trim <$> manyTillChar anyChar           (try $ newline >> lookAhead (blankline <|> nonspaceChar))-  guard $ allowEmpty || not (null val)-  let key' = concat $ words $ map toLower key-  let val' = MetaBlocks $ B.toList $ B.plain $B.text val+  guard $ allowEmpty || not (T.null val)+  let key' = T.concat $ T.words $ T.toLower key+  let val' = MetaBlocks $ B.toList $ B.plain $ B.text val   return (key',val')  parseMarkdown :: PandocMonad m => MarkdownParser m Pandoc@@ -378,13 +383,13 @@   (_,raw) <- reference   char ':'   skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')-  let sourceURL = fmap unwords $ many $ try $ do+  let sourceURL = fmap T.unwords $ many $ try $ do                     skipMany spaceChar                     notFollowedBy' referenceTitle                     notFollowedBy' $ guardEnabled Ext_link_attributes >> attributes                     notFollowedBy' (() <$ reference)-                    many1 $ notFollowedBy space >> litChar-  let betweenAngles = try $ char '<' >> manyTill litChar (char '>')+                    many1Char $ notFollowedBy space >> litChar+  let betweenAngles = try $ char '<' >> manyTillChar litChar (char '>')   src <- try betweenAngles <|> sourceURL   tit <- option "" referenceTitle   attr   <- option nullAttr $ try $@@ -409,20 +414,20 @@   updateState $ \s -> s { stateKeys = M.insert key (target, attr') oldkeys }   return $ return mempty -referenceTitle :: PandocMonad m => MarkdownParser m String+referenceTitle :: PandocMonad m => MarkdownParser m Text referenceTitle = try $ do   skipSpaces >> optional newline >> skipSpaces   quotedTitle '"' <|> quotedTitle '\'' <|> charsInBalanced '(' ')' litChar  -- A link title in quotes-quotedTitle :: PandocMonad m => Char -> MarkdownParser m String+quotedTitle :: PandocMonad m => Char -> MarkdownParser m Text quotedTitle c = try $ do   char c   notFollowedBy spaces   let pEnder = try $ char c >> notFollowedBy (satisfy isAlphaNum)-  let regChunk = many1 (noneOf ['\\','\n','&',c]) <|> count 1 litChar-  let nestedChunk = (\x -> [c] ++ x ++ [c]) <$> quotedTitle c-  unwords . words . concat <$> manyTill (nestedChunk <|> regChunk) pEnder+  let regChunk = many1Char (noneOf ['\\','\n','&',c]) <|> countChar 1 litChar+  let nestedChunk = (\x -> T.singleton c <> x <> T.singleton c) <$> quotedTitle c+  T.unwords . T.words . T.concat <$> manyTill (nestedChunk <|> regChunk) pEnder  -- | PHP Markdown Extra style abbreviation key.  Currently -- we just skip them, since Pandoc doesn't have an element for@@ -438,41 +443,44 @@     blanklines     return $ return mempty -noteMarker :: PandocMonad m => MarkdownParser m String-noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')+noteMarker :: PandocMonad m => MarkdownParser m Text+noteMarker = string "[^" >> many1TillChar (satisfy $ not . isBlank) (char ']') -rawLine :: PandocMonad m => MarkdownParser m String+rawLine :: PandocMonad m => MarkdownParser m Text rawLine = try $ do   notFollowedBy blankline   notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker   optional indentSpaces   anyLine -rawLines :: PandocMonad m => MarkdownParser m String+rawLines :: PandocMonad m => MarkdownParser m Text rawLines = do   first <- anyLine   rest <- many rawLine-  return $ unlines (first:rest)+  return $ T.unlines (first:rest)  noteBlock :: PandocMonad m => MarkdownParser m (F Blocks)-noteBlock = try $ do-  pos <- getPosition-  skipNonindentSpaces-  ref <- noteMarker-  char ':'-  optional blankline-  optional indentSpaces-  first <- rawLines-  rest <- many $ try $ blanklines >> indentSpaces >> rawLines-  let raw = unlines (first:rest) ++ "\n"-  optional blanklines-  parsed <- parseFromString' parseBlocks raw-  oldnotes <- stateNotes' <$> getState-  case M.lookup ref oldnotes of-    Just _  -> logMessage $ DuplicateNoteReference ref pos-    Nothing -> return ()-  updateState $ \s -> s { stateNotes' = M.insert ref (pos, parsed) oldnotes }-  return mempty+noteBlock = do+  guardEnabled Ext_footnotes+  try $ do+     pos <- getPosition+     skipNonindentSpaces+     ref <- noteMarker+     char ':'+     optional blankline+     optional indentSpaces+     first <- rawLines+     rest <- many $ try $ blanklines >> indentSpaces >> rawLines+     let raw = T.unlines (first:rest) <> "\n"+     optional blanklines+     parsed <- parseFromString' parseBlocks raw+     oldnotes <- stateNotes' <$> getState+     case M.lookup ref oldnotes of+       Just _  -> logMessage $ DuplicateNoteReference ref pos+       Nothing -> return ()+     updateState $ \s -> s { stateNotes' =+       M.insert ref (pos, parsed) oldnotes }+     return mempty  -- -- parsing blocks@@ -508,7 +516,7 @@                , para                , plain                ] <?> "block"-  trace (take 60 $ show $ B.toList $ runF res defaultParserState)+  trace (T.take 60 $ tshow $ B.toList $ runF res defaultParserState)   return res  --@@ -532,8 +540,13 @@                   (char '.' <|> char ')') -- this would be a list   guardDisabled Ext_space_in_atx_header <|> notFollowedBy nonspaceChar   skipSpaces-  (text, raw) <- withRaw $-          trimInlinesF . mconcat <$> many (notFollowedBy atxClosing >> inline)+  (text, raw) <- withRaw $ do+    oldAllowLineBreaks <- stateAllowLineBreaks <$> getState+    updateState $ \st -> st{ stateAllowLineBreaks = False }+    res <- trimInlinesF . mconcat <$>+               many (notFollowedBy atxClosing >> inline)+    updateState $ \st -> st{ stateAllowLineBreaks = oldAllowLineBreaks }+    return res   attr <- atxClosing   attr' <- registerHeader attr (runF text defaultParserState)   guardDisabled Ext_implicit_header_references@@ -563,7 +576,7 @@ mmdHeaderIdentifier = do   (_, raw) <- reference   let raw' = trim $ stripFirstAndLast raw-  let ident = concat $ words $ map toLower raw'+  let ident = T.concat $ T.words $ T.toLower raw'   let attr = (ident, [], [])   guardDisabled Ext_implicit_header_references     <|> registerImplicitHeader raw' attr@@ -576,8 +589,13 @@   -- unless necessary -- it gives a significant performance boost.   lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline   skipSpaces-  (text, raw) <- withRaw $-       trimInlinesF . mconcat <$> many1 (notFollowedBy setextHeaderEnd >> inline)+  (text, raw) <- withRaw $ do+    oldAllowLineBreaks <- stateAllowLineBreaks <$> getState+    updateState $ \st -> st{ stateAllowLineBreaks = False }+    res <- trimInlinesF . mconcat <$>+               many (notFollowedBy setextHeaderEnd >> inline)+    updateState $ \st -> st{ stateAllowLineBreaks = oldAllowLineBreaks }+    return res   attr <- setextHeaderEnd   underlineChar <- oneOf setextHChars   many (char underlineChar)@@ -588,20 +606,20 @@     <|> registerImplicitHeader raw attr'   return $ B.headerWith attr' level <$> text -registerImplicitHeader :: PandocMonad m => String -> Attr -> MarkdownParser m ()+registerImplicitHeader :: PandocMonad m => Text -> Attr -> MarkdownParser m () registerImplicitHeader raw attr@(ident, _, _)-  | null raw  = return ()+  | T.null raw = return ()   | otherwise = do-      let key = toKey $ "[" ++ raw ++ "]"+      let key = toKey $ "[" <> raw <> "]"       updateState $ \s ->-        s { stateHeaderKeys = M.insert key (('#':ident,""), attr)+        s { stateHeaderKeys = M.insert key (("#" <> ident,""), attr)                                      (stateHeaderKeys s) }  -- -- hrule block -- -hrule :: PandocMonad m => ParserT [Char] st m (F Blocks)+hrule :: PandocMonad m => ParserT Text st m (F Blocks) hrule = try $ do   skipSpaces   start <- satisfy isHruleChar@@ -615,13 +633,13 @@ -- code blocks -- -indentedLine :: PandocMonad m => MarkdownParser m String+indentedLine :: PandocMonad m => MarkdownParser m Text indentedLine = indentSpaces >> anyLineNewline  blockDelimiter :: PandocMonad m                => (Char -> Bool)                -> Maybe Int-               -> ParserT [Char] ParserState m Int+               -> ParserT Text ParserState m Int blockDelimiter f len = try $ do   skipNonindentSpaces   c <- lookAhead (satisfy f)@@ -640,11 +658,11 @@ attribute :: PandocMonad m => MarkdownParser m (Attr -> Attr) attribute = identifierAttr <|> classAttr <|> keyValAttr <|> specialAttr -identifier :: PandocMonad m => MarkdownParser m String+identifier :: PandocMonad m => MarkdownParser m Text identifier = do   first <- letter   rest <- many $ alphaNum <|> oneOf "-_:."-  return (first:rest)+  return $ T.pack (first:rest)  identifierAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr) identifierAttr = try $ do@@ -662,15 +680,15 @@ keyValAttr = try $ do   key <- identifier   char '='-  val <- enclosed (char '"') (char '"') litChar-     <|> enclosed (char '\'') (char '\'') litChar+  val <- T.pack <$> enclosed (char '"') (char '"') litChar+     <|> T.pack <$> enclosed (char '\'') (char '\'') litChar      <|> ("" <$ try (string "\"\""))      <|> ("" <$ try (string "''"))-     <|> many (escapedChar' <|> noneOf " \t\n\r}")+     <|> manyChar (escapedChar' <|> noneOf " \t\n\r}")   return $ \(id',cs,kvs) ->     case key of          "id"    -> (val,cs,kvs)-         "class" -> (id',cs ++ words val,kvs)+         "class" -> (id',cs ++ T.words val,kvs)          _       -> (id',cs,kvs ++ [(key,val)])  specialAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)@@ -678,12 +696,12 @@   char '-'   return $ \(id',cs,kvs) -> (id',cs ++ ["unnumbered"],kvs) -rawAttribute :: PandocMonad m => MarkdownParser m String+rawAttribute :: PandocMonad m => MarkdownParser m Text rawAttribute = do   char '{'   skipMany spaceChar   char '='-  format <- many1 $ satisfy (\c -> isAlphaNum c || c `elem` "-_")+  format <- many1Char $ satisfy (\c -> isAlphaNum c || c `elem` ['-', '_'])    skipMany spaceChar   char '}'   return format@@ -691,7 +709,7 @@ codeBlockFenced :: PandocMonad m => MarkdownParser m (F Blocks) codeBlockFenced = try $ do   indentchars <- nonindentSpaces-  let indentLevel = length indentchars+  let indentLevel = T.length indentchars   c <- try (guardEnabled Ext_fenced_code_blocks >> lookAhead (char '~'))      <|> (guardEnabled Ext_backtick_code_blocks >> lookAhead (char '`'))   size <- blockDelimiter (== c) Nothing@@ -701,9 +719,9 @@     <|>      (Right <$> option ("",[],[])          (try (guardEnabled Ext_fenced_code_attributes >> attributes)-          <|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar)))+          <|> ((\x -> ("",[toLanguageId x],[])) <$> many1Char nonspaceChar)))   blankline-  contents <- intercalate "\n" <$>+  contents <- T.intercalate "\n" <$>                  manyTill (gobbleAtMostSpaces indentLevel >> anyLine)                           (try $ do                             blockDelimiter (== c) (Just size)@@ -714,8 +732,8 @@           Right attr -> B.codeBlockWith attr contents  -- correctly handle github language identifiers-toLanguageId :: String -> String-toLanguageId = map toLower . go+toLanguageId :: Text -> Text+toLanguageId = T.toLower . go   where go "c++"         = "cpp"         go "objective-c" = "objectivec"         go x             = x@@ -725,11 +743,11 @@   contents <- many1 (indentedLine <|>                      try (do b <- blanklines                              l <- indentedLine-                             return $ b ++ l))+                             return $ b <> l))   optional blanklines   classes <- getOption readerIndentedCodeClasses   return $ return $ B.codeBlockWith ("", classes, []) $-           stripTrailingNewlines $ concat contents+           stripTrailingNewlines $ T.concat contents  lhsCodeBlock :: PandocMonad m => MarkdownParser m (F Blocks) lhsCodeBlock = do@@ -739,33 +757,33 @@     <|> (return . B.codeBlockWith ("",["haskell"],[]) <$>           lhsCodeBlockInverseBird) -lhsCodeBlockLaTeX :: PandocMonad m => MarkdownParser m String+lhsCodeBlockLaTeX :: PandocMonad m => MarkdownParser m Text lhsCodeBlockLaTeX = try $ do   string "\\begin{code}"   manyTill spaceChar newline-  contents <- many1Till anyChar (try $ string "\\end{code}")+  contents <- many1TillChar anyChar (try $ string "\\end{code}")   blanklines   return $ stripTrailingNewlines contents -lhsCodeBlockBird :: PandocMonad m => MarkdownParser m String+lhsCodeBlockBird :: PandocMonad m => MarkdownParser m Text lhsCodeBlockBird = lhsCodeBlockBirdWith '>' -lhsCodeBlockInverseBird :: PandocMonad m => MarkdownParser m String+lhsCodeBlockInverseBird :: PandocMonad m => MarkdownParser m Text lhsCodeBlockInverseBird = lhsCodeBlockBirdWith '<' -lhsCodeBlockBirdWith :: PandocMonad m => Char -> MarkdownParser m String+lhsCodeBlockBirdWith :: PandocMonad m => Char -> MarkdownParser m Text lhsCodeBlockBirdWith c = try $ do   pos <- getPosition-  when (sourceColumn pos /= 1) $ fail "Not in first column"+  when (sourceColumn pos /= 1) $ Prelude.fail "Not in first column"   lns <- many1 $ birdTrackLine c   -- if (as is normal) there is always a space after >, drop it-  let lns' = if all (\ln -> null ln || take 1 ln == " ") lns-                then map (drop 1) lns+  let lns' = if all (\ln -> T.null ln || T.take 1 ln == " ") lns+                then map (T.drop 1) lns                 else lns   blanklines-  return $ intercalate "\n" lns'+  return $ T.intercalate "\n" lns' -birdTrackLine :: PandocMonad m => Char -> ParserT [Char] st m String+birdTrackLine :: PandocMonad m => Char -> ParserT Text st m Text birdTrackLine c = try $ do   char c   -- allow html tags on left margin:@@ -779,12 +797,12 @@ emailBlockQuoteStart :: PandocMonad m => MarkdownParser m Char emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' <* optional (char ' ') -emailBlockQuote :: PandocMonad m => MarkdownParser m [String]+emailBlockQuote :: PandocMonad m => MarkdownParser m [Text] emailBlockQuote = try $ do   emailBlockQuoteStart-  let emailLine = many $ nonEndline <|> try-                         (endline >> notFollowedBy emailBlockQuoteStart >>-                         return '\n')+  let emailLine = manyChar $ nonEndline <|> try+                              (endline >> notFollowedBy emailBlockQuoteStart >>+                               return '\n')   let emailSep = try (newline >> emailBlockQuoteStart)   first <- emailLine   rest <- many $ try $ emailSep >> emailLine@@ -797,7 +815,7 @@ blockQuote = do   raw <- emailBlockQuote   -- parse the extracted block, which may contain various block elements:-  contents <- parseFromString' parseBlocks $ intercalate "\n" raw ++ "\n\n"+  contents <- parseFromString' parseBlocks $ T.intercalate "\n" raw <> "\n\n"   return $ B.blockQuote <$> contents  --@@ -821,7 +839,7 @@   skipNonindentSpaces   notFollowedBy $ string "p." >> spaceChar >> digit  -- page number   (do guardDisabled Ext_fancy_lists-      start <- many1 digit >>= safeRead+      start <- many1Char digit >>= safeRead       char '.'       gobbleSpaces 1 <|> () <$ lookAhead newline       optional $ try (gobbleAtMostSpaces 3 >> notFollowedBy spaceChar)@@ -845,7 +863,7 @@ listStart :: PandocMonad m => MarkdownParser m () listStart = bulletListStart <|> Control.Monad.void (orderedListStart Nothing) -listLine :: PandocMonad m => Int -> MarkdownParser m String+listLine :: PandocMonad m => Int -> MarkdownParser m Text listLine continuationIndent = try $ do   notFollowedBy' (do gobbleSpaces continuationIndent                      skipMany spaceChar@@ -855,18 +873,19 @@   optional (() <$ gobbleSpaces continuationIndent)   listLineCommon -listLineCommon :: PandocMonad m => MarkdownParser m String-listLineCommon = concat <$> manyTill-              (  many1 (satisfy $ \c -> c /= '\n' && c /= '<')+listLineCommon :: PandocMonad m => MarkdownParser m Text+listLineCommon = T.concat <$> manyTill+              (  many1Char (satisfy $ \c -> c `notElem` ['\n', '<', '`'])+             <|> fmap snd (withRaw code)              <|> fmap snd (htmlTag isCommentTag)-             <|> count 1 anyChar+             <|> countChar 1 anyChar               ) newline  -- parse raw text for one list item, excluding start marker and continuations rawListItem :: PandocMonad m             => Bool -- four space rule             -> MarkdownParser m a-            -> MarkdownParser m (String, Int)+            -> MarkdownParser m (Text, Int) rawListItem fourSpaceRule start = try $ do   pos1 <- getPosition   start@@ -879,14 +898,14 @@                    notFollowedBy (() <$ codeBlockFenced)                    notFollowedBy blankline                    listLine continuationIndent)-  blanks <- many blankline-  let result = unlines (first:rest) ++ blanks+  blanks <- manyChar blankline+  let result = T.unlines (first:rest) <> blanks   return (result, continuationIndent)  -- continuation of a list item - indented and separated by blankline -- or (in compact lists) endline. -- note: nested lists are parsed as continuations-listContinuation :: PandocMonad m => Int -> MarkdownParser m String+listContinuation :: PandocMonad m => Int -> MarkdownParser m Text listContinuation continuationIndent = try $ do   x <- try $ do          notFollowedBy blankline@@ -900,12 +919,12 @@          notFollowedByDivCloser          gobbleSpaces continuationIndent <|> notFollowedBy' listStart          anyLineNewline-  blanks <- many blankline-  return $ concat (x:xs) ++ blanks+  blanks <- manyChar blankline+  return $ T.concat (x:xs) <> blanks  -- Variant of blanklines that doesn't require blank lines -- before a fence or eof.-blanklines' :: PandocMonad m => MarkdownParser m [Char]+blanklines' :: PandocMonad m => MarkdownParser m Text blanklines' = blanklines <|> try checkDivCloser   where checkDivCloser = do           guardEnabled Ext_fenced_divs@@ -932,16 +951,16 @@          -> MarkdownParser m a          -> MarkdownParser m (F Blocks) listItem fourSpaceRule start = try $ do-  (first, continuationIndent) <- rawListItem fourSpaceRule start-  continuations <- many (listContinuation continuationIndent)   -- parsing with ListItemState forces markers at beginning of lines to   -- count as list item markers, even if not separated by blank space.   -- see definition of "endline"   state <- getState   let oldContext = stateParserContext state   setState $ state {stateParserContext = ListItemState}+  (first, continuationIndent) <- rawListItem fourSpaceRule start+  continuations <- many (listContinuation continuationIndent)   -- parse the extracted block, which may contain various block elements:-  let raw = concat (first:continuations)+  let raw = T.concat (first:continuations)   contents <- parseFromString' parseBlocks raw   updateState (\st -> st {stateParserContext = oldContext})   exts <- getOption readerExtensions@@ -977,7 +996,7 @@   sps <- nonindentSpaces   char ':' <|> char '~'   tabStop <- getOption readerTabStop-  let remaining = tabStop - (length sps + 1)+  let remaining = tabStop - (T.length sps + 1)   if remaining > 0      then try (count remaining (char ' ')) <|> string "\t" <|> many1 spaceChar      else mzero@@ -988,11 +1007,11 @@   rawLine' <- anyLine   raw <- many1 $ defRawBlock compact   term <- parseFromString' (trimInlinesF <$> inlines) rawLine'-  contents <- mapM (parseFromString' parseBlocks . (++"\n")) raw+  contents <- mapM (parseFromString' parseBlocks . (<> "\n")) raw   optional blanklines   return $ liftM2 (,) term (sequence contents) -defRawBlock :: PandocMonad m => Bool -> MarkdownParser m String+defRawBlock :: PandocMonad m => Bool -> MarkdownParser m Text defRawBlock compact = try $ do   hasBlank <- option False $ blankline >> return True   defListMarker@@ -1007,13 +1026,13 @@                              <|> notFollowedBy defListMarker                     anyLine )   rawlines <- many dline-  cont <- fmap concat $ many $ try $ do+  cont <- fmap T.concat $ many $ try $ do             trailing <- option "" blanklines             ln <- indentSpaces >> notFollowedBy blankline >> anyLine             lns <- many dline-            return $ trailing ++ unlines (ln:lns)-  return $ trimr (firstline ++ unlines rawlines ++ cont) ++-            if hasBlank || not (null cont) then "\n\n" else ""+            return $ trailing <> T.unlines (ln:lns)+  return $ trimr (firstline <> T.unlines rawlines <> cont) <>+            if hasBlank || not (T.null cont) then "\n\n" else ""  definitionList :: PandocMonad m => MarkdownParser m (F Blocks) definitionList = try $ do@@ -1050,7 +1069,7 @@                  | not (null alt) ->                     -- the fig: at beginning of title indicates a figure                     return $ B.singleton-                           $ Image attr alt (src,'f':'i':'g':':':tit)+                           $ Image attr alt (src, "fig:" <> tit)                _ -> return x'        | otherwise = x   result <- implicitFigures . trimInlinesF <$> inlines1@@ -1069,7 +1088,7 @@                      inHtmlBlock <- stateInHtmlBlock <$> getState                      case inHtmlBlock of                           Just "div" -> () <$-                                       lookAhead (htmlTag (~== TagClose "div"))+                                       lookAhead (htmlTag (~== TagClose ("div" :: Text)))                           _          -> mzero               <|> do guardEnabled Ext_fenced_divs                      divLevel <- stateFencedDivLevel <$> getState@@ -1085,7 +1104,7 @@ -- raw html -- -htmlElement :: PandocMonad m => MarkdownParser m String+htmlElement :: PandocMonad m => MarkdownParser m Text htmlElement = rawVerbatimBlock           <|> strictHtmlBlock           <|> fmap snd (htmlTag isBlockTag)@@ -1119,14 +1138,14 @@     first <- htmlElement     skipMany spaceChar     optional blanklines-    return $ if null first+    return $ if T.null first                 then mempty                 else return $ B.rawBlock "html" first -strictHtmlBlock :: PandocMonad m => MarkdownParser m String+strictHtmlBlock :: PandocMonad m => MarkdownParser m Text strictHtmlBlock = htmlInBalanced (not . isInlineTag) -rawVerbatimBlock :: PandocMonad m => MarkdownParser m String+rawVerbatimBlock :: PandocMonad m => MarkdownParser m Text rawVerbatimBlock = htmlInBalanced isVerbTag   where isVerbTag (TagOpen "pre" _)      = True         isVerbTag (TagOpen "style" _)    = True@@ -1137,14 +1156,13 @@ rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks) rawTeXBlock = do   guardEnabled Ext_raw_tex-  lookAhead $ try $ char '\\' >> letter-  result <- (B.rawBlock "tex" . trim . concat <$>-                many1 ((++) <$> rawConTeXtEnvironment <*> spnl'))-          <|> (B.rawBlock "tex" . trim . concat <$>-                many1 ((++) <$> rawLaTeXBlock <*> spnl'))+  result <- (B.rawBlock "tex" . trim . T.concat <$>+                many1 ((<>) <$> rawConTeXtEnvironment <*> spnl'))+          <|> (B.rawBlock "tex" . trim . T.concat <$>+                many1 ((<>) <$> rawLaTeXBlock <*> spnl'))   return $ case B.toList result of                 [RawBlock _ cs]-                  | all (`elem` [' ','\t','\n']) cs -> return mempty+                  | T.all (`elem` [' ','\t','\n']) cs -> return mempty                 -- don't create a raw block for suppressed macro defs                 _ -> return result @@ -1174,7 +1192,7 @@   return result  -- remove markdown="1" attribute-stripMarkdownAttribute :: String -> String+stripMarkdownAttribute :: Text -> Text stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s   where filterAttrib (TagOpen t as) = TagOpen t                                         [(k,v) | (k,v) <- as, k /= "markdown"]@@ -1199,7 +1217,7 @@ -- and the length including trailing space. dashedLine :: PandocMonad m            => Char-           -> ParserT [Char] st m (Int, Int)+           -> ParserT Text st m (Int, Int) dashedLine ch = do   dashes <- many1 (char ch)   sp     <- many spaceChar@@ -1220,9 +1238,9 @@   dashes      <- many1 (dashedLine '-')   newline   let (lengths, lines') = unzip dashes-  let indices  = scanl (+) (length initSp) lines'+  let indices  = scanl (+) (T.length initSp) lines'   -- If no header, calculate alignment on basis of first row of text-  rawHeads <- fmap (tail . splitStringByIndices (init indices)) $+  rawHeads <- fmap (tail . splitTextByIndices (init indices)) $               if headless                  then lookAhead anyLine                  else return rawContent@@ -1238,15 +1256,15 @@ -- Returns an alignment type for a table, based on a list of strings -- (the rows of the column header) and a number (the length of the -- dashed line under the rows.-alignType :: [String]+alignType :: [Text]           -> Int           -> Alignment alignType [] _ = AlignDefault alignType strLst len =-  let nonempties = filter (not . null) $ map trimr strLst+  let nonempties = filter (not . T.null) $ map trimr strLst       (leftSpace, rightSpace) =-           case sortBy (comparing length) nonempties of-                 (x:_) -> (head x `elem` " \t", length x < len)+           case sortBy (comparing T.length) nonempties of+                 (x:_) -> (T.head x `elem` [' ', 't'], T.length x < len)                  []    -> (False, False)   in  case (leftSpace, rightSpace) of         (True,  False) -> AlignRight@@ -1255,7 +1273,7 @@         (False, False) -> AlignDefault  -- Parse a table footer - dashed lines followed by blank line.-tableFooter :: PandocMonad m => MarkdownParser m String+tableFooter :: PandocMonad m => MarkdownParser m Text tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines'  -- Parse a table separator - dashed line.@@ -1265,12 +1283,12 @@ -- Parse a raw line and split it into chunks by indices. rawTableLine :: PandocMonad m              => [Int]-             -> MarkdownParser m [String]+             -> MarkdownParser m [Text] rawTableLine indices = do   notFollowedBy' (blanklines' <|> tableFooter)-  line <- many1Till anyChar newline+  line <- take1WhileP (/='\n') <* newline   return $ map trim $ tail $-           splitStringByIndices (init indices) line+           splitTextByIndices (init indices) line  -- Parse a table line and return a list of lists of blocks (columns). tableLine :: PandocMonad m@@ -1285,7 +1303,7 @@              -> MarkdownParser m (F [Blocks]) multilineRow indices = do   colLines <- many1 (rawTableLine indices)-  let cols = map unlines $ transpose colLines+  let cols = map T.unlines $ transpose colLines   fmap sequence $ mapM (parseFromString' (mconcat <$> many plain)) cols  -- Parses a table caption:  inlines beginning with 'Table:'@@ -1332,7 +1350,7 @@   dashes      <- many1 (dashedLine '-')   newline   let (lengths, lines') = unzip dashes-  let indices  = scanl (+) (length initSp) lines'+  let indices  = scanl (+) (T.length initSp) lines'   -- compensate for the fact that intercolumn spaces are   -- not included in the last index:   let indices' = case reverse indices of@@ -1340,14 +1358,14 @@                       (x:xs) -> reverse (x+1:xs)   rawHeadsList <- if headless                      then fmap (map (:[]) . tail .-                              splitStringByIndices (init indices')) $ lookAhead anyLine+                              splitTextByIndices (init indices')) $ lookAhead anyLine                      else return $ transpose $ map-                           (tail . splitStringByIndices (init indices'))+                           (tail . splitTextByIndices (init indices'))                            rawContent   let aligns   = zipWith alignType rawHeadsList lengths   let rawHeads = if headless                     then replicate (length dashes) ""-                    else map (unlines . map trim) rawHeadsList+                    else map (T.unlines . map trim) rawHeadsList   heads <- fmap sequence $             mapM ((parseFromString' (mconcat <$> many plain)).trim) rawHeads   return (heads, aligns, indices')@@ -1381,7 +1399,7 @@   lines' <- many pipeTableRow   let lines'' = map (take (length aligns) <$>) lines'   let maxlength = maximum $-       map (\x -> length . stringify $ runF x def) (heads' : lines'')+       map (\x -> T.length . stringify $ runF x def) (heads' : lines'')   numColumns <- getOption readerColumns   let widths = if maxlength > numColumns                   then map (\len ->@@ -1418,7 +1436,7 @@       return $ B.plain <$> result)     <|> return mempty -pipeTableHeaderPart :: PandocMonad m => ParserT [Char] st m (Alignment, Int)+pipeTableHeaderPart :: PandocMonad m => ParserT Text st m (Alignment, Int) pipeTableHeaderPart = try $ do   skipMany spaceChar   left <- optionMaybe (char ':')@@ -1434,12 +1452,12 @@       (Just _,Just _)   -> AlignCenter, len)  -- Succeed only if current line contains a pipe.-scanForPipe :: PandocMonad m => ParserT [Char] st m ()+scanForPipe :: PandocMonad m => ParserT Text st m () scanForPipe = do   inp <- getInput-  case break (\c -> c == '\n' || c == '|') inp of-       (_,'|':_) -> return ()-       _         -> mzero+  case T.break (\c -> c == '\n' || c == '|') inp of+       (_, T.uncons -> Just ('|', _)) -> return ()+       _                              -> mzero  -- | Parse a table using 'headerParser', 'rowParser', -- 'lineParser', and 'footerParser'.  Variant of the version in@@ -1549,7 +1567,7 @@   result <- escapedChar'   case result of        ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space-       _   -> return $ return $ B.str [result]+       _   -> return $ return $ B.str $ T.singleton result  ltSign :: PandocMonad m => MarkdownParser m (F Inlines) ltSign = do@@ -1562,12 +1580,12 @@ exampleRef = try $ do   guardEnabled Ext_example_lists   char '@'-  lab <- many1 (alphaNum <|> oneOf "-_")+  lab <- many1Char (alphaNum <|> oneOf "-_")   return $ do     st <- askF     return $ case M.lookup lab (stateExamples st) of-                  Just n  -> B.str (show n)-                  Nothing -> B.str ('@':lab)+                  Just n  -> B.str $ tshow n+                  Nothing -> B.str $ "@" <> lab  symbol :: PandocMonad m => MarkdownParser m (F Inlines) symbol = do@@ -1575,16 +1593,17 @@          <|> try (do lookAhead $ char '\\'                      notFollowedBy' (() <$ rawTeXBlock)                      char '\\')-  return $ return $ B.str [result]+  return $ return $ B.str $ T.singleton result  -- parses inline code, between n `s and n `s code :: PandocMonad m => MarkdownParser m (F Inlines) code = try $ do   starts <- many1 (char '`')   skipSpaces-  result <- (trim . concat) <$>-            manyTill (many1 (noneOf "`\n") <|> many1 (char '`') <|>-                       (char '\n' >> notFollowedBy' blankline >> return " "))+  result <- (trim . T.concat) <$>+            manyTill (notFollowedBy (inList >> listStart) >>+                      (many1Char (noneOf "`\n") <|> many1Char (char '`') <|>+                       (char '\n' >> notFollowedBy' blankline >> return " ")))                       (try (skipSpaces >> count (length starts) (char '`') >>                       notFollowedBy (char '`')))   rawattr <-@@ -1614,10 +1633,10 @@   guardDisabled Ext_intraword_underscores     <|> guard (c == '*')     <|> (guard =<< notAfterString)-  cs <- many1 (char c)+  cs <- many1Char (char c)   (return (B.str cs) <>) <$> whitespace     <|>-        case length cs of+        case T.length cs of              3 -> three c              2 -> two   c mempty              1 -> one   c mempty@@ -1640,7 +1659,7 @@   (ender c 3 >> updateLastStrPos >> return ((B.strong . B.emph) <$> contents))     <|> (ender c 2 >> updateLastStrPos >> one c (B.strong <$> contents))     <|> (ender c 1 >> updateLastStrPos >> two c (B.emph <$> contents))-    <|> return (return (B.str [c,c,c]) <> contents)+    <|> return (return (B.str $ T.pack [c,c,c]) <> contents)  -- Parse inlines til you hit two c's, and emit strong. -- If you never do hit two cs, emit ** plus inlines parsed.@@ -1649,7 +1668,7 @@   contents <- mconcat <$> many (try $ notFollowedBy (ender c 2) >> inline)   (ender c 2 >> updateLastStrPos >>                 return (B.strong <$> (prefix' <> contents)))-    <|> return (return (B.str [c,c]) <> (prefix' <> contents))+    <|> return (return (B.str $ T.pack [c,c]) <> (prefix' <> contents))  -- Parse inlines til you hit a c, and emit emph. -- If you never hit a c, emit * plus inlines parsed.@@ -1660,7 +1679,7 @@                                     notFollowedBy (ender c 1) >>                                     two c mempty) )   (ender c 1 >> updateLastStrPos >> return (B.emph <$> (prefix' <> contents)))-    <|> return (return (B.str [c]) <> (prefix' <> contents))+    <|> return (return (B.str $ T.singleton c) <> (prefix' <> contents))  strongOrEmph :: PandocMonad m => MarkdownParser m (F Inlines) strongOrEmph =  enclosure '*' <|> enclosure '_'@@ -1687,29 +1706,35 @@ superscript = fmap B.superscript <$> try (do   guardEnabled Ext_superscript   char '^'-  mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '^'))+  mconcat <$> many1Till (do notFollowedBy spaceChar+                            notFollowedBy newline+                            inline) (char '^'))  subscript :: PandocMonad m => MarkdownParser m (F Inlines) subscript = fmap B.subscript <$> try (do   guardEnabled Ext_subscript   char '~'-  mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '~'))+  mconcat <$> many1Till (do notFollowedBy spaceChar+                            notFollowedBy newline+                            inline) (char '~'))  whitespace :: PandocMonad m => MarkdownParser m (F Inlines) whitespace = spaceChar >> return <$> (lb <|> regsp) <?> "whitespace"   where lb = spaceChar >> skipMany spaceChar >> option B.space (endline >> return B.linebreak)         regsp = skipMany spaceChar >> return B.space -nonEndline :: PandocMonad m => ParserT [Char] st m Char+nonEndline :: PandocMonad m => ParserT Text st m Char nonEndline = satisfy (/='\n')  str :: PandocMonad m => MarkdownParser m (F Inlines) str = do-  result <- many1 (alphaNum <|> try (char '.' <* notFollowedBy (char '.')))+  result <- mconcat <$> many1+             ( take1WhileP isAlphaNum+              <|> "." <$ try (char '.' <* notFollowedBy (char '.')) )   updateLastStrPos   (do guardEnabled Ext_smart       abbrevs <- getOption readerAbbreviations-      if not (null result) && last result == '.' && result `Set.member` abbrevs+      if not (T.null result) && T.last result == '.' && result `Set.member` abbrevs          then try (do ils <- whitespace                       -- ?? lookAhead alphaNum                       -- replace space after with nonbreaking space@@ -1729,6 +1754,7 @@ endline = try $ do   newline   notFollowedBy blankline+  getState >>= guard . stateAllowLineBreaks   -- parse potential list-starts differently if in a list:   notFollowedBy (inList >> listStart)   guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart@@ -1748,36 +1774,36 @@ --  -- a reference label for a link-reference :: PandocMonad m => MarkdownParser m (F Inlines, String)+reference :: PandocMonad m => MarkdownParser m (F Inlines, Text) reference = do   guardDisabled Ext_footnotes <|> notFollowedBy' (string "[^")   guardDisabled Ext_citations <|> notFollowedBy' (string "[@")   withRaw $ trimInlinesF <$> inlinesInBalancedBrackets -parenthesizedChars :: PandocMonad m => MarkdownParser m [Char]+parenthesizedChars :: PandocMonad m => MarkdownParser m Text parenthesizedChars = do   result <- charsInBalanced '(' ')' litChar-  return $ '(' : result ++ ")"+  return $ "(" <> result <> ")"  -- source for a link, with optional title-source :: PandocMonad m => MarkdownParser m (String, String)+source :: PandocMonad m => MarkdownParser m (Text, Text) source = do   char '('   skipSpaces   let urlChunk =             try parenthesizedChars-        <|> (notFollowedBy (oneOf " )") >> count 1 litChar)-        <|> try (many1 spaceChar <* notFollowedBy (oneOf "\"')"))-  let sourceURL = (unwords . words . concat) <$> many urlChunk+        <|> (notFollowedBy (oneOf " )") >> countChar 1 litChar)+        <|> try (many1Char spaceChar <* notFollowedBy (oneOf "\"')"))+  let sourceURL = (T.unwords . T.words . T.concat) <$> many urlChunk   let betweenAngles = try $-         char '<' >> manyTill litChar (char '>')+         char '<' >> manyTillChar litChar (char '>')   src <- try betweenAngles <|> sourceURL   tit <- option "" $ try $ spnl >> linkTitle   skipSpaces   char ')'   return (escapeURI $ trimr src, tit) -linkTitle :: PandocMonad m => MarkdownParser m String+linkTitle :: PandocMonad m => MarkdownParser m Text linkTitle = quotedTitle '"' <|> quotedTitle '\''  link :: PandocMonad m => MarkdownParser m (F Inlines)@@ -1805,13 +1831,13 @@ isSmallCaps ("",["smallcaps"],[]) = True isSmallCaps ("",[],kvs) =   case lookup "style" kvs of-       Just s -> map toLower (filter (`notElem` " \t;") s) ==+       Just s -> T.toLower (T.filter (`notElem` [' ', '\t', ';']) s) ==                     "font-variant:small-caps"        Nothing -> False isSmallCaps _ = False  regLink :: PandocMonad m-        => (Attr -> String -> String -> Inlines -> Inlines)+        => (Attr -> Text -> Text -> Inlines -> Inlines)         -> F Inlines         -> MarkdownParser m (F Inlines) regLink constructor lab = try $ do@@ -1822,8 +1848,8 @@  -- a link like [this][ref] or [this][] or [this] referenceLink :: PandocMonad m-              => (Attr -> String -> String -> Inlines -> Inlines)-              -> (F Inlines, String)+              => (Attr -> Text -> Text -> Inlines -> Inlines)+              -> (F Inlines, Text)               -> MarkdownParser m (F Inlines) referenceLink constructor (lab, raw) = do   sp <- (True <$ lookAhead (char ' ')) <|> return False@@ -1845,7 +1871,7 @@        parsedRaw' <- parsedRaw        fallback' <- fallback        return $ B.str "[" <> fallback' <> B.str "]" <>-                (if sp && not (null raw) then B.space else mempty) <>+                (if sp && not (T.null raw) then B.space else mempty) <>                 parsedRaw'   return $ do     keys <- asksF stateKeys@@ -1860,19 +1886,19 @@             else makeFallback        Just ((src,tit), attr) -> constructor attr src tit <$> lab -dropBrackets :: String -> String-dropBrackets = reverse . dropRB . reverse . dropLB-  where dropRB (']':xs) = xs-        dropRB xs       = xs-        dropLB ('[':xs) = xs-        dropLB xs       = xs+dropBrackets :: Text -> Text+dropBrackets = dropRB . dropLB+  where dropRB (T.unsnoc -> Just (xs,']')) = xs+        dropRB xs                          = xs+        dropLB (T.uncons -> Just ('[',xs)) = xs+        dropLB xs                          = xs  bareURL :: PandocMonad m => MarkdownParser m (F Inlines) bareURL = try $ do   guardEnabled Ext_autolink_bare_uris   getState >>= guard . stateAllowLinks   (cls, (orig, src)) <- (("uri",) <$> uri) <|> (("email",) <$> emailAddress)-  notFollowedBy $ try $ spaces >> htmlTag (~== TagClose "a")+  notFollowedBy $ try $ spaces >> htmlTag (~== TagClose ("a" :: Text))   return $ return $ B.linkWith ("",[cls],[]) src "" (B.str orig)  autoLink :: PandocMonad m => MarkdownParser m (F Inlines)@@ -1884,19 +1910,20 @@   -- is finished, because the uri parser tries to avoid parsing   -- final punctuation.  for example:  in `<http://hi---there>`,   -- the URI parser will stop before the dashes.-  extra <- fromEntities <$> manyTill nonspaceChar (char '>')+  extra <- fromEntities <$> manyTillChar nonspaceChar (char '>')   attr  <- option ("", [cls], []) $ try $             guardEnabled Ext_link_attributes >> attributes-  return $ return $ B.linkWith attr (src ++ escapeURI extra) ""-                     (B.str $ orig ++ extra)+  return $ return $ B.linkWith attr (src <> escapeURI extra) ""+                     (B.str $ orig <> extra)  image :: PandocMonad m => MarkdownParser m (F Inlines) image = try $ do   char '!'   (lab,raw) <- reference   defaultExt <- getOption readerDefaultImageExtension-  let constructor attr' src = case takeExtension src of-                          "" -> B.imageWith attr' (addExtension src defaultExt)+  let constructor attr' src = case takeExtension (T.unpack src) of+                          "" -> B.imageWith attr' (T.pack $ addExtension (T.unpack src)+                                                          $ T.unpack defaultExt)                           _  -> B.imageWith attr' src   regLink constructor lab <|> referenceLink constructor (lab,raw) @@ -1908,7 +1935,7 @@   return $ do     notes <- asksF stateNotes'     case M.lookup ref notes of-        Nothing       -> return $ B.str $ "[^" ++ ref ++ "]"+        Nothing       -> return $ B.str $ "[^" <> ref <> "]"         Just (_pos, contents) -> do           st <- askF           -- process the note in a context that doesn't resolve@@ -1927,34 +1954,33 @@ rawLaTeXInline' :: PandocMonad m => MarkdownParser m (F Inlines) rawLaTeXInline' = try $ do   guardEnabled Ext_raw_tex-  lookAhead $ try $ char '\\' >> letter   notFollowedBy' rawConTeXtEnvironment   s <- rawLaTeXInline   return $ return $ B.rawInline "tex" s -- "tex" because it might be context -rawConTeXtEnvironment :: PandocMonad m => ParserT [Char] st m String+rawConTeXtEnvironment :: PandocMonad m => ParserT Text st m Text rawConTeXtEnvironment = try $ do   string "\\start"   completion <- inBrackets (letter <|> digit <|> spaceChar)-               <|> many1 letter-  contents <- manyTill (rawConTeXtEnvironment <|> count 1 anyChar)-                       (try $ string "\\stop" >> string completion)-  return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion+               <|> many1Char letter+  contents <- manyTill (rawConTeXtEnvironment <|> countChar 1 anyChar)+                       (try $ string "\\stop" >> textStr completion)+  return $ "\\start" <> completion <> T.concat contents <> "\\stop" <> completion -inBrackets :: PandocMonad m => ParserT [Char] st m Char -> ParserT [Char] st m String+inBrackets :: PandocMonad m => ParserT Text st m Char -> ParserT Text st m Text inBrackets parser = do   char '['-  contents <- many parser+  contents <- manyChar parser   char ']'-  return $ "[" ++ contents ++ "]"+  return $ "[" <> contents <> "]"  spanHtml :: PandocMonad m => MarkdownParser m (F Inlines) spanHtml = try $ do   guardEnabled Ext_native_spans-  (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "span" [])-  contents <- mconcat <$> manyTill inline (htmlTag (~== TagClose "span"))+  (TagOpen _ attrs, _) <- htmlTag (~== TagOpen ("span" :: Text) [])+  contents <- mconcat <$> manyTill inline (htmlTag (~== TagClose ("span" :: Text)))   let ident = fromMaybe "" $ lookup "id" attrs-  let classes = maybe [] words $ lookup "class" attrs+  let classes = maybe [] T.words $ lookup "class" attrs   let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]   return $ if isSmallCaps (ident, classes, keyvals)               then B.smallcaps <$> contents@@ -1963,20 +1989,20 @@ divHtml :: PandocMonad m => MarkdownParser m (F Blocks) divHtml = try $ do   guardEnabled Ext_native_divs-  (TagOpen _ attrs, rawtag) <- htmlTag (~== TagOpen "div" [])+  (TagOpen _ attrs, rawtag) <- htmlTag (~== TagOpen ("div" :: Text) [])   -- we set stateInHtmlBlock so that closing tags that can be either block or   -- inline will not be parsed as inline tags   oldInHtmlBlock <- stateInHtmlBlock <$> getState   updateState $ \st -> st{ stateInHtmlBlock = Just "div" }   bls <- option "" (blankline >> option "" blanklines)   contents <- mconcat <$>-              many (notFollowedBy' (htmlTag (~== TagClose "div")) >> block)-  closed <- option False (True <$ htmlTag (~== TagClose "div"))+              many (notFollowedBy' (htmlTag (~== TagClose ("div" :: Text))) >> block)+  closed <- option False (True <$ htmlTag (~== TagClose ("div" :: Text)))   if closed      then do        updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }        let ident = fromMaybe "" $ lookup "id" attrs-       let classes = maybe [] words $ lookup "class" attrs+       let classes = maybe [] T.words $ lookup "class" attrs        let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]        return $ B.divWith (ident, classes, keyvals) <$> contents      else -- avoid backtracing@@ -1988,7 +2014,7 @@   string ":::"   skipMany (char ':')   skipMany spaceChar-  attribs <- attributes <|> ((\x -> ("",[x],[])) <$> many1 nonspaceChar)+  attribs <- attributes <|> ((\x -> ("",[x],[])) <$> many1Char nonspaceChar)   skipMany spaceChar   skipMany (char ':')   blankline@@ -2030,7 +2056,7 @@ emoji = try $ do   guardEnabled Ext_emoji   char ':'-  emojikey <- many1 (oneOf emojiChars)+  emojikey <- many1Char (oneOf emojiChars)   char ':'   case emojiToInline emojikey of     Just i -> return (return $ B.singleton i)@@ -2060,14 +2086,14 @@   mbrest <- option Nothing $ try $ spnl >> Just <$> withRaw normalCite   case mbrest of        Just (rest, raw) ->-         return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw) . (first:))+         return $ (flip B.cite (B.text $ "@" <> key <> " " <> raw) . (first:))                <$> rest        Nothing   ->          (do           (cs, raw) <- withRaw $ bareloc first-          let (spaces',raw') = span isSpace raw-              spc | null spaces' = mempty-                  | otherwise    = B.space+          let (spaces',raw') = T.span isSpace raw+              spc | T.null spaces' = mempty+                  | otherwise      = B.space           lab <- parseFromString' inlines $ dropBrackets raw'           fallback <- referenceLink B.linkWith (lab,raw')           return $ do@@ -2075,12 +2101,12 @@             cs' <- cs             return $               case B.toList fallback' of-                Link{}:_ -> B.cite [first] (B.str $ '@':key) <> spc <> fallback'-                _        -> B.cite cs' (B.text $ '@':key ++ " " ++ raw))+                Link{}:_ -> B.cite [first] (B.str $ "@" <> key) <> spc <> fallback'+                _        -> B.cite cs' (B.text $ "@" <> key <> " " <> raw))          <|> return (do st <- askF                         return $ case M.lookup key (stateExamples st) of-                                 Just n -> B.str (show n)-                                 _      -> B.cite [first] $ B.str $ '@':key)+                                 Just n -> B.str $ tshow n+                                 _      -> B.cite [first] $ B.str $ "@" <> key)  bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation]) bareloc c = try $ do
src/Text/Pandoc/Readers/MediaWiki.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE RelaxedPolyRec #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RelaxedPolyRec    #-} -- RelaxedPolyRec needed for inlinesBetween on GHC < 7 {- |    Module      : Text.Pandoc.Readers.MediaWiki@@ -24,11 +25,12 @@ import Control.Monad.Except (throwError) import Data.Char (isDigit, isSpace) import qualified Data.Foldable as F-import Data.List (intercalate, intersperse, isPrefixOf)+import Data.List (intersperse) import Data.Maybe (fromMaybe, maybeToList) import Data.Sequence (ViewL (..), viewl, (<|)) import qualified Data.Set as Set-import Data.Text (Text, unpack)+import Data.Text (Text)+import qualified Data.Text as T import Text.HTML.TagSoup import Text.Pandoc.Builder (Blocks, Inlines, trimInlines) import qualified Text.Pandoc.Builder as B@@ -39,7 +41,7 @@ import Text.Pandoc.Parsing hiding (nested) import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isCommentTag) import Text.Pandoc.Shared (crFilter, safeRead, stringify, stripTrailingNewlines,-                           trim)+                           trim, splitTextBy, tshow) import Text.Pandoc.Walk (walk) import Text.Pandoc.XML (fromEntities) @@ -57,7 +59,7 @@                                             , mwLogMessages = []                                             , mwInTT = False                                             }-            (unpack (crFilter s) ++ "\n")+            (crFilter s <> "\n")   case parsed of     Right result -> return result     Left e       -> throwError e@@ -66,12 +68,12 @@                        , mwMaxNestingLevel :: Int                        , mwNextLinkNumber  :: Int                        , mwCategoryLinks   :: [Inlines]-                       , mwIdentifierList  :: Set.Set String+                       , mwIdentifierList  :: Set.Set Text                        , mwLogMessages     :: [LogMessage]                        , mwInTT            :: Bool                        } -type MWParser m = ParserT [Char] MWState m+type MWParser m = ParserT Text MWState m  instance HasReaderOptions MWState where   extractReaderOptions = mwOptions@@ -105,58 +107,58 @@ spaceChars :: [Char] spaceChars = " \n\t" -sym :: PandocMonad m => String -> MWParser m ()-sym s = () <$ try (string s)+sym :: PandocMonad m => Text -> MWParser m ()+sym s = () <$ try (string $ T.unpack s) -newBlockTags :: [String]+newBlockTags :: [Text] newBlockTags = ["haskell","syntaxhighlight","source","gallery","references"] -isBlockTag' :: Tag String -> Bool+isBlockTag' :: Tag Text -> Bool isBlockTag' tag@(TagOpen t _) = (isBlockTag tag || t `elem` newBlockTags) &&   t `notElem` eitherBlockOrInline isBlockTag' tag@(TagClose t) = (isBlockTag tag || t `elem` newBlockTags) &&   t `notElem` eitherBlockOrInline isBlockTag' tag = isBlockTag tag -isInlineTag' :: Tag String -> Bool+isInlineTag' :: Tag Text -> Bool isInlineTag' (TagComment _) = True isInlineTag' t              = not (isBlockTag' t) -eitherBlockOrInline :: [String]+eitherBlockOrInline :: [Text] eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",                                "map", "area", "object"]  htmlComment :: PandocMonad m => MWParser m () htmlComment = () <$ htmlTag isCommentTag -inlinesInTags :: PandocMonad m => String -> MWParser m Inlines+inlinesInTags :: PandocMonad m => Text -> MWParser m Inlines inlinesInTags tag = try $ do   (_,raw) <- htmlTag (~== TagOpen tag [])-  if '/' `elem` raw   -- self-closing tag+  if T.any (== '/') raw   -- self-closing tag      then return mempty      else trimInlines . mconcat <$>             manyTill inline (htmlTag (~== TagClose tag)) -blocksInTags :: PandocMonad m => String -> MWParser m Blocks+blocksInTags :: PandocMonad m => Text -> MWParser m Blocks blocksInTags tag = try $ do   (_,raw) <- htmlTag (~== TagOpen tag [])   let closer = if tag == "li"-                  then htmlTag (~== TagClose "li")+                  then htmlTag (~== TagClose ("li" :: Text))                      <|> lookAhead (-                              htmlTag (~== TagOpen "li" [])-                          <|> htmlTag (~== TagClose "ol")-                          <|> htmlTag (~== TagClose "ul"))+                              htmlTag (~== TagOpen ("li" :: Text) [])+                          <|> htmlTag (~== TagClose ("ol" :: Text))+                          <|> htmlTag (~== TagClose ("ul" :: Text)))                   else htmlTag (~== TagClose tag)-  if '/' `elem` raw   -- self-closing tag+  if T.any (== '/') raw   -- self-closing tag      then return mempty      else mconcat <$> manyTill block closer -charsInTags :: PandocMonad m => String -> MWParser m [Char]-charsInTags tag = try $ do+textInTags :: PandocMonad m => Text -> MWParser m Text+textInTags tag = try $ do   (_,raw) <- htmlTag (~== TagOpen tag [])-  if '/' `elem` raw   -- self-closing tag+  if T.any (== '/') raw   -- self-closing tag      then return ""-     else manyTill anyChar (htmlTag (~== TagClose tag))+     else T.pack <$> manyTill anyChar (htmlTag (~== TagClose tag))  -- -- main parser@@ -192,7 +194,7 @@      <|> blockTag      <|> (B.rawBlock "mediawiki" <$> template)      <|> para-  trace (take 60 $ show $ B.toList res)+  trace (T.take 60 $ tshow $ B.toList res)   return res  para :: PandocMonad m => MWParser m Blocks@@ -208,6 +210,7 @@   styles <- option [] $                parseAttrs <* skipMany spaceChar <* optional (char '|')   skipMany spaceChar+  optional $ template >> skipMany spaceChar   optional blanklines   let tableWidth = case lookup "width" styles of                          Just w  -> fromMaybe 1.0 $ parseWidth w@@ -233,16 +236,16 @@                           else (replicate cols mempty, hdr:rows')   return $ B.table caption cellspecs headers rows -parseAttrs :: PandocMonad m => MWParser m [(String,String)]+parseAttrs :: PandocMonad m => MWParser m [(Text,Text)] parseAttrs = many1 parseAttr -parseAttr :: PandocMonad m => MWParser m (String, String)+parseAttr :: PandocMonad m => MWParser m (Text, Text) parseAttr = try $ do   skipMany spaceChar-  k <- many1 letter+  k <- many1Char letter   char '='-  v <- (char '"' >> many1Till (satisfy (/='\n')) (char '"'))-       <|> many1 (satisfy $ \c -> not (isSpace c) && c /= '|')+  v <- (char '"' >> many1TillChar (satisfy (/='\n')) (char '"'))+       <|> many1Char (satisfy $ \c -> not (isSpace c) && c /= '|')   return (k,v)  tableStart :: PandocMonad m => MWParser m ()@@ -292,8 +295,8 @@                                  notFollowedBy (char '|')   skipMany spaceChar   pos' <- getPosition-  ls <- concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>-                     ((snd <$> withRaw table) <|> count 1 anyChar))+  ls <- T.concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>+                            ((snd <$> withRaw table) <|> countChar 1 anyChar))   bs <- parseFromString (do setPosition pos'                             mconcat <$> many block) ls   let align = case lookup "align" attrs of@@ -306,48 +309,49 @@                     Nothing -> 0.0   return ((align, width), bs) -parseWidth :: String -> Maybe Double+parseWidth :: Text -> Maybe Double parseWidth s =-  case reverse s of-       ('%':ds) | all isDigit ds -> safeRead ('0':'.':reverse ds)-       _        -> Nothing+  case T.unsnoc s of+    Just (ds, '%') | T.all isDigit ds -> safeRead $ "0." <> ds+    _ -> Nothing -template :: PandocMonad m => MWParser m String+template :: PandocMonad m => MWParser m Text template = try $ do   string "{{"   notFollowedBy (char '{')   lookAhead $ letter <|> digit <|> char ':'-  let chunk = template <|> variable <|> many1 (noneOf "{}") <|> count 1 anyChar+  let chunk = template <|> variable <|> many1Char (noneOf "{}") <|> countChar 1 anyChar   contents <- manyTill chunk (try $ string "}}")-  return $ "{{" ++ concat contents ++ "}}"+  return $ "{{" <> T.concat contents <> "}}"  blockTag :: PandocMonad m => MWParser m Blocks blockTag = do   (tag, _) <- lookAhead $ htmlTag isBlockTag'   case tag of       TagOpen "blockquote" _ -> B.blockQuote <$> blocksInTags "blockquote"-      TagOpen "pre" _ -> B.codeBlock . trimCode <$> charsInTags "pre"+      TagOpen "pre" _ -> B.codeBlock . trimCode <$> textInTags "pre"       TagOpen "syntaxhighlight" attrs -> syntaxhighlight "syntaxhighlight" attrs       TagOpen "source" attrs -> syntaxhighlight "source" attrs       TagOpen "haskell" _ -> B.codeBlockWith ("",["haskell"],[]) . trimCode <$>-                                charsInTags "haskell"+                                textInTags "haskell"       TagOpen "gallery" _ -> blocksInTags "gallery"       TagOpen "p" _ -> mempty <$ htmlTag (~== tag)       TagClose "p"  -> mempty <$ htmlTag (~== tag)       _ -> B.rawBlock "html" . snd <$> htmlTag (~== tag) -trimCode :: String -> String-trimCode ('\n':xs) = stripTrailingNewlines xs-trimCode xs        = stripTrailingNewlines xs+trimCode :: Text -> Text+trimCode t = case T.uncons t of+  Just ('\n', xs) -> stripTrailingNewlines xs+  _               -> stripTrailingNewlines t -syntaxhighlight :: PandocMonad m => String -> [Attribute String] -> MWParser m Blocks+syntaxhighlight :: PandocMonad m => Text -> [Attribute Text] -> MWParser m Blocks syntaxhighlight tag attrs = try $ do   let mblang = lookup "lang" attrs   let mbstart = lookup "start" attrs   let mbline = lookup "line" attrs   let classes = maybeToList mblang ++ maybe [] (const ["numberLines"]) mbline   let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart-  contents <- charsInTags tag+  contents <- textInTags tag   return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents  hrule :: PandocMonad m => MWParser m Blocks@@ -361,17 +365,17 @@   guardColumnOne   char ' '   let endline' = B.linebreak <$ try (newline <* char ' ')-  let whitespace' = B.str <$> many1 ('\160' <$ spaceChar)+  let whitespace' = B.str <$> many1Char ('\160' <$ spaceChar)   let spToNbsp ' ' = '\160'       spToNbsp x   = x   let nowiki' = mconcat . intersperse B.linebreak . map B.str .-                lines . fromEntities . map spToNbsp <$> try-                  (htmlTag (~== TagOpen "nowiki" []) *>-                   manyTill anyChar (htmlTag (~== TagClose "nowiki")))+                T.lines . fromEntities . T.map spToNbsp <$> try+                  (htmlTag (~== TagOpen ("nowiki" :: Text) []) *>+                   manyTillChar anyChar (htmlTag (~== TagClose ("nowiki" :: Text))))   let inline' = whitespace' <|> endline' <|> nowiki'                   <|> try (notFollowedBy newline *> inline)   contents <- mconcat <$> many1 inline'-  let spacesStr (Str xs) = all isSpace xs+  let spacesStr (Str xs) = T.all isSpace xs       spacesStr _        = False   if F.all spacesStr contents      then return mempty@@ -384,7 +388,7 @@         strToCode  x      = x         normalizeCode []  = []         normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 =-          normalizeCode $ Code a1 (x ++ y) : zs+          normalizeCode $ Code a1 (x <> y) : zs         normalizeCode (x:xs) = x : normalizeCode xs  header :: PandocMonad m => MWParser m Blocks@@ -399,22 +403,22 @@ -- See #4731: modifyIdentifier :: Attr -> Attr modifyIdentifier (ident,cl,kv) = (ident',cl,kv)-  where ident' = map (\c -> if c == '-' then '_' else c) ident+  where ident' = T.map (\c -> if c == '-' then '_' else c) ident  bulletList :: PandocMonad m => MWParser m Blocks bulletList = B.bulletList <$>    (   many1 (listItem '*')-   <|> (htmlTag (~== TagOpen "ul" []) *> spaces *> many (listItem '*' <|> li) <*-        optional (htmlTag (~== TagClose "ul"))) )+   <|> (htmlTag (~== TagOpen ("ul" :: Text) []) *> spaces *> many (listItem '*' <|> li) <*+        optional (htmlTag (~== TagClose ("ul" :: Text)))) )  orderedList :: PandocMonad m => MWParser m Blocks orderedList =        (B.orderedList <$> many1 (listItem '#'))    <|> try-       (do (tag,_) <- htmlTag (~== TagOpen "ol" [])+       (do (tag,_) <- htmlTag (~== TagOpen ("ol" :: Text) [])            spaces            items <- many (listItem '#' <|> li)-           optional (htmlTag (~== TagClose "ol"))+           optional (htmlTag (~== TagClose ("ol" :: Text)))            let start = fromMaybe 1 $ safeRead $ fromAttrib "start" tag            return $ B.orderedListWith (start, DefaultStyle, DefaultDelim) items) @@ -451,7 +455,7 @@ anyListStart = guardColumnOne >> oneOf "*#:;"  li :: PandocMonad m => MWParser m Blocks-li = lookAhead (htmlTag (~== TagOpen "li" [])) *>+li = lookAhead (htmlTag (~== TagOpen ("li" :: Text) [])) *>      (firstParaToPlain <$> blocksInTags "li") <* spaces  listItem :: PandocMonad m => Char -> MWParser m Blocks@@ -463,13 +467,13 @@      else do        skipMany spaceChar        pos' <- getPosition-       first <- concat <$> manyTill listChunk newline+       first <- T.concat <$> manyTill listChunk newline        rest <- many                 (try $ string extras *> lookAhead listStartChar *>-                       (concat <$> manyTill listChunk newline))+                       (T.concat <$> manyTill listChunk newline))        contents <- parseFromString (do setPosition pos'                                        many1 $ listItem' c)-                          (unlines (first : rest))+                          (T.unlines (first : rest))        case c of            '*' -> return $ B.bulletList contents            '#' -> return $ B.orderedList contents@@ -483,20 +487,20 @@ -- }} -- * next list item -- which seems to be valid mediawiki.-listChunk :: PandocMonad m => MWParser m String-listChunk = template <|> count 1 anyChar+listChunk :: PandocMonad m => MWParser m Text+listChunk = template <|> countChar 1 anyChar  listItem' :: PandocMonad m => Char -> MWParser m Blocks listItem' c = try $ do   listStart c   skipMany spaceChar   pos' <- getPosition-  first <- concat <$> manyTill listChunk newline+  first <- T.concat <$> manyTill listChunk newline   rest <- many (try $ char c *> lookAhead listStartChar *>-                   (concat <$> manyTill listChunk newline))+                   (T.concat <$> manyTill listChunk newline))   parseFromString (do setPosition pos'                       firstParaToPlain . mconcat <$> many1 block)-      $ unlines $ first : rest+      $ T.unlines $ first : rest  firstParaToPlain :: Blocks -> Blocks firstParaToPlain contents =@@ -527,23 +531,23 @@       <|> special  str :: PandocMonad m => MWParser m Inlines-str = B.str <$> many1 (noneOf $ specialChars ++ spaceChars)+str = B.str <$> many1Char (noneOf $ specialChars ++ spaceChars)  math :: PandocMonad m => MWParser m Inlines-math = (B.displayMath . trim <$> try (many1 (char ':') >> charsInTags "math"))-   <|> (B.math . trim <$> charsInTags "math")-   <|> (B.displayMath . trim <$> try (dmStart *> manyTill anyChar dmEnd))-   <|> (B.math . trim <$> try (mStart *> manyTill (satisfy (/='\n')) mEnd))+math = (B.displayMath . trim <$> try (many1 (char ':') >> textInTags "math"))+   <|> (B.math . trim <$> textInTags "math")+   <|> (B.displayMath . trim <$> try (dmStart *> manyTillChar anyChar dmEnd))+   <|> (B.math . trim <$> try (mStart *> manyTillChar (satisfy (/='\n')) mEnd))  where dmStart = string "\\["        dmEnd   = try (string "\\]")        mStart  = string "\\("        mEnd    = try (string "\\)") -variable :: PandocMonad m => MWParser m String+variable :: PandocMonad m => MWParser m Text variable = try $ do   string "{{{"-  contents <- manyTill anyChar (try $ string "}}}")-  return $ "{{{" ++ contents ++ "}}}"+  contents <- manyTillChar anyChar (try $ string "}}}")+  return $ "{{{" <> contents <> "}}}"  inlineTag :: PandocMonad m => MWParser m Inlines inlineTag = do@@ -552,11 +556,11 @@        TagOpen "ref" _ -> B.note . B.plain <$> inlinesInTags "ref"        TagOpen "nowiki" _ -> try $ do           (_,raw) <- htmlTag (~== tag)-          if '/' `elem` raw+          if T.any (== '/') raw              then return mempty              else B.text . fromEntities <$>-                       manyTill anyChar (htmlTag (~== TagClose "nowiki"))-       TagOpen "br" _ -> B.linebreak <$ (htmlTag (~== TagOpen "br" []) -- will get /> too+                       manyTillChar anyChar (htmlTag (~== TagClose ("nowiki" :: Text)))+       TagOpen "br" _ -> B.linebreak <$ (htmlTag (~== TagOpen ("br" :: Text) []) -- will get /> too                             *> optional blankline)        TagOpen "strike" _ -> B.strikeout <$> inlinesInTags "strike"        TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del"@@ -569,12 +573,12 @@          result <- encode <$> inlinesInTags "tt"          updateState $ \st -> st{ mwInTT = inTT }          return result-       TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask"+       TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> textInTags "hask"        _ -> B.rawInline "html" . snd <$> htmlTag (~== tag)  special :: PandocMonad m => MWParser m Inlines-special = B.str <$> count 1 (notFollowedBy' (htmlTag isBlockTag') *>-                             oneOf specialChars)+special = B.str <$> countChar 1 (notFollowedBy' (htmlTag isBlockTag') *>+                                  oneOf specialChars)  inlineHtml :: PandocMonad m => MWParser m Inlines inlineHtml = B.rawInline "html" . snd <$> htmlTag isInlineTag'@@ -593,7 +597,7 @@                      notFollowedBy anyListStart)  imageIdentifiers :: PandocMonad m => [MWParser m ()]-imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers]+imageIdentifiers = [sym (identifier <> ":") | identifier <- identifiers]     where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier",                          "Bild"] @@ -601,9 +605,9 @@ image = try $ do   sym "[["   choice imageIdentifiers-  fname <- addUnderscores <$> many1 (noneOf "|]")+  fname <- addUnderscores <$> many1Char (noneOf "|]")   _ <- many imageOption-  dims <- try (char '|' *> sepBy (many digit) (char 'x') <* string "px")+  dims <- try (char '|' *> sepBy (manyChar digit) (char 'x') <* string "px")           <|> return []   _ <- many imageOption   let kvs = case dims of@@ -613,9 +617,9 @@   let attr = ("", [], kvs)   caption <-   (B.str fname <$ sym "]]")            <|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))-  return $ B.imageWith attr fname ("fig:" ++ stringify caption) caption+  return $ B.imageWith attr fname ("fig:" <> stringify caption) caption -imageOption :: PandocMonad m => MWParser m String+imageOption :: PandocMonad m => MWParser m Text imageOption = try $ char '|' *> opt   where     opt = try (oneOfStrings [ "border", "thumbnail", "frameless"@@ -623,30 +627,27 @@                             , "center", "none", "baseline", "sub"                             , "super", "top", "text-top", "middle"                             , "bottom", "text-bottom" ])-      <|> try (string "frame")+      <|> try (textStr "frame")       <|> try (oneOfStrings ["link=","alt=","page=","class="] <* many (noneOf "|]")) -collapseUnderscores :: String -> String-collapseUnderscores []           = []-collapseUnderscores ('_':'_':xs) = collapseUnderscores ('_':xs)-collapseUnderscores (x:xs)       = x : collapseUnderscores xs--addUnderscores :: String -> String-addUnderscores = collapseUnderscores . intercalate "_" . words+addUnderscores :: Text -> Text+addUnderscores = T.intercalate "_" . splitTextBy sep+  where+    sep c = isSpace c || c == '_'  internalLink :: PandocMonad m => MWParser m Inlines internalLink = try $ do   sym "[["-  pagename <- unwords . words <$> many (noneOf "|]")+  pagename <- T.unwords . T.words <$> manyChar (noneOf "|]")   label <- option (B.text pagename) $ char '|' *>              (  (mconcat <$> many1 (notFollowedBy (char ']') *> inline))              -- the "pipe trick"              -- [[Help:Contents|] -> "Contents"-             <|> return (B.text $ drop 1 $ dropWhile (/=':') pagename) )+             <|> return (B.text $ T.drop 1 $ T.dropWhile (/=':') pagename) )   sym "]]"-  linktrail <- B.text <$> many letter+  linktrail <- B.text <$> manyChar letter   let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)-  if "Category:" `isPrefixOf` pagename+  if "Category:" `T.isPrefixOf` pagename      then do        updateState $ \st -> st{ mwCategoryLinks = link : mwCategoryLinks st }        return mempty@@ -661,7 +662,7 @@        <|> do char ']'               num <- mwNextLinkNumber <$> getState               updateState $ \st -> st{ mwNextLinkNumber = num + 1 }-              return $ B.str $ show num+              return $ B.str $ tshow num   return $ B.link src "" lab  url :: PandocMonad m => MWParser m Inlines
src/Text/Pandoc/Readers/Muse.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE TupleSections     #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Muse    Copyright   : Copyright (C) 2017-2019 Alexander Krotov@@ -24,12 +25,12 @@ import Control.Monad.Except (throwError) import Data.Bifunctor import Data.Default-import Data.List (intercalate, transpose, uncons)-import Data.List.Split (splitOn)+import Data.List (transpose, uncons) import qualified Data.Map as M import qualified Data.Set as Set import Data.Maybe (fromMaybe, isNothing, maybeToList)-import Data.Text (Text, unpack)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad (..))@@ -38,7 +39,7 @@ import Text.Pandoc.Logging import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (F)-import Text.Pandoc.Shared (crFilter, trimr, underlineSpan)+import Text.Pandoc.Shared (crFilter, trimr, underlineSpan, tshow)  -- | Read Muse from an input string and return a Pandoc document. readMuse :: PandocMonad m@@ -49,18 +50,18 @@   let input = crFilter s   res <- flip runReaderT def $ runParserT parseMuse def{ museOptions = opts } "source" input   case res of-       Left e  -> throwError $ PandocParsecError (unpack input) e+       Left e  -> throwError $ PandocParsecError input e        Right d -> return d  type F = Future MuseState  data MuseState = MuseState { museMeta :: F Meta -- ^ Document metadata                            , museOptions :: ReaderOptions-                           , museIdentifierList :: Set.Set String+                           , museIdentifierList :: Set.Set Text                            , museLastSpacePos :: Maybe SourcePos -- ^ Position after last space or newline parsed                            , museLastStrPos :: Maybe SourcePos -- ^ Position after last str parsed                            , museLogMessages :: [LogMessage]-                           , museNotes :: M.Map String (SourcePos, F Blocks)+                           , museNotes :: M.Map Text (SourcePos, F Blocks)                            }  instance Default MuseState where@@ -93,7 +94,7 @@   updateIdentifierList f st = st{ museIdentifierList = f $ museIdentifierList st }  instance HasLastStrPosition MuseState where-  setLastStrPos pos st = st{ museLastStrPos = Just pos }+  setLastStrPos pos st = st{ museLastStrPos = pos }   getLastStrPos st     = museLastStrPos st  instance HasLogMessages MuseState where@@ -116,22 +117,27 @@ -- * Utility functions  -- | Trim up to one newline from the beginning of the string.-lchop :: String -> String-lchop ('\n':xs) = xs-lchop s = s+lchop :: Text -> Text+lchop s = case T.uncons s of+  Just ('\n', xs) -> xs+  _               -> s  -- | Trim up to one newline from the end of the string.-rchop :: String -> String-rchop = reverse . lchop . reverse+rchop :: Text -> Text+rchop s = case T.unsnoc s of+  Just (xs, '\n') -> xs+  _               -> s -unindent :: String -> String-unindent = rchop . intercalate "\n" . dropSpacePrefix . splitOn "\n" . lchop+unindent :: Text -> Text+unindent = rchop . T.intercalate "\n" . dropSpacePrefix . T.splitOn "\n" . lchop -dropSpacePrefix :: [String] -> [String]-dropSpacePrefix lns = drop maxIndent <$> lns+dropSpacePrefix :: [Text] -> [Text]+dropSpacePrefix lns = T.drop maxIndent <$> lns   where isSpaceChar c = c == ' ' || c == '\t'-        maxIndent = length $ takeWhile (isSpaceChar . head) $ takeWhile same $ transpose lns-        same = and . (zipWith (==) <*> drop 1)+        maxIndent = length $ takeWhile (isSpaceChar . T.head) $ takeWhile same $ T.transpose lns+        same t = case T.uncons t of+          Just (c, cs) -> T.all (== c) cs+          Nothing      -> True  atStart :: PandocMonad m => MuseParser m () atStart = do@@ -160,29 +166,29 @@  -- ** HTML parsers -openTag :: PandocMonad m => String -> MuseParser m [(String, String)]+openTag :: PandocMonad m => Text -> MuseParser m [(Text, Text)] openTag tag = try $-  char '<' *> string tag *> manyTill attr (char '>')+  char '<' *> textStr tag *> manyTill attr (char '>')   where     attr = try $ (,)       <$  many1 spaceChar-      <*> many1 (noneOf "=\n")+      <*> many1Char (noneOf "=\n")       <*  string "=\""-      <*> manyTill (noneOf "\"") (char '"')+      <*> manyTillChar (noneOf "\"") (char '"') -closeTag :: PandocMonad m => String -> MuseParser m ()-closeTag tag = try $ string "</" *> string tag *> void (char '>')+closeTag :: PandocMonad m => Text -> MuseParser m ()+closeTag tag = try $ string "</" *> textStr tag *> void (char '>')  -- | Convert HTML attributes to Pandoc 'Attr'-htmlAttrToPandoc :: [(String, String)] -> Attr+htmlAttrToPandoc :: [(Text, Text)] -> Attr htmlAttrToPandoc attrs = (ident, classes, keyvals)   where     ident   = fromMaybe "" $ lookup "id" attrs-    classes = maybe [] words $ lookup "class" attrs+    classes = maybe [] T.words $ lookup "class" attrs     keyvals = [(k,v) | (k,v) <- attrs, k /= "id", k /= "class"]  parseHtmlContent :: PandocMonad m-                 => String -- ^ Tag name+                 => Text -- ^ Tag name                  -> MuseParser m (Attr, F Blocks) parseHtmlContent tag = try $ getIndent >>= \indent -> (,)   <$> fmap htmlAttrToPandoc (openTag tag)@@ -193,16 +199,16 @@ -- ** Directive parsers  -- While not documented, Emacs Muse allows "-" in directive name-parseDirectiveKey :: PandocMonad m => MuseParser m String-parseDirectiveKey = char '#' *> many (letter <|> char '-')+parseDirectiveKey :: PandocMonad m => MuseParser m Text+parseDirectiveKey = char '#' *> manyChar (letter <|> char '-') -parseEmacsDirective :: PandocMonad m => MuseParser m (String, F Inlines)+parseEmacsDirective :: PandocMonad m => MuseParser m (Text, F Inlines) parseEmacsDirective = (,)   <$> parseDirectiveKey   <*  spaceChar   <*> (trimInlinesF . mconcat <$> manyTill inline' eol) -parseAmuseDirective :: PandocMonad m => MuseParser m (String, F Inlines)+parseAmuseDirective :: PandocMonad m => MuseParser m (Text, F Inlines) parseAmuseDirective = (,)   <$> parseDirectiveKey   <*  many1 spaceChar@@ -289,7 +295,7 @@ parseBlock :: PandocMonad m => MuseParser m (F Blocks) parseBlock = do   res <- blockElements <|> para-  trace (take 60 $ show $ B.toList $ runF res def)+  trace (T.take 60 $ tshow $ B.toList $ runF res def)   return res   where para = fst <$> paraUntil (try (eof <|> void (lookAhead blockElements))) @@ -337,7 +343,7 @@   <* string "* * * * *"   <* manyTill spaceChar eol -headingStart :: PandocMonad m => MuseParser m (String, Int)+headingStart :: PandocMonad m => MuseParser m (Text, Int) headingStart = try $ (,)   <$> option "" (try (parseAnchor <* manyTill spaceChar eol))   <*  firstColumn@@ -371,14 +377,14 @@ example = try $ pure . B.codeBlock   <$  string "{{{"   <*  many spaceChar-  <*> (unindent <$> manyTill anyChar (string "}}}"))+  <*> (unindent <$> manyTillChar anyChar (string "}}}"))  -- | Parse an @\<example>@ tag. exampleTag :: PandocMonad m => MuseParser m (F Blocks) exampleTag = try $ fmap pure $ B.codeBlockWith   <$  many spaceChar   <*> (htmlAttrToPandoc <$> openTag "example")-  <*> (unindent <$> manyTill anyChar (closeTag "example"))+  <*> (unindent <$> manyTillChar anyChar (closeTag "example"))   <*  manyTill spaceChar eol  -- | Parse a @\<literal>@ tag as a raw block.@@ -388,7 +394,7 @@   <$  many spaceChar   <*> (fromMaybe "html" . lookup "style" <$> openTag "literal") -- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML   <*  manyTill spaceChar eol-  <*> (unindent <$> manyTill anyChar (closeTag "literal"))+  <*> (unindent <$> manyTillChar anyChar (closeTag "literal"))   <*  manyTill spaceChar eol  -- | Parse @\<center>@ tag.@@ -428,7 +434,7 @@  verseLine :: PandocMonad m => MuseParser m (F Inlines) verseLine = (<>)-  <$> fmap pure (option mempty (B.str <$> many1 ('\160' <$ char ' ')))+  <$> fmap pure (option mempty (B.str <$> many1Char ('\160' <$ char ' ')))   <*> fmap (trimInlinesF . mconcat) (manyTill inline' eol)  -- | Parse @\<verse>@ tag.@@ -466,17 +472,17 @@ noteMarker' :: PandocMonad m             => Char             -> Char-            -> MuseParser m String-noteMarker' l r = try $ (\x y -> l:x:y ++ [r])+            -> MuseParser m Text+noteMarker' l r = try $ (\x y -> T.pack $ l:x:y ++ [r])   <$ char l   <*> oneOf "123456789"   <*> manyTill digit (char r) -noteMarker :: PandocMonad m => MuseParser m String+noteMarker :: PandocMonad m => MuseParser m Text noteMarker = noteMarker' '[' ']' <|> noteMarker' '{' '}'  addNote :: PandocMonad m-        => String+        => Text         -> SourcePos         -> F Blocks         -> MuseParser m ()@@ -496,7 +502,7 @@   ref <- noteMarker   pos <- getPosition   void spaceChar <|> lookAhead eol-  (content, e) <- allowPara $ listItemContentsUntil (sourceColumn pos) (fail "x") end+  (content, e) <- allowPara $ listItemContentsUntil (sourceColumn pos) (Prelude.fail "x") end   addNote ref pos content   return (mempty, e) @@ -558,7 +564,7 @@               LowerRoman -> lowerRoman               UpperAlpha -> upperAlpha               LowerAlpha -> lowerAlpha-              _          -> fail "Unhandled case"+              _          -> Prelude.fail "Unhandled case"  orderedListItemsUntil :: PandocMonad m                       => Int@@ -642,7 +648,7 @@ museToPandocTable :: MuseTable -> Blocks museToPandocTable (MuseTable caption headers body footers) =   B.table caption attrs headRow (rows ++ body ++ footers)-  where attrs = const (AlignDefault, 0.0) <$> transpose (headers ++ body ++ footers)+  where attrs = (AlignDefault, 0.0) <$ transpose (headers ++ body ++ footers)         (headRow, rows) = fromMaybe ([], []) $ uncons headers  museAppendElement :: MuseTableElement@@ -674,15 +680,15 @@                  -> MuseParser m (F [Blocks]) museGridTableRow indent indices = try $ do   lns <- many1 $ try (indentWith indent *> museGridTableRawLine indices)-  let cols = map (unlines . map trimr) $ transpose lns+  let cols = map (T.unlines . map trimr) $ transpose lns   indentWith indent *> museGridTableHeader-  sequence <$> mapM (parseFromString parseBlocks) cols+  sequence <$> mapM (parseFromString' parseBlocks) cols  museGridTableRawLine :: PandocMonad m                      => [Int]-                     -> MuseParser m [String]+                     -> MuseParser m [Text] museGridTableRawLine indices =-  char '|' *> forM indices (\n -> count n anyChar <* char '|') <* manyTill spaceChar eol+  char '|' *> forM indices (\n -> countChar n anyChar <* char '|') <* manyTill spaceChar eol  museGridTable :: PandocMonad m => MuseParser m (F Blocks) museGridTable = try $ do@@ -690,7 +696,7 @@   indices <- museGridTableHeader   fmap rowsToTable . sequence <$> many1 (museGridTableRow indent indices)   where rowsToTable rows = B.table mempty attrs [] rows-                           where attrs = const (AlignDefault, 0.0) <$> transpose rows+                           where attrs = (AlignDefault, 0.0) <$ transpose rows  -- | Parse a table. table :: PandocMonad m => MuseParser m (F Blocks)@@ -736,6 +742,7 @@       <|> br       <|> anchor       <|> footnote+      <|> strongEmph       <|> strong       <|> strongTag       <|> emph@@ -746,6 +753,8 @@       <|> strikeoutTag       <|> verbatimTag       <|> classTag+      <|> inlineRtl+      <|> inlineLtr       <|> nbsp       <|> linkOrImage       <|> code@@ -753,6 +762,7 @@       <|> mathTag       <|> inlineLiteralTag       <|> str+      <|> asterisks       <|> symbol       <?> "inline" @@ -763,12 +773,12 @@ endline :: PandocMonad m => MuseParser m (F Inlines) endline = try $ pure B.softbreak <$ newline <* notFollowedBy blankline <* updateLastSpacePos -parseAnchor :: PandocMonad m => MuseParser m String-parseAnchor = try $ (:)+parseAnchor :: PandocMonad m => MuseParser m Text+parseAnchor = try $ T.cons   <$  firstColumn   <*  char '#'   <*> letter-  <*> many (letter <|> digit <|> char '-')+  <*> manyChar (letter <|> digit <|> char '-')  anchor :: PandocMonad m => MuseParser m (F Inlines) anchor = try $ do@@ -805,24 +815,27 @@   <$  atStart   <*  p   <*  notFollowedBy space-  <*> many1Till inline (try $ noSpaceBefore *> p)-  <*  notFollowedBy alphaNum+  <*> many1Till inline (try $ noSpaceBefore *> p <* notFollowedBy alphaNum)  -- | Parse an inline tag, such as @\<em>@ and @\<strong>@. inlineTag :: PandocMonad m-          => String -- ^ Tag name+          => Text -- ^ Tag name           -> MuseParser m (F Inlines) inlineTag tag = try $ mconcat   <$  openTag tag   <*> manyTill inline (closeTag tag) +-- | Parse strong emphasis inline markup, indicated by @***@.+strongEmph :: PandocMonad m => MuseParser m (F Inlines)+strongEmph = fmap (B.strong . B.emph) <$> emphasisBetween (string "***" <* notFollowedBy (char '*'))+ -- | Parse strong inline markup, indicated by @**@. strong :: PandocMonad m => MuseParser m (F Inlines)-strong = fmap B.strong <$> emphasisBetween (string "**")+strong = fmap B.strong <$> emphasisBetween (string "**" <* notFollowedBy (char '*'))  -- | Parse emphasis inline markup, indicated by @*@. emph :: PandocMonad m => MuseParser m (F Inlines)-emph = fmap B.emph <$> emphasisBetween (char '*')+emph = fmap B.emph <$> emphasisBetween (char '*' <* notFollowedBy (char '*'))  -- | Parse underline inline markup, indicated by @_@. -- Supported only in Emacs Muse mode, not Text::Amuse.@@ -855,51 +868,67 @@ verbatimTag :: PandocMonad m => MuseParser m (F Inlines) verbatimTag = return . B.text   <$  openTag "verbatim"-  <*> manyTill anyChar (closeTag "verbatim")+  <*> manyTillChar anyChar (closeTag "verbatim")  -- | Parse @\<class>@ tag. classTag :: PandocMonad m => MuseParser m (F Inlines) classTag = do-  classes <- maybe [] words . lookup "name" <$> openTag "class"+  classes <- maybe [] T.words . lookup "name" <$> openTag "class"   fmap (B.spanWith ("", classes, [])) . mconcat <$> manyTill inline (closeTag "class") +-- | Parse @\<\<\<RTL>>>@ text.+inlineRtl :: PandocMonad m => MuseParser m (F Inlines)+inlineRtl = try $+  fmap (B.spanWith ("", [], [("dir", "rtl")])) . mconcat <$ string "<<<" <*> manyTill inline (string ">>>")++-- | Parse @\<\<\<LTR>>>@ text.+inlineLtr :: PandocMonad m => MuseParser m (F Inlines)+inlineLtr = try $+  fmap (B.spanWith ("", [], [("dir", "ltr")])) . mconcat <$ string ">>>" <*> manyTill inline (string "<<<")+ -- | Parse "~~" as nonbreaking space. nbsp :: PandocMonad m => MuseParser m (F Inlines) nbsp = try $ pure (B.str "\160") <$ string "~~"  -- | Parse code markup, indicated by @\'=\'@ characters. code :: PandocMonad m => MuseParser m (F Inlines)-code = try $ fmap pure $ B.code . uncurry (++)+code = try $ fmap pure $ B.code . uncurry (<>)   <$  atStart   <*  char '='   <*  notFollowedBy (spaceChar <|> newline)-  <*> manyUntil (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) (try $ fmap pure $ noneOf " \t\n\r=" <* char '=')+  <*> manyUntilChar (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) (try $ fmap T.singleton $ noneOf " \t\n\r=" <* char '=')   <*  notFollowedBy alphaNum  -- | Parse @\<code>@ tag. codeTag :: PandocMonad m => MuseParser m (F Inlines) codeTag = fmap pure $ B.codeWith   <$> (htmlAttrToPandoc <$> openTag "code")-  <*> manyTill anyChar (closeTag "code")+  <*> manyTillChar anyChar (closeTag "code")  -- | Parse @\<math>@ tag. -- @\<math>@ tag is an Emacs Muse extension enabled by @(require 'muse-latex2png)@ mathTag :: PandocMonad m => MuseParser m (F Inlines) mathTag = return . B.math   <$  openTag "math"-  <*> manyTill anyChar (closeTag "math")+  <*> manyTillChar anyChar (closeTag "math")  -- | Parse inline @\<literal>@ tag as a raw inline. inlineLiteralTag :: PandocMonad m => MuseParser m (F Inlines) inlineLiteralTag = try $ fmap pure $ B.rawInline   <$> (fromMaybe "html" . lookup "style" <$> openTag "literal") -- FIXME: Emacs Muse inserts <literal> without style into all output formats, but we assume HTML-  <*> manyTill anyChar (closeTag "literal")+  <*> manyTillChar anyChar (closeTag "literal")  str :: PandocMonad m => MuseParser m (F Inlines)-str = return . B.str <$> many1 alphaNum <* updateLastStrPos+str = return . B.str <$> many1Char alphaNum <* updateLastStrPos +-- | Consume asterisks that were not used as emphasis opening.+-- This prevents series of asterisks from being split into+-- literal asterisk and emphasis opening.+asterisks :: PandocMonad m => MuseParser m (F Inlines)+asterisks = pure . B.str <$> many1Char (char '*')+ symbol :: PandocMonad m => MuseParser m (F Inlines)-symbol = pure . B.str . pure <$> nonspaceChar+symbol = pure . B.str . T.singleton <$> nonspaceChar  -- | Parse a link or image. linkOrImage :: PandocMonad m => MuseParser m (F Inlines)@@ -911,12 +940,12 @@   <*> manyTill inline (char ']')  -- | Parse a link starting with (possibly null) prefix-link :: PandocMonad m => String -> MuseParser m (F Inlines)+link :: PandocMonad m => Text -> MuseParser m (F Inlines) link prefix = try $ do   inLink <- asks museInLink   guard $ not inLink-  string $ "[[" ++ prefix-  url <- manyTill anyChar $ char ']'+  textStr $ "[[" <> prefix+  url <- manyTillChar anyChar $ char ']'   content <- option (pure $ B.str url) (local (\s -> s { museInLink = True }) linkContent)   char ']'   return $ B.link url "" <$> content@@ -924,27 +953,27 @@ image :: PandocMonad m => MuseParser m (F Inlines) image = try $ do   string "[["-  (url, (ext, width, align)) <- manyUntil (noneOf "]") (imageExtensionAndOptions <* char ']')+  (url, (ext, width, align)) <- manyUntilChar (noneOf "]") (imageExtensionAndOptions <* char ']')   content <- option mempty linkContent   char ']'   let widthAttr = case align of-                    Just 'f' -> [("width", fromMaybe "100" width ++ "%"), ("height", "75%")]-                    _ -> maybeToList (("width",) . (++ "%") <$> width)+                    Just 'f' -> [("width", fromMaybe "100" width <> "%"), ("height", "75%")]+                    _ -> maybeToList (("width",) . (<> "%") <$> width)   let alignClass = case align of                      Just 'r' -> ["align-right"]                      Just 'l' -> ["align-left"]                      Just 'f' -> []                      _        -> []-  return $ B.imageWith ("", alignClass, widthAttr) (url ++ ext) mempty <$> content+  return $ B.imageWith ("", alignClass, widthAttr) (url <> ext) mempty <$> content   where -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el         imageExtensions = [".eps", ".gif", ".jpg", ".jpeg", ".pbm", ".png", ".tiff", ".xbm", ".xpm"]-        imageExtension = choice (try . string <$> imageExtensions)+        imageExtension = choice (try . textStr <$> imageExtensions)         imageExtensionAndOptions = do           ext <- imageExtension           (width, align) <- option (Nothing, Nothing) imageAttrs           return (ext, width, align)         imageAttrs = (,)           <$  many1 spaceChar-          <*> optionMaybe (many1 digit)+          <*> optionMaybe (many1Char digit)           <*  many spaceChar           <*> optionMaybe (oneOf "rlf")
src/Text/Pandoc/Readers/Native.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Native    Copyright   : Copyright (C) 2011-2019 John MacFarlane@@ -19,7 +20,7 @@ import Text.Pandoc.Shared (safeRead)  import Control.Monad.Except (throwError)-import Data.Text (Text, unpack)+import Data.Text (Text) import Text.Pandoc.Class import Text.Pandoc.Error @@ -38,18 +39,18 @@            -> Text       -- ^ String to parse (assuming @'\n'@ line endings)            -> m Pandoc readNative _ s =-  case maybe (Pandoc nullMeta <$> readBlocks s) Right (safeRead (unpack s)) of+  case maybe (Pandoc nullMeta <$> readBlocks s) Right (safeRead s) of     Right doc -> return doc     Left _    -> throwError $ PandocParseError "couldn't read native"  readBlocks :: Text -> Either PandocError [Block]-readBlocks s = maybe ((:[]) <$> readBlock s) Right (safeRead (unpack s))+readBlocks s = maybe ((:[]) <$> readBlock s) Right (safeRead s)  readBlock :: Text -> Either PandocError Block-readBlock s = maybe (Plain <$> readInlines s) Right (safeRead (unpack s))+readBlock s = maybe (Plain <$> readInlines s) Right (safeRead s)  readInlines :: Text -> Either PandocError [Inline]-readInlines s = maybe ((:[]) <$> readInline s) Right (safeRead (unpack s))+readInlines s = maybe ((:[]) <$> readInline s) Right (safeRead s)  readInline :: Text -> Either PandocError Inline-readInline s = maybe (Left . PandocParseError $ "Could not read: " ++ unpack s) Right (safeRead (unpack s))+readInline s = maybe (Left . PandocParseError $ "Could not read: " <> s) Right (safeRead s)
src/Text/Pandoc/Readers/OPML.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.OPML    Copyright   : Copyright (C) 2013-2019 John MacFarlane@@ -18,7 +19,8 @@ import Data.Default import Data.Generics import Data.Maybe (fromMaybe)-import Data.Text (Text, pack, unpack)+import Data.Text (Text)+import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Builder import Text.Pandoc.Class (PandocMonad)@@ -50,7 +52,7 @@ readOPML opts inp  = do   (bs, st') <- runStateT                  (mapM parseBlock $ normalizeTree $-                    parseXML (unpack (crFilter inp))) def{ opmlOptions = opts }+                    parseXML (T.unpack (crFilter inp))) def{ opmlOptions = opts }   return $     setTitle (opmlDocTitle st') $     setAuthors (opmlDocAuthors st') $@@ -76,23 +78,26 @@ convertEntity e = Data.Maybe.fromMaybe (map toUpper e) (lookupEntity e)  -- convenience function to get an attribute value, defaulting to ""-attrValue :: String -> Element -> String+attrValue :: String -> Element -> Text attrValue attr elt =-  fromMaybe "" (lookupAttrBy (\x -> qName x == attr) (elAttribs elt))+  maybe "" T.pack (lookupAttrBy (\x -> qName x == attr) (elAttribs elt)) +textContent :: Element -> Text+textContent = T.pack . strContent+ -- exceptT :: PandocMonad m => Either PandocError a -> OPML m a -- exceptT = either throwError return -asHtml :: PandocMonad m => String -> OPML m Inlines+asHtml :: PandocMonad m => Text -> OPML m Inlines asHtml s = do   opts <- gets opmlOptions-  Pandoc _ bs <- readHtml def{ readerExtensions = readerExtensions opts } (pack s)+  Pandoc _ bs <- readHtml def{ readerExtensions = readerExtensions opts } s   return $ blocksToInlines' bs -asMarkdown :: PandocMonad m => String -> OPML m Blocks+asMarkdown :: PandocMonad m => Text -> OPML m Blocks asMarkdown s = do   opts <- gets opmlOptions-  Pandoc _ bs <- readMarkdown def{ readerExtensions = readerExtensions opts }  (pack s)+  Pandoc _ bs <- readMarkdown def{ readerExtensions = readerExtensions opts } s   return $ fromList bs  getBlocks :: PandocMonad m => Element -> OPML m Blocks@@ -102,11 +107,11 @@ parseBlock (Elem e) =   case qName (elName e) of         "ownerName"    -> mempty <$ modify (\st ->-                              st{opmlDocAuthors = [text $ strContent e]})+                              st{opmlDocAuthors = [text $ textContent e]})         "dateModified" -> mempty <$ modify (\st ->-                              st{opmlDocDate = text $ strContent e})+                              st{opmlDocDate = text $ textContent e})         "title"        -> mempty <$ modify (\st ->-                              st{opmlDocTitle = text $ strContent e})+                              st{opmlDocTitle = text $ textContent e})         "outline" -> gets opmlSectionLevel >>= sect . (+1)         "?xml"  -> return mempty         _       -> getBlocks e@@ -115,7 +120,7 @@                      modify $ \st -> st{ opmlSectionLevel = n }                      bs <- getBlocks e                      modify $ \st -> st{ opmlSectionLevel = n - 1 }-                     let headerText' = case map toUpper (attrValue "type" e) of+                     let headerText' = case T.toUpper (attrValue "type" e) of                                              "LINK"  -> link                                                (attrValue "url" e) "" headerText                                              _ -> headerText
src/Text/Pandoc/Readers/Odt.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE PatternGuards #-}+{-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Reader.Odt    Copyright   : Copyright (C) 2015 Martin Linnemann@@ -86,9 +87,8 @@     where       filePathIsOdtMedia :: FilePath -> Bool       filePathIsOdtMedia fp =-        let (dir, _) = splitFileName fp-        in-         (dir == "Pictures/")+        let (dir, name) = splitFileName fp+        in  (dir == "Pictures/") || (dir /= "./" && name == "content.xml")   --
src/Text/Pandoc/Readers/Odt/ContentReader.hs view
@@ -1,9 +1,12 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE Arrows          #-}-{-# LANGUAGE PatternGuards   #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE TupleSections   #-}-{-# LANGUAGE ViewPatterns    #-}+{-# LANGUAGE Arrows            #-}+{-# LANGUAGE DeriveFoldable    #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE RecordWildCards   #-}+{-# LANGUAGE TupleSections     #-}+{-# LANGUAGE ViewPatterns      #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Odt.ContentReader    Copyright   : Copyright (C) 2015 Martin Linnemann@@ -26,21 +29,27 @@ import Control.Arrow  import qualified Data.ByteString.Lazy as B-import Data.List (find, intercalate)+import Data.Foldable (fold)+import Data.List (find, stripPrefix) import qualified Data.Map as M+import qualified Data.Text as T import Data.Maybe+import Data.Semigroup (First(..), Option(..)) +import Text.TeXMath (readMathML, writeTeX) import qualified Text.XML.Light as XML  import Text.Pandoc.Builder import Text.Pandoc.MediaBag (MediaBag, insertMedia) import Text.Pandoc.Shared import Text.Pandoc.Extensions (extensionsFromList, Extension(..))+import qualified Text.Pandoc.UTF8 as UTF8  import Text.Pandoc.Readers.Odt.Base import Text.Pandoc.Readers.Odt.Namespaces import Text.Pandoc.Readers.Odt.StyleReader +import Text.Pandoc.Readers.Odt.Arrows.State (foldS) import Text.Pandoc.Readers.Odt.Arrows.Utils import Text.Pandoc.Readers.Odt.Generic.Fallible import Text.Pandoc.Readers.Odt.Generic.Utils@@ -52,7 +61,7 @@ -- State -------------------------------------------------------------------------------- -type Anchor = String+type Anchor = T.Text type Media = [(FilePath, B.ByteString)]  data ReaderState@@ -197,21 +206,21 @@                )            >>^ fst -lookupResource :: OdtReaderSafe String (FilePath, B.ByteString)+lookupResource :: OdtReaderSafe FilePath (FilePath, B.ByteString) lookupResource = proc target -> do     state <- getExtraState -< ()     case lookup target (getMediaEnv state) of       Just bs -> returnV (target, bs) -<< ()       Nothing -> returnV ("", B.empty) -< () -type AnchorPrefix = String+type AnchorPrefix = T.Text  -- | An adaptation of 'uniqueIdent' from "Text.Pandoc.Shared" that generates a -- unique identifier but without assuming that the id should be for a header. -- Second argument is a list of already used identifiers. uniqueIdentFrom :: AnchorPrefix -> [Anchor] -> Anchor uniqueIdentFrom baseIdent usedIdents =-  let  numIdent n = baseIdent ++ "-" ++ show n+  let  numIdent n = baseIdent <> "-" <> T.pack (show n)   in  if baseIdent `elem` usedIdents         then case find (\x -> numIdent x `notElem` usedIdents) ([1..60000] :: [Int]) of                   Just x  -> numIdent x@@ -298,7 +307,7 @@     isCodeStyle _             = False      inlineCode :: Inlines -> Inlines-    inlineCode = code . intercalate "" . map stringify . toList+    inlineCode = code . T.concat . map stringify . toList  type PropertyTriple = (ReaderState, TextProperties, Maybe StyleFamily) type InlineModifier = Inlines -> Inlines@@ -498,6 +507,13 @@ type BlockMatcher  = ElementMatcher Blocks  +newtype FirstMatch a = FirstMatch (Option (First a))+                     deriving (Foldable, Monoid, Semigroup)++firstMatch :: a -> FirstMatch a+firstMatch = FirstMatch . Option . Just . First++ -- matchingElement :: (Monoid e)                 => Namespace -> ElementName@@ -521,7 +537,6 @@                      ->  OdtReaderSafe _x result matchChildContent ls fallback = returnV mempty >>> matchContent ls fallback - -------------------------------------------- -- Matchers --------------------------------------------@@ -542,8 +557,8 @@                             )                        >>?% mappend     ---    extractText     :: XML.Content -> Fallible String-    extractText (XML.Text cData) = succeedWith (XML.cdData cData)+    extractText     :: XML.Content -> Fallible T.Text+    extractText (XML.Text cData) = succeedWith (T.pack $ XML.cdData cData)     extractText         _        = failEmpty  read_text_seq :: InlineMatcher@@ -598,7 +613,7 @@                                         , read_reference_start                                         , read_bookmark_ref                                         , read_reference_ref-                                        , read_maybe_nested_img_frame+                                        , read_frame                                         , read_text_seq                                         ] read_plain_text @@ -624,7 +639,7 @@                                   , read_reference_start                                   , read_bookmark_ref                                   , read_reference_ref-                                  , read_maybe_nested_img_frame+                                  , read_frame                                   ] read_plain_text               ) -< blocks   anchor   <- getHeaderAnchor -< children@@ -661,8 +676,8 @@ read_link        :: InlineMatcher read_link         = matchingElement NsText "a"                     $ liftA3 link-                      ( findAttrWithDefault NsXLink  "href"  ""              )-                      ( findAttrWithDefault NsOffice "title" ""              )+                      ( findAttrTextWithDefault NsXLink  "href"  ""          )+                      ( findAttrTextWithDefault NsOffice "title" ""          )                       ( matchChildContent [ read_span                                           , read_note                                           , read_citation@@ -695,12 +710,12 @@ read_citation     = matchingElement NsText "bibliography-mark"                     $ liftA2 cite                       ( liftA2 makeCitation-                        ( findAttrWithDefault NsText "identifier" ""     )+                        ( findAttrTextWithDefault NsText "identifier" "" )                         ( readAttrWithDefault NsText "number" 0          )                       )                       ( matchChildContent [] read_plain_text             )   where-   makeCitation :: String -> Int -> [Citation]+   makeCitation :: T.Text -> Int -> [Citation]    makeCitation citeId num = [Citation citeId [] [] NormalCitation num 0]  @@ -737,34 +752,45 @@                                           ]  ------------------------- Images+-- Frames ----------------------  ---read_maybe_nested_img_frame  :: InlineMatcher-read_maybe_nested_img_frame   = matchingElement NsDraw "frame"-                                $ proc blocks -> do-                                   img <- (findChild' NsDraw "image") -< ()-                                   case img of-                                     Just _  ->  read_frame                                 -< blocks-                                     Nothing ->  matchChildContent' [ read_frame_text_box ] -< blocks+read_frame :: InlineMatcher+read_frame = matchingElement NsDraw "frame"+             $ filterChildrenName' NsDraw (`elem` ["image", "object", "text-box"])+           >>> foldS read_frame_child+           >>> arr fold -read_frame :: OdtReaderSafe Inlines Inlines-read_frame =-  proc blocks -> do-   let exts = extensionsFromList [Ext_auto_identifiers]-   w          <- ( findAttr' NsSVG "width" )                 -< ()-   h          <- ( findAttr' NsSVG "height" )                -< ()-   titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks-   src        <-  matchChildContent' [ read_image_src ]      -< blocks-   resource   <- lookupResource                              -< src-   _          <- updateMediaWithResource                     -< resource-   alt        <- (matchChildContent [] read_plain_text)      -< blocks-   arr (uncurry4 imageWith ) -<-                (image_attributes w h, src,-                   inlineListToIdentifier exts (toList titleNodes), alt)+read_frame_child :: OdtReaderSafe XML.Element (FirstMatch Inlines)+read_frame_child =+  proc child -> case elName child of+    "image"    -> read_frame_img      -< child+    "object"   -> read_frame_mathml   -< child+    "text-box" -> read_frame_text_box -< child+    _          -> returnV mempty      -< () -image_attributes :: Maybe String -> Maybe String -> Attr+read_frame_img :: OdtReaderSafe XML.Element (FirstMatch Inlines)+read_frame_img =+  proc img -> do+    src <- executeIn (findAttr' NsXLink "href") -< img+    case fold src of+      ""   -> returnV mempty -< ()+      src' -> do+        let exts = extensionsFromList [Ext_auto_identifiers]+        resource   <- lookupResource                          -< src'+        _          <- updateMediaWithResource                 -< resource+        w          <- findAttrText' NsSVG "width"             -< ()+        h          <- findAttrText' NsSVG "height"            -< ()+        titleNodes <- matchChildContent' [ read_frame_title ] -< ()+        alt        <- matchChildContent [] read_plain_text    -< ()+        arr (firstMatch . uncurry4 imageWith)                 -<+          (image_attributes w h, T.pack src', inlineListToIdentifier exts (toList titleNodes), alt)++read_frame_title :: InlineMatcher+read_frame_title = matchingElement NsSVG "title" (matchChildContent [] read_plain_text)++image_attributes :: Maybe T.Text -> Maybe T.Text -> Attr image_attributes x y =   ( "", [], (dim "width" x) ++ (dim "height" y))   where@@ -772,28 +798,29 @@     dim name (Just v) = [(name, v)]     dim _ Nothing     = [] -read_image_src :: (Namespace, ElementName, OdtReader Anchor Anchor)-read_image_src = matchingElement NsDraw "image"-                 $ proc _ -> do-                    imgSrc <- findAttr NsXLink "href" -< ()-                    case imgSrc of-                      Right src -> returnV src -<< ()-                      Left _    -> returnV ""  -< ()--read_frame_title :: InlineMatcher-read_frame_title = matchingElement NsSVG "title" (matchChildContent [] read_plain_text)+read_frame_mathml :: OdtReaderSafe XML.Element (FirstMatch Inlines)+read_frame_mathml =+  proc obj -> do+    src <- executeIn (findAttr' NsXLink "href") -< obj+    case fold src of+      ""   -> returnV mempty -< ()+      src' -> do+        let path = fromMaybe src' (stripPrefix "./" src') ++ "/content.xml"+        (_, mathml) <- lookupResource -< path+        case readMathML (UTF8.toText $ B.toStrict mathml) of+          Left _     -> returnV mempty -< ()+          Right exps -> arr (firstMatch . displayMath . writeTeX) -< exps -read_frame_text_box :: InlineMatcher-read_frame_text_box = matchingElement NsDraw "text-box"-                      $ proc blocks -> do-                         paragraphs <- (matchChildContent' [ read_paragraph ]) -< blocks-                         arr read_img_with_caption                             -< toList paragraphs+read_frame_text_box :: OdtReaderSafe XML.Element (FirstMatch Inlines)+read_frame_text_box = proc box -> do+    paragraphs <- executeIn (matchChildContent' [ read_paragraph ]) -< box+    arr read_img_with_caption -< toList paragraphs -read_img_with_caption :: [Block] -> Inlines+read_img_with_caption :: [Block] -> FirstMatch Inlines read_img_with_caption (Para [Image attr alt (src,title)] : _) =-  singleton (Image attr alt (src, 'f':'i':'g':':':title))   -- no text, default caption+  firstMatch $ singleton (Image attr alt (src, "fig:" <> title))   -- no text, default caption read_img_with_caption (Para (Image attr _ (src,title) : txt) : _) =-  singleton (Image attr txt (src, 'f':'i':'g':':':title) )  -- override caption with the text that follows+  firstMatch $ singleton (Image attr txt (src, "fig:" <> title) )  -- override caption with the text that follows read_img_with_caption  ( Para (_ : xs) : ys) =   read_img_with_caption (Para xs : ys) read_img_with_caption _ =@@ -803,12 +830,12 @@ -- Internal links ---------------------- -_ANCHOR_PREFIX_ :: String+_ANCHOR_PREFIX_ :: T.Text _ANCHOR_PREFIX_ = "anchor"  -- readAnchorAttr :: OdtReader _x Anchor-readAnchorAttr = findAttr NsText "name"+readAnchorAttr = findAttrText NsText "name"  -- | Beware: may fail findAnchorName :: OdtReader AnchorPrefix Anchor@@ -849,7 +876,7 @@  -- | Beware: may fail findAnchorRef :: OdtReader _x Anchor-findAnchorRef = (      findAttr NsText "ref-name"+findAnchorRef = (      findAttrText NsText "ref-name"                   >>?^ (_ANCHOR_PREFIX_,)                 ) >>?! getPrettyAnchor @@ -864,7 +891,7 @@     Left _ -> returnA -< inlines   where     toAnchorRef :: Anchor -> Inlines -> Inlines-    toAnchorRef anchor = link ('#':anchor) "" -- no title+    toAnchorRef anchor = link ("#" <> anchor) "" -- no title  -- read_bookmark_ref :: InlineMatcher@@ -901,8 +928,8 @@ post_process' bs = bs  read_body :: OdtReader _x (Pandoc, MediaBag)-read_body = executeIn NsOffice "body"-          $ executeIn NsOffice "text"+read_body = executeInSub NsOffice "body"+          $ executeInSub NsOffice "text"           $ liftAsSuccess           $ proc inlines -> do              txt   <- read_text     -< inlines
src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs view
@@ -29,20 +29,26 @@ , modifyExtraState , producingExtraState , findChild'+, filterChildrenName' , isSet' , isSetWithDefault+, elName , searchAttr , lookupAttr , lookupAttr' , lookupDefaultingAttr , findAttr'+, findAttrText' , findAttr+, findAttrText , findAttrWithDefault+, findAttrTextWithDefault , readAttr , readAttr' , readAttrWithDefault , getAttr , executeIn+, executeInSub , withEveryL , tryAll , matchContent'@@ -56,6 +62,7 @@  import           Data.Either ( rights ) import qualified Data.Map             as M+import qualified Data.Text            as T import           Data.Default import           Data.Maybe @@ -76,6 +83,7 @@ type ElementName           = String type AttributeName         = String type AttributeValue        = String+type TextAttributeValue    = T.Text  -- type NameSpacePrefix       = String@@ -309,34 +317,44 @@  -- | Given a namespace id and an element name, creates a 'XML.QName' for -- internal use-elemName                 :: (NameSpaceID nsID)+qualifyName              :: (NameSpaceID nsID)                          => nsID -> ElementName                          -> XMLConverter nsID extraState x XML.QName-elemName nsID name       =         lookupNSiri nsID+qualifyName nsID name    =         lookupNSiri nsID                                &&& lookupNSprefix nsID                            >>% XML.QName name  -- | Checks if a given element matches both a specified namespace id+-- and a predicate+elemNameMatches          :: (NameSpaceID nsID)+                         => nsID -> (ElementName -> Bool)+                         -> XMLConverter nsID extraState XML.Element Bool+elemNameMatches nsID f    = keepingTheValue (lookupNSiri nsID) >>% hasMatchingName+  where hasMatchingName e iri = let name = XML.elName e+                                in     f (XML.qName name)+                                    && XML.qURI name == iri++-- | Checks if a given element matches both a specified namespace id -- and a specified element name elemNameIs               :: (NameSpaceID nsID)                          => nsID -> ElementName                          -> XMLConverter nsID extraState XML.Element Bool-elemNameIs nsID name     = keepingTheValue (lookupNSiri nsID) >>% hasThatName-  where hasThatName e iri = let elName = XML.elName e-                            in     XML.qName elName == name-                                && XML.qURI  elName == iri+elemNameIs nsID name     = elemNameMatches nsID (== name)  -------------------------------------------------------------------------------- -- General content -------------------------------------------------------------------------------- +elName :: XML.Element -> ElementName+elName = XML.qName . XML.elName+ -- elContent               :: XMLConverter nsID extraState x [XML.Content] elContent               =     getCurrentElement                            >>^ XML.elContent  ----------------------------------------------------------------------------------- Chilren+-- Children --------------------------------------------------------------------------------  --@@ -344,7 +362,7 @@ findChildren             :: (NameSpaceID nsID)                          => nsID -> ElementName                          -> XMLConverter nsID extraState x [XML.Element]-findChildren nsID name   =         elemName nsID name+findChildren nsID name   =         qualifyName nsID name                                &&& getCurrentElement                            >>% XML.findChildren @@ -353,7 +371,7 @@                         => nsID                         -> ElementName                         -> XMLConverter nsID extraState x (Maybe XML.Element)-findChild' nsID name    =         elemName nsID name+findChild' nsID name    =         qualifyName nsID name                               &&& getCurrentElement                           >>% XML.findChild @@ -364,6 +382,14 @@ findChild nsID name    =     findChild' nsID name                          >>> maybeToChoice +filterChildrenName'        :: (NameSpaceID nsID)+                           => nsID+                           -> (ElementName -> Bool)+                           -> XMLConverter nsID extraState x [XML.Element]+filterChildrenName' nsID f =     getCurrentElement+                             >>> arr XML.elChildren+                             >>> iterateS (keepingTheValue (elemNameMatches nsID f))+                             >>> arr (catMaybes . fmap (uncurry $ bool Nothing . Just))  -------------------------------------------------------------------------------- -- Attributes@@ -441,10 +467,20 @@ findAttr'               :: (NameSpaceID nsID)                         => nsID -> AttributeName                         -> XMLConverter nsID extraState x (Maybe AttributeValue)-findAttr' nsID attrName =         elemName nsID attrName+findAttr' nsID attrName =         qualifyName nsID attrName                               &&& getCurrentElement                           >>% XML.findAttr +-- | Return value as a (Maybe Text)+findAttrText'           :: (NameSpaceID nsID)+                        => nsID -> AttributeName+                        -> XMLConverter nsID extraState x (Maybe TextAttributeValue)+findAttrText' nsID attrName+                        =         qualifyName nsID attrName+                              &&& getCurrentElement+                          >>% XML.findAttr+                          >>^ fmap T.pack+ -- | Return value as string or fail findAttr               :: (NameSpaceID nsID)                        => nsID -> AttributeName@@ -452,6 +488,15 @@ findAttr nsID attrName =     findAttr' nsID attrName                          >>> maybeToChoice +-- | Return value as text or fail+findAttrText           :: (NameSpaceID nsID)+                       => nsID -> AttributeName+                       -> FallibleXMLConverter nsID extraState x TextAttributeValue+findAttrText nsID attrName+                       = findAttr' nsID attrName+                         >>^ fmap T.pack+                         >>> maybeToChoice+ -- | Return value as string or return provided default value findAttrWithDefault    :: (NameSpaceID nsID)                        => nsID -> AttributeName@@ -461,6 +506,15 @@                        = findAttr' nsID attrName                          >>^ fromMaybe deflt +-- | Return value as string or return provided default value+findAttrTextWithDefault :: (NameSpaceID nsID)+                        => nsID -> AttributeName+                        -> TextAttributeValue+                        -> XMLConverter nsID extraState x TextAttributeValue+findAttrTextWithDefault nsID attrName deflt+                       = findAttr' nsID attrName+                         >>^ maybe deflt T.pack+ -- | Read and return value or fail readAttr               :: (NameSpaceID nsID, Read attrValue)                        => nsID -> AttributeName@@ -537,15 +591,21 @@                           >>> jumpBack -- >>? jumpBack  would not ensure the jump.                           >>^ collapseEither --- | Do something in a sub-element, tnen come back-executeIn              :: (NameSpaceID nsID)-                       => nsID -> ElementName-                       -> FallibleXMLConverter nsID extraState f s-                       -> FallibleXMLConverter nsID extraState f s-executeIn nsID name a  =     keepingTheValue-                               (findChild nsID name)-                         >>> ignoringState liftFailure-                         >>? switchingTheStack a++-- | Do something in a specific element, then come back+executeIn   :: XMLConverter nsID extraState XML.Element s+            -> XMLConverter nsID extraState XML.Element s+executeIn a = duplicate >>> switchingTheStack a++-- | Do something in a sub-element, then come back+executeInSub              :: (NameSpaceID nsID)+                          => nsID -> ElementName+                          -> FallibleXMLConverter nsID extraState f s+                          -> FallibleXMLConverter nsID extraState f s+executeInSub nsID name a  =     keepingTheValue+                                  (findChild nsID name)+                            >>> ignoringState liftFailure+                            >>? switchingTheStack a   where liftFailure (_, (Left  f)) = Left  f         liftFailure (x, (Right e)) = Right (x, e) 
src/Text/Pandoc/Readers/Odt/StyleReader.hs view
@@ -113,7 +113,7 @@  -- | A reader for font pitches fontPitchReader :: XMLReader _s _x FontPitches-fontPitchReader = executeIn NsOffice "font-face-decls" (+fontPitchReader = executeInSub NsOffice "font-face-decls" (                           withEveryL NsStyle "font-face" (liftAsSuccess (                               findAttr' NsStyle "name"                               &&&@@ -423,7 +423,7 @@  -- readStyles :: StyleReader _x Styles-readStyles = executeIn NsOffice "styles" $ liftAsSuccess+readStyles = executeInSub NsOffice "styles" $ liftAsSuccess   $ liftA3 Styles     ( tryAll NsStyle "style"         readStyle        >>^ M.fromList )     ( tryAll NsText  "list-style"    readListStyle    >>^ M.fromList )@@ -431,7 +431,7 @@  -- readAutomaticStyles :: StyleReader _x Styles-readAutomaticStyles = executeIn NsOffice "automatic-styles" $ liftAsSuccess+readAutomaticStyles = executeInSub NsOffice "automatic-styles" $ liftAsSuccess   $ liftA3 Styles     ( tryAll NsStyle "style"         readStyle        >>^ M.fromList )     ( tryAll NsText  "list-style"    readListStyle    >>^ M.fromList )@@ -462,7 +462,7 @@ -- readTextProperties :: StyleReader _x TextProperties readTextProperties =-  executeIn NsStyle "text-properties" $ liftAsSuccess+  executeInSub NsStyle "text-properties" $ liftAsSuccess     ( liftA6 PropT        ( searchAttr   NsXSL_FO "font-style"  False isFontEmphasised )        ( searchAttr   NsXSL_FO "font-weight" False isFontBold       )@@ -501,7 +501,7 @@ -- readParaProperties :: StyleReader _x ParaProperties readParaProperties =-   executeIn NsStyle "paragraph-properties" $ liftAsSuccess+   executeInSub NsStyle "paragraph-properties" $ liftAsSuccess      ( liftA3 PropP        ( liftA2 readNumbering          ( isSet'           NsText   "number-lines"           )@@ -548,11 +548,11 @@ readListLevelStyle levelType =      readAttr NsText "level"                                >>?! keepingTheValue                                     ( liftA5 toListLevelStyle-                                      ( returnV  levelType              )-                                      ( findAttr' NsStyle "num-prefix"  )-                                      ( findAttr' NsStyle "num-suffix"  )-                                      ( getAttr   NsStyle "num-format"  )-                                      ( findAttr' NsText  "start-value" )+                                      ( returnV       levelType             )+                                      ( findAttr'     NsStyle "num-prefix"  )+                                      ( findAttr'     NsStyle "num-suffix"  )+                                      ( getAttr       NsStyle "num-format"  )+                                      ( findAttrText' NsText  "start-value" )                                     )   where   toListLevelStyle _ p s LinfNone b         = ListLevelStyle LltBullet p s LinfNone (startValue b)
src/Text/Pandoc/Readers/Org.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Org    Copyright   : Copyright (C) 2014-2019 Albert Krewinkel@@ -26,7 +27,6 @@ import Control.Monad.Reader (runReaderT)  import Data.Text (Text)-import qualified Data.Text as T  -- | Parse org-mode string and return a Pandoc document. readOrg :: PandocMonad m@@ -36,7 +36,7 @@ readOrg opts s = do   parsed <- flip runReaderT def $             readWithM parseOrg (optionsToParserState opts)-            (T.unpack (crFilter s) ++ "\n\n")+            (crFilter s <> "\n\n")   case parsed of     Right result -> return result     Left  _      -> throwError $ PandocParseError "problem parsing org"
src/Text/Pandoc/Readers/Org/BlockStarts.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Org.BlockStarts    Copyright   : Copyright (C) 2014-2019 Albert Krewinkel@@ -25,6 +26,8 @@  import Prelude import Control.Monad (void)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Readers.Org.Parsing  -- | Horizontal Line (five -- dashes or more)@@ -49,15 +52,15 @@ gridTableStart = try $ skipSpaces <* char '+' <* char '-'  -latexEnvStart :: Monad m => OrgParser m String+latexEnvStart :: Monad m => OrgParser m Text latexEnvStart = try $   skipSpaces *> string "\\begin{"              *> latexEnvName              <* string "}"              <* blankline  where-   latexEnvName :: Monad m => OrgParser m String-   latexEnvName = try $ mappend <$> many1 alphaNum <*> option "" (string "*")+   latexEnvName :: Monad m => OrgParser m Text+   latexEnvName = try $ mappend <$> many1Char alphaNum <*> option "" (textStr "*")  bulletListStart :: Monad m => OrgParser m Int bulletListStart = try $ do@@ -68,7 +71,7 @@   return (ind + 1)  genericListStart :: Monad m-                 => OrgParser m String+                 => OrgParser m Text                  -> OrgParser m Int genericListStart listMarker = try $ do   ind <- length <$> many spaceChar@@ -82,27 +85,29 @@ orderedListStart :: Monad m => OrgParser m Int orderedListStart = genericListStart orderedListMarker   -- Ordered list markers allowed in org-mode-  where orderedListMarker = mappend <$> many1 digit <*> (pure <$> oneOf ".)")+  where orderedListMarker = T.snoc <$> many1Char digit <*> oneOf ".)" -drawerStart :: Monad m => OrgParser m String+drawerStart :: Monad m => OrgParser m Text drawerStart = try $ skipSpaces *> drawerName <* skipSpaces <* newline- where drawerName = char ':' *> manyTill nonspaceChar (char ':')+ where drawerName = char ':' *> manyTillChar nonspaceChar (char ':')  metaLineStart :: Monad m => OrgParser m () metaLineStart = try $ skipSpaces <* string "#+"  commentLineStart :: Monad m => OrgParser m ()-commentLineStart = try $ skipSpaces <* string "# "+commentLineStart = try $+  -- the first char after '#' must be a plain space character or a newline+  skipSpaces <* string "#" <* lookAhead (oneOf " \n")  exampleLineStart :: Monad m => OrgParser m () exampleLineStart = () <$ try (skipSpaces *> string ": ") -noteMarker :: Monad m => OrgParser m String+noteMarker :: Monad m => OrgParser m Text noteMarker = try $ do   char '['-  choice [ many1Till digit (char ']')-         , (++) <$> string "fn:"-                <*> many1Till (noneOf "\n\r\t ") (char ']')+  choice [ many1TillChar digit (char ']')+         , (<>) <$> textStr "fn:"+                <*> many1TillChar (noneOf "\n\r\t ") (char ']')          ]  -- | Succeeds if the parser is at the end of a block.
src/Text/Pandoc/Readers/Org/Blocks.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE RecordWildCards  #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE RecordWildCards   #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Org.Blocks    Copyright   : Copyright (C) 2014-2019 Albert Krewinkel@@ -23,7 +24,7 @@ import Text.Pandoc.Readers.Org.Meta (metaExport, metaKey, metaLine) import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing-import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,+import Text.Pandoc.Readers.Org.Shared (cleanLinkText, isImageFilename,                                        originalLang, translateLang, exportsCode)  import Text.Pandoc.Builder (Blocks, Inlines)@@ -33,11 +34,13 @@ import Text.Pandoc.Shared (compactify, compactifyDL, safeRead)  import Control.Monad (foldM, guard, mzero, void)-import Data.Char (isSpace, toLower, toUpper)+import Data.Char (isSpace) import Data.Default (Default)-import Data.List (foldl', isPrefixOf)+import Data.List (foldl') import Data.Maybe (fromMaybe, isJust, isNothing)+import Data.Text (Text) +import qualified Data.Text as T import qualified Text.Pandoc.Builder as B import qualified Text.Pandoc.Walk as Walk @@ -90,10 +93,10 @@  -- | Attributes that may be added to figures (like a name or caption). data BlockAttributes = BlockAttributes-  { blockAttrName      :: Maybe String-  , blockAttrLabel     :: Maybe String+  { blockAttrName      :: Maybe Text+  , blockAttrLabel     :: Maybe Text   , blockAttrCaption   :: Maybe (F Inlines)-  , blockAttrKeyValues :: [(String, String)]+  , blockAttrKeyValues :: [(Text, Text)]   }  -- | Convert BlockAttributes into pandoc Attr@@ -103,30 +106,34 @@     ident   = fromMaybe mempty $ lookup "id" blockAttrKeyValues     classes = case lookup "class" blockAttrKeyValues of                 Nothing     -> []-                Just clsStr -> words clsStr+                Just clsStr -> T.words clsStr     kv      = filter ((`notElem` ["id", "class"]) . fst) blockAttrKeyValues   in (ident, classes, kv) -stringyMetaAttribute :: Monad m => OrgParser m (String, String)+stringyMetaAttribute :: Monad m => OrgParser m (Text, Text) stringyMetaAttribute = try $ do   metaLineStart-  attrName <- map toUpper <$> many1Till nonspaceChar (char ':')+  attrName <- T.toUpper <$> many1TillChar nonspaceChar (char ':')   skipSpaces   attrValue <- anyLine <|> ("" <$ newline)   return (attrName, attrValue) +-- | Parse a set of block attributes. Block attributes are given through+-- lines like @#+CAPTION: block caption@ or @#+ATTR_HTML: :width 20@.+-- Parsing will fail if any line contains an attribute different from+-- those attributes known to work on blocks. blockAttributes :: PandocMonad m => OrgParser m BlockAttributes blockAttributes = try $ do   kv <- many stringyMetaAttribute-  guard $ all (attrCheck . fst) kv+  guard $ all (isBlockAttr . fst) kv   let caption = foldl' (appendValues "CAPTION") Nothing kv   let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv   let name    = lookup "NAME" kv   let label   = lookup "LABEL" kv   caption' <- case caption of                    Nothing -> return Nothing-                   Just s  -> Just <$> parseFromString inlines (s ++ "\n")-  kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs+                   Just s  -> Just <$> parseFromString inlines (s <> "\n")+  kvAttrs' <- parseFromString keyValues . (<> "\n") $ fromMaybe mempty kvAttrs   return BlockAttributes            { blockAttrName = name            , blockAttrLabel = label@@ -134,27 +141,31 @@            , blockAttrKeyValues = kvAttrs'            }  where-   attrCheck :: String -> Bool-   attrCheck x = x `elem` ["NAME", "LABEL", "CAPTION", "ATTR_HTML", "RESULTS"]+   isBlockAttr :: Text -> Bool+   isBlockAttr = flip elem+                 [ "NAME", "LABEL", "CAPTION"+                 , "ATTR_HTML", "ATTR_LATEX"+                 , "RESULTS"+                 ] -   appendValues :: String -> Maybe String -> (String, String) -> Maybe String+   appendValues :: Text -> Maybe Text -> (Text, Text) -> Maybe Text    appendValues attrName accValue (key, value) =      if key /= attrName      then accValue      else case accValue of-            Just acc -> Just $ acc ++ ' ':value+            Just acc -> Just $ acc <> " " <> value             Nothing  -> Just value  -- | Parse key-value pairs for HTML attributes-keyValues :: Monad m => OrgParser m [(String, String)]+keyValues :: Monad m => OrgParser m [(Text, Text)] keyValues = try $   manyTill ((,) <$> key <*> value) newline  where-   key :: Monad m => OrgParser m String-   key = try $ skipSpaces *> char ':' *> many1 nonspaceChar+   key :: Monad m => OrgParser m Text+   key = try $ skipSpaces *> char ':' *> many1Char nonspaceChar -   value :: Monad m => OrgParser m String-   value = skipSpaces *> manyTill anyChar endOfValue+   value :: Monad m => OrgParser m Text+   value = skipSpaces *> manyTillChar anyChar endOfValue     endOfValue :: Monad m => OrgParser m ()    endOfValue =@@ -172,13 +183,13 @@   blockAttrs <- blockAttributes   blkType <- blockHeaderStart   ($ blkType) $-    case map toLower blkType of+    case T.toLower blkType of       "export"  -> exportBlock       "comment" -> rawBlockLines (const mempty)       "html"    -> rawBlockLines (return . B.rawBlock (lowercase blkType))       "latex"   -> rawBlockLines (return . B.rawBlock (lowercase blkType))       "ascii"   -> rawBlockLines (return . B.rawBlock (lowercase blkType))-      "example" -> rawBlockLines (return . exampleCode)+      "example" -> exampleBlock blockAttrs       "quote"   -> parseBlockLines (fmap B.blockQuote)       "verse"   -> verseBlock       "src"     -> codeBlock blockAttrs@@ -186,61 +197,70 @@                    let (ident, classes, kv) = attrFromBlockAttributes blockAttrs                    in fmap $ B.divWith (ident, classes ++ [blkType], kv)  where-   blockHeaderStart :: Monad m => OrgParser m String+   blockHeaderStart :: Monad m => OrgParser m Text    blockHeaderStart = try $ skipSpaces *> stringAnyCase "#+begin_" *> orgArgWord -   lowercase :: String -> String-   lowercase = map toLower+   lowercase :: Text -> Text+   lowercase = T.toLower -rawBlockLines :: Monad m => (String   -> F Blocks) -> String -> OrgParser m (F Blocks)+exampleBlock :: PandocMonad m => BlockAttributes -> Text -> OrgParser m (F Blocks)+exampleBlock blockAttrs _label = do+  skipSpaces+  (classes, kv) <- switchesAsAttributes+  newline+  content <- rawBlockContent "example"+  let id' = fromMaybe mempty $ blockAttrName blockAttrs+  let codeBlck = B.codeBlockWith (id', "example":classes, kv) content+  return . return $ codeBlck++rawBlockLines :: Monad m => (Text   -> F Blocks) -> Text -> OrgParser m (F Blocks) rawBlockLines f blockType = ignHeaders *> (f <$> rawBlockContent blockType) -parseBlockLines :: PandocMonad m => (F Blocks -> F Blocks) -> String -> OrgParser m (F Blocks)+parseBlockLines :: PandocMonad m => (F Blocks -> F Blocks) -> Text -> OrgParser m (F Blocks) parseBlockLines f blockType = ignHeaders *> (f <$> parsedBlockContent)  where    parsedBlockContent :: PandocMonad m => OrgParser m (F Blocks)    parsedBlockContent = try $ do      raw <- rawBlockContent blockType-     parseFromString blocks (raw ++ "\n")+     parseFromString blocks (raw <> "\n")  -- | Read the raw string content of a block-rawBlockContent :: Monad m => String -> OrgParser m String+rawBlockContent :: Monad m => Text -> OrgParser m Text rawBlockContent blockType = try $ do   blkLines <- manyTill rawLine blockEnder   tabLen <- getOption readerTabStop-  return-    . unlines-    . stripIndent-    . map (tabsToSpaces tabLen . commaEscaped)-    $ blkLines+  trimP <- orgStateTrimLeadBlkIndent <$> getState+  let stripIndent strs = if trimP then map (T.drop (shortestIndent strs)) strs else strs+  (T.unlines+   . stripIndent+   . map (tabsToSpaces tabLen . commaEscaped)+   $ blkLines)+   <$ updateState (\s -> s { orgStateTrimLeadBlkIndent = True })  where-   rawLine :: Monad m => OrgParser m String+   rawLine :: Monad m => OrgParser m Text    rawLine = try $ ("" <$ blankline) <|> anyLine     blockEnder :: Monad m => OrgParser m ()    blockEnder = try $ skipSpaces <* stringAnyCase ("#+end_" <> blockType) -   stripIndent :: [String] -> [String]-   stripIndent strs = map (drop (shortestIndent strs)) strs--   shortestIndent :: [String] -> Int-   shortestIndent = foldr (min . length . takeWhile isSpace) maxBound-                    . filter (not . null)+   shortestIndent :: [Text] -> Int+   shortestIndent = foldr (min . T.length . T.takeWhile isSpace) maxBound+                    . filter (not . T.null) -   tabsToSpaces :: Int -> String -> String-   tabsToSpaces _      []         = []-   tabsToSpaces tabLen cs'@(c:cs) =-       case c of-         ' '  -> ' ':tabsToSpaces tabLen cs-         '\t' -> replicate tabLen ' ' ++ tabsToSpaces tabLen cs-         _    -> cs'+   tabsToSpaces :: Int -> Text -> Text+   tabsToSpaces tabStop t =+     let (ind, suff) = T.span (\c -> c == ' ' || c == '\t') t+         tabNum      = T.length $ T.filter (== '\n') ind+         spaceNum    = T.length ind - tabNum+     in  T.replicate (spaceNum + tabStop * tabNum) " " <> suff -   commaEscaped :: String -> String-   commaEscaped (',':cs@('*':_))     = cs-   commaEscaped (',':cs@('#':'+':_)) = cs-   commaEscaped (' ':cs)             = ' ':commaEscaped cs-   commaEscaped ('\t':cs)            = '\t':commaEscaped cs-   commaEscaped cs                   = cs+   commaEscaped t =+     let (ind, suff) = T.span (\c -> c == ' ' || c == '\t') t+     in  case T.uncons suff of+           Just (',', cs)+             | "*"  <- T.take 1 cs -> ind <> cs+             | "#+" <- T.take 2 cs -> ind <> cs+           _                       -> t  -- | Read but ignore all remaining block headers. ignHeaders :: Monad m => OrgParser m ()@@ -248,34 +268,34 @@  -- | Read a block containing code intended for export in specific backends -- only.-exportBlock :: Monad m => String -> OrgParser m (F Blocks)+exportBlock :: Monad m => Text -> OrgParser m (F Blocks) exportBlock blockType = try $ do   exportType <- skipSpaces *> orgArgWord <* ignHeaders   contents   <- rawBlockContent blockType-  returnF (B.rawBlock (map toLower exportType) contents)+  returnF (B.rawBlock (T.toLower exportType) contents) -verseBlock :: PandocMonad m => String -> OrgParser m (F Blocks)+verseBlock :: PandocMonad m => Text -> OrgParser m (F Blocks) verseBlock blockType = try $ do   ignHeaders   content <- rawBlockContent blockType   fmap B.lineBlock . sequence-    <$> mapM parseVerseLine (lines content)+    <$> mapM parseVerseLine (T.lines content)  where    -- replace initial spaces with nonbreaking spaces to preserve    -- indentation, parse the rest as normal inline-   parseVerseLine :: PandocMonad m => String -> OrgParser m (F Inlines)+   parseVerseLine :: PandocMonad m => Text -> OrgParser m (F Inlines)    parseVerseLine cs = do-     let (initialSpaces, indentedLine) = span isSpace cs-     let nbspIndent = if null initialSpaces+     let (initialSpaces, indentedLine) = T.span isSpace cs+     let nbspIndent = if T.null initialSpaces                       then mempty-                      else B.str $ map (const '\160') initialSpaces-     line <- parseFromString inlines (indentedLine ++ "\n")+                      else B.str $ T.map (const '\160') initialSpaces+     line <- parseFromString inlines (indentedLine <> "\n")      return (trimInlinesF $ pure nbspIndent <> line)  -- | Read a code block and the associated results block if present.  Which of -- boths blocks is included in the output is determined using the "exports" -- argument in the block header.-codeBlock :: PandocMonad m => BlockAttributes -> String -> OrgParser m (F Blocks)+codeBlock :: PandocMonad m => BlockAttributes -> Text -> OrgParser m (F Blocks) codeBlock blockAttrs blockType = do   skipSpaces   (classes, kv)     <- codeHeaderArgs <|> (mempty <$ ignHeaders)@@ -297,7 +317,7 @@    labelledBlock :: F Inlines -> F Blocks    labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], [])) -   exportsResults :: [(String, String)] -> Bool+   exportsResults :: [(Text, Text)] -> Bool    exportsResults = maybe False (`elem` ["results", "both"]) . lookup "exports"  -- | Parse the result of an evaluated babel code block.@@ -312,7 +332,7 @@   resultsMarker = try . void $ stringAnyCase "#+RESULTS:" *> blankline  -- | Parse code block arguments-codeHeaderArgs :: Monad m => OrgParser m ([String], [(String, String)])+codeHeaderArgs :: Monad m => OrgParser m ([Text], [(Text, Text)]) codeHeaderArgs = try $ do   language   <- skipSpaces *> orgArgWord   (switchClasses, switchKv) <- switchesAsAttributes@@ -321,14 +341,14 @@          , originalLang language <> switchKv <> parameters          ) -switchesAsAttributes :: Monad m => OrgParser m ([String], [(String, String)])+switchesAsAttributes :: Monad m => OrgParser m ([Text], [(Text, Text)]) switchesAsAttributes = try $ do   switches <- skipSpaces *> try (switch `sepBy` many1 spaceChar)   return $ foldr addToAttr ([], []) switches  where-  addToAttr :: (Char, Maybe String, SwitchPolarity)-            -> ([String], [(String, String)])-            -> ([String], [(String, String)])+  addToAttr :: (Char, Maybe Text, SwitchPolarity)+            -> ([Text], [(Text, Text)])+            -> ([Text], [(Text, Text)])   addToAttr ('n', lineNum, pol) (cls, kv) =     let kv' = case lineNum of                 Just num -> ("startFrom", num):kv@@ -348,18 +368,25 @@ switchPolarity = (SwitchMinus <$ char '-') <|> (SwitchPlus <$ char '+')  -- | Parses a source block switch option.-switch :: Monad m => OrgParser m (Char, Maybe String, SwitchPolarity)-switch = try $ lineNumberSwitch <|> labelSwitch <|> simpleSwitch+switch :: Monad m => OrgParser m (Char, Maybe Text, SwitchPolarity)+switch = try $ lineNumberSwitch <|> labelSwitch+               <|> whitespaceSwitch <|> simpleSwitch  where    simpleSwitch = (\pol c -> (c, Nothing, pol)) <$> switchPolarity <*> letter    labelSwitch = genericSwitch 'l' $-     char '"' *> many1Till nonspaceChar (char '"')+     char '"' *> many1TillChar nonspaceChar (char '"') +whitespaceSwitch :: Monad m => OrgParser m (Char, Maybe Text, SwitchPolarity)+whitespaceSwitch = do+  string "-i"+  updateState $ \s -> s { orgStateTrimLeadBlkIndent = False }+  return ('i', Nothing, SwitchMinus)+ -- | Generic source block switch-option parser. genericSwitch :: Monad m               => Char-              -> OrgParser m String-              -> OrgParser m (Char, Maybe String, SwitchPolarity)+              -> OrgParser m Text+              -> OrgParser m (Char, Maybe Text, SwitchPolarity) genericSwitch c p = try $ do   polarity <- switchPolarity <* char c <* skipSpaces   arg <- optionMaybe p@@ -367,17 +394,17 @@  -- | Reads a line number switch option. The line number switch can be used with -- example and source blocks.-lineNumberSwitch :: Monad m => OrgParser m (Char, Maybe String, SwitchPolarity)-lineNumberSwitch = genericSwitch 'n' (many digit)+lineNumberSwitch :: Monad m => OrgParser m (Char, Maybe Text, SwitchPolarity)+lineNumberSwitch = genericSwitch 'n' (manyChar digit) -blockOption :: Monad m => OrgParser m (String, String)+blockOption :: Monad m => OrgParser m (Text, Text) blockOption = try $ do   argKey <- orgArgKey   paramValue <- option "yes" orgParamValue   return (argKey, paramValue) -orgParamValue :: Monad m => OrgParser m String-orgParamValue = try $+orgParamValue :: Monad m => OrgParser m Text+orgParamValue = try $ fmap T.pack $   skipSpaces     *> notFollowedBy orgArgKey     *> noneOf "\n\r" `many1Till` endOfValue@@ -396,7 +423,7 @@ -- export setting. genericDrawer :: PandocMonad m => OrgParser m (F Blocks) genericDrawer = try $ do-  name    <- map toUpper <$> drawerStart+  name    <- T.toUpper <$> drawerStart   content <- manyTill drawerLine (try drawerEnd)   state   <- getState   -- Include drawer if it is explicitly included in or not explicitly excluded@@ -408,16 +435,16 @@     Right names | name `notElem` names -> return mempty     _           -> drawerDiv name <$> parseLines content  where-  parseLines :: PandocMonad m => [String] -> OrgParser m (F Blocks)-  parseLines = parseFromString blocks . (++ "\n") . unlines+  parseLines :: PandocMonad m => [Text] -> OrgParser m (F Blocks)+  parseLines = parseFromString blocks . (<> "\n") . T.unlines -  drawerDiv :: String -> F Blocks -> F Blocks+  drawerDiv :: Text -> F Blocks -> F Blocks   drawerDiv drawerName = fmap $ B.divWith (mempty, [drawerName, "drawer"], mempty) -drawerLine :: Monad m => OrgParser m String+drawerLine :: Monad m => OrgParser m Text drawerLine = anyLine -drawerEnd :: Monad m => OrgParser m String+drawerEnd :: Monad m => OrgParser m Text drawerEnd = try $   skipSpaces *> stringAnyCase ":END:" <* skipSpaces <* newline @@ -432,17 +459,17 @@ figure = try $ do   figAttrs <- blockAttributes   src <- skipSpaces *> selfTarget <* skipSpaces <* endOfParagraph-  case cleanLinkString src of+  case cleanLinkText src of     Nothing     -> mzero     Just imgSrc -> do       guard (isImageFilename imgSrc)       let isFigure = isJust $ blockAttrCaption figAttrs       return $ imageBlock isFigure figAttrs imgSrc  where-   selfTarget :: PandocMonad m => OrgParser m String+   selfTarget :: PandocMonad m => OrgParser m Text    selfTarget = try $ char '[' *> linkTarget <* char ']' -   imageBlock :: Bool -> BlockAttributes -> String -> F Blocks+   imageBlock :: Bool -> BlockAttributes -> Text -> F Blocks    imageBlock isFigure figAttrs imgSrc =      let        figName    = fromMaybe mempty $ blockAttrName figAttrs@@ -454,11 +481,11 @@      in        B.para . B.imageWith attr imgSrc figTitle <$> figCaption -   withFigPrefix :: String -> String+   withFigPrefix :: Text -> Text    withFigPrefix cs =-     if "fig:" `isPrefixOf` cs+     if "fig:" `T.isPrefixOf` cs      then cs-     else "fig:" ++ cs+     else "fig:" <> cs  -- | Succeeds if looking at the end of the current paragraph endOfParagraph :: Monad m => OrgParser m ()@@ -471,12 +498,12 @@  -- | Example code marked up by a leading colon. example :: Monad m => OrgParser m (F Blocks)-example = try $ returnF . exampleCode =<< unlines <$> many1 exampleLine+example = try $ returnF . exampleCode =<< T.unlines <$> many1 exampleLine  where-   exampleLine :: Monad m => OrgParser m String+   exampleLine :: Monad m => OrgParser m Text    exampleLine = try $ exampleLineStart *> anyLine -exampleCode :: String -> Blocks+exampleCode :: Text -> Blocks exampleCode = B.codeBlockWith ("", ["example"], [])  @@ -492,7 +519,7 @@ include = try $ do   metaLineStart <* stringAnyCase "include:" <* skipSpaces   filename <- includeTarget-  includeArgs <- many (try $ skipSpaces *> many1 alphaNum)+  includeArgs <- many (try $ skipSpaces *> many1Char alphaNum)   params <- keyValues   blocksParser <- case includeArgs of       ("example" : _) -> return $ pure . B.codeBlock <$> parseRaw@@ -511,10 +538,10 @@     char '"'     manyTill (noneOf "\n\r\t") (char '"') -  parseRaw :: PandocMonad m => OrgParser m String-  parseRaw = many anyChar+  parseRaw :: PandocMonad m => OrgParser m Text+  parseRaw = manyChar anyChar -  blockFilter :: [(String, String)] -> [Block] -> [Block]+  blockFilter :: [(Text, Text)] -> [Block] -> [Block]   blockFilter params blks =     let minlvl = lookup "minlevel" params     in case (minlvl >>= safeRead :: Maybe Int) of@@ -636,7 +663,7 @@                  <$> (skipSpaces                       *> char '<'                       *> optionMaybe tableAlignFromChar)-                 <*> (optionMaybe (many1 digit >>= safeRead)+                 <*> (optionMaybe (many1Char digit >>= safeRead)                       <* char '>'                       <* emptyCell) @@ -715,10 +742,10 @@                               , "\\end{", e, "}\n"                               ] -latexEnd :: Monad m => String -> OrgParser m ()+latexEnd :: Monad m => Text -> OrgParser m () latexEnd envName = try $   () <$ skipSpaces-     <* string ("\\end{" ++ envName ++ "}")+     <* textStr ("\\end{" <> envName <> "}")      <* blankline  @@ -772,7 +799,7 @@   fmap (B.bulletList . compactify) . sequence     <$> many1 (listItem (bulletListStart `indented` indent)) -indented :: Monad m => OrgParser m Int -> Int -> OrgParser m Int+indented :: OrgParser m Int -> Int -> OrgParser m Int indented indentedMarker minIndent = try $ do   n <- indentedMarker   guard (minIndent <= n)@@ -789,12 +816,12 @@                    -> OrgParser m (F (Inlines, [Blocks])) definitionListItem parseIndentedMarker = try $ do   markerLength <- parseIndentedMarker-  term <- manyTill (noneOf "\n\r") (try definitionMarker)+  term <- manyTillChar (noneOf "\n\r") (try definitionMarker)   line1 <- anyLineNewline   blank <- option "" ("\n" <$ blankline)-  cont <- concat <$> many (listContinuation markerLength)+  cont <- T.concat <$> many (listContinuation markerLength)   term' <- parseFromString inlines term-  contents' <- parseFromString blocks $ line1 ++ blank ++ cont+  contents' <- parseFromString blocks $ line1 <> blank <> cont   return $ (,) <$> term' <*> fmap (:[]) contents'  where    definitionMarker =@@ -808,16 +835,27 @@   markerLength <- try parseIndentedMarker   firstLine <- anyLineNewline   blank <- option "" ("\n" <$ blankline)-  rest <- concat <$> many (listContinuation markerLength)-  parseFromString blocks $ firstLine ++ blank ++ rest+  rest <- T.concat <$> many (listContinuation markerLength)+  parseFromString blocks $ firstLine <> blank <> rest  -- continuation of a list item - indented and separated by blankline or endline. -- Note: nested lists are parsed as continuations.-listContinuation :: Monad m => Int-                 -> OrgParser m String+listContinuation :: PandocMonad m => Int -> OrgParser m Text listContinuation markerLength = try $ do   notFollowedBy' blankline-  mappend <$> (concat <$> many1 listLine)-          <*> many blankline+  mappend <$> (T.concat <$> many1 (listContinuation' markerLength))+          <*> manyChar blankline  where-   listLine = try $ indentWith markerLength *> anyLineNewline+   listContinuation' indentation =+      blockLines indentation <|> listLine indentation+   listLine indentation = try $ indentWith indentation *> anyLineNewline+  -- The block attributes and start must be appropriately indented,+  -- but the contents, and end do not.+   blockLines indentation =+      try $ lookAhead (indentWith indentation+                       >> blockAttributes+                       >>= (\blockAttrs ->+                              case attrFromBlockAttributes blockAttrs of+                                ("", [], []) -> countChar 1 anyChar+                                _ -> indentWith indentation))+            >> (snd <$> withRaw orgBlock)
src/Text/Pandoc/Readers/Org/DocumentTree.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Org.DocumentTree    Copyright   : Copyright (C) 2014-2019 Albert Krewinkel@@ -17,9 +18,9 @@ import Prelude import Control.Arrow ((***)) import Control.Monad (guard, void)-import Data.Char (toLower, toUpper) import Data.List (intersperse) import Data.Maybe (mapMaybe)+import Data.Text (Text) import Text.Pandoc.Builder (Blocks, Inlines) import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition@@ -28,6 +29,7 @@ import Text.Pandoc.Readers.Org.Parsing  import qualified Data.Set as Set+import qualified Data.Text as T import qualified Text.Pandoc.Builder as B  --@@ -59,28 +61,28 @@       }  -- | Create a tag containing the given string.-toTag :: String -> Tag+toTag :: Text -> Tag toTag = Tag  -- | The key (also called name or type) of a property.-newtype PropertyKey = PropertyKey { fromKey :: String }+newtype PropertyKey = PropertyKey { fromKey :: Text }   deriving (Show, Eq, Ord)  -- | Create a property key containing the given string.  Org mode keys are -- case insensitive and are hence converted to lower case.-toPropertyKey :: String -> PropertyKey-toPropertyKey = PropertyKey . map toLower+toPropertyKey :: Text -> PropertyKey+toPropertyKey = PropertyKey . T.toLower  -- | The value assigned to a property.-newtype PropertyValue = PropertyValue { fromValue :: String }+newtype PropertyValue = PropertyValue { fromValue :: Text }  -- | Create a property value containing the given string.-toPropertyValue :: String -> PropertyValue+toPropertyValue :: Text -> PropertyValue toPropertyValue = PropertyValue  -- | Check whether the property value is non-nil (i.e. truish). isNonNil :: PropertyValue -> Bool-isNonNil p = map toLower (fromValue p) `notElem` ["()", "{}", "nil"]+isNonNil p = T.toLower (fromValue p) `notElem` ["()", "{}", "nil"]  -- | Key/value pairs from a PROPERTIES drawer type Properties = [(PropertyKey, PropertyValue)]@@ -273,7 +275,7 @@ todoKeyword :: Monad m => OrgParser m TodoMarker todoKeyword = try $ do   taskStates <- activeTodoMarkers <$> getState-  let kwParser tdm = try (tdm <$ string (todoMarkerName tdm)+  let kwParser tdm = try (tdm <$ textStr (todoMarkerName tdm)                               <* spaceChar                               <* updateLastPreCharPos)   choice (map kwParser taskStates)@@ -281,26 +283,26 @@ todoKeywordToInlines :: TodoMarker -> Inlines todoKeywordToInlines tdm =   let todoText  = todoMarkerName tdm-      todoState = map toLower . show $ todoMarkerState tdm+      todoState = T.toLower . T.pack . show $ todoMarkerState tdm       classes = [todoState, todoText]   in B.spanWith (mempty, classes, mempty) (B.str todoText)  propertiesToAttr :: Properties -> Attr propertiesToAttr properties =   let-    toStringPair = fromKey *** fromValue+    toTextPair = fromKey *** fromValue     customIdKey = toPropertyKey "custom_id"     classKey    = toPropertyKey "class"     unnumberedKey = toPropertyKey "unnumbered"     specialProperties = [customIdKey, classKey, unnumberedKey]     id'  = maybe mempty fromValue . lookup customIdKey $ properties     cls  = maybe mempty fromValue . lookup classKey    $ properties-    kvs' = map toStringPair . filter ((`notElem` specialProperties) . fst)+    kvs' = map toTextPair . filter ((`notElem` specialProperties) . fst)            $ properties     isUnnumbered =       maybe False isNonNil . lookup unnumberedKey $ properties   in-    (id', words cls ++ ["unnumbered" | isUnnumbered], kvs')+    (id', T.words cls ++ ["unnumbered" | isUnnumbered], kvs')  tagsToInlines :: [Tag] -> Inlines tagsToInlines [] = mempty@@ -336,15 +338,15 @@                   <> B.emph (B.str time)  -- | An Org timestamp, including repetition marks. TODO: improve-type Timestamp = String+type Timestamp = Text  timestamp :: Monad m => OrgParser m Timestamp timestamp = try $ do   openChar <- oneOf "<["   let isActive = openChar == '<'   let closeChar = if isActive then '>' else ']'-  content <- many1Till anyChar (char closeChar)-  return (openChar : content ++ [closeChar])+  content <- many1TillChar anyChar (char closeChar)+  return $ T.cons openChar $ content `T.snoc` closeChar  -- | Planning information for a subtree/headline. data PlanningInfo = PlanningInfo@@ -374,7 +376,7 @@ propertiesDrawer :: Monad m => OrgParser m Properties propertiesDrawer = try $ do   drawerType <- drawerStart-  guard $ map toUpper drawerType == "PROPERTIES"+  guard $ T.toUpper drawerType == "PROPERTIES"   manyTill property (try endOfDrawer)  where    property :: Monad m => OrgParser m (PropertyKey, PropertyValue)@@ -382,12 +384,12 @@     key :: Monad m => OrgParser m PropertyKey    key = fmap toPropertyKey . try $-         skipSpaces *> char ':' *> many1Till nonspaceChar (char ':')+         skipSpaces *> char ':' *> many1TillChar nonspaceChar (char ':')     value :: Monad m => OrgParser m PropertyValue    value = fmap toPropertyValue . try $-           skipSpaces *> manyTill anyChar (try $ skipSpaces *> newline)+           skipSpaces *> manyTillChar anyChar (try $ skipSpaces *> newline) -   endOfDrawer :: Monad m => OrgParser m String+   endOfDrawer :: Monad m => OrgParser m Text    endOfDrawer = try $      skipSpaces *> stringAnyCase ":END:" <* skipSpaces <* newline
src/Text/Pandoc/Readers/Org/ExportSettings.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Org.ExportSettings    Copyright   : © 2016–2019 Albert Krewinkel@@ -21,6 +22,7 @@ import Control.Monad (mzero, void) import Data.Char (toLower) import Data.Maybe (listToMaybe)+import Data.Text (Text)  -- | Read and handle space separated org-mode export settings. exportSettings :: PandocMonad m => OrgParser m ()@@ -70,11 +72,11 @@  genericExportSetting :: Monad m                      => OrgParser m a-                     -> String+                     -> Text                      -> ExportSettingSetter a                      -> OrgParser m () genericExportSetting optionParser settingIdentifier setter = try $ do-  _     <- string settingIdentifier *> char ':'+  _     <- textStr settingIdentifier *> char ':'   value <- optionParser   updateState $ modifyExportSettings value  where@@ -82,11 +84,11 @@      st { orgStateExportSettings = setter val . orgStateExportSettings $ st }  -- | A boolean option, either nil (False) or non-nil (True).-booleanSetting :: Monad m => String ->  ExportSettingSetter Bool -> OrgParser m ()+booleanSetting :: Monad m => Text ->  ExportSettingSetter Bool -> OrgParser m () booleanSetting = genericExportSetting elispBoolean  -- | An integer-valued option.-integerSetting :: Monad m => String -> ExportSettingSetter Int -> OrgParser m ()+integerSetting :: Monad m => Text -> ExportSettingSetter Int -> OrgParser m () integerSetting = genericExportSetting parseInt  where    parseInt = try $@@ -95,7 +97,7 @@ -- | Either the string "headline" or an elisp boolean and treated as an -- @ArchivedTreesOption@. archivedTreeSetting :: Monad m-                    => String+                    => Text                     -> ExportSettingSetter ArchivedTreesOption                     -> OrgParser m () archivedTreeSetting =@@ -115,42 +117,42 @@  -- | A list or a complement list (i.e. a list starting with `not`). complementableListSetting :: Monad m-                          => String-                          -> ExportSettingSetter (Either [String] [String])+                          => Text+                          -> ExportSettingSetter (Either [Text] [Text])                           -> OrgParser m () complementableListSetting = genericExportSetting $ choice-  [ Left  <$> complementStringList+  [ Left  <$> complementTextList   , Right <$> stringList   , (\b -> if b then Left [] else Right []) <$> elispBoolean   ]  where    -- Read a plain list of strings.-   stringList :: Monad m => OrgParser m [String]+   stringList :: Monad m => OrgParser m [Text]    stringList = try $      char '('-       *> sepBy elispString spaces+       *> sepBy elispText spaces        <* char ')'     -- Read an emacs lisp list specifying a complement set.-   complementStringList :: Monad m => OrgParser m [String]-   complementStringList = try $+   complementTextList :: Monad m => OrgParser m [Text]+   complementTextList = try $      string "(not "-       *> sepBy elispString spaces+       *> sepBy elispText spaces        <* char ')' -   elispString :: Monad m => OrgParser m String-   elispString = try $+   elispText :: Monad m => OrgParser m Text+   elispText = try $      char '"'-       *> manyTill alphaNum (char '"')+       *> manyTillChar alphaNum (char '"')  -- | Read but ignore the export setting.-ignoredSetting :: Monad m => String -> OrgParser m ()-ignoredSetting s = try (() <$ string s <* char ':' <* many1 nonspaceChar)+ignoredSetting :: Monad m => Text -> OrgParser m ()+ignoredSetting s = try (() <$ textStr s <* char ':' <* many1 nonspaceChar)  -- | Read any setting string, but ignore it and emit a warning. ignoreAndWarn :: PandocMonad m => OrgParser m () ignoreAndWarn = try $ do-  opt <- many1 nonspaceChar+  opt <- many1Char nonspaceChar   report (UnknownOrgExportOption opt)   return () 
src/Text/Pandoc/Readers/Org/Inlines.hs view
@@ -20,7 +20,7 @@ import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker) import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing-import Text.Pandoc.Readers.Org.Shared (cleanLinkString, isImageFilename,+import Text.Pandoc.Readers.Org.Shared (cleanLinkText, isImageFilename,                                        originalLang, translateLang, exportsCode)  import Text.Pandoc.Builder (Inlines)@@ -38,12 +38,14 @@ import Data.Char (isAlphaNum, isSpace) import Data.List (intersperse) import qualified Data.Map as M+import Data.Text (Text)+import qualified Data.Text as T import Data.Maybe (fromMaybe)  -- -- Functions acting on the parser state ---recordAnchorId :: PandocMonad m => String -> OrgParser m ()+recordAnchorId :: PandocMonad m => Text -> OrgParser m () recordAnchorId i = updateState $ \s ->   s{ orgStateAnchorIds = i : orgStateAnchorIds s } @@ -127,7 +129,7 @@ linebreak = try $ pure B.linebreak <$ string "\\\\" <* skipSpaces <* newline  str :: PandocMonad m => OrgParser m (F Inlines)-str = return . B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")+str = return . B.str <$> many1Char (noneOf $ specialChars ++ "\n\r ")       <* updateLastStrPos  -- | An endline character that can be treated as a space, not a structural@@ -153,7 +155,7 @@ -- first to be implemented here and is almost identical to Markdown's citation -- syntax.  The org-ref package is in wide use to handle citations, but the -- syntax is a bit limiting and not quite as simple to write.  The--- semi-offical Org-mode citation syntax is based on John MacFarlane's Pandoc+-- semi-official Org-mode citation syntax is based on John MacFarlane's Pandoc -- sytax and Org-oriented enhancements contributed by Richard Lawrence and -- others.  It's dubbed Berkeley syntax due the place of activity of its main -- contributors.  All this should be consolidated once an official Org-mode@@ -321,7 +323,7 @@  -- | Read a citation key.  The characters allowed in citation keys are taken -- from the `org-ref-cite-re` variable in `org-ref.el`.-orgRefCiteKey :: PandocMonad m => OrgParser m String+orgRefCiteKey :: PandocMonad m => OrgParser m Text orgRefCiteKey =   let citeKeySpecialChars = "-_:\\./," :: String       isCiteKeySpecialChar c = c `elem` citeKeySpecialChars@@ -329,7 +331,7 @@       endOfCitation = try $ do         many $ satisfy isCiteKeySpecialChar         satisfy $ not . isCiteKeyChar-  in try $ satisfy isCiteKeyChar `many1Till` lookAhead endOfCitation+  in try $ satisfy isCiteKeyChar `many1TillChar` lookAhead endOfCitation   -- | Supported citation types.  Only a small subset of org-ref types is@@ -384,11 +386,11 @@ inlineNote :: PandocMonad m => OrgParser m (F Inlines) inlineNote = try $ do   string "[fn:"-  ref <- many alphaNum+  ref <- manyChar alphaNum   char ':'   note <- fmap B.para . trimInlinesF . mconcat <$> many1Till inline (char ']')-  unless (null ref) $-       addToNotesTable ("fn:" ++ ref, note)+  unless (T.null ref) $+       addToNotesTable ("fn:" <> ref, note)   return $ B.note <$> note  referencedNote :: PandocMonad m => OrgParser m (F Inlines)@@ -397,7 +399,7 @@   return $ do     notes <- asksF orgStateNotes'     case lookup ref notes of-      Nothing   -> return . B.str $ "[" ++ ref ++ "]"+      Nothing   -> return . B.str $ "[" <> ref <> "]"       Just contents  -> do         st <- askF         let contents' = runF contents st{ orgStateNotes' = [] }@@ -420,7 +422,7 @@   return $ do     src <- srcF     title <- titleF-    case cleanLinkString descr of+    case cleanLinkText descr of       Just imgSrc | isImageFilename imgSrc ->         return . B.link src "" $ B.image imgSrc mempty mempty       _ ->@@ -429,10 +431,10 @@ selflinkOrImage :: PandocMonad m => OrgParser m (F Inlines) selflinkOrImage = try $ do   target <- char '[' *> linkTarget <* char ']'-  case cleanLinkString target of-    Nothing        -> case target of-                        '#':_ -> returnF $ B.link target "" (B.str target)-                        _     -> return $ internalLink target (B.str target)+  case cleanLinkText target of+    Nothing        -> case T.uncons target of+                        Just ('#', _) -> returnF $ B.link target "" (B.str target)+                        _             -> return $ internalLink target (B.str target)     Just nonDocTgt -> if isImageFilename nonDocTgt                       then returnF $ B.image nonDocTgt "" ""                       else returnF $ B.link nonDocTgt "" (B.str target)@@ -449,35 +451,35 @@   char '>'   return link -linkTarget :: PandocMonad m => OrgParser m String-linkTarget = enclosedByPair1 '[' ']' (noneOf "\n\r[]")+linkTarget :: PandocMonad m => OrgParser m Text+linkTarget = T.pack <$> enclosedByPair1 '[' ']' (noneOf "\n\r[]") -possiblyEmptyLinkTarget :: PandocMonad m => OrgParser m String+possiblyEmptyLinkTarget :: PandocMonad m => OrgParser m Text possiblyEmptyLinkTarget = try linkTarget <|> ("" <$ string "[]") -applyCustomLinkFormat :: String -> OrgParser m (F String)+applyCustomLinkFormat :: Text -> OrgParser m (F Text) applyCustomLinkFormat link = do-  let (linkType, rest) = break (== ':') link+  let (linkType, rest) = T.break (== ':') link   return $ do     formatter <- M.lookup linkType <$> asksF orgStateLinkFormatters-    return $ maybe link ($ drop 1 rest) formatter+    return $ maybe link ($ T.drop 1 rest) formatter  -- | Take a link and return a function which produces new inlines when given -- description inlines.-linkToInlinesF :: String -> Inlines -> F Inlines+linkToInlinesF :: Text -> Inlines -> F Inlines linkToInlinesF linkStr =-  case linkStr of-    ""      -> pure . B.link mempty ""       -- wiki link (empty by convention)-    ('#':_) -> pure . B.link linkStr ""      -- document-local fraction-    _       -> case cleanLinkString linkStr of-                 Just extTgt -> return . B.link extTgt ""-                 Nothing     -> internalLink linkStr  -- other internal link+  case T.uncons linkStr of+    Nothing       -> pure . B.link mempty ""       -- wiki link (empty by convention)+    Just ('#', _) -> pure . B.link linkStr ""      -- document-local fraction+    _             -> case cleanLinkText linkStr of+      Just extTgt -> return . B.link extTgt ""+      Nothing     -> internalLink linkStr  -- other internal link -internalLink :: String -> Inlines -> F Inlines+internalLink :: Text -> Inlines -> F Inlines internalLink link title = do   anchorB <- (link `elem`) <$> asksF orgStateAnchorIds   if anchorB-    then return $ B.link ('#':link) "" title+    then return $ B.link ("#" <> link) "" title     else return $ B.emph title  -- | Parse an anchor like @<<anchor-id>>@ and return an empty span with@@ -493,15 +495,15 @@   returnF $ B.spanWith (solidify anchorId, [], []) mempty  where        parseAnchor = string "<<"-                     *> many1 (noneOf "\t\n\r<>\"' ")+                     *> many1Char (noneOf "\t\n\r<>\"' ")                      <* string ">>"                      <* skipSpaces  -- | Replace every char but [a-zA-Z0-9_.-:] with a hyphen '-'.  This mirrors -- the org function @org-export-solidify-link-text@. -solidify :: String -> String-solidify = map replaceSpecialChar+solidify :: Text -> Text+solidify = T.map replaceSpecialChar  where replaceSpecialChar c            | isAlphaNum c    = c            | c `elem` ("_.-:" :: String) = c@@ -511,25 +513,25 @@ inlineCodeBlock :: PandocMonad m => OrgParser m (F Inlines) inlineCodeBlock = try $ do   string "src_"-  lang <- many1 orgArgWordChar+  lang <- many1Char orgArgWordChar   opts <- option [] $ enclosedByPair '[' ']' inlineBlockOption-  inlineCode <- enclosedByPair1 '{' '}' (noneOf "\n\r")+  inlineCode <- T.pack <$> enclosedByPair1 '{' '}' (noneOf "\n\r")   let attrClasses = [translateLang lang]   let attrKeyVal  = originalLang lang <> opts   let codeInlineBlck = B.codeWith ("", attrClasses, attrKeyVal) inlineCode   returnF $ if exportsCode opts then codeInlineBlck else mempty  where-   inlineBlockOption :: PandocMonad m => OrgParser m (String, String)+   inlineBlockOption :: PandocMonad m => OrgParser m (Text, Text)    inlineBlockOption = try $ do      argKey <- orgArgKey      paramValue <- option "yes" orgInlineParamValue      return (argKey, paramValue) -   orgInlineParamValue :: PandocMonad m => OrgParser m String+   orgInlineParamValue :: PandocMonad m => OrgParser m Text    orgInlineParamValue = try $      skipSpaces        *> notFollowedBy (char ':')-       *> many1 (noneOf "\t\n\r ]")+       *> many1Char (noneOf "\t\n\r ]")        <* skipSpaces  @@ -584,7 +586,7 @@  math      :: PandocMonad m => OrgParser m (F Inlines) math      = return . B.math      <$> choice [ math1CharBetween '$'-                                            , mathStringBetween '$'+                                            , mathTextBetween '$'                                             , rawMathBetween "\\(" "\\)"                                             ] @@ -604,7 +606,7 @@   return c  symbol :: PandocMonad m => OrgParser m (F Inlines)-symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)+symbol = return . B.str . T.singleton <$> (oneOf specialChars >>= updatePositions)  emphasisBetween :: PandocMonad m                 => Char@@ -619,7 +621,7 @@  verbatimBetween :: PandocMonad m                 => Char-                -> OrgParser m String+                -> OrgParser m Text verbatimBetween c = try $   emphasisStart c *>   many1TillNOrLessNewlines 1 verbatimChar (emphasisEnd c)@@ -627,33 +629,33 @@    verbatimChar = noneOf "\n\r" >>= updatePositions  -- | Parses a raw string delimited by @c@ using Org's math rules-mathStringBetween :: PandocMonad m+mathTextBetween :: PandocMonad m                   => Char-                  -> OrgParser m String-mathStringBetween c = try $ do+                  -> OrgParser m Text+mathTextBetween c = try $ do   mathStart c   body <- many1TillNOrLessNewlines mathAllowedNewlines                                    (noneOf (c:"\n\r"))                                    (lookAhead $ mathEnd c)   final <- mathEnd c-  return $ body ++ [final]+  return $ T.snoc body final  -- | Parse a single character between @c@ using math rules math1CharBetween :: PandocMonad m                  => Char-                -> OrgParser m String+                -> OrgParser m Text math1CharBetween c = try $ do   char c   res <- noneOf $ c:mathForbiddenBorderChars   char c   eof <|> () <$ lookAhead (oneOf mathPostChars)-  return [res]+  return $ T.singleton res  rawMathBetween :: PandocMonad m-               => String-               -> String-               -> OrgParser m String-rawMathBetween s e = try $ string s *> manyTill anyChar (try $ string e)+               => Text+               -> Text+               -> OrgParser m Text+rawMathBetween s e = try $ textStr s *> manyTillChar anyChar (try $ textStr e)  -- | Parses the start (opening character) of emphasis emphasisStart :: PandocMonad m => Char -> OrgParser m Char@@ -702,10 +704,10 @@  enclosedRaw :: (PandocMonad m, Show b) => OrgParser m a             -> OrgParser m b-            -> OrgParser m String+            -> OrgParser m Text enclosedRaw start end = try $   start *> (onSingleLine <|> spanningTwoLines)- where onSingleLine = try $ many1Till (noneOf "\n\r") end+ where onSingleLine = try $ many1TillChar (noneOf "\n\r") end        spanningTwoLines = try $          anyLine >>= \f -> mappend (f <> " ") <$> onSingleLine @@ -714,7 +716,7 @@ many1TillNOrLessNewlines :: PandocMonad m => Int                          -> OrgParser m Char                          -> OrgParser m a-                         -> OrgParser m String+                         -> OrgParser m Text many1TillNOrLessNewlines n p end = try $   nMoreLines (Just n) mempty >>= oneOrMore  where@@ -726,7 +728,7 @@    rest  m cs = (\x -> (minus1 <$> m, cs ++ x ++ "\n")) <$> try (manyTill p newline)    finalLine = try $ manyTill p end    minus1 k = k - 1-   oneOrMore cs = cs <$ guard (not $ null cs)+   oneOrMore cs = T.pack cs <$ guard (not $ null cs)  -- Org allows customization of the way it reads emphasis.  We use the defaults -- here (see, e.g., the Emacs Lisp variable `org-emphasis-regexp-components`@@ -773,17 +775,17 @@ subOrSuperExpr = try $   choice [ charsInBalanced '{' '}' (noneOf "\n\r")          , enclosing ('(', ')') <$> charsInBalanced '(' ')' (noneOf "\n\r")-         , simpleSubOrSuperString+         , simpleSubOrSuperText          ] >>= parseFromString (mconcat <$> many inline)- where enclosing (left, right) s = left : s ++ [right]+ where enclosing (left, right) s = T.cons left $ T.snoc s right -simpleSubOrSuperString :: PandocMonad m => OrgParser m String-simpleSubOrSuperString = try $ do+simpleSubOrSuperText :: PandocMonad m => OrgParser m Text+simpleSubOrSuperText = try $ do   state <- getState   guard . exportSubSuperscripts . orgStateExportSettings $ state-  choice [ string "*"-         , mappend <$> option [] ((:[]) <$> oneOf "+-")-                   <*> many1 alphaNum+  choice [ textStr "*"+         , mappend <$> option "" (T.singleton <$> oneOf "+-")+                   <*> many1Char alphaNum          ]  inlineLaTeX :: PandocMonad m => OrgParser m (F Inlines)@@ -793,28 +795,28 @@   maybe mzero returnF $      parseAsMathMLSym cmd `mplus` parseAsMath cmd `mplus` ils  where-   parseAsMath :: String -> Maybe Inlines+   parseAsMath :: Text -> Maybe Inlines    parseAsMath cs = B.fromList <$> texMathToPandoc cs -   parseAsInlineLaTeX :: PandocMonad m => String -> m (Maybe Inlines)+   parseAsInlineLaTeX :: PandocMonad m => Text -> m (Maybe Inlines)    parseAsInlineLaTeX cs = maybeRight <$> runParserT inlineCommand state "" cs -   parseAsMathMLSym :: String -> Maybe Inlines+   parseAsMathMLSym :: Text -> Maybe Inlines    parseAsMathMLSym cs = B.str <$> MathMLEntityMap.getUnicode (clean cs)     -- drop initial backslash and any trailing "{}"-    where clean = dropWhileEnd (`elem` ("{}" :: String)) . drop 1+    where clean = T.dropWhileEnd (`elem` ("{}" :: String)) . T.drop 1     state :: ParserState    state = def{ stateOptions = def{ readerExtensions =                     enableExtension Ext_raw_tex (readerExtensions def) } } -   texMathToPandoc :: String -> Maybe [Inline]+   texMathToPandoc :: Text -> Maybe [Inline]    texMathToPandoc cs = maybeRight (readTeX cs) >>= writePandoc DisplayInline  maybeRight :: Either a b -> Maybe b maybeRight = either (const Nothing) Just -inlineLaTeXCommand :: PandocMonad m => OrgParser m String+inlineLaTeXCommand :: PandocMonad m => OrgParser m Text inlineLaTeXCommand = try $ do   rest <- getInput   st <- getState@@ -823,21 +825,17 @@     Right cs -> do       -- drop any trailing whitespace, those are not be part of the command as       -- far as org mode is concerned.-      let cmdNoSpc = dropWhileEnd isSpace cs-      let len = length cmdNoSpc+      let cmdNoSpc = T.dropWhileEnd isSpace cs+      let len = T.length cmdNoSpc       count len anyChar       return cmdNoSpc     _ -> mzero --- Taken from Data.OldList.-dropWhileEnd :: (a -> Bool) -> [a] -> [a]-dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) []- exportSnippet :: PandocMonad m => OrgParser m (F Inlines) exportSnippet = try $ do   string "@@"-  format <- many1Till (alphaNum <|> char '-') (char ':')-  snippet <- manyTill anyChar (try $ string "@@")+  format <- many1TillChar (alphaNum <|> char '-') (char ':')+  snippet <- manyTillChar anyChar (try $ string "@@")   returnF $ B.rawInline format snippet  macro :: PandocMonad m => OrgParser m (F Inlines)@@ -845,7 +843,7 @@   recursionDepth <- orgStateMacroDepth <$> getState   guard $ recursionDepth < 15   string "{{{"-  name <- many alphaNum+  name <- manyChar alphaNum   args <- ([] <$ string "}}}")           <|> char '(' *> argument `sepBy` char ',' <* eoa   expander <- lookupMacro name <$> getState@@ -857,7 +855,7 @@       updateState $ \s -> s { orgStateMacroDepth = recursionDepth }       return res  where-  argument = many $ notFollowedBy eoa *> noneOf ","+  argument = manyChar $ notFollowedBy eoa *> noneOf ","   eoa = string ")}}}"  smart :: PandocMonad m => OrgParser m (F Inlines)
src/Text/Pandoc/Readers/Org/Meta.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE TupleSections    #-}+{-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE TupleSections     #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Org.Meta    Copyright   : Copyright (C) 2014-2019 Albert Krewinkel@@ -30,11 +31,12 @@ import Text.Pandoc.Shared (safeRead)  import Control.Monad (mzero, void, when)-import Data.Char (toLower) import Data.List (intersperse) import Data.Maybe (fromMaybe) import qualified Data.Map as M import qualified Data.Set as Set+import Data.Text (Text)+import qualified Data.Text as T import Network.HTTP (urlEncode)  -- | Returns the current meta, respecting export options.@@ -47,7 +49,7 @@          . (if exportWithEmail   settings then id else removeMeta "email")         <$> orgStateMeta st -removeMeta :: String -> Meta -> Meta+removeMeta :: Text -> Meta -> Meta removeMeta key meta' =   let metaMap = unMeta meta'   in Meta $ M.delete key metaMap@@ -60,18 +62,18 @@  declarationLine :: PandocMonad m => OrgParser m () declarationLine = try $ do-  key   <- map toLower <$> metaKey+  key   <- T.toLower <$> metaKey   (key', value) <- metaValue key   let addMetaValue st =         st { orgStateMeta = B.setMeta key' <$> value <*> orgStateMeta st }   when (key' /= "results") $ updateState addMetaValue -metaKey :: Monad m => OrgParser m String-metaKey = map toLower <$> many1 (noneOf ": \n\r")-                      <*  char ':'-                      <*  skipSpaces+metaKey :: Monad m => OrgParser m Text+metaKey = T.toLower <$> many1Char (noneOf ": \n\r")+                    <*  char ':'+                    <*  skipSpaces -metaValue :: PandocMonad m => String -> OrgParser m (String, F MetaValue)+metaValue :: PandocMonad m => Text -> OrgParser m (Text, F MetaValue) metaValue key =   let inclKey = "header-includes"   in case key of@@ -88,7 +90,7 @@     -- Org-mode expects class options to contain the surrounding brackets,     -- pandoc does not.     "latex_class_options" -> ("classoption",) <$>-                             metaModifiedString (filter (`notElem` "[]"))+                             metaModifiedString (T.filter (`notElem` ("[]" :: String)))     "html_head"       -> (inclKey,) <$>                          accumulatingList inclKey (metaExportSnippet "html")     _                 -> (key,) <$> metaString@@ -98,25 +100,25 @@  metaInlinesCommaSeparated :: PandocMonad m => OrgParser m (F MetaValue) metaInlinesCommaSeparated = do-  itemStrs <- many1 (noneOf ",\n") `sepBy1` char ','+  itemStrs <- many1Char (noneOf ",\n") `sepBy1` char ','   newline-  items <- mapM (parseFromString inlinesTillNewline . (++ "\n")) itemStrs+  items <- mapM (parseFromString inlinesTillNewline . (<> "\n")) itemStrs   let toMetaInlines = MetaInlines . B.toList   return $ MetaList . map toMetaInlines <$> sequence items  metaString :: Monad m => OrgParser m (F MetaValue) metaString = metaModifiedString id -metaModifiedString :: Monad m => (String -> String) -> OrgParser m (F MetaValue)+metaModifiedString :: Monad m => (Text -> Text) -> OrgParser m (F MetaValue) metaModifiedString f = return . MetaString . f <$> anyLine  -- | Read an format specific meta definition-metaExportSnippet :: Monad m => String -> OrgParser m (F MetaValue)+metaExportSnippet :: Monad m => Text -> OrgParser m (F MetaValue) metaExportSnippet format =   return . MetaInlines . B.toList . B.rawInline format <$> anyLine  -- | Accumulate the result of the @parser@ in a list under @key@.-accumulatingList :: Monad m => String+accumulatingList :: Monad m => Text                  -> OrgParser m (F MetaValue)                  -> OrgParser m (F MetaValue) accumulatingList key p = do@@ -147,33 +149,33 @@     "pandoc-emphasis-post" -> emphChars >>= updateState . setEmphasisPostChar     _          -> mzero -addLinkFormat :: Monad m => String-              -> (String -> String)+addLinkFormat :: Monad m => Text+              -> (Text -> Text)               -> OrgParser m () addLinkFormat key formatter = updateState $ \s ->   let fs = orgStateLinkFormatters s   in s{ orgStateLinkFormatters = M.insert key formatter fs } -parseLinkFormat :: Monad m => OrgParser m (String, String -> String)+parseLinkFormat :: Monad m => OrgParser m (Text, Text -> Text) parseLinkFormat = try $ do-  linkType <- (:) <$> letter <*> many (alphaNum <|> oneOf "-_") <* skipSpaces+  linkType <- T.cons <$> letter <*> manyChar (alphaNum <|> oneOf "-_") <* skipSpaces   linkSubst <- parseFormat   return (linkType, linkSubst)  -- | An ad-hoc, single-argument-only implementation of a printf-style format -- parser.-parseFormat :: Monad m => OrgParser m (String -> String)+parseFormat :: Monad m => OrgParser m (Text -> Text) parseFormat = try $ replacePlain <|> replaceUrl <|> justAppend  where    -- inefficient, but who cares-   replacePlain = try $ (\x -> concat . flip intersperse x)+   replacePlain = try $ (\x -> T.concat . flip intersperse x)                      <$> sequence [tillSpecifier 's', rest]-   replaceUrl   = try $ (\x -> concat . flip intersperse x . urlEncode)+   replaceUrl   = try $ (\x -> T.concat . flip intersperse x . T.pack . urlEncode . T.unpack)                      <$> sequence [tillSpecifier 'h', rest]-   justAppend   = try $ (++) <$> rest+   justAppend   = try $ (<>) <$> rest -   rest            = manyTill anyChar         (eof <|> () <$ oneOf "\n\r")-   tillSpecifier c = manyTill (noneOf "\n\r") (try $ string ('%':c:""))+   rest            = manyTillChar anyChar         (eof <|> () <$ oneOf "\n\r")+   tillSpecifier c = manyTillChar (noneOf "\n\r") (try $ string ('%':c:""))  tagList :: Monad m => OrgParser m [Tag] tagList = do@@ -231,41 +233,41 @@                     (x:xs) -> return $ keywordsToSequence (reverse xs) [x]   where-   todoKeywords :: Monad m => OrgParser m [String]+   todoKeywords :: Monad m => OrgParser m [Text]    todoKeywords = try $-     let keyword = many1 nonspaceChar <* skipSpaces+     let keyword = many1Char nonspaceChar <* skipSpaces          endOfKeywords = todoDoneSep <|> void newline      in manyTill keyword (lookAhead endOfKeywords)     todoDoneSep :: Monad m => OrgParser m ()    todoDoneSep = void . try $ skipSpaces *> char '|' <* skipSpaces1 -   keywordsToSequence :: [String] -> [String] -> TodoSequence+   keywordsToSequence :: [Text] -> [Text] -> TodoSequence    keywordsToSequence todo done =      let todoMarkers = map (TodoMarker Todo) todo          doneMarkers = map (TodoMarker Done) done      in todoMarkers ++ doneMarkers -macroDefinition :: Monad m => OrgParser m (String, [String] -> String)+macroDefinition :: Monad m => OrgParser m (Text, [Text] -> Text) macroDefinition = try $ do-  macroName <- many1 nonspaceChar <* skipSpaces+  macroName <- many1Char nonspaceChar <* skipSpaces   firstPart <- expansionPart   (elemOrder, parts) <- unzip <$> many ((,) <$> placeholder <*> expansionPart)   let expander = mconcat . alternate (firstPart:parts) . reorder elemOrder   return (macroName, expander)  where   placeholder :: Monad m => OrgParser m Int-  placeholder = try . fmap (fromMaybe 1 . safeRead) $ char '$' *> many1 digit+  placeholder = try . fmap (fromMaybe 1 . safeRead) $ char '$' *> many1Char digit -  expansionPart :: Monad m => OrgParser m String-  expansionPart = try $ many (notFollowedBy placeholder *> noneOf "\n\r")+  expansionPart :: Monad m => OrgParser m Text+  expansionPart = try $ manyChar (notFollowedBy placeholder *> noneOf "\n\r")    alternate :: [a] -> [a] -> [a]   alternate []     ys     = ys   alternate xs     []     = xs   alternate (x:xs) (y:ys) = x : y : alternate xs ys -  reorder :: [Int] -> [String] -> [String]+  reorder :: [Int] -> [Text] -> [Text]   reorder perm xs =     let element n = take 1 $ drop (n - 1) xs     in concatMap element perm
src/Text/Pandoc/Readers/Org/ParserState.hs view
@@ -1,6 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude     #-} {-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings     #-} {- |    Module      : Text.Pandoc.Readers.Org.ParserState    Copyright   : Copyright (C) 2014-2019 Albert Krewinkel@@ -63,16 +64,16 @@ type F = Future OrgParserState  -- | An inline note / footnote containing the note key and its (inline) value.-type OrgNoteRecord = (String, F Blocks)+type OrgNoteRecord = (Text, F Blocks) -- | Table of footnotes type OrgNoteTable = [OrgNoteRecord] -- | Map of functions for link transformations.  The map key is refers to the -- link-type, the corresponding function transforms the given link string.-type OrgLinkFormatters = M.Map String (String -> String)+type OrgLinkFormatters = M.Map Text (Text -> Text) -- | Macro expander function-type MacroExpander = [String] -> String+type MacroExpander = [Text] -> Text -- | Tag-newtype Tag = Tag { fromTag :: String }+newtype Tag = Tag { fromTag :: Text }   deriving (Show, Eq, Ord)  -- | The states in which a todo item can be@@ -82,7 +83,7 @@ -- | A ToDo keyword like @TODO@ or @DONE@. data TodoMarker = TodoMarker   { todoMarkerState :: TodoState-  , todoMarkerName  :: String+  , todoMarkerName  :: Text   }   deriving (Show, Eq) @@ -91,7 +92,7 @@  -- | Org-mode parser state data OrgParserState = OrgParserState-  { orgStateAnchorIds            :: [String]+  { orgStateAnchorIds            :: [Text]   , orgStateEmphasisCharStack    :: [Char]   , orgStateEmphasisPreChars     :: [Char] -- ^ Chars allowed to occur before                                            -- emphasis; spaces and newlines are@@ -102,13 +103,13 @@   , orgStateExcludeTags          :: Set.Set Tag   , orgStateExcludeTagsChanged   :: Bool   , orgStateExportSettings       :: ExportSettings-  , orgStateIdentifiers          :: Set.Set String-  , orgStateIncludeFiles         :: [String]+  , orgStateIdentifiers          :: Set.Set Text+  , orgStateIncludeFiles         :: [Text]   , orgStateLastForbiddenCharPos :: Maybe SourcePos   , orgStateLastPreCharPos       :: Maybe SourcePos   , orgStateLastStrPos           :: Maybe SourcePos   , orgStateLinkFormatters       :: OrgLinkFormatters-  , orgStateMacros               :: M.Map String MacroExpander+  , orgStateMacros               :: M.Map Text MacroExpander   , orgStateMacroDepth           :: Int   , orgStateMeta                 :: F Meta   , orgStateNotes'               :: OrgNoteTable@@ -117,6 +118,7 @@   , orgStateSelectTags           :: Set.Set Tag   , orgStateSelectTagsChanged    :: Bool   , orgStateTodoSequences        :: [TodoSequence]+  , orgStateTrimLeadBlkIndent    :: Bool   , orgLogMessages               :: [LogMessage]   , orgMacros                    :: M.Map Text Macro   }@@ -133,7 +135,7 @@  instance HasLastStrPosition OrgParserState where   getLastStrPos = orgStateLastStrPos-  setLastStrPos pos st = st{ orgStateLastStrPos = Just pos }+  setLastStrPos pos st = st{ orgStateLastStrPos = pos }  instance Monad m => HasQuoteContext st (ReaderT OrgParserLocal m) where   getQuoteContext = asks orgLocalQuoteContext@@ -184,6 +186,7 @@   , orgStateParserContext = NullState   , orgStateSelectTags = Set.singleton $ Tag "export"   , orgStateSelectTagsChanged = False+  , orgStateTrimLeadBlkIndent = True   , orgStateTodoSequences = []   , orgLogMessages = []   , orgMacros = M.empty@@ -210,10 +213,10 @@ activeTodoMarkers :: OrgParserState -> TodoSequence activeTodoMarkers = concat . activeTodoSequences -lookupMacro :: String -> OrgParserState -> Maybe MacroExpander+lookupMacro :: Text -> OrgParserState -> Maybe MacroExpander lookupMacro macroName = M.lookup macroName . orgStateMacros -registerMacro :: (String, MacroExpander) -> OrgParserState -> OrgParserState+registerMacro :: (Text, MacroExpander) -> OrgParserState -> OrgParserState registerMacro (name, expander) st =   let curMacros = orgStateMacros st   in st{ orgStateMacros = M.insert name expander curMacros }@@ -234,7 +237,7 @@ -- These settings can be changed via OPTIONS statements. data ExportSettings = ExportSettings   { exportArchivedTrees    :: ArchivedTreesOption -- ^ How to treat archived trees-  , exportDrawers          :: Either [String] [String]+  , exportDrawers          :: Either [Text] [Text]   -- ^ Specify drawer names which should be exported.  @Left@ names are   -- explicitly excluded from the resulting output while @Right@ means that   -- only the listed drawer names should be included.
src/Text/Pandoc/Readers/Org/Parsing.hs view
@@ -32,7 +32,13 @@   , orgTagWordChar   -- * Re-exports from Text.Pandoc.Parser   , ParserContext (..)+  , textStr+  , countChar+  , manyChar+  , many1Char+  , manyTillChar   , many1Till+  , many1TillChar   , notFollowedBy'   , spaceChar   , nonspaceChar@@ -98,6 +104,7 @@   ) where  import Prelude+import Data.Text (Text) import Text.Pandoc.Readers.Org.ParserState  import Text.Pandoc.Parsing hiding (F, anyLine, blanklines, newline,@@ -108,14 +115,14 @@ import Control.Monad.Reader (ReaderT)  -- | The parser used to read org files.-type OrgParser m = ParserT [Char] OrgParserState (ReaderT OrgParserLocal m)+type OrgParser m = ParserT Text OrgParserState (ReaderT OrgParserLocal m)  -- -- Adaptions and specializations of parsing utilities --  -- | Parse any line of text-anyLine :: Monad m => OrgParser m String+anyLine :: Monad m => OrgParser m Text anyLine =   P.anyLine     <* updateLastPreCharPos@@ -123,7 +130,7 @@  -- | Like @'Text.Pandoc.Parsing'@, but resets the position of the last character -- allowed before emphasised text.-parseFromString :: Monad m => OrgParser m a -> String -> OrgParser m a+parseFromString :: Monad m => OrgParser m a -> Text -> OrgParser m a parseFromString parser str' = do   updateState $ \s -> s{ orgStateLastPreCharPos = Nothing }   result <- P.parseFromString parser str'@@ -142,7 +149,7 @@        <* updateLastForbiddenCharPos  -- | Like @Text.Parsec.Char.blanklines@, but causes additional state changes.-blanklines :: Monad m => OrgParser m [Char]+blanklines :: Monad m => OrgParser m Text blanklines =   P.blanklines        <* updateLastPreCharPos@@ -192,21 +199,21 @@ --  -- | Read the key of a plist style key-value list.-orgArgKey :: Monad m => OrgParser m String+orgArgKey :: Monad m => OrgParser m Text orgArgKey = try $   skipSpaces *> char ':'-             *> many1 orgArgWordChar+             *> many1Char orgArgWordChar  -- | Read the value of a plist style key-value list.-orgArgWord :: Monad m => OrgParser m String-orgArgWord = many1 orgArgWordChar+orgArgWord :: Monad m => OrgParser m Text+orgArgWord = many1Char orgArgWordChar  -- | Chars treated as part of a word in plists. orgArgWordChar :: Monad m => OrgParser m Char orgArgWordChar = alphaNum <|> oneOf "-_" -orgTagWord :: Monad m => OrgParser m String-orgTagWord = many1 orgTagWordChar+orgTagWord :: Monad m => OrgParser m Text+orgTagWord = many1Char orgTagWordChar  orgTagWordChar :: Monad m => OrgParser m Char orgTagWordChar = alphaNum <|> oneOf "@%#_"
src/Text/Pandoc/Readers/Org/Shared.hs view
@@ -10,7 +10,7 @@ Utility functions used in other Pandoc Org modules. -} module Text.Pandoc.Readers.Org.Shared-  ( cleanLinkString+  ( cleanLinkText   , isImageFilename   , originalLang   , translateLang@@ -19,44 +19,44 @@  import Prelude import Data.Char (isAlphaNum)-import Data.List (isPrefixOf)+import Data.Text (Text)+import qualified Data.Text as T import System.FilePath (isValid, takeExtension)-+import Text.Pandoc.Shared (elemText)  -- | Check whether the given string looks like the path to of URL of an image.-isImageFilename :: String -> Bool-isImageFilename fp = hasImageExtension && (isValid fp || isKnownProtocolUri)+isImageFilename :: Text -> Bool+isImageFilename fp = hasImageExtension && (isValid (T.unpack fp) || isKnownProtocolUri)  where-   hasImageExtension = takeExtension fp `elem` imageExtensions-   isKnownProtocolUri = any (\x -> (x ++ "://") `isPrefixOf` fp) protocols+   hasImageExtension = takeExtension (T.unpack fp) `elem` imageExtensions+   isKnownProtocolUri = any (\x -> (x <> "://") `T.isPrefixOf` fp) protocols     imageExtensions = [ ".jpeg", ".jpg", ".png", ".gif", ".svg" ]    protocols = [ "file", "http", "https" ]  -- | Cleanup and canonicalize a string describing a link.  Return @Nothing@ if -- the string does not appear to be a link.-cleanLinkString :: String -> Maybe String-cleanLinkString s =-  case s of-    '/':_                  -> Just $ "file://" ++ s  -- absolute path-    '.':'/':_              -> Just s                 -- relative path-    '.':'.':'/':_          -> Just s                 -- relative path-    -- Relative path or URL (file schema)-    'f':'i':'l':'e':':':s' -> Just $ if "//" `isPrefixOf` s' then s else s'-    _                      -> if isUrl s then Just s else Nothing- where-   isUrl :: String -> Bool-   isUrl cs =-     let (scheme, path) = break (== ':') cs-     in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme-          && not (null path)+cleanLinkText :: Text -> Maybe Text+cleanLinkText s+  | Just _ <- T.stripPrefix "/" s      = Just $ "file://" <> s -- absolute path+  | Just _ <- T.stripPrefix "./" s     = Just s                -- relative path+  | Just _ <- T.stripPrefix "../" s    = Just s                -- relative path+  -- Relative path or URL (file schema)+  | Just s' <- T.stripPrefix "file:" s = Just $ if "//" `T.isPrefixOf` s' then s else s'+  | otherwise                          = if isUrl s then Just s else Nothing+  where+    isUrl :: Text -> Bool+    isUrl cs =+      let (scheme, path) = T.break (== ':') cs+      in T.all (\c -> isAlphaNum c || c `elemText` ".-") scheme+         && not (T.null path)  -- | Creates an key-value pair marking the original language name specified for -- a piece of source code.  -- | Creates an key-value attributes marking the original language name -- specified for a piece of source code.-originalLang :: String -> [(String, String)]+originalLang :: Text -> [(Text, Text)] originalLang lang =   let transLang = translateLang lang   in if transLang == lang@@ -66,7 +66,7 @@ -- | Translate from Org-mode's programming language identifiers to those used -- by Pandoc.  This is useful to allow for proper syntax highlighting in -- Pandoc output.-translateLang :: String -> String+translateLang :: Text -> Text translateLang cs =   case cs of     "C"          -> "c"@@ -79,5 +79,5 @@     "sqlite"     -> "sql"     _            -> cs -exportsCode :: [(String, String)] -> Bool+exportsCode :: [(Text, Text)] -> Bool exportsCode = maybe True (`elem` ["code", "both"]) . lookup "exports"
src/Text/Pandoc/Readers/RST.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE FlexibleContexts    #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ViewPatterns        #-} {- |    Module      : Text.Pandoc.Readers.RST    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -19,9 +20,8 @@ import Control.Monad (forM_, guard, liftM, mplus, mzero, when) import Control.Monad.Except (throwError) import Control.Monad.Identity (Identity (..))-import Data.Char (isHexDigit, isSpace, toLower, toUpper, isAlphaNum)-import Data.List (deleteFirstsBy, elemIndex, intercalate, isInfixOf, isSuffixOf,-                  nub, sort, transpose)+import Data.Char (isHexDigit, isSpace, toUpper, isAlphaNum)+import Data.List (deleteFirstsBy, elemIndex, nub, sort, transpose) import qualified Data.Map as M import Data.Maybe (fromMaybe) import Data.Sequence (ViewR (..), viewr)@@ -47,16 +47,16 @@ -- | Parse reStructuredText string and return Pandoc document. readRST :: PandocMonad m         => ReaderOptions -- ^ Reader options-        -> Text          -- ^ String to parse (assuming @'\n'@ line endings)+        -> Text          -- ^ Text to parse (assuming @'\n'@ line endings)         -> m Pandoc readRST opts s = do   parsed <- readWithM parseRST def{ stateOptions = opts }-               (T.unpack (crFilter s) ++ "\n\n")+               (crFilter s <> "\n\n")   case parsed of     Right result -> return result     Left e       -> throwError e -type RSTParser m = ParserT [Char] ParserState m+type RSTParser m = ParserT Text ParserState m  -- -- Constants and data structure definitions@@ -113,7 +113,7 @@  metaFromDefList :: [([Inline], [[Block]])] -> Meta -> Meta metaFromDefList ds meta = adjustAuthors $ foldr f meta ds- where f (k,v) = setMeta (map toLower $ stringify k) (mconcat $ map fromList v)+ where f (k,v) = setMeta (T.toLower $ stringify k) (mconcat $ map fromList v)        adjustAuthors (Meta metamap) = Meta $ M.adjust splitAuthors "author"                                            $ M.adjust toPlain "date"                                            $ M.adjust toPlain "title"@@ -136,13 +136,13 @@        isSp LineBreak = True        isSp _         = False        splitOnSemi                    = splitBy (==Str ";")-       factorSemi (Str [])            = []-       factorSemi (Str s)             = case break (==';') s of-                                             (xs,[]) -> [Str xs]-                                             (xs,';':ys) -> Str xs : Str ";" :-                                                factorSemi (Str ys)-                                             (xs,ys) -> Str xs :-                                                factorSemi (Str ys)+       factorSemi (Str "")            = []+       factorSemi (Str s)             = case T.break (==';') s of+                                          (xs,"") -> [Str xs]+                                          (xs,T.uncons -> Just (';',ys)) -> Str xs : Str ";" :+                                            factorSemi (Str ys)+                                          (xs,ys) -> Str xs :+                                            factorSemi (Str ys)        factorSemi x                   = [x]  parseRST :: PandocMonad m => RSTParser m Pandoc@@ -151,7 +151,7 @@   startPos <- getPosition   -- go through once just to get list of reference keys and notes   -- docMinusKeys is the raw document with blanks where the keys were...-  docMinusKeys <- concat <$>+  docMinusKeys <- T.concat <$>                   manyTill (referenceKey <|> anchorDef <|>                             noteBlock <|> citationBlock <|>                             (snd <$> withRaw comment) <|>@@ -180,7 +180,7 @@   return $ Pandoc meta' (blocks' ++ refBlock)  parseCitation :: PandocMonad m-              => (String, String) -> RSTParser m (Inlines, [Blocks])+              => (Text, Text) -> RSTParser m (Inlines, [Blocks]) parseCitation (ref, raw) = do   contents <- parseFromString' parseBlocks raw   return (B.spanWith (ref, ["citation-label"], []) (B.str ref),@@ -215,23 +215,23 @@ -- field list -- -rawFieldListItem :: Monad m => Int -> RSTParser m (String, String)+rawFieldListItem :: Monad m => Int -> RSTParser m (Text, Text) rawFieldListItem minIndent = try $ do   indent <- length <$> many (char ' ')   guard $ indent >= minIndent   char ':'-  name <- many1Till (noneOf "\n") (char ':')+  name <- many1TillChar (noneOf "\n") (char ':')   (() <$ lookAhead newline) <|> skipMany1 spaceChar   first <- anyLine   rest <- option "" $ try $ do lookAhead (count indent (char ' ') >> spaceChar)                                indentedBlock-  let raw = (if null first then "" else (first ++ "\n")) ++ rest ++ "\n"+  let raw = (if T.null first then "" else (first <> "\n")) <> rest <> "\n"   return (name, raw)  fieldListItem :: PandocMonad m => Int -> RSTParser m (Inlines, [Blocks]) fieldListItem minIndent = try $ do   (name, raw) <- rawFieldListItem minIndent-  term <- parseInlineFromString name+  term <- parseInlineFromText name   contents <- parseFromString' parseBlocks raw   optional blanklines   return (term, [contents])@@ -251,12 +251,12 @@ lineBlock :: PandocMonad m => RSTParser m Blocks lineBlock = try $ do   lines' <- lineBlockLines-  lines'' <- mapM parseInlineFromString lines'+  lines'' <- mapM parseInlineFromText lines'   return $ B.lineBlock lines'' -lineBlockDirective :: PandocMonad m => String -> RSTParser m Blocks+lineBlockDirective :: PandocMonad m => Text -> RSTParser m Blocks lineBlockDirective body = do-  lines' <- mapM parseInlineFromString $ lines $ stripTrailingNewlines body+  lines' <- mapM parseInlineFromText $ T.lines $ stripTrailingNewlines body   return $ B.lineBlock lines'  --@@ -271,9 +271,9 @@     newline     blanklines     case viewr (B.unMany result) of-         ys :> Str xs | "::" `isSuffixOf` xs -> do+         ys :> Str xs | "::" `T.isSuffixOf` xs -> do               raw <- option mempty codeBlockBody-              return $ B.para (B.Many ys <> B.str (take (length xs - 1) xs))+              return $ B.para (B.Many ys <> B.str (T.take (T.length xs - 1) xs))                          <> raw          _ -> return (B.para result) @@ -312,7 +312,7 @@   txt <- trimInlines . mconcat <$> many1 (notFollowedBy blankline >> inline)   pos <- getPosition   let len = sourceColumn pos - 1-  when (len > lenTop) $ fail "title longer than border"+  when (len > lenTop) $ Prelude.fail "title longer than border"   blankline              -- spaces and newline   count lenTop (char c)  -- the bottom line   blanklines@@ -349,7 +349,7 @@ -- hrule block -- -hrule :: Monad m => ParserT [Char] st m Blocks+hrule :: Monad m => ParserT Text st m Blocks hrule = try $ do   chr <- oneOf underlineChars   count 3 (char chr)@@ -363,36 +363,39 @@ --  -- read a line indented by a given string-indentedLine :: Monad m => String -> ParserT [Char] st m [Char]+indentedLine :: (HasReaderOptions st, Monad m)+             => Int -> ParserT Text st m Text indentedLine indents = try $ do-  string indents+  lookAhead spaceChar+  gobbleAtMostSpaces indents   anyLine  -- one or more indented lines, possibly separated by blank lines. -- any amount of indentation will work.-indentedBlock :: Monad m => ParserT [Char] st m [Char]+indentedBlock :: (HasReaderOptions st, Monad m)+              => ParserT Text st m Text indentedBlock = try $ do-  indents <- lookAhead $ many1 spaceChar+  indents <- length <$> lookAhead (many1 spaceChar)   lns <- many1 $ try $ do b <- option "" blanklines                           l <- indentedLine indents-                          return (b ++ l)+                          return (b <> l)   optional blanklines-  return $ unlines lns+  return $ T.unlines lns -quotedBlock :: Monad m => ParserT [Char] st m [Char]+quotedBlock :: Monad m => ParserT Text st m Text quotedBlock = try $ do     quote <- lookAhead $ oneOf "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"     lns <- many1 $ lookAhead (char quote) >> anyLine     optional blanklines-    return $ unlines lns+    return $ T.unlines lns -codeBlockStart :: Monad m => ParserT [Char] st m Char+codeBlockStart :: Monad m => ParserT Text st m Char codeBlockStart = string "::" >> blankline >> blankline -codeBlock :: Monad m => ParserT [Char] st m Blocks+codeBlock :: (HasReaderOptions st, Monad m) => ParserT Text st m Blocks codeBlock = try $ codeBlockStart >> codeBlockBody -codeBlockBody :: Monad m => ParserT [Char] st m Blocks+codeBlockBody :: (HasReaderOptions st, Monad m) => ParserT Text st m Blocks codeBlockBody = try $ B.codeBlock . stripTrailingNewlines <$>                 (indentedBlock <|> quotedBlock) @@ -404,24 +407,24 @@   lns <- latexCodeBlock <|> birdCodeBlock   blanklines   return $ B.codeBlockWith ("", ["haskell","literate"], [])-         $ intercalate "\n" lns+         $ T.intercalate "\n" lns -latexCodeBlock :: Monad m => ParserT [Char] st m [[Char]]+latexCodeBlock :: Monad m => ParserT Text st m [Text] latexCodeBlock = try $ do   try (latexBlockLine "\\begin{code}")   many1Till anyLine (try $ latexBlockLine "\\end{code}")  where   latexBlockLine s = skipMany spaceChar >> string s >> blankline -birdCodeBlock :: Monad m => ParserT [Char] st m [[Char]]+birdCodeBlock :: Monad m => ParserT Text st m [Text] birdCodeBlock = filterSpace <$> many1 birdTrackLine   where filterSpace lns =             -- if (as is normal) there is always a space after >, drop it-            if all (\ln -> null ln || take 1 ln == " ") lns-               then map (drop 1) lns+            if all (\ln -> T.null ln || T.take 1 ln == " ") lns+               then map (T.drop 1) lns                else lns -birdTrackLine :: Monad m => ParserT [Char] st m [Char]+birdTrackLine :: Monad m => ParserT Text st m Text birdTrackLine = char '>' >> anyLine  --@@ -432,7 +435,7 @@ blockQuote = do   raw <- indentedBlock   -- parse the extracted block, which may contain various block elements:-  contents <- parseFromString' parseBlocks $ raw ++ "\n\n"+  contents <- parseFromString' parseBlocks $ raw <> "\n\n"   return $ B.blockQuote contents  {-@@ -442,12 +445,12 @@ -}  includeDirective :: PandocMonad m-                 => String -> [(String, String)] -> String+                 => Text -> [(Text, Text)] -> Text                  -> RSTParser m Blocks includeDirective top fields body = do   let f = trim top-  guard $ not (null f)-  guard $ null (trim body)+  guard $ not (T.null f)+  guard $ T.null (trim body)   -- options   let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead   let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead@@ -455,11 +458,11 @@   oldInput <- getInput   containers <- stateContainers <$> getState   when (f `elem` containers) $-    throwError $ PandocParseError $ "Include file loop at " ++ show oldPos+    throwError $ PandocParseError $ "Include file loop at " <> tshow oldPos   updateState $ \s -> s{ stateContainers = f : stateContainers s }-  mbContents <- readFileFromDirs ["."] f+  mbContents <- readFileFromDirs ["."] $ T.unpack f   contentLines <- case mbContents of-                       Just s -> return $ lines s+                       Just s -> return $ T.lines s                        Nothing -> do                          logMessage $ CouldNotLoadIncludeFile f oldPos                          return []@@ -475,23 +478,23 @@   let contentLines' =   drop (startLine' - 1)                       $ take (endLine' - 1) contentLines   let contentLines'' = (case trim <$> lookup "end-before" fields of-                             Just patt -> takeWhile (not . (patt `isInfixOf`))+                             Just patt -> takeWhile (not . (patt `T.isInfixOf`))                              Nothing   -> id) .                        (case trim <$> lookup "start-after" fields of                              Just patt -> drop 1 .-                                            dropWhile (not . (patt `isInfixOf`))+                                            dropWhile (not . (patt `T.isInfixOf`))                              Nothing   -> id) $ contentLines'-  let contents' = unlines contentLines'' ++ "\n"+  let contents' = T.unlines contentLines'' <> "\n"   case lookup "code" fields of        Just lang -> do          let numberLines = lookup "number-lines" fields-         let classes =  maybe [] words (lookup "class" fields)+         let classes =  maybe [] T.words (lookup "class" fields)          let ident = maybe "" trimr $ lookup "name" fields          codeblock ident classes numberLines (trimr lang) contents' False        Nothing   -> case lookup "literal" fields of                          Just _  -> return $ B.rawBlock "rst" contents'                          Nothing -> do-                           setPosition $ newPos f 1 1+                           setPosition $ newPos (T.unpack f) 1 1                            setInput contents'                            bs <- optional blanklines >>                                   (mconcat <$> many block)@@ -516,14 +519,14 @@   term <- trimInlines . mconcat <$> many1Till inline endline   raw <- indentedBlock   -- parse the extracted block, which may contain various block elements:-  contents <- parseFromString' parseBlocks $ raw ++ "\n"+  contents <- parseFromString' parseBlocks $ raw <> "\n"   return (term, [contents])  definitionList :: PandocMonad m => RSTParser m Blocks definitionList = B.definitionList <$> many1 definitionListItem  -- parses bullet list start and returns its length (inc. following whitespace)-bulletListStart :: Monad m => ParserT [Char] st m Int+bulletListStart :: Monad m => ParserT Text st m Int bulletListStart = try $ do   notFollowedBy' hrule  -- because hrules start out just like lists   marker <- oneOf bulletListMarkers@@ -540,7 +543,7 @@   return $ markerLen + length white  -- parse a line of a list item-listLine :: Monad m => Int -> RSTParser m [Char]+listLine :: Monad m => Int -> RSTParser m Text listLine markerLength = try $ do   notFollowedBy blankline   indentWith markerLength@@ -548,21 +551,21 @@  -- parse raw text for one list item, excluding start marker and continuations rawListItem :: Monad m => RSTParser m Int-            -> RSTParser m (Int, [Char])+            -> RSTParser m (Int, Text) rawListItem start = try $ do   markerLength <- start   firstLine <- anyLineNewline   restLines <- many (listLine markerLength)-  return (markerLength, firstLine ++ concat restLines)+  return (markerLength, firstLine <> T.concat restLines)  -- continuation of a list item - indented and separated by blankline or -- (in compact lists) endline. -- Note: nested lists are parsed as continuations.-listContinuation :: Monad m => Int -> RSTParser m [Char]+listContinuation :: Monad m => Int -> RSTParser m Text listContinuation markerLength = try $ do-  blanks <- many1 blankline+  blanks <- many1Char blankline   result <- many1 (listLine markerLength)-  return $ blanks ++ concat result+  return $ blanks <> T.concat result  listItem :: PandocMonad m          => RSTParser m Int@@ -578,7 +581,7 @@   let oldContext = stateParserContext state   setState $ state {stateParserContext = ListItemState}   -- parse the extracted block, which may itself contain block elements-  parsed <- parseFromString' parseBlocks $ concat (first:rest) ++ "\n"+  parsed <- parseFromString' parseBlocks $ T.concat (first:rest) <> "\n"   updateState (\st -> st {stateParserContext = oldContext})   return $ case B.toList parsed of                 [Para xs] ->@@ -614,9 +617,9 @@   optional indentedBlock   return mempty -directiveLabel :: Monad m => RSTParser m String-directiveLabel = map toLower-  <$> many1Till (letter <|> char '-') (try $ string "::")+directiveLabel :: Monad m => RSTParser m Text+directiveLabel = T.toLower+  <$> many1TillChar (letter <|> char '-') (try $ string "::")  directive :: PandocMonad m => RSTParser m Blocks directive = try $ do@@ -628,7 +631,7 @@   skipMany1 spaceChar   label <- directiveLabel   skipMany spaceChar-  top <- many $ satisfy (/='\n')+  top <- manyChar $ satisfy (/='\n')              <|> try (char '\n' <*                       notFollowedBy' (rawFieldListItem 1) <*                       many1 (char ' ') <*@@ -641,35 +644,33 @@        else many $ rawFieldListItem fieldIndent   body <- option "" $ try $ blanklines >> indentedBlock   optional blanklines-  let body' = body ++ "\n\n"+  let body' = body <> "\n\n"       name = trim $ fromMaybe "" (lookup "name" fields)-      classes = words $ maybe "" trim (lookup "class" fields)+      classes = T.words $ maybe "" trim (lookup "class" fields)       keyvals = [(k, trim v) | (k, v) <- fields, k /= "name", k /= "class"]-      imgAttr cl = ("", classes ++ alignClasses, widthAttr ++ heightAttr)+      imgAttr cl = (name, classes ++ alignClasses, widthAttr ++ heightAttr)         where-          alignClasses = words $ maybe "" trim (lookup cl fields) ++-                          maybe "" (\x -> "align-" ++ trim x)+          alignClasses = T.words $ maybe "" trim (lookup cl fields) <>+                          maybe "" (\x -> "align-" <> trim x)                           (lookup "align" fields)           scale = case trim <$> lookup "scale" fields of-                       Just v  -> case reverse v of-                                       '%':vv ->-                                         case safeRead (reverse vv) of-                                              Just (percent :: Double)-                                                      -> percent / 100.0-                                              Nothing -> 1.0-                                       _ ->-                                         case safeRead v of-                                              Just (s :: Double) -> s-                                              Nothing            -> 1.0-                       Nothing -> 1.0+                    Just v -> case T.unsnoc v of+                      Just (vv, '%') -> case safeRead vv of+                                          Just (percent :: Double)+                                            -> percent / 100.0+                                          Nothing -> 1.0+                      _ -> case safeRead v of+                             Just (s :: Double) -> s+                             Nothing            -> 1.0+                    Nothing -> 1.0           widthAttr = maybe [] (\x -> [("width",-                                        show $ scaleDimension scale x)])+                                        tshow $ scaleDimension scale x)])                         $ lookup "width" fields >>=-                          (lengthToDim . filter (not . isSpace))+                          (lengthToDim . T.filter (not . isSpace))           heightAttr = maybe [] (\x -> [("height",-                                         show $ scaleDimension scale x)])+                                         tshow $ scaleDimension scale x)])                         $ lookup "height" fields >>=-                          (lengthToDim . filter (not . isSpace))+                          (lengthToDim . T.filter (not . isSpace))   case label of         "include" -> includeDirective top fields body'         "table" -> tableDirective top fields body'@@ -679,36 +680,37 @@         "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)         "role" -> addNewRole top $ map (second trim) fields         "container" -> B.divWith-                         (name, "container" : words top ++ classes, []) <$>+                         (name, "container" : T.words top ++ classes, []) <$>                           parseFromString' parseBlocks body'         "replace" -> B.para <$>  -- consumed by substKey-                   parseInlineFromString (trim top)+                   parseInlineFromText (trim top)         "unicode" -> B.para <$>  -- consumed by substKey-                   parseInlineFromString (trim $ unicodeTransform top)+                   parseInlineFromText (trim $ unicodeTransform top)         "compound" -> parseFromString' parseBlocks body'         "pull-quote" -> B.blockQuote <$> parseFromString' parseBlocks body'         "epigraph" -> B.blockQuote <$> parseFromString' parseBlocks body'         "highlights" -> B.blockQuote <$> parseFromString' parseBlocks body'-        "rubric" -> B.para . B.strong <$> parseInlineFromString top+        "rubric" -> B.para . B.strong <$> parseInlineFromText top         _ | label `elem` ["attention","caution","danger","error","hint",                           "important","note","tip","warning","admonition"] ->-           do bod <- parseFromString' parseBlocks $ top ++ "\n\n" ++ body'+           do bod <- parseFromString' parseBlocks $ top <> "\n\n" <> body'               let lab = case label of-                             "admonition" -> mempty-                             (l:ls) -> B.divWith ("",["admonition-title"],[])-                                          (B.para (B.str (toUpper l : ls)))-                             [] -> mempty+                          "admonition" -> mempty+                          (T.uncons -> Just (l, ls))+                            -> B.divWith ("",["title"],[])+                                          (B.para (B.str $ T.cons (toUpper l)  ls))+                          _ -> mempty               return $ B.divWith (name,label:classes,keyvals) (lab <> bod)         "sidebar" ->            do let subtit = maybe "" trim $ lookup "subtitle" fields-              tit <- B.para . B.strong <$> parseInlineFromString-                          (trim top ++ if null subtit+              tit <- B.para . B.strong <$> parseInlineFromText+                          (trim top <> if T.null subtit                                           then ""-                                          else (":  " ++ subtit))+                                          else (":  " <> subtit))               bod <- parseFromString' parseBlocks body'               return $ B.divWith (name,"sidebar":classes,keyvals) $ tit <> bod         "topic" ->-           do tit <- B.para . B.strong <$> parseInlineFromString top+           do tit <- B.para . B.strong <$> parseInlineFromText top               bod <- parseFromString' parseBlocks body'               return $ B.divWith (name,"topic":classes,keyvals) $ tit <> bod         "default-role" -> mempty <$ updateState (\s ->@@ -723,7 +725,7 @@           let attribs = (name, ["aafig"], map (second trimr) fields)           return $ B.codeBlockWith attribs $ stripTrailingNewlines body         "math" -> return $ B.para $ mconcat $ map B.displayMath-                         $ toChunks $ top ++ "\n\n" ++ body+                         $ toChunks $ top <> "\n\n" <> body         "figure" -> do            (caption, legend) <- parseFromString' extractCaption body'            let src = escapeURI $ trim top@@ -739,7 +741,7 @@                                      $ B.imageWith attr src "" alt                           Nothing -> B.imageWith attr src "" alt         "class" -> do-            let attrs = (name, words (trim top), map (second trimr) fields)+            let attrs = (name, T.words (trim top), map (second trimr) fields)             --  directive content or the first immediately following element             children <- case body of                 "" -> block@@ -747,12 +749,12 @@             return $ B.divWith attrs children         other     -> do             pos <- getPosition-            logMessage $ SkippedContent (".. " ++ other) pos-            bod <- parseFromString' parseBlocks $ top ++ "\n\n" ++ body'+            logMessage $ SkippedContent (".. " <> other) pos+            bod <- parseFromString' parseBlocks $ top <> "\n\n" <> body'             return $ B.divWith (name, other:classes, keyvals) bod  tableDirective :: PandocMonad m-               => String -> [(String, String)] -> String -> RSTParser m Blocks+               => Text -> [(Text, Text)] -> Text -> RSTParser m Blocks tableDirective top fields body = do   bs <- parseFromString' parseBlocks body   case B.toList bs of@@ -767,7 +769,7 @@                            Just "grid" -> widths'                            Just specs -> normWidths                                $ map (fromMaybe (0 :: Double) . safeRead)-                               $ splitBy (`elem` (" ," :: String)) specs+                               $ splitTextBy (`elem` (" ," :: String)) specs                            Nothing -> widths'          -- align is not applicable since we can't represent whole table align          return $ B.singleton $ Table (B.toList title)@@ -780,7 +782,7 @@ -- since Pandoc doesn't support a table with multiple header rows. -- We don't need to parse :align: as it represents the whole table align. listTableDirective :: PandocMonad m-                   => String -> [(String, String)] -> String+                   => Text -> [(Text, Text)] -> Text                    -> RSTParser m Blocks listTableDirective top fields body = do   bs <- parseFromString' parseBlocks body@@ -796,7 +798,7 @@       widths = case trim <$> lookup "widths" fields of         Just "auto" -> replicate numOfCols 0         Just specs -> normWidths $ map (fromMaybe (0 :: Double) . safeRead) $-                           splitBy (`elem` (" ," :: String)) specs+                           splitTextBy (`elem` (" ," :: String)) specs         _ -> replicate numOfCols 0   return $ B.table title              (zip (replicate numOfCols AlignDefault) widths)@@ -809,7 +811,7 @@           normWidths ws = map (/ max 1 (sum ws)) ws  csvTableDirective :: PandocMonad m-                   => String -> [(String, String)] -> String+                   => Text -> [(Text, Text)] -> Text                    -> RSTParser m Blocks csvTableDirective top fields rawcsv = do   let explicitHeader = trim <$> lookup "header" fields@@ -817,14 +819,17 @@                 csvDelim = case trim <$> lookup "delim" fields of                                 Just "tab"   -> '\t'                                 Just "space" -> ' '-                                Just [c]     -> c+                                Just (T.unpack -> [c])+                                             -> c                                 _            -> ','               , csvQuote = case trim <$> lookup "quote" fields of-                                Just [c] -> c-                                _        -> '"'+                                Just (T.unpack -> [c])+                                  -> c+                                _ -> '"'               , csvEscape = case trim <$> lookup "escape" fields of-                                Just [c] -> Just c-                                _        -> Nothing+                                Just (T.unpack -> [c])+                                  -> Just c+                                _ -> Nothing               , csvKeepSpace = case trim <$> lookup "keepspace" fields of                                        Just "true" -> True                                        _           -> False@@ -837,16 +842,16 @@                     lookup "file" fields `mplus` lookup "url" fields of                   Just u  -> do                     (bs, _) <- fetchItem u-                    return $ UTF8.toString bs+                    return $ UTF8.toText bs                   Nothing -> return rawcsv-  let res = parseCSV opts (T.pack $ case explicitHeader of-                                         Just h  -> h ++ "\n" ++ rawcsv'-                                         Nothing -> rawcsv')+  let res = parseCSV opts (case explicitHeader of+                              Just h  -> h <> "\n" <> rawcsv'+                              Nothing -> rawcsv')   case res of        Left e  ->          throwError $ PandocParsecError "csv table" e        Right rawrows -> do-         let parseCell = parseFromString' (plain <|> return mempty) . T.unpack+         let parseCell = parseFromString' (plain <|> return mempty)          let parseRow = mapM parseCell          rows <- mapM parseRow rawrows          let (headerRow,bodyRows,numOfCols) =@@ -862,7 +867,7 @@                  Just "auto" -> replicate numOfCols 0                  Just specs -> normWidths                                $ map (fromMaybe (0 :: Double) . safeRead)-                               $ splitBy (`elem` (" ," :: String)) specs+                               $ splitTextBy (`elem` (" ," :: String)) specs                  _ -> replicate numOfCols 0          return $ B.table title                   (zip (replicate numOfCols AlignDefault) widths)@@ -873,10 +878,10 @@ --  - Only supports :format: fields with a single format for :raw: roles, --    change Text.Pandoc.Definition.Format to fix addNewRole :: PandocMonad m-           => String -> [(String, String)] -> RSTParser m Blocks-addNewRole roleString fields = do+           => Text -> [(Text, Text)] -> RSTParser m Blocks+addNewRole roleText fields = do     pos <- getPosition-    (role, parentRole) <- parseFromString' inheritedRole roleString+    (role, parentRole) <- parseFromString' inheritedRole roleText     customRoles <- stateRstCustomRoles <$> getState     let getBaseRole (r, f, a) roles =             case M.lookup r roles of@@ -885,7 +890,7 @@         (baseRole, baseFmt, baseAttr) =                getBaseRole (parentRole, Nothing, nullAttr) customRoles         fmt = if parentRole == "raw" then lookup "format" fields else baseFmt-        annotate :: [String] -> [String]+        annotate :: [Text] -> [Text]         annotate = maybe id (:) $             if baseRole == "code"                then lookup "language" fields@@ -901,7 +906,7 @@                         pos                  "format" -> when (baseRole /= "raw") $ logMessage $                      SkippedContent ":format: [because parent of role is not :raw:]" pos-                 _ -> logMessage $ SkippedContent (":" ++ key ++ ":") pos+                 _ -> logMessage $ SkippedContent (":" <> key <> ":") pos     when (parentRole == "raw" && countKeys "format" > 1) $         logMessage $ SkippedContent                   ":format: [after first in definition of role]"@@ -927,30 +932,29 @@ -- hexadecimal numbers, prefixed by 0x, x, \x, U+, u, or \u -- or as XML-style hexadecimal character entities, e.g. &#x1a2b; -- or text, which is used as-is.  Comments start with ..-unicodeTransform :: String -> String-unicodeTransform t =-  case t of-       ('.':'.':xs)  -> unicodeTransform $ dropWhile (/='\n') xs -- comment-       ('0':'x':xs)  -> go "0x" xs-       ('x':xs)      -> go "x" xs-       ('\\':'x':xs) -> go "\\x" xs-       ('U':'+':xs)  -> go "U+" xs-       ('u':xs)      -> go "u" xs-       ('\\':'u':xs) -> go "\\u" xs-       ('&':'#':'x':xs) -> maybe ("&#x" ++ unicodeTransform xs)-                           -- drop semicolon-                           (\(c,s) -> c : unicodeTransform (drop 1 s))-                           $ extractUnicodeChar xs-       (x:xs)        -> x : unicodeTransform xs-       []            -> []-    where go pref zs = maybe (pref ++ unicodeTransform zs)-                         (\(c,s) -> c : unicodeTransform s)-                         $ extractUnicodeChar zs+unicodeTransform :: Text -> Text+unicodeTransform t+  | Just xs <- T.stripPrefix ".." t  = unicodeTransform $ T.dropWhile (/= '\n') xs -- comment+  | Just xs <- T.stripPrefix "0x" t  = go "0x" xs+  | Just xs <- T.stripPrefix "x" t   = go "x" xs+  | Just xs <- T.stripPrefix "\\x" t = go "\\x" xs+  | Just xs <- T.stripPrefix "U+" t  = go "U+" xs+  | Just xs <- T.stripPrefix "u" t   = go "u" xs+  | Just xs <- T.stripPrefix "\\u" t = go "\\u" xs+  | Just xs <- T.stripPrefix "&#x" t = maybe ("&#x" <> unicodeTransform xs)+                                       -- drop semicolon+                                       (\(c,s) -> T.cons c $ unicodeTransform $ T.drop 1 s)+                                       $ extractUnicodeChar xs+  | Just (x, xs) <- T.uncons t       = T.cons x $ unicodeTransform xs+  | otherwise                        = ""+  where go pref zs = maybe (pref <> unicodeTransform zs)+                     (\(c,s) -> T.cons c $ unicodeTransform s)+                     $ extractUnicodeChar zs -extractUnicodeChar :: String -> Maybe (Char, String)+extractUnicodeChar :: Text -> Maybe (Char, Text) extractUnicodeChar s = maybe Nothing (\c -> Just (c,rest)) mbc-  where (ds,rest) = span isHexDigit s-        mbc = safeRead ('\'':'\\':'x':ds ++ "'")+  where (ds,rest) = T.span isHexDigit s+        mbc = safeRead ("'\\x" <> ds <> "'")  extractCaption :: PandocMonad m => RSTParser m (Inlines, Blocks) extractCaption = do@@ -960,16 +964,16 @@  -- divide string by blanklines, and surround with -- \begin{aligned}...\end{aligned} if needed.-toChunks :: String -> [String]-toChunks = dropWhile null-           . map (addAligned . trim . unlines)-           . splitBy (all (`elem` (" \t" :: String))) . lines+toChunks :: Text -> [Text]+toChunks = dropWhile T.null+           . map (addAligned . trim . T.unlines)+           . splitBy (T.all (`elem` (" \t" :: String))) . T.lines   -- we put this in an aligned environment if it contains \\, see #4254-  where addAligned s = if "\\\\" `isInfixOf` s-                          then "\\begin{aligned}\n" ++ s ++ "\n\\end{aligned}"+  where addAligned s = if "\\\\" `T.isInfixOf` s+                          then "\\begin{aligned}\n" <> s <> "\n\\end{aligned}"                           else s -codeblock :: String -> [String] -> Maybe String -> String -> String -> Bool+codeblock :: Text -> [Text] -> Maybe Text -> Text -> Text -> Bool           -> RSTParser m Blocks codeblock ident classes numberLines lang body rmTrailingNewlines =   return $ B.codeBlockWith attribs $ stripTrailingNewlines' body@@ -981,7 +985,7 @@                     : maybe [] (const ["numberLines"]) numberLines                     ++ classes           kvs = maybe [] (\n -> case trimr n of-                                   [] -> []+                                   "" -> []                                    xs -> [("startFrom", xs)])                             numberLines @@ -989,25 +993,25 @@ --- note block --- -noteBlock :: Monad m => RSTParser m [Char]+noteBlock :: Monad m => RSTParser m Text noteBlock = try $ do   (ref, raw, replacement) <- noteBlock' noteMarker   updateState $ \s -> s { stateNotes = (ref, raw) : stateNotes s }   -- return blanks so line count isn't affected   return replacement -citationBlock :: Monad m => RSTParser m [Char]+citationBlock :: Monad m => RSTParser m Text citationBlock = try $ do   (ref, raw, replacement) <- noteBlock' citationMarker   updateState $ \s ->      s { stateCitations = M.insert ref raw (stateCitations s),-         stateKeys = M.insert (toKey ref) (('#':ref,""), ("",["citation"],[]))+         stateKeys = M.insert (toKey ref) (("#" <> ref,""), ("",["citation"],[]))                                (stateKeys s) }   -- return blanks so line count isn't affected   return replacement  noteBlock' :: Monad m-           => RSTParser m String -> RSTParser m (String, String, String)+           => RSTParser m Text -> RSTParser m (Text, Text, Text) noteBlock' marker = try $ do   startPos <- getPosition   string ".."@@ -1018,24 +1022,24 @@   blanks <- option "" blanklines   rest <- option "" indentedBlock   endPos <- getPosition-  let raw = first ++ "\n" ++ blanks ++ rest ++ "\n"-  let replacement =replicate (sourceLine endPos - sourceLine startPos) '\n'+  let raw = first <> "\n" <> blanks <> rest <> "\n"+  let replacement = T.replicate (sourceLine endPos - sourceLine startPos) "\n"   return (ref, raw, replacement) -citationMarker :: Monad m => RSTParser m [Char]+citationMarker :: Monad m => RSTParser m Text citationMarker = do   char '['   res <- simpleReferenceName   char ']'   return res -noteMarker :: Monad m => RSTParser m [Char]+noteMarker :: Monad m => RSTParser m Text noteMarker = do   char '['-  res <- many1 digit+  res <- many1Char digit       <|>-                  try (char '#' >> liftM ('#':) simpleReferenceName)-      <|> count 1 (oneOf "#*")+                  try (char '#' >> liftM ("#" <>) simpleReferenceName)+      <|> countChar 1 (oneOf "#*")   char ']'   return res @@ -1043,47 +1047,48 @@ -- reference key -- -quotedReferenceName :: PandocMonad m => RSTParser m String+quotedReferenceName :: PandocMonad m => RSTParser m Text quotedReferenceName = try $ do   char '`' >> notFollowedBy (char '`') -- `` means inline code!-  manyTill anyChar (char '`')+  manyTillChar anyChar (char '`')  -- Simple reference names are single words consisting of alphanumerics -- plus isolated (no two adjacent) internal hyphens, underscores, -- periods, colons and plus signs; no whitespace or other characters -- are allowed.-simpleReferenceName :: Monad m => ParserT [Char] st m String+simpleReferenceName :: Monad m => ParserT Text st m Text simpleReferenceName = do   x <- alphaNum   xs <- many $  alphaNum             <|> try (oneOf "-_:+." <* lookAhead alphaNum)-  return (x:xs)+  return $ T.pack (x:xs) -referenceName :: PandocMonad m => RSTParser m String+referenceName :: PandocMonad m => RSTParser m Text referenceName = quotedReferenceName <|> simpleReferenceName -referenceKey :: PandocMonad m => RSTParser m [Char]+referenceKey :: PandocMonad m => RSTParser m Text referenceKey = do   startPos <- getPosition   choice [substKey, anonymousKey, regularKey]   optional blanklines   endPos <- getPosition   -- return enough blanks to replace key-  return $ replicate (sourceLine endPos - sourceLine startPos) '\n'+  return $ T.replicate (sourceLine endPos - sourceLine startPos) "\n" -targetURI :: Monad m => ParserT [Char] st m [Char]+targetURI :: Monad m => ParserT Text st m Text targetURI = do   skipSpaces   optional $ try $ newline >> notFollowedBy blankline   contents <- trim <$>-     many1 (satisfy (/='\n')+     many1Char (satisfy (/='\n')      <|> try (newline >> many1 spaceChar >> noneOf " \t\n"))   blanklines-  case reverse contents of-       -- strip backticks-       '_':'`':xs -> return (dropWhile (=='`') (reverse xs) ++ "_")-       '_':_      -> return contents-       _          -> return (escapeURI contents)+  return $ stripBackticks contents+  where+    stripBackticks t+      | Just xs <- T.stripSuffix "`_" t = T.dropWhile (=='`') xs <> "_"+      | Just _  <- T.stripSuffix "_"  t = t+      | otherwise                       = escapeURI t  substKey :: PandocMonad m => RSTParser m () substKey = try $ do@@ -1109,21 +1114,21 @@   oneOfStrings [".. __:", "__"]   src <- targetURI   pos <- getPosition-  let key = toKey $ "_" ++ printf "%09d" (sourceLine pos)+  let key = toKey $ "_" <> T.pack (printf "%09d" (sourceLine pos))   updateState $ \s -> s { stateKeys = M.insert key ((src,""), nullAttr) $                           stateKeys s } -referenceNames :: PandocMonad m => RSTParser m [String]+referenceNames :: PandocMonad m => RSTParser m [Text] referenceNames = do   let rn = try $ do              string ".. _"              ref <- quotedReferenceName-                  <|> many (  noneOf ":\n"-                          <|> try (char '\n' <*-                                   string "   " <*-                                   notFollowedBy blankline)-                          <|> try (char ':' <* lookAhead alphaNum)-                           )+                  <|> manyChar (  noneOf ":\n"+                              <|> try (char '\n' <*+                                       string "   " <*+                                       notFollowedBy blankline)+                              <|> try (char ':' <* lookAhead alphaNum)+                               )              char ':'              return ref   first <- rn@@ -1137,18 +1142,18 @@   -- .. _goodbye: url.com   refs <- referenceNames   src <- targetURI-  guard $ not (null src)+  guard $ not (T.null src)   let keys = map toKey refs   forM_ keys $ \key ->     updateState $ \s -> s { stateKeys = M.insert key ((src,""), nullAttr) $                             stateKeys s } -anchorDef :: PandocMonad m => RSTParser m [Char]+anchorDef :: PandocMonad m => RSTParser m Text anchorDef = try $ do   (refs, raw) <- withRaw $ try (referenceNames <* blanklines)   forM_ refs $ \rawkey ->     updateState $ \s -> s { stateKeys =-       M.insert (toKey rawkey) (('#':rawkey,""), nullAttr) $ stateKeys s }+       M.insert (toKey rawkey) (("#" <> rawkey,""), nullAttr) $ stateKeys s }   -- keep this for 2nd round of parsing, where we'll add the divs (anchor)   return raw @@ -1171,12 +1176,12 @@                 -- because it hides them from promoteHeader, see #4240        _ -> return $ foldr addDiv b refs -headerBlock :: PandocMonad m => RSTParser m [Char]+headerBlock :: PandocMonad m => RSTParser m Text headerBlock = do   ((txt, _), raw) <- withRaw (doubleHeader' <|> singleHeader')   (ident,_,_) <- registerHeader nullAttr txt   let key = toKey (stringify txt)-  updateState $ \s -> s { stateKeys = M.insert key (('#':ident,""), nullAttr)+  updateState $ \s -> s { stateKeys = M.insert key (("#" <> ident,""), nullAttr)                           $ stateKeys s }   return raw @@ -1198,13 +1203,13 @@ -- Grid tables TODO: --  - column spans -dashedLine :: Monad m => Char -> ParserT [Char] st m (Int, Int)+dashedLine :: Monad m => Char -> ParserT Text st m (Int, Int) dashedLine ch = do   dashes <- many1 (char ch)   sp     <- many (char ' ')   return (length dashes, length $ dashes ++ sp) -simpleDashedLines :: Monad m => Char -> ParserT [Char] st m [(Int,Int)]+simpleDashedLines :: Monad m => Char -> ParserT Text st m [(Int,Int)] simpleDashedLines ch = try $ many1 (dashedLine ch)  -- Parse a table row separator@@ -1212,17 +1217,17 @@ simpleTableSep ch = try $ simpleDashedLines ch >> newline  -- Parse a table footer-simpleTableFooter :: Monad m => RSTParser m [Char]+simpleTableFooter :: Monad m => RSTParser m Text simpleTableFooter = try $ simpleTableSep '=' >> blanklines  -- Parse a raw line and split it into chunks by indices.-simpleTableRawLine :: Monad m => [Int] -> RSTParser m [String]+simpleTableRawLine :: Monad m => [Int] -> RSTParser m [Text] simpleTableRawLine indices = simpleTableSplitLine indices <$> anyLine -simpleTableRawLineWithEmptyCell :: Monad m => [Int] -> RSTParser m [String]+simpleTableRawLineWithEmptyCell :: Monad m => [Int] -> RSTParser m [Text] simpleTableRawLineWithEmptyCell indices = try $ do   cs <- simpleTableRawLine indices-  let isEmptyCell = all (\c -> c == ' ' || c == '\t')+  let isEmptyCell = T.all (\c -> c == ' ' || c == '\t')   guard $ any isEmptyCell cs   return cs @@ -1232,15 +1237,15 @@   notFollowedBy' simpleTableFooter   firstLine <- simpleTableRawLine indices   conLines  <- many $ simpleTableRawLineWithEmptyCell indices-  let cols = map unlines . transpose $ firstLine : conLines ++-                                 [replicate (length indices) ""-                                   | not (null conLines)]+  let cols = map T.unlines . transpose $ firstLine : conLines +++                                  [replicate (length indices) ""+                                    | not (null conLines)]   mapM (parseFromString' parseBlocks) cols -simpleTableSplitLine :: [Int] -> String -> [String]+simpleTableSplitLine :: [Int] -> Text -> [Text] simpleTableSplitLine indices line =   map trimr-  $ tail $ splitByIndices (init indices) line+  $ tail $ splitTextByIndices (init indices) line  simpleTableHeader :: PandocMonad m                   => Bool  -- ^ Headerless table@@ -1319,35 +1324,35 @@                        , escapedChar                        , symbol ] <?> "inline content" -parseInlineFromString :: PandocMonad m => String -> RSTParser m Inlines-parseInlineFromString = parseFromString' (trimInlines . mconcat <$> many inline)+parseInlineFromText :: PandocMonad m => Text -> RSTParser m Inlines+parseInlineFromText = parseFromString' (trimInlines . mconcat <$> many inline)  hyphens :: Monad m => RSTParser m Inlines hyphens = do-  result <- many1 (char '-')+  result <- many1Char (char '-')   optional endline   -- don't want to treat endline after hyphen or dash as a space   return $ B.str result -escapedChar :: Monad m => ParserT [Char] st m Inlines+escapedChar :: Monad m => ParserT Text st m Inlines escapedChar = do c <- escaped anyChar                  return $ if c == ' ' || c == '\n' || c == '\r'                              -- '\ ' is null in RST                              then mempty-                             else B.str [c]+                             else B.str $ T.singleton c  symbol :: Monad m => RSTParser m Inlines symbol = do   result <- oneOf specialChars-  return $ B.str [result]+  return $ B.str $ T.singleton result  -- parses inline code, between codeStart and codeEnd code :: Monad m => RSTParser m Inlines code = try $ do   string "``"-  result <- manyTill anyChar (try (string "``"))+  result <- manyTillChar anyChar (try (string "``"))   return $ B.code-         $ trim $ unwords $ lines result+         $ trim $ T.unwords $ T.lines result  -- succeeds only if we're not right after a str (ie. in middle of word) atStart :: Monad m => RSTParser m a -> RSTParser m a@@ -1379,7 +1384,7 @@   renderRole contents Nothing role nullAttr  renderRole :: PandocMonad m-           => String -> Maybe String -> String -> Attr -> RSTParser m Inlines+           => Text -> Maybe Text -> Text -> Attr -> RSTParser m Inlines renderRole contents fmt role attr = case role of     "sup"  -> return $ B.superscript $ treatAsText contents     "superscript" -> return $ B.superscript $ treatAsText contents@@ -1409,36 +1414,36 @@                           contents  where    titleRef ref = return $ B.spanWith ("",["title-ref"],[]) $ treatAsText ref-   rfcLink rfcNo = B.link rfcUrl ("RFC " ++ rfcNo) $ B.str ("RFC " ++ rfcNo)-     where rfcUrl = "http://www.faqs.org/rfcs/rfc" ++ rfcNo ++ ".html"-   pepLink pepNo = B.link pepUrl ("PEP " ++ pepNo) $ B.str ("PEP " ++ pepNo)-     where padNo = replicate (4 - length pepNo) '0' ++ pepNo-           pepUrl = "http://www.python.org/dev/peps/pep-" ++ padNo ++ "/"+   rfcLink rfcNo = B.link rfcUrl ("RFC " <> rfcNo) $ B.str ("RFC " <> rfcNo)+     where rfcUrl = "http://www.faqs.org/rfcs/rfc" <> rfcNo <> ".html"+   pepLink pepNo = B.link pepUrl ("PEP " <> pepNo) $ B.str ("PEP " <> pepNo)+     where padNo = T.replicate (4 - T.length pepNo) "0" <> pepNo+           pepUrl = "http://www.python.org/dev/peps/pep-" <> padNo <> "/"    treatAsText = B.text . handleEscapes-   handleEscapes [] = []-   handleEscapes ('\\':' ':cs) = handleEscapes cs-   handleEscapes ('\\':c:cs) = c : handleEscapes cs-   handleEscapes (c:cs) = c : handleEscapes cs+   handleEscapes = T.concat . removeSpace . T.splitOn "\\"+     where headSpace t = fromMaybe t $ T.stripPrefix " " t+           removeSpace (x:xs) = x : map headSpace xs+           removeSpace []     = [] -roleName :: PandocMonad m => RSTParser m String-roleName = many1 (letter <|> char '-')+roleName :: PandocMonad m => RSTParser m Text+roleName = many1Char (letter <|> char '-') -roleMarker :: PandocMonad m => RSTParser m String+roleMarker :: PandocMonad m => RSTParser m Text roleMarker = char ':' *> roleName <* char ':' -roleBefore :: PandocMonad m => RSTParser m (String,String)+roleBefore :: PandocMonad m => RSTParser m (Text,Text) roleBefore = try $ do   role <- roleMarker   contents <- unmarkedInterpretedText   return (role,contents) -roleAfter :: PandocMonad m => RSTParser m (String,String)+roleAfter :: PandocMonad m => RSTParser m (Text,Text) roleAfter = try $ do   contents <- unmarkedInterpretedText   role <- roleMarker <|> (stateRstDefaultRole <$> getState)   return (role,contents) -unmarkedInterpretedText :: PandocMonad m => RSTParser m [Char]+unmarkedInterpretedText :: PandocMonad m => RSTParser m Text unmarkedInterpretedText = try $ do   atStart (char '`')   contents <- mconcat <$> (many1@@ -1450,7 +1455,7 @@                 lookAhead (satisfy isAlphaNum))        ))   char '`'-  return contents+  return $ T.pack contents  whitespace :: PandocMonad m => RSTParser m Inlines whitespace = B.space <$ skipMany1 spaceChar <?> "whitespace"@@ -1458,7 +1463,7 @@ str :: Monad m => RSTParser m Inlines str = do   let strChar = noneOf ("\t\n " ++ specialChars)-  result <- many1 strChar+  result <- many1Char strChar   updateLastStrPos   return $ B.str result @@ -1486,7 +1491,7 @@   notFollowedBy (char '`') -- `` marks start of inline code   label' <- trimInlines . mconcat <$>              manyTill (notFollowedBy (char '`') >> inlineContent) (char '<')-  src <- trim <$> manyTill (noneOf ">\n") (char '>')+  src <- trim <$> manyTillChar (noneOf ">\n") (char '>')   skipSpaces   string "`_"   optional $ char '_' -- anonymous form@@ -1494,22 +1499,26 @@                    then B.str src                    else label'   -- `link <google_>` is a reference link to _google!-  ((src',tit),attr) <- case reverse src of-                          '_':xs -> lookupKey [] (toKey (reverse xs))-                          _      -> return ((src, ""), nullAttr)+  ((src',tit),attr) <-+    if isURI src+       then return ((src, ""), nullAttr)+       else+         case T.unsnoc src of+           Just (xs, '_') -> lookupKey [] (toKey xs)+           _              -> return ((src, ""), nullAttr)   return $ B.linkWith attr (escapeURI src') tit label'' -citationName :: PandocMonad m => RSTParser m String+citationName :: PandocMonad m => RSTParser m Text citationName = do   raw <- citationMarker-  return $ "[" ++ raw ++ "]"+  return $ "[" <> raw <> "]"  referenceLink :: PandocMonad m => RSTParser m Inlines referenceLink = try $ do   ref <- (referenceName <|> citationName) <* char '_'   let label' = B.text ref-  let isAnonKey (Key ('_':_)) = True-      isAnonKey _             = False+  let isAnonKey (Key (T.uncons -> Just ('_',_))) = True+      isAnonKey _                                = False   state <- getState   let keyTable = stateKeys state   key <- option (toKey ref) $@@ -1526,7 +1535,7 @@  -- We keep a list of oldkeys so we can detect lookup loops. lookupKey :: PandocMonad m-          => [Key] -> Key -> RSTParser m ((String, String), Attr)+          => [Key] -> Key -> RSTParser m ((Text, Text), Attr) lookupKey oldkeys key = do   pos <- getPosition   state <- getState@@ -1537,8 +1546,8 @@          logMessage $ ReferenceNotFound key' pos          return (("",""),nullAttr)        -- check for keys of the form link_, which need to be resolved:-       Just ((u@(_:_),""),_) | last u == '_' -> do-         let rawkey = init u+       Just ((u, ""),_) | T.length u > 1, T.last u == '_', T.head u /= '#' -> do+         let rawkey = T.init u          let newkey = toKey rawkey          if newkey `elem` oldkeys             then do@@ -1569,7 +1578,7 @@   case M.lookup key substTable of        Nothing     -> do          pos <- getPosition-         logMessage $ ReferenceNotFound (show key) pos+         logMessage $ ReferenceNotFound (tshow key) pos          return mempty        Just target -> return target 
src/Text/Pandoc/Readers/Roff.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns #-} {- |    Module      : Text.Pandoc.Readers.Roff    Copyright   : Copyright (C) 2018-2019 Yan Pashkovsky and John MacFarlane@@ -21,7 +23,7 @@   , TableRow   , RoffToken(..)   , RoffTokens(..)-  , linePartsToString+  , linePartsToText   , lexRoff   ) where@@ -32,8 +34,7 @@ import Control.Monad.Except (throwError) import Text.Pandoc.Class        (getResourcePath, readFileFromDirs, PandocMonad(..), report)-import Data.Char (isLower, toLower, toUpper, chr,-                  isAscii, isAlphaNum, isSpace)+import Data.Char (isLower, toLower, toUpper, chr, isAscii, isAlphaNum) import Data.Default (Default) import qualified Data.Map as M import Data.List (intercalate)@@ -41,9 +42,8 @@ import Text.Pandoc.Logging (LogMessage(..)) import Text.Pandoc.Options import Text.Pandoc.Parsing-import Text.Pandoc.Shared (safeRead, substitute)+import Text.Pandoc.Shared (safeRead) import Text.Parsec hiding (tokenPrim)-import qualified Text.Parsec as Parsec import Text.Pandoc.RoffChar (characterCodes, combiningAccents) import qualified Data.Sequence as Seq import qualified Data.Foldable as Foldable@@ -62,28 +62,28 @@ defaultFontSpec :: FontSpec defaultFontSpec = FontSpec False False False -data LinePart = RoffStr String+data LinePart = RoffStr T.Text               | Font FontSpec               | MacroArg Int               deriving Show  type Arg = [LinePart] -type TableOption = (String, String)+type TableOption = (T.Text, T.Text)  data CellFormat =   CellFormat   { columnType     :: Char   , pipePrefix     :: Bool   , pipeSuffix     :: Bool-  , columnSuffixes :: [String]+  , columnSuffixes :: [T.Text]   } deriving (Show, Eq, Ord)  type TableRow = ([CellFormat], [RoffTokens])  data RoffToken = TextLine [LinePart]                | EmptyLine-               | ControlLine String [Arg] SourcePos+               | ControlLine T.Text [Arg] SourcePos                | Tbl [TableOption] [TableRow] SourcePos                deriving Show @@ -97,7 +97,7 @@               | CopyMode               deriving Show -data RoffState = RoffState { customMacros     :: M.Map String RoffTokens+data RoffState = RoffState { customMacros     :: M.Map T.Text RoffTokens                            , prevFont         :: FontSpec                            , currentFont      :: FontSpec                            , tableTabChar     :: Char@@ -123,28 +123,28 @@                   , afterConditional = False                   } -type RoffLexer m = ParserT [Char] RoffState m+type RoffLexer m = ParserT T.Text RoffState m  ----- Lexer: String -> RoffToken+-- Lexer: T.Text -> RoffToken --  eofline :: Stream s m Char => ParsecT s u m ()-eofline = void newline <|> eof+eofline = void newline <|> eof <|> () <$ lookAhead (string "\\}")  spacetab :: Stream s m Char => ParsecT s u m Char spacetab = char ' ' <|> char '\t' -characterCodeMap :: M.Map String Char+characterCodeMap :: M.Map T.Text Char characterCodeMap =   M.fromList $ map (\(x,y) -> (y,x)) characterCodes -combiningAccentsMap :: M.Map String Char+combiningAccentsMap :: M.Map T.Text Char combiningAccentsMap =   M.fromList $ map (\(x,y) -> (y,x)) combiningAccents  escape :: PandocMonad m => RoffLexer m [LinePart]-escape = do+escape = try $ do   backslash   escapeGlyph <|> escapeNormal @@ -153,47 +153,44 @@   c <- lookAhead (oneOf ['[','('])   escapeArg >>= resolveGlyph c -resolveGlyph :: PandocMonad m => Char -> String -> RoffLexer m [LinePart]+resolveGlyph :: PandocMonad m => Char -> T.Text -> RoffLexer m [LinePart] resolveGlyph delimChar glyph = do-  let cs = substitute "_u" " u" glyph -- unicode glyphs separated by _-  (case words cs of+  let cs = T.replace "_u" " u" glyph -- unicode glyphs separated by _+  (case T.words cs of       []  -> mzero       [s] -> case M.lookup s characterCodeMap `mplus` readUnicodeChar s of                Nothing -> mzero-               Just c  -> return [RoffStr [c]]+               Just c  -> return [RoffStr $ T.singleton c]       (s:ss) -> do         basechar <- case M.lookup s characterCodeMap `mplus`                          readUnicodeChar s of                       Nothing ->-                        case s of+                        case T.unpack s of                           [ch] | isAscii ch && isAlphaNum ch ->                                  return ch                           _ -> mzero                       Just c  -> return c-        let addAccents [] xs = return $ T.unpack .-                                 Normalize.normalize Normalize.NFC .-                                 T.pack $ reverse xs+        let addAccents [] xs = return $ Normalize.normalize Normalize.NFC $+                                        T.reverse xs             addAccents (a:as) xs =               case M.lookup a combiningAccentsMap `mplus` readUnicodeChar a of-                Just x  -> addAccents as (x:xs)+                Just x  -> addAccents as $ T.cons x xs                 Nothing -> mzero-        addAccents ss [basechar] >>= \xs -> return [RoffStr xs])+        addAccents ss (T.singleton basechar) >>= \xs -> return [RoffStr xs])       <|> case delimChar of-            '['  -> escUnknown ("\\[" ++ glyph ++ "]")-            '('  -> escUnknown ("\\(" ++ glyph)-            '\'' -> escUnknown ("\\C'" ++ glyph ++ "'")-            _    -> fail "resolveGlyph: unknown glyph delimiter"+            '['  -> escUnknown ("\\[" <> glyph <> "]")+            '('  -> escUnknown ("\\(" <> glyph)+            '\'' -> escUnknown ("\\C'" <> glyph <> "'")+            _    -> Prelude.fail "resolveGlyph: unknown glyph delimiter" -readUnicodeChar :: String -> Maybe Char-readUnicodeChar ('u':cs@(_:_:_:_:_)) =-  case safeRead ('0':'x':cs) of-    Just i  -> Just (chr i)-    Nothing -> Nothing-readUnicodeChar _ = Nothing+readUnicodeChar :: T.Text -> Maybe Char+readUnicodeChar t = case T.uncons t of+  Just ('u', cs) | T.length cs > 3 -> chr <$> safeRead ("0x" <> cs)+  _ -> Nothing  escapeNormal :: PandocMonad m => RoffLexer m [LinePart] escapeNormal = do-  c <- anyChar+  c <- noneOf "{}"   optional expandString   case c of     ' ' -> return [RoffStr " "]@@ -220,14 +217,14 @@         NormalMode -> return [RoffStr "\\"]     'H' -> escIgnore 'H' [quoteArg]     'L' -> escIgnore 'L' [quoteArg]-    'M' -> escIgnore 'M' [escapeArg, count 1 (satisfy (/='\n'))]+    'M' -> escIgnore 'M' [escapeArg, countChar 1 (satisfy (/='\n'))]     'N' -> escIgnore 'N' [quoteArg]-    'O' -> escIgnore 'O' [count 1 (oneOf ['0','1'])]+    'O' -> escIgnore 'O' [countChar 1 (oneOf ['0','1'])]     'R' -> escIgnore 'R' [quoteArg]     'S' -> escIgnore 'S' [quoteArg]-    'V' -> escIgnore 'V' [escapeArg, count 1 alphaNum]+    'V' -> escIgnore 'V' [escapeArg, countChar 1 alphaNum]     'X' -> escIgnore 'X' [quoteArg]-    'Y' -> escIgnore 'Y' [escapeArg, count 1 (satisfy (/='\n'))]+    'Y' -> escIgnore 'Y' [escapeArg, countChar 1 (satisfy (/='\n'))]     'Z' -> escIgnore 'Z' [quoteArg]     '\'' -> return [RoffStr "`"]     '\n' -> return mempty  -- line continuation@@ -240,12 +237,12 @@     'd' -> escIgnore 'd' [] -- forward down 1/2em     'e' -> return [RoffStr "\\"]     'f' -> escFont-    'g' -> escIgnore 'g' [escapeArg, count 1 (satisfy (/='\n'))]+    'g' -> escIgnore 'g' [escapeArg, countChar 1 (satisfy (/='\n'))]     'h' -> escIgnore 'h' [quoteArg]-    'k' -> escIgnore 'k' [escapeArg, count 1 (satisfy (/='\n'))]+    'k' -> escIgnore 'k' [escapeArg, countChar 1 (satisfy (/='\n'))]     'l' -> escIgnore 'l' [quoteArg]-    'm' -> escIgnore 'm' [escapeArg, count 1 (satisfy (/='\n'))]-    'n' -> escIgnore 'm' [escapeArg, count 1 (satisfy (/='\n'))]+    'm' -> escIgnore 'm' [escapeArg, countChar 1 (satisfy (/='\n'))]+    'n' -> escIgnore 'm' [escapeArg, countChar 1 (satisfy (/='\n'))]     'o' -> escIgnore 'o' [quoteArg]     'p' -> escIgnore 'p' []     'r' -> escIgnore 'r' []@@ -255,10 +252,8 @@     'v' -> escIgnore 'v' [quoteArg]     'w' -> escIgnore 'w' [quoteArg]     'x' -> escIgnore 'x' [quoteArg]-    'z' -> escIgnore 'z' [count 1 anyChar]-    '{' -> return mempty+    'z' -> escIgnore 'z' [countChar 1 anyChar]     '|' -> return [RoffStr "\x2006"] --1/6 em space-    '}' -> return mempty     '~' -> return [RoffStr "\160"] -- nonbreaking space     '\\' -> do       mode <- roffMode <$> getState@@ -266,40 +261,40 @@         CopyMode   -> char '\\'         NormalMode -> return '\\'       return [RoffStr "\\"]-    _   -> return [RoffStr [c]]+    _   -> return [RoffStr $ T.singleton c]     -- man 7 groff: "If  a  backslash  is followed by a character that     -- does not constitute a defined escape sequence, the backslash     -- is  silently  ignored  and  the character maps to itself."  escIgnore :: PandocMonad m           => Char-          -> [RoffLexer m String]+          -> [RoffLexer m T.Text]           -> RoffLexer m [LinePart] escIgnore c argparsers = do   pos <- getPosition   arg <- snd <$> withRaw (choice argparsers) <|> return ""-  report $ SkippedContent ('\\':c:arg) pos+  report $ SkippedContent ("\\" <> T.cons c arg) pos   return mempty -escUnknown :: PandocMonad m => String -> RoffLexer m [LinePart]+escUnknown :: PandocMonad m => T.Text -> RoffLexer m [LinePart] escUnknown s = do   pos <- getPosition   report $ SkippedContent s pos   return [RoffStr "\xFFFD"] -signedNumber :: PandocMonad m => RoffLexer m String+signedNumber :: PandocMonad m => RoffLexer m T.Text signedNumber = try $ do   sign <- option "" ("-" <$ char '-' <|> "" <$ char '+')-  ds <- many1 digit-  return (sign ++ ds)+  ds <- many1Char digit+  return (sign <> ds)  -- Parses: [..] or (..-escapeArg :: PandocMonad m => RoffLexer m String+escapeArg :: PandocMonad m => RoffLexer m T.Text escapeArg = choice     [ char '[' *> optional expandString *>-                  manyTill (noneOf ['\n',']']) (char ']')+                  manyTillChar (noneOf ['\n',']']) (char ']')     , char '(' *> optional expandString *>-                  count 2 (satisfy (/='\n'))+                  countChar 2 (satisfy (/='\n'))     ]  expandString :: PandocMonad m => RoffLexer m ()@@ -307,21 +302,21 @@   pos <- getPosition   char '\\'   char '*'-  cs <- escapeArg <|> count 1 anyChar-  s <- linePartsToString <$> resolveString cs pos-  getInput >>= setInput . (s ++)+  cs <- escapeArg <|> countChar 1 anyChar+  s <- linePartsToText <$> resolveText cs pos+  getInput >>= setInput . (s <>)   return ()  -- Parses: '..'-quoteArg :: PandocMonad m => RoffLexer m String-quoteArg = char '\'' *> manyTill (noneOf ['\n','\'']) (char '\'')+quoteArg :: PandocMonad m => RoffLexer m T.Text+quoteArg = char '\'' *> manyTillChar (noneOf ['\n','\'']) (char '\'')  escFont :: PandocMonad m => RoffLexer m [LinePart] escFont = do-  font <- escapeArg <|> count 1 alphaNum-  font' <- if null font || font == "P"+  font <- escapeArg <|> countChar 1 alphaNum+  font' <- if T.null font || font == "P"               then prevFont <$> getState-              else return $ foldr processFontLetter defaultFontSpec font+              else return $ foldr processFontLetter defaultFontSpec $ T.unpack font   modifyState $ \st -> st{ prevFont = currentFont st                          , currentFont = font' }   return [Font font']@@ -338,7 +333,6 @@ lexComment :: PandocMonad m => RoffLexer m RoffTokens lexComment = do   try $ string ".\\\""-  many Parsec.space   skipMany $ noneOf "\n"   eofline   return mempty@@ -350,19 +344,20 @@   guard $ sourceColumn pos == 1 || afterConditional st   char '.' <|> char '\''   skipMany spacetab-  macroName <- many (satisfy (not . isSpace))+  macroName <- manyChar (satisfy isAlphaNum)   case macroName of     "nop" -> return mempty     "ie"  -> lexConditional "ie"     "if"  -> lexConditional "if"     "el"  -> lexConditional "el"+    "while" -> lexConditional "while"+               -- this doesn't get the semantics right but+               -- avoids parse errors      _ -> do        args <- lexArgs        case macroName of          ""     -> return mempty-         "\\\"" -> return mempty-         "\\#"  -> return mempty          "TS"   -> lexTable pos          "de"   -> lexMacroDef args          "de1"  -> lexMacroDef args@@ -378,8 +373,8 @@   spaces   opts <- try tableOptions <|> [] <$ optional (char ';')   case lookup "tab" opts of-    Just (c:_) -> modifyState $ \st -> st{ tableTabChar = c }-    _          -> modifyState $ \st -> st{ tableTabChar = '\t' }+    Just (T.uncons -> Just (c, _)) -> modifyState $ \st -> st{ tableTabChar = c }+    _                              -> modifyState $ \st -> st{ tableTabChar = '\t' }   spaces   skipMany lexComment   spaces@@ -392,7 +387,7 @@   string ".TE"   skipMany spacetab   eofline-  return $ singleTok $ Tbl opts (rows ++ concat morerows) pos+  return $ singleTok $ Tbl opts (rows <> concat morerows) pos  lexTableRows :: PandocMonad m => RoffLexer m [TableRow] lexTableRows = do@@ -432,11 +427,11 @@  tableOption :: PandocMonad m => RoffLexer m TableOption tableOption = do-  k <- many1 letter+  k <- many1Char letter   v <- option "" $ try $ do          skipMany spacetab          char '('-         manyTill anyChar (char ')')+         manyTillChar anyChar (char ')')   skipMany spacetab   optional (char ',' >> skipMany spacetab)   return (k,v)@@ -448,7 +443,7 @@   let speclines = first:rest   spaces   char '.'-  return $ speclines ++ repeat (lastDef [] speclines) -- last line is default+  return $ speclines <> repeat (lastDef [] speclines) -- last line is default  tableFormatSpecLine :: PandocMonad m => RoffLexer m [CellFormat] tableFormatSpecLine =@@ -460,19 +455,19 @@                    $ True <$ try (string "|" <* notFollowedBy spacetab)     c <- oneOf ['a','A','c','C','l','L','n','N','r','R','s','S','^','_','-',                 '=','|']-    suffixes <- many $ try (skipMany spacetab *> count 1 digit) <|>+    suffixes <- many $ try (skipMany spacetab *> countChar 1 digit) <|>       (do x <- oneOf ['b','B','d','D','e','E','f','F','i','I','m','M',                   'p','P','t','T','u','U','v','V','w','W','x','X', 'z','Z']           num <- case toLower x of                    'w' -> many1 digit <|>                            (do char '('                                xs <- manyTill anyChar (char ')')-                               return ("(" ++ xs ++ ")")) <|>+                               return ("(" <> xs <> ")")) <|>                            return ""                    'f' -> count 1 alphaNum <* skipMany spacetab                    'm' -> count 1 alphaNum <* skipMany spacetab                    _   -> return ""-          return $ x : num)+          return $ T.pack $ x : num)     pipeSuffix' <- option False $ True <$ string "|"     return $ CellFormat              { columnType     = c@@ -483,7 +478,7 @@ -- We don't fully handle the conditional.  But we do -- include everything under '.ie n', which occurs commonly -- in man pages.-lexConditional :: PandocMonad m => String -> RoffLexer m RoffTokens+lexConditional :: PandocMonad m => T.Text -> RoffLexer m RoffTokens lexConditional mname = do   pos <- getPosition   skipMany spacetab@@ -492,7 +487,9 @@                else expression   skipMany spacetab   st <- getState -- save state, so we can reset it-  ifPart <- lexGroup <|> ((try (char '\\' >> newline)) >> manToken)+  ifPart <- do+      optional $ try $ char '\\' >> newline+      lexGroup        <|> do modifyState $ \s -> s{ afterConditional = True }               t <- manToken               modifyState $ \s -> s{ afterConditional = False }@@ -500,7 +497,7 @@   case mbtest of     Nothing    -> do       putState st  -- reset state, so we don't record macros in skipped section-      report $ SkippedContent ('.':mname) pos+      report $ SkippedContent (T.cons '.' mname) pos       return mempty     Just True  -> return ifPart     Just False -> do@@ -510,7 +507,7 @@ expression :: PandocMonad m => RoffLexer m (Maybe Bool) expression = do   raw <- charsInBalanced '(' ')' (satisfy (/= '\n'))-      <|> many1 nonspaceChar+      <|> many1Char nonspaceChar   returnValue $     case raw of       "1"  -> Just True@@ -527,27 +524,25 @@   groupstart   mconcat <$> manyTill manToken groupend   where-    groupstart = try $ string "\\{\\" >> newline-    groupend   = try $ optional (char '.' >> many spacetab) >>-                       string "\\}" >> (lexLine <|> lexEmptyLine)-                       -- could be comment+    groupstart = try $ string "\\{" <* optional (try (string "\\\n"))+    groupend   = try $ string "\\}"  lexIncludeFile :: PandocMonad m => [Arg] -> RoffLexer m RoffTokens lexIncludeFile args = do   pos <- getPosition   case args of     (f:_) -> do-      let fp = linePartsToString f+      let fp = linePartsToText f       dirs <- getResourcePath-      result <- readFileFromDirs dirs fp+      result <- readFileFromDirs dirs $ T.unpack fp       case result of         Nothing  -> report $ CouldNotLoadIncludeFile fp pos-        Just s   -> getInput >>= setInput . (s ++)+        Just s   -> getInput >>= setInput . (s <>)       return mempty     []    -> return mempty  resolveMacro :: PandocMonad m-             => String -> [Arg] -> SourcePos -> RoffLexer m RoffTokens+             => T.Text -> [Arg] -> SourcePos -> RoffLexer m RoffTokens resolveMacro macroName args pos = do   macros <- customMacros <$> getState   case M.lookup macroName macros of@@ -556,7 +551,7 @@       let fillLP (MacroArg i)    zs =             case drop (i - 1) args of               []     -> zs-              (ys:_) -> ys ++ zs+              (ys:_) -> ys <> zs           fillLP z zs = z : zs       let fillMacroArg (TextLine lineparts) =             TextLine (foldr fillLP [] lineparts)@@ -566,10 +561,10 @@ lexStringDef :: PandocMonad m => [Arg] -> RoffLexer m RoffTokens lexStringDef args = do -- string definition    case args of-     []     -> fail "No argument to .ds"+     []     -> Prelude.fail "No argument to .ds"      (x:ys) -> do        let ts = singleTok $ TextLine (intercalate [RoffStr " " ] ys)-       let stringName = linePartsToString x+       let stringName = linePartsToText x        modifyState $ \st ->          st{ customMacros = M.insert stringName ts (customMacros st) }    return mempty@@ -579,14 +574,14 @@    modifyState $ \st -> st{ roffMode = CopyMode }    (macroName, stopMacro) <-      case args of-       (x : y : _) -> return (linePartsToString x, linePartsToString y)+       (x : y : _) -> return (linePartsToText x, linePartsToText y)                       -- optional second arg-       (x:_)       -> return (linePartsToString x, ".")-       []          -> fail "No argument to .de"+       (x:_)       -> return (linePartsToText x, ".")+       []          -> Prelude.fail "No argument to .de"    let stop = try $ do          char '.' <|> char '\''          skipMany spacetab-         string stopMacro+         textStr stopMacro          _ <- lexArgs          return ()    ts <- mconcat <$> manyTill manToken stop@@ -632,7 +627,7 @@         char '"'         return [RoffStr "\""] -checkDefined :: PandocMonad m => String -> RoffLexer m [LinePart]+checkDefined :: PandocMonad m => T.Text -> RoffLexer m [LinePart] checkDefined name = do   macros <- customMacros <$> getState   case M.lookup name macros of@@ -642,19 +637,19 @@ escString :: PandocMonad m => RoffLexer m [LinePart] escString = try $ do   pos <- getPosition-  (do cs <- escapeArg <|> count 1 anyChar-      resolveString cs pos)+  (do cs <- escapeArg <|> countChar 1 anyChar+      resolveText cs pos)     <|> mempty <$ char 'S'  -- strings and macros share namespace-resolveString :: PandocMonad m-              => String -> SourcePos -> RoffLexer m [LinePart]-resolveString stringname pos = do+resolveText :: PandocMonad m+              => T.Text -> SourcePos -> RoffLexer m [LinePart]+resolveText stringname pos = do   RoffTokens ts <- resolveMacro stringname [] pos   case Foldable.toList ts of     [TextLine xs] -> return xs     _          -> do-      report $ SkippedContent ("unknown string " ++ stringname) pos+      report $ SkippedContent ("unknown string " <> stringname) pos       return mempty  lexLine :: PandocMonad m => RoffLexer m RoffTokens@@ -692,16 +687,16 @@   pos <- getPosition   backslash   char '$'-  x <- escapeArg <|> count 1 digit+  x <- escapeArg <|> countChar 1 digit   case safeRead x of     Just i  -> return [MacroArg i]     Nothing -> do-      report $ SkippedContent ("illegal macro argument " ++ x) pos+      report $ SkippedContent ("illegal macro argument " <> x) pos       return []  regularText :: PandocMonad m => RoffLexer m [LinePart] regularText = do-  s <- many1 $ noneOf "\n\r\t \\\""+  s <- many1Char $ noneOf "\n\r\t \\\""   return [RoffStr s]  quoteChar :: PandocMonad m => RoffLexer m [LinePart]@@ -712,7 +707,7 @@ spaceTabChar :: PandocMonad m => RoffLexer m [LinePart] spaceTabChar = do   c <- spacetab-  return [RoffStr [c]]+  return [RoffStr $ T.singleton c]  lexEmptyLine :: PandocMonad m => RoffLexer m RoffTokens lexEmptyLine = newline >> return (singleTok EmptyLine)@@ -720,8 +715,8 @@ manToken :: PandocMonad m => RoffLexer m RoffTokens manToken = lexComment <|> lexMacro <|> lexLine <|> lexEmptyLine -linePartsToString :: [LinePart] -> String-linePartsToString = mconcat . map go+linePartsToText :: [LinePart] -> T.Text+linePartsToText = mconcat . map go   where   go (RoffStr s) = s   go _ = mempty@@ -730,7 +725,7 @@ lexRoff :: PandocMonad m => SourcePos -> T.Text -> m RoffTokens lexRoff pos txt = do   eithertokens <- readWithM (do setPosition pos-                                mconcat <$> many manToken) def (T.unpack txt)+                                mconcat <$> many manToken) def txt   case eithertokens of     Left e       -> throwError e     Right tokenz -> return tokenz
src/Text/Pandoc/Readers/TWiki.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RelaxedPolyRec    #-} -- RelaxedPolyRec needed for inlinesBetween on GHC < 7 {- |@@ -31,7 +32,7 @@ import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (enclosed, nested) import Text.Pandoc.Readers.HTML (htmlTag, isCommentTag)-import Text.Pandoc.Shared (crFilter)+import Text.Pandoc.Shared (crFilter, tshow) import Text.Pandoc.XML (fromEntities)  -- | Read twiki from an input string and return a Pandoc document.@@ -41,19 +42,19 @@           -> m Pandoc readTWiki opts s = do   res <- readWithM parseTWiki def{ stateOptions = opts }-             (T.unpack (crFilter s) ++ "\n\n")+             (crFilter s <> "\n\n")   case res of        Left e  -> throwError e        Right d -> return d -type TWParser = ParserT [Char] ParserState+type TWParser = ParserT Text ParserState  -- -- utility functions -- -tryMsg :: String -> TWParser m a -> TWParser m a-tryMsg msg p = try p <?> msg+tryMsg :: Text -> TWParser m a -> TWParser m a+tryMsg msg p = try p <?> T.unpack msg  nested :: PandocMonad m => TWParser m a -> TWParser m a nested p = do@@ -64,25 +65,25 @@   updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }   return res -htmlElement :: PandocMonad m => String -> TWParser m (Attr, String)+htmlElement :: PandocMonad m => Text -> TWParser m (Attr, Text) htmlElement tag = tryMsg tag $ do   (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])-  content <- manyTill anyChar (endtag <|> endofinput)+  content <- T.pack <$> manyTill anyChar (endtag <|> endofinput)   return (htmlAttrToPandoc attr, trim content)   where     endtag     = void $ htmlTag (~== TagClose tag)     endofinput = lookAhead $ try $ skipMany blankline >> skipSpaces >> eof-    trim       = dropWhile (=='\n') . reverse . dropWhile (=='\n') . reverse+    trim       = T.dropAround (=='\n') -htmlAttrToPandoc :: [Attribute String] -> Attr+htmlAttrToPandoc :: [Attribute Text] -> Attr htmlAttrToPandoc attrs = (ident, classes, keyvals)   where     ident   = fromMaybe "" $ lookup "id" attrs-    classes = maybe [] words $ lookup "class" attrs+    classes = maybe [] T.words $ lookup "class" attrs     keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]  parseHtmlContentWithAttrs :: PandocMonad m-                          => String -> TWParser m a -> TWParser m (Attr, [a])+                          => Text -> TWParser m a -> TWParser m (Attr, [a]) parseHtmlContentWithAttrs tag parser = do   (attr, content) <- htmlElement tag   parsedContent <- try $ parseContent content@@ -91,7 +92,13 @@     parseContent = parseFromString' $ nested $ manyTill parser endOfContent     endOfContent = try $ skipMany blankline >> skipSpaces >> eof -parseHtmlContent :: PandocMonad m => String -> TWParser m a -> TWParser m [a]+parseCharHtmlContentWithAttrs :: PandocMonad m+                          => Text -> TWParser m Char -> TWParser m (Attr, Text)+parseCharHtmlContentWithAttrs tag = fmap go . parseHtmlContentWithAttrs tag+  where+    go (x, y) = (x, T.pack y)++parseHtmlContent :: PandocMonad m => Text -> TWParser m a -> TWParser m [a] parseHtmlContent tag p = snd <$> parseHtmlContentWithAttrs tag p  --@@ -113,7 +120,7 @@          <|> blockElements          <|> para   skipMany blankline-  trace (take 60 $ show $ B.toList res)+  trace (T.take 60 $ tshow $ B.toList res)   return res  blockElements :: PandocMonad m => TWParser m B.Blocks@@ -150,38 +157,38 @@     format (_, _, kvs)        = fromMaybe "html" $ lookup "format" kvs     rawBlock (attrs, content) = B.rawBlock (format attrs) content -list :: PandocMonad m => String -> TWParser m B.Blocks+list :: PandocMonad m => Text -> TWParser m B.Blocks list prefix = choice [ bulletList prefix                      , orderedList prefix                      , definitionList prefix] -definitionList :: PandocMonad m => String -> TWParser m B.Blocks+definitionList :: PandocMonad m => Text -> TWParser m B.Blocks definitionList prefix = tryMsg "definitionList" $ do-  indent <- lookAhead $ string prefix *> many1 (string "   ") <* string "$ "-  elements <- many $ parseDefinitionListItem (prefix ++ concat indent)+  indent <- lookAhead $ textStr prefix *> many1 (textStr "   ") <* textStr "$ "+  elements <- many $ parseDefinitionListItem (prefix <> T.concat indent)   return $ B.definitionList elements   where     parseDefinitionListItem :: PandocMonad m-                            => String -> TWParser m (B.Inlines, [B.Blocks])+                            => Text -> TWParser m (B.Inlines, [B.Blocks])     parseDefinitionListItem indent = do-      string (indent ++ "$ ") >> skipSpaces+      textStr (indent <> "$ ") >> skipSpaces       term <- many1Till inline $ string ": "       line <- listItemLine indent $ string "$ "       return (mconcat term, [line]) -bulletList :: PandocMonad m => String -> TWParser m B.Blocks+bulletList :: PandocMonad m => Text -> TWParser m B.Blocks bulletList prefix = tryMsg "bulletList" $                     parseList prefix (char '*') (char ' ') -orderedList :: PandocMonad m => String -> TWParser m B.Blocks+orderedList :: PandocMonad m => Text -> TWParser m B.Blocks orderedList prefix = tryMsg "orderedList" $                      parseList prefix (oneOf "1iIaA") (string ". ")  parseList :: PandocMonad m-          => String -> TWParser m Char -> TWParser m a -> TWParser m B.Blocks+          => Text -> TWParser m Char -> TWParser m a -> TWParser m B.Blocks parseList prefix marker delim = do-  (indent, style) <- lookAhead $ string prefix *> listStyle <* delim-  blocks <- many $ parseListItem (prefix ++ indent) (char style <* delim)+  (indent, style) <- lookAhead $ textStr prefix *> listStyle <* delim+  blocks <- many $ parseListItem (prefix <> indent) (char style <* delim)   return $ case style of     '1' -> B.orderedListWith (1, DefaultStyle, DefaultDelim) blocks     'i' -> B.orderedListWith (1, LowerRoman, DefaultDelim) blocks@@ -191,24 +198,24 @@     _   -> B.bulletList blocks   where     listStyle = do-      indent <- many1 $ string "   "+      indent <- many1 $ textStr "   "       style <- marker-      return (concat indent, style)+      return (T.concat indent, style)  parseListItem :: (PandocMonad m, Show a)-              => String -> TWParser m a -> TWParser m B.Blocks-parseListItem prefix marker = string prefix >> marker >> listItemLine prefix marker+              => Text -> TWParser m a -> TWParser m B.Blocks+parseListItem prefix marker = textStr prefix >> marker >> listItemLine prefix marker  listItemLine :: (PandocMonad m, Show a)-             => String -> TWParser m a -> TWParser m B.Blocks+             => Text -> TWParser m a -> TWParser m B.Blocks listItemLine prefix marker = mconcat <$> (lineContent >>= parseContent)   where     lineContent = do       content <- anyLine       continuation <- optionMaybe listContinuation-      return $ filterSpaces content ++ "\n" ++ maybe "" ("   " ++) continuation-    filterSpaces = reverse . dropWhile (== ' ') . reverse-    listContinuation = notFollowedBy (string prefix >> marker) >>+      return $ filterSpaces content <> "\n" <> maybe "" ("   " <>) continuation+    filterSpaces = T.dropWhileEnd (== ' ')+    listContinuation = notFollowedBy (textStr prefix >> marker) >>                        string "   " >> lineContent     parseContent = parseFromString' $ many1 $ nestedList <|> parseInline     parseInline = (B.plain . mconcat) <$> many1Till inline (lastNewline <|> newlineBeforeNestedList)@@ -352,29 +359,29 @@   char '%'   return $ buildSpan name kvs $ B.str content -buildSpan :: String -> [(String, String)] -> B.Inlines -> B.Inlines+buildSpan :: Text -> [(Text, Text)] -> B.Inlines -> B.Inlines buildSpan className kvs = B.spanWith attrs   where     attrs             = ("", ["twiki-macro", className] ++ additionalClasses, kvsWithoutClasses)-    additionalClasses = maybe [] words $ lookup "class" kvs+    additionalClasses = maybe [] T.words $ lookup "class" kvs     kvsWithoutClasses = [(k,v) | (k,v) <- kvs, k /= "class"] -macroName :: PandocMonad m => TWParser m String+macroName :: PandocMonad m => TWParser m Text macroName = do   first <- letter   rest <- many $ alphaNum <|> char '_'-  return (first:rest)+  return $ T.pack $ first:rest -attributes :: PandocMonad m => TWParser m (String, [(String, String)])-attributes = foldr (either mkContent mkKvs) ([], [])+attributes :: PandocMonad m => TWParser m (Text, [(Text, Text)])+attributes = foldr (either mkContent mkKvs) ("", [])   <$> (char '{' *> spnl *> many (attribute <* spnl) <* char '}')   where     spnl                      = skipMany (spaceChar <|> newline)-    mkContent c  ([], kvs)   = (c, kvs)-    mkContent c  (rest, kvs) = (c ++ " " ++ rest, kvs)+    mkContent c  ("", kvs)    = (c, kvs)+    mkContent c  (rest, kvs)  = (c <> " " <> rest, kvs)     mkKvs     kv (cont, rest) = (cont, kv : rest) -attribute :: PandocMonad m => TWParser m (Either String (String, String))+attribute :: PandocMonad m => TWParser m (Either Text (Text, Text)) attribute = withKey <|> withoutKey   where     withKey = try $ do@@ -383,10 +390,10 @@       curry Right key <$> parseValue False     withoutKey = try $ Left <$> parseValue True     parseValue allowSpaces = fromEntities <$> (withQuotes <|> withoutQuotes allowSpaces)-    withQuotes             = between (char '"') (char '"') (\_ -> count 1 $ noneOf ['"'])+    withQuotes             = between (char '"') (char '"') (\_ -> countChar 1 $ noneOf ['"'])     withoutQuotes allowSpaces-      | allowSpaces = many1 $ noneOf "}"-      | otherwise   = many1 $ noneOf " }"+      | allowSpaces = many1Char $ noneOf "}"+      | otherwise   = many1Char $ noneOf " }"  nestedInlines :: (Show a, PandocMonad m)               => TWParser m a -> TWParser m B.Inlines@@ -413,10 +420,10 @@ emphHtml = B.emph . mconcat <$> (parseHtmlContent "em" inline <|> parseHtmlContent "i" inline)  nestedString :: (Show a, PandocMonad m)-             => TWParser m a -> TWParser m String-nestedString end = innerSpace <|> count 1 nonspaceChar+             => TWParser m a -> TWParser m Text+nestedString end = innerSpace <|> countChar 1 nonspaceChar   where-    innerSpace = try $ many1 spaceChar <* notFollowedBy end+    innerSpace = try $ many1Char spaceChar <* notFollowedBy end  boldCode :: PandocMonad m => TWParser m B.Inlines boldCode = try $ (B.strong . B.code . fromEntities) <$> enclosed (string "==") nestedString@@ -429,7 +436,7 @@  codeHtml :: PandocMonad m => TWParser m B.Inlines codeHtml = do-  (attrs, content) <- parseHtmlContentWithAttrs "code" anyChar+  (attrs, content) <- parseCharHtmlContentWithAttrs "code" anyChar   return $ B.codeWith attrs $ fromEntities content  autoLink :: PandocMonad m => TWParser m B.Inlines@@ -437,7 +444,7 @@   state <- getState   guard $ stateAllowLinks state   (text, url) <- parseLink-  guard $ checkLink (last url)+  guard $ checkLink (T.last url)   return $ makeLink (text, url)   where     parseLink            = notFollowedBy nop >> (uri <|> emailAddress)@@ -447,17 +454,17 @@       | otherwise = isAlphaNum c  str :: PandocMonad m => TWParser m B.Inlines-str = B.str <$> (many1 alphaNum <|> count 1 characterReference)+str = B.str <$> (many1Char alphaNum <|> countChar 1 characterReference)  nop :: PandocMonad m => TWParser m B.Inlines nop = try $ (void exclamation <|> void nopTag) >> followContent   where     exclamation   = char '!'     nopTag        = stringAnyCase "<nop>"-    followContent = B.str . fromEntities <$> many1 nonspaceChar+    followContent = B.str . fromEntities <$> many1Char nonspaceChar  symbol :: PandocMonad m => TWParser m B.Inlines-symbol = B.str <$> count 1 nonspaceChar+symbol = B.str <$> countChar 1 nonspaceChar  smart :: PandocMonad m => TWParser m B.Inlines smart = do@@ -491,13 +498,13 @@   setState $ st{ stateAllowLinks = True }   return $ B.link url title content -linkText :: PandocMonad m => TWParser m (String, String, B.Inlines)+linkText :: PandocMonad m => TWParser m (Text, Text, B.Inlines) linkText = do   string "[["-  url <- many1Till anyChar (char ']')+  url <- T.pack <$> many1Till anyChar (char ']')   content <- option (B.str url) (mconcat <$> linkContent)   char ']'   return (url, "", content)   where-    linkContent      = char '[' >> many1Till anyChar (char ']') >>= parseLinkContent+    linkContent      = char '[' >> many1Till anyChar (char ']') >>= parseLinkContent . T.pack     parseLinkContent = parseFromString' $ many1 inline
src/Text/Pandoc/Readers/Textile.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Readers.Textile    Copyright   : Copyright (C) 2010-2012 Paul Rivier@@ -38,7 +40,7 @@ import Control.Monad (guard, liftM) import Control.Monad.Except (throwError) import Data.Char (digitToInt, isUpper)-import Data.List (intercalate, intersperse, transpose)+import Data.List (intersperse, transpose) import Data.Text (Text) import qualified Data.Text as T import Text.HTML.TagSoup (Tag (..), fromAttrib)@@ -52,7 +54,7 @@ import Text.Pandoc.Parsing import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isInlineTag) import Text.Pandoc.Readers.LaTeX (rawLaTeXBlock, rawLaTeXInline)-import Text.Pandoc.Shared (crFilter, trim, underlineSpan)+import Text.Pandoc.Shared (crFilter, trim, underlineSpan, tshow)  -- | Parse a Textile text and return a Pandoc document. readTextile :: PandocMonad m@@ -61,21 +63,21 @@             -> m Pandoc readTextile opts s = do   parsed <- readWithM parseTextile def{ stateOptions = opts }-                (T.unpack (crFilter s) ++ "\n\n")+                (crFilter s <> "\n\n")   case parsed of      Right result -> return result      Left e       -> throwError e   -- | Generate a Pandoc ADT from a textile document-parseTextile :: PandocMonad m => ParserT [Char] ParserState m Pandoc+parseTextile :: PandocMonad m => ParserT Text ParserState m Pandoc parseTextile = do   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+  manyTill firstPassParser eof >>= setInput . T.concat   setPosition startPos   st' <- getState   let reversedNotes = stateNotes st'@@ -84,29 +86,29 @@   blocks <- parseBlocks   return $ Pandoc nullMeta (B.toList blocks) -- FIXME -noteMarker :: PandocMonad m => ParserT [Char] ParserState m [Char]-noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.')+noteMarker :: PandocMonad m => ParserT Text ParserState m Text+noteMarker = skipMany spaceChar >> string "fn" >> T.pack <$> manyTill digit (char '.') -noteBlock :: PandocMonad m => ParserT [Char] ParserState m [Char]+noteBlock :: PandocMonad m => ParserT Text ParserState m Text noteBlock = try $ do   startPos <- getPosition   ref <- noteMarker   optional blankline-  contents <- unlines <$> many1Till anyLine (blanklines <|> noteBlock)+  contents <- T.unlines <$> many1Till anyLine (blanklines <|> noteBlock)   endPos <- getPosition-  let newnote = (ref, contents ++ "\n")+  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'+  return $ T.replicate (sourceLine endPos - sourceLine startPos) "\n"  -- | Parse document blocks-parseBlocks :: PandocMonad m => ParserT [Char] ParserState m Blocks+parseBlocks :: PandocMonad m => ParserT Text ParserState m Blocks parseBlocks = mconcat <$> manyTill block eof  -- | Block parsers list tried in definition order-blockParsers :: PandocMonad m => [ParserT [Char] ParserState m Blocks]+blockParsers :: PandocMonad m => [ParserT Text ParserState m Blocks] blockParsers = [ codeBlock                , header                , blockQuote@@ -121,22 +123,22 @@                ]  -- | Any block in the order of definition of blockParsers-block :: PandocMonad m => ParserT [Char] ParserState m Blocks+block :: PandocMonad m => ParserT Text ParserState m Blocks block = do   res <- choice blockParsers <?> "block"-  trace (take 60 $ show $ B.toList res)+  trace (T.take 60 $ tshow $ B.toList res)   return res -commentBlock :: PandocMonad m => ParserT [Char] ParserState m Blocks+commentBlock :: PandocMonad m => ParserT Text ParserState m Blocks commentBlock = try $ do   string "###."   manyTill anyLine blanklines   return mempty -codeBlock :: PandocMonad m => ParserT [Char] ParserState m Blocks+codeBlock :: PandocMonad m => ParserT Text ParserState m Blocks codeBlock = codeBlockBc <|> codeBlockPre -codeBlockBc :: PandocMonad m => ParserT [Char] ParserState m Blocks+codeBlockBc :: PandocMonad m => ParserT Text ParserState m Blocks codeBlockBc = try $ do   string "bc."   extended <- option False (True <$ char '.')@@ -150,31 +152,31 @@                    rest <- many (notFollowedBy ender *> anyLine)                    return (f:rest)                  else manyTill anyLine blanklines-  return $ B.codeBlock (trimTrailingNewlines (unlines contents))+  return $ B.codeBlock (trimTrailingNewlines (T.unlines contents)) -trimTrailingNewlines :: String -> String-trimTrailingNewlines = reverse . dropWhile (=='\n') . reverse+trimTrailingNewlines :: Text -> Text+trimTrailingNewlines = T.dropWhileEnd (=='\n')  -- | Code Blocks in Textile are between <pre> and </pre>-codeBlockPre :: PandocMonad m => ParserT [Char] ParserState m Blocks+codeBlockPre :: PandocMonad m => ParserT Text ParserState m Blocks codeBlockPre = try $ do   (t@(TagOpen _ attrs),_) <- htmlTag (tagOpen (=="pre") (const True))-  result' <- manyTill anyChar (htmlTag (tagClose (=="pre")))+  result' <- T.pack <$> manyTill anyChar (htmlTag (tagClose (=="pre")))   -- drop leading newline if any-  let result'' = case result' of-                      '\n':xs -> xs-                      _       -> result'+  let result'' = case T.uncons result' of+                   Just ('\n', xs) -> xs+                   _               -> result'   -- drop trailing newline if any-  let result''' = case reverse result'' of-                       '\n':_ -> init result''-                       _      -> result''-  let classes = words $ fromAttrib "class" t+  let result''' = case T.unsnoc result'' of+                    Just (xs, '\n') -> xs+                    _               -> result''+  let classes = T.words $ fromAttrib "class" t   let ident = fromAttrib "id" t   let kvs = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]   return $ B.codeBlockWith (ident,classes,kvs) result'''  -- | Header of the form "hN. content" with N in 1..6-header :: PandocMonad m => ParserT [Char] ParserState m Blocks+header :: PandocMonad m => ParserT Text ParserState m Blocks header = try $ do   char 'h'   level <- digitToInt <$> oneOf "123456"@@ -186,14 +188,14 @@   return $ B.headerWith attr' level name  -- | Blockquote of the form "bq. content"-blockQuote :: PandocMonad m => ParserT [Char] ParserState m Blocks+blockQuote :: PandocMonad m => ParserT Text ParserState m Blocks blockQuote = try $ do   string "bq" >> attributes >> char '.' >> whitespace   B.blockQuote <$> para  -- Horizontal rule -hrule :: PandocMonad m => ParserT [Char] st m Blocks+hrule :: PandocMonad m => ParserT Text st m Blocks hrule = try $ do   skipSpaces   start <- oneOf "-*"@@ -208,39 +210,39 @@ -- | 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 :: PandocMonad m => ParserT [Char] ParserState m Blocks+anyList :: PandocMonad m => ParserT Text ParserState m Blocks anyList = try $ anyListAtDepth 1 <* blanklines  -- | This allow one type of list to be nested into an other type, -- provided correct nesting-anyListAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks+anyListAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks anyListAtDepth depth = choice [ bulletListAtDepth depth,                                 orderedListAtDepth depth,                                 definitionList ]  -- | Bullet List of given depth, depth being the number of leading '*'-bulletListAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks+bulletListAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks bulletListAtDepth depth = try $ B.bulletList  <$> many1 (bulletListItemAtDepth depth)  -- | Bullet List Item of given depth, depth being the number of -- leading '*'-bulletListItemAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks+bulletListItemAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks bulletListItemAtDepth = genericListItemAtDepth '*'  -- | Ordered List of given depth, depth being the number of -- leading '#'-orderedListAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks+orderedListAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks orderedListAtDepth depth = try $ do   items <- many1 (orderedListItemAtDepth depth)   return $ B.orderedList items  -- | Ordered List Item of given depth, depth being the number of -- leading '#'-orderedListItemAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks+orderedListItemAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks orderedListItemAtDepth = genericListItemAtDepth '#'  -- | Common implementation of list items-genericListItemAtDepth :: PandocMonad m => Char -> Int -> ParserT [Char] ParserState m Blocks+genericListItemAtDepth :: PandocMonad m => Char -> Int -> ParserT Text ParserState m Blocks genericListItemAtDepth c depth = try $ do   count depth (char c) >> attributes >> whitespace   contents <- mconcat <$> many ((B.plain . mconcat <$> many1 inline) <|>@@ -250,25 +252,25 @@   return $ contents <> sublist  -- | A definition list is a set of consecutive definition items-definitionList :: PandocMonad m => ParserT [Char] ParserState m Blocks+definitionList :: PandocMonad m => ParserT Text ParserState m Blocks definitionList = try $ B.definitionList <$> many1 definitionListItem  -- | List start character.-listStart :: PandocMonad m => ParserT [Char] ParserState m ()+listStart :: PandocMonad m => ParserT Text ParserState m () listStart = genericListStart '*'         <|> () <$ genericListStart '#'         <|> () <$ definitionListStart -genericListStart :: PandocMonad m => Char -> ParserT [Char] st m ()+genericListStart :: PandocMonad m => Char -> ParserT Text st m () genericListStart c = () <$ try (many1 (char c) >> whitespace) -basicDLStart :: PandocMonad m => ParserT [Char] ParserState m ()+basicDLStart :: PandocMonad m => ParserT Text ParserState m () basicDLStart = do   char '-'   whitespace   notFollowedBy newline -definitionListStart :: PandocMonad m => ParserT [Char] ParserState m Inlines+definitionListStart :: PandocMonad m => ParserT Text ParserState m Inlines definitionListStart = try $ do   basicDLStart   trimInlines . mconcat <$>@@ -281,26 +283,26 @@ -- the term defined, then spaces and ":=". The definition follows, on -- the same single line, or spaned on multiple line, after a line -- break.-definitionListItem :: PandocMonad m => ParserT [Char] ParserState m (Inlines, [Blocks])+definitionListItem :: PandocMonad m => ParserT Text ParserState m (Inlines, [Blocks]) definitionListItem = try $ do   term <- (mconcat . intersperse B.linebreak) <$> many1 definitionListStart   def' <- string ":=" *> optional whitespace *> (multilineDef <|> inlineDef)   return (term, def')-  where inlineDef :: PandocMonad m => ParserT [Char] ParserState m [Blocks]+  where inlineDef :: PandocMonad m => ParserT Text ParserState m [Blocks]         inlineDef = liftM (\d -> [B.plain d])                     $ optional whitespace >> (trimInlines . mconcat <$> many inline) <* newline-        multilineDef :: PandocMonad m => ParserT [Char] ParserState m [Blocks]+        multilineDef :: PandocMonad m => ParserT Text ParserState m [Blocks]         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")+          s <- T.pack <$> many1Till anyChar (try (string "=:" >> newline))+          -- this <> "\n\n" does not look very good+          ds <- parseFromString' parseBlocks (s <> "\n\n")           return [ds]  -- raw content  -- | A raw Html Block, optionally followed by blanklines-rawHtmlBlock :: PandocMonad m => ParserT [Char] ParserState m Blocks+rawHtmlBlock :: PandocMonad m => ParserT Text ParserState m Blocks rawHtmlBlock = try $ do   skipMany spaceChar   (_,b) <- htmlTag isBlockTag@@ -308,14 +310,14 @@   return $ B.rawBlock "html" b  -- | Raw block of LaTeX content-rawLaTeXBlock' :: PandocMonad m => ParserT [Char] ParserState m Blocks+rawLaTeXBlock' :: PandocMonad m => ParserT Text ParserState m Blocks rawLaTeXBlock' = do   guardEnabled Ext_raw_tex   B.rawBlock "latex" <$> (rawLaTeXBlock <* spaces)   -- | In textile, paragraphs are separated by blank lines.-para :: PandocMonad m => ParserT [Char] ParserState m Blocks+para :: PandocMonad m => ParserT Text ParserState m Blocks para = B.para . trimInlines . mconcat <$> many1 inline  -- Tables@@ -326,7 +328,7 @@ toAlignment '=' = AlignCenter toAlignment _   = AlignDefault -cellAttributes :: PandocMonad m => ParserT [Char] ParserState m (Bool, Alignment)+cellAttributes :: PandocMonad m => ParserT Text ParserState m (Bool, Alignment) cellAttributes = try $ do   isHeader <- option False (True <$ char '_')   -- we just ignore colspan and rowspan markers:@@ -339,18 +341,18 @@   return (isHeader, alignment)  -- | A table cell spans until a pipe |-tableCell :: PandocMonad m => ParserT [Char] ParserState m ((Bool, Alignment), Blocks)+tableCell :: PandocMonad m => ParserT Text ParserState m ((Bool, Alignment), Blocks) tableCell = try $ do   char '|'   (isHeader, alignment) <- option (False, AlignDefault) cellAttributes   notFollowedBy blankline-  raw <- trim <$>+  raw <- trim . T.pack <$>          many (noneOf "|\n" <|> try (char '\n' <* notFollowedBy blankline))   content <- mconcat <$> parseFromString' (many inline) raw   return ((isHeader, alignment), B.plain content)  -- | A table row is made of many table cells-tableRow :: PandocMonad m => ParserT [Char] ParserState m [((Bool, Alignment), Blocks)]+tableRow :: PandocMonad m => ParserT Text ParserState m [((Bool, Alignment), Blocks)] tableRow = try $ do   -- skip optional row attributes   optional $ try $ do@@ -360,7 +362,7 @@   many1 tableCell <* char '|' <* blankline  -- | A table with an optional header.-table :: PandocMonad m => ParserT [Char] ParserState m Blocks+table :: PandocMonad m => ParserT Text ParserState m Blocks table = try $ do   -- ignore table attributes   caption <- option mempty $ try $ do@@ -384,7 +386,7 @@     (map (map snd) rows)  -- | Ignore markers for cols, thead, tfoot.-ignorableRow :: PandocMonad m => ParserT [Char] ParserState m ()+ignorableRow :: PandocMonad m => ParserT Text ParserState m () ignorableRow = try $ do   char '|'   oneOf ":^-~"@@ -393,9 +395,9 @@   _ <- anyLine   return () -explicitBlockStart :: PandocMonad m => String -> ParserT [Char] ParserState m ()+explicitBlockStart :: PandocMonad m => Text -> ParserT Text ParserState m () explicitBlockStart name = try $ do-  string name+  string (T.unpack name)   attributes   char '.'   optional whitespace@@ -404,9 +406,9 @@ -- | Blocks like 'p' and 'table' do not need explicit block tag. -- However, they can be used to set HTML/CSS attributes when needed. maybeExplicitBlock :: PandocMonad m-                   => String  -- ^ block tag name-                   -> ParserT [Char] ParserState m Blocks -- ^ implicit block-                   -> ParserT [Char] ParserState m Blocks+                   => Text  -- ^ block tag name+                   -> ParserT Text ParserState m Blocks -- ^ implicit block+                   -> ParserT Text ParserState m Blocks maybeExplicitBlock name blk = try $ do   optional $ explicitBlockStart name   blk@@ -419,11 +421,11 @@   -- | Any inline element-inline :: PandocMonad m => ParserT [Char] ParserState m Inlines+inline :: PandocMonad m => ParserT Text ParserState m Inlines inline = choice inlineParsers <?> "inline"  -- | Inline parsers tried in order-inlineParsers :: PandocMonad m => [ParserT [Char] ParserState m Inlines]+inlineParsers :: PandocMonad m => [ParserT Text ParserState m Inlines] inlineParsers = [ str                 , whitespace                 , endline@@ -437,13 +439,13 @@                 , link                 , image                 , mark-                , (B.str . (:[])) <$> characterReference+                , (B.str . T.singleton) <$> characterReference                 , smartPunctuation inline                 , symbol                 ]  -- | Inline markups-inlineMarkup :: PandocMonad m => ParserT [Char] ParserState m Inlines+inlineMarkup :: PandocMonad m => ParserT Text ParserState m Inlines inlineMarkup = choice [ simpleInline (string "??") (B.cite [])                       , simpleInline (string "**") B.strong                       , simpleInline (string "__") B.emph@@ -457,34 +459,34 @@                       ]  -- | Trademark, registered, copyright-mark :: PandocMonad m => ParserT [Char] st m Inlines+mark :: PandocMonad m => ParserT Text st m Inlines mark = try $ char '(' >> (try tm <|> try reg <|> copy) -reg :: PandocMonad m => ParserT [Char] st m Inlines+reg :: PandocMonad m => ParserT Text st m Inlines reg = do   oneOf "Rr"   char ')'   return $ B.str "\174" -tm :: PandocMonad m => ParserT [Char] st m Inlines+tm :: PandocMonad m => ParserT Text st m Inlines tm = do   oneOf "Tt"   oneOf "Mm"   char ')'   return $ B.str "\8482" -copy :: PandocMonad m => ParserT [Char] st m Inlines+copy :: PandocMonad m => ParserT Text st m Inlines copy = do   oneOf "Cc"   char ')'   return $ B.str "\169" -note :: PandocMonad m => ParserT [Char] ParserState m Inlines+note :: PandocMonad m => ParserT Text ParserState m Inlines note = try $ do   ref <- char '[' *> many1 digit <* char ']'   notes <- stateNotes <$> getState-  case lookup ref notes of-    Nothing  -> fail "note not found"+  case lookup (T.pack ref) notes of+    Nothing  -> Prelude.fail "note not found"     Just raw -> B.note <$> parseFromString' parseBlocks raw  -- | Special chars@@ -500,42 +502,42 @@ stringBreakers = " \t\n\r.,\"'?!;:<>«»„“”‚‘’()[]"  wordBoundaries :: [Char]-wordBoundaries = markupChars ++ stringBreakers+wordBoundaries = markupChars <> stringBreakers  -- | Parse a hyphened sequence of words-hyphenedWords :: PandocMonad m => ParserT [Char] ParserState m String+hyphenedWords :: PandocMonad m => ParserT Text ParserState m Text hyphenedWords = do   x <- wordChunk   xs <-  many (try $ char '-' >> wordChunk)-  return $ intercalate "-" (x:xs)+  return $ T.intercalate "-" (x:xs) -wordChunk :: PandocMonad m => ParserT [Char] ParserState m String+wordChunk :: PandocMonad m => ParserT Text ParserState m Text wordChunk = try $ do   hd <- noneOf wordBoundaries   tl <- many ( noneOf wordBoundaries <|>                try (notFollowedBy' note *> oneOf markupChars                      <* lookAhead (noneOf wordBoundaries) ) )-  return $ hd:tl+  return $ T.pack $ hd:tl  -- | Any string-str :: PandocMonad m => ParserT [Char] ParserState m Inlines+str :: PandocMonad m => ParserT Text ParserState m Inlines str = do   baseStr <- hyphenedWords   -- RedCloth compliance : if parsed word is uppercase and immediately   -- followed by parens, parens content is unconditionally word acronym   fullStr <- option baseStr $ try $ do-    guard $ all isUpper baseStr-    acro <- enclosed (char '(') (char ')') anyChar'-    return $ concat [baseStr, " (", acro, ")"]+    guard $ T.all isUpper baseStr+    acro <- T.pack <$> enclosed (char '(') (char ')') anyChar'+    return $ T.concat [baseStr, " (", acro, ")"]   updateLastStrPos   return $ B.str fullStr  -- | Some number of space chars-whitespace :: PandocMonad m => ParserT [Char] st m Inlines+whitespace :: PandocMonad m => ParserT Text st m Inlines whitespace = many1 spaceChar >> return B.space <?> "whitespace"  -- | In Textile, an isolated endline character is a line break-endline :: PandocMonad m => ParserT [Char] ParserState m Inlines+endline :: PandocMonad m => ParserT Text ParserState m Inlines endline = try $ do   newline   notFollowedBy blankline@@ -543,18 +545,18 @@   notFollowedBy rawHtmlBlock   return B.linebreak -rawHtmlInline :: PandocMonad m => ParserT [Char] ParserState m Inlines+rawHtmlInline :: PandocMonad m => ParserT Text ParserState m Inlines rawHtmlInline = B.rawInline "html" . snd <$> htmlTag isInlineTag  -- | Raw LaTeX Inline-rawLaTeXInline' :: PandocMonad m => ParserT [Char] ParserState m Inlines+rawLaTeXInline' :: PandocMonad m => ParserT Text ParserState m Inlines rawLaTeXInline' = try $ do   guardEnabled Ext_raw_tex   B.rawInline "latex" <$> rawLaTeXInline  -- | Textile standard link syntax is "label":target. But we -- can also have ["label":target].-link :: PandocMonad m => ParserT [Char] ParserState m Inlines+link :: PandocMonad m => ParserT Text ParserState m Inlines link = try $ do   bracketed <- (True <$ char '[') <|> return False   char '"' *> notFollowedBy (oneOf " \t\n\r")@@ -567,121 +569,122 @@                 else lookAhead $ space <|> eof' <|>                        try (oneOf "!.,;:" *>                               (space <|> newline <|> eof'))-  url <- many1Till nonspaceChar stop+  url <- T.pack <$> many1Till nonspaceChar stop   let name' = if B.toList name == [Str "$"] then B.str url else name   return $ if attr == nullAttr               then B.link url "" name'               else B.spanWith attr $ B.link url "" name'  -- | image embedding-image :: PandocMonad m => ParserT [Char] ParserState m Inlines+image :: PandocMonad m => ParserT Text ParserState m Inlines image = try $ do   char '!' >> notFollowedBy space   (ident, cls, kvs) <- attributes   let attr = case lookup "style" kvs of                Just stls -> (ident, cls, pickStylesToKVs ["width", "height"] stls)                Nothing   -> (ident, cls, kvs)-  src <- many1 (noneOf " \t\n\r!(")-  alt <- option "" $ try $ char '(' *> manyTill anyChar (char ')')+  src <- T.pack <$> many1 (noneOf " \t\n\r!(")+  alt <- fmap T.pack $ option "" $ try $ char '(' *> manyTill anyChar (char ')')   char '!'   return $ B.imageWith attr src alt (B.str alt) -escapedInline :: PandocMonad m => ParserT [Char] ParserState m Inlines+escapedInline :: PandocMonad m => ParserT Text ParserState m Inlines escapedInline = escapedEqs <|> escapedTag -escapedEqs :: PandocMonad m => ParserT [Char] ParserState m Inlines-escapedEqs = B.str <$>+escapedEqs :: PandocMonad m => ParserT Text ParserState m Inlines+escapedEqs = B.str . T.pack <$>   try (string "==" *> manyTill anyChar' (try $ string "=="))  -- | literal text escaped btw <notextile> tags-escapedTag :: PandocMonad m => ParserT [Char] ParserState m Inlines-escapedTag = B.str <$>+escapedTag :: PandocMonad m => ParserT Text ParserState m Inlines+escapedTag = B.str . T.pack <$>   try (string "<notextile>" *>          manyTill anyChar' (try $ string "</notextile>"))  -- | Any special symbol defined in wordBoundaries-symbol :: PandocMonad m => ParserT [Char] ParserState m Inlines-symbol = B.str . singleton <$> (notFollowedBy newline *>-                                notFollowedBy rawHtmlBlock *>-                                oneOf wordBoundaries)+symbol :: PandocMonad m => ParserT Text ParserState m Inlines+symbol = B.str . T.singleton <$> (notFollowedBy newline *>+                                  notFollowedBy rawHtmlBlock *>+                                  oneOf wordBoundaries)  -- | Inline code-code :: PandocMonad m => ParserT [Char] ParserState m Inlines+code :: PandocMonad m => ParserT Text ParserState m Inlines code = code1 <|> code2  -- any character except a newline before a blank line-anyChar' :: PandocMonad m => ParserT [Char] ParserState m Char+anyChar' :: PandocMonad m => ParserT Text ParserState m Char anyChar' =   satisfy (/='\n') <|>   try (char '\n' <* notFollowedBy blankline) -code1 :: PandocMonad m => ParserT [Char] ParserState m Inlines-code1 = B.code <$> surrounded (char '@') anyChar'+code1 :: PandocMonad m => ParserT Text ParserState m Inlines+code1 = B.code . T.pack <$> surrounded (char '@') anyChar' -code2 :: PandocMonad m => ParserT [Char] ParserState m Inlines+code2 :: PandocMonad m => ParserT Text ParserState m Inlines code2 = do   htmlTag (tagOpen (=="tt") null)-  B.code <$> manyTill anyChar' (try $ htmlTag $ tagClose (=="tt"))+  B.code . T.pack <$> manyTill anyChar' (try $ htmlTag $ tagClose (=="tt"))  -- | Html / CSS attributes-attributes :: PandocMonad m => ParserT [Char] ParserState m Attr+attributes :: PandocMonad m => ParserT Text ParserState m Attr attributes = foldl (flip ($)) ("",[],[]) <$>   try (do special <- option id specialAttribute           attrs <- many attribute           return (special : attrs)) -specialAttribute :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)+specialAttribute :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr) specialAttribute = do   alignStr <- ("center" <$ char '=') <|>     ("justify" <$ try (string "<>")) <|>     ("right" <$ char '>') <|>     ("left" <$ char '<')   notFollowedBy spaceChar-  return $ addStyle ("text-align:" ++ alignStr)+  return $ addStyle $ T.pack $ "text-align:" ++ alignStr -attribute :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)+attribute :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr) attribute = try $   (classIdAttr <|> styleAttr <|> langAttr) <* notFollowedBy spaceChar -classIdAttr :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)+classIdAttr :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr) classIdAttr = try $ do -- (class class #id)   char '('-  ws <- words `fmap` manyTill anyChar' (char ')')+  ws <- T.words `fmap` T.pack <$> manyTill anyChar' (char ')')   case reverse ws of-       []                      -> return $ \(_,_,keyvals) -> ("",[],keyvals)-       (('#':ident'):classes') -> return $ \(_,_,keyvals) ->-                                             (ident',classes',keyvals)-       classes'                -> return $ \(_,_,keyvals) ->-                                             ("",classes',keyvals)+       []+         -> return $ \(_,_,keyvals) -> ("",[],keyvals)+       ((T.uncons -> Just ('#', ident')):classes')+         -> return $ \(_,_,keyvals) -> (ident',classes',keyvals)+       classes'+         -> return $ \(_,_,keyvals) -> ("",classes',keyvals) -styleAttr :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)+styleAttr :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr) styleAttr = do   style <- try $ enclosed (char '{') (char '}') anyChar'-  return $ addStyle style+  return $ addStyle $ T.pack style -addStyle :: String -> Attr -> Attr+addStyle :: Text -> Attr -> Attr addStyle style (id',classes,keyvals) =   (id',classes,keyvals')   where keyvals' = ("style", style') : [(k,v) | (k,v) <- keyvals, k /= "style"]-        style' = style ++ ";" ++ concat [v | ("style",v) <- keyvals]+        style' = style <> ";" <> T.concat [v | ("style",v) <- keyvals] -langAttr :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)+langAttr :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr) langAttr = do   lang <- try $ enclosed (char '[') (char ']') alphaNum-  return $ \(id',classes,keyvals) -> (id',classes,("lang",lang):keyvals)+  return $ \(id',classes,keyvals) -> (id',classes,("lang",T.pack lang):keyvals)  -- | Parses material surrounded by a parser. surrounded :: (PandocMonad m, Show t)-           => ParserT [Char] st m t   -- ^ surrounding parser-           -> ParserT [Char] st m a   -- ^ content parser (to be used repeatedly)-           -> ParserT [Char] st m [a]+           => ParserT Text st m t   -- ^ surrounding parser+           -> ParserT Text st m a   -- ^ content parser (to be used repeatedly)+           -> ParserT Text st m [a] surrounded border =   enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try border)  simpleInline :: PandocMonad m-             => ParserT [Char] ParserState m t        -- ^ surrounding parser+             => ParserT Text ParserState m t        -- ^ surrounding parser              -> (Inlines -> Inlines)                  -- ^ Inline constructor-             -> ParserT [Char] ParserState m Inlines  -- ^ content parser (to be used repeatedly)+             -> ParserT Text ParserState m Inlines  -- ^ content parser (to be used repeatedly) simpleInline border construct = try $ do   notAfterString   border *> notFollowedBy (oneOf " \t\n\r")@@ -695,7 +698,7 @@            then body            else B.spanWith attr body -groupedInlineMarkup :: PandocMonad m => ParserT [Char] ParserState m Inlines+groupedInlineMarkup :: PandocMonad m => ParserT Text ParserState m Inlines groupedInlineMarkup = try $ do     char '['     sp1 <- option mempty $ B.space <$ whitespace@@ -704,9 +707,5 @@     char ']'     return $ sp1 <> result <> sp2 --- | Create a singleton list-singleton :: a -> [a]-singleton x = [x]--eof' :: Monad m => ParserT [Char] s m Char+eof' :: Monad m => ParserT Text s m Char eof' = '\n' <$ eof
src/Text/Pandoc/Readers/TikiWiki.hs view
@@ -43,21 +43,21 @@           -> m Pandoc readTikiWiki opts s = do   res <- readWithM parseTikiWiki def{ stateOptions = opts }-             (T.unpack (crFilter s) ++ "\n\n")+             (crFilter s <> "\n\n")   case res of        Left e  -> throwError e        Right d -> return d -type TikiWikiParser = ParserT [Char] ParserState+type TikiWikiParser = ParserT Text ParserState  -- -- utility functions -- -tryMsg :: PandocMonad m => String -> TikiWikiParser m a -> TikiWikiParser m a-tryMsg msg p = try p <?> msg+tryMsg :: Text -> TikiWikiParser m a -> TikiWikiParser m a+tryMsg msg p = try p <?> (T.unpack msg) -skip :: PandocMonad m => TikiWikiParser m a -> TikiWikiParser m ()+skip :: TikiWikiParser m a -> TikiWikiParser m () skip parser = Control.Monad.void parser  nested :: PandocMonad m => TikiWikiParser m a -> TikiWikiParser m a@@ -89,7 +89,7 @@          <|> para   skipMany blankline   when (verbosity >= INFO) $-    trace (printf "line %d: %s" (sourceLine pos) (take 60 $ show $ B.toList res))+    trace (T.pack $ printf "line %d: %s" (sourceLine pos) (take 60 $ show $ B.toList res))   return res  blockElements :: PandocMonad m => TikiWikiParser m B.Blocks@@ -133,7 +133,7 @@ tableRow = try $ do --  row <- sepBy1 (many1Till inline $ oneOf "\n|") (try $ string "|" <* notFollowedBy (oneOf "|\n")) --  return $ map (B.plain . mconcat) row-  row <- sepBy1 (many1 (noneOf "\n|") >>= parseColumn) (try $ string "|" <* notFollowedBy (oneOf "|\n"))+  row <- sepBy1 (many1 (noneOf "\n|") >>= parseColumn . T.pack) (try $ string "|" <* notFollowedBy (oneOf "|\n"))   return $ map B.plain row   where     parseColumn x = do@@ -342,15 +342,15 @@     lineContent = do       content <- anyLine       continuation <- optionMaybe listContinuation-      return $ filterSpaces content ++ "\n" ++ Data.Maybe.fromMaybe "" continuation-    filterSpaces = reverse . dropWhile (== ' ') . reverse+      return $ filterSpaces content <> "\n" <> Data.Maybe.fromMaybe "" continuation+    filterSpaces = T.dropWhileEnd (== ' ')     listContinuation = string (replicate nest '+') >> lineContent     parseContent x = do       parsed <- parseFromString (many1 inline) x       return $ mconcat $ dropWhileEnd (== B.space) parsed  -- Turn the CODE macro attributes into Pandoc code block attributes.-mungeAttrs :: [(String, String)] -> (String, [String], [(String, String)])+mungeAttrs :: [(Text, Text)] -> (Text, [Text], [(Text, Text)]) mungeAttrs rawAttrs = ("", classes, rawAttrs)   where     -- "colors" is TikiWiki CODE macro for "name of language to do@@ -370,7 +370,7 @@   string "{CODE("   rawAttrs <- macroAttrs   string ")}"-  body <- manyTill anyChar (try (string "{CODE}"))+  body <- T.pack <$> manyTill anyChar (try (string "{CODE}"))   newline   if not (null rawAttrs)     then@@ -428,9 +428,9 @@ htmlComment :: PandocMonad m => TikiWikiParser m B.Inlines htmlComment = try $ do   string "~hc~"-  inner <- many1 $ noneOf "~"+  inner <- fmap T.pack $ many1 $ noneOf "~"   string "~/hc~"-  return $ B.str $ " NOT SUPPORTED: ~hc~ (html comment opener) BEGIN: " ++ inner ++ " ~/hc~ :END "+  return $ B.str $ " NOT SUPPORTED: ~hc~ (html comment opener) BEGIN: " <> inner <> " ~/hc~ :END "  linebreak :: PandocMonad m => TikiWikiParser m B.Inlines linebreak = newline >> notFollowedBy newline >> (lastNewline <|> innerNewline)@@ -469,15 +469,15 @@   let title = fromMaybe src $ lookup "desc" rawAttrs   let alt = fromMaybe title $ lookup "alt" rawAttrs   let classes = map fst $ filter (\(_,b) -> b == "" || b == "y") rawAttrs-  if not (null src)+  if not (T.null src)     then       return $ B.imageWith ("", classes, rawAttrs) src title (B.str alt)     else-      return $ B.str $ " NOT SUPPORTED: image without src attribute BEGIN: {img " ++ printAttrs rawAttrs ++ "} :END "+      return $ B.str $ " NOT SUPPORTED: image without src attribute BEGIN: {img " <> printAttrs rawAttrs <> "} :END "   where-    printAttrs attrs = unwords $ map (\(a, b) -> a ++ "=\"" ++ b ++ "\"") attrs+    printAttrs attrs = T.unwords $ map (\(a, b) -> a <> "=\"" <> b <> "\"") attrs -imageAttr :: PandocMonad m => TikiWikiParser m (String, String)+imageAttr :: PandocMonad m => TikiWikiParser m (Text, Text) imageAttr = try $ do   key <- many1 (noneOf "=} \t\n")   char '='@@ -485,7 +485,7 @@   value <- many1 (noneOf "}\"\n")   optional $ char '"'   optional $ char ','-  return (key, value)+  return (T.pack key, T.pack value)   -- __strong__@@ -500,57 +500,57 @@ escapedChar :: PandocMonad m => TikiWikiParser m B.Inlines escapedChar = try $ do   string "~"-  mNumber <- safeRead <$> many1 digit+  mNumber <- safeRead . T.pack <$> many1 digit   string "~"   return $ B.str $     case mNumber of-      Just number -> [toEnum (number :: Int) :: Char]-      Nothing     -> []+      Just number -> T.singleton $ toEnum (number :: Int)+      Nothing     -> ""  -- UNSUPPORTED, as there doesn't seem to be any facility in calibre -- for this centered :: PandocMonad m => TikiWikiParser m B.Inlines centered = try $ do   string "::"-  inner <- many1 $ noneOf ":\n"+  inner <- fmap T.pack $ many1 $ noneOf ":\n"   string "::"-  return $ B.str $ " NOT SUPPORTED: :: (centered) BEGIN: ::" ++ inner ++ ":: :END "+  return $ B.str $ " NOT SUPPORTED: :: (centered) BEGIN: ::" <> inner <> ":: :END "  -- UNSUPPORTED, as there doesn't seem to be any facility in calibre -- for this colored :: PandocMonad m => TikiWikiParser m B.Inlines colored = try $ do   string "~~"-  inner <- many1 $ noneOf "~\n"+  inner <- fmap T.pack $ many1 $ noneOf "~\n"   string "~~"-  return $ B.str $ " NOT SUPPORTED: ~~ (colored) BEGIN: ~~" ++ inner ++ "~~ :END "+  return $ B.str $ " NOT SUPPORTED: ~~ (colored) BEGIN: ~~" <> inner <> "~~ :END "  -- UNSUPPORTED, as there doesn't seem to be any facility in calibre -- for this underlined :: PandocMonad m => TikiWikiParser m B.Inlines underlined = try $ do   string "==="-  inner <- many1 $ noneOf "=\n"+  inner <- fmap T.pack $ many1 $ noneOf "=\n"   string "==="-  return $ B.str $ " NOT SUPPORTED: ==== (underlined) BEGIN: ===" ++ inner ++ "=== :END "+  return $ B.str $ " NOT SUPPORTED: ==== (underlined) BEGIN: ===" <> inner <> "=== :END "  -- UNSUPPORTED, as there doesn't seem to be any facility in calibre -- for this boxed :: PandocMonad m => TikiWikiParser m B.Inlines boxed = try $ do   string "^"-  inner <- many1 $ noneOf "^\n"+  inner <- fmap T.pack $ many1 $ noneOf "^\n"   string "^"-  return $ B.str $ " NOT SUPPORTED: ^ (boxed) BEGIN: ^" ++ inner ++ "^ :END "+  return $ B.str $ " NOT SUPPORTED: ^ (boxed) BEGIN: ^" <> inner <> "^ :END "  -- --text-- strikeout :: PandocMonad m => TikiWikiParser m B.Inlines strikeout = try $ fmap B.strikeout (enclosed (string "--") nestedInlines) -nestedString :: (Show a, PandocMonad m) => TikiWikiParser m a -> TikiWikiParser m String-nestedString end = innerSpace <|> count 1 nonspaceChar+nestedString :: (Show a, PandocMonad m) => TikiWikiParser m a -> TikiWikiParser m Text+nestedString end = innerSpace <|> countChar 1 nonspaceChar   where-    innerSpace = try $ many1 spaceChar <* notFollowedBy end+    innerSpace = try $ T.pack <$> many1 spaceChar <* notFollowedBy end  breakChars :: PandocMonad m => TikiWikiParser m B.Inlines breakChars = try $ string "%%%" >> return B.linebreak@@ -564,7 +564,7 @@   string "{SUP("   manyTill anyChar (string ")}")   body <- manyTill anyChar (string "{SUP}")-  return $ B.superscript $ B.text body+  return $ B.superscript $ B.text $ T.pack body  -- subscript: baz{TAG(tag=>sub)}sub{TAG}qux / qux{SUB()}sub2{SUB}qux subTag :: PandocMonad m => TikiWikiParser m B.Inlines@@ -575,22 +575,22 @@   string "{SUB("   manyTill anyChar (string ")}")   body <- manyTill anyChar (string "{SUB}")-  return $ B.subscript $ B.text body+  return $ B.subscript $ B.text $ T.pack body  -- -+text+- code :: PandocMonad m => TikiWikiParser m B.Inlines code = try $  fmap (B.code . fromEntities) ( between (string "-+") (string "+-") nestedString) -macroAttr :: PandocMonad m => TikiWikiParser m (String, String)+macroAttr :: PandocMonad m => TikiWikiParser m (Text, Text) macroAttr = try $ do   key <- many1 (noneOf "=)")   char '='   optional $ char '"'   value <- many1 (noneOf " )\"")   optional $ char '"'-  return (key, value)+  return (T.pack key, T.pack value) -macroAttrs :: PandocMonad m => TikiWikiParser m [(String, String)]+macroAttrs :: PandocMonad m => TikiWikiParser m [(Text, Text)] macroAttrs = try $ sepEndBy macroAttr spaces  -- ~np~ __not bold__ ~/np~@@ -598,13 +598,13 @@ noparse = try $ do   string "~np~"   body <- manyTill anyChar (string "~/np~")-  return $ B.str body+  return $ B.str $ T.pack body  str :: PandocMonad m => TikiWikiParser m B.Inlines-str = fmap B.str (many1 alphaNum <|> count 1 characterReference)+str = fmap B.str (T.pack <$> many1 alphaNum <|> countChar 1 characterReference)  symbol :: PandocMonad m => TikiWikiParser m B.Inlines-symbol = fmap B.str (count 1 nonspaceChar)+symbol = fmap B.str (countChar 1 nonspaceChar)  -- [[not a link] notExternalLink :: PandocMonad m => TikiWikiParser m B.Inlines@@ -612,14 +612,14 @@   start <- string "[["   body <- many (noneOf "\n[]")   end <- string "]"-  return $ B.text (start ++ body ++ end)+  return $ B.text $ T.pack $ start ++ body ++ end  -- [http://www.somesite.org url|Some Site title] -- ((internal link)) -- -- The ((...)) wiki links and [...] external links are handled -- exactly the same; this abstracts that out-makeLink :: PandocMonad m => String -> String -> String -> TikiWikiParser m B.Inlines+makeLink :: PandocMonad m => Text -> Text -> Text -> TikiWikiParser m B.Inlines makeLink start middle end = try $ do   st <- getState   guard $ stateAllowLinks st@@ -627,15 +627,15 @@   (url, title, anchor) <- wikiLinkText start middle end   parsedTitle <- parseFromString (many1 inline) title   setState $ st{ stateAllowLinks = True }-  return $ B.link (url++anchor) "" $mconcat parsedTitle+  return $ B.link (url <> anchor) "" $ mconcat parsedTitle -wikiLinkText :: PandocMonad m => String -> String -> String -> TikiWikiParser m (String, String, String)+wikiLinkText :: PandocMonad m => Text -> Text -> Text -> TikiWikiParser m (Text, Text, Text) wikiLinkText start middle end = do-  string start-  url <- many1 (noneOf $ middle ++ "\n")+  string (T.unpack start)+  url <- T.pack <$> many1 (noneOf $ T.unpack middle ++ "\n")   seg1 <- option url linkContent   seg2 <- option "" linkContent-  string end+  string (T.unpack end)   if seg2 /= ""     then       return (url, seg2, seg1)@@ -644,7 +644,7 @@   where     linkContent      = do       char '|'-      many (noneOf middle)+      T.pack <$> many (noneOf $ T.unpack middle)  externalLink :: PandocMonad m => TikiWikiParser m B.Inlines externalLink = makeLink "[" "]|" "]"
src/Text/Pandoc/Readers/Txt2Tags.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Readers.Txt2Tags    Copyright   : Copyright (C) 2014 Matthew Pickering@@ -18,7 +19,6 @@ import Control.Monad (guard, void, when) import Control.Monad.Except (catchError, throwError) import Control.Monad.Reader (Reader, asks, runReader)-import Data.Char (toLower) import Data.Default import Data.List (intercalate, transpose) import Data.Maybe (fromMaybe)@@ -36,13 +36,13 @@ import Text.Pandoc.Shared (compactify, compactifyDL, crFilter, escapeURI,                            underlineSpan) -type T2T = ParserT String ParserState (Reader T2TMeta)+type T2T = ParserT Text ParserState (Reader T2TMeta)  -- | An object for the T2T macros meta information -- the contents of each field is simply substituted verbatim into the file data  T2TMeta = T2TMeta {-                 date    :: String -- ^ Current date-               , mtime   :: String -- ^ Last modification time of infile+                 date    :: Text -- ^ Current date+               , mtime   :: Text -- ^ Last modification time of infile                , infile  :: FilePath -- ^ Input file                , outfile :: FilePath -- ^ Output file                } deriving Show@@ -63,7 +63,7 @@                   _ -> catchError                         (maximum <$> mapM getModTime inps)                         (const (return ""))-    return $ T2TMeta curDate curMtime (intercalate ", " inps) outp+    return $ T2TMeta (T.pack curDate) (T.pack curMtime) (intercalate ", " inps) outp  -- | Read Txt2Tags from an input string returning a Pandoc document readTxt2Tags :: PandocMonad m@@ -74,14 +74,14 @@   meta <- getT2TMeta   let parsed = flip runReader meta $         readWithM parseT2T (def {stateOptions = opts}) $-        T.unpack (crFilter s) ++ "\n\n"+        crFilter s <> "\n\n"   case parsed of     Right result -> return result     Left e       -> throwError e  -- | Read Txt2Tags (ignoring all macros) from an input string returning -- a Pandoc document--- readTxt2TagsNoMacros :: PandocMonad m => ReaderOptions -> String -> m Pandoc+-- readTxt2TagsNoMacros :: PandocMonad m => ReaderOptions -> Text -> m Pandoc -- readTxt2TagsNoMacros = readTxt2Tags  parseT2T :: T2T Pandoc@@ -106,7 +106,7 @@ header :: T2T () header = titleline >> authorline >> dateline -headerline :: B.ToMetaValue a => String -> T2T a -> T2T ()+headerline :: B.ToMetaValue a => Text -> T2T a -> T2T () headerline field p = (() <$ try blankline)                         <|> (p >>= updateState . B.setMeta field) @@ -123,15 +123,15 @@ dateline :: T2T () dateline = headerline "date" (trimInlines . mconcat <$> manyTill inline newline) -type Keyword = String-type Value = String+type Keyword = Text+type Value = Text  setting :: T2T (Keyword, Value) setting = do   string "%!"-  keyword <- ignoreSpacesCap (many1 alphaNum)+  keyword <- ignoreSpacesCap (many1Char alphaNum)   char ':'-  value <- ignoreSpacesCap (manyTill anyChar newline)+  value <- ignoreSpacesCap (manyTillChar anyChar newline)   return (keyword, value)  -- Blocks@@ -163,10 +163,10 @@   spaces   level <- length <$> many1 (char c)   guard (level <= 5) -- Max header level 5-  heading <- manyTill (noneOf "\n\r") (count level (char c))+  heading <- manyTillChar (noneOf "\n\r") (count level (char c))   label <- optionMaybe (enclosed (char '[') (char ']') (alphaNum <|> oneOf "_-"))   many spaceChar *> newline-  let attr = maybe nullAttr (\x -> (x, [], [])) label+  let attr = maybe nullAttr (\x -> (T.pack x, [], [])) label   return $ B.headerWith attr level (trimInlines $ B.text heading)  para :: T2T Blocks@@ -192,7 +192,7 @@ quote = try $ do   lookAhead tab   rawQuote <-  many1 (tab *> optional spaces *> anyLine)-  contents <- parseFromString' parseBlocks (intercalate "\n" rawQuote ++ "\n\n")+  contents <- parseFromString' parseBlocks (T.intercalate "\n" rawQuote <> "\n\n")   return $ B.blockQuote contents  commentLine :: T2T Inlines@@ -243,17 +243,17 @@   markerLength <- try start   firstLine <- anyLineNewline   blank <- option "" ("\n" <$ blankline)-  rest <- concat <$> many (listContinuation markerLength)-  parseFromString' end $ firstLine ++ blank ++ rest+  rest <- T.concat <$> many (listContinuation markerLength)+  parseFromString' end $ firstLine <> blank <> rest  -- continuation of a list item - indented and separated by blankline or endline. -- Note: nested lists are parsed as continuations. listContinuation :: Int-                 -> T2T String+                 -> T2T Text listContinuation markerLength = try $   notFollowedBy' (blankline >> blankline)-  *> (mappend <$> (concat <$> many1 listLine)-              <*> many blankline)+  *> (mappend <$> (T.concat <$> many1 listLine)+              <*> manyChar blankline)  where listLine = try $ indentWith markerLength *> anyLineNewline  -- Table@@ -327,16 +327,16 @@  -- Generic -genericBlock :: Monoid a => T2T a -> (a -> Blocks) -> String -> T2T Blocks+genericBlock :: Monoid a => T2T a -> (a -> Blocks) -> Text -> T2T Blocks genericBlock p f s = blockMarkupArea p f s <|> blockMarkupLine p f s -blockMarkupArea :: Monoid a => T2T a -> (a -> Blocks) -> String -> T2T Blocks+blockMarkupArea :: Monoid a => T2T a -> (a -> Blocks) -> Text -> T2T Blocks blockMarkupArea p f s = try (do-  string s *> blankline-  f . mconcat <$> manyTill p (eof <|> void (string s *> blankline)))+  textStr s *> blankline+  f . mconcat <$> manyTill p (eof <|> void (textStr s *> blankline))) -blockMarkupLine :: T2T a -> (a -> Blocks) -> String -> T2T Blocks-blockMarkupLine p f s = try (f <$> (string s *> space *> p))+blockMarkupLine :: T2T a -> (a -> Blocks) -> Text -> T2T Blocks+blockMarkupLine p f s = try (f <$> (textStr s *> space *> p))  -- Can be in either block or inline position comment :: Monoid a => T2T a@@ -385,15 +385,15 @@ italic = inlineMarkup inline B.emph '/' B.str  code :: T2T Inlines-code = inlineMarkup ((:[]) <$> anyChar) B.code '`' id+code = inlineMarkup (T.singleton <$> anyChar) B.code '`' id  raw :: T2T Inlines-raw = inlineMarkup ((:[]) <$> anyChar) B.text '"' id+raw = inlineMarkup (T.singleton <$> anyChar) B.text '"' id  tagged :: T2T Inlines tagged = do   target <- getTarget-  inlineMarkup ((:[]) <$> anyChar) (B.rawInline target) '\'' id+  inlineMarkup (T.singleton <$> anyChar) (B.rawInline target) '\'' id  -- Parser for markup indicated by a double character. -- Inline markup is greedy and glued@@ -404,33 +404,33 @@              => T2T a -- Content parser              -> (a -> Inlines) -- Constructor              -> Char -- Fence-             -> (String -> a) -- Special Case to handle ******+             -> (Text -> a) -- Special Case to handle ******              -> T2T Inlines inlineMarkup p f c special = try $ do-  start <- many1 (char c)-  let l = length start+  start <- many1Char (char c)+  let l = T.length start   guard (l >= 2)   when (l == 2) (void $ notFollowedBy space)   -- We must make sure that there is no space before the start of the   -- closing tags-  body <-  optionMaybe (try $ manyTill (noneOf "\n\r")+  body <-  optionMaybe (try $ manyTillChar (noneOf "\n\r")                 (try $ lookAhead (noneOf " " >> string [c,c] )))   case body of     Just middle -> do       lastChar <- anyChar-      end <- many1 (char c)+      end <- many1Char (char c)       let parser inp = parseFromString' (mconcat <$> many p) inp-      let start' = case drop 2 start of+      let start' = case T.drop 2 start of                           "" -> mempty                           xs -> special xs-      body' <- parser (middle ++ [lastChar])-      let end' = case drop 2 end of+      body' <- parser (middle <> T.singleton lastChar)+      let end' = case T.drop 2 end of                           "" -> mempty                           xs -> special xs       return $ f (start' `mappend` body' `mappend` end')     Nothing -> do -- Either bad or case such as *****       guard (l >= 5)-      let body' = replicate (l - 4) c+      let body' = T.replicate (l - 4) $ T.singleton c       return $ f (special body')  link :: T2T Inlines@@ -441,12 +441,12 @@ titleLink = try $ do   char '['   notFollowedBy space-  tokens <- sepBy1 (many $ noneOf " ]") space+  tokens <- sepBy1 (manyChar $ noneOf " ]") space   guard (length tokens >= 2)   char ']'   let link' = last tokens-  guard $ not $ null link'-  let tit = unwords (init tokens)+  guard $ not $ T.null link'+  let tit = T.unwords (init tokens)   return $ B.link link' "" (B.text tit)  -- Link with image@@ -455,7 +455,7 @@   char '['   body <- image   many1 space-  l <- manyTill (noneOf "\n\r ") (char ']')+  l <- manyTillChar (noneOf "\n\r ") (char ']')   return (B.link l "" body)  macro :: T2T Inlines@@ -466,7 +466,7 @@   maybe (return mempty) (\f -> B.str <$> asks f) (lookup name commands)   where     commands = [ ("date", date), ("mtime", mtime)-               , ("infile", infile), ("outfile", outfile)]+               , ("infile", T.pack . infile), ("outfile", T.pack . outfile)]  -- raw URLs in text are automatically linked url :: T2T Inlines@@ -474,7 +474,7 @@   (rawUrl, escapedUrl) <- try uri <|> emailAddress   return $ B.link rawUrl "" (B.str escapedUrl) -uri :: T2T (String, String)+uri :: T2T (Text, Text) uri = try $ do   address <- t2tURI   return (address, escapeURI address)@@ -486,25 +486,25 @@ --isT2TURI (parse t2tURI "" -> Right _) = True --isT2TURI _ = False -t2tURI :: T2T String+t2tURI :: T2T Text t2tURI = do-  start <- try ((++) <$> proto <*> urlLogin) <|> guess-  domain <- many1 chars-  sep <- many (char '/')-  form' <- option mempty ((:) <$> char '?' <*> many1 form)-  anchor' <- option mempty ((:) <$> char '#' <*> many anchor)-  return (start ++ domain ++ sep ++ form' ++ anchor')+  start <- try ((<>) <$> proto <*> urlLogin) <|> guess+  domain <- many1Char chars+  sep <- manyChar (char '/')+  form' <- option mempty (T.cons <$> char '?' <*> many1Char form)+  anchor' <- option mempty (T.cons <$> char '#' <*> manyChar anchor)+  return (start <> domain <> sep <> form' <> anchor')   where     protos = ["http", "https", "ftp", "telnet", "gopher", "wais"]-    proto = (++) <$> oneOfStrings protos <*> string "://"-    guess = (++) <$> (((++) <$> stringAnyCase "www" <*> option mempty ((:[]) <$> oneOf "23"))-              <|> stringAnyCase "ftp") <*> ((:[]) <$> char '.')+    proto = (<>) <$> oneOfStrings protos <*> textStr "://"+    guess = (<>) <$> (((<>) <$> stringAnyCase "www" <*> option mempty (T.singleton <$> oneOf "23"))+              <|> stringAnyCase "ftp") <*> (T.singleton <$> char '.')     login = alphaNum <|> oneOf "_.-"-    pass = many (noneOf " @")+    pass = manyChar (noneOf " @")     chars = alphaNum <|> oneOf "%._/~:,=$@&+-"     anchor = alphaNum <|> oneOf "%._0"     form = chars <|> oneOf ";*"-    urlLogin = option mempty $ try ((\x y z -> x ++ y ++ [z]) <$> many1 login <*> option mempty ((:) <$> char ':' <*> pass) <*> char '@')+    urlLogin = option mempty $ try ((\x y z -> x <> y <> T.singleton z) <$> many1Char login <*> option mempty (T.cons <$> char ':' <*> pass) <*> char '@')   image :: T2T Inlines@@ -512,12 +512,12 @@   -- List taken from txt2tags source   let extensions = [".jpg", ".jpeg", ".gif", ".png", ".eps", ".bmp"]   char '['-  (path, ext) <- manyUntil (noneOf "\n\t\r ") (oneOfStrings extensions)+  (path, ext) <- manyUntilChar (noneOf "\n\t\r ") (oneOfStrings extensions)   char ']'-  return $ B.image (path ++ ext) "" mempty+  return $ B.image (path <> ext) "" mempty  -- Characters used in markup-specialChars :: String+specialChars :: [Char] specialChars = "%*-_/|:+;"  tab :: T2T Char@@ -526,8 +526,8 @@ space :: T2T Char space = char ' ' -spaces :: T2T String-spaces = many space+spaces :: T2T Text+spaces = manyChar space  endline :: T2T Inlines endline = try $ do@@ -544,17 +544,17 @@   return B.softbreak  str :: T2T Inlines-str = try $ B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")+str = try $ B.str <$> many1Char (noneOf $ specialChars ++ "\n\r ")  whitespace :: T2T Inlines whitespace = try $ B.space <$ spaceChar  symbol :: T2T Inlines-symbol = B.str . (:[]) <$> oneOf specialChars+symbol = B.str . T.singleton <$> oneOf specialChars  -- Utility -getTarget :: T2T String+getTarget :: T2T Text getTarget = do   mv <- lookupMeta "target" . stateMeta <$> getState   return $ case mv of@@ -565,5 +565,5 @@ atStart :: T2T () atStart = (sourceColumn <$> getPosition) >>= guard . (== 1) -ignoreSpacesCap :: T2T String -> T2T String-ignoreSpacesCap p = map toLower <$> (spaces *> p <* spaces)+ignoreSpacesCap :: T2T Text -> T2T Text+ignoreSpacesCap p = T.toLower <$> (spaces *> p <* spaces)
src/Text/Pandoc/Readers/Vimwiki.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE CPP #-} {- |    Module      : Text.Pandoc.Readers.Vimwiki@@ -51,9 +52,10 @@ import Control.Monad (guard) import Control.Monad.Except (throwError) import Data.Default-import Data.List (isInfixOf, isPrefixOf)+import Data.List (isInfixOf) import Data.Maybe import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Builder (Blocks, Inlines, fromList, toList, trimInlines) import qualified Text.Pandoc.Builder as B (blockQuote, bulletList, code,                                            codeBlockWith, definitionList,@@ -73,12 +75,13 @@ import Text.Pandoc.Parsing (ParserState, ParserT, blanklines, emailAddress,                             many1Till, orderedListMarker, readWithM,                             registerHeader, spaceChar, stateMeta,-                            stateOptions, uri)-import Text.Pandoc.Shared (crFilter, splitBy, stringify, stripFirstAndLast,-                           isURI)+                            stateOptions, uri, manyTillChar, manyChar, textStr,+                            many1Char, countChar, many1TillChar)+import Text.Pandoc.Shared (crFilter, splitTextBy, stringify, stripFirstAndLast,+                           isURI, tshow) import Text.Parsec.Char (alphaNum, anyChar, char, newline, noneOf, oneOf, space,                          spaces, string)-import Text.Parsec.Combinator (between, choice, count, eof, lookAhead, many1,+import Text.Parsec.Combinator (between, choice, eof, lookAhead, many1,                                manyTill, notFollowedBy, option, skipMany1) import Text.Parsec.Prim (getState, many, try, updateState, (<|>)) @@ -128,7 +131,7 @@                 , definitionList                 , para                 ]-  trace (take 60 $ show $ toList res)+  trace (T.take 60 $ tshow $ toList res)   return res  blockML :: PandocMonad m => VwParser m Blocks@@ -218,32 +221,32 @@ defMarkerE :: PandocMonad m => VwParser m Char defMarkerE = string "::" >> newline -hasDefMarkerM :: PandocMonad m => VwParser m String-hasDefMarkerM = manyTill (noneOf "\n") (try defMarkerM)+hasDefMarkerM :: PandocMonad m => VwParser m Text+hasDefMarkerM = manyTillChar (noneOf "\n") (try defMarkerM)  preformatted :: PandocMonad m => VwParser m Blocks preformatted = try $ do   many spaceChar >> string "{{{"-  attrText <- many (noneOf "\n")+  attrText <- manyChar (noneOf "\n")   lookAhead newline-  contents <- manyTill anyChar (try (char '\n' >> many spaceChar >> string "}}}"+  contents <- manyTillChar anyChar (try (char '\n' >> many spaceChar >> string "}}}"     >> many spaceChar >> newline))-  if (contents /= "") && (head contents == '\n')-     then return $ B.codeBlockWith (makeAttr attrText) (tail contents)+  if (contents /= "") && (T.head contents == '\n')+     then return $ B.codeBlockWith (makeAttr attrText) (T.tail contents)      else return $ B.codeBlockWith (makeAttr attrText) contents -makeAttr :: String -> Attr+makeAttr :: Text -> Attr makeAttr s =-  let xs = splitBy (`elem` " \t") s in+  let xs = splitTextBy (`elem` (" \t" :: String)) s in     ("", [], mapMaybe nameValue xs) -nameValue :: String -> Maybe (String, String)+nameValue :: Text -> Maybe (Text, Text) nameValue s =-  let t = splitBy (== '=') s in+  let t = splitTextBy (== '=') s in     if length t /= 2       then Nothing       else let (a, b) = (head t, last t) in-             if (length b < 2) || ((head b, last b) /= ('"', '"'))+             if (T.length b < 2) || ((T.head b, T.last b) /= ('"', '"'))                then Nothing                else Just (a, stripFirstAndLast b) @@ -253,16 +256,16 @@   many spaceChar >> string "{{$"   mathTag <- option "" mathTagParser   many space-  contents <- manyTill anyChar (try (char '\n' >> many spaceChar >> string "}}$"+  contents <- manyTillChar anyChar (try (char '\n' >> many spaceChar >> string "}}$"     >> many spaceChar >> newline))   let contentsWithTags         | mathTag == "" = contents-        | otherwise     = "\\begin{" ++ mathTag ++ "}\n" ++ contents-                          ++ "\n\\end{" ++ mathTag ++ "}"+        | otherwise     = "\\begin{" <> mathTag <> "}\n" <> contents+                          <> "\n\\end{" <> mathTag <> "}"   return $ B.para $ B.displayMath contentsWithTags  -mathTagLaTeX :: String -> String+mathTagLaTeX :: Text -> Text mathTagLaTeX s = case s of    "equation"  -> ""    "equation*" -> ""@@ -360,17 +363,17 @@                             _ -> x:[y] combineList x xs = x:xs -listStart :: PandocMonad m => VwParser m (Int, String)+listStart :: PandocMonad m => VwParser m (Int, Text) listStart = try $ do   s <- many spaceChar   listType <- bulletListMarkers <|> orderedListMarkers   spaceChar   return (length s, listType) -bulletListMarkers :: PandocMonad m => VwParser m String+bulletListMarkers :: PandocMonad m => VwParser m Text bulletListMarkers = "ul" <$ (char '*' <|> char '-') -orderedListMarkers :: PandocMonad m => VwParser m String+orderedListMarkers :: PandocMonad m => VwParser m Text orderedListMarkers =   ("ol" <$choice (orderedListMarker Decimal Period:(($OneParen) . orderedListMarker <$> [Decimal, LowerRoman, UpperRoman, LowerAlpha, UpperAlpha])))     <|> ("ol" <$ char '#')@@ -421,13 +424,15 @@ placeholder = try $   choice (ph <$> ["title", "date"]) <|> noHtmlPh <|> templatePh -ph :: PandocMonad m => String -> VwParser m ()+ph :: PandocMonad m => Text -> VwParser m () ph s = try $ do-  many spaceChar >>string ('%':s) >> spaceChar+  many spaceChar >> textStr (T.cons '%' s) >> spaceChar   contents <- trimInlines . mconcat <$> manyTill inline (lookAhead newline)     --use lookAhead because of placeholder in the whitespace parser   let meta' = B.setMeta s contents nullMeta-  updateState $ \st -> st { stateMeta = stateMeta st <> meta' }+  -- this order ensures that later values will be ignored in favor+  -- of earlier ones:+  updateState $ \st -> st { stateMeta = meta' <> stateMeta st }  noHtmlPh :: PandocMonad m => VwParser m () noHtmlPh = try $@@ -474,7 +479,7 @@ inlineML = choice $ whitespace endlineML:inlineList  str :: PandocMonad m => VwParser m Inlines-str = B.str <$>many1 (noneOf $ spaceChars ++ specialChars)+str = B.str <$> many1Char (noneOf $ spaceChars ++ specialChars)  whitespace :: PandocMonad m => VwParser m () -> VwParser m Inlines whitespace endline = B.space <$ (skipMany1 spaceChar <|>@@ -485,7 +490,7 @@ whitespace' = B.space <$ skipMany1 spaceChar  special :: PandocMonad m => VwParser m Inlines-special = B.str <$> count 1 (oneOf specialChars)+special = B.str <$> countChar 1 (oneOf specialChars)  bareURL :: PandocMonad m => VwParser m Inlines bareURL = try $ do@@ -503,8 +508,8 @@   return $ B.spanWith (makeId contents, [], []) mempty     <> B.strong contents -makeId :: Inlines -> String-makeId i = concat (stringify <$> toList i)+makeId :: Inlines -> Text+makeId i = T.concat (stringify <$> toList i)  emph :: PandocMonad m => VwParser m Inlines emph = try $ do@@ -525,7 +530,7 @@ code :: PandocMonad m => VwParser m Inlines code = try $ do   char '`'-  contents <- many1Till (noneOf "\n") (char '`')+  contents <- many1TillChar (noneOf "\n") (char '`')   return $ B.code contents  superscript :: PandocMonad m => VwParser m Inlines@@ -540,8 +545,8 @@ link :: PandocMonad m => VwParser m Inlines link = try $ do   string "[["-  contents <- lookAhead $ manyTill anyChar (string "]]")-  case '|' `elem` contents of+  contents <- lookAhead $ manyTillChar anyChar (string "]]")+  case T.any (== '|') contents of                   False -> do                     manyTill anyChar (string "]]") -- not using try here because [[hell]o]] is not rendered as a link in vimwiki@@ -550,7 +555,7 @@                                  else "wikilink"                     return $ B.link (procLink contents) tit (B.str contents)                   True  -> do-                    url <- manyTill anyChar $ char '|'+                    url <- manyTillChar anyChar $ char '|'                     lab <- mconcat <$> manyTill inline (string "]]")                     let tit = if isURI url                                  then ""@@ -566,52 +571,52 @@ images :: PandocMonad m => Int -> VwParser m Inlines images k   | k == 0 = do-           imgurl <- manyTill anyChar (try $ string "}}")+           imgurl <- manyTillChar anyChar (try $ string "}}")            return $ B.image (procImgurl imgurl) "" (B.str "")   | k == 1 = do-           imgurl <- manyTill anyChar (char '|')+           imgurl <- manyTillChar anyChar (char '|')            alt <- mconcat <$> manyTill inline (try $ string "}}")            return $ B.image (procImgurl imgurl) "" alt   | k == 2 = do-           imgurl <- manyTill anyChar (char '|')-           alt <- mconcat <$>manyTill inline (char '|')-           attrText <- manyTill anyChar (try $ string "}}")+           imgurl <- manyTillChar anyChar (char '|')+           alt <- mconcat <$> manyTill inline (char '|')+           attrText <- manyTillChar anyChar (try $ string "}}")            return $ B.imageWith (makeAttr attrText) (procImgurl imgurl) "" alt   | otherwise = do-           imgurl <- manyTill anyChar (char '|')-           alt <- mconcat <$>manyTill inline (char '|')-           attrText <- manyTill anyChar (char '|')+           imgurl <- manyTillChar anyChar (char '|')+           alt <- mconcat <$> manyTill inline (char '|')+           attrText <- manyTillChar anyChar (char '|')            manyTill anyChar (try $ string "}}")            return $ B.imageWith (makeAttr attrText) (procImgurl imgurl) "" alt -procLink' :: String -> String+procLink' :: Text -> Text procLink' s-  | take 6 s == "local:" = "file" ++ drop 5 s-  | take 6 s == "diary:" = "diary/" ++ drop 6 s-  | or ((`isPrefixOf` s) <$> [ "http:", "https:", "ftp:", "file:", "mailto:",+  | T.take 6 s == "local:" = "file" <> T.drop 5 s+  | T.take 6 s == "diary:" = "diary/" <> T.drop 6 s+  | or ((`T.isPrefixOf` s) <$> [ "http:", "https:", "ftp:", "file:", "mailto:",                               "news:", "telnet:" ])                              = s   | s == ""                  = ""-  | last s == '/'          = s+  | T.last s == '/'          = s   | otherwise                = s -procLink :: String -> String-procLink s = procLink' x ++ y-  where (x, y) = break (=='#') s+procLink :: Text -> Text+procLink s = procLink' x <> y+  where (x, y) = T.break (=='#') s -procImgurl :: String -> String-procImgurl s = if take 6 s == "local:" then "file" ++ drop 5 s else s+procImgurl :: Text -> Text+procImgurl s = if T.take 6 s == "local:" then "file" <> T.drop 5 s else s  inlineMath :: PandocMonad m => VwParser m Inlines inlineMath = try $-  B.math <$ char '$' <*> many1Till (noneOf "\n") (char '$')+  B.math <$ char '$' <*> many1TillChar (noneOf "\n") (char '$')  tag :: PandocMonad m => VwParser m Inlines tag = try $ do   char ':'-  s <- manyTill (noneOf spaceChars) (try (char ':' >> lookAhead space))-  guard $ not $ "::" `isInfixOf` (":" ++ s ++ ":")-  let ss = splitBy (==':') s+  s <- manyTillChar (noneOf spaceChars) (try (char ':' >> lookAhead space))+  guard $ not $ "::" `T.isInfixOf` (":" <> s <> ":")+  let ss = splitTextBy (==':') s   return $ mconcat $ makeTagSpan' (head ss):(makeTagSpan <$> tail ss)  todoMark :: PandocMonad m => VwParser m Inlines@@ -644,16 +649,16 @@ hasDefMarker :: PandocMonad m => VwParser m () hasDefMarker = () <$ manyTill (noneOf "\n") (string "::" >> oneOf spaceChars) -makeTagSpan' :: String -> Inlines-makeTagSpan' s = B.spanWith ('-' : s, [], []) (B.str "") <>+makeTagSpan' :: Text -> Inlines+makeTagSpan' s = B.spanWith (T.cons '-' s, [], []) (B.str "") <>                   B.spanWith (s, ["tag"], []) (B.str s) -makeTagSpan :: String -> Inlines+makeTagSpan :: Text -> Inlines makeTagSpan s = B.space <> makeTagSpan' s -mathTagParser :: PandocMonad m => VwParser m String+mathTagParser :: PandocMonad m => VwParser m Text mathTagParser = do-  s <- try $ lookAhead (char '%' >> manyTill (noneOf spaceChars)+  s <- try $ lookAhead (char '%' >> manyTillChar (noneOf spaceChars)     (try $ char '%' >> many (noneOf $ '%':spaceChars) >> space))-  char '%' >> string s >> char '%'+  char '%' >> textStr s >> char '%'   return $ mathTagLaTeX s
src/Text/Pandoc/RoffChar.hs view
@@ -18,10 +18,11 @@   , combiningAccents   ) where import Prelude+import qualified Data.Text as T  -- | These are the escapes specifically mentioned in groff_man(7), -- plus @ and ellipsis.-standardEscapes :: [(Char, String)]+standardEscapes :: [(Char, T.Text)] standardEscapes =   [ ('\160', "\\ ")   , ('\'', "\\[aq]")@@ -40,7 +41,7 @@   , ('\x2026', "\\&...")  -- because u2026 doesn't render on tty   ] -characterCodes :: [(Char, String)]+characterCodes :: [(Char, T.Text)] characterCodes =   [ ('Ð', "-D")   , ('ð', "Sd")@@ -402,7 +403,7 @@   ]  -- use like: \\[E a^ aa]-combiningAccents :: [(Char, String)]+combiningAccents :: [(Char, T.Text)] combiningAccents =   [ ('\779' , "a\"")   , ('\772', "a-")
src/Text/Pandoc/SelfContained.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TupleSections     #-} {- |    Module      : Text.Pandoc.SelfContained    Copyright   : Copyright (C) 2011-2019 John MacFarlane@@ -23,8 +24,8 @@ import Data.ByteString.Base64 import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as L-import Data.Char (isAlphaNum, isAscii, toLower)-import Data.List (isPrefixOf)+import qualified Data.Text as T+import Data.Char (isAlphaNum, isAscii) import Network.URI (escapeURIString) import System.FilePath (takeDirectory, takeExtension, (</>)) import Text.HTML.TagSoup@@ -34,24 +35,24 @@ import Text.Pandoc.Logging import Text.Pandoc.MIME (MimeType) import Text.Pandoc.Shared (isURI, renderTags', trim)-import Text.Pandoc.UTF8 (toString)+import Text.Pandoc.UTF8 (toString, toText, fromText) import Text.Parsec (ParsecT, runParserT) import qualified Text.Parsec as P  isOk :: Char -> Bool isOk c = isAscii c && isAlphaNum c -makeDataURI :: (MimeType, ByteString) -> String+makeDataURI :: (MimeType, ByteString) -> T.Text makeDataURI (mime, raw) =   if textual-     then "data:" ++ mime' ++ "," ++ escapeURIString isOk (toString raw)-     else "data:" ++ mime' ++ ";base64," ++ toString (encode raw)-  where textual = "text/" `Data.List.isPrefixOf` mime-        mime' = if textual && ';' `notElem` mime-                   then mime ++ ";charset=utf-8"+     then "data:" <> mime' <> "," <> T.pack (escapeURIString isOk (toString raw))+     else "data:" <> mime' <> ";base64," <> toText (encode raw)+  where textual = "text/" `T.isPrefixOf` mime+        mime' = if textual && T.any (== ';') mime+                   then mime <> ";charset=utf-8"                    else mime  -- mime type already has charset -convertTags :: PandocMonad m => [Tag String] -> m [Tag String]+convertTags :: PandocMonad m => [Tag T.Text] -> m [Tag T.Text] convertTags [] = return [] convertTags (t@TagOpen{}:ts)   | fromAttrib "data-external" t == "1" = (t:) <$> convertTags ts@@ -68,10 +69,10 @@                 enc <- getDataURI (fromAttrib "type" t) y                 return (x, enc)               else return (x,y)-convertTags (t@(TagOpen "script" as):TagClose "script":ts) =+convertTags (t@(TagOpen "script" as):TagClose "script":ts) =    case fromAttrib "src" t of-       []  -> (t:) <$> convertTags ts-       src    -> do+       ""  -> (t:) <$> convertTags ts+       src -> do            let typeAttr = fromAttrib "type" t            res <- getData typeAttr src            rest <- convertTags ts@@ -80,13 +81,13 @@                      (("src",dataUri) : [(x,y) | (x,y) <- as, x /= "src"]) :                      TagClose "script" : rest                 Right (mime, bs)-                  | ("text/javascript" `isPrefixOf` mime ||-                     "application/javascript" `isPrefixOf` mime ||-                     "application/x-javascript" `isPrefixOf` mime) &&+                  | ("text/javascript" `T.isPrefixOf` mime ||+                     "application/javascript" `T.isPrefixOf` mime ||+                     "application/x-javascript" `T.isPrefixOf` mime) &&                      not ("</script" `B.isInfixOf` bs) ->                      return $-                       TagOpen "script" [("type", typeAttr)|not (null typeAttr)]-                       : TagText (toString bs)+                       TagOpen "script" [("type", typeAttr)|not (T.null typeAttr)]+                       : TagText (toText bs)                        : TagClose "script"                        : rest                   | otherwise ->@@ -96,7 +97,7 @@                         TagClose "script" : rest convertTags (t@(TagOpen "link" as):ts) =   case fromAttrib "href" t of-       []  -> (t:) <$> convertTags ts+       ""  -> (t:) <$> convertTags ts        src -> do            res <- getData (fromAttrib "type" t) src            case res of@@ -106,14 +107,14 @@                      (("href",dataUri) : [(x,y) | (x,y) <- as, x /= "href"]) :                      rest                 Right (mime, bs)-                  | "text/css" `isPrefixOf` mime-                    && null (fromAttrib "media" t)+                  | "text/css" `T.isPrefixOf` mime+                    && T.null (fromAttrib "media" t)                     && not ("</" `B.isInfixOf` bs) -> do                       rest <- convertTags $                                  dropWhile (==TagClose "link") ts                       return $-                       TagOpen "style" [("type", mime)]-                       : TagText (toString bs)+                       TagOpen "style" [("type", "text/css")] -- see #5725+                       : TagText (toText bs)                        : TagClose "style"                        : rest                   | otherwise -> do@@ -129,7 +130,7 @@   res <- runParserT (parseCSSUrls d) () "css" orig   case res of        Left e    -> do-         report $ CouldNotParseCSS (show e)+         report $ CouldNotParseCSS $ T.pack $ show e          return orig        Right bs  -> return bs @@ -175,50 +176,52 @@        Left b -> return b        Right (mt,b) -> do          let enc = makeDataURI (mt, b)-         return (B.pack $ "url(" ++ enc ++ ")")+         return $ fromText $ "url(" <> enc <> ")"  pQuoted :: PandocMonad m-        => ParsecT ByteString () m (String, ByteString)+        => ParsecT ByteString () m (T.Text, ByteString) pQuoted = P.try $ do   quote <- P.oneOf "\"'"-  url <- P.manyTill P.anyChar (P.char quote)-  let fallback = B.pack ([quote] ++ trim url ++ [quote])+  url <- T.pack <$> P.manyTill P.anyChar (P.char quote)+  let fallback = fromText $ T.singleton quote <> trim url <> T.singleton quote   return (url, fallback)  pUrl :: PandocMonad m-     => ParsecT ByteString () m (String, ByteString)+     => ParsecT ByteString () m (T.Text, ByteString) pUrl = P.try $ do   P.string "url("   P.spaces   quote <- P.option Nothing (Just <$> P.oneOf "\"'")-  url <- P.manyTill P.anyChar (maybe (P.lookAhead (P.char ')')) P.char quote)+  url <- T.pack <$> P.manyTill P.anyChar (maybe (P.lookAhead (P.char ')')) P.char quote)   P.spaces   P.char ')'-  let fallback = B.pack ("url(" ++ maybe "" (:[]) quote ++ trim url ++-                            maybe "" (:[]) quote ++ ")")+  let fallback = fromText ("url(" <> maybe "" T.singleton quote <> trim url <>+                            maybe "" T.singleton quote <> ")")   return (url, fallback)  handleCSSUrl :: PandocMonad m-             => FilePath -> (String, ByteString)+             => FilePath -> (T.Text, ByteString)              -> ParsecT ByteString () m                   (Either ByteString (MimeType, ByteString)) handleCSSUrl d (url, fallback) =-  case escapeURIString (/='|') (trim url) of+  case escapeURIString (/='|') (T.unpack $ trim url) of       '#':_ -> return $ Left fallback       'd':'a':'t':'a':':':_ -> return $ Left fallback-      u ->  do let url' = if isURI u then u else d </> u+      u ->  do let url' = if isURI (T.pack u) then T.pack u else T.pack (d </> u)                res <- lift $ getData "" url'                case res of-                    Left uri -> return $ Left (B.pack $ "url(" ++ uri ++ ")")-                    Right (mt, raw) -> do+                    Left uri -> return $ Left (fromText $ "url(" <> uri <> ")")+                    Right (mt', raw) -> do                       -- note that the downloaded CSS may                       -- itself contain url(...).-                      b <- if "text/css" `isPrefixOf` mt-                              then cssURLs d raw-                              else return raw+                      (mt, b) <- if "text/css" `T.isPrefixOf` mt'+                                    -- see #5725: in HTML5, content type+                                    -- isn't allowed on style type attribute+                                    then ("text/css",) <$> cssURLs d raw+                                    else return (mt', raw)                       return $ Right (mt, b) -getDataURI :: PandocMonad m => MimeType -> String -> m String+getDataURI :: PandocMonad m => MimeType -> T.Text -> m T.Text getDataURI mimetype src = do   res <- getData mimetype src   case res of@@ -226,35 +229,36 @@        Right x  -> return $ makeDataURI x  getData :: PandocMonad m-        => MimeType -> String-        -> m (Either String (MimeType, ByteString))-getData _ src@('d':'a':'t':'a':':':_) = return $ Left src-- already data: uri-getData mimetype src = do-  let ext = map toLower $ takeExtension src-  (raw, respMime) <- fetchItem src-  let raw' = if ext `elem` [".gz", ".svgz"]-                then B.concat $ L.toChunks $ Gzip.decompress $ L.fromChunks [raw]-                else raw-  mime <- case (mimetype, respMime) of-                  ("",Nothing) -> throwError $ PandocSomeError-                         $ "Could not determine mime type for `" ++ src ++ "'"-                  (x, Nothing) -> return x-                  (_, Just x ) -> return x-  result <- if "text/css" `isPrefixOf` mime-               then do-                 oldInputs <- getInputFiles-                 setInputFiles [src]-                 res <- cssURLs (takeDirectory src) raw'-                 setInputFiles oldInputs-                 return res+        => MimeType -> T.Text+        -> m (Either T.Text (MimeType, ByteString))+getData mimetype src+  | "data:" `T.isPrefixOf` src = return $ Left src -- already data: uri+  | otherwise = do+      let ext = T.toLower $ T.pack $ takeExtension $ T.unpack src+      (raw, respMime) <- fetchItem src+      let raw' = if ext `elem` [".gz", ".svgz"]+                 then B.concat $ L.toChunks $ Gzip.decompress $ L.fromChunks [raw]+                 else raw+      mime <- case (mimetype, respMime) of+                ("",Nothing) -> throwError $ PandocSomeError+                  $ "Could not determine mime type for `" <> src <> "'"+                (x, Nothing) -> return x+                (_, Just x ) -> return x+      result <- if "text/css" `T.isPrefixOf` mime+                then do+                  oldInputs <- getInputFiles+                  setInputFiles [T.unpack src]+                  res <- cssURLs (takeDirectory $ T.unpack src) raw'+                  setInputFiles oldInputs+                  return res                else return raw'-  return $ Right (mime, result)+      return $ Right (mime, result)    -- | Convert HTML into self-contained HTML, incorporating images, -- scripts, and CSS using data: URIs.-makeSelfContained :: PandocMonad m => String -> m String+makeSelfContained :: PandocMonad m => T.Text -> m T.Text makeSelfContained inp = do   let tags = parseTags inp   out' <- convertTags tags
src/Text/Pandoc/Shared.hs view
@@ -1,12 +1,14 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude     #-} {-# LANGUAGE CPP                   #-} {-# LANGUAGE DeriveDataTypeable    #-} {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables   #-} {-# LANGUAGE ViewPatterns          #-}-{-# LANGUAGE FlexibleInstances  #-}+{-# LANGUAGE FlexibleInstances     #-} {-# LANGUAGE TypeSynonymInstances  #-}+{-# LANGUAGE LambdaCase            #-}+{-# LANGUAGE OverloadedStrings     #-} {- |    Module      : Text.Pandoc.Shared    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -21,14 +23,20 @@ module Text.Pandoc.Shared (                      -- * List processing                      splitBy,+                     splitTextBy,                      splitByIndices,                      splitStringByIndices,+                     splitTextByIndices,                      substitute,                      ordNub,                      -- * Text processing                      ToString (..),+                     ToText (..),+                     tshow,                      backslashEscapes,                      escapeStringUsing,+                     elemText,+                     notElemText,                      stripTrailingNewlines,                      trim,                      triml,@@ -36,6 +44,7 @@                      trimMath,                      stripFirstAndLast,                      camelCaseToHyphenated,+                     camelCaseStrToHyphenated,                      toRomanNumeral,                      escapeURI,                      tabFilter,@@ -47,13 +56,13 @@                      extractSpaces,                      removeFormatting,                      deNote,+                     deLink,                      stringify,                      capitalize,                      compactify,                      compactifyDL,                      linesToPara,-                     Element (..),-                     hierarchicalize,+                     makeSections,                      uniqueIdent,                      inlineListToIdentifier,                      isHeaderBlock,@@ -67,6 +76,7 @@                      makeMeta,                      eastAsianLineBreakFilter,                      underlineSpan,+                     htmlSpanLikeElements,                      splitSentences,                      filterIpynbOutput,                      -- * TagSoup HTML handling@@ -88,6 +98,7 @@                      defaultBlocksSeparator,                      -- * Safe read                      safeRead,+                     safeStrRead,                      -- * User data directory                      defaultUserDataDirs,                      -- * Version@@ -104,11 +115,10 @@ import Data.Char (isAlpha, isLower, isSpace, isUpper, toLower, isAlphaNum,                   generalCategory, GeneralCategory(NonSpacingMark,                   SpacingCombiningMark, EnclosingMark, ConnectorPunctuation))-import Data.Data (Data, Typeable) import Data.List (find, intercalate, intersperse, stripPrefix, sortBy) import Data.Ord (comparing) import qualified Data.Map as M-import Data.Maybe (mapMaybe)+import Data.Maybe (mapMaybe, fromMaybe) import Data.Monoid (Any (..)) import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr) import qualified Data.Set as Set@@ -128,12 +138,12 @@ import Text.Pandoc.Definition import Text.Pandoc.Extensions (Extensions, Extension(..), extensionEnabled) import Text.Pandoc.Generic (bottomUp)-import Text.Pandoc.Pretty (charWidth)+import Text.DocLayout (charWidth) import Text.Pandoc.Walk  -- | Version number of pandoc library.-pandocVersion :: String-pandocVersion = showVersion version+pandocVersion :: T.Text+pandocVersion = T.pack $ showVersion version  -- -- List processing@@ -147,6 +157,13 @@       rest'         = dropWhile isSep rest   in  first:splitBy isSep rest' +splitTextBy :: (Char -> Bool) -> T.Text -> [T.Text]+splitTextBy isSep t+  | T.null t = []+  | otherwise = let (first, rest) = T.break isSep t+                    rest'         = T.dropWhile isSep rest+                in  first : splitTextBy isSep rest'+ splitByIndices :: [Int] -> [a] -> [[a]] splitByIndices [] lst = [lst] splitByIndices (x:xs) lst = first:splitByIndices (map (\y -> y - x)  xs) rest@@ -159,6 +176,9 @@   let (first, rest) = splitAt' x lst in   first : splitStringByIndices (map (\y -> y - x) xs) rest +splitTextByIndices :: [Int] -> T.Text -> [T.Text]+splitTextByIndices ns = fmap T.pack . splitStringByIndices ns . T.unpack+ splitAt' :: Int -> [Char] -> ([Char],[Char]) splitAt' _ []          = ([],[]) splitAt' n xs | n <= 0 = ([],xs)@@ -194,84 +214,116 @@ instance ToString T.Text where   toString = T.unpack +class ToText a where+  toText :: a -> T.Text++instance ToText String where+  toText = T.pack++instance ToText T.Text where+  toText = id++tshow :: Show a => a -> T.Text+tshow = T.pack . show+ -- | Returns an association list of backslash escapes for the -- designated characters. backslashEscapes :: [Char]    -- ^ list of special characters to escape-                 -> [(Char, String)]-backslashEscapes = map (\ch -> (ch, ['\\',ch]))+                 -> [(Char, T.Text)]+backslashEscapes = map (\ch -> (ch, T.pack ['\\',ch]))  -- | Escape a string of characters, using an association list of -- characters and strings.-escapeStringUsing :: [(Char, String)] -> String -> String-escapeStringUsing _ [] = ""-escapeStringUsing escapeTable (x:xs) =-  case lookup x escapeTable of-       Just str -> str ++ rest-       Nothing  -> x:rest-  where rest = escapeStringUsing escapeTable xs+escapeStringUsing :: [(Char, T.Text)] -> T.Text -> T.Text+escapeStringUsing tbl = T.concatMap $ \c -> fromMaybe (T.singleton c) $ lookup c tbl +-- | @True@ exactly when the @Char@ appears in the @Text@.+elemText :: Char -> T.Text -> Bool+elemText c = T.any (== c)++-- | @True@ exactly when the @Char@ does not appear in the @Text@.+notElemText :: Char -> T.Text -> Bool+notElemText c = T.all (/= c)+ -- | Strip trailing newlines from string.-stripTrailingNewlines :: String -> String-stripTrailingNewlines = reverse . dropWhile (== '\n') . reverse+stripTrailingNewlines :: T.Text -> T.Text+stripTrailingNewlines = T.dropWhileEnd (== '\n')  -- | Remove leading and trailing space (including newlines) from string.-trim :: String -> String-trim = triml . trimr+trim :: T.Text -> T.Text+trim = T.dropAround (`elemText` " \r\n\t")  -- | Remove leading space (including newlines) from string.-triml :: String -> String-triml = dropWhile (`elem` " \r\n\t")+triml :: T.Text -> T.Text+triml = T.dropWhile (`elemText` " \r\n\t")  -- | Remove trailing space (including newlines) from string.-trimr :: String -> String-trimr = reverse . triml . reverse+trimr :: T.Text -> T.Text+trimr = T.dropWhileEnd (`elemText` " \r\n\t")  -- | Trim leading space and trailing space unless after \.-trimMath :: String -> String-trimMath = triml . reverse . stripspace . reverse+trimMath :: T.Text -> T.Text+trimMath = triml . T.reverse . stripBeginSpace . T.reverse -- no Text.spanEnd   where-  stripspace (c1:c2:cs)-    | c1  `elem` [' ','\t','\n','\r']-    , c2 /= '\\' = stripspace (c2:cs)-  stripspace cs = cs+    stripBeginSpace t+      | T.null pref = t+      | Just ('\\', _) <- T.uncons suff = T.cons (T.last pref) suff+      | otherwise = suff+      where+        (pref, suff) = T.span (`elemText` " \t\n\r") t  -- | Strip leading and trailing characters from string-stripFirstAndLast :: String -> String-stripFirstAndLast str =-  drop 1 $ take (length str - 1) str+stripFirstAndLast :: T.Text -> T.Text+stripFirstAndLast t = case T.uncons t of+  Just (_, t') -> case T.unsnoc t' of+    Just (t'', _) -> t''+    _             -> t'+  _               -> ""  -- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).-camelCaseToHyphenated :: String -> String-camelCaseToHyphenated [] = ""-camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =-  a:'-':toLower b:camelCaseToHyphenated rest-camelCaseToHyphenated (a:rest) = toLower a:camelCaseToHyphenated rest+camelCaseToHyphenated :: T.Text -> T.Text+camelCaseToHyphenated = T.pack . camelCaseStrToHyphenated . T.unpack +-- This may not work as expected on general Unicode, if it contains+-- letters with a longer lower case form than upper case. I don't know+-- what the camel case practices of affected scripts are, though.+camelCaseStrToHyphenated :: String -> String+camelCaseStrToHyphenated [] = ""+camelCaseStrToHyphenated (a:b:rest)+  | isLower a+  , isUpper b = a:'-':toLower b:camelCaseStrToHyphenated rest+-- handle ABCDef = abc-def+camelCaseStrToHyphenated (a:b:c:rest)+  | isUpper a+  , isUpper b+  , isLower c = toLower a:'-':toLower b:camelCaseStrToHyphenated (c:rest)+camelCaseStrToHyphenated (a:rest) = toLower a:camelCaseStrToHyphenated rest+ -- | Convert number < 4000 to uppercase roman numeral.-toRomanNumeral :: Int -> String+toRomanNumeral :: Int -> T.Text toRomanNumeral x   | x >= 4000 || x < 0 = "?"-  | x >= 1000 = "M" ++ toRomanNumeral (x - 1000)-  | x >= 900  = "CM" ++ toRomanNumeral (x - 900)-  | x >= 500  = "D" ++ toRomanNumeral (x - 500)-  | x >= 400  = "CD" ++ toRomanNumeral (x - 400)-  | x >= 100  = "C" ++ toRomanNumeral (x - 100)-  | x >= 90   = "XC" ++ toRomanNumeral (x - 90)-  | x >= 50   = "L"  ++ toRomanNumeral (x - 50)-  | x >= 40   = "XL" ++ toRomanNumeral (x - 40)-  | x >= 10   = "X" ++ toRomanNumeral (x - 10)+  | x >= 1000 = "M" <> toRomanNumeral (x - 1000)+  | x >= 900  = "CM" <> toRomanNumeral (x - 900)+  | x >= 500  = "D" <> toRomanNumeral (x - 500)+  | x >= 400  = "CD" <> toRomanNumeral (x - 400)+  | x >= 100  = "C" <> toRomanNumeral (x - 100)+  | x >= 90   = "XC" <> toRomanNumeral (x - 90)+  | x >= 50   = "L"  <> toRomanNumeral (x - 50)+  | x >= 40   = "XL" <> toRomanNumeral (x - 40)+  | x >= 10   = "X" <> toRomanNumeral (x - 10)   | x == 9    = "IX"-  | x >= 5    = "V" ++ toRomanNumeral (x - 5)+  | x >= 5    = "V" <> toRomanNumeral (x - 5)   | x == 4    = "IV"-  | x >= 1    = "I" ++ toRomanNumeral (x - 1)+  | x >= 1    = "I" <> toRomanNumeral (x - 1)   | otherwise = ""  -- | Escape whitespace and some punctuation characters in URI.-escapeURI :: String -> String-escapeURI = escapeURIString (not . needsEscaping)-  where needsEscaping c = isSpace c || c `elem`-                           ['<','>','|','"','{','}','[',']','^', '`']+escapeURI :: T.Text -> T.Text+escapeURI = T.pack . escapeURIString (not . needsEscaping) . T.unpack+  where needsEscaping c = isSpace c || c `elemText` "<>|\"{}[]^`" + -- | Convert tabs to spaces. Tabs will be preserved if tab stop is set to 0. tabFilter :: Int       -- ^ Tab stop           -> T.Text    -- ^ Input@@ -297,8 +349,11 @@ -- | Parse a date and convert (if possible) to "YYYY-MM-DD" format. We -- limit years to the range 1601-9999 (ISO 8601 accepts greater than -- or equal to 1583, but MS Word only accepts dates starting 1601).-normalizeDate :: String -> Maybe String-normalizeDate s = fmap (formatTime defaultTimeLocale "%F")+normalizeDate :: T.Text -> Maybe T.Text+normalizeDate = fmap T.pack . normalizeDate' . T.unpack++normalizeDate' :: String -> Maybe String+normalizeDate' s = fmap (formatTime defaultTimeLocale "%F")   (msum $ map (\fs -> parsetimeWith fs s >>= rejectBadYear) formats :: Maybe Day)   where rejectBadYear day = case toGregorian day of           (y, _, _) | y >= 1601 && y <= 9999 -> Just day@@ -314,26 +369,26 @@  -- | Generate infinite lazy list of markers for an ordered list, -- depending on list attributes.-orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]+orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [T.Text] orderedListMarkers (start, numstyle, numdelim) =-  let singleton c = [c]-      nums = case numstyle of-                     DefaultStyle -> map show [start..]-                     Example      -> map show [start..]-                     Decimal      -> map show [start..]+  let nums = case numstyle of+                     DefaultStyle -> map tshow [start..]+                     Example      -> map tshow [start..]+                     Decimal      -> map tshow [start..]                      UpperAlpha   -> drop (start - 1) $ cycle $-                                     map singleton ['A'..'Z']+                                     map T.singleton ['A'..'Z']                      LowerAlpha   -> drop (start - 1) $ cycle $-                                     map singleton ['a'..'z']+                                     map T.singleton ['a'..'z']                      UpperRoman   -> map toRomanNumeral [start..]-                     LowerRoman   -> map (map toLower . toRomanNumeral) [start..]+                     LowerRoman   -> map (T.toLower . toRomanNumeral) [start..]       inDelim str = case numdelim of-                            DefaultDelim -> str ++ "."-                            Period       -> str ++ "."-                            OneParen     -> str ++ ")"-                            TwoParens    -> "(" ++ str ++ ")"+                            DefaultDelim -> str <> "."+                            Period       -> str <> "."+                            OneParen     -> str <> ")"+                            TwoParens    -> "(" <> str <> ")"   in  map inDelim nums + -- | Extract the leading and trailing spaces from inside an inline element -- and place them outside the element.  SoftBreaks count as Spaces for -- these purposes.@@ -366,6 +421,10 @@ deNote (Note _) = Str "" deNote x        = x +deLink :: Inline -> Inline+deLink (Link _ ils _) = Span nullAttr ils+deLink x              = x+ deQuote :: Inline -> Inline deQuote (Quoted SingleQuote xs) =   Span ("",[],[]) (Str "\8216" : xs ++ [Str "\8217"])@@ -376,15 +435,16 @@ -- | Convert pandoc structure to a string with formatting removed. -- Footnotes are skipped (since we don't want their contents in link -- labels).-stringify :: Walkable Inline a => a -> String+stringify :: Walkable Inline a => a -> T.Text stringify = query go . walk (deNote . deQuote)-  where go :: Inline -> [Char]+  where go :: Inline -> T.Text         go Space                                       = " "         go SoftBreak                                   = " "         go (Str x)                                     = x         go (Code _ x)                                  = x         go (Math _ x)                                  = x-        go (RawInline (Format "html") ('<':'b':'r':_)) = " " -- see #2105+        go (RawInline (Format "html") (T.unpack -> ('<':'b':'r':_)))+                                                       = " " -- see #2105         go LineBreak                                   = " "         go _                                           = "" @@ -396,7 +456,7 @@ capitalize :: Walkable Inline a => a -> a capitalize = walk go   where go :: Inline -> Inline-        go (Str s) = Str (T.unpack $ T.toUpper $ T.pack s)+        go (Str s) = Str $ T.toUpper s         go x       = x  -- | Change final list item from @Para@ to @Plain@ if the list contains@@ -449,96 +509,111 @@ isPara (Para _) = True isPara _        = False --- | Data structure for defining hierarchical Pandoc documents-data Element = Blk Block-             | Sec Int [Int] Attr [Inline] [Element]-             --    lvl  num attributes label    contents-             deriving (Eq, Read, Show, Typeable, Data)--instance Walkable Inline Element where-  walk f (Blk x) = Blk (walk f x)-  walk f (Sec lev nums attr ils elts) = Sec lev nums attr (walk f ils) (walk f elts)-  walkM f (Blk x) = Blk `fmap` walkM f x-  walkM f (Sec lev nums attr ils elts) = do-    ils' <- walkM f ils-    elts' <- walkM f elts-    return $ Sec lev nums attr ils' elts'-  query f (Blk x)              = query f x-  query f (Sec _ _ _ ils elts) = query f ils `mappend` query f elts--instance Walkable Block Element where-  walk f (Blk x) = Blk (walk f x)-  walk f (Sec lev nums attr ils elts) = Sec lev nums attr (walk f ils) (walk f elts)-  walkM f (Blk x) = Blk `fmap` walkM f x-  walkM f (Sec lev nums attr ils elts) = do-    ils' <- walkM f ils-    elts' <- walkM f elts-    return $ Sec lev nums attr ils' elts'-  query f (Blk x)              = query f x-  query f (Sec _ _ _ ils elts) = query f ils `mappend` query f elts- -- | Convert Pandoc inline list to plain text identifier.  HTML -- identifiers must start with a letter, and may contain only -- letters, digits, and the characters _-.-inlineListToIdentifier :: Extensions -> [Inline] -> String+inlineListToIdentifier :: Extensions -> [Inline] -> T.Text inlineListToIdentifier exts =-  dropNonLetter . filterAscii . toIdent . stringify+  dropNonLetter . filterAscii . toIdent . stringify . walk unEmojify   where+    unEmojify :: [Inline] -> [Inline]+    unEmojify+      | extensionEnabled Ext_gfm_auto_identifiers exts ||+        extensionEnabled Ext_ascii_identifiers exts = walk unEmoji+      | otherwise = id+    unEmoji (Span ("",["emoji"],[("data-emoji",ename)]) _) = Str ename+    unEmoji x = x     dropNonLetter       | extensionEnabled Ext_gfm_auto_identifiers exts = id-      | otherwise = dropWhile (not . isAlpha)+      | otherwise = T.dropWhile (not . isAlpha)     filterAscii       | extensionEnabled Ext_ascii_identifiers exts-        = mapMaybe toAsciiChar+        = T.pack . mapMaybe toAsciiChar . T.unpack       | otherwise = id     toIdent       | extensionEnabled Ext_gfm_auto_identifiers exts =-        filterPunct . spaceToDash . map toLower-      | otherwise = intercalate "-" . words . filterPunct . map toLower-    filterPunct = filter (\c -> isSpace c || isAlphaNum c || isAllowedPunct c)+        filterPunct . spaceToDash . T.toLower+      | otherwise = T.intercalate "-" . T.words . filterPunct . T.toLower+    filterPunct = T.filter (\c -> isSpace c || isAlphaNum c || isAllowedPunct c)     isAllowedPunct c       | extensionEnabled Ext_gfm_auto_identifiers exts         = c == '-' || c == '_' ||           generalCategory c `elem` [NonSpacingMark, SpacingCombiningMark,                                     EnclosingMark, ConnectorPunctuation]       | otherwise = c == '_' || c == '-' || c == '.'-    spaceToDash = map (\c -> if isSpace c then '-' else c)+    spaceToDash = T.map (\c -> if isSpace c then '-' else c) --- | Convert list of Pandoc blocks into (hierarchical) list of Elements-hierarchicalize :: [Block] -> [Element]-hierarchicalize blocks = S.evalState (hierarchicalizeWithIds blocks) [] -hierarchicalizeWithIds :: [Block] -> S.State [Int] [Element]-hierarchicalizeWithIds [] = return []-hierarchicalizeWithIds (Header level attr@(_,classes,_) title':xs) = do-  lastnum <- S.get-  let lastnum' = take level lastnum-  let newnum = case length lastnum' of-                    x | "unnumbered" `elem` classes -> []-                      | x >= level -> init lastnum' ++ [last lastnum' + 1]-                      | otherwise -> lastnum ++-                           replicate (level - length lastnum - 1) 0 ++ [1]-  unless (null newnum) $ S.put newnum-  let (sectionContents, rest) = break (headerLtEq level) xs-  sectionContents' <- hierarchicalizeWithIds sectionContents-  rest' <- hierarchicalizeWithIds rest-  return $ Sec level newnum attr title' sectionContents' : rest'-hierarchicalizeWithIds (Div ("refs",classes',kvs')-                         (Header level (ident,classes,kvs) title' : xs):ys) =-  hierarchicalizeWithIds (Header level (ident,"references":classes,kvs)-                           title' : Div ("refs",classes',kvs') xs : ys)-hierarchicalizeWithIds (x:rest) = do-  rest' <- hierarchicalizeWithIds rest-  return $ Blk x : rest'+-- | Put a list of Pandoc blocks into a hierarchical structure:+-- a list of sections (each a Div with class "section" and first+-- element a Header).  If the 'numbering' parameter is True, Header+-- numbers are added via the number attribute on the header.+-- If the baseLevel parameter is Just n, Header levels are+-- adjusted to be gapless starting at level n.+makeSections :: Bool -> Maybe Int -> [Block] -> [Block]+makeSections numbering mbBaseLevel bs =+  S.evalState (go bs) (mbBaseLevel, [])+ where+  go :: [Block] -> S.State (Maybe Int, [Int]) [Block]+  go (Header level (ident,classes,kvs) title':xs) = do+    (mbLevel, lastnum) <- S.get+    let level' = fromMaybe level mbLevel+    let lastnum' = take level' lastnum+    let newnum =+          if level' > 0+             then case length lastnum' of+                      x | "unnumbered" `elem` classes -> []+                        | x >= level' -> init lastnum' ++ [last lastnum' + 1]+                        | otherwise -> lastnum +++                             replicate (level' - length lastnum - 1) 0 ++ [1]+             else []+    unless (null newnum) $ S.modify $ \(mbl, _) -> (mbl, newnum)+    let (sectionContents, rest) = break (headerLtEq level) xs+    S.modify $ \(_, ln) -> (fmap (+ 1) mbLevel, ln)+    sectionContents' <- go sectionContents+    S.modify $ \(_, ln) -> (mbLevel, ln)+    rest' <- go rest+    let divattr = (ident, ["section"], [])+    let attr = ("",classes,+                   -- don't touch number if already present+                   case lookup "number" kvs of+                     Nothing | numbering ->+                        ("number", T.intercalate "." (map tshow newnum)) : kvs+                     _ -> kvs)+    return $+      Div divattr (Header level' attr title' : sectionContents') : rest'+  go (Div (dident,dclasses,dkvs)+       (Header level (ident,classes,kvs) title':ys) : xs)+      | all (\case+               Header level' _ _ -> level' > level+               _                 -> True) ys = do+    inner <- go (Header level (ident,classes,kvs) title':ys)+    let inner' =+          case inner of+            (Div (dident',dclasses',dkvs') zs@(Header{}:zs') : ws)+              | T.null dident ->+                Div (dident',dclasses' ++ dclasses,dkvs' ++ dkvs) zs : ws+              | otherwise -> -- keep id on header so we don't lose anchor+                Div (dident,dclasses ++ dclasses',dkvs ++ dkvs')+                  (Header level (dident',classes,kvs) title':zs') : ws+            _ -> inner  -- shouldn't happen+    rest <- go xs+    return $ inner' ++ rest+  go (Div attr xs : rest) = do+    xs' <- go xs+    rest' <- go rest+    return $ Div attr xs' : rest'+  go (x:xs) = (x :) <$> go xs+  go [] = return []  headerLtEq :: Int -> Block -> Bool-headerLtEq level (Header l _ _)                                  = l <= level-headerLtEq level (Div ("",["references"],[]) (Header l _ _ : _)) = l <= level-headerLtEq _ _                                                   = False+headerLtEq level (Header l _ _)  = l <= level+headerLtEq level (Div _ (b:_))   = headerLtEq level b+headerLtEq _ _                   = False  -- | Generate a unique identifier from a list of inlines. -- Second argument is a list of already used identifiers.-uniqueIdent :: Extensions -> [Inline] -> Set.Set String -> String+uniqueIdent :: Extensions -> [Inline] -> Set.Set T.Text -> T.Text uniqueIdent exts title' usedIdents =   if baseIdent `Set.member` usedIdents      then case find (\x -> not $ numIdent x `Set.member` usedIdents)@@ -551,7 +626,7 @@     baseIdent = case inlineListToIdentifier exts title' of                      "" -> "section"                      x  -> x-    numIdent n = baseIdent ++ "-" ++ show n+    numIdent n = baseIdent <> "-" <> tshow n  -- | True if block is a Header block. isHeaderBlock :: Block -> Bool@@ -560,10 +635,23 @@  -- | Shift header levels up or down. headerShift :: Int -> Pandoc -> Pandoc-headerShift n = walk shift-  where shift :: Block -> Block-        shift (Header level attr inner) = Header (level + n) attr inner-        shift x                         = x+headerShift n (Pandoc meta (Header m _ ils : bs))+  | n < 0+  , m + n == 0 = headerShift n $+                 B.setTitle (B.fromList ils) $ Pandoc meta bs+headerShift n (Pandoc meta bs)+  | n > 0+  , not (null (docTitle meta))+    = Pandoc meta' (Header n nullAttr (docTitle meta) : bs')+ where+   Pandoc meta' bs' = headerShift n $ B.deleteMeta "title" $ Pandoc meta bs+headerShift n (Pandoc meta bs) = Pandoc meta (walk shift bs)+ where+   shift :: Block -> Block+   shift (Header level attr inner)+     | level + n > 0  = Header (level + n) attr inner+     | otherwise      = Para inner+   shift x            = x  -- | Remove empty paragraphs. stripEmptyParagraphs :: Pandoc -> Pandoc@@ -588,7 +676,7 @@  -- | Detect if a list is tight. isTightList :: [[Block]] -> Bool-isTightList = all firstIsPlain+isTightList = all (\item -> firstIsPlain item || null item)   where firstIsPlain (Plain _ : _) = True         firstIsPlain _             = False @@ -625,7 +713,7 @@ -- | Set a field of a 'Meta' object.  If the field already has a value, -- convert it into a list with the new value appended to the old value(s). addMetaField :: ToMetaValue a-             => String+             => T.Text              -> a              -> Meta              -> Meta@@ -647,12 +735,16 @@ -- | Remove soft breaks between East Asian characters. eastAsianLineBreakFilter :: Pandoc -> Pandoc eastAsianLineBreakFilter = bottomUp go-  where go (x:SoftBreak:y:zs) =-         case (stringify x, stringify y) of-               (xs@(_:_), c:_)-                 | charWidth (last xs) == 2 && charWidth c == 2 -> x:y:zs-               _ -> x:SoftBreak:y:zs-        go xs = xs+  where go (x:SoftBreak:y:zs)+          | Just (_, b) <- T.unsnoc $ stringify x+          , Just (c, _) <- T.uncons $ stringify y+          , charWidth b == 2+          , charWidth c == 2+          = x:y:zs+          | otherwise+          = x:SoftBreak:y:zs+        go xs+          = xs  -- | Builder for underline. -- This probably belongs in Builder.hs in pandoc-types.@@ -660,25 +752,31 @@ underlineSpan :: Inlines -> Inlines underlineSpan = B.spanWith ("", ["underline"], []) +-- | Set of HTML elements that are represented as Span with a class equal as+-- the element tag itself.+htmlSpanLikeElements :: Set.Set T.Text+htmlSpanLikeElements = Set.fromList ["kbd", "mark", "dfn"]+ -- | Returns the first sentence in a list of inlines, and the rest. breakSentence :: [Inline] -> ([Inline], [Inline]) breakSentence [] = ([],[]) breakSentence xs =-  let isSentenceEndInline (Str ys@(_:_)) | last ys == '.' = True-      isSentenceEndInline (Str ys@(_:_)) | last ys == '?' = True-      isSentenceEndInline LineBreak      = True-      isSentenceEndInline _              = False+  let isSentenceEndInline (Str ys)+        | Just (_, c) <- T.unsnoc ys = c == '.' || c == '?'+      isSentenceEndInline LineBreak  = True+      isSentenceEndInline _          = False       (as, bs) = break isSentenceEndInline xs   in  case bs of-           []             -> (as, [])-           [c]            -> (as ++ [c], [])-           (c:Space:cs)   -> (as ++ [c], cs)-           (c:SoftBreak:cs) -> (as ++ [c], cs)-           (Str ".":Str (')':ys):cs) -> (as ++ [Str ".", Str (')':ys)], cs)-           (x@(Str ('.':')':_)):cs) -> (as ++ [x], cs)-           (LineBreak:x@(Str ('.':_)):cs) -> (as ++[LineBreak], x:cs)-           (c:cs)         -> (as ++ [c] ++ ds, es)-              where (ds, es) = breakSentence cs+        []             -> (as, [])+        [c]            -> (as ++ [c], [])+        (c:Space:cs)   -> (as ++ [c], cs)+        (c:SoftBreak:cs) -> (as ++ [c], cs)+        (Str ".":Str s@(T.uncons -> Just (')',_)):cs)+          -> (as ++ [Str ".", Str s], cs)+        (x@(Str (T.stripPrefix ".)" -> Just _)):cs) -> (as ++ [x], cs)+        (LineBreak:x@(Str (T.uncons -> Just ('.',_))):cs) -> (as ++[LineBreak], x:cs)+        (c:cs)         -> (as ++ [c] ++ ds, es)+          where (ds, es) = breakSentence cs  -- | Split a list of inlines into sentences. splitSentences :: [Inline] -> [[Inline]]@@ -688,7 +786,8 @@  -- | Process ipynb output cells.  If mode is Nothing, -- remove all output.  If mode is Just format, select--- best output for the format.+-- best output for the format.  If format is not ipynb,+-- strip out ANSI escape sequences from CodeBlocks (see #5633). filterIpynbOutput :: Maybe Format -> Pandoc -> Pandoc filterIpynbOutput mode = walk go   where go (Div (ident, ("output":os), kvs) bs) =@@ -699,6 +798,7 @@               | fmt == Format "ipynb"                           -> Div (ident, ("output":os), kvs) bs               | otherwise -> Div (ident, ("output":os), kvs) $+                              walk removeANSI $                               take 1 $ sortBy (comparing rank) bs                  where                   rank (RawBlock (Format "html") _)@@ -714,6 +814,14 @@                     | otherwise = 3                   rank (Para [Image{}]) = 1                   rank _ = 2+                  removeANSI (CodeBlock attr code) =+                    CodeBlock attr (removeANSIEscapes code)+                  removeANSI x = x+                  removeANSIEscapes t+                    | Just cs <- T.stripPrefix "\x1b[" t =+                        removeANSIEscapes $ T.drop 1 $ T.dropWhile (/='m') cs+                    | Just (c, cs) <- T.uncons t = T.cons c $ removeANSIEscapes cs+                    | otherwise = ""         go x = x  --@@ -721,12 +829,12 @@ --  -- | Render HTML tags.-renderTags' :: [Tag String] -> String+renderTags' :: [Tag T.Text] -> T.Text renderTags' = renderTagsOptions                renderOptions{ optMinimize = matchTags ["hr", "br", "img",                                                        "meta", "link"]                             , optRawTag   = matchTags ["script", "style"] }-              where matchTags tags = flip elem tags . map toLower+              where matchTags tags = flip elem tags . T.toLower  -- -- File handling@@ -773,8 +881,8 @@ -- Convert the path part of a file: URI to a regular path. -- On windows, @/c:/foo@ should be @c:/foo@. -- On linux, @/foo@ should be @/foo@.-uriPathToPath :: String -> FilePath-uriPathToPath path =+uriPathToPath :: T.Text -> FilePath+uriPathToPath (T.unpack -> path) = #ifdef _WINDOWS   case path of     '/':ps -> ps@@ -800,7 +908,7 @@  -- | Schemes from http://www.iana.org/assignments/uri-schemes.html plus -- the unofficial schemes doi, javascript, isbn, pmid.-schemes :: Set.Set String+schemes :: Set.Set T.Text schemes = Set.fromList   -- Official IANA schemes   [ "aaa", "aaas", "about", "acap", "acct", "acr", "adiumxtra", "afp", "afs"@@ -852,11 +960,11 @@  -- | Check if the string is a valid URL with a IANA or frequently used but -- unofficial scheme (see @schemes@).-isURI :: String -> Bool-isURI = maybe False hasKnownScheme . parseURI+isURI :: T.Text -> Bool+isURI = maybe False hasKnownScheme . parseURI . T.unpack   where-    hasKnownScheme = (`Set.member` schemes) . map toLower .-                     filter (/= ':') . uriScheme+    hasKnownScheme = (`Set.member` schemes) . T.toLower .+                     T.filter (/= ':') . T.pack . uriScheme  --- --- Squash blocks into inlines@@ -909,12 +1017,14 @@ -- Safe read -- -safeRead :: (MonadPlus m, Read a) => String -> m a-safeRead s = case reads s of+safeRead :: (MonadPlus m, Read a) => T.Text -> m a+safeRead = safeStrRead . T.unpack++safeStrRead :: (MonadPlus m, Read a) => String -> m a+safeStrRead s = case reads s of                   (d,x):_                     | all isSpace x -> return d                   _                 -> mzero- -- -- User data directory --
src/Text/Pandoc/Slides.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Slides    Copyright   : Copyright (C) 2012-2019 John MacFarlane@@ -22,13 +23,14 @@   where go least (Header n _ _ : x : xs)                  | n < least && nonHOrHR x = go n xs                  | otherwise               = go least (x:xs)+        go least (Div _ bs : xs) = min (go least bs) (go least xs)         go least (_ : xs) = go least xs         go least [] = least         nonHOrHR Header{}       = False         nonHOrHR HorizontalRule = False         nonHOrHR _              = True --- | Prepare a block list to be passed to hierarchicalize.+-- | Prepare a block list to be passed to makeSections. prepSlides :: Int -> [Block] -> [Block] prepSlides slideLevel = ensureStartWithH . splitHrule . extractRefsHeader   where splitHrule (HorizontalRule : Header n attr xs : ys)@@ -44,5 +46,7 @@                                    Div ("refs",classes,kvs) ys]                _ -> bs         ensureStartWithH bs@(Header n _ _:_)+                       | n <= slideLevel = bs+        ensureStartWithH bs@(Div _ (Header n _ _:_) : _)                        | n <= slideLevel = bs         ensureStartWithH bs              = Header slideLevel nullAttr [Str "\0"] : bs
src/Text/Pandoc/Templates.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Templates@@ -8,32 +10,29 @@    Stability   : alpha    Portability : portable -A simple templating system with variable substitution and conditionals.-+Utility functions for working with pandoc templates. -} -module Text.Pandoc.Templates ( module Text.DocTemplates-                             , renderTemplate'+module Text.Pandoc.Templates ( Template+                             , compileTemplate+                             , renderTemplate                              , getDefaultTemplate                              ) where  import Prelude-import Control.Monad.Except (throwError)-import Data.Aeson (ToJSON (..))-import qualified Data.Text as T import System.FilePath ((<.>), (</>))-import Text.DocTemplates (Template, TemplateTarget, applyTemplate,-                          compileTemplate, renderTemplate, varListToJSON)+import Text.DocTemplates (Template, compileTemplate, renderTemplate) import Text.Pandoc.Class (PandocMonad, readDataFile)-import Text.Pandoc.Error import qualified Text.Pandoc.UTF8 as UTF8+import Data.Text (Text)+import qualified Data.Text as T  -- | Get default template for the specified writer. getDefaultTemplate :: PandocMonad m-                   => String           -- ^ Name of writer-                   -> m String+                   => Text           -- ^ Name of writer+                   -> m Text getDefaultTemplate writer = do-  let format = takeWhile (`notElem` ("+-" :: String)) writer  -- strip off extensions+  let format = T.takeWhile (`notElem` ("+-" :: String)) writer  -- strip off extensions   case format of        "native"  -> return ""        "json"    -> return ""@@ -52,14 +51,8 @@        "markdown_mmd"      -> getDefaultTemplate "markdown"        "markdown_phpextra" -> getDefaultTemplate "markdown"        "gfm"               -> getDefaultTemplate "commonmark"-       _        -> let fname = "templates" </> "default" <.> format-                   in  UTF8.toString <$> readDataFile fname+       _        -> do+         let fname = "templates" </> "default" <.> T.unpack format+         UTF8.toText <$> readDataFile fname --- | Like 'applyTemplate', but runs in PandocMonad and--- raises an error if compilation fails.-renderTemplate' :: (PandocMonad m, ToJSON a, TemplateTarget b)-                => String -> a -> m b-renderTemplate' template context =-  case applyTemplate (T.pack template) context of-       Left e  -> throwError (PandocTemplateError e)-       Right r -> return r+
src/Text/Pandoc/Translations.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude          #-} {-# LANGUAGE CPP                        #-} {-# LANGUAGE DeriveGeneric              #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings          #-} {- |    Module      : Text.Pandoc.Translations    Copyright   : Copyright (C) 2017-2019 John MacFarlane@@ -34,7 +35,7 @@ import qualified Data.Aeson.Types as Aeson import qualified Data.HashMap.Strict as HM import qualified Data.Map as M-import Data.Text as T+import qualified Data.Text as T import qualified Data.YAML as YAML import GHC.Generics (Generic) import Text.Pandoc.Shared (safeRead)@@ -65,21 +66,21 @@   | To   deriving (Show, Eq, Ord, Generic, Enum, Read) -newtype Translations = Translations (M.Map Term String)+newtype Translations = Translations (M.Map Term T.Text)         deriving (Show, Generic, Semigroup, Monoid)  instance FromJSON Term where-  parseJSON (String t) = case safeRead (T.unpack t) of+  parseJSON (String t) = case safeRead t of                                Just t' -> pure t'-                               Nothing -> fail $ "Invalid Term name " +++                               Nothing -> Prelude.fail $ "Invalid Term name " ++                                                  show t   parseJSON invalid = Aeson.typeMismatch "Term" invalid  instance YAML.FromYAML Term where-  parseYAML (YAML.Scalar (YAML.SStr t)) =-                         case safeRead (T.unpack t) of+  parseYAML (YAML.Scalar _ (YAML.SStr t)) =+                         case safeRead t of                                Just t' -> pure t'-                               Nothing -> fail $ "Invalid Term name " +++                               Nothing -> Prelude.fail $ "Invalid Term name " ++                                                  show t   parseYAML invalid = YAML.typeMismatch "Term" invalid @@ -88,33 +89,35 @@     xs <- mapM addItem (HM.toList hm)     return $ Translations (M.fromList xs)     where addItem (k,v) =-            case safeRead (T.unpack k) of-                 Nothing -> fail $ "Invalid Term name " ++ show k+            case safeRead k of+                 Nothing -> Prelude.fail $ "Invalid Term name " ++ show k                  Just t  ->                    case v of-                        (String s) -> return (t, T.unpack $ T.strip s)+                        (String s) -> return (t, T.strip s)                         inv        -> Aeson.typeMismatch "String" inv   parseJSON invalid = Aeson.typeMismatch "Translations" invalid  instance YAML.FromYAML Translations where   parseYAML = YAML.withMap "Translations" $     \tr -> Translations .M.fromList <$> mapM addItem (M.toList tr)-   where addItem (n@(YAML.Scalar (YAML.SStr k)), v) =-            case safeRead (T.unpack k) of+   where addItem (n@(YAML.Scalar _ (YAML.SStr k)), v) =+            case safeRead k of                  Nothing -> YAML.typeMismatch "Term" n                  Just t  ->                    case v of-                        (YAML.Scalar (YAML.SStr s)) ->-                          return (t, T.unpack (T.strip s))+                        (YAML.Scalar _ (YAML.SStr s)) ->+                          return (t, T.strip s)                         n' -> YAML.typeMismatch "String" n'          addItem (n, _) = YAML.typeMismatch "String" n -lookupTerm :: Term -> Translations -> Maybe String+lookupTerm :: Term -> Translations -> Maybe T.Text lookupTerm t (Translations tm) = M.lookup t tm -readTranslations :: String -> Either String Translations+readTranslations :: T.Text -> Either T.Text Translations readTranslations s =-  case YAML.decodeStrict $ UTF8.fromString s of-       Left err'   -> Left err'-       Right (t:_) -> Right t-       Right []    -> Left "empty YAML document"+  case YAML.decodeStrict $ UTF8.fromText s of+       Left (pos,err') -> Left $ T.pack $ err' +++           " (line " ++ show (YAML.posLine pos) ++ " column " +++           show (YAML.posColumn pos) ++ ")"+       Right (t:_)     -> Right t+       Right []        -> Left "empty YAML document"
src/Text/Pandoc/Writers.hs view
@@ -1,7 +1,8 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE FlexibleInstances   #-} {-# LANGUAGE GADTs               #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings   #-} {- |    Module      : Text.Pandoc    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -70,14 +71,17 @@     ) where  import Prelude+import Control.Monad.Except (throwError)+import Control.Monad (unless) import Data.Aeson import qualified Data.ByteString.Lazy as BL-import Data.List (intercalate) import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class import Text.Pandoc.Definition import Text.Pandoc.Options import qualified Text.Pandoc.UTF8 as UTF8+import Text.Pandoc.Error import Text.Pandoc.Writers.AsciiDoc import Text.Pandoc.Writers.CommonMark import Text.Pandoc.Writers.ConTeXt@@ -118,7 +122,7 @@               | ByteStringWriter (WriterOptions -> Pandoc -> m BL.ByteString)  -- | Association list of formats and writers.-writers :: PandocMonad m => [ ( String, Writer m) ]+writers :: PandocMonad m => [ (Text, Writer m) ] writers = [    ("native"       , TextWriter writeNative)   ,("json"         , TextWriter $ \o d -> writeJSON o d)@@ -176,15 +180,29 @@   ]  -- | Retrieve writer, extensions based on formatSpec (format+extensions).-getWriter :: PandocMonad m => String -> Either String (Writer m, Extensions)-getWriter s-  = case parseFormatSpec s of-         Left e  -> Left $ intercalate "\n" [m | Message m <- errorMessages e]-         Right (writerName, setExts) ->-             case lookup writerName writers of-                     Nothing -> Left $ "Unknown writer: " ++ writerName-                     Just r -> Right (r, setExts $-                                  getDefaultExtensions writerName)+getWriter :: PandocMonad m => Text -> m (Writer m, Extensions)+getWriter s =+  case parseFormatSpec s of+        Left e  -> throwError $ PandocAppError+                    $ T.intercalate "\n" [T.pack m | Message m <- errorMessages e]+        Right (writerName, extsToEnable, extsToDisable) ->+           case lookup writerName writers of+                   Nothing  -> throwError $+                                 PandocUnknownWriterError writerName+                   Just  w  -> do+                     let allExts = getAllExtensions writerName+                     let exts = foldr disableExtension+                           (foldr enableExtension+                             (getDefaultExtensions writerName)+                                   extsToEnable) extsToDisable+                     mapM_ (\ext ->+                              unless (extensionEnabled ext allExts) $+                                throwError $+                                   PandocUnsupportedExtensionError+                                   (T.drop 4 $ T.pack $ show ext) writerName)+                          (extsToEnable ++ extsToDisable)+                     return (w, exts)+  writeJSON :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeJSON _ = return . UTF8.toText . BL.toStrict . encode
src/Text/Pandoc/Writers/AsciiDoc.hs view
@@ -22,10 +22,11 @@ module Text.Pandoc.Writers.AsciiDoc (writeAsciiDoc, writeAsciiDoctor) where import Prelude import Control.Monad.State.Strict-import Data.Char (isPunctuation, isSpace, toLower)-import Data.List (intercalate, intersperse, stripPrefix)-import Data.Maybe (fromMaybe, isJust, listToMaybe)+import Data.Char (isPunctuation, isSpace)+import Data.List (intercalate, intersperse)+import Data.Maybe (fromMaybe, isJust) import qualified Data.Set as Set+import qualified Data.Text as T import Data.Text (Text) import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition@@ -33,16 +34,16 @@ import Text.Pandoc.Logging import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (blankline, space)-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared -data WriterState = WriterState { defListMarker       :: String+data WriterState = WriterState { defListMarker       :: Text                                , orderedListLevel    :: Int                                , bulletListLevel     :: Int                                , intraword           :: Bool-                               , autoIds             :: Set.Set String+                               , autoIds             :: Set.Set Text                                , asciidoctorVariant  :: Bool                                , inList              :: Bool                                , hasMath             :: Bool@@ -79,14 +80,11 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  metadata <- metaToJSON opts-              (fmap render' . blockListToAsciiDoc opts)-              (fmap render' . inlineListToAsciiDoc opts)+  metadata <- metaToContext opts+              (blockListToAsciiDoc opts)+              (fmap chomp . inlineListToAsciiDoc opts)               meta-  body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)-  let main = render colwidth body+  main <- blockListToAsciiDoc opts $ makeSections False (Just 1) blocks   st <- get   let context  = defField "body" main                $ defField "toc"@@ -94,25 +92,18 @@                    isJust (writerTemplate opts))                $ defField "math" (hasMath st)                $ defField "titleblock" titleblock metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context--elementToAsciiDoc :: PandocMonad m-                  => Int -> WriterOptions -> Element -> ADW m Doc-elementToAsciiDoc _ opts (Blk b) = blockToAsciiDoc opts b-elementToAsciiDoc nestlevel opts (Sec _lvl _num attr label children) = do-  hdr <- blockToAsciiDoc opts (Header nestlevel attr label)-  rest <- vcat <$> mapM (elementToAsciiDoc (nestlevel + 1) opts) children-  return $ hdr $$ rest+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Escape special characters for AsciiDoc.-escapeString :: String -> String+escapeString :: Text -> Text escapeString = escapeStringUsing escs   where escs = backslashEscapes "{"  -- | Ordered list start parser for use in Para below.-olMarker :: Parser [Char] ParserState Char+olMarker :: Parser Text ParserState Char olMarker = do (start, style', delim) <- anyOrderedListMarker               if delim == Period &&                           (style' == UpperAlpha || (style' == UpperRoman &&@@ -122,27 +113,36 @@  -- | True if string begins with an ordered list marker -- or would be interpreted as an AsciiDoc option command-needsEscaping :: String -> Bool+needsEscaping :: Text -> Bool needsEscaping s = beginsWithOrderedListMarker s || isBracketed s   where     beginsWithOrderedListMarker str =-      case runParser olMarker defaultParserState "para start" (take 10 str) of+      case runParser olMarker defaultParserState "para start" (T.take 10 str) of              Left  _ -> False              Right _ -> True-    isBracketed ('[':cs) = listToMaybe (reverse cs) == Just ']'-    isBracketed _ = False+    isBracketed t+      | Just ('[', t') <- T.uncons t+      , Just (_, ']')  <- T.unsnoc t'+      = True+      | otherwise = False  -- | Convert Pandoc block element to asciidoc. blockToAsciiDoc :: PandocMonad m                 => WriterOptions -- ^ Options                 -> Block         -- ^ Block element-                -> ADW m Doc+                -> ADW m (Doc Text) blockToAsciiDoc _ Null = return empty+blockToAsciiDoc opts (Div (id',"section":_,_)+                       (Header level (_,cls,kvs) ils : xs)) = do+  hdr <- blockToAsciiDoc opts (Header level (id',cls,kvs) ils)+  rest <- blockListToAsciiDoc opts xs+  return $ hdr $$ rest blockToAsciiDoc opts (Plain inlines) = do   contents <- inlineListToAsciiDoc opts inlines   return $ contents <> blankline-blockToAsciiDoc opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =-  blockToAsciiDoc opts (Para [Image attr alt (src,tit)])+blockToAsciiDoc opts (Para [Image attr alt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt+  = blockToAsciiDoc opts (Para [Image attr alt (src,tit)]) blockToAsciiDoc opts (Para inlines) = do   contents <- inlineListToAsciiDoc opts inlines   -- escape if para starts with ordered list marker@@ -158,7 +158,7 @@   contents <- joinWithLinefeeds <$> mapM docify lns   return $ "[verse]" $$ text "--" $$ contents $$ text "--" $$ blankline blockToAsciiDoc _ b@(RawBlock f s)-  | f == "asciidoc" = return $ text s+  | f == "asciidoc" = return $ literal s   | otherwise         = do       report $ BlockNotRendered b       return empty@@ -169,20 +169,20 @@   ids <- gets autoIds   let autoId = uniqueIdent (writerExtensions opts) inlines ids   modify $ \st -> st{ autoIds = Set.insert autoId ids }-  let identifier = if null ident ||+  let identifier = if T.null ident ||                       (isEnabled Ext_auto_identifiers opts && ident == autoId)                       then empty-                      else "[[" <> text ident <> "]]"+                      else "[[" <> literal ident <> "]]"   return $ identifier $$            nowrap (text (replicate (level + 1) '=') <> space <> contents) <>            blankline  blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $ flush (   if null classes-     then "...." $$ text str $$ "...."-     else attrs $$ "----" $$ text str $$ "----")+     then "...." $$ literal str $$ "...."+     else attrs $$ "----" $$ literal str $$ "----")   <> blankline-    where attrs = "[" <> text (intercalate "," ("source" : classes)) <> "]"+    where attrs = "[" <> literal (T.intercalate "," ("source" : classes)) <> "]" blockToAsciiDoc opts (BlockQuote blocks) = do   contents <- blockListToAsciiDoc opts blocks   let isBlock (BlockQuote _) = True@@ -256,36 +256,55 @@   modify $ \st -> st{ inList = True }   contents <- mapM (bulletListItemToAsciiDoc opts) items   modify $ \st -> st{ inList = inlist }-  return $ cat contents <> blankline+  return $ mconcat contents <> blankline blockToAsciiDoc opts (OrderedList (start, sty, _delim) items) = do   let listStyle = case sty of                        DefaultStyle -> []                        Decimal      -> ["arabic"]                        Example      -> []-                       _            -> [map toLower (show sty)]-  let listStart = if start == 1 then [] else ["start=" ++ show start]-  let listoptions = case intercalate ", " (listStyle ++ listStart) of-                          [] -> empty-                          x  -> brackets (text x)+                       _            -> [T.toLower (tshow sty)]+  let listStart = if start == 1 then [] else ["start=" <> tshow start]+  let listoptions = case T.intercalate ", " (listStyle ++ listStart) of+                          "" -> empty+                          x  -> brackets (literal x)   inlist <- gets inList   modify $ \st -> st{ inList = True }   contents <- mapM (orderedListItemToAsciiDoc opts) items   modify $ \st -> st{ inList = inlist }-  return $ listoptions $$ cat contents <> blankline+  return $ listoptions $$ mconcat contents <> blankline blockToAsciiDoc opts (DefinitionList items) = do   inlist <- gets inList   modify $ \st -> st{ inList = True }   contents <- mapM (definitionListItemToAsciiDoc opts) items   modify $ \st -> st{ inList = inlist }-  return $ cat contents <> blankline-blockToAsciiDoc opts (Div (ident,_,_) bs) = do-  let identifier = if null ident then empty else "[[" <> text ident <> "]]"-  contents <- blockListToAsciiDoc opts bs+  return $ mconcat contents <> blankline+blockToAsciiDoc opts (Div (ident,classes,_) bs) = do+  let identifier = if T.null ident then empty else "[[" <> literal ident <> "]]"+  let admonitions = ["attention","caution","danger","error","hint",+                     "important","note","tip","warning"]+  contents <-+       case classes of+         (l:_) | l `elem` admonitions -> do+             let (titleBs, bodyBs) =+                     case bs of+                       (Div (_,["title"],_) ts : rest) -> (ts, rest)+                       _ -> ([], bs)+             admonitionTitle <- if null titleBs+                                   then return mempty+                                   else ("." <>) <$>+                                         blockListToAsciiDoc opts titleBs+             admonitionBody <- blockListToAsciiDoc opts bodyBs+             return $ "[" <> literal (T.toUpper l) <> "]" $$+                      chomp admonitionTitle $$+                      "====" $$+                      chomp admonitionBody $$+                      "===="+         _ -> blockListToAsciiDoc opts bs   return $ identifier $$ contents  -- | Convert bullet list item (list of blocks) to asciidoc. bulletListItemToAsciiDoc :: PandocMonad m-                         => WriterOptions -> [Block] -> ADW m Doc+                         => WriterOptions -> [Block] -> ADW m (Doc Text) bulletListItemToAsciiDoc opts blocks = do   lev <- gets bulletListLevel   modify $ \s -> s{ bulletListLevel = lev + 1 }@@ -295,7 +314,8 @@   return $ marker <> text " " <> listBegin blocks <>     contents <> cr -addBlock :: PandocMonad m => WriterOptions -> Doc -> Block -> ADW m Doc+addBlock :: PandocMonad m+         => WriterOptions -> Doc Text -> Block -> ADW m (Doc Text) addBlock opts d b = do   x <- chomp <$> blockToAsciiDoc opts b   return $@@ -308,7 +328,7 @@         Plain{} | isEmpty d -> x         _ -> d <> cr <> text "+" <> cr <> x -listBegin :: [Block] -> Doc+listBegin :: [Block] -> Doc Text listBegin blocks =         case blocks of           Para (Math DisplayMath _:_) : _  -> "{blank}"@@ -322,7 +342,7 @@ orderedListItemToAsciiDoc :: PandocMonad m                           => WriterOptions -- ^ options                           -> [Block]       -- ^ list item (list of blocks)-                          -> ADW m Doc+                          -> ADW m (Doc Text) orderedListItemToAsciiDoc opts blocks = do   lev <- gets orderedListLevel   modify $ \s -> s{ orderedListLevel = lev + 1 }@@ -335,7 +355,7 @@ definitionListItemToAsciiDoc :: PandocMonad m                              => WriterOptions                              -> ([Inline],[[Block]])-                             -> ADW m Doc+                             -> ADW m (Doc Text) definitionListItemToAsciiDoc opts (label, defs) = do   labelText <- inlineListToAsciiDoc opts label   marker <- gets defListMarker@@ -343,25 +363,26 @@      then modify (\st -> st{ defListMarker = ";;"})      else modify (\st -> st{ defListMarker = "::"})   let divider = cr <> text "+" <> cr-  let defsToAsciiDoc :: PandocMonad m => [Block] -> ADW m Doc+  let defsToAsciiDoc :: PandocMonad m => [Block] -> ADW m (Doc Text)       defsToAsciiDoc ds = (vcat . intersperse divider . map chomp)            `fmap` mapM (blockToAsciiDoc opts) ds   defs' <- mapM defsToAsciiDoc defs   modify (\st -> st{ defListMarker = marker })   let contents = nest 2 $ vcat $ intersperse divider $ map chomp defs'-  return $ labelText <> text marker <> cr <> contents <> cr+  return $ labelText <> literal marker <> cr <> contents <> cr  -- | Convert list of Pandoc block elements to asciidoc. blockListToAsciiDoc :: PandocMonad m                     => WriterOptions -- ^ Options                     -> [Block]       -- ^ List of block elements-                    -> ADW m Doc-blockListToAsciiDoc opts blocks = cat `fmap` mapM (blockToAsciiDoc opts) blocks+                    -> ADW m (Doc Text)+blockListToAsciiDoc opts blocks =+  mconcat `fmap` mapM (blockToAsciiDoc opts) blocks  data SpacyLocation = End | Start  -- | Convert list of Pandoc inline elements to asciidoc.-inlineListToAsciiDoc :: PandocMonad m => WriterOptions -> [Inline] -> ADW m Doc+inlineListToAsciiDoc :: PandocMonad m => WriterOptions -> [Inline] -> ADW m (Doc Text) inlineListToAsciiDoc opts lst = do   oldIntraword <- gets intraword   setIntraword False@@ -391,10 +412,11 @@        isSpacy _ SoftBreak = True        -- Note that \W characters count as spacy in AsciiDoc        -- for purposes of determining interword:-       isSpacy End (Str xs) = case reverse xs of-                                   c:_ -> isPunctuation c || isSpace c-                                   _   -> False-       isSpacy Start (Str (c:_)) = isPunctuation c || isSpace c+       isSpacy End (Str xs) = case T.unsnoc xs of+                                   Just (_, c) -> isPunctuation c || isSpace c+                                   _           -> False+       isSpacy Start (Str xs)+         | Just (c, _) <- T.uncons xs = isPunctuation c || isSpace c        isSpacy _ _ = False  setIntraword :: PandocMonad m => Bool -> ADW m ()@@ -404,7 +426,7 @@ withIntraword p = setIntraword True *> p <* setIntraword False  -- | Convert Pandoc inline element to asciidoc.-inlineToAsciiDoc :: PandocMonad m => WriterOptions -> Inline -> ADW m Doc+inlineToAsciiDoc :: PandocMonad m => WriterOptions -> Inline -> ADW m (Doc Text) inlineToAsciiDoc opts (Emph [Strong xs]) =   inlineToAsciiDoc opts (Strong [Emph xs])  -- see #5565 inlineToAsciiDoc opts (Emph lst) = do@@ -437,22 +459,27 @@       DoubleQuote         | isAsciidoctor -> [Str "\"`"] ++ lst ++ [Str "`\""]         | otherwise     -> [Str "``"] ++ lst ++ [Str "''"]-inlineToAsciiDoc _ (Code _ str) = return $-  text "`+" <> text (escapeStringUsing (backslashEscapes "`") str) <> "+`"-inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str+inlineToAsciiDoc _ (Code _ str) = do+  isAsciidoctor <- gets asciidoctorVariant+  let contents = literal (escapeStringUsing (backslashEscapes "`") str)+  return $+    if isAsciidoctor+       then text "`+" <> contents <> "+`"+       else text "`"  <> contents <> "`"+inlineToAsciiDoc _ (Str str) = return $ literal $ escapeString str inlineToAsciiDoc _ (Math InlineMath str) = do   isAsciidoctor <- gets asciidoctorVariant   modify $ \st -> st{ hasMath = True }   let content = if isAsciidoctor-                then text str-                else "$" <> text str <> "$"+                then literal str+                else "$" <> literal str <> "$"   return $ "latexmath:[" <> content <> "]" inlineToAsciiDoc _ (Math DisplayMath str) = do   isAsciidoctor <- gets asciidoctorVariant   modify $ \st -> st{ hasMath = True }   let content = if isAsciidoctor-                then text str-                else "\\[" <> text str <> "\\]"+                then literal str+                else "\\[" <> literal str <> "\\]"   inlist <- gets inList   let sepline = if inlist                    then text "+"@@ -461,7 +488,7 @@       (cr <> sepline) $$ "[latexmath]" $$ "++++" $$       content $$ "++++" <> cr inlineToAsciiDoc _ il@(RawInline f s)-  | f == "asciidoc" = return $ text s+  | f == "asciidoc" = return $ literal s   | otherwise         = do       report $ InlineNotRendered il       return empty@@ -479,38 +506,38 @@ -- abs:  http://google.cod[Google] -- or my@email.com[email john]   linktext <- inlineListToAsciiDoc opts txt-  let isRelative = ':' `notElem` src+  let isRelative = T.all (/= ':') src   let prefix = if isRelative                   then text "link:"                   else empty-  let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)+  let srcSuffix = fromMaybe src (T.stripPrefix "mailto:" src)   let useAuto = case txt of                       [Str s] | escapeURI s == srcSuffix -> True                       _       -> False   return $ if useAuto-              then text srcSuffix-              else prefix <> text src <> "[" <> linktext <> "]"+              then literal srcSuffix+              else prefix <> literal src <> "[" <> linktext <> "]" inlineToAsciiDoc opts (Image attr alternate (src, tit)) = do -- image:images/logo.png[Company logo, title="blah"]   let txt = if null alternate || (alternate == [Str ""])                then [Str "image"]                else alternate   linktext <- inlineListToAsciiDoc opts txt-  let linktitle = if null tit+  let linktitle = if T.null tit                      then empty-                     else ",title=\"" <> text tit <> "\""+                     else ",title=\"" <> literal tit <> "\""       showDim dir = case dimension dir attr of                       Just (Percent a) ->                         ["scaledwidth=" <> text (show (Percent a))]                       Just dim         ->-                        [text (show dir) <> "=" <> text (showInPixel opts dim)]+                        [text (show dir) <> "=" <> literal (showInPixel opts dim)]                       Nothing          ->                         []       dimList = showDim Width ++ showDim Height       dims = if null dimList                 then empty-                else "," <> cat (intersperse "," dimList)-  return $ "image:" <> text src <> "[" <> linktext <> linktitle <> dims <> "]"+                else "," <> mconcat (intersperse "," dimList)+  return $ "image:" <> literal src <> "[" <> linktext <> linktitle <> dims <> "]" inlineToAsciiDoc opts (Note [Para inlines]) =   inlineToAsciiDoc opts (Note [Plain inlines]) inlineToAsciiDoc opts (Note [Plain inlines]) = do@@ -522,9 +549,9 @@   contents <- inlineListToAsciiDoc opts ils   isIntraword <- gets intraword   let marker = if isIntraword then "##" else "#"-  if null ident && null classes+  if T.null ident && null classes      then return contents      else do-       let modifier = brackets $ text $ unwords $-            [ '#':ident | not (null ident)] ++ map ('.':) classes+       let modifier = brackets $ literal $ T.unwords $+            [ "#" <> ident | not (T.null ident)] ++ map ("." <>) classes        return $ modifier <> marker <> contents <> marker
src/Text/Pandoc/Writers/CommonMark.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.CommonMark    Copyright   : Copyright (C) 2015-2019 John MacFarlane@@ -28,12 +29,13 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared (capitalize, isHeaderBlock, isTightList,-    linesToPara, onlySimpleTableCells, substitute, taskListItemToAscii)-import Text.Pandoc.Templates (renderTemplate')+    linesToPara, onlySimpleTableCells, taskListItemToAscii, tshow)+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Walk (walk, walkM) import Text.Pandoc.Writers.HTML (writeHtml5String, tagWithAttributes) import Text.Pandoc.Writers.Shared import Text.Pandoc.XML (toHtml5Entities)+import Text.DocLayout (literal, render)  -- | Convert Pandoc to CommonMark. writeCommonMark :: PandocMonad m => WriterOptions -> Pandoc -> m Text@@ -49,9 +51,9 @@                then []                else [OrderedList (1, Decimal, Period) $ reverse notes]   main <-  blocksToCommonMark opts (blocks' ++ notes')-  metadata <- metaToJSON opts-              (blocksToCommonMark opts)-              (inlinesToCommonMark opts)+  metadata <- metaToContext opts+              (fmap (literal . T.stripEnd) . blocksToCommonMark opts)+              (fmap (literal . T.stripEnd) . inlinesToCommonMark opts)               meta   let context =           -- for backwards compatibility we populate toc@@ -59,9 +61,10 @@           defField "toc" toc         $ defField "table-of-contents" toc         $ defField "body" main metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  return $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> render Nothing $ renderTemplate tpl context  softBreakToSpace :: Inline -> Inline softBreakToSpace SoftBreak = Space@@ -71,7 +74,7 @@ processNotes (Note bs) = do   modify (bs :)   notes <- get-  return $ Str $ "[" ++ show (length notes) ++ "]"+  return $ Str $ "[" <> tshow (length notes) <> "]" processNotes x = return x  node :: NodeType -> [Node] -> Node@@ -107,14 +110,14 @@   return (node PARAGRAPH (inlinesToNodes opts xs) : ns) blockToNodes opts (LineBlock lns) ns = blockToNodes opts (linesToPara lns) ns blockToNodes _ (CodeBlock (_,classes,_) xs) ns = return-  (node (CODE_BLOCK (T.pack (unwords classes)) (T.pack xs)) [] : ns)+  (node (CODE_BLOCK (T.unwords classes) xs) [] : ns) blockToNodes opts (RawBlock (Format f) xs) ns   | f == "html" && isEnabled Ext_raw_html opts-              = return (node (HTML_BLOCK (T.pack xs)) [] : ns)+              = return (node (HTML_BLOCK xs) [] : ns)   | (f == "latex" || f == "tex") && isEnabled Ext_raw_tex opts-              = return (node (CUSTOM_BLOCK (T.pack xs) T.empty) [] : ns)+              = return (node (CUSTOM_BLOCK xs T.empty) [] : ns)   | f == "markdown"-              = return (node (CUSTOM_BLOCK (T.pack xs) T.empty) [] : ns)+              = return (node (CUSTOM_BLOCK xs T.empty) [] : ns)   | otherwise = return ns blockToNodes opts (BlockQuote bs) ns = do   nodes <- blocksToNodes opts bs@@ -167,9 +170,9 @@        let capt' = node PARAGRAPH (inlinesToNodes opts capt)        -- backslash | in code and raw:        let fixPipe (Code attr xs) =-             Code attr (substitute "|" "\\|" xs)+             Code attr (T.replace "|" "\\|" xs)            fixPipe (RawInline format xs) =-             RawInline format (substitute "|" "\\|" xs)+             RawInline format (T.replace "|" "\\|" xs)            fixPipe x = x        let toCell [Plain ils] = T.strip                                 $ nodeToCommonmark [] Nothing@@ -274,19 +277,19 @@            [node (HTML_INLINE (T.pack "</span>")) []]) ++ )     else (inlinesToNodes opts (capitalize xs) ++) inlineToNodes opts (Link _ ils (url,tit)) =-  (node (LINK (T.pack url) (T.pack tit)) (inlinesToNodes opts ils) :)+  (node (LINK url tit) (inlinesToNodes opts ils) :) -- title beginning with fig: indicates implicit figure-inlineToNodes opts (Image alt ils (url,'f':'i':'g':':':tit)) =+inlineToNodes opts (Image alt ils (url,T.stripPrefix "fig:" -> Just tit)) =   inlineToNodes opts (Image alt ils (url,tit)) inlineToNodes opts (Image _ ils (url,tit)) =-  (node (IMAGE (T.pack url) (T.pack tit)) (inlinesToNodes opts ils) :)+  (node (IMAGE url tit) (inlinesToNodes opts ils) :) inlineToNodes opts (RawInline (Format f) xs)   | f == "html" && isEnabled Ext_raw_html opts-              = (node (HTML_INLINE (T.pack xs)) [] :)+              = (node (HTML_INLINE xs) [] :)   | (f == "latex" || f == "tex") && isEnabled Ext_raw_tex opts-              = (node (CUSTOM_INLINE (T.pack xs) T.empty) [] :)+              = (node (CUSTOM_INLINE xs T.empty) [] :)   | f == "markdown"-              = (node (CUSTOM_INLINE (T.pack xs) T.empty) [] :)+              = (node (CUSTOM_INLINE xs T.empty) [] :)   | otherwise = id inlineToNodes opts (Quoted qt ils) =   ((node (HTML_INLINE start) [] :@@ -302,12 +305,12 @@                             | writerPreferAscii opts ->                                      ("&ldquo;", "&rdquo;")                             | otherwise -> ("“", "”")-inlineToNodes _ (Code _ str) = (node (CODE (T.pack str)) [] :)+inlineToNodes _ (Code _ str) = (node (CODE str) [] :) inlineToNodes opts (Math mt str) =   case writerHTMLMathMethod opts of        WebTeX url ->            let core = inlineToNodes opts-                        (Image nullAttr [Str str] (url ++ urlEncode str, str))+                        (Image nullAttr [Str str] (url <> T.pack (urlEncode $ T.unpack str), str))                sep = if mt == DisplayMath                         then (node LINEBREAK [] :)                         else id@@ -315,14 +318,14 @@        _  ->            case mt of             InlineMath  ->-              (node (HTML_INLINE (T.pack ("\\(" ++ str ++ "\\)"))) [] :)+              (node (HTML_INLINE ("\\(" <> str <> "\\)")) [] :)             DisplayMath ->-              (node (HTML_INLINE (T.pack ("\\[" ++ str ++ "\\]"))) [] :)+              (node (HTML_INLINE ("\\[" <> str <> "\\]")) [] :) inlineToNodes opts (Span ("",["emoji"],kvs) [Str s]) = do   case lookup "data-emoji" kvs of        Just emojiname | isEnabled Ext_emoji opts ->-            (node (TEXT (":" <> T.pack emojiname <> ":")) [] :)-       _ -> (node (TEXT (T.pack s)) [] :)+            (node (TEXT (":" <> emojiname <> ":")) [] :)+       _ -> (node (TEXT s) [] :) inlineToNodes opts (Span attr ils) =   let nodes = inlinesToNodes opts ils       op = tagWithAttributes opts True False "span" attr@@ -334,17 +337,17 @@ inlineToNodes _ (Note _) = id -- should not occur -- we remove Note elements in preprocessing -stringToNodes :: WriterOptions -> String -> [Node] -> [Node]+stringToNodes :: WriterOptions -> Text -> [Node] -> [Node] stringToNodes opts s-  | not (writerPreferAscii opts) = (node (TEXT (T.pack s)) [] :)+  | not (writerPreferAscii opts) = (node (TEXT s) [] :)   | otherwise = step s   where     step input =-      let (ascii, rest) = span isAscii input-          this = node (TEXT (T.pack ascii)) []-          nodes = case rest of-            [] -> id-            (nonAscii : rest') ->+      let (ascii, rest) = T.span isAscii input+          this = node (TEXT ascii) []+          nodes = case T.uncons rest of+            Nothing -> id+            Just (nonAscii, rest') ->               let escaped = toHtml5Entities (T.singleton nonAscii)               in (node (HTML_INLINE escaped) [] :) . step rest'       in (this :) . nodes@@ -352,7 +355,7 @@ toSubscriptInline :: Inline -> Maybe Inline toSubscriptInline Space = Just Space toSubscriptInline (Span attr ils) = Span attr <$> traverse toSubscriptInline ils-toSubscriptInline (Str s) = Str <$> traverse toSubscript s+toSubscriptInline (Str s) = Str . T.pack <$> traverse toSubscript (T.unpack s) toSubscriptInline LineBreak = Just LineBreak toSubscriptInline SoftBreak = Just SoftBreak toSubscriptInline _ = Nothing@@ -360,7 +363,7 @@ toSuperscriptInline :: Inline -> Maybe Inline toSuperscriptInline Space = Just Space toSuperscriptInline (Span attr ils) = Span attr <$> traverse toSuperscriptInline ils-toSuperscriptInline (Str s) = Str <$> traverse toSuperscript s+toSuperscriptInline (Str s) = Str . T.pack <$> traverse toSuperscript (T.unpack s) toSuperscriptInline LineBreak = Just LineBreak toSuperscriptInline SoftBreak = Just SoftBreak toSuperscriptInline _ = Nothing
src/Text/Pandoc/Writers/ConTeXt.hs view
@@ -1,6 +1,7 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ViewPatterns        #-} {- |    Module      : Text.Pandoc.Writers.ConTeXt    Copyright   : Copyright (C) 2007-2019 John MacFarlane@@ -16,9 +17,10 @@ import Prelude import Control.Monad.State.Strict import Data.Char (ord, isDigit)-import Data.List (intercalate, intersperse)+import Data.List (intersperse) import Data.Maybe (mapMaybe) import Data.Text (Text)+import qualified Data.Text as T import Network.URI (unEscapeString) import Text.Pandoc.BCP47 import Text.Pandoc.Class (PandocMonad, report, toLang)@@ -26,9 +28,9 @@ import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Walk (query) import Text.Pandoc.Writers.Shared import Text.Printf (printf)@@ -37,6 +39,8 @@   WriterState { stNextRef          :: Int  -- number of next URL reference               , stOrderedListLevel :: Int  -- level of ordered list               , stOptions          :: WriterOptions -- writer options+              , stHasCslRefs       :: Bool -- has CSL citations+              , stCslHangingIndent :: Bool -- CSL hanging indent               }  data Tabl = Xtb | Ntb deriving (Show, Eq)@@ -50,6 +54,8 @@   let defaultWriterState = WriterState { stNextRef = 1                                        , stOrderedListLevel = 0                                        , stOptions = options+                                       , stHasCslRefs = False+                                       , stCslHangingIndent = False                                        }   in evalStateT (pandocToConTeXt options document) defaultWriterState @@ -60,24 +66,24 @@   let colwidth = if writerWrapText options == WrapAuto                     then Just $ writerColumns options                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  metadata <- metaToJSON options-              (fmap render' . blockListToConTeXt)-              (fmap render' . inlineListToConTeXt)+  metadata <- metaToContext options+              blockListToConTeXt+              (fmap chomp . inlineListToConTeXt)               meta-  body <- mapM (elementToConTeXt options) $ hierarchicalize blocks-  let main = (render' . vcat) body-  let layoutFromMargins = intercalate [','] $ mapMaybe (\(x,y) ->-                                ((x ++ "=") ++) <$> getField y metadata)+  main <- blockListToConTeXt $ makeSections False Nothing blocks+  let layoutFromMargins = mconcat $ intersperse ("," :: Doc Text) $+                          mapMaybe (\(x,y) ->+                                ((x <> "=") <>) <$> getField y metadata)                               [("leftmargin","margin-left")                               ,("rightmargin","margin-right")                               ,("top","margin-top")                               ,("bottom","margin-bottom")                               ]   mblang <- fromBCP47 (getLang options meta)+  st <- get   let context =   defField "toc" (writerTableOfContents options)-                $ defField "placelist" (intercalate ("," :: String) $+                $ defField "placelist"+                   (mconcat . intersperse ("," :: Doc Text) $                      take (writerTOCDepth options +                            case writerTopLevelDivision options of                              TopLevelPart    -> 0@@ -88,25 +94,35 @@                 $ defField "body" main                 $ defField "layout" layoutFromMargins                 $ defField "number-sections" (writerNumberSections options)-                $ maybe id (defField "context-lang") mblang-                $ (case getField "papersize" metadata of+                $ defField "csl-refs" (stHasCslRefs st)+                $ defField "csl-hanging-indent" (stCslHangingIndent st)+                $ maybe id (\l ->+                     defField "context-lang" (literal l :: Doc Text)) mblang+                $ (case T.unpack . render Nothing <$>+                      getField "papersize" metadata of                         Just (('a':d:ds) :: String)                           | all isDigit (d:ds) -> resetField "papersize"-                                                     (('A':d:ds) :: String)+                                                   (T.pack ('A':d:ds))+                        _                     -> id)+                $ (case T.toLower $ lookupMetaString "pdfa" meta of+                        "true" -> resetField "pdfa" (T.pack "1b:2005")                         _                     -> id) metadata-  let context' = defField "context-dir" (toContextDir+  let context' = defField "context-dir" (maybe mempty toContextDir                                          $ getField "dir" context) context-  case writerTemplate options of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context'+  return $ render colwidth $+    case writerTemplate options of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context' -toContextDir :: Maybe String -> String-toContextDir (Just "rtl") = "r2l"-toContextDir (Just "ltr") = "l2r"-toContextDir _            = ""+-- change rtl to r2l, ltr to l2r+toContextDir :: Doc Text -> Doc Text+toContextDir = fmap (\t -> case t of+                              "ltr" -> "l2r"+                              "rtl" -> "r2l"+                              _     -> t)  -- | escape things as needed for ConTeXt-escapeCharForConTeXt :: WriterOptions -> Char -> String+escapeCharForConTeXt :: WriterOptions -> Char -> Text escapeCharForConTeXt opts ch =  let ligatures = isEnabled Ext_smart opts in  case ch of@@ -125,41 +141,40 @@     '\x2013' | ligatures -> "--"     '\x2019' | ligatures -> "'"     '\x2026' -> "\\ldots{}"-    x        -> [x]+    x        -> T.singleton x  -- | Escape string for ConTeXt-stringToConTeXt :: WriterOptions -> String -> String-stringToConTeXt opts = concatMap (escapeCharForConTeXt opts)+stringToConTeXt :: WriterOptions -> Text -> Text+stringToConTeXt opts = T.concatMap (escapeCharForConTeXt opts)  -- | Sanitize labels-toLabel :: String -> String-toLabel z = concatMap go z+toLabel :: Text -> Text+toLabel z = T.concatMap go z  where go x-         | x `elem` ("\\#[]\",{}%()|=" :: String) = "ux" ++ printf "%x" (ord x)-         | otherwise = [x]---- | Convert Elements to ConTeXt-elementToConTeXt :: PandocMonad m => WriterOptions -> Element -> WM m Doc-elementToConTeXt _ (Blk block) = blockToConTeXt block-elementToConTeXt opts (Sec level _ attr title' elements) = do-  header' <- sectionHeader attr level title'-  footer' <- sectionFooter attr level-  innerContents <- mapM (elementToConTeXt opts) elements-  return $ header' $$ vcat innerContents $$ footer'+         | x `elem` ("\\#[]\",{}%()|=" :: String) = "ux" <> T.pack (printf "%x" (ord x))+         | otherwise = T.singleton x  -- | Convert Pandoc block element to ConTeXt.-blockToConTeXt :: PandocMonad m => Block -> WM m Doc+blockToConTeXt :: PandocMonad m => Block -> WM m (Doc Text) blockToConTeXt Null = return empty+blockToConTeXt (Div attr@(_,"section":_,_)+                 (Header level _ title' : xs)) = do+  header' <- sectionHeader attr level title'+  footer' <- sectionFooter attr level+  innerContents <- blockListToConTeXt xs+  return $ header' $$ innerContents $$ footer' blockToConTeXt (Plain lst) = inlineListToConTeXt lst -- title beginning with fig: indicates that the image is a figure-blockToConTeXt (Para [Image attr txt (src,'f':'i':'g':':':_)]) = do-  capt <- inlineListToConTeXt txt-  img  <- inlineToConTeXt (Image attr txt (src, ""))-  let (ident, _, _) = attr-      label = if null ident-                 then empty-                 else "[]" <> brackets (text $ toLabel ident)-  return $ blankline $$ "\\placefigure" <> label <> braces capt <> img <> blankline+blockToConTeXt (Para [Image attr txt (src,tgt)])+  | Just _ <- T.stripPrefix "fig:" tgt+  = do+      capt <- inlineListToConTeXt txt+      img  <- inlineToConTeXt (Image attr txt (src, ""))+      let (ident, _, _) = attr+          label = if T.null ident+                  then empty+                  else "[]" <> brackets (literal $ toLabel ident)+      return $ blankline $$ "\\placefigure" <> label <> braces capt <> img <> blankline blockToConTeXt (Para lst) = do   contents <- inlineListToConTeXt lst   return $ contents <> blankline@@ -170,17 +185,22 @@   contents <- blockListToConTeXt lst   return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline blockToConTeXt (CodeBlock _ str) =-  return $ flush ("\\starttyping" <> cr <> text str <> cr <> "\\stoptyping") $$ blankline+  return $ flush ("\\starttyping" <> cr <> literal str <> cr <> "\\stoptyping") $$ blankline   -- blankline because \stoptyping can't have anything after it, inc. '}' blockToConTeXt b@(RawBlock f str)-  | f == Format "context" || f == Format "tex" = return $ text str <> blankline+  | f == Format "context" || f == Format "tex" = return $ literal str <> blankline   | otherwise = empty <$ report (BlockNotRendered b)+blockToConTeXt (Div ("refs",classes,_) bs) = do+  modify $ \st -> st{ stHasCslRefs = True+                    , stCslHangingIndent = "hanging-indent" `elem` classes }+  inner <- blockListToConTeXt bs+  return $ "\\startcslreferences" $$ inner $$ "\\stopcslreferences" blockToConTeXt (Div (ident,_,kvs) bs) = do   let align dir txt = "\\startalignment[" <> dir <> "]" $$ txt $$ "\\stopalignment"   mblang <- fromBCP47 (lookup "lang" kvs)-  let wrapRef txt = if null ident+  let wrapRef txt = if T.null ident                        then txt-                       else ("\\reference" <> brackets (text $ toLabel ident) <>+                       else ("\\reference" <> brackets (literal $ toLabel ident) <>                               braces empty <> "%") $$ txt       wrapDir = case lookup "dir" kvs of                   Just "rtl" -> align "righttoleft"@@ -188,7 +208,7 @@                   _          -> id       wrapLang txt = case mblang of                        Just lng -> "\\start\\language["-                                     <> text lng <> "]" $$ txt $$ "\\stop"+                                     <> literal lng <> "]" $$ txt $$ "\\stop"                        Nothing  -> txt       wrapBlank txt = blankline <> txt <> blankline   (wrapBlank . wrapLang . wrapDir . wrapRef) <$> blockListToConTeXt bs@@ -197,29 +217,29 @@   return $ ("\\startitemize" <> if isTightList lst                                    then brackets "packed"                                    else empty) $$-    vcat contents $$ text "\\stopitemize" <> blankline+    vcat contents $$ literal "\\stopitemize" <> blankline blockToConTeXt (OrderedList (start, style', delim) lst) = do     st <- get     let level = stOrderedListLevel st     put st {stOrderedListLevel = level + 1}     contents <- mapM listItemToConTeXt lst     put st {stOrderedListLevel = level}-    let start' = if start == 1 then "" else "start=" ++ show start+    let start' = if start == 1 then "" else "start=" <> tshow start     let delim' = case delim of                         DefaultDelim -> ""                         Period       -> "stopper=."                         OneParen     -> "stopper=)"                         TwoParens    -> "left=(,stopper=)"-    let width = maximum $ map length $ take (length contents)+    let width = maximum $ map T.length $ take (length contents)                           (orderedListMarkers (start, style', delim))     let width' = (toEnum width + 1) / 2     let width'' = if width' > (1.5 :: Double)-                     then "width=" ++ show width' ++ "em"+                     then "width=" <> tshow width' <> "em"                      else ""-    let specs2Items = filter (not . null) [start', delim', width'']+    let specs2Items = filter (not . T.null) [start', delim', width'']     let specs2 = if null specs2Items                     then ""-                    else "[" ++ intercalate "," specs2Items ++ "]"+                    else "[" <> T.intercalate "," specs2Items <> "]"     let style'' = '[': (case style' of                           DefaultStyle -> orderedListStyles !! level                           Decimal      -> 'n'@@ -229,8 +249,8 @@                           LowerAlpha   -> 'a'                           UpperAlpha   -> 'A') :                        if isTightList lst then ",packed]" else "]"-    let specs = style'' ++ specs2-    return $ "\\startitemize" <> text specs $$ vcat contents $$+    let specs = T.pack style'' <> specs2+    return $ "\\startitemize" <> literal specs $$ vcat contents $$              "\\stopitemize" <> blankline blockToConTeXt (DefinitionList lst) =   liftM vcat $ mapM defListItemToConTeXt lst@@ -254,7 +274,8 @@         else "title=" <> braces captionText       ) $$ body $$ "\\stopplacetable" <> blankline -tableToConTeXt :: PandocMonad m => Tabl -> Doc -> [Doc] -> WM m Doc+tableToConTeXt :: PandocMonad m+               => Tabl -> Doc Text -> [Doc Text] -> WM m (Doc Text) tableToConTeXt Xtb heads rows =   return $ "\\startxtable" $$     (if isEmpty heads@@ -276,7 +297,7 @@            "\\startTABLEfoot" $$ last rows $$ "\\stopTABLEfoot") $$     "\\stopTABLE" -tableRowToConTeXt :: PandocMonad m => Tabl -> [Alignment] -> [Double] -> [[Block]] -> WM m Doc+tableRowToConTeXt :: PandocMonad m => Tabl -> [Alignment] -> [Double] -> [[Block]] -> WM m (Doc Text) tableRowToConTeXt Xtb aligns widths cols = do   cells <- mapM (tableColToConTeXt Xtb) $ zip3 aligns widths cols   return $ "\\startxrow" $$ vcat cells $$ "\\stopxrow"@@ -284,36 +305,37 @@   cells <- mapM (tableColToConTeXt Ntb) $ zip3 aligns widths cols   return $ vcat cells $$ "\\NC\\NR" -tableColToConTeXt :: PandocMonad m => Tabl -> (Alignment, Double, [Block]) -> WM m Doc+tableColToConTeXt :: PandocMonad m => Tabl -> (Alignment, Double, [Block]) -> WM m (Doc Text) tableColToConTeXt tabl (align, width, blocks) = do   cellContents <- blockListToConTeXt blocks   let colwidth = if width == 0         then empty         else "width=" <> braces (text (printf "%.2f\\textwidth" width))   let halign = alignToConTeXt align-  let options = (if keys == empty+  let options = (if isEmpty keys                  then empty                  else brackets keys) <> space-        where keys = hcat $ intersperse "," $ filter (empty /=) [halign, colwidth]+        where keys = hcat $ intersperse "," $ filter (not . isEmpty) [halign, colwidth]   tableCellToConTeXt tabl options cellContents -tableCellToConTeXt :: PandocMonad m => Tabl -> Doc -> Doc -> WM m Doc+tableCellToConTeXt :: PandocMonad m+                   => Tabl -> Doc Text -> Doc Text -> WM m (Doc Text) tableCellToConTeXt Xtb options cellContents =   return $ "\\startxcell" <> options <> cellContents <> " \\stopxcell" tableCellToConTeXt Ntb options cellContents =   return $ "\\NC" <> options <> cellContents -alignToConTeXt :: Alignment -> Doc+alignToConTeXt :: Alignment -> Doc Text alignToConTeXt align = case align of                          AlignLeft    -> "align=right"                          AlignRight   -> "align=left"                          AlignCenter  -> "align=middle"                          AlignDefault -> empty -listItemToConTeXt :: PandocMonad m => [Block] -> WM m Doc+listItemToConTeXt :: PandocMonad m => [Block] -> WM m (Doc Text) listItemToConTeXt list = (("\\item" $$) . nest 2) <$> blockListToConTeXt list -defListItemToConTeXt :: PandocMonad m => ([Inline], [[Block]]) -> WM m Doc+defListItemToConTeXt :: PandocMonad m => ([Inline], [[Block]]) -> WM m (Doc Text) defListItemToConTeXt (term, defs) = do   term' <- inlineListToConTeXt term   def'  <- liftM vsep $ mapM blockListToConTeXt defs@@ -321,13 +343,13 @@            "\\stopdescription" <> blankline  -- | Convert list of block elements to ConTeXt.-blockListToConTeXt :: PandocMonad m => [Block] -> WM m Doc+blockListToConTeXt :: PandocMonad m => [Block] -> WM m (Doc Text) blockListToConTeXt lst = liftM vcat $ mapM blockToConTeXt lst  -- | Convert list of inline elements to ConTeXt. inlineListToConTeXt :: PandocMonad m                     => [Inline]  -- ^ Inlines to convert-                    -> WM m Doc+                    -> WM m (Doc Text) inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt $ addStruts lst   -- We add a \strut after a line break that precedes a space,   -- or the space gets swallowed@@ -336,14 +358,14 @@              addStruts xs         addStruts (x:xs) = x : addStruts xs         addStruts [] = []-        isSpacey Space            = True-        isSpacey (Str ('\160':_)) = True-        isSpacey _                = False+        isSpacey Space                               = True+        isSpacey (Str (T.uncons -> Just ('\160',_))) = True+        isSpacey _                                   = False  -- | Convert inline element to ConTeXt inlineToConTeXt :: PandocMonad m                 => Inline    -- ^ Inline to convert-                -> WM m Doc+                -> WM m (Doc Text) inlineToConTeXt (Emph lst) = do   contents <- inlineListToConTeXt lst   return $ braces $ "\\em " <> contents@@ -362,11 +384,11 @@ inlineToConTeXt (SmallCaps lst) = do   contents <- inlineListToConTeXt lst   return $ braces $ "\\sc " <> contents-inlineToConTeXt (Code _ str) | not ('{' `elem` str || '}' `elem` str) =-  return $ "\\type" <> braces (text str)+inlineToConTeXt (Code _ str) | not ('{' `elemText` str || '}' `elemText` str) =+  return $ "\\type" <> braces (literal str) inlineToConTeXt (Code _ str) = do   opts <- gets stOptions-  return $ "\\mono" <> braces (text $ stringToConTeXt opts str)+  return $ "\\mono" <> braces (literal $ stringToConTeXt opts str) inlineToConTeXt (Quoted SingleQuote lst) = do   contents <- inlineListToConTeXt lst   return $ "\\quote" <> braces contents@@ -376,15 +398,15 @@ inlineToConTeXt (Cite _ lst) = inlineListToConTeXt lst inlineToConTeXt (Str str) = do   opts <- gets stOptions-  return $ text $ stringToConTeXt opts str+  return $ literal $ stringToConTeXt opts str inlineToConTeXt (Math InlineMath str) =-  return $ char '$' <> text str <> char '$'+  return $ char '$' <> literal str <> char '$' inlineToConTeXt (Math DisplayMath str) =-  return $ text "\\startformula "  <> text str <> text " \\stopformula" <> space+  return $ literal "\\startformula "  <> literal str <> literal " \\stopformula" <> space inlineToConTeXt il@(RawInline f str)-  | f == Format "tex" || f == Format "context" = return $ text str+  | f == Format "tex" || f == Format "context" = return $ literal str   | otherwise = empty <$ report (InlineNotRendered il)-inlineToConTeXt LineBreak = return $ text "\\crlf" <> cr+inlineToConTeXt LineBreak = return $ literal "\\crlf" <> cr inlineToConTeXt SoftBreak = do   wrapText <- gets (writerWrapText . stOptions)   return $ case wrapText of@@ -393,66 +415,66 @@                WrapPreserve -> cr inlineToConTeXt Space = return space -- Handle HTML-like internal document references to sections-inlineToConTeXt (Link _ txt ('#' : ref, _)) = do+inlineToConTeXt (Link _ txt (T.uncons -> Just ('#', ref), _)) = do   opts <- gets stOptions   contents <-  inlineListToConTeXt txt   let ref' = toLabel $ stringToConTeXt opts ref-  return $ text "\\goto"+  return $ literal "\\goto"            <> braces contents-           <> brackets (text ref')+           <> brackets (literal ref')  inlineToConTeXt (Link _ txt (src, _)) = do-  let isAutolink = txt == [Str (unEscapeString src)]+  let isAutolink = txt == [Str (T.pack $ unEscapeString $ T.unpack src)]   st <- get   let next = stNextRef st   put $ st {stNextRef = next + 1}-  let ref = "url" ++ show next+  let ref = "url" <> tshow next   contents <-  inlineListToConTeXt txt   return $ "\\useURL"-           <> brackets (text ref)-           <> brackets (text $ escapeStringUsing [('#',"\\#"),('%',"\\%")] src)+           <> brackets (literal ref)+           <> brackets (literal $ escapeStringUsing [('#',"\\#"),('%',"\\%")] src)            <> (if isAutolink                   then empty                   else brackets empty <> brackets contents)            <> "\\from"-           <> brackets (text ref)+           <> brackets (literal ref) inlineToConTeXt (Image attr@(_,cls,_) _ (src, _)) = do   opts <- gets stOptions-  let showDim dir = let d = text (show dir) <> "="+  let showDim dir = let d = literal (tshow dir) <> "="                     in case dimension dir attr of                          Just (Pixel a)   ->-                           [d <> text (showInInch opts (Pixel a)) <> "in"]+                           [d <> literal (showInInch opts (Pixel a)) <> "in"]                          Just (Percent a) ->-                           [d <> text (showFl (a / 100)) <> "\\textwidth"]+                           [d <> literal (showFl (a / 100)) <> "\\textwidth"]                          Just dim         ->-                           [d <> text (show dim)]+                           [d <> literal (tshow dim)]                          Nothing          ->                            []       dimList = showDim Width ++ showDim Height       dims = if null dimList                 then empty-                else brackets $ cat (intersperse "," dimList)+                else brackets $ mconcat (intersperse "," dimList)       clas = if null cls                 then empty-                else brackets $ text $ toLabel $ head cls+                else brackets $ literal $ toLabel $ head cls       -- Use / for path separators on Windows; see #4918-      fixPathSeparators = map $ \c -> case c of-                                           '\\' -> '/'-                                           _    -> c+      fixPathSeparators = T.map $ \c -> case c of+                                          '\\' -> '/'+                                          _    -> c       src' = fixPathSeparators $              if isURI src                 then src-                else unEscapeString src-  return $ braces $ "\\externalfigure" <> brackets (text src') <> dims <> clas+                else T.pack $ unEscapeString $ T.unpack src+  return $ braces $ "\\externalfigure" <> brackets (literal src') <> dims <> clas inlineToConTeXt (Note contents) = do   contents' <- blockListToConTeXt contents   let codeBlock x@(CodeBlock _ _) = [x]       codeBlock _                 = []   let codeBlocks = query codeBlock contents   return $ if null codeBlocks-              then text "\\footnote{" <> nest 2 contents' <> char '}'-              else text "\\startbuffer " <> nest 2 contents' <>-                   text "\\stopbuffer\\footnote{\\getbuffer}"+              then literal "\\footnote{" <> nest 2 (chomp contents') <> char '}'+              else literal "\\startbuffer " <> nest 2 (chomp contents') <>+                   literal "\\stopbuffer\\footnote{\\getbuffer}" inlineToConTeXt (Span (_,_,kvs) ils) = do   mblang <- fromBCP47 (lookup "lang" kvs)   let wrapDir txt = case lookup "dir" kvs of@@ -460,8 +482,8 @@                       Just "ltr" -> braces $ "\\lefttoright " <> txt                       _          -> txt       wrapLang txt = case mblang of-                       Just lng -> "\\start\\language[" <> text lng-                                      <> "]" <> txt <> "\\stop "+                       Just lng -> braces ("\\language" <>+                                           brackets (literal lng) <> txt)                        Nothing -> txt   (wrapLang . wrapDir) <$> inlineListToConTeXt ils @@ -470,28 +492,28 @@               => Attr               -> Int               -> [Inline]-              -> WM m Doc+              -> WM m (Doc Text) sectionHeader (ident,classes,kvs) hdrLevel lst = do   opts <- gets stOptions   contents <- inlineListToConTeXt lst   levelText <- sectionLevelToText opts (ident,classes,kvs) hdrLevel-  let ident' = if null ident+  let ident' = if T.null ident                then empty-               else "reference=" <> braces (text (toLabel ident))-  let contents' = if contents == empty+               else "reference=" <> braces (literal (toLabel ident))+  let contents' = if isEmpty contents                   then empty                   else "title=" <> braces contents-  let options = if keys == empty || levelText == empty+  let options = if isEmpty keys || isEmpty levelText                 then empty                 else brackets keys-        where keys = hcat $ intersperse "," $ filter (empty /=) [contents', ident']+        where keys = hcat $ intersperse "," $ filter (not . isEmpty) [contents', ident']   let starter = if writerSectionDivs opts                 then "\\start"                 else "\\"   return $ starter <> levelText <> options <> blankline  -- | Craft the section footer-sectionFooter :: PandocMonad m => Attr -> Int -> WM m Doc+sectionFooter :: PandocMonad m => Attr -> Int -> WM m (Doc Text) sectionFooter attr hdrLevel = do   opts <- gets stOptions   levelText <- sectionLevelToText opts attr hdrLevel@@ -500,7 +522,7 @@            else empty  -- | Generate a textual representation of the section level-sectionLevelToText :: PandocMonad m => WriterOptions -> Attr -> Int -> WM m Doc+sectionLevelToText :: PandocMonad m => WriterOptions -> Attr -> Int -> WM m (Doc Text) sectionLevelToText opts (_,classes,_) hdrLevel = do   let level' = case writerTopLevelDivision opts of                  TopLevelPart    -> hdrLevel - 2@@ -508,23 +530,23 @@                  TopLevelSection -> hdrLevel                  TopLevelDefault -> hdrLevel   let (section, chapter) = if "unnumbered" `elem` classes-                              then (text "subject", text "title")-                              else (text "section", text "chapter")+                              then (literal "subject", literal "title")+                              else (literal "section", literal "chapter")   return $ case level' of-             -1         -> text "part"+             -1         -> literal "part"              0          -> chapter              n | n >= 1 -> text (concat (replicate (n - 1) "sub"))                            <> section              _          -> empty -- cannot happen -fromBCP47 :: PandocMonad m => Maybe String -> WM m (Maybe String)+fromBCP47 :: PandocMonad m => Maybe Text -> WM m (Maybe Text) fromBCP47 mbs = fromBCP47' <$> toLang mbs  -- Takes a list of the constituents of a BCP 47 language code -- and irons out ConTeXt's exceptions -- https://tools.ietf.org/html/bcp47#section-2.1 -- http://wiki.contextgarden.net/Language_Codes-fromBCP47' :: Maybe Lang -> Maybe String+fromBCP47' :: Maybe Lang -> Maybe Text fromBCP47' (Just (Lang "ar" _ "SY" _)     ) = Just "ar-sy" fromBCP47' (Just (Lang "ar" _ "IQ" _)     ) = Just "ar-iq" fromBCP47' (Just (Lang "ar" _ "JO" _)     ) = Just "ar-jo"
src/Text/Pandoc/Writers/Custom.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances  #-} {-# LANGUAGE NoImplicitPrelude  #-}+{-# LANGUAGE OverloadedStrings  #-} {- |    Module      : Text.Pandoc.Writers.Custom    Copyright   : Copyright (C) 2012-2019 John MacFarlane@@ -17,35 +18,35 @@ import Control.Arrow ((***)) import Control.Exception import Control.Monad (when)-import Data.Char (toLower) import Data.List (intersperse) import qualified Data.Map as M+import qualified Data.Text as T import Data.Text (Text, pack) import Data.Typeable import Foreign.Lua (Lua, Pushable)+import Text.DocLayout (render, literal) import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition-import Text.Pandoc.Error import Text.Pandoc.Lua (Global (..), LuaException (LuaException),                         runLua, setGlobals) import Text.Pandoc.Lua.Util (addField, dofileWithTraceback) import Text.Pandoc.Options-import Text.Pandoc.Templates+import Text.Pandoc.Templates (renderTemplate) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Writers.Shared  import qualified Foreign.Lua as Lua -attrToMap :: Attr -> M.Map String String+attrToMap :: Attr -> M.Map T.Text T.Text attrToMap (id',classes,keyvals) = M.fromList     $ ("id", id')-    : ("class", unwords classes)+    : ("class", T.unwords classes)     : keyvals  newtype Stringify a = Stringify a  instance Pushable (Stringify Format) where-  push (Stringify (Format f)) = Lua.push (map toLower f)+  push (Stringify (Format f)) = Lua.push (T.toLower f)  instance Pushable (Stringify [Inline]) where   push (Stringify ils) = Lua.push =<< inlineListToCustom ils@@ -82,7 +83,7 @@     Lua.push v     Lua.rawset (Lua.nthFromTop 3) -data PandocLuaException = PandocLuaException String+data PandocLuaException = PandocLuaException Text     deriving (Show, Typeable)  instance Exception PandocLuaException@@ -99,22 +100,21 @@     -- check for error in lua script (later we'll change the return type     -- to handle this more gracefully):     when (stat /= Lua.OK) $-      Lua.tostring' (-1) >>= throw . PandocLuaException . UTF8.toString+      Lua.tostring' (-1) >>= throw . PandocLuaException . UTF8.toText     rendered <- docToCustom opts doc-    context <- metaToJSON opts-               blockListToCustom-               inlineListToCustom+    context <- metaToContext opts+               (fmap (literal . pack) . blockListToCustom)+               (fmap (literal . pack) . inlineListToCustom)                meta-    return (rendered, context)+    return (pack rendered, context)   let (body, context) = case res of         Left (LuaException msg) -> throw (PandocLuaException msg)         Right x -> x-  case writerTemplate opts of-       Nothing  -> return $ pack body-       Just tpl ->-         case applyTemplate (pack tpl) $ setField "body" body context of-              Left e  -> throw (PandocTemplateError e)-              Right r -> return (pack r)+  return $+    case writerTemplate opts of+       Nothing  -> body+       Just tpl -> render Nothing $+                    renderTemplate tpl $ setField "body" body context  docToCustom :: WriterOptions -> Pandoc -> Lua String docToCustom opts (Pandoc (Meta metamap) blocks) = do
src/Text/Pandoc/Writers/Docbook.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.Docbook    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -15,11 +16,10 @@ module Text.Pandoc.Writers.Docbook ( writeDocbook4, writeDocbook5 ) where import Prelude import Control.Monad.Reader-import Data.Char (toLower) import Data.Generics (everywhere, mkT)-import Data.List (isPrefixOf, isSuffixOf, stripPrefix) import Data.Monoid (Any (..)) import Data.Text (Text)+import qualified Data.Text as T import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition@@ -27,12 +27,12 @@ import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate)+import Text.Pandoc.Writers.Shared import Text.Pandoc.Walk import Text.Pandoc.Writers.Math-import Text.Pandoc.Writers.Shared import Text.Pandoc.XML import Text.TeXMath import qualified Text.XML.Light as Xml@@ -50,21 +50,21 @@                     then Just $ writerColumns opts                     else Nothing   return $ B.rawInline "docbook" $ render colwidth $-      if ',' `elem` name+      if T.any (== ',') name          then -- last name first-              let (lastname, rest) = break (==',') name+              let (lastname, rest) = T.break (==',') name                   firstname = triml rest in-              inTagsSimple "firstname" (text $ escapeStringForXML firstname) <>-              inTagsSimple "surname" (text $ escapeStringForXML lastname)+              inTagsSimple "firstname" (literal $ escapeStringForXML firstname) <>+              inTagsSimple "surname" (literal $ escapeStringForXML lastname)          else -- last name last-              let namewords = words name+              let namewords = T.words name                   lengthname = length namewords                   (firstname, lastname) = case lengthname of                     0 -> ("","")                     1 -> ("", name)-                    n -> (unwords (take (n-1) namewords), last namewords)-               in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$-                  inTagsSimple "surname" (text $ escapeStringForXML lastname)+                    n -> (T.unwords (take (n-1) namewords), last namewords)+               in inTagsSimple "firstname" (literal $ escapeStringForXML firstname) $$+                  inTagsSimple "surname" (literal $ escapeStringForXML lastname)  writeDocbook4 :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeDocbook4 opts d =@@ -77,72 +77,36 @@ -- | Convert Pandoc document to string in Docbook format. writeDocbook :: PandocMonad m => WriterOptions -> Pandoc -> DB m Text writeDocbook opts (Pandoc meta blocks) = do-  let elements = hierarchicalize blocks   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  let opts'    = if maybe False (("/book>" `isSuffixOf`) . trimr)-                            (writerTemplate opts) &&-                     TopLevelDefault == writerTopLevelDivision opts-                    then opts{ writerTopLevelDivision = TopLevelChapter }-                    else opts   -- The numbering here follows LaTeX's internal numbering-  let startLvl = case writerTopLevelDivision opts' of+  let startLvl = case writerTopLevelDivision opts of                    TopLevelPart    -> -1                    TopLevelChapter -> 0                    TopLevelSection -> 1                    TopLevelDefault -> 1+  let fromBlocks = blocksToDocbook opts .+                   makeSections False (Just startLvl)   auths' <- mapM (authorToDocbook opts) $ docAuthors meta   let meta' = B.setMeta "author" auths' meta-  metadata <- metaToJSON opts-                 (fmap (render' . vcat) .-                          mapM (elementToDocbook opts' startLvl) .-                            hierarchicalize)-                 (fmap render' . inlinesToDocbook opts')+  metadata <- metaToContext opts+                 (fromBlocks)+                 (inlinesToDocbook opts)                  meta'-  main <- (render' . vcat) <$> mapM (elementToDocbook opts' startLvl) elements+  main <- fromBlocks blocks   let context = defField "body" main-              $-                  defField "mathml" (case writerHTMLMathMethod opts of+              $ defField "mathml" (case writerHTMLMathMethod opts of                                           MathML -> True                                           _      -> False) metadata-  (if writerPreferAscii opts then toEntities else id) <$>+  return $ render colwidth $+    (if writerPreferAscii opts then fmap toEntities else id) $     case writerTemplate opts of-         Nothing  -> return main-         Just tpl -> renderTemplate' tpl context---- | Convert an Element to Docbook.-elementToDocbook :: PandocMonad m => WriterOptions -> Int -> Element -> DB m Doc-elementToDocbook opts _   (Blk block) = blockToDocbook opts block-elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) = do-  version <- ask-  -- Docbook doesn't allow sections with no content, so insert some if needed-  let elements' = if null elements-                    then [Blk (Para [])]-                    else elements-      tag = case lvl of-                 -1                   -> "part"-                 0                    -> "chapter"-                 n | n >= 1 && n <= 5 -> if version == DocBook5-                                              then "section"-                                              else "sect" ++ show n-                 _                    -> "simplesect"-      idName = if version == DocBook5-                 then "xml:id"-                 else "id"-      idAttr = [(idName, writerIdentifierPrefix opts ++ id') | not (null id')]-      nsAttr = if version == DocBook5 && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")]-                                      else []-      attribs = nsAttr ++ idAttr-  contents <- mapM (elementToDocbook opts (lvl + 1)) elements'-  title' <- inlinesToDocbook opts title-  return $ inTags True tag attribs $-      inTagsSimple "title" title' $$ vcat contents+         Nothing  -> main+         Just tpl -> renderTemplate tpl context  -- | Convert a list of Pandoc blocks to Docbook.-blocksToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m Doc+blocksToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m (Doc Text) blocksToDocbook opts = fmap vcat . mapM (blockToDocbook opts)  -- | Auxiliary function to convert Plain block to Para.@@ -153,13 +117,13 @@ -- | Convert a list of pairs of terms and definitions into a list of -- Docbook varlistentrys. deflistItemsToDocbook :: PandocMonad m-                      => WriterOptions -> [([Inline],[[Block]])] -> DB m Doc+                      => WriterOptions -> [([Inline],[[Block]])] -> DB m (Doc Text) deflistItemsToDocbook opts items =   vcat <$> mapM (uncurry (deflistItemToDocbook opts)) items  -- | Convert a term and a list of blocks into a Docbook varlistentry. deflistItemToDocbook :: PandocMonad m-                     => WriterOptions -> [Inline] -> [[Block]] -> DB m Doc+                     => WriterOptions -> [Inline] -> [[Block]] -> DB m (Doc Text) deflistItemToDocbook opts term defs = do   term' <- inlinesToDocbook opts term   def' <- blocksToDocbook opts $ concatMap (map plainToPara) defs@@ -168,30 +132,53 @@       inTagsIndented "listitem" def'  -- | Convert a list of lists of blocks to a list of Docbook list items.-listItemsToDocbook :: PandocMonad m => WriterOptions -> [[Block]] -> DB m Doc+listItemsToDocbook :: PandocMonad m => WriterOptions -> [[Block]] -> DB m (Doc Text) listItemsToDocbook opts items = vcat <$> mapM (listItemToDocbook opts) items  -- | Convert a list of blocks into a Docbook list item.-listItemToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m Doc+listItemToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m (Doc Text) listItemToDocbook opts item =   inTagsIndented "listitem" <$> blocksToDocbook opts (map plainToPara item) -imageToDocbook :: WriterOptions -> Attr -> String -> Doc+imageToDocbook :: WriterOptions -> Attr -> Text -> Doc Text imageToDocbook _ attr src = selfClosingTag "imagedata" $-  ("fileref", src) : idAndRole attr ++ dims+  ("fileref", src) : idAndRole attr <> dims   where-    dims = go Width "width" ++ go Height "depth"+    dims = go Width "width" <> go Height "depth"     go dir dstr = case dimension dir attr of-                    Just a  -> [(dstr, show a)]+                    Just a  -> [(dstr, tshow a)]                     Nothing -> []  -- | Convert a Pandoc block element to Docbook.-blockToDocbook :: PandocMonad m => WriterOptions -> Block -> DB m Doc+blockToDocbook :: PandocMonad m => WriterOptions -> Block -> DB m (Doc Text) blockToDocbook _ Null = return empty -- Add ids to paragraphs in divs with ids - this is needed for -- pandoc-citeproc to get link anchors in bibliographies:+blockToDocbook opts (Div (id',"section":_,_) (Header lvl _ ils : xs)) = do+  version <- ask+  -- Docbook doesn't allow sections with no content, so insert some if needed+  let bs = if null xs+              then [Para []]+              else xs+      tag = case lvl of+                 -1                   -> "part"+                 0                    -> "chapter"+                 n | n >= 1 && n <= 5 -> if version == DocBook5+                                              then "section"+                                              else "sect" <> tshow n+                 _                    -> "simplesect"+      idName = if version == DocBook5+                 then "xml:id"+                 else "id"+      idAttr = [(idName, writerIdentifierPrefix opts <> id') | not (T.null id')]+      nsAttr = if version == DocBook5 && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")]+                                      else []+      attribs = nsAttr <> idAttr+  title' <- inlinesToDocbook opts ils+  contents <- blocksToDocbook opts bs+  return $ inTags True tag attribs $ inTagsSimple "title" title' $$ contents blockToDocbook opts (Div (ident,_,_) [Para lst]) =-  let attribs = [("id", ident) | not (null ident)] in+  let attribs = [("id", ident) | not (T.null ident)] in   if hasLineBreaks lst      then (flush . nowrap . inTags False "literallayout" attribs)                          <$> inlinesToDocbook opts lst@@ -199,16 +186,16 @@ blockToDocbook opts (Div (ident,_,_) bs) = do   contents <- blocksToDocbook opts (map plainToPara bs)   return $-    (if null ident+    (if T.null ident         then mempty         else selfClosingTag "anchor" [("id", ident)]) $$ contents blockToDocbook _ h@Header{} = do-  -- should not occur after hierarchicalize, except inside lists/blockquotes+  -- should be handled by Div section above, except inside lists/blockquotes   report $ BlockNotRendered h   return empty blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst -- title beginning with fig: indicates that the image is a figure-blockToDocbook opts (Para [Image attr txt (src,'f':'i':'g':':':_)]) = do+blockToDocbook opts (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just _)]) = do   alt <- inlinesToDocbook opts txt   let capt = if null txt                 then empty@@ -228,16 +215,16 @@ blockToDocbook opts (BlockQuote blocks) =   inTagsIndented "blockquote" <$> blocksToDocbook opts blocks blockToDocbook _ (CodeBlock (_,classes,_) str) = return $-  text ("<programlisting" ++ lang ++ ">") <> cr <>-     flush (text (escapeStringForXML str) <> cr <> text "</programlisting>")+  literal ("<programlisting" <> lang <> ">") <> cr <>+     flush (literal (escapeStringForXML str) <> cr <> literal "</programlisting>")     where lang  = if null langs                      then ""-                     else " language=\"" ++ escapeStringForXML (head langs) +++                     else " language=\"" <> escapeStringForXML (head langs) <>                           "\""-          isLang l    = map toLower l `elem` map (map toLower) languages+          isLang l    = T.toLower l `elem` map T.toLower languages           langsFrom s = if isLang s                            then [s]-                           else languagesByExtension . map toLower $ s+                           else languagesByExtension . T.toLower $ s           langs       = concatMap langsFrom classes blockToDocbook opts (BulletList lst) = do   let attribs = [("spacing", "compact") | isTightList lst]@@ -253,26 +240,26 @@                        UpperRoman   -> [("numeration", "upperroman")]                        LowerRoman   -> [("numeration", "lowerroman")]       spacing    = [("spacing", "compact") | isTightList (first:rest)]-      attribs    = numeration ++ spacing+      attribs    = numeration <> spacing   items <- if start == 1               then listItemsToDocbook opts (first:rest)               else do                 first' <- blocksToDocbook opts (map plainToPara first)                 rest' <- listItemsToDocbook opts rest                 return $-                  inTags True "listitem" [("override",show start)] first' $$+                  inTags True "listitem" [("override",tshow start)] first' $$                    rest'   return $ inTags True "orderedlist" attribs items blockToDocbook opts (DefinitionList lst) = do   let attribs = [("spacing", "compact") | isTightList $ concatMap snd lst]   inTags True "variablelist" attribs <$> deflistItemsToDocbook opts lst blockToDocbook _ b@(RawBlock f str)-  | f == "docbook" = return $ text str -- raw XML block+  | f == "docbook" = return $ literal str -- raw XML block   | f == "html"    = do                      version <- ask                      if version == DocBook5                         then return empty -- No html in Docbook5-                        else return $ text str -- allow html for backwards compatibility+                        else return $ literal str -- allow html for backwards compatibility   | otherwise      = do       report $ BlockNotRendered b       return empty@@ -283,9 +270,9 @@                    else inTagsIndented "title" <$>                          inlinesToDocbook opts caption   let tableType    = if isEmpty captionDoc then "informaltable" else "table"-      percent w    = show (truncate (100*w) :: Integer) ++ "*"+      percent w    = tshow (truncate (100*w) :: Integer) <> "*"       coltags = vcat $ zipWith (\w al -> selfClosingTag "colspec"-                       ([("colwidth", percent w) | w > 0] +++                       ([("colwidth", percent w) | w > 0] <>                         [("align", alignmentToString al)])) widths aligns   head' <- if all null headers               then return empty@@ -293,7 +280,7 @@   body' <- (inTagsIndented "tbody" . vcat) <$>               mapM (tableRowToDocbook opts) rows   return $ inTagsIndented tableType $ captionDoc $$-        inTags True "tgroup" [("cols", show (length headers))] (+        inTags True "tgroup" [("cols", tshow (length headers))] (          coltags $$ head' $$ body')  hasLineBreaks :: [Inline] -> Bool@@ -306,7 +293,7 @@     isLineBreak LineBreak = Any True     isLineBreak _         = Any False -alignmentToString :: Alignment -> [Char]+alignmentToString :: Alignment -> Text alignmentToString alignment = case alignment of                                  AlignLeft    -> "left"                                  AlignRight   -> "right"@@ -316,24 +303,24 @@ tableRowToDocbook :: PandocMonad m                   => WriterOptions                   -> [[Block]]-                  -> DB m Doc+                  -> DB m (Doc Text) tableRowToDocbook opts cols =   (inTagsIndented "row" . vcat) <$> mapM (tableItemToDocbook opts) cols  tableItemToDocbook :: PandocMonad m                    => WriterOptions                    -> [Block]-                   -> DB m Doc+                   -> DB m (Doc Text) tableItemToDocbook opts item =   (inTags True "entry" [] . vcat) <$> mapM (blockToDocbook opts) item  -- | Convert a list of inline elements to Docbook.-inlinesToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> DB m Doc+inlinesToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> DB m (Doc Text) inlinesToDocbook opts lst = hcat <$> mapM (inlineToDocbook opts) lst  -- | Convert an inline element to Docbook.-inlineToDocbook :: PandocMonad m => WriterOptions -> Inline -> DB m Doc-inlineToDocbook _ (Str str) = return $ text $ escapeStringForXML str+inlineToDocbook :: PandocMonad m => WriterOptions -> Inline -> DB m (Doc Text)+inlineToDocbook _ (Str str) = return $ literal $ escapeStringForXML str inlineToDocbook opts (Emph lst) =   inTagsSimple "emphasis" <$> inlinesToDocbook opts lst inlineToDocbook opts (Strong lst) =@@ -353,18 +340,18 @@ inlineToDocbook opts (Cite _ lst) =   inlinesToDocbook opts lst inlineToDocbook opts (Span (ident,_,_) ils) =-  ((if null ident+  ((if T.null ident        then mempty        else selfClosingTag "anchor" [("id", ident)]) <>) <$>   inlinesToDocbook opts ils inlineToDocbook _ (Code _ str) =-  return $ inTagsSimple "literal" $ text (escapeStringForXML str)+  return $ inTagsSimple "literal" $ literal (escapeStringForXML str) inlineToDocbook opts (Math t str)   | isMathML (writerHTMLMathMethod opts) = do     res <- convertMath writeMathML t str     case res of          Right r  -> return $ inTagsSimple tagtype-                     $ text $ Xml.ppcElement conf+                     $ literal $ T.pack $ Xml.ppcElement conf                      $ fixNS                      $ removeAttr r          Left il  -> inlineToDocbook opts il@@ -378,19 +365,19 @@            fixNS' qname = qname{ Xml.qPrefix = Just "mml" }            fixNS = everywhere (mkT fixNS') inlineToDocbook _ il@(RawInline f x)-  | f == "html" || f == "docbook" = return $ text x+  | f == "html" || f == "docbook" = return $ literal x   | otherwise                     = do       report $ InlineNotRendered il       return empty-inlineToDocbook _ LineBreak = return $ text "\n"+inlineToDocbook _ LineBreak = return $ literal "\n" -- currently ignore, would require the option to add custom -- styles to the document inlineToDocbook _ Space = return space -- because we use \n for LineBreak, we can't do soft breaks: inlineToDocbook _ SoftBreak = return space inlineToDocbook opts (Link attr txt (src, _))-  | Just email <- stripPrefix "mailto:" src =-      let emailLink = inTagsSimple "email" $ text $+  | Just email <- T.stripPrefix "mailto:" src =+      let emailLink = inTagsSimple "email" $ literal $                       escapeStringForXML email       in  case txt of            [Str s] | escapeURI s == email -> return emailLink@@ -399,17 +386,17 @@                                           char '(' <> emailLink <> char ')'   | otherwise = do       version <- ask-      (if "#" `isPrefixOf` src-            then inTags False "link" $ ("linkend", writerIdentifierPrefix opts ++ drop 1 src) : idAndRole attr+      (if "#" `T.isPrefixOf` src+            then inTags False "link" $ ("linkend", writerIdentifierPrefix opts <> T.drop 1 src) : idAndRole attr             else if version == DocBook5                     then inTags False "link" $ ("xlink:href", src) : idAndRole attr                     else inTags False "ulink" $ ("url", src) : idAndRole attr )         <$> inlinesToDocbook opts txt inlineToDocbook opts (Image attr _ (src, tit)) = return $-  let titleDoc = if null tit+  let titleDoc = if T.null tit                    then empty                    else inTagsIndented "objectinfo" $-                        inTagsIndented "title" (text $ escapeStringForXML tit)+                        inTagsIndented "title" (literal $ escapeStringForXML tit)   in  inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $       titleDoc $$ imageToDocbook opts attr src inlineToDocbook opts (Note contents) =@@ -419,12 +406,12 @@ isMathML MathML = True isMathML _      = False -idAndRole :: Attr -> [(String, String)]-idAndRole (id',cls,_) = ident ++ role+idAndRole :: Attr -> [(Text, Text)]+idAndRole (id',cls,_) = ident <> role   where-    ident = if null id'+    ident = if T.null id'                then []                else [("id", id')]     role  = if null cls                then []-               else [("role", unwords cls)]+               else [("role", T.unwords cls)]
src/Text/Pandoc/Writers/Docx.hs view
@@ -3,6 +3,8 @@ {-# LANGUAGE RankNTypes          #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns        #-}+{-# LANGUAGE FlexibleContexts    #-}+{-# LANGUAGE OverloadedStrings   #-} {- |    Module      : Text.Pandoc.Writers.Docx    Copyright   : Copyright (C) 2012-2019 John MacFarlane@@ -18,17 +20,19 @@ import Prelude import Codec.Archive.Zip import Control.Applicative ((<|>))-import Control.Monad.Except (catchError)+import Control.Monad.Except (catchError, throwError) import Control.Monad.Reader import Control.Monad.State.Strict import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL-import Data.Char (isSpace, ord, toLower, isLetter)+import Data.Char (isSpace, ord, isLetter) import Data.List (intercalate, isPrefixOf, isSuffixOf)+import Data.String (fromString) import qualified Data.Map as M import Data.Maybe (fromMaybe, isNothing, mapMaybe, maybeToList) import qualified Data.Set as Set import qualified Data.Text as T+import qualified Data.Text.Lazy as TL import Data.Time.Clock.POSIX import Data.Digest.Pure.SHA (sha1, showDigest) import Skylighting@@ -37,17 +41,18 @@ import Text.Pandoc.Class (PandocMonad, report, toLang) import qualified Text.Pandoc.Class as P import Data.Time-import Text.Pandoc.UTF8 (fromStringLazy)+import Text.Pandoc.UTF8 (fromTextLazy) import Text.Pandoc.Definition import Text.Pandoc.Generic import Text.Pandoc.Highlighting (highlight)+import Text.Pandoc.Error import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType,                          getMimeTypeDef) import Text.Pandoc.Options-import Text.Pandoc.Readers.Docx.StyleMap-import Text.Pandoc.Shared hiding (Element)+import Text.Pandoc.Writers.Docx.StyleMap+import Text.Pandoc.Shared import Text.Pandoc.Walk import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared@@ -81,20 +86,36 @@                       OneParen     -> '2'                       TwoParens    -> '3' -data WriterEnv = WriterEnv{ envTextProperties :: [Element]-                          , envParaProperties :: [Element]+data EnvProps = EnvProps{ styleElement  :: Maybe Element+                        , otherElements :: [Element]+                        }++instance Semigroup EnvProps where+  EnvProps Nothing es <> EnvProps s es' = EnvProps s (es ++ es')+  EnvProps s       es <> EnvProps _ es' = EnvProps s (es ++ es')++instance Monoid EnvProps where+  mempty = EnvProps Nothing []+  mappend = (<>)++squashProps :: EnvProps -> [Element]+squashProps (EnvProps Nothing es) = es+squashProps (EnvProps (Just e) es) = e : es++data WriterEnv = WriterEnv{ envTextProperties :: EnvProps+                          , envParaProperties :: EnvProps                           , envRTL            :: Bool                           , envListLevel      :: Int                           , envListNumId      :: Int                           , envInDel          :: Bool-                          , envChangesAuthor  :: String-                          , envChangesDate    :: String+                          , envChangesAuthor  :: T.Text+                          , envChangesDate    :: T.Text                           , envPrintWidth     :: Integer                           }  defaultWriterEnv :: WriterEnv-defaultWriterEnv = WriterEnv{ envTextProperties = []-                            , envParaProperties = []+defaultWriterEnv = WriterEnv{ envTextProperties = mempty+                            , envParaProperties = mempty                             , envRTL = False                             , envListLevel = -1                             , envListNumId = 1@@ -106,8 +127,8 @@  data WriterState = WriterState{          stFootnotes      :: [Element]-       , stComments       :: [([(String,String)], [Inline])]-       , stSectionIds     :: Set.Set String+       , stComments       :: [([(T.Text, T.Text)], [Inline])]+       , stSectionIds     :: Set.Set T.Text        , stExternalLinks  :: M.Map String String        , stImages         :: M.Map FilePath (String, String, Maybe MimeType, B.ByteString)        , stLists          :: [ListMarker]@@ -115,9 +136,10 @@        , stDelId          :: Int        , stStyleMaps      :: StyleMaps        , stFirstPara      :: Bool+       , stInTable        :: Bool        , stTocTitle       :: [Inline]-       , stDynamicParaProps :: Set.Set String-       , stDynamicTextProps :: Set.Set String+       , stDynamicParaProps :: Set.Set ParaStyleName+       , stDynamicTextProps :: Set.Set CharStyleName        , stCurId          :: Int        } @@ -131,8 +153,9 @@       , stLists          = [NoMarker]       , stInsId          = 1       , stDelId          = 1-      , stStyleMaps      = defaultStyleMaps+      , stStyleMaps      = StyleMaps M.empty M.empty       , stFirstPara      = False+      , stInTable        = False       , stTocTitle       = [Str "Table of Contents"]       , stDynamicParaProps = Set.empty       , stDynamicTextProps = Set.empty@@ -141,7 +164,6 @@  type WS m = ReaderT WriterEnv (StateT WriterState m) - renumIdMap :: Int -> [Element] -> M.Map String String renumIdMap _ [] = M.empty renumIdMap n (e:es)@@ -167,10 +189,16 @@ renumIds :: (QName -> Bool) -> M.Map String String -> [Element] -> [Element] renumIds f renumMap = map (renumId f renumMap) +findAttrTextBy :: (QName -> Bool) -> Element -> Maybe T.Text+findAttrTextBy x = fmap T.pack . findAttrBy x++lookupAttrTextBy :: (QName -> Bool) -> [XML.Attr] -> Maybe T.Text+lookupAttrTextBy x = fmap T.pack . lookupAttrBy x+ -- | Certain characters are invalid in XML even if escaped. -- See #1992-stripInvalidChars :: String -> String-stripInvalidChars = filter isValidChar+stripInvalidChars :: T.Text -> T.Text+stripInvalidChars = T.filter isValidChar  -- | See XML reference isValidChar :: Char -> Bool@@ -191,7 +219,7 @@   let doc' = walk fixDisplayMath doc   username <- P.lookupEnv "USERNAME"   utctime <- P.getCurrentTime-  distArchive <- (toArchive . BL.fromStrict) <$> do+  distArchive <- toArchive . BL.fromStrict <$> do     oldUserDataDir <- P.getUserDataDir     P.setUserDataDir Nothing     res <- P.readDefaultDataFile "reference.docx"@@ -199,7 +227,7 @@     return res   refArchive <- case writerReferenceDoc opts of                      Just f  -> toArchive <$> P.readFileLazy f-                     Nothing -> (toArchive . BL.fromStrict) <$>+                     Nothing -> toArchive . BL.fromStrict <$>                         P.readDataFile "reference.docx"    parsedDoc <- parseXml refArchive distArchive "word/document.xml"@@ -208,11 +236,11 @@    -- Gets the template size   let mbpgsz = mbsectpr >>= filterElementName (wname (=="pgSz"))-  let mbAttrSzWidth = (elAttribs <$> mbpgsz) >>= lookupAttrBy ((=="w") . qName)+  let mbAttrSzWidth = (elAttribs <$> mbpgsz) >>= lookupAttrTextBy ((=="w") . qName)    let mbpgmar = mbsectpr >>= filterElementName (wname (=="pgMar"))-  let mbAttrMarLeft = (elAttribs <$> mbpgmar) >>= lookupAttrBy ((=="left") . qName)-  let mbAttrMarRight = (elAttribs <$> mbpgmar) >>= lookupAttrBy ((=="right") . qName)+  let mbAttrMarLeft = (elAttribs <$> mbpgmar) >>= lookupAttrTextBy ((=="left") . qName)+  let mbAttrMarRight = (elAttribs <$> mbpgmar) >>= lookupAttrTextBy ((=="right") . qName)    -- Get the available area (converting the size and the margins to int and   -- doing the difference@@ -220,13 +248,13 @@                        >>= subtrct mbAttrMarRight                        >>= subtrct mbAttrMarLeft         where-          subtrct mbStr = \x -> mbStr >>= safeRead >>= (\y -> Just $ x - y)+          subtrct mbStr x = mbStr >>= safeRead >>= (\y -> Just $ x - y)    -- styles   mblang <- toLang $ getLang opts meta   let addLang :: Element -> Element       addLang e = case mblang >>= \l ->-                         (return . XMLC.toTree . go (renderLang l)+                         (return . XMLC.toTree . go (T.unpack $ renderLang l)                                  . XMLC.fromElement) e of                     Just (Elem e') -> e'                     _              -> e -- return original@@ -248,7 +276,7 @@   styledoc <- addLang <$> parseXml refArchive distArchive stylepath    -- parse styledoc for heading styles-  let styleMaps = getStyleMaps styledoc+  let styleMaps = getStyleMaps refArchive    let tocTitle = case lookupMetaInlines "toc-title" meta of                    [] -> stTocTitle defaultWriterState@@ -267,8 +295,8 @@   let env = defaultWriterEnv {           envRTL = isRTLmeta         , envChangesAuthor = fromMaybe "unknown" username-        , envChangesDate   = formatTime defaultTimeLocale "%FT%XZ" utctime-        , envPrintWidth = maybe 420 (\x -> quot x 20) pgContentWidth+        , envChangesDate   = T.pack $ formatTime defaultTimeLocale "%FT%XZ" utctime+        , envPrintWidth = maybe 420 (`quot` 20) pgContentWidth         }  @@ -315,9 +343,9 @@                [("PartName",part'),("ContentType",contentType')] ()   let mkImageOverride (_, imgpath, mbMimeType, _) =           mkOverrideNode ("/word/" ++ imgpath,-                          fromMaybe "application/octet-stream" mbMimeType)+                          maybe "application/octet-stream" T.unpack mbMimeType)   let mkMediaOverride imgpath =-          mkOverrideNode ('/':imgpath, getMimeTypeDef imgpath)+          mkOverrideNode ('/':imgpath, T.unpack $ getMimeTypeDef imgpath)   let overrides = map mkOverrideNode (                   [("/word/webSettings.xml",                     "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml")@@ -349,7 +377,7 @@                   map (\x -> (maybe "" ("/word/" ++) $ extractTarget x,                        "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++                     map mkImageOverride imgs ++-                    map mkMediaOverride [ eRelativePath e | e <- zEntries refArchive+                    [ mkMediaOverride (eRelativePath e) | e <- zEntries refArchive                                         , "word/media/" `isPrefixOf` eRelativePath e ]    let defaultnodes = [mknode "Default"@@ -445,11 +473,11 @@   -- are not already in the style map. Note that keys in the stylemap   -- are normalized as lowercase.   let newDynamicParaProps = filter-        (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sParaStyleMap styleMaps)+        (\sty -> not $ hasStyleName sty $ smParaStyle styleMaps)         (Set.toList $ stDynamicParaProps st)        newDynamicTextProps = filter-        (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sCharStyleMap styleMaps)+        (\sty -> not $ hasStyleName sty $ smCharStyle styleMaps)         (Set.toList $ stDynamicTextProps st)    let newstyles = map newParaPropToOpenXml newDynamicParaProps ++@@ -466,10 +494,10 @@   numbering <- parseXml refArchive distArchive numpath   newNumElts <- mkNumbering (stLists st)   let pandocAdded e =-       case findAttrBy ((== "abstractNumId") . qName) e >>= safeRead of+       case findAttrTextBy ((== "abstractNumId") . qName) e >>= safeRead of          Just numid -> numid >= (990 :: Int)          Nothing    ->-           case findAttrBy ((== "numId") . qName) e >>= safeRead of+           case findAttrTextBy ((== "numId") . qName) e >>= safeRead of              Just numid -> numid >= (1000 :: Int)              Nothing    -> False   let oldElts = filter (not . pandocAdded) $ onlyElems (elContent numbering)@@ -491,23 +519,23 @@   let extraCoreProps = ["subject","lang","category","description"]   let extraCorePropsMap = M.fromList $ zip extraCoreProps                        ["dc:subject","dc:language","cp:category","dc:description"]-  let lookupMetaString' :: String -> Meta -> String+  let lookupMetaString' :: T.Text -> Meta -> T.Text       lookupMetaString' key' meta' =         case key' of-             "description"    -> intercalate "_x000d_\n" (map stringify $ lookupMetaBlocks "description" meta')-             _                -> lookupMetaString key' meta'-  +             "description"    -> T.intercalate "_x000d_\n" (map stringify $ lookupMetaBlocks "description" meta')+             key''            -> lookupMetaString key'' meta'+   let docProps = mknode "cp:coreProperties"           [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties")           ,("xmlns:dc","http://purl.org/dc/elements/1.1/")           ,("xmlns:dcterms","http://purl.org/dc/terms/")           ,("xmlns:dcmitype","http://purl.org/dc/dcmitype/")           ,("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")]-          $ mknode "dc:title" [] (stringify $ docTitle meta)-          : mknode "dc:creator" [] (intercalate "; " (map stringify $ docAuthors meta))-          : [ mknode (M.findWithDefault "" k extraCorePropsMap) [] (lookupMetaString' k meta)+          $ mktnode "dc:title" [] (stringify $ docTitle meta)+          : mktnode "dc:creator" [] (T.intercalate "; " (map stringify $ docAuthors meta))+          : [ mktnode (M.findWithDefault "" k extraCorePropsMap) [] (lookupMetaString' k meta)             | k <- M.keys (unMeta meta), k `elem` extraCoreProps]-          ++ mknode "cp:keywords" [] (intercalate ", " keywords)+          ++ mknode "cp:keywords" [] (T.unpack $ T.intercalate ", " keywords)           : (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] x                    , mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] x                    ]) (formatTime defaultTimeLocale "%FT%XZ" utctime)@@ -515,7 +543,7 @@    -- docProps/custom.xml   let customProperties :: [(String, String)]-      customProperties = [(k, lookupMetaString k meta) | k <- M.keys (unMeta meta)+      customProperties = [(T.unpack k, T.unpack $ lookupMetaString k meta) | k <- M.keys (unMeta meta)                          , k `notElem` (["title", "author", "keywords"]                                        ++ extraCoreProps)]   let mkCustomProp (k, v) pid = mknode "property"@@ -556,11 +584,13 @@                      , "w:hyphenationZone"                      , "w:doNotHyphenateCap"                      , "w:evenAndOddHeaders"+                     , "w:proofState"                      ]   settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList    let entryFromArchive arch path =-         maybe (fail $ path ++ " missing in reference docx")+         maybe (throwError $ PandocSomeError+                           $ T.pack $ path ++ " missing in reference docx")                return                (findEntryByPath path arch `mplus` findEntryByPath path distArchive)   docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"@@ -571,8 +601,8 @@                      mapMaybe (fmap ("word/" ++) . extractTarget)                      (headers ++ footers)   let miscRelEntries = [ e | e <- zEntries refArchive-                       , "word/_rels/" `isPrefixOf` (eRelativePath e)-                       , ".xml.rels" `isSuffixOf` (eRelativePath e)+                       , "word/_rels/" `isPrefixOf` eRelativePath e+                       , ".xml.rels" `isSuffixOf` eRelativePath e                        , eRelativePath e /= "word/_rels/document.xml.rels"                        , eRelativePath e /= "word/_rels/footnotes.xml.rels" ]   let otherMediaEntries = [ e | e <- zEntries refArchive@@ -590,25 +620,24 @@                   miscRelEntries ++ otherMediaEntries   return $ fromArchive archive --newParaPropToOpenXml :: String -> Element-newParaPropToOpenXml s =-  let styleId = filter (not . isSpace) s+newParaPropToOpenXml :: ParaStyleName -> Element+newParaPropToOpenXml (fromStyleName -> s) =+  let styleId = T.filter (not . isSpace) s   in mknode "w:style" [ ("w:type", "paragraph")                       , ("w:customStyle", "1")-                      , ("w:styleId", styleId)]-     [ mknode "w:name" [("w:val", s)] ()+                      , ("w:styleId", T.unpack styleId)]+     [ mknode "w:name" [("w:val", T.unpack s)] ()      , mknode "w:basedOn" [("w:val","BodyText")] ()      , mknode "w:qFormat" [] ()      ] -newTextPropToOpenXml :: String -> Element-newTextPropToOpenXml s =-  let styleId = filter (not . isSpace) s+newTextPropToOpenXml :: CharStyleName -> Element+newTextPropToOpenXml (fromStyleName -> s) =+  let styleId = T.filter (not . isSpace) s   in mknode "w:style" [ ("w:type", "character")                       , ("w:customStyle", "1")-                      , ("w:styleId", styleId)]-     [ mknode "w:name" [("w:val", s)] ()+                      , ("w:styleId", T.unpack styleId)]+     [ mknode "w:name" [("w:val", T.unpack s)] ()      , mknode "w:basedOn" [("w:val","BodyTextChar")] ()      ] @@ -616,7 +645,7 @@ styleToOpenXml sm style =   maybeToList parStyle ++ mapMaybe toStyle alltoktypes   where alltoktypes = enumFromTo KeywordTok NormalTok-        toStyle toktype | hasStyleName (show toktype) (sCharStyleMap sm) = Nothing+        toStyle toktype | hasStyleName (fromString $ show toktype) (smCharStyle sm) = Nothing                         | otherwise = Just $                           mknode "w:style" [("w:type","character"),                            ("w:customStyle","1"),("w:styleId",show toktype)]@@ -639,7 +668,7 @@         tokBg toktype = maybe "auto" (drop 1 . fromColor)                          $ (tokenBackground =<< M.lookup toktype tokStyles)                            `mplus` backgroundColor style-        parStyle | hasStyleName "Source Code" (sParaStyleMap sm) = Nothing+        parStyle | hasStyleName "Source Code" (smParaStyle sm) = Nothing                  | otherwise = Just $                    mknode "w:style" [("w:type","paragraph"),                            ("w:customStyle","1"),("w:styleId","SourceCode")]@@ -760,24 +789,24 @@   tocTitle <- gets stTocTitle   title <- withParaPropM (pStyleM "TOC Heading") (blocksToOpenXML opts [Para tocTitle])   return-    [mknode "w:sdt" [] ([+    [mknode "w:sdt" [] [       mknode "w:sdtPr" [] (-        mknode "w:docPartObj" [] (+        mknode "w:docPartObj" []           [mknode "w:docPartGallery" [("w:val","Table of Contents")] (),           mknode "w:docPartUnique" [] ()]-        ) -- w:docPartObj+         -- w:docPartObj       ), -- w:sdtPr       mknode "w:sdtContent" [] (title++[         mknode "w:p" [] (-          mknode "w:r" [] ([+          mknode "w:r" [] [             mknode "w:fldChar" [("w:fldCharType","begin"),("w:dirty","true")] (),             mknode "w:instrText" [("xml:space","preserve")] tocCmd,             mknode "w:fldChar" [("w:fldCharType","separate")] (),             mknode "w:fldChar" [("w:fldCharType","end")] ()-          ]) -- w:r+          ] -- w:r         ) -- w:p       ])-    ])] -- w:sdt+    ]] -- w:sdt  -- | Convert Pandoc document to two lists of -- OpenXML elements (the main document and footnotes).@@ -791,14 +820,14 @@   let includeTOC = writerTableOfContents opts || lookupMetaBool "toc" meta   title <- withParaPropM (pStyleM "Title") $ blocksToOpenXML opts [Para tit | not (null tit)]   subtitle <- withParaPropM (pStyleM "Subtitle") $ blocksToOpenXML opts [Para subtitle' | not (null subtitle')]-  authors <- withParaProp (pCustomStyle "Author") $ blocksToOpenXML opts $+  authors <- withParaPropM (pStyleM "Author") $ blocksToOpenXML opts $        map Para auths   date <- withParaPropM (pStyleM "Date") $ blocksToOpenXML opts [Para dat | not (null dat)]   abstract <- if null abstract'                  then return []-                 else withParaProp (pCustomStyle "Abstract") $ blocksToOpenXML opts abstract'-  let convertSpace (Str x : Space : Str y : xs) = Str (x ++ " " ++ y) : xs-      convertSpace (Str x : Str y : xs)         = Str (x ++ y) : xs+                 else withParaPropM (pStyleM "Abstract") $ blocksToOpenXML opts abstract'+  let convertSpace (Str x : Space : Str y : xs) = Str (x <> " " <> y) : xs+      convertSpace (Str x : Str y : xs)         = Str (x <> y) : xs       convertSpace xs                           = xs   let blocks' = bottomUp convertSpace blocks   doc' <- setFirstPara >> blocksToOpenXML opts blocks'@@ -807,7 +836,7 @@   let toComment (kvs, ils) = do         annotation <- inlinesToOpenXML opts ils         return $-          mknode "w:comment" [('w':':':k,v) | (k,v) <- kvs]+          mknode "w:comment" [('w':':':T.unpack k,T.unpack v) | (k,v) <- kvs]             [ mknode "w:p" [] $               [ mknode "w:pPr" []                 [ mknode "w:pStyle" [("w:val", "CommentText")] () ]@@ -830,23 +859,17 @@ blocksToOpenXML :: (PandocMonad m) => WriterOptions -> [Block] -> WS m [Element] blocksToOpenXML opts bls = concat `fmap` mapM (blockToOpenXML opts) bls -pCustomStyle :: String -> Element-pCustomStyle sty = mknode "w:pStyle" [("w:val",sty)] ()--pStyleM :: (PandocMonad m) => String -> WS m XML.Element+pStyleM :: (PandocMonad m) => ParaStyleName -> WS m XML.Element pStyleM styleName = do-  styleMaps <- gets stStyleMaps-  let sty' = getStyleId styleName $ sParaStyleMap styleMaps-  return $ mknode "w:pStyle" [("w:val",sty')] ()--rCustomStyle :: String -> Element-rCustomStyle sty = mknode "w:rStyle" [("w:val",sty)] ()+  pStyleMap <- gets (smParaStyle . stStyleMaps)+  let sty' = getStyleIdFromName styleName pStyleMap+  return $ mknode "w:pStyle" [("w:val", T.unpack $ fromStyleId sty')] () -rStyleM :: (PandocMonad m) => String -> WS m XML.Element+rStyleM :: (PandocMonad m) => CharStyleName -> WS m XML.Element rStyleM styleName = do-  styleMaps <- gets stStyleMaps-  let sty' = getStyleId styleName $ sCharStyleMap styleMaps-  return $ mknode "w:rStyle" [("w:val",sty')] ()+  cStyleMap <- gets (smCharStyle . stStyleMaps)+  let sty' = getStyleIdFromName styleName cStyleMap+  return $ mknode "w:rStyle" [("w:val", T.unpack $ fromStyleId sty')] ()  getUniqueId :: (PandocMonad m) => WS m String -- the + 20 is to ensure that there are no clashes with the rIds@@ -857,7 +880,7 @@   return $ show n  -- | Key for specifying user-defined docx styles.-dynamicStyleKey :: String+dynamicStyleKey :: T.Text dynamicStyleKey = "custom-style"  -- | Convert a Pandoc block element to OpenXML.@@ -868,7 +891,7 @@ blockToOpenXML' _ Null = return [] blockToOpenXML' opts (Div (ident,_classes,kvs) bs) = do   stylemod <- case lookup dynamicStyleKey kvs of-                   Just sty -> do+                   Just (fromString . T.unpack -> sty) -> do                       modify $ \s ->                         s{stDynamicParaProps = Set.insert sty                              (stDynamicParaProps s)}@@ -886,32 +909,35 @@                   else id   header <- dirmod $ stylemod $ blocksToOpenXML opts hs   contents <- dirmod $ bibmod $ stylemod $ blocksToOpenXML opts bs'-  wrapBookmark ident $ header ++ contents+  wrapBookmark ident $ header <> contents blockToOpenXML' opts (Header lev (ident,_,_) lst) = do   setFirstPara-  paraProps <- withParaPropM (pStyleM ("Heading "++show lev)) $+  paraProps <- withParaPropM (pStyleM (fromString $ "Heading "++show lev)) $                     getParaProps False   contents <- inlinesToOpenXML opts lst-  if null ident-     then return [mknode "w:p" [] (paraProps ++contents)]+  if T.null ident+     then return [mknode "w:p" [] (paraProps ++ contents)]      else do        let bookmarkName = ident        modify $ \s -> s{ stSectionIds = Set.insert bookmarkName                                       $ stSectionIds s }        bookmarkedContents <- wrapBookmark bookmarkName contents        return [mknode "w:p" [] (paraProps ++ bookmarkedContents)]-blockToOpenXML' opts (Plain lst) = withParaProp (pCustomStyle "Compact")-  $ blockToOpenXML opts (Para lst)+blockToOpenXML' opts (Plain lst) = do+  isInTable <- gets stInTable+  let block = blockToOpenXML opts (Para lst)+  prop <- pStyleM "Compact"+  if isInTable then withParaProp prop block else block -- title beginning with fig: indicates that the image is a figure-blockToOpenXML' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = do+blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit)]) = do   setFirstPara-  let prop = pCustomStyle $+  prop <- pStyleM $         if null alt         then "Figure"-        else "CaptionedFigure"-  paraProps <- local (\env -> env { envParaProperties = prop : envParaProperties env }) (getParaProps False)+        else "Captioned Figure"+  paraProps <- local (\env -> env { envParaProperties = EnvProps (Just prop) [] <> envParaProperties env }) (getParaProps False)   contents <- inlinesToOpenXML opts [Image attr alt (src,tit)]-  captionNode <- withParaProp (pCustomStyle "ImageCaption")+  captionNode <- withParaPropM (pStyleM "Image Caption")                  $ blockToOpenXML opts (Para alt)   return $ mknode "w:p" [] (paraProps ++ contents) : captionNode blockToOpenXML' opts (Para lst)@@ -922,10 +948,10 @@                                  [x] -> isDisplayMath x                                  _   -> False       paraProps <- getParaProps displayMathPara-      bodyTextStyle <- pStyleM "Body Text"+      bodyTextStyle <- if isFirstPara+                       then pStyleM "First Paragraph"+                       else pStyleM "Body Text"       let paraProps' = case paraProps of-            [] | isFirstPara -> [mknode "w:pPr" []-                                [pCustomStyle "FirstParagraph"]]             []               -> [mknode "w:pPr" [] [bodyTextStyle]]             ps               -> ps       modify $ \s -> s { stFirstPara = False }@@ -938,11 +964,12 @@       report $ BlockNotRendered b       return [] blockToOpenXML' opts (BlockQuote blocks) = do-  p <- withParaPropM (pStyleM "Block Text") $ blocksToOpenXML opts blocks+  p <- withParaPropM (pStyleM "Block Text")+       $ blocksToOpenXML opts blocks   setFirstPara   return p blockToOpenXML' opts (CodeBlock attrs@(ident, _, _) str) = do-  p <- withParaProp (pCustomStyle "SourceCode") (blockToOpenXML opts $ Para [Code attrs str])+  p <- withParaPropM (pStyleM "Source Code") (blockToOpenXML opts $ Para [Code attrs str])   setFirstPara   wrapBookmark ident p blockToOpenXML' _ HorizontalRule = do@@ -954,10 +981,11 @@                        ("o:hrstd","t"),("o:hr","t")] () ] blockToOpenXML' opts (Table caption aligns widths headers rows) = do   setFirstPara+  modify $ \s -> s { stInTable = True }   let captionStr = stringify caption   caption' <- if null caption                  then return []-                 else withParaProp (pCustomStyle "TableCaption")+                 else withParaPropM (pStyleM "Table Caption")                       $ blockToOpenXML opts (Para caption)   let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()   -- Table cells require a <w:p> element, even an empty one!@@ -973,7 +1001,8 @@                     [ mknode "w:tcBorders" []                       $ mknode "w:bottom" [("w:val","single")] ()                     , mknode "w:vAlign" [("w:val","bottom")] () ]-  let emptyCell = [mknode "w:p" [] [mknode "w:pPr" [] [pCustomStyle "Compact"]]]+  compactStyle <- pStyleM "Compact"+  let emptyCell = [mknode "w:p" [] [mknode "w:pPr" [] [compactStyle]]]   let mkcell border contents = mknode "w:tc" []                             $ [ borderProps | border ] ++                             if null contents@@ -989,6 +1018,7 @@   let mkgridcol w = mknode "w:gridCol"                        [("w:w", show (floor (textwidth * w) :: Integer))] ()   let hasHeader = not (all null headers)+  modify $ \s -> s { stInTable = False }   return $     caption' ++     [mknode "w:tbl" []@@ -996,7 +1026,7 @@         (   mknode "w:tblStyle" [("w:val","Table")] () :             mknode "w:tblW" [("w:type", "pct"), ("w:w", show rowwidth)] () :             mknode "w:tblLook" [("w:firstRow",if hasHeader then "1" else "0") ] () :-          [ mknode "w:tblCaption" [("w:val", captionStr)] ()+          [ mknode "w:tblCaption" [("w:val", T.unpack captionStr)] ()           | not (null caption) ] )       : mknode "w:tblGrid" []         (if all (==0) widths@@ -1005,20 +1035,17 @@       : [ mkrow True headers' | hasHeader ] ++       map (mkrow False) rows'       )]-blockToOpenXML' opts (BulletList lst) = do-  let marker = BulletMarker-  addList marker-  numid  <- getNumId-  l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst-  setFirstPara-  return l-blockToOpenXML' opts (OrderedList (start, numstyle, numdelim) lst) = do-  let marker = NumberMarker numstyle numdelim start-  addList marker-  numid  <- getNumId-  l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst-  setFirstPara-  return l+blockToOpenXML' opts el+  | BulletList lst <- el = addOpenXMLList BulletMarker lst+  | OrderedList (start, numstyle, numdelim) lst <- el+  = addOpenXMLList (NumberMarker numstyle numdelim start) lst+  where+    addOpenXMLList marker lst = do+      addList marker+      numid  <- getNumId+      l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst+      setFirstPara+      return l blockToOpenXML' opts (DefinitionList items) = do   l <- concat `fmap` mapM (definitionListItemToOpenXML opts) items   setFirstPara@@ -1026,9 +1053,9 @@  definitionListItemToOpenXML  :: (PandocMonad m) => WriterOptions -> ([Inline],[[Block]]) -> WS m [Element] definitionListItemToOpenXML opts (term,defs) = do-  term' <- withParaProp (pCustomStyle "DefinitionTerm")+  term' <- withParaPropM (pStyleM "Definition Term")            $ blockToOpenXML opts (Para term)-  defs' <- withParaProp (pCustomStyle "Definition")+  defs' <- withParaPropM (pStyleM "Definition")            $ concat `fmap` mapM (blocksToOpenXML opts) defs   return $ term' ++ defs' @@ -1062,16 +1089,20 @@ asList :: (PandocMonad m) => WS m a -> WS m a asList = local $ \env -> env{ envListLevel = envListLevel env + 1 } +isStyle :: Element -> Bool+isStyle e = isElem [] "w" "rStyle" e ||+            isElem [] "w" "pStyle" e+ getTextProps :: (PandocMonad m) => WS m [Element] getTextProps = do   props <- asks envTextProperties-  return $ if null props-              then []-              else [mknode "w:rPr" [] props]+  let squashed = squashProps props+  return [mknode "w:rPr" [] squashed | (not . null) squashed]  withTextProp :: PandocMonad m => Element -> WS m a -> WS m a withTextProp d p =-  local (\env -> env {envTextProperties = d : envTextProperties env}) p+  local (\env -> env {envTextProperties = ep <> envTextProperties env}) p+  where ep = if isStyle d then EnvProps (Just d) [] else EnvProps Nothing [d]  withTextPropM :: PandocMonad m => WS m Element -> WS m a -> WS m a withTextPropM = (. flip withTextProp) . (>>=)@@ -1082,32 +1113,33 @@   listLevel <- asks envListLevel   numid <- asks envListNumId   let listPr = [mknode "w:numPr" []-                [ mknode "w:numId" [("w:val",show numid)] ()-                , mknode "w:ilvl" [("w:val",show listLevel)] () ] | listLevel >= 0 && not displayMathPara]-  return $ case props ++ listPr of+                [ mknode "w:ilvl" [("w:val",show listLevel)] ()+                , mknode "w:numId" [("w:val",show numid)] () ] | listLevel >= 0 && not displayMathPara]+  return $ case listPr ++ squashProps props of                 [] -> []                 ps -> [mknode "w:pPr" [] ps]  withParaProp :: PandocMonad m => Element -> WS m a -> WS m a withParaProp d p =-  local (\env -> env {envParaProperties = d : envParaProperties env}) p+  local (\env -> env {envParaProperties = ep <> envParaProperties env}) p+  where ep = if isStyle d then EnvProps (Just d) [] else EnvProps Nothing [d]  withParaPropM :: PandocMonad m => WS m Element -> WS m a -> WS m a withParaPropM = (. flip withParaProp) . (>>=) -formattedString :: PandocMonad m => String -> WS m [Element]+formattedString :: PandocMonad m => T.Text -> WS m [Element] formattedString str =   -- properly handle soft hyphens-  case splitBy (=='\173') str of+  case splitTextBy (=='\173') str of       [w] -> formattedString' w       ws  -> do          sh <- formattedRun [mknode "w:softHyphen" [] ()]          intercalate sh <$> mapM formattedString' ws -formattedString' :: PandocMonad m => String -> WS m [Element]+formattedString' :: PandocMonad m => T.Text -> WS m [Element] formattedString' str = do   inDel <- asks envInDel-  formattedRun [ mknode (if inDel then "w:delText" else "w:t")+  formattedRun [ mktnode (if inDel then "w:delText" else "w:t")                  [("xml:space","preserve")] (stripInvalidChars str) ]  formattedRun :: PandocMonad m => [Element] -> WS m [Element]@@ -1127,7 +1159,7 @@   formattedString str inlineToOpenXML' opts Space = inlineToOpenXML opts (Str " ") inlineToOpenXML' opts SoftBreak = inlineToOpenXML opts (Str " ")-inlineToOpenXML' opts (Span (_,["underline"],_) ils) = do+inlineToOpenXML' opts (Span (_,["underline"],_) ils) =   withTextProp (mknode "w:u" [("w:val","single")] ()) $     inlinesToOpenXML opts ils inlineToOpenXML' _ (Span (ident,["comment-start"],kvs) ils) = do@@ -1136,21 +1168,21 @@   let ident' = fromMaybe ident (lookup "id" kvs)       kvs' = filter (("id" /=) . fst) kvs   modify $ \st -> st{ stComments = (("id",ident'):kvs', ils) : stComments st }-  return [ mknode "w:commentRangeStart" [("w:id", ident')] () ]+  return [ mknode "w:commentRangeStart" [("w:id", T.unpack ident')] () ] inlineToOpenXML' _ (Span (ident,["comment-end"],kvs) _) =   -- prefer the "id" in kvs, since that is the one produced by the docx   -- reader.   let ident' = fromMaybe ident (lookup "id" kvs)   in-    return [ mknode "w:commentRangeEnd" [("w:id", ident')] ()+    return [ mknode "w:commentRangeEnd" [("w:id", T.unpack ident')] ()            , mknode "w:r" []              [ mknode "w:rPr" []                [ mknode "w:rStyle" [("w:val", "CommentReference")] () ]-             , mknode "w:commentReference" [("w:id", ident')] () ]+             , mknode "w:commentReference" [("w:id", T.unpack ident')] () ]            ] inlineToOpenXML' opts (Span (ident,classes,kvs) ils) = do   stylemod <- case lookup dynamicStyleKey kvs of-                   Just sty -> do+                   Just (fromString . T.unpack -> sty) -> do                       modify $ \s ->                         s{stDynamicTextProps = Set.insert sty                               (stDynamicTextProps s)}@@ -1160,41 +1192,41 @@                  Just "rtl" -> local (\env -> env { envRTL = True })                  Just "ltr" -> local (\env -> env { envRTL = False })                  _          -> id-  let off x = withTextProp (mknode x [("w:val","0")] ())-  let pmod =  (if "csl-no-emph" `elem` classes then off "w:i" else id) .+      off x = withTextProp (mknode x [("w:val","0")] ())+      pmod =  (if "csl-no-emph" `elem` classes then off "w:i" else id) .               (if "csl-no-strong" `elem` classes then off "w:b" else id) .               (if "csl-no-smallcaps" `elem` classes                   then off "w:smallCaps"                   else id)+      getChangeAuthorDate = do+        defaultAuthor <- asks envChangesAuthor+        defaultDate <- asks envChangesDate+        let author = fromMaybe defaultAuthor (lookup "author" kvs)+            date   = fromMaybe defaultDate (lookup "date" kvs)+        return (author, date)   insmod <- if "insertion" `elem` classes                then do-                 defaultAuthor <- asks envChangesAuthor-                 defaultDate <- asks envChangesDate-                 let author = fromMaybe defaultAuthor (lookup "author" kvs)-                     date   = fromMaybe defaultDate (lookup "date" kvs)+                 (author, date) <- getChangeAuthorDate                  insId <- gets stInsId                  modify $ \s -> s{stInsId = insId + 1}                  return $ \f -> do                    x <- f                    return [ mknode "w:ins"                               [("w:id", show insId),-                              ("w:author", author),-                              ("w:date", date)] x ]+                              ("w:author", T.unpack author),+                              ("w:date", T.unpack date)] x ]                else return id   delmod <- if "deletion" `elem` classes                then do-                 defaultAuthor <- asks envChangesAuthor-                 defaultDate <- asks envChangesDate-                 let author = fromMaybe defaultAuthor (lookup "author" kvs)-                     date   = fromMaybe defaultDate (lookup "date" kvs)+                 (author, date) <- getChangeAuthorDate                  delId <- gets stDelId                  modify $ \s -> s{stDelId = delId + 1}                  return $ \f -> local (\env->env{envInDel=True}) $ do                    x <- f                    return [mknode "w:del"                            [("w:id", show delId),-                           ("w:author", author),-                           ("w:date", date)] x]+                           ("w:author", T.unpack author),+                           ("w:date", T.unpack date)] x]                else return id   contents <- insmod $ delmod $ dirmod $ stylemod $ pmod                      $ inlinesToOpenXML opts ils@@ -1234,21 +1266,24 @@        Left il -> inlineToOpenXML' opts il inlineToOpenXML' opts (Cite _ lst) = inlinesToOpenXML opts lst inlineToOpenXML' opts (Code attrs str) = do+  let alltoktypes = [KeywordTok ..]+  tokTypesMap <- mapM (\tt -> (,) tt <$> rStyleM (fromString $ show tt)) alltoktypes   let unhighlighted = intercalate [br] `fmap`-                       mapM formattedString (lines str)+                       mapM formattedString (T.lines str)       formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)-      toHlTok (toktype,tok) = mknode "w:r" []-                               [ mknode "w:rPr" []-                                 [ rCustomStyle (show toktype) ]-                               , mknode "w:t" [("xml:space","preserve")] (T.unpack tok) ]-  withTextProp (rCustomStyle "VerbatimChar")+      toHlTok (toktype,tok) =+        mknode "w:r" []+          [ mknode "w:rPr" [] $+            maybeToList (lookup toktype tokTypesMap)+            , mknode "w:t" [("xml:space","preserve")] (T.unpack tok) ]+  withTextPropM (rStyleM "Verbatim Char")     $ if isNothing (writerHighlightStyle opts)           then unhighlighted           else case highlight (writerSyntaxMap opts)                       formatOpenXML attrs str of                     Right h  -> return h                     Left msg -> do-                      unless (null msg) $ report $ CouldNotHighlight msg+                      unless (T.null msg) $ report $ CouldNotHighlight msg                       unhighlighted inlineToOpenXML' opts (Note bs) = do   notes <- gets stFootnotes@@ -1257,14 +1292,14 @@   let notemarker = mknode "w:r" []                    [ mknode "w:rPr" [] footnoteStyle                    , mknode "w:footnoteRef" [] () ]-  let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker+  let notemarkerXml = RawInline (Format "openxml") $ T.pack $ ppElement notemarker   let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : Space : ils) : xs       insertNoteRef (Para ils  : xs) = Para  (notemarkerXml : Space : ils) : xs       insertNoteRef xs               = Para [notemarkerXml] : xs    contents <- local (\env -> env{ envListLevel = -1-                                , envParaProperties = []-                                , envTextProperties = [] })+                                , envParaProperties = mempty+                                , envTextProperties = mempty })               (withParaPropM (pStyleM "Footnote Text") $ blocksToOpenXML opts                 $ insertNoteRef bs)   let newnote = mknode "w:footnote" [("w:id", notenum)] contents@@ -1273,27 +1308,27 @@            [ mknode "w:rPr" [] footnoteStyle            , mknode "w:footnoteReference" [("w:id", notenum)] () ] ] -- internal link:-inlineToOpenXML' opts (Link _ txt ('#':xs,_)) = do+inlineToOpenXML' opts (Link _ txt (T.uncons -> Just ('#', xs),_)) = do   contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt   return-    [ mknode "w:hyperlink" [("w:anchor", toBookmarkName xs)] contents ]+    [ mknode "w:hyperlink" [("w:anchor", T.unpack $ toBookmarkName xs)] contents ] -- external link: inlineToOpenXML' opts (Link _ txt (src,_)) = do   contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt   extlinks <- gets stExternalLinks-  id' <- case M.lookup src extlinks of+  id' <- case M.lookup (T.unpack src) extlinks of             Just i   -> return i             Nothing  -> do               i <- ("rId"++) `fmap` getUniqueId               modify $ \st -> st{ stExternalLinks =-                        M.insert src i extlinks }+                        M.insert (T.unpack src) i extlinks }               return i   return [ mknode "w:hyperlink" [("r:id",id')] contents ] inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do   pageWidth <- asks envPrintWidth   imgs <- gets stImages   let-    stImage = M.lookup src imgs+    stImage = M.lookup (T.unpack src) imgs     generateImgElt (ident, _, _, img) =       let         (xpt,ypt) = desiredSizeInPoints opts attr@@ -1306,7 +1341,7 @@                                              ,("noChangeAspect","1")] ()         nvPicPr  = mknode "pic:nvPicPr" []                         [ mknode "pic:cNvPr"-                            [("descr",src),("id","0"),("name","Picture")] ()+                            [("descr",T.unpack src),("id","0"),("name","Picture")] ()                         , cNvPicPr ]         blipFill = mknode "pic:blipFill" []           [ mknode "a:blip" [("r:embed",ident)] ()@@ -1341,8 +1376,8 @@               , mknode "wp:effectExtent"                 [("b","0"),("l","0"),("r","0"),("t","0")] ()               , mknode "wp:docPr"-                [ ("descr", stringify alt)-                , ("title", title)+                [ ("descr", T.unpack $ stringify alt)+                , ("title", T.unpack title)                 , ("id","1")                 , ("name","Picture")                 ] ()@@ -1359,7 +1394,7 @@        let         imgext = case mt >>= extensionFromMimeType of-          Just x    -> '.':x+          Just x    -> "." <> x           Nothing   -> case imageType img of             Just Png  -> ".png"             Just Jpeg -> ".jpeg"@@ -1369,21 +1404,21 @@             Just Svg  -> ".svg"             Just Emf  -> ".emf"             Nothing   -> ""-        imgpath = "media/" ++ ident ++ imgext+        imgpath = "media/" <> ident <> T.unpack imgext         mbMimeType = mt <|> getMimeType imgpath          imgData = (ident, imgpath, mbMimeType, img) -      if null imgext+      if T.null imgext          then -- without an extension there is no rule for content type            inlinesToOpenXML opts alt -- return alt to avoid corrupted docx          else do            -- insert mime type to use in constructing [Content_Types].xml-           modify $ \st -> st { stImages = M.insert src imgData $ stImages st }+           modify $ \st -> st { stImages = M.insert (T.unpack src) imgData $ stImages st }            return [generateImgElt imgData]       )       `catchError` ( \e -> do-        report $ CouldNotFetchResource src (show e)+        report $ CouldNotFetchResource src $ T.pack (show e)         -- emit alt text         inlinesToOpenXML opts alt       )@@ -1399,12 +1434,12 @@ defaultFootnotes = [ mknode "w:footnote"                      [("w:type", "separator"), ("w:id", "-1")]                      [ mknode "w:p" []-                       [mknode "w:r" [] $+                       [mknode "w:r" []                         [ mknode "w:separator" [] ()]]]                    , mknode "w:footnote"                      [("w:type", "continuationSeparator"), ("w:id", "0")]                      [ mknode "w:p" []-                       [ mknode "w:r" [] $+                       [ mknode "w:r" []                          [ mknode "w:continuationSeparator" [] ()]]]]  @@ -1416,34 +1451,36 @@   -- We want to clean all bidirection (bidi) and right-to-left (rtl)   -- properties from the props first. This is because we don't want   -- them to stack up.-  let paraProps' = filter (\e -> (qName . elName) e /= "bidi") paraProps-      textProps' = filter (\e -> (qName . elName) e /= "rtl") textProps+  let paraProps' = filter (\e -> (qName . elName) e /= "bidi") (otherElements paraProps)+      textProps' = filter (\e -> (qName . elName) e /= "rtl") (otherElements textProps)+      paraStyle = styleElement paraProps+      textStyle = styleElement textProps   if isRTL     -- if we are going right-to-left, we (re?)add the properties.     then flip local x $-         \env -> env { envParaProperties = mknode "w:bidi" [] () : paraProps'-                     , envTextProperties = mknode "w:rtl" [] () : textProps'+         \env -> env { envParaProperties = EnvProps paraStyle $ mknode "w:bidi" [] () : paraProps'+                     , envTextProperties = EnvProps textStyle $ mknode "w:rtl" [] () : textProps'                      }-    else flip local x $ \env -> env { envParaProperties = paraProps'-                                    , envTextProperties = textProps'+    else flip local x $ \env -> env { envParaProperties = EnvProps paraStyle paraProps'+                                    , envTextProperties = EnvProps textStyle textProps'                                     } -wrapBookmark :: (PandocMonad m) => String -> [Element] -> WS m [Element]-wrapBookmark [] contents = return contents+wrapBookmark :: (PandocMonad m) => T.Text -> [Element] -> WS m [Element]+wrapBookmark "" contents = return contents wrapBookmark ident contents = do   id' <- getUniqueId   let bookmarkStart = mknode "w:bookmarkStart"                        [("w:id", id')-                       ,("w:name", toBookmarkName ident)] ()+                       ,("w:name", T.unpack $ toBookmarkName ident)] ()       bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()   return $ bookmarkStart : contents ++ [bookmarkEnd]  -- Word imposes a 40 character limit on bookmark names and requires -- that they begin with a letter.  So we just use a hash of the--- identifer when otherwise we'd have an illegal bookmark name.-toBookmarkName :: String -> String-toBookmarkName s =-  case s of-    (c:_) | isLetter c-          , length s <= 40 -> s-    _     -> 'X' : drop 1 (showDigest (sha1 (fromStringLazy s)))+-- identifier when otherwise we'd have an illegal bookmark name.+toBookmarkName :: T.Text -> T.Text+toBookmarkName s+  | Just (c, _) <- T.uncons s+  , isLetter c+  , T.length s <= 40 = s+  | otherwise = T.pack $ 'X' : drop 1 (showDigest (sha1 (fromTextLazy $ TL.fromStrict s)))
+ src/Text/Pandoc/Writers/Docx/StyleMap.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts  #-}+{- |+   Module : Text.Pandoc.Writers.Docx.StyleMap+   Copyright   : © 2014-2019 Jesse Rosenthal <jrosenthal@jhu.edu>,+                   2014-2019 John MacFarlane <jgm@berkeley.edu>,+                   2015-2019 Nikolay Yakimov <root@livid.pp.ru>+   License     : GNU GPL, version 2 or above++   Maintainer  : Jesse Rosenthal <jrosenthal@jhu.edu>+   Stability   : alpha+   Portability : portable++Mappings of element styles (word to pandoc-internal).+-}++module Text.Pandoc.Writers.Docx.StyleMap ( StyleMaps(..)+                                         , ParaStyleName+                                         , CharStyleName+                                         , getStyleMaps+                                         , getStyleIdFromName+                                         , hasStyleName+                                         , fromStyleId+                                         , fromStyleName+                                         ) where++import Text.Pandoc.Readers.Docx.Parse.Styles+import Codec.Archive.Zip+import qualified Data.Map as M+import qualified Data.Text as T+import Data.String+import Data.Char (isSpace)+import Prelude++data StyleMaps = StyleMaps { smCharStyle :: CharStyleNameMap, smParaStyle :: ParaStyleNameMap }+type ParaStyleNameMap = M.Map ParaStyleName ParStyle+type CharStyleNameMap = M.Map CharStyleName CharStyle++getStyleIdFromName :: (Ord sn, FromStyleName sn, IsString (StyleId sty), HasStyleId sty)+                   => sn -> M.Map sn sty -> StyleId sty+getStyleIdFromName s = maybe (fallback s) getStyleId . M.lookup s+  where fallback = fromString . T.unpack . T.filter (not . isSpace) . fromStyleName++hasStyleName :: (Ord sn, HasStyleId sty)+             => sn -> M.Map sn sty -> Bool+hasStyleName styleName = M.member styleName++getStyleMaps :: Archive -> StyleMaps+getStyleMaps = uncurry StyleMaps . archiveToStyles' getStyleName getStyleName
src/Text/Pandoc/Writers/DokuWiki.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Writers.DokuWiki    Copyright   : Copyright (C) 2008-2019 John MacFarlane@@ -27,23 +28,25 @@ import Control.Monad.Reader (ReaderT, asks, local, runReaderT) import Control.Monad.State.Strict (StateT, evalStateT) import Data.Default (Default (..))-import Data.List (intercalate, intersect, isPrefixOf, transpose)-import Data.Text (Text, pack)+import Data.List (intersect, transpose)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options (WrapOption (..), WriterOptions (writerTableOfContents, writerTemplate, writerWrapText)) import Text.Pandoc.Shared (camelCaseToHyphenated, escapeURI, isURI, linesToPara,-                           removeFormatting, substitute, trimr)-import Text.Pandoc.Templates (renderTemplate')-import Text.Pandoc.Writers.Shared (defField, metaToJSON)+                           removeFormatting, trimr, tshow)+import Text.Pandoc.Templates (renderTemplate)+import Text.DocLayout (render, literal)+import Text.Pandoc.Writers.Shared (defField, metaToContext)  data WriterState = WriterState {   }  data WriterEnvironment = WriterEnvironment {-    stIndent      :: String          -- Indent after the marker at the beginning of list items+    stIndent      :: Text          -- Indent after the marker at the beginning of list items   , stUseTags     :: Bool            -- True if we should use HTML tags because we're in a complex list   , stBackSlashLB :: Bool     -- True if we should produce formatted strings with newlines (as in a table cell)   }@@ -70,57 +73,59 @@ pandocToDokuWiki :: PandocMonad m                  => WriterOptions -> Pandoc -> DokuWiki m Text pandocToDokuWiki opts (Pandoc meta blocks) = do-  metadata <- metaToJSON opts-              (fmap trimr . blockListToDokuWiki opts)-              (inlineListToDokuWiki opts)+  metadata <- metaToContext opts+              (fmap (literal . trimr) . blockListToDokuWiki opts)+              (fmap (literal . trimr) . inlineListToDokuWiki opts)               meta   body <- blockListToDokuWiki opts blocks-  let main = pack body-  let context = defField "body" main-                $ defField "toc" (writerTableOfContents opts) metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  let context = defField "body" body+              $ defField "toc" (writerTableOfContents opts) metadata+  return $+    case writerTemplate opts of+       Nothing  -> body+       Just tpl -> render Nothing $ renderTemplate tpl context  -- | Escape special characters for DokuWiki.-escapeString :: String -> String-escapeString = substitute "__" "%%__%%" .-               substitute "**" "%%**%%" .-               substitute "//" "%%//%%"+escapeString :: Text -> Text+escapeString = T.replace "__" "%%__%%" .+               T.replace "**" "%%**%%" .+               T.replace "//" "%%//%%"  -- | Convert Pandoc block element to DokuWiki. blockToDokuWiki :: PandocMonad m                 => WriterOptions -- ^ Options                 -> Block         -- ^ Block element-                -> DokuWiki m String+                -> DokuWiki m Text  blockToDokuWiki _ Null = return ""  blockToDokuWiki opts (Div _attrs bs) = do   contents <- blockListToDokuWiki opts bs-  return $ contents ++ "\n"+  return $ contents <> "\n"  blockToDokuWiki opts (Plain inlines) =   inlineListToDokuWiki opts inlines  -- title beginning with fig: indicates that the image is a figure -- dokuwiki doesn't support captions - so combine together alt and caption into alt-blockToDokuWiki opts (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do-  capt <- if null txt-             then return ""-             else (" " ++) `fmap` inlineListToDokuWiki opts txt-  let opt = if null txt-               then ""-               else "|" ++ if null tit then capt else tit ++ capt-  return $ "{{" ++ src ++ imageDims opts attr ++ opt ++ "}}\n"+blockToDokuWiki opts (Para [Image attr txt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt+  = do+      capt <- if null txt+              then return ""+              else (" " <>) `fmap` inlineListToDokuWiki opts txt+      let opt = if null txt+                then ""+                else "|" <> if T.null tit then capt else tit <> capt+      return $ "{{" <> src <> imageDims opts attr <> opt <> "}}\n"  blockToDokuWiki opts (Para inlines) = do   indent <- asks stIndent   useTags <- asks stUseTags   contents <- inlineListToDokuWiki opts inlines   return $ if useTags-              then "<HTML><p></HTML>" ++ contents ++ "<HTML></p></HTML>"-              else contents ++ if null indent then "\n" else ""+              then "<HTML><p></HTML>" <> contents <> "<HTML></p></HTML>"+              else contents <> if T.null indent then "\n" else ""  blockToDokuWiki opts (LineBlock lns) =   blockToDokuWiki opts $ linesToPara lns@@ -129,7 +134,7 @@   | f == Format "dokuwiki" = return str   -- See https://www.dokuwiki.org/wiki:syntax   -- use uppercase HTML tag for block-level content:-  | f == Format "html"     = return $ "<HTML>\n" ++ str ++ "\n</HTML>"+  | f == Format "html"     = return $ "<HTML>\n" <> str <> "\n</HTML>"   | otherwise              = "" <$          report (BlockNotRendered b) @@ -139,8 +144,8 @@   -- emphasis, links etc. not allowed in headers, apparently,   -- so we remove formatting:   contents <- inlineListToDokuWiki opts $ removeFormatting inlines-  let eqs = replicate ( 7 - level ) '='-  return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"+  let eqs = T.replicate ( 7 - level ) "="+  return $ eqs <> " " <> contents <> " " <> eqs <> "\n"  blockToDokuWiki _ (CodeBlock (_,classes,_) str) = do   let at  = classes `intersect` ["actionscript", "ada", "apache", "applescript", "asm", "asp",@@ -152,43 +157,43 @@                        "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",                        "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",                        "visualfoxpro", "winbatch", "xml", "xpp", "z80"]-  return $ "<code" +++  return $ "<code" <>                 (case at of                       []    -> ">\n"-                      (x:_) -> " " ++ x ++ ">\n") ++ str ++ "\n</code>"+                      (x:_) -> " " <> x <> ">\n") <> str <> "\n</code>"  blockToDokuWiki opts (BlockQuote blocks) = do   contents <- blockListToDokuWiki opts blocks   if isSimpleBlockQuote blocks-     then return $ unlines $ map ("> " ++) $ lines contents-     else return $ "<HTML><blockquote>\n" ++ contents ++ "</blockquote></HTML>"+     then return $ T.unlines $ map ("> " <>) $ T.lines contents+     else return $ "<HTML><blockquote>\n" <> contents <> "</blockquote></HTML>"  blockToDokuWiki opts (Table capt aligns _ headers rows) = do   captionDoc <- if null capt                    then return ""                    else do                       c <- inlineListToDokuWiki opts capt-                      return $ "" ++ c ++ "\n"+                      return $ "" <> c <> "\n"   headers' <- if all null headers                  then return []                  else zipWithM (tableItemToDokuWiki opts) aligns headers   rows' <- mapM (zipWithM (tableItemToDokuWiki opts) aligns) rows-  let widths = map (maximum . map length) $ transpose (headers':rows')+  let widths = map (maximum . map T.length) $ transpose (headers':rows')   let padTo (width, al) s =-          case width - length s of+          case width - T.length s of                x | x > 0 ->                  if al == AlignLeft || al == AlignDefault-                    then s ++ replicate x ' '+                    then s <> T.replicate x " "                     else if al == AlignRight-                            then replicate x ' ' ++ s-                            else replicate (x `div` 2) ' ' ++-                                 s ++ replicate (x - x `div` 2) ' '+                            then T.replicate x " " <> s+                            else T.replicate (x `div` 2) " " <>+                                 s <> T.replicate (x - x `div` 2) " "                  | otherwise -> s-  let renderRow sep cells = sep ++-          intercalate sep (zipWith padTo (zip widths aligns) cells) ++ sep-  return $ captionDoc ++-           (if null headers' then "" else renderRow "^" headers' ++ "\n") ++-           unlines (map (renderRow "|") rows')+  let renderRow sep cells = sep <>+          T.intercalate sep (zipWith padTo (zip widths aligns) cells) <> sep+  return $ captionDoc <>+           (if null headers' then "" else renderRow "^" headers' <> "\n") <>+           T.unlines (map (renderRow "|") rows')  blockToDokuWiki opts x@(BulletList items) = do   oldUseTags <- asks stUseTags@@ -199,12 +204,12 @@      then do         contents <- local (\s -> s { stUseTags = True })                       (mapM (listItemToDokuWiki opts) items)-        return $ "<HTML><ul></HTML>\n" ++ vcat contents ++ "<HTML></ul></HTML>\n"+        return $ "<HTML><ul></HTML>\n" <> vcat contents <> "<HTML></ul></HTML>\n"      else do-        contents <- local (\s -> s { stIndent = stIndent s ++ "  "+        contents <- local (\s -> s { stIndent = stIndent s <> "  "                                    , stBackSlashLB = backSlash})                       (mapM (listItemToDokuWiki opts) items)-        return $ vcat contents ++ if null indent then "\n" else ""+        return $ vcat contents <> if T.null indent then "\n" else ""  blockToDokuWiki opts x@(OrderedList attribs items) = do   oldUseTags <- asks stUseTags@@ -215,12 +220,12 @@      then do         contents <- local (\s -> s { stUseTags = True })                       (mapM (orderedListItemToDokuWiki opts) items)-        return $ "<HTML><ol" ++ listAttribsToString attribs ++ "></HTML>\n" ++ vcat contents ++ "<HTML></ol></HTML>\n"+        return $ "<HTML><ol" <> listAttribsToString attribs <> "></HTML>\n" <> vcat contents <> "<HTML></ol></HTML>\n"      else do-        contents <- local (\s -> s { stIndent = stIndent s ++ "  "+        contents <- local (\s -> s { stIndent = stIndent s <> "  "                                    , stBackSlashLB = backSlash})                       (mapM (orderedListItemToDokuWiki opts) items)-        return $ vcat contents ++ if null indent then "\n" else ""+        return $ vcat contents <> if T.null indent then "\n" else ""  -- TODO Need to decide how to make definition lists work on dokuwiki - I don't think there --      is a specific representation of them.@@ -234,106 +239,92 @@      then do         contents <- local (\s -> s { stUseTags = True })                       (mapM (definitionListItemToDokuWiki opts) items)-        return $ "<HTML><dl></HTML>\n" ++ vcat contents ++ "<HTML></dl></HTML>\n"+        return $ "<HTML><dl></HTML>\n" <> vcat contents <> "<HTML></dl></HTML>\n"      else do-        contents <- local (\s -> s { stIndent = stIndent s ++ "  "+        contents <- local (\s -> s { stIndent = stIndent s <> "  "                                    , stBackSlashLB = backSlash})                       (mapM (definitionListItemToDokuWiki opts) items)-        return $ vcat contents ++ if null indent then "\n" else ""+        return $ vcat contents <> if T.null indent then "\n" else ""  -- Auxiliary functions for lists:  -- | Convert ordered list attributes to HTML attribute string-listAttribsToString :: ListAttributes -> String+listAttribsToString :: ListAttributes -> Text listAttribsToString (startnum, numstyle, _) =-  let numstyle' = camelCaseToHyphenated $ show numstyle+  let numstyle' = camelCaseToHyphenated $ tshow numstyle   in  (if startnum /= 1-          then " start=\"" ++ show startnum ++ "\""-          else "") +++          then " start=\"" <> tshow startnum <> "\""+          else "") <>       (if numstyle /= DefaultStyle-          then " style=\"list-style-type: " ++ numstyle' ++ ";\""+          then " style=\"list-style-type: " <> numstyle' <> ";\""           else "")  -- | Convert bullet list item (list of blocks) to DokuWiki. listItemToDokuWiki :: PandocMonad m-                   => WriterOptions -> [Block] -> DokuWiki m String+                   => WriterOptions -> [Block] -> DokuWiki m Text listItemToDokuWiki opts items = do   useTags <- asks stUseTags   if useTags      then do        contents <- blockListToDokuWiki opts items-       return $ "<HTML><li></HTML>" ++ contents ++ "<HTML></li></HTML>"+       return $ "<HTML><li></HTML>" <> contents <> "<HTML></li></HTML>"      else do        bs <- mapM (blockToDokuWiki opts) items        let contents = case items of-                           [_, CodeBlock _ _] -> concat bs+                           [_, CodeBlock _ _] -> T.concat bs                            _                  -> vcat bs        indent <- asks stIndent        backSlash <- asks stBackSlashLB-       let indent' = if backSlash then drop 2 indent else indent-       return $ indent' ++ "* " ++ contents+       let indent' = if backSlash then T.drop 2 indent else indent+       return $ indent' <> "* " <> contents  -- | Convert ordered list item (list of blocks) to DokuWiki. -- | TODO Emiminate dreadful duplication of text from listItemToDokuWiki-orderedListItemToDokuWiki :: PandocMonad m => WriterOptions -> [Block] -> DokuWiki m String+orderedListItemToDokuWiki :: PandocMonad m => WriterOptions -> [Block] -> DokuWiki m Text orderedListItemToDokuWiki opts items = do   contents <- blockListToDokuWiki opts items   useTags <- asks stUseTags   if useTags-     then return $ "<HTML><li></HTML>" ++ contents ++ "<HTML></li></HTML>"+     then return $ "<HTML><li></HTML>" <> contents <> "<HTML></li></HTML>"      else do        indent <- asks stIndent        backSlash <- asks stBackSlashLB-       let indent' = if backSlash then drop 2 indent else indent-       return $ indent' ++ "- " ++ contents+       let indent' = if backSlash then T.drop 2 indent else indent+       return $ indent' <> "- " <> contents  -- | Convert definition list item (label, list of blocks) to DokuWiki. definitionListItemToDokuWiki :: PandocMonad m                              => WriterOptions                              -> ([Inline],[[Block]])-                             -> DokuWiki m String+                             -> DokuWiki m Text definitionListItemToDokuWiki opts (label, items) = do   labelText <- inlineListToDokuWiki opts label   contents <- mapM (blockListToDokuWiki opts) items   useTags <- asks stUseTags   if useTags-     then return $ "<HTML><dt></HTML>" ++ labelText ++ "<HTML></dt></HTML>\n" ++-           intercalate "\n" (map (\d -> "<HTML><dd></HTML>" ++ d ++ "<HTML></dd></HTML>") contents)+     then return $ "<HTML><dt></HTML>" <> labelText <> "<HTML></dt></HTML>\n" <>+           T.intercalate "\n" (map (\d -> "<HTML><dd></HTML>" <> d <> "<HTML></dd></HTML>") contents)      else do        indent <- asks stIndent        backSlash <- asks stBackSlashLB-       let indent' = if backSlash then drop 2 indent else indent-       return $ indent' ++ "* **" ++ labelText ++ "** " ++ concat contents+       let indent' = if backSlash then T.drop 2 indent else indent+       return $ indent' <> "* **" <> labelText <> "** " <> T.concat 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]-       DefinitionList items             -> all isSimpleListItem $ concatMap snd items-       _                                -> False+       BulletList items            -> all isSimpleListItem items+       OrderedList (1, _, _) items -> all isSimpleListItem items+       DefinitionList items        -> all (all isSimpleListItem . snd) items+       _                           -> 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-       DefinitionList _ -> isSimpleList x-       _                -> False-isSimpleListItem [x, y] | isPlainOrPara x =-  case y of-       BulletList _     -> isSimpleList y-       OrderedList _ _  -> isSimpleList y-       DefinitionList _ -> isSimpleList y-       CodeBlock _ _    -> True-       _                -> False+isSimpleListItem [x, CodeBlock{}] | isPlainOrPara x = True+isSimpleListItem (x:ys) | isPlainOrPara x = all isSimpleList ys isSimpleListItem _ = False  isPlainOrPara :: Block -> Bool@@ -345,17 +336,17 @@ isSimpleBlockQuote bs  = all isPlainOrPara bs  -- | Concatenates strings with line breaks between them.-vcat :: [String] -> String-vcat = intercalate "\n"+vcat :: [Text] -> Text+vcat = T.intercalate "\n"  -- | For each string in the input list, convert all newlines to -- dokuwiki escaped newlines. Then concat the list using double linebreaks.-backSlashLineBreaks :: [String] -> String-backSlashLineBreaks ls = vcatBackSlash $ map escape ls+backSlashLineBreaks :: [Text] -> Text+backSlashLineBreaks ls = vcatBackSlash $ map (T.pack . escape . T.unpack) ls   where-    vcatBackSlash = intercalate "\\\\ \\\\ " -- simulate paragraphs.-    escape ['\n'] = "" -- remove trailing newlines-    escape ('\n':cs) = "\\\\ " ++ escape cs+    vcatBackSlash = T.intercalate "\\\\ \\\\ " -- simulate paragraphs.+    escape ['\n']    = "" -- remove trailing newlines+    escape ('\n':cs) = "\\\\ " <> escape cs     escape (c:cs)    = c : escape cs     escape []        = [] @@ -365,11 +356,11 @@                     => WriterOptions                     -> Alignment                     -> [Block]-                    -> DokuWiki m String+                    -> DokuWiki m Text tableItemToDokuWiki opts align' item = do   let mkcell x = (if align' == AlignRight || align' == AlignCenter                      then "  "-                     else "") ++ x +++                     else "") <> x <>                  (if align' == AlignLeft || align' == AlignCenter                      then "  "                      else "")@@ -381,7 +372,7 @@ blockListToDokuWiki :: PandocMonad m                     => WriterOptions -- ^ Options                     -> [Block]       -- ^ List of block elements-                    -> DokuWiki m String+                    -> DokuWiki m Text blockListToDokuWiki opts blocks = do   backSlash <- asks stBackSlashLB   let blocks' = consolidateRawBlocks blocks@@ -392,51 +383,51 @@ consolidateRawBlocks :: [Block] -> [Block] consolidateRawBlocks [] = [] consolidateRawBlocks (RawBlock f1 b1 : RawBlock f2 b2 : xs)-  | f1 == f2 = consolidateRawBlocks (RawBlock f1 (b1 ++ "\n" ++ b2) : xs)+  | f1 == f2 = consolidateRawBlocks (RawBlock f1 (b1 <> "\n" <> b2) : xs) consolidateRawBlocks (x:xs) = x : consolidateRawBlocks xs  -- | Convert list of Pandoc inline elements to DokuWiki. inlineListToDokuWiki :: PandocMonad m-                     => WriterOptions -> [Inline] -> DokuWiki m String+                     => WriterOptions -> [Inline] -> DokuWiki m Text inlineListToDokuWiki opts lst =-  concat <$> mapM (inlineToDokuWiki opts) lst+  T.concat <$> mapM (inlineToDokuWiki opts) lst  -- | Convert Pandoc inline element to DokuWiki. inlineToDokuWiki :: PandocMonad m-                 => WriterOptions -> Inline -> DokuWiki m String+                 => WriterOptions -> Inline -> DokuWiki m Text  inlineToDokuWiki opts (Span _attrs ils) =   inlineListToDokuWiki opts ils  inlineToDokuWiki opts (Emph lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "//" ++ contents ++ "//"+  return $ "//" <> contents <> "//"  inlineToDokuWiki opts (Strong lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "**" ++ contents ++ "**"+  return $ "**" <> contents <> "**"  inlineToDokuWiki opts (Strikeout lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "<del>" ++ contents ++ "</del>"+  return $ "<del>" <> contents <> "</del>"  inlineToDokuWiki opts (Superscript lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "<sup>" ++ contents ++ "</sup>"+  return $ "<sup>" <> contents <> "</sup>"  inlineToDokuWiki opts (Subscript lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "<sub>" ++ contents ++ "</sub>"+  return $ "<sub>" <> contents <> "</sub>"  inlineToDokuWiki opts (SmallCaps lst) = inlineListToDokuWiki opts lst  inlineToDokuWiki opts (Quoted SingleQuote lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "\8216" ++ contents ++ "\8217"+  return $ "\8216" <> contents <> "\8217"  inlineToDokuWiki opts (Quoted DoubleQuote lst) = do   contents <- inlineListToDokuWiki opts lst-  return $ "\8220" ++ contents ++ "\8221"+  return $ "\8220" <> contents <> "\8221"  inlineToDokuWiki opts (Cite _  lst) = inlineListToDokuWiki opts lst @@ -450,11 +441,11 @@   -- characters.   -- It does mean that if pandoc could ever read dokuwiki, and so round-trip the format,   -- any formatting inside inlined code blocks would be lost, or presented incorrectly.-  return $ "''%%" ++ str ++ "%%''"+  return $ "''%%" <> str <> "%%''"  inlineToDokuWiki _ (Str str) = return $ escapeString str -inlineToDokuWiki _ (Math mathType str) = return $ delim ++ str ++ delim+inlineToDokuWiki _ (Math mathType str) = return $ delim <> str <> delim                                  -- note:  str should NOT be escaped   where delim = case mathType of                      DisplayMath -> "$$"@@ -462,7 +453,7 @@  inlineToDokuWiki _ il@(RawInline f str)   | f == Format "dokuwiki" = return str-  | f == Format "html"     = return $ "<html>" ++ str ++ "</html>"+  | f == Format "html"     = return $ "<html>" <> str <> "</html>"   | otherwise              = "" <$ report (InlineNotRendered il)  inlineToDokuWiki _ LineBreak = do@@ -482,34 +473,34 @@ inlineToDokuWiki opts (Link _ txt (src, _)) = do   label <- inlineListToDokuWiki opts txt   case txt of-     [Str s] | "mailto:" `isPrefixOf` src -> return $ "<" ++ s ++ ">"+     [Str s] | "mailto:" `T.isPrefixOf` src -> return $ "<" <> s <> ">"              | escapeURI 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+              then return $ "[[" <> src  <> "|" <> label <> "]]"+              else return $ "[[" <> src' <> "|" <> label <> "]]"+                     where src' = case T.uncons src of+                                     Just ('/',xs) -> xs  -- with leading / it's a+                                     _             -> src -- link to a help page inlineToDokuWiki opts (Image attr alt (source, tit)) = do   alt' <- inlineListToDokuWiki opts alt   let txt = case (tit, alt) of               ("", []) -> ""-              ("", _ ) -> "|" ++ alt'-              (_ , _ ) -> "|" ++ tit-  return $ "{{" ++ source ++ imageDims opts attr ++ txt ++ "}}"+              ("", _ ) -> "|" <> alt'+              (_ , _ ) -> "|" <> tit+  return $ "{{" <> source <> imageDims opts attr <> txt <> "}}"  inlineToDokuWiki opts (Note contents) = do   contents' <- blockListToDokuWiki opts contents-  return $ "((" ++ contents' ++ "))"+  return $ "((" <> contents' <> "))"   -- note - may not work for notes with multiple blocks -imageDims :: WriterOptions -> Attr -> String+imageDims :: WriterOptions -> Attr -> Text imageDims opts attr = go (toPx $ dimension Width attr) (toPx $ dimension Height attr)   where     toPx = fmap (showInPixel opts) . checkPct     checkPct (Just (Percent _)) = Nothing     checkPct maybeDim           = maybeDim-    go (Just w) Nothing  = "?" ++ w-    go (Just w) (Just h) = "?" ++ w ++ "x" ++ h-    go Nothing  (Just h) = "?0x" ++ h+    go (Just w) Nothing  = "?" <> w+    go (Just w) (Just h) = "?" <> w <> "x" <> h+    go Nothing  (Just h) = "?0x" <> h     go Nothing  Nothing  = ""
src/Text/Pandoc/Writers/EPUB.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE CPP                 #-} {-# LANGUAGE FlexibleContexts    #-} {-# LANGUAGE PatternGuards       #-}+{-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} {- |    Module      : Text.Pandoc.Writers.EPUB@@ -21,12 +22,12 @@ import Control.Applicative ( (<|>) ) import Control.Monad (mplus, unless, when, zipWithM) import Control.Monad.Except (catchError, throwError)-import Control.Monad.State.Strict (State, StateT, evalState, evalStateT, get,-                                   gets, lift, modify, put)+import Control.Monad.State.Strict (StateT, evalState, evalStateT, get,+                                   gets, lift, modify) import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy.Char8 as B8 import Data.Char (isAlphaNum, isAscii, isDigit, toLower)-import Data.List (intercalate, isInfixOf, isPrefixOf)+import Data.List (isInfixOf, isPrefixOf) import qualified Data.Map as M import Data.Maybe (fromMaybe, isNothing, mapMaybe, isJust) import qualified Data.Set as Set@@ -41,14 +42,14 @@ import Data.Time import Text.Pandoc.Definition import Text.Pandoc.Error+import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.MIME (MimeType, extensionFromMimeType, getMimeType) import Text.Pandoc.Options (EPUBVersion (..), HTMLMathMethod (..),                             ObfuscationMethod (NoObfuscation), WrapOption (..),                             WriterOptions (..))-import Text.Pandoc.Shared (hierarchicalize, normalizeDate, renderTags',-                           safeRead, stringify, trim, uniqueIdent)-import qualified Text.Pandoc.Shared as S (Element (..))+import Text.Pandoc.Shared (makeSections, normalizeDate, renderTags',+                           safeRead, stringify, trim, uniqueIdent, tshow) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.UUID (getUUID) import Text.Pandoc.Walk (query, walk, walkM)@@ -58,15 +59,16 @@                        add_attrs, lookupAttr, node, onlyElems, parseXML,                        ppElement, showElement, strContent, unode, unqual) import Text.Pandoc.XML (escapeStringForXML)+import Text.DocTemplates (FromContext(lookupContext), Context(..),+                          ToContext(toVal), Val(..)) --- A Chapter includes a list of blocks and maybe a section--- number offset.  Note, some chapters are unnumbered. The section--- number is different from the index number, which will be used--- in filenames, chapter0003.xhtml.-data Chapter = Chapter (Maybe [Int]) [Block]+-- A Chapter includes a list of blocks.+data Chapter = Chapter [Block]+  deriving (Show)  data EPUBState = EPUBState {         stMediaPaths  :: [(FilePath, (FilePath, Maybe Entry))]+      , stMediaNextId :: Int       , stEpubSubdir  :: String       } @@ -137,6 +139,9 @@ removeNote (Note _) = Str "" removeNote x        = x +toVal' :: String -> Val TS.Text+toVal' = toVal . TS.pack+ mkEntry :: PandocMonad m => FilePath -> B.ByteString -> E m Entry mkEntry path content = do   epubSubdir <- gets stEpubSubdir@@ -164,17 +169,17 @@           else return m   let addLanguage m =        if null (epubLanguage m)-          then case lookup "lang" (writerVariables opts) of-                     Just x  -> return m{ epubLanguage = x }+          then case lookupContext "lang" (writerVariables opts) of+                     Just x  -> return m{ epubLanguage = TS.unpack x }                      Nothing -> do                        mLang <- lift $ P.lookupEnv "LANG"                        let localeLang =                              case mLang of                                Just lang ->-                                 map (\c -> if c == '_' then '-' else c) $-                                 takeWhile (/='.') lang+                                 TS.map (\c -> if c == '_' then '-' else c) $+                                 TS.takeWhile (/='.') lang                                Nothing -> "en-US"-                       return m{ epubLanguage = localeLang }+                       return m{ epubLanguage = TS.unpack localeLang }           else return m   let fixDate m =        if null (epubDate m)@@ -189,7 +194,7 @@           then return m           else do             let authors' = map stringify $ docAuthors meta-            let toAuthor name = Creator{ creatorText = name+            let toAuthor name = Creator{ creatorText = TS.unpack name                                        , creatorRole = Just "aut"                                        , creatorFileAs = Nothing }             return $ m{ epubCreator = map toAuthor authors' ++ epubCreator m }@@ -248,18 +253,18 @@ addMetadataFromXML _ md = md  metaValueToString :: MetaValue -> String-metaValueToString (MetaString s)    = s-metaValueToString (MetaInlines ils) = stringify ils-metaValueToString (MetaBlocks bs)   = stringify bs+metaValueToString (MetaString s)    = TS.unpack s+metaValueToString (MetaInlines ils) = TS.unpack $ stringify ils+metaValueToString (MetaBlocks bs)   = TS.unpack $ stringify bs metaValueToString (MetaBool True)   = "true" metaValueToString (MetaBool False)  = "false" metaValueToString _                 = "" -metaValueToPaths:: MetaValue -> [FilePath]+metaValueToPaths :: MetaValue -> [FilePath] metaValueToPaths (MetaList xs) = map metaValueToString xs metaValueToPaths x             = [metaValueToString x] -getList :: String -> Meta -> (MetaValue -> a) -> [a]+getList :: TS.Text -> Meta -> (MetaValue -> a) -> [a] getList s meta handleMetaValue =   case lookupMeta s meta of        Just (MetaList xs) -> map handleMetaValue xs@@ -283,7 +288,7 @@                 , titleType = metaValueToString <$> M.lookup "type" m }         handleMetaValue mv = Title (metaValueToString mv) Nothing Nothing -getCreator :: String -> Meta -> [Creator]+getCreator :: TS.Text -> Meta -> [Creator] getCreator s meta = getList s meta handleMetaValue   where handleMetaValue (MetaMap m) =            Creator{ creatorText = maybe "" metaValueToString $ M.lookup "text" m@@ -291,7 +296,7 @@                   , creatorRole = metaValueToString <$> M.lookup "role" m }         handleMetaValue mv = Creator (metaValueToString mv) Nothing Nothing -getDate :: String -> Meta -> [Date]+getDate :: TS.Text -> Meta -> [Date] getDate s meta = getList s meta handleMetaValue   where handleMetaValue (MetaMap m) =            Date{ dateText = fromMaybe "" $@@ -300,7 +305,7 @@         handleMetaValue mv = Date { dateText = fromMaybe "" $ normalizeDate' $ metaValueToString mv                                   , dateEvent = Nothing } -simpleList :: String -> Meta -> [String]+simpleList :: TS.Text -> Meta -> [String] simpleList s meta =   case lookupMeta s meta of        Just (MetaList xs) -> map metaValueToString xs@@ -346,11 +351,14 @@         relation = metaValueToString <$> lookupMeta "relation" meta         coverage = metaValueToString <$> lookupMeta "coverage" meta         rights = metaValueToString <$> lookupMeta "rights" meta-        coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus`-             (metaValueToString <$> lookupMeta "cover-image" meta)+        coverImage =+            (TS.unpack <$> lookupContext "epub-cover-image"+                              (writerVariables opts))+            `mplus` (metaValueToString <$> lookupMeta "cover-image" meta)         mCss = lookupMeta "css" meta <|> lookupMeta "stylesheet" meta         stylesheets = fromMaybe [] (metaValueToPaths <$> mCss) ++-                        [f | ("css",f) <- writerVariables opts]+                      maybe [] (\t -> [TS.unpack t])+                        (lookupContext "css" (writerVariables opts))         pageDirection = case map toLower . metaValueToString <$>                              lookupMeta "page-progression-direction" meta of                               Just "ltr" -> Just LTR@@ -358,11 +366,11 @@                               _          -> Nothing         ibooksFields = case lookupMeta "ibooks" meta of                             Just (MetaMap mp)-                               -> M.toList $ M.map metaValueToString mp+                               -> M.toList $ M.mapKeys TS.unpack $ M.map metaValueToString mp                             _  -> []         calibreFields = case lookupMeta "calibre" meta of                             Just (MetaMap mp)-                               -> M.toList $ M.map metaValueToString mp+                               -> M.toList $ M.mapKeys TS.unpack $ M.map metaValueToString mp                             _  -> []  -- | Produce an EPUB2 file from a Pandoc document.@@ -388,9 +396,9 @@ writeEPUB epubVersion opts doc = do   let epubSubdir = writerEpubSubdirectory opts   -- sanity check on epubSubdir-  unless (all (\c -> isAscii c && isAlphaNum c) epubSubdir) $+  unless (TS.all (\c -> isAscii c && isAlphaNum c) epubSubdir) $     throwError $ PandocEpubSubdirectoryError epubSubdir-  let initState = EPUBState { stMediaPaths = [], stEpubSubdir = epubSubdir }+  let initState = EPUBState { stMediaPaths = [], stMediaNextId = 0, stEpubSubdir = TS.unpack epubSubdir }   evalStateT (pandocToEPUB epubVersion opts doc) initState  pandocToEPUB :: PandocMonad m@@ -414,7 +422,7 @@                         [] -> case epubTitle metadata of                                    []    -> "UNTITLED"                                    (x:_) -> titleText x-                        x  -> stringify x+                        x  -> TS.unpack $ stringify x    -- stylesheet   stylesheets <- case epubStylesheets metadata of@@ -425,10 +433,15 @@         (\bs n -> mkEntry ("styles/stylesheet" ++ show n ++ ".css") bs)         stylesheets [(1 :: Int)..] -  let vars = ("epub3", if epub3 then "true" else "false")-             : [(x,y) | (x,y) <- writerVariables opts, x /= "css"]+  let vars = Context $+               M.delete "css" .+               M.insert "epub3"+                 (toVal' $ if epub3 then "true" else "false") .+               M.insert "lang" (toVal' $ epubLanguage metadata)+             $ unContext $ writerVariables opts -  let cssvars useprefix = map (\e -> ("css",+  let cssvars useprefix = Context $ M.fromList $ map+                       (\e -> ("css", toVal' $                                (if useprefix                                    then "../"                                    else "")@@ -450,14 +463,25 @@                      Nothing   -> return ([],[])                      Just img  -> do                        let coverImage = takeFileName img+                       imgContent <- lift $ P.readFileLazy img+                       (coverImageWidth, coverImageHeight) <-+                             case imageSize opts' (B.toStrict imgContent) of+                               Right sz  -> return $ sizeInPixels sz+                               Left err' -> (0, 0) <$ report+                                 (CouldNotDetermineImageSize (TS.pack img) err')                        cpContent <- lift $ writeHtml                             opts'{ writerVariables =-                                    ("coverpage","true"):-                                    ("pagetitle",-                                       escapeStringForXML plainTitle):-                                     cssvars True ++ vars }-                            (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"../media/" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])-                       imgContent <- lift $ P.readFileLazy img+                                   Context (M.fromList [+                                    ("coverpage", toVal' "true"),+                                    ("pagetitle", toVal $+                                      escapeStringForXML $ TS.pack plainTitle),+                                    ("cover-image", toVal' coverImage),+                                    ("cover-image-width", toVal' $+                                       show coverImageWidth),+                                    ("cover-image-height", toVal' $+                                       show coverImageHeight)]) <>+                                     cssvars True <> vars }+                            (Pandoc meta [])                        coverEntry <- mkEntry "text/cover.xhtml" cpContent                        coverImageEntry <- mkEntry ("media/" ++ coverImage)                                              imgContent@@ -466,10 +490,13 @@    -- title page   tpContent <- lift $ writeHtml opts'{-                                  writerVariables = ("titlepage","true"):-                                  ("body-type", "frontmatter"):-                                  ("pagetitle", escapeStringForXML plainTitle):-                                  cssvars True ++ vars }+                                  writerVariables =+                                      Context (M.fromList [+                                        ("titlepage", toVal' "true"),+                                        ("body-type",  toVal' "frontmatter"),+                                        ("pagetitle", toVal $+                                            escapeStringForXML $ TS.pack plainTitle)])+                                      <> cssvars True <> vars }                                (Pandoc meta [])   tpEntry <- mkEntry "text/title_page.xhtml" tpContent @@ -477,7 +504,7 @@   let matchingGlob f = do         xs <- lift $ P.glob f         when (null xs) $-          report $ CouldNotFetchResource f "glob did not match any font files"+          report $ CouldNotFetchResource (TS.pack f) "glob did not match any font files"         return xs   let mkFontEntry f = mkEntry ("fonts/" ++ takeFileName f) =<<                         lift (P.readFileLazy f)@@ -494,81 +521,74 @@    -- body pages -  -- add level 1 header to beginning if none there-  let blocks' = addIdentifiers opts-                $ case blocks of-                      (Header 1 _ _ : _) -> blocks-                      _                  -> Header 1 ("",["unnumbered"],[])-                                                 (docTitle' meta) : blocks-   let chapterHeaderLevel = writerEpubChapterLevel opts -  let isChapterHeader (Header n _ _) = n <= chapterHeaderLevel-      isChapterHeader (Div ("refs",_,_) (Header n _ _:_)) =-        n <= chapterHeaderLevel+  let isChapterHeader (Div _ (Header n _ _:_)) = n <= chapterHeaderLevel       isChapterHeader _ = False -  let toChapters :: [Block] -> State [Int] [Chapter]-      toChapters []     = return []-      toChapters (Div ("refs",_,_) bs@(Header 1 _ _:_) : rest) =-        toChapters (bs ++ rest)-      toChapters (Header n attr@(_,classes,_) ils : bs) = do-        nums <- get-        mbnum <- if "unnumbered" `elem` classes-                    then return Nothing-                    else case splitAt (n - 1) nums of-                              (ks, m:_) -> do-                                let nums' = ks ++ [m+1]-                                put nums'-                                return $ Just (ks ++ [m])-                                -- note, this is the offset not the sec number-                              (ks, []) -> do-                                let nums' = ks ++ [1]-                                put nums'-                                return $ Just ks-        let (xs,ys) = break isChapterHeader bs-        (Chapter mbnum (Header n attr ils : xs) :) `fmap` toChapters ys-      toChapters (b:bs) = do-        let (xs,ys) = break isChapterHeader bs-        (Chapter Nothing (b:xs) :) `fmap` toChapters ys+  let secsToChapters :: [Block] -> [Chapter]+      secsToChapters [] = []+      secsToChapters (d@(Div attr (h@(Header lvl _ _) : bs)) : rest)+        | chapterHeaderLevel == lvl =+           Chapter [d] : secsToChapters rest+        | chapterHeaderLevel > lvl =+           Chapter [Div attr (h:xs)] :+           secsToChapters ys ++ secsToChapters rest+             where (xs, ys) = break isChapterHeader bs+      secsToChapters bs =+          (if null xs then id else (Chapter xs :)) $ secsToChapters ys+            where (xs, ys) = break isChapterHeader bs -  let chapters' = evalState (toChapters blocks') []+  -- add level 1 header to beginning if none there+  let secs = makeSections True Nothing+              $ addIdentifiers opts+              $ case blocks of+                  (Div _+                    (Header{}:_) : _) -> blocks+                  (Header 1 _ _ : _)  -> blocks+                  _                   -> Header 1 ("",["unnumbered"],[])+                                             (docTitle' meta) : blocks -  let extractLinkURL' :: Int -> Inline -> [(String, String)]+  let chapters' = secsToChapters secs++  let extractLinkURL' :: Int -> Inline -> [(TS.Text, TS.Text)]       extractLinkURL' num (Span (ident, _, _) _)-        | not (null ident) = [(ident, showChapter num ++ ('#':ident))]+        | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]       extractLinkURL' _ _ = [] -  let extractLinkURL :: Int -> Block -> [(String, String)]+  let extractLinkURL :: Int -> Block -> [(TS.Text, TS.Text)]       extractLinkURL num (Div (ident, _, _) _)-        | not (null ident) = [(ident, showChapter num ++ ('#':ident))]+        | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]       extractLinkURL num (Header _ (ident, _, _) _)-        | not (null ident) = [(ident, showChapter num ++ ('#':ident))]+        | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]       extractLinkURL num b = query (extractLinkURL' num) b -  let reftable = concat $ zipWith (\(Chapter _ bs) num ->+  let reftable = concat $ zipWith (\(Chapter bs) num ->                                     query (extractLinkURL num) bs)                           chapters' [1..]    let fixInternalReferences :: Inline -> Inline-      fixInternalReferences (Link attr lab ('#':xs, tit)) =-        case lookup xs reftable of+      fixInternalReferences (Link attr lab (src, tit))+        | Just ('#', xs) <- TS.uncons src = case lookup xs reftable of              Just ys -> Link attr lab (ys, tit)-             Nothing -> Link attr lab ('#':xs, tit)+             Nothing -> Link attr lab (src, tit)       fixInternalReferences x = x    -- internal reference IDs change when we chunk the file,   -- so that '#my-header-1' might turn into 'chap004.xhtml#my-header'.   -- this fixes that:-  let chapters = map (\(Chapter mbnum bs) ->-                         Chapter mbnum $ walk fixInternalReferences bs)+  let chapters = map (\(Chapter bs) ->+                         Chapter $ walk fixInternalReferences bs)                  chapters' -  let chapToEntry num (Chapter mbnum bs) =+  let chapToEntry num (Chapter bs) =         mkEntry ("text/" ++ showChapter num) =<<-        writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum-                       , writerVariables = ("body-type", bodyType) :-                                           cssvars True ++ vars } pdoc+        writeHtml opts'{ writerVariables =+                            Context (M.fromList+                                     [("body-type", toVal' bodyType),+                                      ("pagetitle", toVal' $+                                           showChapter num)])+                            <> cssvars True <> vars } pdoc          where (pdoc, bodyType) =                  case bs of                      (Header _ (_,_,kvs) xs : _) ->@@ -625,14 +645,14 @@                             ("href", makeRelative epubSubdir                                      $ eRelativePath ent),                             ("media-type",-                               fromMaybe "application/octet-stream"+                               maybe "application/octet-stream" TS.unpack                                $ mediaTypeOf $ eRelativePath ent)] $ ()   let fontNode ent = unode "item" !                            [("id", toId $ makeRelative epubSubdir                                         $ eRelativePath ent),                             ("href", makeRelative epubSubdir                                      $ eRelativePath ent),-                            ("media-type", fromMaybe "" $+                            ("media-type", maybe "" TS.unpack $                                   getMimeType $ eRelativePath ent)] $ ()    let tocTitle = fromMaybe plainTitle $@@ -701,45 +721,47 @@   contentsEntry <- mkEntry "content.opf" contentsData    -- toc.ncx-  let secs = hierarchicalize blocks'-   let tocLevel = writerTOCDepth opts    let navPointNode :: PandocMonad m-                   => (Int -> [Inline] -> String -> [Element] -> Element)-                   -> S.Element -> StateT Int m Element-      navPointNode formatter (S.Sec _ nums (ident,_,_) ils children) = do-        n <- get-        modify (+1)-        let showNums :: [Int] -> String-            showNums = intercalate "." . map show-        let tit = if writerNumberSections opts && not (null nums)-                     then Span ("", ["section-header-number"], [])-                           [Str (showNums nums)] : Space : ils-                     else ils-        src <- case lookup ident reftable of-                 Just x  -> return x-                 Nothing -> throwError $ PandocSomeError $ ident ++ " not found in reftable"-        let isSec (S.Sec lev _ _ _ _) = lev <= tocLevel-            isSec _                   = False-        let subsecs = filter isSec children-        subs <- mapM (navPointNode formatter) subsecs-        return $ formatter n tit src subs-      navPointNode _ (S.Blk _) = throwError $ PandocSomeError "navPointNode encountered Blk"+                   => (Int -> [Inline] -> TS.Text -> [Element] -> Element)+                   -> Block -> StateT Int m [Element]+      navPointNode formatter (Div (ident,_,_)+                                (Header lvl (_,_,kvs) ils : children)) = do+        if lvl > tocLevel+           then return []+           else do+             n <- get+             modify (+1)+             let num = fromMaybe "" $ lookup "number" kvs+             let tit = if writerNumberSections opts && not (TS.null num)+                          then Span ("", ["section-header-number"], [])+                                [Str num] : Space : ils+                          else ils+             src <- case lookup ident reftable of+                      Just x  -> return x+                      Nothing -> throwError $ PandocSomeError $+                                    ident <> " not found in reftable"+             subs <- concat <$> mapM (navPointNode formatter) children+             return [formatter n tit src subs]+      navPointNode formatter (Div _ bs) =+        concat <$> mapM (navPointNode formatter) bs+      navPointNode _ _ = return [] -  let navMapFormatter :: Int -> [Inline] -> String -> [Element] -> Element+  let navMapFormatter :: Int -> [Inline] -> TS.Text -> [Element] -> Element       navMapFormatter n tit src subs = unode "navPoint" !                [("id", "navPoint-" ++ show n)] $-                  [ unode "navLabel" $ unode "text" $ stringify tit-                  , unode "content" ! [("src", "text/" ++ src)] $ ()+                  [ unode "navLabel" $ unode "text" $ TS.unpack $ stringify tit+                  , unode "content" ! [("src", "text/" <> TS.unpack src)] $ ()                   ] ++ subs    let tpNode = unode "navPoint" !  [("id", "navPoint-0")] $-                  [ unode "navLabel" $ unode "text" (stringify $ docTitle' meta)+                  [ unode "navLabel" $ unode "text" (TS.unpack $ stringify $ docTitle' meta)                   , unode "content" ! [("src", "text/title_page.xhtml")]                   $ () ] -  navMap <- lift $ evalStateT (mapM (navPointNode navMapFormatter) secs) 1+  navMap <- lift $ evalStateT+             (concat <$> mapM (navPointNode navMapFormatter) secs) 1   let tocData = UTF8.fromStringLazy $ ppTopElement $         unode "ncx" ! [("version","2005-1")                        ,("xmlns","http://www.daisy.org/z3986/2005/ncx/")] $@@ -762,11 +784,11 @@           ]   tocEntry <- mkEntry "toc.ncx" tocData -  let navXhtmlFormatter :: Int -> [Inline] -> String -> [Element] -> Element+  let navXhtmlFormatter :: Int -> [Inline] -> TS.Text -> [Element] -> Element       navXhtmlFormatter n tit src subs = unode "li" !                                        [("id", "toc-li-" ++ show n)] $                                             (unode "a" !-                                                [("href", "text/" ++ src)]+                                                [("href", "text/" <> TS.unpack src)]                                              $ titElements)                                             : case subs of                                                  []    -> []@@ -776,12 +798,13 @@                                (writeHtmlStringForEPUB version                                  opts{ writerTemplate = Nothing                                      , writerVariables =-                                       ("pagetitle",-                                         escapeStringForXML plainTitle):-                                       writerVariables opts}+                                         Context (M.fromList+                                           [("pagetitle", toVal $+                                             escapeStringForXML $ TS.pack plainTitle)])+                                       <> writerVariables opts}                                  (Pandoc nullMeta                                    [Plain $ walk clean tit])) of-                                Left _  -> TS.pack $ stringify tit+                                Left _  -> stringify tit                                 Right x -> x                 -- can't have <a> elements inside generated links...                 clean (Link _ ils _) = Span ("", [], []) ils@@ -789,9 +812,10 @@                 clean x              = x    let navtag = if epub3 then "nav" else "div"-  tocBlocks <- lift $ evalStateT (mapM (navPointNode navXhtmlFormatter) secs) 1+  tocBlocks <- lift $ evalStateT+                 (concat <$> mapM (navPointNode navXhtmlFormatter) secs) 1   let navBlocks = [RawBlock (Format "html")-                  $ showElement $ -- prettyprinting introduces bad spaces+                  $ TS.pack $ showElement $ -- prettyprinting introduces bad spaces                    unode navtag ! ([("epub:type","toc") | epub3] ++                                    [("id","toc")]) $                     [ unode "h1" ! [("id","toc-title")] $ tocTitle@@ -800,26 +824,27 @@                          then [ unode "li"                                 [ unode "a" ! [("href", "text/cover.xhtml")                                               ,("epub:type", "cover")] $-                                  "Cover"] |+                                  ("Cover" :: String)] |                                   isJust (epubCoverImage metadata)                               ] ++                               [ unode "li"                                 [ unode "a" ! [("href", "#toc")                                               ,("epub:type", "toc")] $-                                    "Table of contents"+                                    ("Table of contents" :: String)                                 ] | writerTableOfContents opts                               ]                          else []   let landmarks = if null landmarkItems                      then []-                     else [RawBlock (Format "html") $ ppElement $+                     else [RawBlock (Format "html") $ TS.pack $ ppElement $                             unode "nav" ! [("epub:type","landmarks")                                           ,("id","landmarks")                                           ,("hidden","hidden")] $                             [ unode "ol" landmarkItems ]                           ]-  navData <- lift $ writeHtml opts'{ writerVariables = ("navpage","true"):-                     cssvars False ++ vars }+  navData <- lift $ writeHtml opts'{ writerVariables =+                     Context (M.fromList [("navpage", toVal' "true")])+                     <> cssvars False <> vars }             (Pandoc (setMeta "title"                      (walk removeNote $ fromList $ docTitle' meta) nullMeta)                (navBlocks ++ landmarks))@@ -845,7 +870,7 @@   let apple = UTF8.fromStringLazy $ ppTopElement $         unode "display_options" $           unode "platform" ! [("name","*")] $-            unode "option" ! [("name","specified-fonts")] $ "true"+            unode "option" ! [("name","specified-fonts")] $ ("true" :: String)   appleEntry <- mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple    -- construct archive@@ -948,6 +973,7 @@              (("id",id') :                 maybe [] (\x -> [("opf:event",x)]) (dateEvent date)) $                  dateText date]+        schemeToOnix :: String -> String         schemeToOnix "ISBN-10"              = "02"         schemeToOnix "GTIN-13"              = "03"         schemeToOnix "UPC"                  = "04"@@ -969,42 +995,50 @@ showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ"  transformTag :: PandocMonad m-             => Tag String-             -> E m (Tag String)+             => Tag TS.Text+             -> E m (Tag TS.Text) transformTag tag@(TagOpen name attr)   | name `elem` ["video", "source", "img", "audio"] &&     isNothing (lookup "data-external" attr) = do   let src = fromAttrib "src" tag   let poster = fromAttrib "poster" tag-  newsrc <- modifyMediaRef src-  newposter <- modifyMediaRef poster+  newsrc <- modifyMediaRef $ TS.unpack src+  newposter <- modifyMediaRef $ TS.unpack poster   let attr' = filter (\(x,_) -> x /= "src" && x /= "poster") attr ++-              [("src", "../" ++ newsrc) | not (null newsrc)] ++-              [("poster", "../" ++ newposter) | not (null newposter)]+              [("src", "../" <> newsrc) | not (TS.null newsrc)] +++              [("poster", "../" <> newposter) | not (TS.null newposter)]   return $ TagOpen name attr' transformTag tag = return tag  modifyMediaRef :: PandocMonad m                => FilePath-               -> E m FilePath+               -> E m TS.Text modifyMediaRef "" = return "" modifyMediaRef oldsrc = do   media <- gets stMediaPaths   case lookup oldsrc media of-         Just (n,_) -> return n+         Just (n,_) -> return $ TS.pack n          Nothing    -> catchError-           (do (img, mbMime) <- P.fetchItem oldsrc-               let new = "media/file" ++ show (length media) ++-                          fromMaybe (takeExtension (takeWhile (/='?') oldsrc))-                          (('.':) <$> (mbMime >>= extensionFromMimeType))-               entry <- mkEntry new (B.fromChunks . (:[]) $ img)+           (do (img, mbMime) <- P.fetchItem $ TS.pack oldsrc+               let ext = maybe (takeExtension (takeWhile (/='?') oldsrc)) TS.unpack+                         (("." <>) <$> (mbMime >>= extensionFromMimeType))+               newName <- getMediaNextNewName ext+               let newPath = "media/" ++ newName+               entry <- mkEntry newPath (B.fromChunks . (:[]) $ img)                modify $ \st -> st{ stMediaPaths =-                            (oldsrc, (new, Just entry)):media}-               return new)+                            (oldsrc, (newPath, Just entry)):media}+               return $ TS.pack newPath)            (\e -> do-                report $ CouldNotFetchResource oldsrc (show e)-                return oldsrc)+                report $ CouldNotFetchResource (TS.pack oldsrc) (tshow e)+                return $ TS.pack oldsrc) +getMediaNextNewName :: PandocMonad m => String -> E m String+getMediaNextNewName ext = do+  nextId <- gets stMediaNextId+  modify $ \st -> st { stMediaNextId = nextId + 1 }+  let nextName = "file" ++ show nextId ++ ext+  (P.fetchItem (TS.pack nextName) >> getMediaNextNewName ext) `catchError` const (return nextName)+ transformBlock  :: PandocMonad m                 => Block                 -> E m Block@@ -1020,14 +1054,14 @@                  -> Inline                  -> E m Inline transformInline _opts (Image attr lab (src,tit)) = do-    newsrc <- modifyMediaRef src-    return $ Image attr lab ("../" ++ newsrc, tit)+    newsrc <- modifyMediaRef $ TS.unpack src+    return $ Image attr lab ("../" <> newsrc, tit) transformInline opts (x@(Math t m))   | WebTeX url <- writerHTMLMathMethod opts = do-    newsrc <- modifyMediaRef (url ++ urlEncode m)+    newsrc <- modifyMediaRef (TS.unpack url <> urlEncode (TS.unpack m))     let mathclass = if t == DisplayMath then "display" else "inline"     return $ Span ("",["math",mathclass],[])-                [Image nullAttr [x] ("../" ++ newsrc, "")]+                [Image nullAttr [x] ("../" <> newsrc, "")] transformInline _opts (RawInline fmt raw)   | fmt == Format "html" = do   let tags = parseTags raw@@ -1047,7 +1081,7 @@         unEntity ('&':'#':xs) =                    let (ds,ys) = break (==';') xs                        rest = drop 1 ys-                   in  case safeRead ('\'':'\\':ds ++ "'") of+                   in  case safeRead (TS.pack $ "'\\" <> ds <> "'") of                           Just x  -> x : unEntity rest                           Nothing -> '&':'#':unEntity xs         unEntity (x:xs) = x : unEntity xs@@ -1056,7 +1090,7 @@ mediaTypeOf x =   let mediaPrefixes = ["image", "video", "audio"] in   case getMimeType x of-    Just y | any (`isPrefixOf` y) mediaPrefixes -> Just y+    Just y | any (`TS.isPrefixOf` y) mediaPrefixes -> Just y     _      -> Nothing  -- Returns filename for chapter number.@@ -1068,7 +1102,7 @@ addIdentifiers opts bs = evalState (mapM go bs) Set.empty  where go (Header n (ident,classes,kvs) ils) = do          ids <- get-         let ident' = if null ident+         let ident' = if TS.null ident                          then uniqueIdent (writerExtensions opts) ils ids                          else ident          modify $ Set.insert ident'@@ -1077,13 +1111,16 @@  -- Variant of normalizeDate that allows partial dates: YYYY, YYYY-MM normalizeDate' :: String -> Maybe String-normalizeDate' xs =-  let xs' = trim xs in-  case xs' of-       [y1,y2,y3,y4] | all isDigit [y1,y2,y3,y4] -> Just xs'     -- YYYY-       [y1,y2,y3,y4,'-',m1,m2] | all isDigit [y1,y2,y3,y4,m1,m2]  -- YYYY-MM-                                                 -> Just xs'-       _                                         -> normalizeDate xs'+normalizeDate' = fmap TS.unpack . go . trim . TS.pack+  where+    go xs+      | TS.length xs == 4            -- YYY+      , TS.all isDigit xs = Just xs+      | (y, s) <- TS.splitAt 4 xs    -- YYY-MM+      , Just ('-', m) <- TS.uncons s+      , TS.length m == 2+      , TS.all isDigit y && TS.all isDigit m = Just xs+      | otherwise = normalizeDate xs  toRelator :: String -> Maybe String toRelator x
src/Text/Pandoc/Writers/FB2.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE PatternGuards #-}+{-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE OverloadedStrings #-} {- | Module      : Text.Pandoc.Writers.FB2 Copyright   : Copyright (C) 2011-2012 Sergey Astanin@@ -23,11 +24,12 @@ import Control.Monad.Except (catchError) import Control.Monad.State.Strict (StateT, evalStateT, get, gets, lift, liftM, modify) import Data.ByteString.Base64 (encode)-import qualified Data.ByteString.Char8 as B8-import Data.Char (isAscii, isControl, isSpace, toLower)+import Data.Char (isAscii, isControl, isSpace) import Data.Either (lefts, rights)-import Data.List (intercalate, isPrefixOf, stripPrefix)+import Data.List (intercalate) import Data.Text (Text, pack)+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE import Network.HTTP (urlEncode) import Text.XML.Light import qualified Text.XML.Light as X@@ -39,16 +41,16 @@ import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..), def)-import Text.Pandoc.Shared (capitalize, isURI, orderedListMarkers, hierarchicalize)+import Text.Pandoc.Shared (capitalize, isURI, orderedListMarkers,+                           makeSections, tshow) import Text.Pandoc.Writers.Shared (lookupMetaString)-import qualified Text.Pandoc.Shared as Shared (Element(Blk, Sec))  -- | Data to be written at the end of the document: -- (foot)notes, URLs, references, images. data FbRenderState = FbRenderState-    { footnotes         :: [ (Int, String, [Content]) ]  -- ^ #, ID, text-    , imagesToFetch     :: [ (String, String) ]  -- ^ filename, URL or path-    , parentListMarker  :: String  -- ^ list marker of the parent ordered list+    { footnotes         :: [ (Int, Text, [Content]) ]  -- ^ #, ID, text+    , imagesToFetch     :: [ (Text, Text) ]  -- ^ filename, URL or path+    , parentListMarker  :: Text  -- ^ list marker of the parent ordered list     , writerOptions     :: WriterOptions     } deriving (Show) @@ -98,8 +100,8 @@ description :: PandocMonad m => Meta -> FBM m Content description meta' = do   let genre = case lookupMetaString "genre" meta' of-                "" -> el "genre" "unrecognised"-                s  -> el "genre" s+                "" -> el "genre" ("unrecognised" :: String)+                s  -> el "genre" (T.unpack s)   bt <- booktitle meta'   let as = authors meta'   dd <- docdate meta'@@ -110,7 +112,7 @@                Just (MetaInlines [Str s]) -> [el "lang" $ iso639 s]                Just (MetaString s)        -> [el "lang" $ iso639 s]                _                          -> []-             where iso639 = takeWhile (/= '-') -- Convert BCP 47 to ISO 639+             where iso639 = T.unpack . T.takeWhile (/= '-') -- Convert BCP 47 to ISO 639   let coverimage url = do         let img = Image nullAttr mempty (url, "")         im <- insertImage InlineImage img@@ -122,7 +124,7 @@   return $ el "description"     [ el "title-info" (genre :                       (as ++ bt ++ annotation ++ dd ++ coverpage ++ lang))-    , el "document-info" [el "program-used" "pandoc"]+    , el "document-info" [el "program-used" ("pandoc" :: String)]     ]  booktitle :: PandocMonad m => Meta -> FBM m [Content]@@ -162,28 +164,27 @@ -- representation. renderSections :: PandocMonad m => Int -> [Block] -> FBM m [Content] renderSections level blocks = do-    let elements = hierarchicalize blocks-    let isSection Shared.Sec{} = True+    let blocks' = makeSections False Nothing blocks+    let isSection (Div (_,"section":_,_) (Header{}:_)) = True         isSection _ = False-    let (initialBlocks, secs) = break isSection elements-    let elements' = if null initialBlocks-        then secs-        else Shared.Sec 1 [] nullAttr mempty initialBlocks : secs-    cMapM (renderSection level) elements'--+    let (initialBlocks, secs) = break isSection blocks'+    let blocks'' = if null initialBlocks+        then blocks'+        else Div ("",["section"],[])+               (Header 1 nullAttr mempty : initialBlocks) : secs+    cMapM (renderSection level) blocks'' -renderSection :: PandocMonad m =>  Int -> Shared.Element -> FBM m [Content]-renderSection _   (Shared.Blk block) = blockToXml block-renderSection lvl (Shared.Sec _ _num (id',_,_) title elements) = do-  content <- cMapM (renderSection (lvl + 1)) elements+renderSection :: PandocMonad m =>  Int -> Block -> FBM m [Content]+renderSection lvl (Div (id',"section":_,_) (Header _ _ title : xs)) = do   title' <- if null title             then return []             else list . el "title" <$> formatTitle title-  let sectionContent = if null id'+  content <- cMapM (renderSection (lvl + 1)) xs+  let sectionContent = if T.null id'       then el "section" (title' ++ content)       else el "section" ([uattr "id" id'], title' ++ content)   return [sectionContent]+renderSection _ b = blockToXml b  -- | Only <p> and <empty-line> are allowed within <title> in FB2. formatTitle :: PandocMonad m => [Inline] -> FBM m [Content]@@ -214,19 +215,19 @@  -- | Fetch images and encode them for the FictionBook XML. -- Return image data and a list of hrefs of the missing images.-fetchImages :: PandocMonad m => [(String,String)] -> m ([Content],[String])+fetchImages :: PandocMonad m => [(Text,Text)] -> m ([Content],[Text]) fetchImages links = do     imgs <- mapM (uncurry fetchImage) links     return (rights imgs, lefts imgs)  -- | Fetch image data from disk or from network and make a <binary> XML section. -- Return either (Left hrefOfMissingImage) or (Right xmlContent).-fetchImage :: PandocMonad m => String -> String -> m (Either String Content)+fetchImage :: PandocMonad m => Text -> Text -> m (Either Text Content) fetchImage href link = do   mbimg <-       case (isURI link, readDataURI link) of        (True, Just (mime,_,True,base64)) ->-           let mime' = map toLower mime+           let mime' = T.toLower mime            in if mime' == "image/png" || mime' == "image/jpeg"               then return (Just (mime',base64))               else return Nothing@@ -238,9 +239,9 @@                                report $ CouldNotDetermineMimeType link                                return Nothing                              Just mime -> return $ Just (mime,-                                                      B8.unpack $ encode bs))+                                                      TE.decodeUtf8 $ encode bs))                     (\e ->-                       do report $ CouldNotFetchResource link (show e)+                       do report $ CouldNotFetchResource link (tshow e)                           return Nothing)   case mbimg of     Just (imgtype, imgdata) ->@@ -248,52 +249,52 @@                    ( [uattr "id" href                      , uattr "content-type" imgtype]                    , txt imgdata )-    _ -> return (Left ('#':href))+    _ -> return (Left ("#" <> href))   -- | Extract mime type and encoded data from the Data URI.-readDataURI :: String -- ^ URI-            -> Maybe (String,String,Bool,String)+readDataURI :: Text -- ^ URI+            -> Maybe (Text,Text,Bool,Text)                -- ^ Maybe (mime,charset,isBase64,data) readDataURI uri =-  case stripPrefix "data:" uri of+  case T.stripPrefix "data:" uri of     Nothing   -> Nothing     Just rest ->-      let meta = takeWhile (/= ',') rest  -- without trailing ','-          uridata = drop (length meta + 1) rest-          parts = split (== ';') meta+      let meta = T.takeWhile (/= ',') rest  -- without trailing ','+          uridata = T.drop (T.length meta + 1) rest+          parts = T.split (== ';') meta           (mime,cs,enc)=foldr upd ("text/plain","US-ASCII",False) parts       in  Just (mime,cs,enc,uridata)   where    upd str m@(mime,cs,enc)-       | isMimeType str                          = (str,cs,enc)-       | Just str' <- stripPrefix "charset=" str = (mime,str',enc)-       | str ==  "base64"                        = (mime,cs,True)-       | otherwise                               = m+       | isMimeType str                            = (str,cs,enc)+       | Just str' <- T.stripPrefix "charset=" str = (mime,str',enc)+       | str ==  "base64"                          = (mime,cs,True)+       | otherwise                                 = m  -- Without parameters like ;charset=...; see RFC 2045, 5.1-isMimeType :: String -> Bool+isMimeType :: Text -> Bool isMimeType s =-    case split (=='/') s of+    case T.split (=='/') s of       [mtype,msubtype] ->-          (map toLower mtype `elem` types-           || "x-" `isPrefixOf` map toLower mtype)-          && all valid mtype-          && all valid msubtype+          (T.toLower mtype `elem` types+           || "x-" `T.isPrefixOf` T.toLower mtype)+          && T.all valid mtype+          && T.all valid msubtype       _ -> False  where    types =  ["text","image","audio","video","application","message","multipart"]    valid c = isAscii c && not (isControl c) && not (isSpace c) &&-             c `notElem` "()<>@,;:\\\"/[]?="+             c `notElem` ("()<>@,;:\\\"/[]?=" :: String) -footnoteID :: Int -> String-footnoteID i = "n" ++ show i+footnoteID :: Int -> Text+footnoteID i = "n" <> tshow i -mkitem :: PandocMonad m => String -> [Block] -> FBM m [Content]+mkitem :: PandocMonad m => Text -> [Block] -> FBM m [Content] mkitem mrk bs = do   pmrk <- gets parentListMarker-  let nmrk = pmrk ++ mrk ++ " "+  let nmrk = pmrk <> mrk <> " "   modify (\s -> s { parentListMarker = nmrk})   item <- cMapM blockToXml $ plainToPara $ indentBlocks nmrk bs   modify (\s -> s { parentListMarker = pmrk }) -- old parent marker@@ -304,11 +305,12 @@ blockToXml (Plain ss) = cMapM toXml ss  -- FIXME: can lead to malformed FB2 blockToXml (Para [Math DisplayMath formula]) = insertMath NormalImage formula -- title beginning with fig: indicates that the image is a figure-blockToXml (Para [Image atr alt (src,'f':'i':'g':':':tit)]) =-  insertImage NormalImage (Image atr alt (src,tit))+blockToXml (Para [Image atr alt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt+  = insertImage NormalImage (Image atr alt (src,tit)) blockToXml (Para ss) = list . el "p" <$> cMapM toXml ss blockToXml (CodeBlock _ s) = return . spaceBeforeAfter .-                             map (el "p" . el "code") . lines $ s+                             map (el "p" . el "code" . T.unpack) . T.lines $ s blockToXml (RawBlock f str) =   if f == Format "fb2"     then return $ XI.parseXML str@@ -330,11 +332,11 @@     cMapM mkdef defs     where       mkdef (term, bss) = do-          items <- cMapM (cMapM blockToXml . plainToPara . indentBlocks (replicate 4 ' ')) bss+          items <- cMapM (cMapM blockToXml . plainToPara . indentBlocks (T.replicate 4 " ")) bss           t <- wrap "strong" term           return (el "p" t : items) blockToXml h@Header{} = do-  -- should not occur after hierarchicalize, except inside lists/blockquotes+  -- should not occur after makeSections, except inside lists/blockquotes   report $ BlockNotRendered h   return [] blockToXml HorizontalRule = return [ el "empty-line" () ]@@ -377,13 +379,13 @@  -- Simulate increased indentation level. Will not really work -- for multi-line paragraphs.-indentPrefix :: String -> Block -> Block+indentPrefix :: Text -> Block -> Block indentPrefix spacer = indentBlock   where   indentBlock (Plain ins) = Plain (Str spacer:ins)   indentBlock (Para ins) = Para (Str spacer:ins)   indentBlock (CodeBlock a s) =-    let s' = unlines . map (spacer++) . lines $ s+    let s' = T.unlines . map (spacer<>) . T.lines $ s     in  CodeBlock a s'   indentBlock (BlockQuote bs) = BlockQuote (map indent bs)   indentBlock (Header l attr' ins) = Header l attr' (indentLines ins)@@ -397,12 +399,12 @@ indent = indentPrefix spacer   where   -- indentation space-  spacer :: String-  spacer = replicate 4 ' '+  spacer :: Text+  spacer = T.replicate 4 " " -indentBlocks :: String -> [Block] -> [Block]+indentBlocks :: Text -> [Block] -> [Block] indentBlocks _ [] = []-indentBlocks prefix (x:xs) = indentPrefix prefix x : map (indentPrefix $ replicate (length prefix) ' ') xs+indentBlocks prefix (x:xs) = indentPrefix prefix x : map (indentPrefix $ T.replicate (T.length prefix) " ") xs  -- | Convert a Pandoc's Inline element to FictionBook XML representation. toXml :: PandocMonad m => Inline -> FBM m [Content]@@ -421,7 +423,7 @@   inner <- cMapM toXml ss   return $ [txt "“"] ++ inner ++ [txt "”"] toXml (Cite _ ss) = cMapM toXml ss  -- FIXME: support citation styles-toXml (Code _ s) = return [el "code" s]+toXml (Code _ s) = return [el "code" $ T.unpack s] toXml Space = return [txt " "] toXml SoftBreak = return [txt "\n"] toXml LineBreak = return [txt "\n"]@@ -439,40 +441,40 @@   let fn_id = footnoteID n   fn_desc <- cMapM blockToXml bs   modify (\s -> s { footnotes = (n, fn_id, fn_desc) : fns })-  let fn_ref = txt $ "[" ++ show n ++ "]"-  return . list $ el "a" ( [ attr ("l","href") ('#':fn_id)+  let fn_ref = txt $ "[" <> tshow n <> "]"+  return . list $ el "a" ( [ attr ("l","href") ("#" <> fn_id)                            , uattr "type" "note" ]                          , fn_ref ) -insertMath :: PandocMonad m => ImageMode -> String -> FBM m [Content]+insertMath :: PandocMonad m => ImageMode -> Text -> FBM m [Content] insertMath immode formula = do   htmlMath <- fmap (writerHTMLMathMethod . writerOptions) get   case htmlMath of     WebTeX url -> do        let alt = [Code nullAttr formula]-       let imgurl = url ++ urlEncode formula+       let imgurl = url <> T.pack (urlEncode $ T.unpack formula)        let img = Image nullAttr alt (imgurl, "")        insertImage immode img-    _ -> return [el "code" formula]+    _ -> return [el "code" $ T.unpack formula]  insertImage :: PandocMonad m => ImageMode -> Inline -> FBM m [Content] insertImage immode (Image _ alt (url,ttl)) = do   images <- imagesToFetch `liftM` get   let n = 1 + length images-  let fname = "image" ++ show n+  let fname = "image" <> tshow n   modify (\s -> s { imagesToFetch = (fname, url) : images })-  let ttlattr = case (immode, null ttl) of+  let ttlattr = case (immode, T.null ttl) of                   (NormalImage, False) -> [ uattr "title" ttl ]                   _                    -> []   return . list $          el "image" $-            [ attr ("l","href") ('#':fname)-            , attr ("l","type") (show immode)-            , uattr "alt" (cMap plain alt) ]+            [ attr ("l","href") ("#" <> fname)+            , attr ("l","type") (tshow immode)+            , uattr "alt" (T.pack $ cMap plain alt) ]             ++ ttlattr insertImage _ _ = error "unexpected inline instead of image" -replaceImagesWithAlt :: [String] -> Content -> Content+replaceImagesWithAlt :: [Text] -> Content -> Content replaceImagesWithAlt missingHrefs body =   let cur = XC.fromContent body       cur' = replaceAll cur@@ -508,8 +510,8 @@              (Just alt', Just imtype') ->                  if imtype' == show NormalImage                  then el "p" alt'-                 else txt alt'-             (Just alt', Nothing) -> txt alt'  -- no type attribute+                 else txt $ T.pack alt'+             (Just alt', Nothing) -> txt $ T.pack alt'  -- no type attribute              _ -> n   -- don't replace if alt text is not found     replaceNode n = n   --@@ -530,7 +532,7 @@  -- | Convert an 'Inline' to plaintext. plain :: Inline -> String-plain (Str s)               = s+plain (Str s)               = T.unpack s plain (Emph ss)             = cMap plain ss plain (Span _ ss)           = cMap plain ss plain (Strong ss)           = cMap plain ss@@ -540,13 +542,13 @@ plain (SmallCaps ss)        = cMap plain ss plain (Quoted _ ss)         = cMap plain ss plain (Cite _ ss)           = cMap plain ss  -- FIXME-plain (Code _ s)            = s+plain (Code _ s)            = T.unpack s plain Space                 = " " plain SoftBreak             = " " plain LineBreak             = "\n"-plain (Math _ s)            = s+plain (Math _ s)            = T.unpack s plain (RawInline _ _)       = ""-plain (Link _ text (url,_)) = concat (map plain text ++ [" <", url, ">"])+plain (Link _ text (url,_)) = concat (map plain text ++ [" <", T.unpack url, ">"]) plain (Image _ alt _)       = cMap plain alt plain (Note _)              = ""  -- FIXME @@ -564,16 +566,16 @@     in  [emptyline] ++ cs ++ [emptyline]  -- | Create a plain-text XML content.-txt :: String -> Content-txt s = Text $ CData CDataText s Nothing+txt :: Text -> Content+txt s = Text $ CData CDataText (T.unpack s) Nothing  -- | Create an XML attribute with an unqualified name.-uattr :: String -> String -> Text.XML.Light.Attr-uattr name = Attr (uname name)+uattr :: String -> Text -> Text.XML.Light.Attr+uattr name = Attr (uname name) . T.unpack  -- | Create an XML attribute with a qualified name from given namespace.-attr :: (String, String) -> String -> Text.XML.Light.Attr-attr (ns, name) = Attr (qname ns name)+attr :: (String, String) -> Text -> Text.XML.Light.Attr+attr (ns, name) = Attr (qname ns name) . T.unpack  -- | Unqualified name uname :: String -> QName
src/Text/Pandoc/Writers/HTML.hs view
@@ -1,9 +1,10 @@-{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP                 #-}+{-# LANGUAGE LambdaCase          #-}+{-# LANGUAGE MultiWayIf          #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns        #-}-{-# LANGUAGE MultiWayIf          #-} {- |    Module      : Text.Pandoc.Writers.HTML    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -28,24 +29,27 @@   writeRevealJs,   tagWithAttributes   ) where-import Prelude import Control.Monad.State.Strict-import Data.Char (ord, toLower)-import Data.List (intercalate, intersperse, isPrefixOf, partition)-import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing, mapMaybe)+import Data.Char (ord)+import Data.List (intercalate, intersperse, partition, delete)+import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe) import qualified Data.Set as Set-import Data.String (fromString) import Data.Text (Text)+import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Network.HTTP (urlEncode) import Network.URI (URI (..), parseURIReference) import Numeric (showHex)-import Text.Blaze.Internal (customLeaf, customParent, MarkupM(Empty))+import Text.DocLayout (render, literal)+import Prelude+import Text.Blaze.Internal (MarkupM (Empty), customLeaf, customParent)+import Text.DocTemplates (FromContext (lookupContext)) #if MIN_VERSION_blaze_markup(0,6,3) #else import Text.Blaze.Internal (preEscapedString, preEscapedText) #endif import Text.Blaze.Html hiding (contents)+import Text.DocTemplates (Context (..)) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (formatHtmlBlock, formatHtmlInline, highlight,                                  styleToCss)@@ -53,12 +57,11 @@ import Text.Pandoc.Options import Text.Pandoc.Shared import Text.Pandoc.Slides-import Text.Pandoc.Templates+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Walk import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared-import Text.Pandoc.XML (escapeStringForXML, fromEntities,-                        toEntities, toHtml5Entities)+import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities) #if MIN_VERSION_blaze_markup(0,6,3) #else import Text.Blaze.Internal (preEscapedString, preEscapedText)@@ -71,7 +74,6 @@ import qualified Text.Blaze.Html5.Attributes as A5 #endif import Control.Monad.Except (throwError)-import Data.Aeson (Value) import System.FilePath (takeBaseName) import Text.Blaze.Html.Renderer.Text (renderHtml) import qualified Text.Blaze.XHtml1.Transitional as H@@ -90,37 +92,39 @@     , stMath         :: Bool    -- ^ Math is used in document     , stQuotes       :: Bool    -- ^ <q> tag is used     , stHighlighting :: Bool    -- ^ Syntax highlighting is used-    , stSecNum       :: [Int]   -- ^ Number of current section-    , stElement      :: Bool    -- ^ Processing an Element     , stHtml5        :: Bool    -- ^ Use HTML5     , stEPUBVersion  :: Maybe EPUBVersion -- ^ EPUB version if for epub     , stSlideVariant :: HTMLSlideVariant+    , stSlideLevel   :: Int     -- ^ Slide level     , stCodeBlockNum :: Int     -- ^ Number of code block     }  defaultWriterState :: WriterState defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False,-                                  stHighlighting = False, stSecNum = [],-                                  stElement = False, stHtml5 = False,+                                  stHighlighting = False,+                                  stHtml5 = False,                                   stEPUBVersion = Nothing,                                   stSlideVariant = NoSlides,+                                  stSlideLevel = 1,                                   stCodeBlockNum = 0}  -- Helpers to render HTML with the appropriate function. -strToHtml :: String -> Html-strToHtml ('\'':xs) = preEscapedString "\'" `mappend` strToHtml xs-strToHtml ('"' :xs) = preEscapedString "\"" `mappend` strToHtml xs-strToHtml (x:xs) | needsVariationSelector x-                 = preEscapedString [x, '\xFE0E'] `mappend`-                   case xs of-                     ('\xFE0E':ys) -> strToHtml ys-                     _             -> strToHtml xs-strToHtml xs@(_:_)  = case break (\c -> c == '\'' || c == '"' ||-                                        needsVariationSelector c) xs of-                           (_ ,[]) -> toHtml xs-                           (ys,zs) -> toHtml ys `mappend` strToHtml zs-strToHtml [] = ""+strToHtml :: Text -> Html+strToHtml = strToHtml' . T.unpack+  where+    strToHtml' ('\'':xs) = preEscapedString "\'" `mappend` strToHtml' xs+    strToHtml' ('"' :xs) = preEscapedString "\"" `mappend` strToHtml' xs+    strToHtml' (x:xs) | needsVariationSelector x+                      = preEscapedString [x, '\xFE0E'] `mappend`+                        case xs of+                          ('\xFE0E':ys) -> strToHtml' ys+                          _             -> strToHtml' xs+    strToHtml' xs@(_:_) = case break (\c -> c == '\'' || c == '"' ||+                                       needsVariationSelector c) xs of+                            (_ ,[]) -> toHtml xs+                            (ys,zs) -> toHtml ys `mappend` strToHtml' zs+    strToHtml' [] = ""  -- See #5469: this prevents iOS from substituting emojis. needsVariationSelector :: Char -> Bool@@ -206,27 +210,28 @@ writeHtmlString' st opts d = do   (body, context) <- evalStateT (pandocToHtml opts d) st   (if writerPreferAscii opts-      then-        if stHtml5 st-           then toHtml5Entities-           else toEntities+      then toEntities       else id) <$>     case writerTemplate opts of        Nothing -> return $ renderHtml' body        Just tpl -> do          -- warn if empty lang-         when (isNothing (getField "lang" context :: Maybe String)) $+         when (isNothing (getField "lang" context :: Maybe Text)) $            report NoLangSpecified          -- check for empty pagetitle          context' <-             case getField "pagetitle" context of-                 Just (s :: String) | not (null s) -> return context+                 Just (s :: Text) | not (T.null s) -> return context                  _ -> do-                   let fallback = fromMaybe "Untitled" $ takeBaseName <$>-                           lookup "sourcefile" (writerVariables opts)+                   let fallback = T.pack $+                         case lookupContext "sourcefile"+                                   (writerVariables opts) of+                           Nothing    -> "Untitled"+                           Just []    -> "Untitled"+                           Just (x:_) -> takeBaseName $ T.unpack x                    report $ NoTitleElement fallback                    return $ resetField "pagetitle" fallback context-         renderTemplate' tpl+         return $ render Nothing $ renderTemplate tpl              (defField "body" (renderHtml' body) context')  writeHtml' :: PandocMonad m => WriterState -> WriterOptions -> Pandoc -> m Html@@ -244,61 +249,78 @@ pandocToHtml :: PandocMonad m              => WriterOptions              -> Pandoc-             -> StateT WriterState m (Html, Value)+             -> StateT WriterState m (Html, Context Text) pandocToHtml opts (Pandoc meta blocks) = do-  metadata <- metaToJSON opts-              (fmap renderHtml' . blockListToHtml opts)-              (fmap renderHtml' . inlineListToHtml opts)+  let slideLevel = fromMaybe (getSlideLevel blocks) $ writerSlideLevel opts+  modify $ \st -> st{ stSlideLevel = slideLevel }+  metadata <- metaToContext opts+              (fmap (literal . renderHtml') . blockListToHtml opts)+              (fmap (literal . renderHtml') . inlineListToHtml opts)               meta   let stringifyHTML = escapeStringForXML . stringify   let authsMeta = map stringifyHTML $ docAuthors meta   let dateMeta  = stringifyHTML $ docDate meta-  let slideLevel = fromMaybe (getSlideLevel blocks) $ writerSlideLevel opts   slideVariant <- gets stSlideVariant-  let sects = hierarchicalize $+  let sects = makeSections (writerNumberSections opts) Nothing $               if slideVariant == NoSlides                  then blocks                  else prepSlides slideLevel blocks   toc <- if writerTableOfContents opts && slideVariant /= S5Slides             then fmap renderHtml' <$> tableOfContents opts sects             else return Nothing-  blocks' <- liftM (mconcat . intersperse (nl opts)) $-                 mapM (elementToHtml Nothing slideLevel opts) sects+  blocks' <- blockListToHtml opts sects   st <- get   notes <- footnoteSection opts (reverse (stNotes st))   let thebody = blocks' >> notes   let math = case writerHTMLMathMethod opts of-                      MathJax url-                        | slideVariant /= RevealJsSlides ->-                        -- mathjax is handled via a special plugin in revealjs-                         H.script ! A.src (toValue url)-                                  ! A.type_ "text/javascript"-                                  $ case slideVariant of-                                         SlideousSlides ->-                                            preEscapedString-                                            "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);"-                                         _ -> mempty-                      KaTeX url -> do-                         H.script !-                           A.src (toValue $ url ++ "katex.min.js") $ mempty-                         nl opts-                         H.script-                            "document.addEventListener(\"DOMContentLoaded\", function () {\n  var mathElements = document.getElementsByClassName(\"math\");\n  for (var i = 0; i < mathElements.length; i++) {\n    var texText = mathElements[i].firstChild;\n    if (mathElements[i].tagName == \"SPAN\") { katex.render(texText.data, mathElements[i], { displayMode: mathElements[i].classList.contains(\"display\"), throwOnError: false } );\n  }}});"-                         nl opts-                         H.link ! A.rel "stylesheet" !-                           A.href (toValue $ url ++ "katex.min.css")+        MathJax url+          | slideVariant /= RevealJsSlides ->+          -- mathjax is handled via a special plugin in revealjs+            H.script ! A.src (toValue url)+                    ! A.type_ "text/javascript"+                    $ case slideVariant of+                            SlideousSlides ->+                              preEscapedString+                              "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);"+                            _ -> mempty+        KaTeX url -> do+          H.script !+            A.src (toValue $ url <> "katex.min.js") $ mempty+          nl opts+          let katexFlushLeft =+                case lookupContext "classoption" metadata of+                  Just clsops | "fleqn" `elem` (clsops :: [Text]) -> "true"+                  _ -> "false"+          H.script $ text $ T.unlines [+              "document.addEventListener(\"DOMContentLoaded\", function () {"+            , " var mathElements = document.getElementsByClassName(\"math\");"+            , " for (var i = 0; i < mathElements.length; i++) {"+            , "  var texText = mathElements[i].firstChild;"+            , "  if (mathElements[i].tagName == \"SPAN\") {"+            , "   katex.render(texText.data, mathElements[i], {"+            , "    displayMode: mathElements[i].classList.contains('display'),"+            , "    throwOnError: false,"+            , "    fleqn: " <> katexFlushLeft+            , "   });"+            , "}}});"+            ]+          nl opts+          H.link ! A.rel "stylesheet" !+            A.href (toValue $ url <> "katex.min.css") -                      _ -> case lookup "mathml-script" (writerVariables opts) of-                                 Just s | not (stHtml5 st) ->-                                   H.script ! A.type_ "text/javascript"-                                      $ preEscapedString-                                       ("/*<![CDATA[*/\n" ++ s ++ "/*]]>*/\n")-                                        | otherwise -> mempty-                                 Nothing -> mempty+        _ -> case lookupContext "mathml-script"+                  (writerVariables opts) of+                    Just s | not (stHtml5 st) ->+                      H.script ! A.type_ "text/javascript"+                        $ preEscapedString+                          ("/*<![CDATA[*/\n" ++ T.unpack s +++                          "/*]]>*/\n")+                          | otherwise -> mempty+                    Nothing -> mempty   let context =   (if stHighlighting st                       then case writerHighlightStyle opts of                                 Just sty -> defField "highlighting-css"-                                              (styleToCss sty)+                                              (T.pack $ styleToCss sty)                                 Nothing  -> id                       else id) $                   (if stMath st@@ -307,7 +329,7 @@                   (case writerHTMLMathMethod opts of                         MathJax u -> defField "mathjax" True .                                      defField "mathjaxurl"-                                       (takeWhile (/='?') u)+                                       (T.takeWhile (/='?') u)                         _         -> defField "mathjax" False) $                   defField "quotes" (stQuotes st) $                   -- for backwards compatibility we populate toc@@ -316,25 +338,27 @@                   maybe id (defField "toc") toc $                   maybe id (defField "table-of-contents") toc $                   defField "author-meta" authsMeta $-                  maybe id (defField "date-meta") (normalizeDate dateMeta) $-                  defField "pagetitle" (stringifyHTML (docTitle meta)) $+                  maybe id (defField "date-meta")+                    (normalizeDate dateMeta) $+                  defField "pagetitle"+                      (stringifyHTML . docTitle $ meta) $                   defField "idprefix" (writerIdentifierPrefix opts) $                   -- these should maybe be set in pandoc.hs                   defField "slidy-url"-                    ("https://www.w3.org/Talks/Tools/Slidy2" :: String) $-                  defField "slideous-url" ("slideous" :: String) $-                  defField "revealjs-url" ("reveal.js" :: String) $-                  defField "s5-url" ("s5/default" :: String) $+                    ("https://www.w3.org/Talks/Tools/Slidy2" :: Text) $+                  defField "slideous-url" ("slideous" :: Text) $+                  defField "revealjs-url" ("reveal.js" :: Text) $+                  defField "s5-url" ("s5/default" :: Text) $                   defField "html5" (stHtml5 st)                   metadata   return (thebody, context)  -- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix-prefixedId :: WriterOptions -> String -> Attribute+prefixedId :: WriterOptions -> Text -> Attribute prefixedId opts s =   case s of     "" -> mempty-    _  -> A.id $ toValue $ writerIdentifierPrefix opts ++ s+    _  -> A.id $ toValue $ writerIdentifierPrefix opts <> s  toList :: PandocMonad m        => (Html -> Html)@@ -381,130 +405,20 @@       return $ constr (checkbox >> isContents) >> bsContents  -- | Construct table of contents from list of elements.-tableOfContents :: PandocMonad m => WriterOptions -> [Element]+tableOfContents :: PandocMonad m => WriterOptions -> [Block]                 -> StateT WriterState m (Maybe Html) tableOfContents _ [] = return Nothing tableOfContents opts sects = do-  contents  <- mapM (elementToListItem opts) sects-  let tocList = catMaybes contents-  if null tocList-     then return Nothing-     else Just <$> unordList opts tocList---- | Convert section number to string-showSecNum :: [Int] -> String-showSecNum = intercalate "." . map show---- | Converts an Element to a list item for a table of contents,--- retrieving the appropriate identifier from state.-elementToListItem :: PandocMonad m => WriterOptions -> Element-                  -> StateT WriterState m (Maybe Html)--- Don't include the empty headers created in slide shows--- shows when an hrule is used to separate slides without a new title:-elementToListItem _ (Sec _ _ _ [Str "\0"] _) = return Nothing-elementToListItem opts (Sec lev num (id',classes,_) headerText subsecs)-  | lev <= writerTOCDepth opts = do-  let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0)-  let sectnum = if writerNumberSections opts && not (null num) &&-                   "unnumbered" `notElem` classes-                   then (H.span ! A.class_ "toc-section-number"-                        $ toHtml $ showSecNum num') >> preEscapedString " "-                   else mempty-  txt <- liftM (sectnum >>) $-         inlineListToHtml opts $ walk (deLink . deNote) headerText-  subHeads <- mapM (elementToListItem opts) subsecs >>= return . catMaybes-  subList <- if null subHeads-                then return mempty-                else unordList opts subHeads   -- in reveal.js, we need #/apples, not #apples:   slideVariant <- gets stSlideVariant-  let revealSlash = ['/' | slideVariant== RevealJsSlides]-  return $ Just-         $ if null id'-              then  H.a (toHtml txt) >> subList-              else (H.a ! A.href (toValue $ "#" ++ revealSlash ++-                    writerIdentifierPrefix opts ++ id')-                       $ toHtml txt) >> subList-elementToListItem _ _ = return Nothing--deLink :: Inline -> Inline-deLink (Link _ ils _) = Span nullAttr ils-deLink x              = x---- | Convert an Element to Html.-elementToHtml :: PandocMonad m => Maybe Int -> Int -> WriterOptions -> Element-              -> StateT WriterState m Html-elementToHtml _ _ opts (Blk block) = blockToHtml opts block-elementToHtml mbparentlevel slideLevel opts-      (Sec level num (id',classes,keyvals) title' elements)-  = do-  slideVariant <- gets stSlideVariant-  let slide = slideVariant /= NoSlides &&-               (level <= slideLevel ||-                -- we're missing a header at slide level (see #5168)-                maybe False (< slideLevel) mbparentlevel)-  let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0)-  modify $ \st -> st{stSecNum = num'}  -- update section number-  html5 <- gets stHtml5-  let titleSlide = slide && level < slideLevel-  header' <- if title' == [Str "\0"]  -- marker for hrule-                then return mempty-                else do-                  modify (\st -> st{ stElement = True})-                  let level' = if level <= slideLevel &&-                                  slideVariant == SlidySlides-                                  then 1 -- see #3566-                                  else level-                  res <- blockToHtml opts-                           (Header level' (id',classes,keyvals) title')-                  modify (\st -> st{ stElement = False})-                  return res--  let isSec Sec{} = True-      isSec (Blk _) = False-  let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]-      isPause _       = False-  let fragmentClass = case slideVariant of-                           RevealJsSlides -> "fragment"-                           _              -> "incremental"-  let inDiv xs = Blk (RawBlock (Format "html") ("<div class=\""-                       ++ fragmentClass ++ "\">")) :-                   (xs ++ [Blk (RawBlock (Format "html") "</div>")])-  let (titleBlocks, innerSecs) =-                     if titleSlide-                        -- title slides have no content of their own-                        then ([x | Blk x <- elements],-                              filter isSec elements)-                        else case splitBy isPause elements of-                                  []     -> ([],[])-                                  (x:xs) -> ([],x ++ concatMap inDiv xs)-  titleContents <- blockListToHtml opts titleBlocks-  innerContents <- mapM (elementToHtml (Just level) slideLevel opts) innerSecs-  let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]-  let classes' = ["title-slide" | titleSlide] ++ ["slide" | slide] ++-                  ["section" | (slide || writerSectionDivs opts) &&-                               not html5 ] ++-                  ["level" ++ show level | slide || writerSectionDivs opts ]-                  ++ classes-  let secttag  = if html5-                    then H5.section-                    else H.div-  let attr = (id',classes',keyvals)-  if titleSlide-     then do-       t <- addAttrs opts attr $ secttag $ header' <> titleContents-       return $-         (if slideVariant == RevealJsSlides && not (null innerContents)-             -- revealjs doesn't like more than one level of section nesting:-             && isNothing mbparentlevel-                then H5.section-                else id) $ mconcat $ t : innerContents-     else if writerSectionDivs opts || slide-          then addAttrs opts attr-               $ secttag $ inNl $ header' : innerContents-          else do-            t <- addAttrs opts attr header'-            return $ mconcat $ intersperse (nl opts) (t : innerContents)+  let opts' = case slideVariant of+                RevealJsSlides ->+                  opts{ writerIdentifierPrefix =+                          "/" <> writerIdentifierPrefix opts }+                _ -> opts+  case toTableOfContents opts sects of+    bl@(BulletList (_:_)) -> Just <$> blockToHtml opts' bl+    _                     -> return Nothing  -- | Convert list of Note blocks to a footnote <div>. -- Assumes notes are sorted.@@ -532,64 +446,64 @@               H.ol (mconcat notes >> nl opts) >> nl opts)  -- | Parse a mailto link; return Just (name, domain) or Nothing.-parseMailto :: String -> Maybe (String, String)+parseMailto :: Text -> Maybe (Text, Text) parseMailto s =-  case break (==':') s of-       (xs,':':addr) | map toLower xs == "mailto" -> do-         let (name', rest) = span (/='@') addr-         let domain = drop 1 rest+  case T.break (==':') s of+       (xs,T.uncons -> Just (':',addr)) | T.toLower xs == "mailto" -> do+         let (name', rest) = T.span (/='@') addr+         let domain = T.drop 1 rest          return (name', domain)-       _ -> fail "not a mailto: URL"+       _ -> Prelude.fail "not a mailto: URL"  -- | Obfuscate a "mailto:" link. obfuscateLink :: PandocMonad m-              => WriterOptions -> Attr -> Html -> String+              => WriterOptions -> Attr -> Html -> Text               -> StateT WriterState m Html obfuscateLink opts attr txt s | writerEmailObfuscation opts == NoObfuscation =   addAttrs opts attr $ H.a ! A.href (toValue s) $ txt-obfuscateLink opts attr (TL.unpack . renderHtml -> txt) s =+obfuscateLink opts attr (TL.toStrict . renderHtml -> txt) s =   let meth = writerEmailObfuscation opts-      s' = map toLower (take 7 s) ++ drop 7 s+      s' = T.toLower (T.take 7 s) <> T.drop 7 s   in  case parseMailto s' of         (Just (name', domain)) ->-          let domain'  = substitute "." " dot " domain+          let domain'  = T.replace "." " dot " domain               at'      = obfuscateChar '@'               (linkText, altText) =-                 if txt == drop 7 s' -- autolink-                    then ("e", name' ++ " at " ++ domain')-                    else ("'" ++ obfuscateString txt ++ "'",-                          txt ++ " (" ++ name' ++ " at " ++ domain' ++ ")")+                 if txt == T.drop 7 s' -- autolink+                    then ("e", name' <> " at " <> domain')+                    else ("'" <> obfuscateString txt <> "'",+                          txt <> " (" <> name' <> " at " <> domain' <> ")")               (_, classNames, _) = attr-              classNamesStr = concatMap (' ':) classNames+              classNamesStr = T.concat $ map (" "<>) classNames           in  case meth of                 ReferenceObfuscation ->                      -- need to use preEscapedString or &'s are escaped to &amp; in URL                      return $-                     preEscapedString $ "<a href=\"" ++ obfuscateString s'-                     ++ "\" class=\"email\">" ++ obfuscateString txt ++ "</a>"+                     preEscapedText $ "<a href=\"" <> obfuscateString s'+                     <> "\" class=\"email\">" <> obfuscateString txt <> "</a>"                 JavascriptObfuscation ->                      return $                      (H.script ! A.type_ "text/javascript" $-                     preEscapedString ("\n<!--\nh='" ++-                     obfuscateString domain ++ "';a='" ++ at' ++ "';n='" ++-                     obfuscateString name' ++ "';e=n+a+h;\n" ++-                     "document.write('<a h'+'ref'+'=\"ma'+'ilto'+':'+e+'\" clas'+'s=\"em' + 'ail" ++-                     classNamesStr ++ "\">'+" ++-                     linkText  ++ "+'<\\/'+'a'+'>');\n// -->\n")) >>-                     H.noscript (preEscapedString $ obfuscateString altText)-                _ -> throwError $ PandocSomeError $ "Unknown obfuscation method: " ++ show meth+                     preEscapedText ("\n<!--\nh='" <>+                     obfuscateString domain <> "';a='" <> at' <> "';n='" <>+                     obfuscateString name' <> "';e=n+a+h;\n" <>+                     "document.write('<a h'+'ref'+'=\"ma'+'ilto'+':'+e+'\" clas'+'s=\"em' + 'ail" <>+                     classNamesStr <> "\">'+" <>+                     linkText  <> "+'<\\/'+'a'+'>');\n// -->\n")) >>+                     H.noscript (preEscapedText $ obfuscateString altText)+                _ -> throwError $ PandocSomeError $ "Unknown obfuscation method: " <> tshow meth         _ -> addAttrs opts attr $ H.a ! A.href (toValue s) $ toHtml txt  -- malformed email  -- | Obfuscate character as entity.-obfuscateChar :: Char -> String+obfuscateChar :: Char -> Text obfuscateChar char =   let num    = ord char-      numstr = if even num then show num else "x" ++ showHex num ""-  in  "&#" ++ numstr ++ ";"+      numstr = if even num then show num else "x" <> showHex num ""+  in  "&#" <> T.pack numstr <> ";"  -- | Obfuscate string using entities.-obfuscateString :: String -> String-obfuscateString = concatMap obfuscateChar . fromEntities+obfuscateString :: Text -> Text+obfuscateString = T.concatMap obfuscateChar . fromEntities  -- | Create HTML tag with attributes. tagWithAttributes :: WriterOptions@@ -611,7 +525,7 @@ addAttrs opts attr h = foldl (!) h <$> attrsToHtml opts attr  toAttrs :: PandocMonad m-        => [(String, String)] -> StateT WriterState m [Attribute]+        => [(Text, Text)] -> StateT WriterState m [Attribute] toAttrs kvs = do   html5 <- gets stHtml5   mbEpubVersion <- gets stEPUBVersion@@ -619,17 +533,18 @@             if html5                then                   if x `Set.member` (html5Attributes <> rdfaAttributes)-                     || ':' `elem` x -- e.g. epub: namespace-                     || "data-" `isPrefixOf` x-                     then Just $ customAttribute (fromString x) (toValue y)-                     else Just $ customAttribute (fromString ("data-" ++ x))+                     || T.any (== ':') x -- e.g. epub: namespace+                     || "data-" `T.isPrefixOf` x+                     || "aria-" `T.isPrefixOf` x+                     then Just $ customAttribute (textTag x) (toValue y)+                     else Just $ customAttribute (textTag ("data-" <> x))                                   (toValue y)                else                  if mbEpubVersion == Just EPUB2 &&                     not (x `Set.member` (html4Attributes <> rdfaAttributes) ||-                         "xml:" `isPrefixOf` x)+                         "xml:" `T.isPrefixOf` x)                     then Nothing-                    else Just $ customAttribute (fromString x) (toValue y))+                    else Just $ customAttribute (textTag x) (toValue y))             kvs  attrsToHtml :: PandocMonad m@@ -637,8 +552,8 @@ attrsToHtml opts (id',classes',keyvals) = do   attrs <- toAttrs keyvals   return $-    [prefixedId opts id' | not (null id')] ++-    [A.class_ (toValue $ unwords classes') | not (null classes')] ++ attrs+    [prefixedId opts id' | not (T.null id')] +++    [A.class_ (toValue $ T.unwords classes') | not (null classes')] ++ attrs  imgAttrsToHtml :: PandocMonad m                => WriterOptions -> Attr -> StateT WriterState m [Attribute]@@ -653,23 +568,23 @@     isNotDim ("height", _) = False     isNotDim _             = True -dimensionsToAttrList :: Attr -> [(String, String)]+dimensionsToAttrList :: Attr -> [(Text, Text)] dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height   where-    consolidateStyles :: [(String, String)] -> [(String, String)]+    consolidateStyles :: [(Text, Text)] -> [(Text, Text)]     consolidateStyles xs =       case partition isStyle xs of            ([], _)    -> xs-           (ss, rest) -> ("style", intercalate ";" $ map snd ss) : rest+           (ss, rest) -> ("style", T.intercalate ";" $ map snd ss) : rest     isStyle ("style", _) = True     isStyle _            = False     go dir = case dimension dir attr of-               (Just (Pixel a)) -> [(show dir, show a)]-               (Just x)         -> [("style", show dir ++ ":" ++ show x)]+               (Just (Pixel a)) -> [(tshow dir, tshow a)]+               (Just x)         -> [("style", tshow dir <> ":" <> tshow x)]                Nothing          -> []  figure :: PandocMonad m-       => WriterOptions -> Attr -> [Inline] -> (String, String)+       => WriterOptions -> Attr -> [Inline] -> (Text, Text)        -> StateT WriterState m Html figure opts attr txt (s,tit) = do   img <- inlineToHtml opts (Image attr [Str ""] (s,tit))@@ -686,6 +601,16 @@               else H.div ! A.class_ "figure" $ mconcat                     [nl opts, img, nl opts, capt, nl opts] +showSecNum :: [Int] -> Text+showSecNum = T.intercalate "." . map tshow++getNumber :: WriterOptions -> Attr -> Text+getNumber opts (_,_,kvs) =+  showSecNum $ zipWith (+) num (writerNumberOffset opts ++ repeat 0)+  where+   num = maybe [] (map (fromMaybe 0 . safeRead) . T.split (=='.')) $+          lookup "number" kvs+ -- | Convert Pandoc block element to HTML. blockToHtml :: PandocMonad m => WriterOptions -> Block -> StateT WriterState m Html blockToHtml _ Null = return mempty@@ -700,7 +625,7 @@          inlineToHtml opts (Image attr txt (src, tit))        _ -> figure opts attr txt (src, tit) -- title beginning with fig: indicates that the image is a figure-blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) =+blockToHtml opts (Para [Image attr txt (s,T.stripPrefix "fig:" -> Just tit)]) =   figure opts attr txt (s,tit) blockToHtml opts (Para lst) = do   contents <- inlineListToHtml opts lst@@ -713,15 +638,82 @@   else do     htmlLines <- inlineListToHtml opts $ intercalate [LineBreak] lns     return $ H.div ! A.class_ "line-block" $ htmlLines+blockToHtml opts (Div (ident, "section":dclasses, dkvs)+                   (Header level hattr ils : xs)) = do+  slideVariant <- gets stSlideVariant+  slideLevel <- gets stSlideLevel+  let slide = slideVariant /= NoSlides &&+               level <= slideLevel {- DROPPED old fix for #5168 here -}+  html5 <- gets stHtml5+  let titleSlide = slide && level < slideLevel+  let level' = if level <= slideLevel && slideVariant == SlidySlides+                  then 1 -- see #3566+                  else level+  header' <- if ils == [Str "\0"]  -- marker for hrule+                then return mempty+                else blockToHtml opts (Header level' hattr ils)+  let isSec (Div (_,"section":_,_) _) = True+      isSec (Div _ zs)                = any isSec zs+      isSec _                         = False+  let isPause (Para [Str ".",Space,Str ".",Space,Str "."]) = True+      isPause _                                            = False+  let fragmentClass = case slideVariant of+                           RevealJsSlides -> "fragment"+                           _              -> "incremental"+  let inDiv zs = (RawBlock (Format "html") ("<div class=\""+                       <> fragmentClass <> "\">")) :+                   (zs ++ [RawBlock (Format "html") "</div>"])+  let (titleBlocks, innerSecs) =+        if titleSlide+           -- title slides have no content of their own+           then break isSec xs+           else case splitBy isPause xs of+                     []     -> ([],[])+                     (z:zs) -> ([],z ++ concatMap inDiv zs)+  titleContents <- blockListToHtml opts titleBlocks+  innerContents <- blockListToHtml opts innerSecs+  let classes' = ["title-slide" | titleSlide] ++ ["slide" | slide] +++                  ["section" | (slide || writerSectionDivs opts) &&+                               not html5 ] +++                  ["level" <> tshow level | slide || writerSectionDivs opts ]+                  <> dclasses+  let secttag  = if html5+                    then H5.section+                    else H.div+  let attr = (ident, classes', dkvs)+  if titleSlide+     then do+       t <- addAttrs opts attr $ secttag $ header' <> titleContents+       return $+         (if slideVariant == RevealJsSlides && not (null innerSecs)+             -- revealjs doesn't like more than one level of section nesting:+               {- REMOVED && isNothing mbparentlevel -}+                then H5.section+                else id) $ t <> if null innerSecs+                                   then mempty+                                   else nl opts <> innerContents+     else if writerSectionDivs opts || slide || not (null dclasses) ||+              not (null dkvs)+          then addAttrs opts attr+               $ secttag+               $ nl opts <> header' <> nl opts <>+                 if null innerSecs+                    then mempty+                    else innerContents <> nl opts+          else do+            t <- addAttrs opts attr header'+            return $ t <> if null innerSecs+                             then mempty+                             else nl opts <> innerContents blockToHtml opts (Div attr@(ident, classes, kvs') bs) = do   html5 <- gets stHtml5   slideVariant <- gets stSlideVariant   let kvs = [(k,v) | (k,v) <- kvs', k /= "width"] ++-            [("style", "width:" ++ w ++ ";")+            [("style", "width:" <> w <> ";")              | ("width",w) <- kvs', "column" `elem` classes] ++             [("role", "doc-bibliography") | ident == "refs" && html5] ++             [("role", "doc-biblioentry")-              | "ref-item" `isPrefixOf` ident && html5]+              | "ref-item" `T.isPrefixOf` ident && html5]   let speakerNotes = "notes" `elem` classes   -- we don't want incremental output inside speaker notes, see #1394   let opts' = if | speakerNotes -> opts{ writerIncremental = False }@@ -759,7 +751,7 @@ blockToHtml opts (RawBlock f str) = do   ishtml <- isRawHtml f   if ishtml-     then return $ preEscapedString str+     then return $ preEscapedText str      else if (f == Format "latex" || f == Format "tex") &&              allowsMathEnvironments (writerHTMLMathMethod opts) &&              isMathEnvironment str@@ -771,22 +763,22 @@   html5 <- gets stHtml5   return $ if html5 then H5.hr else H.hr blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do-  id'' <- if null id'+  id'' <- if T.null id'              then do                modify $ \st -> st{ stCodeBlockNum = stCodeBlockNum st + 1 }                codeblocknum <- gets stCodeBlockNum-               return ("cb" ++ show codeblocknum)-             else return id'+               return (writerIdentifierPrefix opts <> "cb" <> tshow codeblocknum)+             else return (writerIdentifierPrefix opts <> id')   let tolhs = isEnabled Ext_literate_haskell opts &&-                any (\c -> map toLower c == "haskell") classes &&-                any (\c -> map toLower c == "literate") classes+                any (\c -> T.toLower c == "haskell") classes &&+                any (\c -> T.toLower c == "literate") classes       classes' = if tolhs-                    then map (\c -> if map toLower c == "haskell"+                    then map (\c -> if T.toLower c == "haskell"                                        then "literatehaskell"                                        else c) classes                     else classes       adjCode  = if tolhs-                    then unlines . map ("> " ++) . lines $ rawCode+                    then T.unlines . map ("> " <>) . T.lines $ rawCode                     else rawCode       hlCode   = if isJust (writerHighlightStyle opts)                     then highlight (writerSyntaxMap opts) formatHtmlBlock@@ -794,12 +786,14 @@                     else Left ""   case hlCode of          Left msg -> do-           unless (null msg) $+           unless (T.null msg) $              report $ CouldNotHighlight msg            addAttrs opts (id',classes,keyvals)              $ H.pre $ H.code $ toHtml adjCode          Right h -> modify (\st -> st{ stHighlighting = True }) >>-                    addAttrs opts (id'',[],keyvals) h+                    -- we set writerIdentifierPrefix to "" since id'' already+                    -- includes it:+                    addAttrs opts{writerIdentifierPrefix = ""} (id'',[],keyvals) h blockToHtml opts (BlockQuote blocks) = do   -- in S5, treat list in blockquote specially   -- if default is incremental, make it nonincremental;@@ -824,14 +818,13 @@        return $ H.blockquote $ nl opts >> contents >> nl opts blockToHtml opts (Header level attr@(_,classes,_) lst) = do   contents <- inlineListToHtml opts lst-  secnum <- liftM stSecNum get-  let contents' = if writerNumberSections opts && not (null secnum)+  let secnum = getNumber opts attr+  let contents' = if writerNumberSections opts && not (T.null secnum)                      && "unnumbered" `notElem` classes-                     then (H.span ! A.class_ "header-section-number" $ toHtml-                          $ showSecNum secnum) >> strToHtml " " >> contents+                     then (H.span ! A.class_ "header-section-number"+                             $ toHtml secnum) >> strToHtml " " >> contents                      else contents-  inElement <- gets stElement-  (if inElement then return else addAttrs opts attr)+  addAttrs opts attr          $ case level of               1 -> H.h1 contents'               2 -> H.h2 contents'@@ -848,7 +841,7 @@   html5 <- gets stHtml5   let numstyle' = case numstyle of                        Example -> "decimal"-                       _       -> camelCaseToHyphenated $ show numstyle+                       _       -> camelCaseToHyphenated $ tshow numstyle   let attribs = [A.start $ toValue startnum | startnum /= 1] ++                 [A.class_ "example" | numstyle == Example] ++                 (if numstyle /= DefaultStyle@@ -861,7 +854,7 @@                                       LowerRoman -> "i"                                       UpperRoman -> "I"                                       _          -> "1"]-                           else [A.style $ toValue $ "list-style-type: " +++                           else [A.style $ toValue $ "list-style-type: " <>                                    numstyle']                    else [])   l <- ordList opts contents@@ -881,7 +874,7 @@                      cs <- inlineListToHtml opts capt                      return $ H.caption cs >> nl opts   html5 <- gets stHtml5-  let percent w = show (truncate (100*w) :: Integer) ++ "%"+  let percent w = show (truncate (100*w) :: Integer) <> "%"   let coltags = if all (== 0.0) widths                    then mempty                    else do@@ -889,7 +882,7 @@                        nl opts                        mapM_ (\w -> do                             if html5-                               then H.col ! A.style (toValue $ "width: " +++                               then H.col ! A.style (toValue $ "width: " <>                                                       percent w)                                else H.col ! A.width (toValue $ percent w)                             nl opts) widths@@ -908,8 +901,8 @@   -- table, or some browsers give us skinny columns with lots of space between:   return $ if totalWidth == 0 || totalWidth == 1               then tbl-              else tbl ! A.style (toValue $ "width:" ++-                              show (round (totalWidth * 100) :: Int) ++ "%;")+              else tbl ! A.style (toValue $ "width:" <>+                              show (round (totalWidth * 100) :: Int) <> "%;")  tableRowToHtml :: PandocMonad m                => WriterOptions@@ -920,9 +913,9 @@ tableRowToHtml opts aligns rownum cols' = do   let mkcell = if rownum == 0 then H.th else H.td   let rowclass = case rownum of-                      0 -> "header"+                      0                  -> "header"                       x | x `rem` 2 == 1 -> "odd"-                      _ -> "even"+                      _                  -> "even"   cols'' <- zipWithM             (\alignment item -> tableItemToHtml opts mkcell alignment item)             aligns cols'@@ -947,7 +940,7 @@   html5 <- gets stHtml5   let alignStr = alignmentToString align'   let attribs = if html5-                   then A.style (toValue $ "text-align: " ++ alignStr ++ ";")+                   then A.style (toValue $ "text-align: " <> alignStr <> ";")                    else A.align (toValue alignStr)   let tag'' = if null alignStr                  then tag'@@ -974,8 +967,8 @@   mapM (inlineToHtml opts) lst >>= return . mconcat  -- | Annotates a MathML expression with the tex source-annotateMML :: XML.Element -> String -> XML.Element-annotateMML e tex = math (unode "semantics" [cs, unode "annotation" (annotAttrs, tex)])+annotateMML :: XML.Element -> Text -> XML.Element+annotateMML e tex = math (unode "semantics" [cs, unode "annotation" (annotAttrs, T.unpack tex)])   where     cs = case elChildren e of           []  -> unode "mrow" ()@@ -993,47 +986,71 @@ inlineToHtml opts inline = do   html5 <- gets stHtml5   case inline of-    (Str str)        -> return $ strToHtml str+    (Str str)      -> return $ strToHtml str     Space          -> return $ strToHtml " "     SoftBreak      -> return $ case writerWrapText opts of-                                     WrapNone     -> preEscapedString " "-                                     WrapAuto     -> preEscapedString " "-                                     WrapPreserve -> preEscapedString "\n"+                                     WrapNone     -> preEscapedText " "+                                     WrapAuto     -> preEscapedText " "+                                     WrapPreserve -> preEscapedText "\n"     LineBreak      -> return $ do                         if html5 then H5.br else H.br                         strToHtml "\n"-    (Span (id',classes,kvs) ils)-                     -> inlineListToHtml opts ils >>=-                           addAttrs opts attr' . H.span-                        where attr' = (id',classes',kvs')-                              classes' = filter (`notElem` ["csl-no-emph",-                                              "csl-no-strong",-                                              "csl-no-smallcaps"]) classes-                              kvs' = if null styles-                                        then kvs-                                        else ("style", concat styles) : kvs++    (Span (id',classes,kvs) ils) ->+                        let spanLikeTag = case classes of+                                (c:_) -> do+                                  guard (c `Set.member` htmlSpanLikeElements)+                                  pure $ customParent (textTag c)+                                _   -> Nothing+                        in case spanLikeTag of+                            Just tag -> do+                              h <- inlineListToHtml opts ils+                              addAttrs opts (id',tail classes',kvs') $ tag h+                            Nothing -> do+                              h <- inlineListToHtml opts ils+                              addAttrs opts (id',classes',kvs') (H.span h)+                            where                               styles = ["font-style:normal;"-                                         | "csl-no-emph" `elem` classes]+                                       | "csl-no-emph" `elem` classes]                                     ++ ["font-weight:normal;"-                                         | "csl-no-strong" `elem` classes]+                                       | "csl-no-strong" `elem` classes]                                     ++ ["font-variant:normal;"-                                         | "csl-no-smallcaps" `elem` classes]+                                       | "csl-no-smallcaps" `elem` classes]+                              kvs' = if null styles+                                        then kvs+                                        else ("style", T.concat styles) : kvs+                              classes' = [ c | c <- classes+                                         , c `notElem` [ "csl-no-emph"+                                                       , "csl-no-strong"+                                                       , "csl-no-smallcaps"+                                                       ]+                                         ]+     (Emph lst)       -> inlineListToHtml opts lst >>= return . H.em     (Strong lst)     -> inlineListToHtml opts lst >>= return . H.strong-    (Code attr str)  -> case hlCode of+    (Code attr@(ids,cs,kvs) str)  +                     -> case hlCode of                              Left msg -> do-                               unless (null msg) $+                               unless (T.null msg) $                                  report $ CouldNotHighlight msg-                               addAttrs opts attr $ H.code $ strToHtml str+                               addAttrs opts (ids,cs',kvs) $ +                                 maybe H.code id sampOrVar $ +                                 strToHtml str                              Right h -> do                                modify $ \st -> st{ stHighlighting = True }-                               addAttrs opts (id',[],keyvals) h-                        where (id',_,keyvals) = attr-                              hlCode = if isJust (writerHighlightStyle opts)+                               addAttrs opts (ids,[],kvs) $ +                                 maybe id id sampOrVar $ h+                        where hlCode = if isJust (writerHighlightStyle opts)                                           then highlight                                                  (writerSyntaxMap opts)                                                  formatHtmlInline attr str                                           else Left ""+                              (sampOrVar,cs') = +                                  if "sample" `elem` cs+                                      then (Just H.samp,"sample" `delete` cs)+                                  else if "variable" `elem` cs+                                      then (Just H.var,"variable" `delete` cs)+                                      else (Nothing,cs)     (Strikeout lst)  -> inlineListToHtml opts lst >>=                         return . H.del     (SmallCaps lst)   -> inlineListToHtml opts lst >>=@@ -1046,21 +1063,31 @@                                               strToHtml "’")                               DoubleQuote -> (strToHtml "“",                                               strToHtml "”")-                        in  if writerHtmlQTags opts++                        in if writerHtmlQTags opts                                then do                                  modify $ \st -> st{ stQuotes = True }-                                 H.q `fmap` inlineListToHtml opts lst+                                 let (maybeAttr, lst') = case lst of+                                      [Span attr@(_, _, kvs) cs]+                                        | any ((=="cite") . fst) kvs+                                          -> (Just attr, cs)+                                      cs -> (Nothing, cs)+                                 H.q `fmap` inlineListToHtml opts lst'+                                   >>= maybe return (addAttrs opts) maybeAttr                                else (\x -> leftQuote >> x >> rightQuote)                                     `fmap` inlineListToHtml opts lst     (Math t str) -> do       modify (\st -> st {stMath = True})-      let mathClass = toValue $ ("math " :: String) +++      let mathClass = toValue $ ("math " :: Text) <>                       if t == InlineMath then "inline" else "display"       case writerHTMLMathMethod opts of            WebTeX url -> do               let imtag = if html5 then H5.img else H.img+              let s = case t of+                           InlineMath  -> "\\textstyle "+                           DisplayMath -> "\\displaystyle "               let m = imtag ! A.style "vertical-align:middle"-                            ! A.src (toValue $ url ++ urlEncode str)+                            ! A.src (toValue $ url <> T.pack (urlEncode (T.unpack $ s <> str)))                             ! A.alt (toValue str)                             ! A.title (toValue str)               let brtag = if html5 then H5.br else H.br@@ -1085,8 +1112,8 @@                                    inlineToHtml opts il            MathJax _ -> return $ H.span ! A.class_ mathClass $ toHtml $               case t of-                InlineMath  -> "\\(" ++ str ++ "\\)"-                DisplayMath -> "\\[" ++ str ++ "\\]"+                InlineMath  -> "\\(" <> str <> "\\)"+                DisplayMath -> "\\[" <> str <> "\\]"            KaTeX _ -> return $ H.span ! A.class_ mathClass $ toHtml $               case t of                 InlineMath  -> str@@ -1101,7 +1128,7 @@     (RawInline f str) -> do       ishtml <- isRawHtml f       if ishtml-         then return $ preEscapedString str+         then return $ preEscapedText str          else if (f == Format "latex" || f == Format "tex") &&                 allowsMathEnvironments (writerHTMLMathMethod opts) &&                 isMathEnvironment str@@ -1109,21 +1136,21 @@                 else do                   report $ InlineNotRendered inline                   return mempty-    (Link attr txt (s,_)) | "mailto:" `isPrefixOf` s -> do+    (Link attr txt (s,_)) | "mailto:" `T.isPrefixOf` s -> do                         linkText <- inlineListToHtml opts txt                         obfuscateLink opts attr linkText s     (Link (ident,classes,kvs) txt (s,tit)) -> do                         linkText <- inlineListToHtml opts txt                         slideVariant <- gets stSlideVariant-                        let s' = case s of-                                   '#':xs -> let prefix = if slideVariant == RevealJsSlides+                        let s' = case T.uncons s of+                                   Just ('#',xs) -> let prefix = if slideVariant == RevealJsSlides                                                              then "/"                                                              else writerIdentifierPrefix opts-                                             in  '#' : prefix ++ xs+                                             in  "#" <> prefix <> xs                                    _ -> s                         let link = H.a ! A.href (toValue s') $ linkText                         link' <- addAttrs opts (ident, classes, kvs) link-                        return $ if null tit+                        return $ if T.null tit                                     then link'                                     else link' ! A.title (toValue tit)     (Image attr txt (s,tit)) -> do@@ -1136,7 +1163,7 @@                               (if isReveal                                   then customAttribute "data-src" $ toValue s                                   else A.src $ toValue s) :-                              [A.title $ toValue tit | not (null tit)] +++                              [A.title $ toValue tit | not (T.null tit)] ++                               attrs                             imageTag = (if html5 then H5.img else H.img                               , [A.alt $ toValue alternate | not (null txt)] )@@ -1146,7 +1173,7 @@                                             else alternate                               in (tg $ H.a ! A.href (toValue s) $ toHtml linkTxt                                  , [A5.controls ""] )-                            normSrc = maybe s uriPath (parseURIReference s)+                            normSrc = maybe (T.unpack s) uriPath (parseURIReference $ T.unpack s)                             (tag, specAttrs) = case mediaCategory normSrc of                               Just "image" -> imageTag                               Just "video" -> mediaTag H5.video "Video"@@ -1158,18 +1185,18 @@     (Note contents) -> do                         notes <- gets stNotes                         let number = length notes + 1-                        let ref = show number+                        let ref = tshow number                         htmlContents <- blockListToNote opts ref contents                         epubVersion <- gets stEPUBVersion                         -- push contents onto front of notes                         modify $ \st -> st {stNotes = htmlContents:notes}                         slideVariant <- gets stSlideVariant-                        let revealSlash = ['/' | slideVariant == RevealJsSlides]-                        let link = H.a ! A.href (toValue $ "#" ++-                                         revealSlash ++-                                         writerIdentifierPrefix opts ++ "fn" ++ ref)+                        let revealSlash = T.pack ['/' | slideVariant == RevealJsSlides]+                        let link = H.a ! A.href (toValue $ "#" <>+                                         revealSlash <>+                                         writerIdentifierPrefix opts <> "fn" <> ref)                                        ! A.class_ "footnote-ref"-                                       ! prefixedId opts ("fnref" ++ ref)+                                       ! prefixedId opts ("fnref" <> ref)                                        $ (if isJust epubVersion                                              then id                                              else H.sup)@@ -1180,7 +1207,7 @@                                                       "role" "doc-noteref"                                       _          -> link     (Cite cits il)-> do contents <- inlineListToHtml opts (walk addRoleToLink il)-                        let citationIds = unwords $ map citationId cits+                        let citationIds = T.unwords $ map citationId cits                         let result = H.span ! A.class_ "citation" $ contents                         return $ if html5                                     then result ! customAttribute "data-cites" (toValue citationIds)@@ -1192,7 +1219,7 @@ addRoleToLink x = x  blockListToNote :: PandocMonad m-                => WriterOptions -> String -> [Block]+                => WriterOptions -> Text -> [Block]                 -> StateT WriterState m Html blockListToNote opts ref blocks = do   html5 <- gets stHtml5@@ -1200,7 +1227,7 @@   -- that block. Otherwise, insert a new Plain block with the backlink.   let kvs = if html5 then [("role","doc-backlink")] else []   let backlink = [Link ("",["footnote-back"],kvs)-                    [Str "↩"] ("#" ++ "fnref" ++ ref,[])]+                    [Str "↩"] ("#" <> "fnref" <> ref,"")]   let blocks'  = if null blocks                     then []                     else let lastBlock   = last blocks@@ -1213,7 +1240,7 @@                                   _           -> otherBlocks ++ [lastBlock,                                                  Plain backlink]   contents <- blockListToHtml opts blocks'-  let noteItem = H.li ! prefixedId opts ("fn" ++ ref) $ contents+  let noteItem = H.li ! prefixedId opts ("fn" <> ref) $ contents   epubVersion <- gets stEPUBVersion   let noteItem' = case epubVersion of                        Just EPUB3 -> noteItem !@@ -1223,10 +1250,10 @@                        _          -> noteItem   return $ nl opts >> noteItem' -isMathEnvironment :: String -> Bool-isMathEnvironment s = "\\begin{" `isPrefixOf` s &&+isMathEnvironment :: Text -> Bool+isMathEnvironment s = "\\begin{" `T.isPrefixOf` s &&                          envName `elem` mathmlenvs-  where envName = takeWhile (/= '}') (drop 7 s)+  where envName = T.takeWhile (/= '}') (T.drop 7 s)         mathmlenvs = [ "align"                      , "align*"                      , "alignat"@@ -1267,7 +1294,7 @@   return $ f == Format "html" ||            ((html5 && f == Format "html5") || f == Format "html4") -html5Attributes :: Set.Set String+html5Attributes :: Set.Set Text html5Attributes = Set.fromList   [ "abbr"   , "accept"@@ -1476,7 +1503,7 @@   ]  -- See https://en.wikipedia.org/wiki/RDFa, https://www.w3.org/TR/rdfa-primer/-rdfaAttributes :: Set.Set String+rdfaAttributes :: Set.Set Text rdfaAttributes = Set.fromList   [ "about"   , "rel"@@ -1492,7 +1519,7 @@   , "prefix"   ] -html4Attributes :: Set.Set String+html4Attributes :: Set.Set Text html4Attributes = Set.fromList   [ "abbr"   , "accept"
src/Text/Pandoc/Writers/Haddock.hs view
@@ -19,13 +19,14 @@ import Control.Monad.State.Strict import Data.Default import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared  type Notes = [[Block]]@@ -49,22 +50,20 @@   body <- blockListToHaddock opts blocks   st <- get   notes' <- notesToHaddock opts (reverse $ stNotes st)-  let render' :: Doc -> Text-      render' = render colwidth-  let main = render' $ body <>-               (if isEmpty notes' then empty else blankline <> notes')-  metadata <- metaToJSON opts-               (fmap render' . blockListToHaddock opts)-               (fmap render' . inlineListToHaddock opts)+  let main = body <> (if isEmpty notes' then empty else blankline <> notes')+  metadata <- metaToContext opts+               (blockListToHaddock opts)+               (fmap chomp . inlineListToHaddock opts)                meta   let context  = defField "body" main metadata-  case writerTemplate opts of-          Nothing  -> return main-          Just tpl -> renderTemplate' tpl context+  return $ render colwidth $+    case writerTemplate opts of+          Nothing  -> main+          Just tpl -> renderTemplate tpl context  -- | Return haddock representation of notes. notesToHaddock :: PandocMonad m-               => WriterOptions -> [[Block]] -> StateT WriterState m Doc+               => WriterOptions -> [[Block]] -> StateT WriterState m (Doc Text) notesToHaddock opts notes =   if null notes      then return empty@@ -73,7 +72,7 @@        return $ text "#notes#" <> blankline <> contents  -- | Escape special characters for Haddock.-escapeString :: String -> String+escapeString :: Text -> Text escapeString = escapeStringUsing haddockEscapes   where haddockEscapes = backslashEscapes "\\/'`\"@<" @@ -81,7 +80,7 @@ blockToHaddock :: PandocMonad m                => WriterOptions -- ^ Options                -> Block         -- ^ Block element-               -> StateT WriterState m Doc+               -> StateT WriterState m (Doc Text) blockToHaddock _ Null = return empty blockToHaddock opts (Div _ ils) = do   contents <- blockListToHaddock opts ils@@ -90,8 +89,9 @@   contents <- inlineListToHaddock opts inlines   return $ contents <> cr -- title beginning with fig: indicates figure-blockToHaddock opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =-  blockToHaddock opts (Para [Image attr alt (src,tit)])+blockToHaddock opts (Para [Image attr alt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt+  = blockToHaddock opts (Para [Image attr alt (src,tit)]) blockToHaddock opts (Para inlines) =   -- TODO:  if it contains linebreaks, we need to use a @...@ block   (<> blankline) `fmap` blockToHaddock opts (Plain inlines)@@ -99,7 +99,7 @@   blockToHaddock opts $ linesToPara lns blockToHaddock _ b@(RawBlock f str)   | f == "haddock" =-      return $ text str <> text "\n"+      return $ literal str <> text "\n"   | otherwise = do     report $ BlockNotRendered b     return empty@@ -107,13 +107,13 @@   return $ blankline <> text (replicate (writerColumns opts) '_') <> blankline blockToHaddock opts (Header level (ident,_,_) inlines) = do   contents <- inlineListToHaddock opts inlines-  let attr' = if null ident+  let attr' = if T.null ident                  then empty-                 else cr <> text "#" <> text ident <> text "#"+                 else cr <> text "#" <> literal ident <> text "#"   return $ nowrap (text (replicate level '=') <> space <> contents)                  <> attr' <> blankline blockToHaddock _ (CodeBlock (_,_,_) str) =-  return $ prefixed "> " (text str) <> blankline+  return $ prefixed "> " (literal str) <> blankline -- Nothing in haddock corresponds to block quotes: blockToHaddock opts (BlockQuote blocks) =   blockListToHaddock opts blocks@@ -128,81 +128,84 @@   return $ prefixed "> " (tbl $$ blankline $$ caption'') $$ blankline blockToHaddock opts (BulletList items) = do   contents <- mapM (bulletListItemToHaddock opts) items-  return $ cat contents <> blankline+  return $ (if isTightList items then vcat else vsep) contents <> blankline blockToHaddock opts (OrderedList (start,_,delim) items) = do   let attribs = (start, Decimal, delim)   let markers  = orderedListMarkers attribs-  let markers' = map (\m -> if length m < 3-                               then m ++ replicate (3 - length m) ' '+  let markers' = map (\m -> if T.length m < 3+                               then m <> T.replicate (3 - T.length m) " "                                else m) markers   contents <- zipWithM (orderedListItemToHaddock opts) markers' items-  return $ cat contents <> blankline+  return $ (if isTightList items then vcat else vsep) contents <> blankline blockToHaddock opts (DefinitionList items) = do   contents <- mapM (definitionListItemToHaddock opts) items-  return $ cat contents <> blankline+  return $ vcat contents <> blankline  -- | Convert bullet list item (list of blocks) to haddock bulletListItemToHaddock :: PandocMonad m-                        => WriterOptions -> [Block] -> StateT WriterState m Doc+                        => WriterOptions -> [Block] -> StateT WriterState m (Doc Text) bulletListItemToHaddock opts items = do   contents <- blockListToHaddock opts items   let sps = replicate (writerTabStop opts - 2) ' '   let start = text ('-' : ' ' : sps)-  -- remove trailing blank line if it is a tight list-  let contents' = case reverse items of-                       (BulletList xs:_) | isTightList xs ->-                            chomp contents <> cr-                       (OrderedList _ xs:_) | isTightList xs ->-                            chomp contents <> cr-                       _ -> contents-  return $ hang (writerTabStop opts) start $ contents' <> cr+  return $ hang (writerTabStop opts) start contents $$+           if endsWithPlain items+              then cr+              else blankline  -- | Convert ordered list item (a list of blocks) to haddock orderedListItemToHaddock :: PandocMonad m                          => WriterOptions -- ^ options-                         -> String        -- ^ list item marker+                         -> Text        -- ^ list item marker                          -> [Block]       -- ^ list item (list of blocks)-                         -> StateT WriterState m Doc+                         -> StateT WriterState m (Doc Text) orderedListItemToHaddock opts marker items = do   contents <- blockListToHaddock opts items-  let sps = case length marker - writerTabStop opts of+  let sps = case T.length marker - writerTabStop opts of                    n | n > 0 -> text $ replicate n ' '                    _ -> text " "-  let start = text marker <> sps-  return $ hang (writerTabStop opts) start $ contents <> cr+  let start = literal marker <> sps+  return $ hang (writerTabStop opts) start contents $$+           if endsWithPlain items+              then cr+              else blankline  -- | Convert definition list item (label, list of blocks) to haddock definitionListItemToHaddock :: PandocMonad m                             => WriterOptions                             -> ([Inline],[[Block]])-                            -> StateT WriterState m Doc+                            -> StateT WriterState m (Doc Text) definitionListItemToHaddock opts (label, defs) = do   labelText <- inlineListToHaddock opts label   defs' <- mapM (mapM (blockToHaddock opts)) defs-  let contents = vcat $ map (\d -> hang 4 empty $ vcat d <> cr) defs'-  return $ nowrap (brackets labelText) <> cr <> contents <> cr+  let contents = (if isTightList defs then vcat else vsep) $+                 map (\d -> hang 4 empty $ vcat d <> cr) defs'+  return $ nowrap (brackets labelText) $$ contents $$+           if isTightList defs+              then cr+              else blankline  -- | Convert list of Pandoc block elements to haddock blockListToHaddock :: PandocMonad m                    => WriterOptions -- ^ Options                    -> [Block]       -- ^ List of block elements-                   -> StateT WriterState m Doc+                   -> StateT WriterState m (Doc Text) blockListToHaddock opts blocks =-  cat <$> mapM (blockToHaddock opts) blocks+  mconcat <$> mapM (blockToHaddock opts) blocks  -- | Convert list of Pandoc inline elements to haddock. inlineListToHaddock :: PandocMonad m-                    => WriterOptions -> [Inline] -> StateT WriterState m Doc+                    => WriterOptions -> [Inline] -> StateT WriterState m (Doc Text) inlineListToHaddock opts lst =-  cat <$> mapM (inlineToHaddock opts) lst+  mconcat <$> mapM (inlineToHaddock opts) lst  -- | Convert Pandoc inline element to haddock. inlineToHaddock :: PandocMonad m-                => WriterOptions -> Inline -> StateT WriterState m Doc+                => WriterOptions -> Inline -> StateT WriterState m (Doc Text) inlineToHaddock opts (Span (ident,_,_) ils) = do   contents <- inlineListToHaddock opts ils-  if not (null ident) && null ils-     then return $ "#" <> text ident <> "#"+  if not (T.null ident) && null ils+     then return $ "#" <> literal ident <> "#"      else return contents inlineToHaddock opts (Emph lst) = do   contents <- inlineListToHaddock opts lst@@ -227,15 +230,15 @@   contents <- inlineListToHaddock opts lst   return $ "“" <> contents <> "”" inlineToHaddock _ (Code _ str) =-  return $ "@" <> text (escapeString str) <> "@"+  return $ "@" <> literal (escapeString str) <> "@" inlineToHaddock _ (Str str) =-  return $ text $ escapeString str+  return $ literal $ escapeString str inlineToHaddock _ (Math mt str) =   return $ case mt of-    DisplayMath -> cr <> "\\[" <> text str <> "\\]" <> cr-    InlineMath  -> "\\(" <> text str <> "\\)"+    DisplayMath -> cr <> "\\[" <> literal str <> "\\]" <> cr+    InlineMath  -> "\\(" <> literal str <> "\\)" inlineToHaddock _ il@(RawInline f str)-  | f == "haddock" = return $ text str+  | f == "haddock" = return $ literal str   | otherwise = do     report $ InlineNotRendered il     return empty@@ -249,12 +252,12 @@ inlineToHaddock _ Space = return space inlineToHaddock opts (Cite _ lst) = inlineListToHaddock opts lst inlineToHaddock _ (Link _ txt (src, _)) = do-  let linktext = text $ escapeString $ stringify txt+  let linktext = literal $ escapeString $ stringify txt   let useAuto = isURI src &&                 case txt of                       [Str s] | escapeURI s == src -> True                       _       -> False-  return $ nowrap $ "<" <> text src <>+  return $ nowrap $ "<" <> literal src <>            (if useAuto then empty else space <> linktext) <> ">" inlineToHaddock opts (Image attr alternate (source, tit)) = do   linkhaddock <- inlineToHaddock opts (Link attr alternate (source, tit))@@ -263,5 +266,5 @@ inlineToHaddock opts (Note contents) = do   modify (\st -> st{ stNotes = contents : stNotes st })   st <- get-  let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st)+  let ref = literal $ writerIdentifierPrefix opts <> tshow (length $ stNotes st)   return $ "<#notes [" <> ref <> "]>"
src/Text/Pandoc/Writers/ICML.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ViewPatterns #-}  {- |    Module      : Text.Pandoc.Writers.ICML@@ -20,10 +21,10 @@ import Prelude import Control.Monad.Except (catchError) import Control.Monad.State.Strict-import Data.List (intersperse, isInfixOf, isPrefixOf, stripPrefix)+import Data.List (intersperse) import Data.Maybe (fromMaybe, maybeToList) import qualified Data.Set as Set-import Data.Text as Text (breakOnAll, pack)+import qualified Data.Text as Text import Data.Text (Text) import Text.Pandoc.Class (PandocMonad, report) import qualified Text.Pandoc.Class as P@@ -31,19 +32,19 @@ import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty-import Text.Pandoc.Shared (isURI, linesToPara, splitBy)-import Text.Pandoc.Templates (renderTemplate')+import Text.DocLayout+import Text.Pandoc.Shared+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Math (texMathToInlines) import Text.Pandoc.Writers.Shared import Text.Pandoc.XML -type Style = [String]-type Hyperlink = [(Int, String)]+type Style = [Text]+type Hyperlink = [(Int, Text)]  data WriterState = WriterState{-    blockStyles  :: Set.Set String-  , inlineStyles :: Set.Set String+    blockStyles  :: Set.Set Text+  , inlineStyles :: Set.Set Text   , links        :: Hyperlink   , listDepth    :: Int   , maxListDepth :: Int@@ -61,14 +62,14 @@   }  -- inline names (appear in InDesign's character styles pane)-emphName        :: String-strongName      :: String-strikeoutName   :: String-superscriptName :: String-subscriptName   :: String-smallCapsName   :: String-codeName        :: String-linkName        :: String+emphName        :: Text+strongName      :: Text+strikeoutName   :: Text+superscriptName :: Text+subscriptName   :: Text+smallCapsName   :: Text+codeName        :: Text+linkName        :: Text emphName        = "Italic" strongName      = "Bold" strikeoutName   = "Strikeout"@@ -79,31 +80,31 @@ linkName        = "Link"  -- block element names (appear in InDesign's paragraph styles pane)-paragraphName     :: String-figureName        :: String-imgCaptionName    :: String-codeBlockName     :: String-blockQuoteName    :: String-orderedListName   :: String-bulletListName    :: String-defListTermName   :: String-defListDefName    :: String-headerName        :: String-tableName         :: String-tableHeaderName   :: String-tableCaptionName  :: String-alignLeftName     :: String-alignRightName    :: String-alignCenterName   :: String-firstListItemName :: String-beginsWithName    :: String-lowerRomanName    :: String-upperRomanName    :: String-lowerAlphaName    :: String-upperAlphaName    :: String-subListParName    :: String-footnoteName      :: String-citeName          :: String+paragraphName     :: Text+figureName        :: Text+imgCaptionName    :: Text+codeBlockName     :: Text+blockQuoteName    :: Text+orderedListName   :: Text+bulletListName    :: Text+defListTermName   :: Text+defListDefName    :: Text+headerName        :: Text+tableName         :: Text+tableHeaderName   :: Text+tableCaptionName  :: Text+alignLeftName     :: Text+alignRightName    :: Text+alignCenterName   :: Text+firstListItemName :: Text+beginsWithName    :: Text+lowerRomanName    :: Text+upperRomanName    :: Text+lowerAlphaName    :: Text+upperAlphaName    :: Text+subListParName    :: Text+footnoteName      :: Text+citeName          :: Text paragraphName     = "Paragraph" figureName        = "Figure" imgCaptionName    = "Caption"@@ -136,31 +137,29 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-      render' :: Doc -> Text-      render' = render colwidth-      renderMeta f s = liftM (render' . fst) $ runStateT (f opts [] s) defaultWriterState-  metadata <- metaToJSON opts+      renderMeta f s = fst <$> runStateT (f opts [] s) defaultWriterState+  metadata <- metaToContext opts              (renderMeta blocksToICML)              (renderMeta inlinesToICML)              meta-  (doc, st) <- runStateT (blocksToICML opts [] blocks) defaultWriterState-  let main    = render' doc-      context = defField "body" main-              $ defField "charStyles" (render' $ charStylesToDoc st)-              $ defField "parStyles"  (render' $ parStylesToDoc st)-              $ defField "hyperlinks" (render' $ hyperlinksToDoc $ links st) metadata-  (if writerPreferAscii opts then toEntities else id) <$>+  (main, st) <- runStateT (blocksToICML opts [] blocks) defaultWriterState+  let context = defField "body" main+              $ defField "charStyles" (charStylesToDoc st)+              $ defField "parStyles"  (parStylesToDoc st)+              $ defField "hyperlinks" (hyperlinksToDoc $ links st) metadata+  return $ render colwidth $+    (if writerPreferAscii opts then fmap toEntities else id) $     case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Auxiliary functions for parStylesToDoc and charStylesToDoc.-contains :: String -> (String, (String, String)) -> [(String, String)]+contains :: Text -> (Text, (Text, Text)) -> [(Text, Text)] contains s rule =-  [snd rule | (fst rule) `isInfixOf` s]+  [snd rule | (fst rule) `Text.isInfixOf` s]  -- | The monospaced font to use as default.-monospacedFont :: Doc+monospacedFont :: Doc Text monospacedFont = inTags False "AppliedFont" [("type", "string")] $ text "Courier New"  -- | How much to indent blockquotes etc.@@ -172,15 +171,15 @@ defaultListIndent = 10  -- other constants-lineSeparator :: String+lineSeparator :: Text lineSeparator = "&#x2028;"  -- | Convert a WriterState with its block styles to the ICML listing of Paragraph Styles.-parStylesToDoc :: WriterState -> Doc+parStylesToDoc :: WriterState -> Doc Text parStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ blockStyles st   where     makeStyle s =-      let countSubStrs sub str = length $ Text.breakOnAll (Text.pack sub) (Text.pack str)+      let countSubStrs sub str = length $ Text.breakOnAll sub str           attrs = concatMap (contains s) [                                (defListTermName, ("BulletsAndNumberingListType", "BulletList"))                              , (defListTermName, ("FontStyle", "Bold"))@@ -188,14 +187,14 @@                              , (alignLeftName,   ("Justification", "LeftAlign"))                              , (alignRightName,  ("Justification", "RightAlign"))                              , (alignCenterName, ("Justification", "CenterAlign"))-                             , (headerName++"1", ("PointSize", "36"))-                             , (headerName++"2", ("PointSize", "30"))-                             , (headerName++"3", ("PointSize", "24"))-                             , (headerName++"4", ("PointSize", "18"))-                             , (headerName++"5", ("PointSize", "14"))+                             , (headerName<>"1", ("PointSize", "36"))+                             , (headerName<>"2", ("PointSize", "30"))+                             , (headerName<>"3", ("PointSize", "24"))+                             , (headerName<>"4", ("PointSize", "18"))+                             , (headerName<>"5", ("PointSize", "14"))                              ]           -- what is the most nested list type, if any?-          (isBulletList, isOrderedList) = findList $ reverse $ splitBy (==' ') s+          (isBulletList, isOrderedList) = findList $ reverse $ splitTextBy (==' ') s             where               findList [] = (False, False)               findList (x:xs) | x == bulletListName  = (True, False)@@ -203,23 +202,23 @@                               | otherwise = findList xs           nBuls = countSubStrs bulletListName s           nOrds = countSubStrs orderedListName s-          attrs' = numbering ++ listType ++ indent ++ attrs+          attrs' = numbering <> listType <> indent <> attrs             where-              numbering | isOrderedList = [("NumberingExpression", "^#.^t"), ("NumberingLevel", show nOrds)]+              numbering | isOrderedList = [("NumberingExpression", "^#.^t"), ("NumberingLevel", tshow nOrds)]                         | otherwise     = []-              listType | isOrderedList && not (subListParName `isInfixOf` s)+              listType | isOrderedList && not (subListParName `Text.isInfixOf` s)                            = [("BulletsAndNumberingListType", "NumberedList")]-                       | isBulletList && not (subListParName `isInfixOf` s)+                       | isBulletList && not (subListParName `Text.isInfixOf` s)                            = [("BulletsAndNumberingListType", "BulletList")]                        | otherwise = []-              indent = [("LeftIndent", show indt)]+              indent = [("LeftIndent", tshow indt)]                 where                   nBlockQuotes = countSubStrs blockQuoteName s                   nDefLists = countSubStrs defListDefName s                   indt = max 0 $ defaultListIndent*(nBuls + nOrds - 1) + defaultIndent*(nBlockQuotes + nDefLists)           props = inTags True "Properties" [] (basedOn $$ tabList $$ numbForm)             where-              font = if codeBlockName `isInfixOf` s+              font = if codeBlockName `Text.isInfixOf` s                         then monospacedFont                         else empty               basedOn = inTags False "BasedOn" [("type", "object")] (text "$ID/NormalParagraphStyle") $$ font@@ -234,15 +233,15 @@                                   ]                            else empty               makeNumb name = inTags False "NumberingFormat" [("type", "string")] (text name)-              numbForm | isInfixOf lowerRomanName s = makeNumb "i, ii, iii, iv..."-                       | isInfixOf upperRomanName s = makeNumb "I, II, III, IV..."-                       | isInfixOf lowerAlphaName s = makeNumb "a, b, c, d..."-                       | isInfixOf upperAlphaName s = makeNumb "A, B, C, D..."+              numbForm | Text.isInfixOf lowerRomanName s = makeNumb "i, ii, iii, iv..."+                       | Text.isInfixOf upperRomanName s = makeNumb "I, II, III, IV..."+                       | Text.isInfixOf lowerAlphaName s = makeNumb "a, b, c, d..."+                       | Text.isInfixOf upperAlphaName s = makeNumb "A, B, C, D..."                        | otherwise = empty-      in  inTags True "ParagraphStyle" ([("Self", "ParagraphStyle/"++s), ("Name", s)] ++ attrs') props+      in  inTags True "ParagraphStyle" ([("Self", "ParagraphStyle/"<>s), ("Name", s)] ++ attrs') props  -- | Convert a WriterState with its inline styles to the ICML listing of Character Styles.-charStylesToDoc :: WriterState -> Doc+charStylesToDoc :: WriterState -> Doc Text charStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ inlineStyles st   where     makeStyle s =@@ -252,56 +251,56 @@                              , (subscriptName,   ("Position", "Subscript"))                              , (smallCapsName,   ("Capitalization", "SmallCaps"))                              ]-          attrs' | isInfixOf emphName s && isInfixOf strongName s = ("FontStyle", "Bold Italic") : attrs-                 | isInfixOf strongName s                         = ("FontStyle", "Bold") : attrs-                 | isInfixOf emphName s                           = ("FontStyle", "Italic") : attrs-                 | otherwise                                      = attrs+          attrs' | Text.isInfixOf emphName s && Text.isInfixOf strongName s+                                               = ("FontStyle", "Bold Italic") : attrs+                 | Text.isInfixOf strongName s = ("FontStyle", "Bold") : attrs+                 | Text.isInfixOf emphName s   = ("FontStyle", "Italic") : attrs+                 | otherwise                   = attrs           props = inTags True "Properties" [] $                     inTags False "BasedOn" [("type", "object")] (text "$ID/NormalCharacterStyle") $$ font                   where                     font =-                      if codeName `isInfixOf` s+                      if codeName `Text.isInfixOf` s                          then monospacedFont                          else empty-      in  inTags True "CharacterStyle" ([("Self", "CharacterStyle/"++s), ("Name", s)] ++ attrs') props+      in  inTags True "CharacterStyle" ([("Self", "CharacterStyle/"<>s), ("Name", s)] ++ attrs') props  -- | Escape colon characters as %3a-escapeColons :: String -> String-escapeColons (x:xs)-  | x == ':' = "%3a" ++ escapeColons xs-  | otherwise = x : escapeColons xs-escapeColons []     = []+escapeColons :: Text -> Text+escapeColons = Text.concatMap $ \x -> case x of+  ':' -> "%3a"+  _   -> Text.singleton x  -- | Convert a list of (identifier, url) pairs to the ICML listing of hyperlinks.-hyperlinksToDoc :: Hyperlink -> Doc+hyperlinksToDoc :: Hyperlink -> Doc Text hyperlinksToDoc []     = empty hyperlinksToDoc (x:xs) = hyp x $$ hyperlinksToDoc xs   where     hyp (ident, url) = hdest $$ hlink       where         hdest = selfClosingTag "HyperlinkURLDestination"-                  [("Self", "HyperlinkURLDestination/"++escapeColons url), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")] -- HyperlinkURLDestination with more than one colon crashes CS6-        hlink = inTags True "Hyperlink" [("Self","uf-"++show ident),  ("Name",url),-                    ("Source","htss-"++show ident), ("Visible","true"), ("DestinationUniqueKey","1")]+                  [("Self", "HyperlinkURLDestination/"<>escapeColons url), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")] -- HyperlinkURLDestination with more than one colon crashes CS6+        hlink = inTags True "Hyperlink" [("Self","uf-"<>tshow ident),  ("Name",url),+                    ("Source","htss-"<>tshow ident), ("Visible","true"), ("DestinationUniqueKey","1")]                   $ inTags True "Properties" []                   $ inTags False "BorderColor" [("type","enumeration")] (text "Black")-                  $$ inTags False "Destination" [("type","object")] (text $ "HyperlinkURLDestination/"++escapeColons (escapeStringForXML url)) -- HyperlinkURLDestination with more than one colon crashes CS6+                  $$ inTags False "Destination" [("type","object")] (literal $ "HyperlinkURLDestination/"<>escapeColons (escapeStringForXML url)) -- HyperlinkURLDestination with more than one colon crashes CS6  -- | Key for specifying user-defined styles-dynamicStyleKey :: String+dynamicStyleKey :: Text dynamicStyleKey = "custom-style"  -- | Convert a list of Pandoc blocks to ICML.-blocksToICML :: PandocMonad m => WriterOptions -> Style -> [Block] -> WS m Doc+blocksToICML :: PandocMonad m => WriterOptions -> Style -> [Block] -> WS m (Doc Text) blocksToICML opts style lst = do   docs <- mapM (blockToICML opts style) lst   return $ intersperseBrs docs  -- | Convert a Pandoc block element to ICML.-blockToICML :: PandocMonad m => WriterOptions -> Style -> Block -> WS m Doc+blockToICML :: PandocMonad m => WriterOptions -> Style -> Block -> WS m (Doc Text) blockToICML opts style (Plain lst) = parStyle opts style lst -- title beginning with fig: indicates that the image is a figure-blockToICML opts style (Para img@[Image _ txt (_,'f':'i':'g':':':_)]) = do+blockToICML opts style (Para img@[Image _ txt (_,Text.stripPrefix "fig:" -> Just _)]) = do   figure  <- parStyle opts (figureName:style) img   caption <- parStyle opts (imgCaptionName:style) txt   return $ intersperseBrs [figure, caption]@@ -310,7 +309,7 @@   blockToICML opts style $ linesToPara lns blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) [Str str] blockToICML _ _ b@(RawBlock f str)-  | f == Format "icml" = return $ text str+  | f == Format "icml" = return $ literal str   | otherwise          = do       report $ BlockNotRendered b       return empty@@ -319,7 +318,7 @@ blockToICML opts style (BulletList lst) = listItemsToICML opts bulletListName style Nothing lst blockToICML opts style (DefinitionList lst) = intersperseBrs `fmap` mapM (definitionListItemToICML opts style) lst blockToICML opts style (Header lvl (_, cls, _) lst) =-  let stl = (headerName ++ show lvl ++ unnumbered):style+  let stl = (headerName <> tshow lvl <> unnumbered):style       unnumbered = if "unnumbered" `elem` cls                    then " (unnumbered)"                    else ""@@ -350,7 +349,7 @@                  | otherwise = stl         c <- blocksToICML opts stl' cell         let cl = return $ inTags True "Cell"-                   [("Name", show colNr ++":"++ show rowNr), ("AppliedCellStyle","CellStyle/Cell")] c+                   [("Name", tshow colNr <>":"<> tshow rowNr), ("AppliedCellStyle","CellStyle/Cell")] c         liftM2 ($$) cl $ colsToICML rest restAligns rowNr (colNr+1)   in  do       let tabl = if noHeader@@ -358,14 +357,14 @@                     else headers:rows       cells <- rowsToICML tabl (0::Int)       let colWidths w =-            [("SingleColumnWidth",show $ 500 * w) | w > 0]-      let tupToDoc tup = selfClosingTag "Column" $ ("Name",show $ fst tup) : colWidths (snd tup)+            [("SingleColumnWidth",tshow $ 500 * w) | w > 0]+      let tupToDoc tup = selfClosingTag "Column" $ ("Name",tshow $ fst tup) : colWidths (snd tup)       let colDescs = vcat $ zipWith (curry tupToDoc) [0..nrCols-1] widths       let tableDoc = return $ inTags True "Table" [                          ("AppliedTableStyle","TableStyle/Table")                        , ("HeaderRowCount", nrHeaders)-                       , ("BodyRowCount", show nrRows)-                       , ("ColumnCount", show nrCols)+                       , ("BodyRowCount", tshow nrRows)+                       , ("ColumnCount", tshow nrCols)                        ] (colDescs $$ cells)       liftM2 ($$) tableDoc $ parStyle opts (tableCaptionName:style) caption blockToICML opts style (Div (_, _, kvs) lst) =@@ -374,7 +373,7 @@ blockToICML _ _ Null = return empty  -- | Convert a list of lists of blocks to ICML list items.-listItemsToICML :: PandocMonad m => WriterOptions -> String -> Style -> Maybe ListAttributes -> [[Block]] -> WS m Doc+listItemsToICML :: PandocMonad m => WriterOptions -> Text -> Style -> Maybe ListAttributes -> [[Block]] -> WS m (Doc Text) listItemsToICML _ _ _ _ [] = return empty listItemsToICML opts listType style attribs (first:rest) = do   st <- get@@ -389,7 +388,7 @@   return $ intersperseBrs docs  -- | Convert a list of blocks to ICML list items.-listItemToICML :: PandocMonad m => WriterOptions -> Style -> Bool-> Maybe ListAttributes -> [Block] -> WS m Doc+listItemToICML :: PandocMonad m => WriterOptions -> Style -> Bool-> Maybe ListAttributes -> [Block] -> WS m (Doc Text) listItemToICML opts style isFirst attribs item =   let makeNumbStart (Just (beginsWith, numbStl, _)) =         let doN DefaultStyle = []@@ -399,7 +398,7 @@             doN UpperAlpha   = [upperAlphaName]             doN _            = []             bw =-              [beginsWithName ++ show beginsWith | beginsWith > 1]+              [beginsWithName <> tshow beginsWith | beginsWith > 1]         in  doN numbStl ++ bw       makeNumbStart Nothing = []       stl = if isFirst@@ -415,7 +414,7 @@            return $ intersperseBrs (f : r)          else blocksToICML opts stl' item -definitionListItemToICML :: PandocMonad m => WriterOptions -> Style -> ([Inline],[[Block]]) -> WS m Doc+definitionListItemToICML :: PandocMonad m => WriterOptions -> Style -> ([Inline],[[Block]]) -> WS m (Doc Text) definitionListItemToICML opts style (term,defs) = do   term' <- parStyle opts (defListTermName:style) term   defs' <- mapM (blocksToICML opts (defListDefName:style)) defs@@ -423,12 +422,12 @@   -- | Convert a list of inline elements to ICML.-inlinesToICML :: PandocMonad m => WriterOptions -> Style -> [Inline] -> WS m Doc+inlinesToICML :: PandocMonad m => WriterOptions -> Style -> [Inline] -> WS m (Doc Text) inlinesToICML opts style lst = vcat `fmap` mapM (inlineToICML opts style) (mergeStrings opts lst)  -- | Convert an inline element to ICML.-inlineToICML :: PandocMonad m => WriterOptions -> Style -> Inline -> WS m Doc-inlineToICML _    style (Str str) = charStyle style $ text $ escapeStringForXML str+inlineToICML :: PandocMonad m => WriterOptions -> Style -> Inline -> WS m (Doc Text)+inlineToICML _    style (Str str) = charStyle style $ literal $ escapeStringForXML str inlineToICML opts style (Emph lst) = inlinesToICML opts (emphName:style) lst inlineToICML opts style (Strong lst) = inlinesToICML opts (strongName:style) lst inlineToICML opts style (Strikeout lst) = inlinesToICML opts (strikeoutName:style) lst@@ -440,19 +439,19 @@ inlineToICML opts style (Quoted DoubleQuote lst) = inlinesToICML opts style $   mergeStrings opts $ [Str "“"] ++ lst ++ [Str "”"] inlineToICML opts style (Cite _ lst) = inlinesToICML opts (citeName:style) lst-inlineToICML _    style (Code _ str) = charStyle (codeName:style) $ text $ escapeStringForXML str+inlineToICML _    style (Code _ str) = charStyle (codeName:style) $ literal $ escapeStringForXML str inlineToICML _    style Space = charStyle style space inlineToICML opts style SoftBreak =   case writerWrapText opts of        WrapAuto     -> charStyle style space        WrapNone     -> charStyle style space        WrapPreserve -> charStyle style cr-inlineToICML _ style LineBreak = charStyle style $ text lineSeparator+inlineToICML _ style LineBreak = charStyle style $ literal lineSeparator inlineToICML opts style (Math mt str) =   lift (texMathToInlines mt str) >>=-    (fmap cat . mapM (inlineToICML opts style))+    (fmap mconcat . mapM (inlineToICML opts style)) inlineToICML _ _ il@(RawInline f str)-  | f == Format "icml" = return $ text str+  | f == Format "icml" = return $ literal str   | otherwise          = do       report $ InlineNotRendered il       return empty@@ -464,7 +463,7 @@                            else 1 + fst (head $ links st)                 newst = st{ links = (ident, url):links st }                 cont  = inTags True "HyperlinkTextSource"-                         [("Self","htss-"++show ident), ("Name",title), ("Hidden","false")] content+                         [("Self","htss-"<>tshow ident), ("Name",title), ("Hidden","false")] content             in  (cont, newst) inlineToICML opts style (Image attr _ target) = imageICML opts style attr target inlineToICML opts style (Note lst) = footnoteToICML opts style lst@@ -473,7 +472,7 @@   in  inlinesToICML opts (dynamicStyle <> style) lst  -- | Convert a list of block elements to an ICML footnote.-footnoteToICML :: PandocMonad m => WriterOptions -> Style -> [Block] -> WS m Doc+footnoteToICML :: PandocMonad m => WriterOptions -> Style -> [Block] -> WS m (Doc Text) footnoteToICML opts style lst =   let insertTab (Para ls) = blockToICML opts (footnoteName:style) $ Para $ Str "\t":ls       insertTab block     = blockToICML opts (footnoteName:style) block@@ -494,31 +493,32 @@                                     _             -> Str " "         spaceToStr x = x -        mergeStrings' (Str x : Str y : zs) = mergeStrings' (Str (x ++ y) : zs)+        mergeStrings' (Str x : Str y : zs) = mergeStrings' (Str (x <> y) : zs)         mergeStrings' (x : xs) = x : mergeStrings' xs         mergeStrings' []       = []  -- | Intersperse line breaks-intersperseBrs :: [Doc] -> Doc+intersperseBrs :: [Doc Text] -> Doc Text intersperseBrs = vcat . intersperse (selfClosingTag "Br" []) . filter (not . isEmpty)  -- | Wrap a list of inline elements in an ICML Paragraph Style-parStyle :: PandocMonad m => WriterOptions -> Style -> [Inline] -> WS m Doc+parStyle :: PandocMonad m => WriterOptions -> Style -> [Inline] -> WS m (Doc Text) parStyle opts style lst =-  let slipIn x y = if null y+  let slipIn x y = if Text.null y                       then x-                      else x ++ " > " ++ y-      stlStr = foldr slipIn [] $ reverse style-      stl    = if null stlStr+                      else x <> " > " <> y+      stlStr = foldr slipIn "" $ reverse style+      stl    = if Text.null stlStr                   then ""-                  else "ParagraphStyle/" ++ stlStr+                  else "ParagraphStyle/" <> stlStr       attrs  = ("AppliedParagraphStyle", stl)       attrs' =  if firstListItemName `elem` style                    then let ats = attrs : [("NumberingContinue", "false")]-                            begins = filter (isPrefixOf beginsWithName) style+                            begins = filter (Text.isPrefixOf beginsWithName) style                         in  if null begins                                then ats-                               else let i = fromMaybe "" $ stripPrefix beginsWithName $ head begins+                               else let i = fromMaybe "" $ Text.stripPrefix beginsWithName+                                                         $ head begins                                     in  ("NumberingStartAt", i) : ats                    else [attrs]   in  do@@ -527,29 +527,29 @@       state $ \st -> (cont, st{ blockStyles = Set.insert stlStr $ blockStyles st })  -- | Wrap a Doc in an ICML Character Style.-charStyle :: PandocMonad m => Style -> Doc -> WS m Doc+charStyle :: PandocMonad m => Style -> Doc Text -> WS m (Doc Text) charStyle style content =   let (stlStr, attrs) = styleToStrAttr style       doc = inTags True "CharacterStyleRange" attrs $ inTagsSimple "Content" $ flush content   in       state $ \st ->-    let styles = if null stlStr+    let styles = if Text.null stlStr                     then st                     else st{ inlineStyles = Set.insert stlStr $ inlineStyles st }     in  (doc, styles)  -- | Transform a Style to a tuple of String (eliminating duplicates and ordered) and corresponding attribute.-styleToStrAttr :: Style -> (String, [(String, String)])+styleToStrAttr :: Style -> (Text, [(Text, Text)]) styleToStrAttr style =-  let stlStr = unwords $ Set.toAscList $ Set.fromList style+  let stlStr = Text.unwords $ Set.toAscList $ Set.fromList style       stl    = if null style                   then "$ID/NormalCharacterStyle"-                  else "CharacterStyle/" ++ stlStr+                  else "CharacterStyle/" <> stlStr       attrs = [("AppliedCharacterStyle", stl)]   in  (stlStr, attrs)  -- | Assemble an ICML Image.-imageICML :: PandocMonad m => WriterOptions -> Style -> Attr -> Target -> WS m Doc+imageICML :: PandocMonad m => WriterOptions -> Style -> Attr -> Target -> WS m (Doc Text) imageICML opts style attr (src, _) = do   imgS <- catchError           (do (img, _) <- P.fetchItem src@@ -559,35 +559,35 @@                   report $ CouldNotDetermineImageSize src msg                   return def)            (\e -> do-               report $ CouldNotFetchResource src (show e)+               report $ CouldNotFetchResource src $ tshow e                return def)   let (ow, oh) = sizeInPoints imgS       (imgWidth, imgHeight) = desiredSizeInPoints opts attr imgS       hw = showFl $ ow / 2       hh = showFl $ oh / 2-      scale = showFl (imgWidth / ow) ++ " 0 0 " ++ showFl (imgHeight / oh)-      src' = if isURI src then src else "file:" ++ src+      scale = showFl (imgWidth / ow) <> " 0 0 " <> showFl (imgHeight / oh)+      src' = if isURI src then src else "file:" <> src       (stlStr, attrs) = styleToStrAttr style       props  = inTags True "Properties" [] $ inTags True "PathGeometry" []                  $ inTags True "GeometryPathType" [("PathOpen","false")]                  $ inTags True "PathPointArray" []                  $ vcat [-                     selfClosingTag "PathPointType" [("Anchor", "-"++hw++" -"++hh),-                       ("LeftDirection", "-"++hw++" -"++hh), ("RightDirection", "-"++hw++" -"++hh)]-                   , selfClosingTag "PathPointType" [("Anchor", "-"++hw++" "++hh),-                       ("LeftDirection", "-"++hw++" "++hh), ("RightDirection", "-"++hw++" "++hh)]-                   , selfClosingTag "PathPointType" [("Anchor", hw++" "++hh),-                       ("LeftDirection", hw++" "++hh), ("RightDirection", hw++" "++hh)]-                   , selfClosingTag "PathPointType" [("Anchor", hw++" -"++hh),-                       ("LeftDirection", hw++" -"++hh), ("RightDirection", hw++" -"++hh)]+                     selfClosingTag "PathPointType" [("Anchor", "-"<>hw<>" -"<>hh),+                       ("LeftDirection", "-"<>hw<>" -"<>hh), ("RightDirection", "-"<>hw<>" -"<>hh)]+                   , selfClosingTag "PathPointType" [("Anchor", "-"<>hw<>" "<>hh),+                       ("LeftDirection", "-"<>hw<>" "<>hh), ("RightDirection", "-"<>hw<>" "<>hh)]+                   , selfClosingTag "PathPointType" [("Anchor", hw<>" "<>hh),+                       ("LeftDirection", hw<>" "<>hh), ("RightDirection", hw<>" "<>hh)]+                   , selfClosingTag "PathPointType" [("Anchor", hw<>" -"<>hh),+                       ("LeftDirection", hw<>" -"<>hh), ("RightDirection", hw<>" -"<>hh)]                    ]       image  = inTags True "Image"-                   [("Self","ue6"), ("ItemTransform", scale++" -"++hw++" -"++hh)]+                   [("Self","ue6"), ("ItemTransform", scale<>" -"<>hw<>" -"<>hh)]                  $ vcat [                      inTags True "Properties" [] $ inTags True "Profile" [("type","string")] $ text "$ID/Embedded"                    , selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", src')]                    ]       doc    = inTags True "CharacterStyleRange" attrs                  $ inTags True "Rectangle" [("Self","uec"), ("StrokeWeight", "0"),-                     ("ItemTransform", scale++" "++hw++" -"++hh)] (props $$ image)+                     ("ItemTransform", scale<>" "<>hw<>" -"<>hh)] (props $$ image)   state $ \st -> (doc, st{ inlineStyles = Set.insert stlStr $ inlineStyles st } )
src/Text/Pandoc/Writers/Ipynb.hs view
@@ -19,7 +19,6 @@ import Prelude import Control.Monad.State import qualified Data.Map as M-import Data.Char (toLower) import Data.Maybe (catMaybes, fromMaybe) import Text.Pandoc.Options import Text.Pandoc.Definition@@ -30,15 +29,17 @@ import Text.Pandoc.Logging import Data.Text (Text) import qualified Data.Text as T+import qualified Data.Text.Lazy as TL import Data.Aeson as Aeson import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Shared (safeRead, isURI)-import Text.Pandoc.Writers.Shared (metaToJSON')+import Text.Pandoc.Writers.Shared (metaToContext') import Text.Pandoc.Writers.Markdown (writeMarkdown) import qualified Data.Text.Encoding as TE import qualified Data.ByteString.Lazy as BL import Data.Aeson.Encode.Pretty (Config(..), defConfig,            encodePretty', keyOrder, Indent(Spaces))+import Text.DocLayout (literal)  writeIpynb :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeIpynb opts d = do@@ -57,9 +58,9 @@ pandocToNotebook :: PandocMonad m                  => WriterOptions -> Pandoc -> m (Notebook NbV4) pandocToNotebook opts (Pandoc meta blocks) = do-  let blockWriter bs = writeMarkdown+  let blockWriter bs = literal <$> writeMarkdown            opts{ writerTemplate = Nothing } (Pandoc nullMeta bs)-  let inlineWriter ils = T.stripEnd <$> writeMarkdown+  let inlineWriter ils = literal . T.stripEnd <$> writeMarkdown            opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain ils])   let jupyterMeta =         case lookupMeta "jupyter" meta of@@ -73,9 +74,10 @@                         Just z  -> (4, z)                         Nothing -> (4, 5)                _                -> (4, 5) -- write as v4.5-  metadata' <- metaToJSON' blockWriter inlineWriter $-                 B.deleteMeta "nbformat" $-                 B.deleteMeta "nbformat_minor" $ jupyterMeta+  metadata' <- toJSON <$> metaToContext' blockWriter inlineWriter+                 (B.deleteMeta "nbformat" $+                  B.deleteMeta "nbformat_minor" $+                  jupyterMeta)   -- convert from a Value (JSON object) to a M.Map Text Value:   let metadata = case fromJSON metadata' of                    Error _ -> mempty -- TODO warning here? shouldn't happen@@ -92,8 +94,8 @@ addAttachment (Image attr lab (src,tit))   | not (isURI src) = do   (img, mbmt) <- fetchItem src-  let mt = maybe "application/octet-stream" (T.pack) mbmt-  modify $ M.insert (T.pack src)+  let mt = fromMaybe "application/octet-stream" mbmt+  modify $ M.insert src           (MimeBundle (M.insert mt (BinaryData img) mempty))   return $ Image attr lab ("attachment:" <> src, tit) addAttachment x = return x@@ -109,7 +111,7 @@       source <- writeMarkdown opts{ writerTemplate = Nothing } newdoc       (Cell{           cellType = Markdown-        , cellSource = Source $ breakLines source+        , cellSource = Source $ breakLines $ T.stripEnd source         , cellMetadata = meta         , cellAttachments = if M.null attachments                                then Nothing@@ -119,7 +121,7 @@   , "code" `elem` classes = do       let (codeContent, rest) =             case xs of-               (CodeBlock _ t : ys) -> (T.pack t, ys)+               (CodeBlock _ t : ys) -> (t, ys)                ys                   -> (mempty, ys)       let meta = pairsToJSONMeta kvs       outputs <- catMaybes <$> mapM blockToOutput rest@@ -137,7 +139,7 @@       case consolidateAdjacentRawBlocks xs of         [RawBlock (Format f) raw] -> do           let format' =-                case map toLower f of+                case T.toLower f of                   "html"     -> "text/html"                   "revealjs" -> "text/html"                   "latex"    -> "text/latex"@@ -146,11 +148,11 @@                   _          -> f           (Cell{               cellType = Raw-            , cellSource = Source $ breakLines $ T.pack raw+            , cellSource = Source $ breakLines raw             , cellMetadata = if format' == "ipynb" -- means no format given                                 then mempty                                 else M.insert "format"-                                       (Aeson.String $ T.pack format') mempty+                                       (Aeson.String format') mempty             , cellAttachments = Nothing } :) <$> extractCells opts bs         _ -> extractCells opts bs extractCells opts (CodeBlock (_id,classes,kvs) raw : bs)@@ -162,7 +164,7 @@                 codeExecutionCount = exeCount               , codeOutputs = []               }-        , cellSource = Source $ breakLines $ T.pack raw+        , cellSource = Source $ breakLines raw         , cellMetadata = meta         , cellAttachments = Nothing } :) <$> extractCells opts bs extractCells opts (b:bs) = do@@ -175,13 +177,13 @@ blockToOutput :: PandocMonad m => Block -> m (Maybe (Output a)) blockToOutput (Div (_,["output","stream",sname],_) (CodeBlock _ t:_)) =   return $ Just-         $ Stream{ streamName = T.pack sname-               , streamText = Source (breakLines $ T.pack t) }+         $ Stream{ streamName = sname+               , streamText = Source (breakLines t) } blockToOutput (Div (_,["output","error"],kvs) (CodeBlock _ t:_)) =   return $ Just-         $ Err{ errName = maybe mempty T.pack (lookup "ename" kvs)-              , errValue = maybe mempty T.pack (lookup "evalue" kvs)-              , errTraceback = breakLines $ T.pack t }+         $ Err{ errName = fromMaybe mempty (lookup "ename" kvs)+              , errValue = fromMaybe mempty (lookup "evalue" kvs)+              , errTraceback = breakLines t } blockToOutput (Div (_,["output","execute_result"],kvs) bs) = do   (data', metadata') <- extractData bs   return $ Just@@ -205,28 +207,28 @@       (img, mbmt) <- fetchItem src       case mbmt of         Just mt -> return-          (M.insert (T.pack mt) (BinaryData img) mmap,+          (M.insert mt (BinaryData img) mmap,            meta <> pairsToJSONMeta kvs)         Nothing -> (mmap, meta) <$ report (BlockNotRendered b)     go (mmap, meta) b@(CodeBlock (_,["json"],_) code) =-      case decode (UTF8.fromStringLazy code) of+      case decode (UTF8.fromTextLazy $ TL.fromStrict code) of         Just v  -> return                     (M.insert "application/json" (JsonData v) mmap, meta)         Nothing -> (mmap, meta) <$ report (BlockNotRendered b)     go (mmap, meta) (CodeBlock ("",[],[]) code) =-       return (M.insert "text/plain" (TextualData (T.pack code)) mmap, meta)+       return (M.insert "text/plain" (TextualData code) mmap, meta)     go (mmap, meta) (RawBlock (Format "html") raw) =-       return (M.insert "text/html" (TextualData (T.pack raw)) mmap, meta)+       return (M.insert "text/html" (TextualData raw) mmap, meta)     go (mmap, meta) (RawBlock (Format "latex") raw) =-       return (M.insert "text/latex" (TextualData (T.pack raw)) mmap, meta)+       return (M.insert "text/latex" (TextualData raw) mmap, meta)     go (mmap, meta) (Div _ bs') = foldM go (mmap, meta) bs'     go (mmap, meta) b = (mmap, meta) <$ report (BlockNotRendered b) -pairsToJSONMeta :: [(String, String)] -> JSONMeta+pairsToJSONMeta :: [(Text, Text)] -> JSONMeta pairsToJSONMeta kvs =-  M.fromList [(T.pack k, case Aeson.decode (UTF8.fromStringLazy v) of+  M.fromList [(k, case Aeson.decode (UTF8.fromTextLazy $ TL.fromStrict v) of                            Just val -> val-                           Nothing  -> String (T.pack v))+                           Nothing  -> String v)              | (k,v) <- kvs              , k /= "execution_count"              ]
src/Text/Pandoc/Writers/JATS.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns #-} {- |    Module      : Text.Pandoc.Writers.JATS    Copyright   : Copyright (C) 2017-2019 John MacFarlane@@ -17,12 +19,12 @@ import Prelude import Control.Monad.Reader import Control.Monad.State-import Data.Char (toLower) import Data.Generics (everywhere, mkT)-import Data.List (isSuffixOf, partition, isPrefixOf)+import Data.List (partition) import qualified Data.Map as M import Data.Maybe (fromMaybe) import Data.Time (toGregorian, Day, parseTimeM, defaultTimeLocale, formatTime)+import qualified Data.Text as T import Data.Text (Text) import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition@@ -31,9 +33,10 @@ import Text.Pandoc.MIME (getMimeType) import Text.Pandoc.Walk (walk) import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate)+import Text.DocTemplates (Context(..), Val(..)) import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared import Text.Pandoc.XML@@ -44,7 +47,7 @@      deriving (Eq, Show)  data JATSState = JATSState-  { jatsNotes :: [(Int, Doc)] }+  { jatsNotes :: [(Int, Doc Text)] }  type JATS a = StateT JATSState (ReaderT JATSVersion a) @@ -60,80 +63,65 @@   let isBackBlock (Div ("refs",_,_) _) = True       isBackBlock _                    = False   let (backblocks, bodyblocks) = partition isBackBlock blocks-  let elements = hierarchicalize bodyblocks-  let backElements = hierarchicalize $ backblocks-  let colwidth = if writerWrapText opts == WrapAuto-                    then Just $ writerColumns opts-                    else Nothing-  let render'  :: Doc -> Text-      render'  = render colwidth-  let opts'    = if maybe False (("/book>" `isSuffixOf`) . trimr)-                            (writerTemplate opts) &&-                     TopLevelDefault == writerTopLevelDivision opts-                    then opts{ writerTopLevelDivision = TopLevelChapter }-                    else opts   -- The numbering here follows LaTeX's internal numbering-  let startLvl = case writerTopLevelDivision opts' of+  let startLvl = case writerTopLevelDivision opts of                    TopLevelPart    -> -1                    TopLevelChapter -> 0                    TopLevelSection -> 1                    TopLevelDefault -> 1-  metadata <- metaToJSON opts-                 (fmap (render' . vcat) .-                          mapM (elementToJATS opts' startLvl) .-                            hierarchicalize)-                 (fmap render' . inlinesToJATS opts')+  let fromBlocks = blocksToJATS opts . makeSections False (Just startLvl)+  let colwidth = if writerWrapText opts == WrapAuto+                    then Just $ writerColumns opts+                    else Nothing+  metadata <- metaToContext opts+                 fromBlocks+                 (fmap chomp . inlinesToJATS opts)                  meta-  main <- (render' . vcat) <$>-            mapM (elementToJATS opts' startLvl) elements+  main <- fromBlocks bodyblocks   notes <- reverse . map snd <$> gets jatsNotes-  backs <- mapM (elementToJATS opts' startLvl) backElements-  let fns = inTagsIndented "fn-group" $ vcat notes-  let back = render' $ vcat backs $$ fns-  let date = case  getField "date" metadata -- an object-               `mplus`-                   (getField "date" metadata >>= parseDate) of-               Nothing  -> mempty+  backs <- fromBlocks backblocks+  let fns = if null notes+            then mempty+            else inTagsIndented "fn-group" $ vcat notes+  let back = backs $$ fns+  let date =+        case getField "date" metadata of+          Nothing -> NullVal+          Just (SimpleVal (x :: Doc Text)) ->+             case parseDate (render Nothing x) of+               Nothing  -> NullVal                Just day ->                  let (y,m,d) = toGregorian day-                 in  M.insert ("year" :: String) (show y)-                      $ M.insert "month" (show m)-                      $ M.insert "day" (show d)+                 in  MapVal $ Context+                      $ M.insert ("year" :: Text) (SimpleVal $ text $ show y)+                      $ M.insert "month" (SimpleVal $ text $ show m)+                      $ M.insert "day" (SimpleVal $ text $ show d)                       $ M.insert "iso-8601"-                         (formatTime defaultTimeLocale "%F" day)+                        (SimpleVal $ text $+                            formatTime defaultTimeLocale "%F" day)                       $ mempty+          Just x -> x   let context = defField "body" main               $ defField "back" back-              $ resetField ("date" :: String) date+              $ resetField "date" date               $ defField "mathml" (case writerHTMLMathMethod opts of                                         MathML -> True                                         _      -> False) metadata-  (if writerPreferAscii opts then toEntities else id) <$>+  return $ render colwidth $+    (if writerPreferAscii opts then fmap toEntities else id) $     case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context---- | Convert an Element to JATS.-elementToJATS :: PandocMonad m => WriterOptions -> Int -> Element -> JATS m Doc-elementToJATS opts _   (Blk block) = blockToJATS opts block-elementToJATS opts lvl (Sec _ _num (id',_,kvs) title elements) = do-  let idAttr = [("id", writerIdentifierPrefix opts ++ id') | not (null id')]-  let otherAttrs = ["sec-type", "specific-use"]-  let attribs = idAttr ++ [(k,v) | (k,v) <- kvs, k `elem` otherAttrs]-  contents <- mapM (elementToJATS opts (lvl + 1)) elements-  title' <- inlinesToJATS opts title-  return $ inTags True "sec" attribs $-      inTagsSimple "title" title' $$ vcat contents+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Convert a list of Pandoc blocks to JATS.-blocksToJATS :: PandocMonad m => WriterOptions -> [Block] -> JATS m Doc+blocksToJATS :: PandocMonad m => WriterOptions -> [Block] -> JATS m (Doc Text) blocksToJATS = wrappedBlocksToJATS (const False)  wrappedBlocksToJATS :: PandocMonad m                     => (Block -> Bool)                     -> WriterOptions                     -> [Block]-                    -> JATS m Doc+                    -> JATS m (Doc Text) wrappedBlocksToJATS needsWrap opts =   fmap vcat . mapM wrappedBlockToJATS   where@@ -152,13 +140,13 @@ -- | Convert a list of pairs of terms and definitions into a list of -- JATS varlistentrys. deflistItemsToJATS :: PandocMonad m-                      => WriterOptions -> [([Inline],[[Block]])] -> JATS m Doc+                      => WriterOptions -> [([Inline],[[Block]])] -> JATS m (Doc Text) deflistItemsToJATS opts items =   vcat <$> mapM (uncurry (deflistItemToJATS opts)) items  -- | Convert a term and a list of blocks into a JATS varlistentry. deflistItemToJATS :: PandocMonad m-                     => WriterOptions -> [Inline] -> [[Block]] -> JATS m Doc+                     => WriterOptions -> [Inline] -> [[Block]] -> JATS m (Doc Text) deflistItemToJATS opts term defs = do   term' <- inlinesToJATS opts term   def' <- wrappedBlocksToJATS (not . isPara)@@ -170,7 +158,7 @@  -- | Convert a list of lists of blocks to a list of JATS list items. listItemsToJATS :: PandocMonad m-                => WriterOptions -> Maybe [String] -> [[Block]] -> JATS m Doc+                => WriterOptions -> Maybe [Text] -> [[Block]] -> JATS m (Doc Text) listItemsToJATS opts markers items =   case markers of        Nothing -> vcat <$> mapM (listItemToJATS opts Nothing) items@@ -178,41 +166,41 @@  -- | Convert a list of blocks into a JATS list item. listItemToJATS :: PandocMonad m-               => WriterOptions -> Maybe String -> [Block] -> JATS m Doc+               => WriterOptions -> Maybe Text -> [Block] -> JATS m (Doc Text) listItemToJATS opts mbmarker item = do   contents <- wrappedBlocksToJATS (not . isParaOrList) opts                  (walk demoteHeaderAndRefs item)   return $ inTagsIndented "list-item" $-           maybe empty (\lbl -> inTagsSimple "label" (text lbl)) mbmarker+           maybe empty (\lbl -> inTagsSimple "label" (text $ T.unpack lbl)) mbmarker            $$ contents -imageMimeType :: String -> [(String, String)] -> (String, String)+imageMimeType :: Text -> [(Text, Text)] -> (Text, Text) imageMimeType src kvs =-  let mbMT = getMimeType src+  let mbMT = getMimeType (T.unpack src)       maintype = fromMaybe "image" $                   lookup "mimetype" kvs `mplus`-                  (takeWhile (/='/') <$> mbMT)+                  (T.takeWhile (/='/') <$> mbMT)       subtype = fromMaybe "" $                   lookup "mime-subtype" kvs `mplus`-                  ((drop 1 . dropWhile (/='/')) <$> mbMT)+                  ((T.drop 1 . T.dropWhile (/='/')) <$> mbMT)   in (maintype, subtype) -languageFor :: [String] -> String+languageFor :: [Text] -> Text languageFor classes =   case langs of      (l:_) -> escapeStringForXML l      []    -> ""-    where isLang l    = map toLower l `elem` map (map toLower) languages+    where isLang l    = T.toLower l `elem` map T.toLower languages           langsFrom s = if isLang s                            then [s]-                           else languagesByExtension . map toLower $ s+                           else languagesByExtension . T.toLower $ s           langs       = concatMap langsFrom classes -codeAttr :: Attr -> (String, [(String, String)])+codeAttr :: Attr -> (Text, [(Text, Text)]) codeAttr (ident,classes,kvs) = (lang, attr)     where-       attr = [("id",ident) | not (null ident)] ++-              [("language",lang) | not (null lang)] +++       attr = [("id",ident) | not (T.null ident)] +++              [("language",lang) | not (T.null lang)] ++               [(k,v) | (k,v) <- kvs, k `elem` ["code-type",                 "code-version", "executable",                 "language-version", "orientation",@@ -220,24 +208,32 @@        lang  = languageFor classes  -- | Convert a Pandoc block element to JATS.-blockToJATS :: PandocMonad m => WriterOptions -> Block -> JATS m Doc+blockToJATS :: PandocMonad m => WriterOptions -> Block -> JATS m (Doc Text) blockToJATS _ Null = return empty+blockToJATS opts (Div (id',"section":_,kvs) (Header _lvl _ ils : xs)) = do+  let idAttr = [("id", writerIdentifierPrefix opts <> id') | not (T.null id')]+  let otherAttrs = ["sec-type", "specific-use"]+  let attribs = idAttr ++ [(k,v) | (k,v) <- kvs, k `elem` otherAttrs]+  title' <- inlinesToJATS opts ils+  contents <- blocksToJATS opts xs+  return $ inTags True "sec" attribs $+      inTagsSimple "title" title' $$ contents -- Bibliography reference:-blockToJATS opts (Div ('r':'e':'f':'-':_,_,_) [Para lst]) =+blockToJATS opts (Div (T.stripPrefix "ref-" -> Just _,_,_) [Para lst]) =    inlinesToJATS opts lst blockToJATS opts (Div ("refs",_,_) xs) = do   contents <- blocksToJATS opts xs   return $ inTagsIndented "ref-list" contents blockToJATS opts (Div (ident,[cls],kvs) bs) | cls `elem` ["fig", "caption", "table-wrap"] = do   contents <- blocksToJATS opts bs-  let attr = [("id", ident) | not (null ident)] +++  let attr = [("id", ident) | not (T.null ident)] ++              [("xml:lang",l) | ("lang",l) <- kvs] ++              [(k,v) | (k,v) <- kvs, k `elem` ["specific-use",                  "content-type", "orientation", "position"]]   return $ inTags True cls attr contents blockToJATS opts (Div (ident,_,kvs) bs) = do   contents <- blocksToJATS opts bs-  let attr = [("id", ident) | not (null ident)] +++  let attr = [("id", ident) | not (T.null ident)] ++              [("xml:lang",l) | ("lang",l) <- kvs] ++              [(k,v) | (k,v) <- kvs, k `elem` ["specific-use",                  "content-type", "orientation", "position"]]@@ -249,13 +245,13 @@ blockToJATS opts (Plain lst) = blockToJATS opts (Para lst) -- title beginning with fig: indicates that the image is a figure blockToJATS opts (Para [Image (ident,_,kvs) txt-  (src,'f':'i':'g':':':tit)]) = do+  (src,T.stripPrefix "fig:" -> Just tit)]) = do   alt <- inlinesToJATS opts txt   let (maintype, subtype) = imageMimeType src kvs   let capt = if null txt                 then empty                 else inTagsSimple "caption" $ inTagsSimple "p" alt-  let attr = [("id", ident) | not (null ident)] +++  let attr = [("id", ident) | not (T.null ident)] ++              [(k,v) | (k,v) <- kvs, k `elem` ["fig-type", "orientation",                                               "position", "specific-use"]]   let graphicattr = [("mimetype",maintype),@@ -266,11 +262,11 @@               capt $$ selfClosingTag "graphic" graphicattr blockToJATS _ (Para [Image (ident,_,kvs) _ (src, tit)]) = do   let (maintype, subtype) = imageMimeType src kvs-  let attr = [("id", ident) | not (null ident)] +++  let attr = [("id", ident) | not (T.null ident)] ++              [("mimetype", maintype),               ("mime-subtype", subtype),               ("xlink:href", src)] ++-             [("xlink:title", tit) | not (null tit)] +++             [("xlink:title", tit) | not (T.null tit)] ++              [(k,v) | (k,v) <- kvs, k `elem` ["baseline-shift",                         "content-type", "specific-use", "xlink:actuate",                         "xlink:href", "xlink:role", "xlink:show",@@ -283,9 +279,9 @@ blockToJATS opts (BlockQuote blocks) =   inTagsIndented "disp-quote" <$> blocksToJATS opts blocks blockToJATS _ (CodeBlock a str) = return $-  inTags False tag attr (flush (text (escapeStringForXML str)))+  inTags False tag attr (flush (text (T.unpack $ escapeStringForXML str)))     where (lang, attr) = codeAttr a-          tag          = if null lang then "preformat" else "code"+          tag          = if T.null lang then "preformat" else "code" blockToJATS _ (BulletList []) = return empty blockToJATS opts (BulletList lst) =   inTags True "list" [("list-type", "bullet")] <$>@@ -311,16 +307,16 @@ blockToJATS opts (DefinitionList lst) =   inTags True "def-list" [] <$> deflistItemsToJATS opts lst blockToJATS _ b@(RawBlock f str)-  | f == "jats"    = return $ text str -- raw XML block+  | f == "jats"    = return $ text $ T.unpack str -- raw XML block   | otherwise      = do       report $ BlockNotRendered b       return empty blockToJATS _ HorizontalRule = return empty -- not semantic blockToJATS opts (Table [] aligns widths headers rows) = do-  let percent w    = show (truncate (100*w) :: Integer) ++ "*"+  let percent w    = tshow (truncate (100*w) :: Integer) <> "*"   let coltags = vcat $ zipWith (\w al -> selfClosingTag "col"                        ([("width", percent w) | w > 0] ++-                        [("align", alignmentToString al)])) widths aligns+                        [("align", alignmentToText al)])) widths aligns   thead <- if all null headers               then return empty               else inTagsIndented "thead" <$> tableRowToJATS opts True headers@@ -332,8 +328,8 @@   tbl <- blockToJATS opts (Table [] aligns widths headers rows)   return $ inTags True "table-wrap" [] $ captionDoc $$ tbl -alignmentToString :: Alignment -> [Char]-alignmentToString alignment = case alignment of+alignmentToText :: Alignment -> Text+alignmentToText alignment = case alignment of                                  AlignLeft    -> "left"                                  AlignRight   -> "right"                                  AlignCenter  -> "center"@@ -343,7 +339,7 @@                   => WriterOptions                   -> Bool                   -> [[Block]]-                  -> JATS m Doc+                  -> JATS m (Doc Text) tableRowToJATS opts isHeader cols =   (inTagsIndented "tr" . vcat) <$> mapM (tableItemToJATS opts isHeader) cols @@ -351,7 +347,7 @@                    => WriterOptions                    -> Bool                    -> [Block]-                   -> JATS m Doc+                   -> JATS m (Doc Text) tableItemToJATS opts isHeader [Plain item] =   inTags False (if isHeader then "th" else "td") [] <$>     inlinesToJATS opts item@@ -360,7 +356,7 @@     mapM (blockToJATS opts) item  -- | Convert a list of inline elements to JATS.-inlinesToJATS :: PandocMonad m => WriterOptions -> [Inline] -> JATS m Doc+inlinesToJATS :: PandocMonad m => WriterOptions -> [Inline] -> JATS m (Doc Text) inlinesToJATS opts lst = hcat <$> mapM (inlineToJATS opts) (fixCitations lst)   where    fixCitations [] = []@@ -368,7 +364,7 @@      x : Str (stringify ys) : fixCitations zs      where        needsFixing (RawInline (Format "jats") z) =-           "<pub-id pub-id-type=" `isPrefixOf` z+           "<pub-id pub-id-type=" `T.isPrefixOf` z        needsFixing _             = False        isRawInline (RawInline{}) = True        isRawInline _             = False@@ -376,8 +372,8 @@    fixCitations (x:xs) = x : fixCitations xs  -- | Convert an inline element to JATS.-inlineToJATS :: PandocMonad m => WriterOptions -> Inline -> JATS m Doc-inlineToJATS _ (Str str) = return $ text $ escapeStringForXML str+inlineToJATS :: PandocMonad m => WriterOptions -> Inline -> JATS m (Doc Text)+inlineToJATS _ (Str str) = return $ text $ T.unpack $ escapeStringForXML str inlineToJATS opts (Emph lst) =   inTagsSimple "italic" <$> inlinesToJATS opts lst inlineToJATS opts (Strong lst) =@@ -397,11 +393,11 @@   contents <- inlinesToJATS opts lst   return $ char '“' <> contents <> char '”' inlineToJATS _ (Code a str) =-  return $ inTags False tag attr $ text (escapeStringForXML str)+  return $ inTags False tag attr $ literal (escapeStringForXML str)     where (lang, attr) = codeAttr a-          tag          = if null lang then "monospace" else "code"+          tag          = if T.null lang then "monospace" else "code" inlineToJATS _ il@(RawInline f x)-  | f == "jats" = return $ text x+  | f == "jats" = return $ literal x   | otherwise   = do       report $ InlineNotRendered il       return empty@@ -416,12 +412,12 @@   let notenum = case notes of                   (n, _):_ -> n + 1                   []       -> 1-  thenote <- inTags True "fn" [("id","fn" ++ show notenum)]+  thenote <- inTags True "fn" [("id","fn" <> tshow notenum)]                 <$> wrappedBlocksToJATS (not . isPara) opts                      (walk demoteHeaderAndRefs contents)   modify $ \st -> st{ jatsNotes = (notenum, thenote) : notes }   return $ inTags False "xref" [("ref-type", "fn"),-                                ("rid", "fn" ++ show notenum)]+                                ("rid", "fn" <> tshow notenum)]          $ text (show notenum) inlineToJATS opts (Cite _ lst) =   -- TODO revisit this after examining the jats.csl pipeline@@ -429,7 +425,7 @@ inlineToJATS opts (Span ("",_,[]) ils) = inlinesToJATS opts ils inlineToJATS opts (Span (ident,_,kvs) ils) = do   contents <- inlinesToJATS opts ils-  let attr = [("id",ident) | not (null ident)] +++  let attr = [("id",ident) | not (T.null ident)] ++              [("xml:lang",l) | ("lang",l) <- kvs] ++              [(k,v) | (k,v) <- kvs                     ,  k `elem` ["content-type", "rationale",@@ -451,7 +447,7 @@                      InlineMath  -> "inline-formula"   let rawtex = inTagsSimple "tex-math"                                 $ text "<![CDATA[" <>-                                  text str <>+                                  literal str <>                                   text "]]>"   return $ inTagsSimple tagtype $              case res of@@ -459,11 +455,11 @@                                   cr <> rawtex $$                                   text (Xml.ppcElement conf $ fixNS r)                    Left _   -> rawtex-inlineToJATS _ (Link _attr [Str t] ('m':'a':'i':'l':'t':'o':':':email, _))+inlineToJATS _ (Link _attr [Str t] (T.stripPrefix "mailto:" -> Just email, _))   | escapeURI t == email =-  return $ inTagsSimple "email" $ text (escapeStringForXML email)-inlineToJATS opts (Link (ident,_,kvs) txt ('#':src, _)) = do-  let attr = [("id", ident) | not (null ident)] +++  return $ inTagsSimple "email" $ literal (escapeStringForXML email)+inlineToJATS opts (Link (ident,_,kvs) txt (T.uncons -> Just ('#', src), _)) = do+  let attr = [("id", ident) | not (T.null ident)] ++              [("alt", stringify txt) | not (null txt)] ++              [("rid", src)] ++              [(k,v) | (k,v) <- kvs, k `elem` ["ref-type", "specific-use"]]@@ -473,10 +469,10 @@         contents <- inlinesToJATS opts txt         return $ inTags False "xref" attr contents inlineToJATS opts (Link (ident,_,kvs) txt (src, tit)) = do-  let attr = [("id", ident) | not (null ident)] +++  let attr = [("id", ident) | not (T.null ident)] ++              [("ext-link-type", "uri"),               ("xlink:href", src)] ++-             [("xlink:title", tit) | not (null tit)] +++             [("xlink:title", tit) | not (T.null tit)] ++              [(k,v) | (k,v) <- kvs, k `elem` ["assigning-authority",                                               "specific-use", "xlink:actuate",                                               "xlink:role", "xlink:show",@@ -484,18 +480,18 @@   contents <- inlinesToJATS opts txt   return $ inTags False "ext-link" attr contents inlineToJATS _ (Image (ident,_,kvs) _ (src, tit)) = do-  let mbMT = getMimeType src+  let mbMT = getMimeType (T.unpack src)   let maintype = fromMaybe "image" $                   lookup "mimetype" kvs `mplus`-                  (takeWhile (/='/') <$> mbMT)+                  (T.takeWhile (/='/') <$> mbMT)   let subtype = fromMaybe "" $                   lookup "mime-subtype" kvs `mplus`-                  ((drop 1 . dropWhile (/='/')) <$> mbMT)-  let attr = [("id", ident) | not (null ident)] +++                  ((T.drop 1 . T.dropWhile (/='/')) <$> mbMT)+  let attr = [("id", ident) | not (T.null ident)] ++              [("mimetype", maintype),               ("mime-subtype", subtype),               ("xlink:href", src)] ++-             [("xlink:title", tit) | not (null tit)] +++             [("xlink:title", tit) | not (T.null tit)] ++              [(k,v) | (k,v) <- kvs, k `elem` ["baseline-shift",                         "content-type", "specific-use", "xlink:actuate",                         "xlink:href", "xlink:role", "xlink:show",@@ -521,8 +517,8 @@                        Div ("",cls,kvs) bs demoteHeaderAndRefs x = x -parseDate :: String -> Maybe Day-parseDate s = msum (map (\fs -> parsetimeWith fs s) formats) :: Maybe Day+parseDate :: Text -> Maybe Day+parseDate s = msum (map (\fs -> parsetimeWith fs $ T.unpack s) formats) :: Maybe Day   where parsetimeWith = parseTimeM True defaultTimeLocale         formats = ["%x","%m/%d/%Y", "%D","%F", "%d %b %Y",                     "%e %B %Y", "%b. %e, %Y", "%B %e, %Y",
src/Text/Pandoc/Writers/Jira.hs view
@@ -17,7 +17,6 @@ module Text.Pandoc.Writers.Jira ( writeJira ) where import Prelude import Control.Monad.State.Strict-import Data.Char (toLower) import Data.Foldable (find) import Data.Text (Text, pack) import Text.Pandoc.Class (PandocMonad, report)@@ -25,10 +24,11 @@ import Text.Pandoc.Logging (LogMessage (BlockNotRendered, InlineNotRendered)) import Text.Pandoc.Options (WriterOptions (writerTemplate)) import Text.Pandoc.Shared (blocksToInlines, linesToPara)-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Math (texMathToInlines)-import Text.Pandoc.Writers.Shared (metaToJSON, defField)+import Text.Pandoc.Writers.Shared (metaToContext, defField) import qualified Data.Text as T+import Text.DocLayout (literal, render)  data WriterState = WriterState   { stNotes     :: [Text]      -- Footnotes@@ -53,35 +53,30 @@ pandocToJira :: PandocMonad m              => WriterOptions -> Pandoc -> JiraWriter m Text pandocToJira opts (Pandoc meta blocks) = do-  metadata <- metaToJSON opts (blockListToJira opts)-                 (inlineListToJira opts) meta+  metadata <- metaToContext opts+                 (fmap literal . blockListToJira opts)+                 (fmap literal . inlineListToJira opts) meta   body <- blockListToJira opts blocks   notes <- gets $ T.intercalate "\n" . reverse . stNotes-  let main = body <> if T.null notes then "" else "\n\n" <> notes+  let main = body <> if T.null notes+                        then mempty+                        else T.pack "\n\n" <> notes   let context = defField "body" main metadata-  case writerTemplate opts of-    Nothing  -> return main-    Just tpl -> renderTemplate' tpl context+  return $+    case writerTemplate opts of+      Nothing  -> main+      Just tpl -> render Nothing $ renderTemplate tpl context  -- | Escape one character as needed for Jira. escapeCharForJira :: Char -> Text-escapeCharForJira c = case c of-  '&'      -> "&amp;"-  '<'      -> "&lt;"-  '>'      -> "&gt;"-  '"'      -> "&quot;"-  '*'      -> "&ast;"-  '_'      -> "&lowbar;"-  '@'      -> "&commat;"-  '+'      -> "&plus;"-  '-'      -> "&hyphen;"-  '|'      -> "&vert;"-  '{'      -> "\\{"-  '\x2014' -> " -- "-  '\x2013' -> " - "-  '\x2019' -> "'"-  '\x2026' -> "..."-  _        -> T.singleton c+escapeCharForJira c =+  let specialChars = "_*-+~^|!{}[]" :: String+  in case c of+    '\x2013' -> " -- "+    '\x2014' -> " --- "+    '\x2026' -> "..."+    _ | c `elem` specialChars -> T.cons '\\' (T.singleton c)+    _                         -> T.singleton c  -- | Escape string as needed for Jira. escapeStringForJira :: Text -> Text@@ -92,7 +87,7 @@ anchor (ident,_,_) =   if ident == ""   then ""-  else "{anchor:" <> pack ident <> "}"+  else "{anchor:" <> ident <> "}"  -- | Append a newline character unless we are in a list. appendNewlineUnlessInList :: PandocMonad m@@ -125,7 +120,7 @@  blockToJira _ b@(RawBlock f str) =   if f == Format "jira"-  then return (pack str)+  then return str   else "" <$ report (BlockNotRendered b)  blockToJira _ HorizontalRule = return "----\n"@@ -136,22 +131,22 @@   return $ prefix <> anchor attr <> contents <> "\n"  blockToJira _ (CodeBlock attr@(_,classes,_) str) = do-  let lang = find (\c -> map toLower c `elem` knownLanguages) classes+  let lang = find (\c -> T.toLower c `elem` knownLanguages) classes   let start = case lang of                 Nothing -> "{code}"-                Just l  -> "{code:" <> pack l <> "}"+                Just l  -> "{code:" <> l <> "}"   let anchorMacro = anchor attr   appendNewlineUnlessInList . T.intercalate "\n" $     (if anchorMacro == "" then id else (anchorMacro :))-    [start, escapeStringForJira (pack str), "{code}"]+    [start, str, "{code}"]  blockToJira opts (BlockQuote [p@(Para _)]) = do   contents <- blockToJira opts p-  appendNewlineUnlessInList ("bq. " <> contents)+  return ("bq. " <> contents)  blockToJira opts (BlockQuote blocks) = do   contents <- blockListToJira opts blocks-  appendNewlineUnlessInList . T.intercalate "\n" $+  appendNewlineUnlessInList . T.unlines $     [ "{quote}", contents, "{quote}"]  blockToJira opts (Table _caption _aligns _widths headers rows) = do@@ -269,9 +264,9 @@ inlineToJira opts (Cite _  lst) = inlineListToJira opts lst  inlineToJira _ (Code attr str) =-  return (anchor attr <> "{{" <> escapeStringForJira (pack str) <> "}}")+  return (anchor attr <> "{{" <> str <> "}}") -inlineToJira _ (Str str) = return $ escapeStringForJira (pack str)+inlineToJira _ (Str str) = return $ escapeStringForJira str  inlineToJira opts (Math InlineMath str) =   lift (texMathToInlines InlineMath str) >>= inlineListToJira opts@@ -283,7 +278,7 @@  inlineToJira _opts il@(RawInline f str) =   if f == Format "jira"-  then return (pack str)+  then return str   else "" <$ report (InlineNotRendered il)  inlineToJira _ LineBreak = return "\n"@@ -297,12 +292,12 @@   return $ T.concat     [ "["     , if null txt then "" else linkText <> "|"-    , pack src+    , src     , "]"     ]  inlineToJira _opts (Image attr _alt (src, _title)) =-  return . T.concat $ [anchor attr, "!", pack src, "!"]+  return . T.concat $ [anchor attr, "!", src, "!"]  inlineToJira opts (Note contents) = do   curNotes <- gets stNotes@@ -313,7 +308,7 @@   return $ "[" <> pack (show newnum) <> "]"  -- | Language codes recognized by jira-knownLanguages :: [String]+knownLanguages :: [Text] knownLanguages =   [ "actionscript", "ada", "applescript", "bash", "c", "c#", "c++"   , "css", "erlang", "go", "groovy", "haskell", "html", "javascript"
src/Text/Pandoc/Writers/LaTeX.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE PatternGuards       #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ViewPatterns        #-} {- |    Module      : Text.Pandoc.Writers.LaTeX    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -21,16 +22,15 @@ import Control.Applicative ((<|>)) import Control.Monad.State.Strict import Data.Monoid (Any(..))-import Data.Aeson (FromJSON, object, (.=)) import Data.Char (isAlphaNum, isAscii, isDigit, isLetter, isSpace,-                  isPunctuation, ord, toLower)-import Data.List (foldl', intercalate, intersperse, isInfixOf, nubBy,-                  stripPrefix, (\\), uncons)+                  isPunctuation, ord)+import Data.List (foldl', intersperse, nubBy, (\\), uncons) import Data.Maybe (catMaybes, fromMaybe, isJust, mapMaybe, isNothing) import qualified Data.Map as M import Data.Text (Text) import qualified Data.Text as T import Network.URI (unEscapeString)+import Text.DocTemplates (FromContext(lookupContext)) import Text.Pandoc.BCP47 (Lang (..), getLang, renderLang) import Text.Pandoc.Class (PandocMonad, report, toLang) import Text.Pandoc.Definition@@ -39,13 +39,13 @@ import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared import Text.Pandoc.Slides-import Text.Pandoc.Templates+import Text.Pandoc.Templates (renderTemplate)+import Text.DocTemplates (Val(..), Context(..)) import Text.Pandoc.Walk import Text.Pandoc.Writers.Shared-import qualified Text.Parsec as P import Text.Printf (printf) import qualified Data.Text.Normalize as Normalize @@ -57,7 +57,7 @@               , stInMinipage    :: Bool          -- true if in minipage                , stInHeading     :: Bool          -- true if in a section heading               , stInItem        :: Bool          -- true if in \item[..]-              , stNotes         :: [Doc]         -- notes in a minipage+              , stNotes         :: [Doc Text]    -- notes in a minipage               , stOLLevel       :: Int           -- level of ordered list nesting               , stOptions       :: WriterOptions -- writer options, so they don't have to be parameter               , stVerbInNote    :: Bool          -- true if document has verbatim text in note@@ -70,9 +70,11 @@               , stCsquotes      :: Bool          -- true if document uses csquotes               , stHighlighting  :: Bool          -- true if document has highlighted code               , stIncremental   :: Bool          -- true if beamer lists should be displayed bit by bit-              , stInternalLinks :: [String]      -- list of internal link targets+              , stInternalLinks :: [Text]      -- list of internal link targets               , stBeamer        :: Bool          -- produce beamer               , stEmptyLine     :: Bool          -- true if no content on line+              , stHasCslRefs    :: Bool          -- has a Div with class refs+              , stCslHangingIndent :: Bool       -- use hanging indent for bib               }  startingState :: WriterOptions -> WriterState@@ -101,7 +103,9 @@                 , stIncremental = writerIncremental options                 , stInternalLinks = []                 , stBeamer = False-                , stEmptyLine = True }+                , stEmptyLine = True+                , stHasCslRefs = False+                , stCslHangingIndent = False }  -- | Convert Pandoc to LaTeX. writeLaTeX :: PandocMonad m => WriterOptions -> Pandoc -> m Text@@ -128,47 +132,37 @@                              _                     -> blocks                    else blocks   -- see if there are internal links-  let isInternalLink (Link _ _ ('#':xs,_)) = [xs]-      isInternalLink _                     = []+  let isInternalLink (Link _ _ (s,_))+        | Just ('#', xs) <- T.uncons s = [xs]+      isInternalLink _                 = []   modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' }-  let template = fromMaybe "" $ writerTemplate options   let colwidth = if writerWrapText options == WrapAuto                     then Just $ writerColumns options                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  metadata <- metaToJSON options-              (fmap render' . blockListToLaTeX)-              (fmap render' . inlineListToLaTeX)+  metadata <- metaToContext options+              blockListToLaTeX+              (fmap chomp . inlineListToLaTeX)               meta   let chaptersClasses = ["memoir","book","report","scrreprt","scrbook","extreport","extbook","tufte-book"]   let frontmatterClasses = ["memoir","book","scrbook","extbook","tufte-book"]   -- these have \frontmatter etc.   beamer <- gets stBeamer   let documentClass =-        case lookup "documentclass" (writerVariables options) `mplus`-              fmap stringify (lookupMeta "documentclass" meta) of+        case (lookupContext "documentclass"+                  (writerVariables options)) `mplus`+              (stringify <$> lookupMeta "documentclass" meta) of                  Just x -> x-                 Nothing ->-                  case P.parse pDocumentClass "template" template of-                     Right r -> r-                     Left _-                      | beamer    -> "beamer"-                      | otherwise -> case writerTopLevelDivision options of-                                       TopLevelPart    -> "book"-                                       TopLevelChapter -> "book"-                                       _               -> "article"+                 Nothing | beamer    -> "beamer"+                         | otherwise -> case writerTopLevelDivision options of+                                          TopLevelPart    -> "book"+                                          TopLevelChapter -> "book"+                                          _               -> "article"   when (documentClass `elem` chaptersClasses) $      modify $ \s -> s{ stHasChapters = True }-  -- check for \usepackage...{csquotes}; if present, we'll use-  -- \enquote{...} for smart quotes:-  let headerIncludesField :: FromJSON a => Maybe a-      headerIncludesField = getField "header-includes" metadata-  let headerIncludes = fromMaybe [] $ mplus-                       (fmap return headerIncludesField)-                       headerIncludesField-  when (any (isInfixOf "{csquotes}") (template : headerIncludes)) $-    modify $ \s -> s{stCsquotes = True}+  case T.toLower . render Nothing <$> getField "csquotes" metadata of+     Nothing      -> return ()+     Just "false" -> return ()+     Just _       -> modify $ \s -> s{stCsquotes = True}   let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then                                  (blocks', [])                                else case reverse blocks' of@@ -176,25 +170,27 @@                                  _                 -> (blocks', [])   blocks''' <- if beamer                   then toSlides blocks''-                  else return blocks''-  body <- mapM (elementToLaTeX options) $ hierarchicalize blocks'''-  (biblioTitle :: Text) <- render' <$> inlineListToLaTeX lastHeader-  let main = render' $ vsep body+                  else return $ makeSections False Nothing blocks''+  main <- blockListToLaTeX blocks'''+  biblioTitle <- inlineListToLaTeX lastHeader   st <- get   titleMeta <- stringToLaTeX TextString $ stringify $ docTitle meta   authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta   docLangs <- catMaybes <$>       mapM (toLang . Just) (ordNub (query (extract "lang") blocks))-  let hasStringValue x = isJust (getField x metadata :: Maybe String)-  let geometryFromMargins = intercalate [','] $ mapMaybe (\(x,y) ->-                                ((x ++ "=") ++) <$> getField y metadata)+  let hasStringValue x = isJust (getField x metadata :: Maybe (Doc Text))+  let geometryFromMargins = mconcat $ intersperse ("," :: Doc Text) $+                            mapMaybe (\(x,y) ->+                                ((x <> "=") <>) <$> getField y metadata)                               [("lmargin","margin-left")                               ,("rmargin","margin-right")                               ,("tmargin","margin-top")                               ,("bmargin","margin-bottom")                               ]-  let toPolyObj lang = object [ "name"    .= T.pack name-                              , "options" .= T.pack opts ]+  let toPolyObj :: Lang -> Val Text+      toPolyObj lang = MapVal $ Context $+                        M.fromList [ ("name" , SimpleVal $ literal name)+                                   , ("options" , SimpleVal $ literal opts) ]         where           (name, opts) = toPolyglossia lang   mblang <- toLang $ case getLang options meta of@@ -206,13 +202,15 @@   let dirs = query (extract "dir") blocks    let context  =  defField "toc" (writerTableOfContents options) $-                  defField "toc-depth" (show (writerTOCDepth options -+                  defField "toc-depth" (tshow $+                                        (writerTOCDepth options -                                               if stHasChapters st                                                  then 1                                                  else 0)) $                   defField "body" main $                   defField "title-meta" titleMeta $-                  defField "author-meta" (intercalate "; " authorsMeta) $+                  defField "author-meta"+                        (T.intercalate "; " authorsMeta) $                   defField "documentclass" documentClass $                   defField "verbatim-in-note" (stVerbInNote st) $                   defField "tables" (stTable st) $@@ -229,7 +227,7 @@                       then case writerHighlightStyle options of                                 Just sty ->                                    defField "highlighting-macros"-                                      (styleToLaTeX sty)+                                      (T.stripEnd $ styleToLaTeX sty)                                 Nothing -> id                       else id) $                   (case writerCiteMethod options of@@ -243,40 +241,47 @@                             "filecolor"]) $                   (if null dirs                      then id-                     else defField "dir" ("ltr" :: String)) $+                     else defField "dir" ("ltr" :: Text)) $                   defField "section-titles" True $+                  defField "csl-refs" (stHasCslRefs st) $+                  defField "csl-hanging-indent" (stCslHangingIndent st) $                   defField "geometry" geometryFromMargins $-                  (case getField "papersize" metadata of-                        -- uppercase a4, a5, etc.-                        Just (('A':d:ds) :: String)-                          | all isDigit (d:ds) -> resetField "papersize"-                                                    (('a':d:ds) :: String)-                        _                     -> id)+                  (case T.uncons . render Nothing <$>+                        getField "papersize" metadata of+                      -- uppercase a4, a5, etc.+                      Just (Just ('A', ds))+                        | not (T.null ds) && T.all isDigit ds+                          -> resetField "papersize" ("a" <> ds)+                      _   -> id)                   metadata   let context' =           -- note: lang is used in some conditionals in the template,           -- so we need to set it if we have any babel/polyglossia:-          maybe id (defField "lang" . renderLang) mblang-        $ maybe id (defField "babel-lang" . toBabel) mblang-        $ defField "babel-otherlangs" (map toBabel docLangs)-        $ defField "babel-newcommands" (concatMap (\(poly, babel) ->+          maybe id (\l -> defField "lang"+                      (literal $ renderLang l)) mblang+        $ maybe id (\l -> defField "babel-lang"+                      (literal $ toBabel l)) mblang+        $ defField "babel-otherlangs"+             (map (literal . toBabel) docLangs)+        $ defField "babel-newcommands" (vcat $+           map (\(poly, babel) -> literal $             -- \textspanish and \textgalician are already used by babel             -- save them as \oritext... and let babel use that             if poly `elem` ["spanish", "galician"]-               then "\\let\\oritext" ++ poly ++ "\\text" ++ poly ++ "\n" ++-                    "\\AddBabelHook{" ++ poly ++ "}{beforeextras}" ++-                      "{\\renewcommand{\\text" ++ poly ++ "}{\\oritext"-                      ++ poly ++ "}}\n" ++-                    "\\AddBabelHook{" ++ poly ++ "}{afterextras}" ++-                      "{\\renewcommand{\\text" ++ poly ++ "}[2][]{\\foreignlanguage{"-                      ++ poly ++ "}{##2}}}\n"+               then "\\let\\oritext" <> poly <> "\\text" <> poly <> "\n" <>+                    "\\AddBabelHook{" <> poly <> "}{beforeextras}" <>+                      "{\\renewcommand{\\text" <> poly <> "}{\\oritext"+                      <> poly <> "}}\n" <>+                    "\\AddBabelHook{" <> poly <> "}{afterextras}" <>+                      "{\\renewcommand{\\text" <> poly <> "}[2][]{\\foreignlanguage{"+                      <> poly <> "}{##2}}}"                else (if poly == "latin" -- see #4161                         then "\\providecommand{\\textlatin}{}\n\\renewcommand"-                        else "\\newcommand") ++ "{\\text" ++ poly ++-                    "}[2][]{\\foreignlanguage{" ++ babel ++ "}{#2}}\n" ++-                    "\\newenvironment{" ++ poly ++-                    "}[2][]{\\begin{otherlanguage}{" ++-                    babel ++ "}}{\\end{otherlanguage}}\n"+                        else "\\newcommand") <> "{\\text" <> poly <>+                    "}[2][]{\\foreignlanguage{" <> babel <> "}{#2}}\n" <>+                    "\\newenvironment{" <> poly <>+                    "}[2][]{\\begin{otherlanguage}{" <>+                    babel <> "}}{\\end{otherlanguage}}"             )             -- eliminate duplicates that have same polyglossia name             $ nubBy (\a b -> fst a == fst b)@@ -284,23 +289,16 @@             $ map (\l -> (fst $ toPolyglossia l, toBabel l)) docLangs           )         $ maybe id (defField "polyglossia-lang" . toPolyObj) mblang-        $ defField "polyglossia-otherlangs" (map toPolyObj docLangs)+        $ defField "polyglossia-otherlangs"+             (ListVal (map toPolyObj docLangs :: [Val Text]))         $                   defField "latex-dir-rtl"-           (getField "dir" context == Just ("rtl" :: String)) context-  case writerTemplate options of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context'---- | Convert Elements to LaTeX-elementToLaTeX :: PandocMonad m => WriterOptions -> Element -> LW m Doc-elementToLaTeX _ (Blk block) = blockToLaTeX block-elementToLaTeX opts (Sec level _ (id',classes,_) title' elements) = do-  modify $ \s -> s{stInHeading = True}-  header' <- sectionHeader ("unnumbered" `elem` classes) id' level title'-  modify $ \s -> s{stInHeading = False}-  innerContents <- mapM (elementToLaTeX opts) elements-  return $ vsep (header' : innerContents)+           ((render Nothing <$> getField "dir" context) ==+               Just ("rtl" :: Text)) context+  return $ render colwidth $+    case writerTemplate options of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context'  data StringContext = TextString                    | URLString@@ -308,15 +306,16 @@                    deriving (Eq)  -- escape things as needed for LaTeX-stringToLaTeX :: PandocMonad m => StringContext -> String -> LW m String+stringToLaTeX :: PandocMonad m => StringContext -> Text -> LW m Text stringToLaTeX context zs = do   opts <- gets stOptions-  return $-    foldr (go opts context) mempty $+  return $ T.pack $+    foldr (go opts context) mempty $ T.unpack $     if writerPreferAscii opts-       then T.unpack $ Normalize.normalize Normalize.NFD $ T.pack zs+       then Normalize.normalize Normalize.NFD zs        else zs  where+  go :: WriterOptions -> StringContext -> Char -> String -> String   go opts ctx x xs   =     let ligatures = isEnabled Ext_smart opts && ctx == TextString         isUrl = ctx == URLString@@ -327,12 +326,12 @@         emits s =           case mbAccentCmd of                Just cmd ->-                 cmd ++ "{" ++ s ++ "}" ++ drop 1 xs -- drop combining accent-               Nothing  -> s ++ xs+                 cmd <> "{" <> s <> "}" <> drop 1 xs -- drop combining accent+               Nothing  -> s <> xs         emitc c =           case mbAccentCmd of                Just cmd ->-                 cmd ++ "{" ++ [c] ++ "}" ++ drop 1 xs -- drop combining accent+                 cmd <> "{" <> [c] <> "}" <> drop 1 xs -- drop combining accent                Nothing  -> c : xs         emitcseq cs = do           case xs of@@ -343,6 +342,11 @@                 | ctx == TextString                              -> cs <> xs             _ -> cs <> "{}" <> xs+        emitquote cs = do+          case xs of+            '`':_  -> cs <> "\\," <> xs -- add thin space+            '\'':_ -> cs <> "\\," <> xs -- add thin space+            _      -> cs <> xs     in case x of          '?' | ligatures ->  -- avoid ?` ligature            case xs of@@ -375,12 +379,13 @@          ']' -> emits "{]}"  -- optional arguments          '\'' | ctx == CodeString -> emitcseq "\\textquotesingle"          '\160' -> emits "~"+         '\x200B' -> emits "\\hspace{0pt}"  -- zero-width space          '\x202F' -> emits "\\,"          '\x2026' -> emitcseq "\\ldots"-         '\x2018' | ligatures -> emits "`"-         '\x2019' | ligatures -> emits "'"-         '\x201C' | ligatures -> emits "``"-         '\x201D' | ligatures -> emits "''"+         '\x2018' | ligatures -> emitquote "`"+         '\x2019' | ligatures -> emitquote "'"+         '\x201C' | ligatures -> emitquote "``"+         '\x201D' | ligatures -> emitquote "''"          '\x2014' | ligatures -> emits "---"          '\x2013' | ligatures -> emits "--"          _ | writerPreferAscii opts@@ -431,84 +436,33 @@   , ('\8413', "\\textcircled")   ] -toLabel :: PandocMonad m => String -> LW m String+toLabel :: PandocMonad m => Text -> LW m Text toLabel z = go `fmap` stringToLaTeX URLString z- where go [] = ""-       go (x:xs)-         | (isLetter x || isDigit x) && isAscii x = x:go xs-         | x `elem` ("_-+=:;." :: String) = x:go xs-         | otherwise = "ux" ++ printf "%x" (ord x) ++ go xs+ where+   go = T.concatMap $ \x -> case x of+     _ | (isLetter x || isDigit x) && isAscii x -> T.singleton x+       | x `elemText` "_-+=:;." -> T.singleton x+       | otherwise -> T.pack $ "ux" <> printf "%x" (ord x)  -- | Puts contents into LaTeX command.-inCmd :: String -> Doc -> Doc-inCmd cmd contents = char '\\' <> text cmd <> braces contents+inCmd :: Text -> Doc Text -> Doc Text+inCmd cmd contents = char '\\' <> literal cmd <> braces contents  toSlides :: PandocMonad m => [Block] -> LW m [Block] toSlides bs = do   opts <- gets stOptions   let slideLevel = fromMaybe (getSlideLevel bs) $ writerSlideLevel opts   let bs' = prepSlides slideLevel bs-  concat `fmap` mapM (elementToBeamer slideLevel) (hierarchicalize bs')+  walkM (elementToBeamer slideLevel) $ makeSections False Nothing bs' -elementToBeamer :: PandocMonad m => Int -> Element -> LW m [Block]-elementToBeamer _slideLevel (Blk (Div attr bs)) = do-  -- make sure we support "blocks" inside divs-  bs' <- concat `fmap` mapM (elementToBeamer 0) (hierarchicalize bs)-  return [Div attr bs']-elementToBeamer _slideLevel (Blk b) = return [b]-elementToBeamer slideLevel  (Sec lvl _num (ident,classes,kvs) tit elts)-  | lvl >  slideLevel = do-      bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts-      return $ Para ( RawInline "latex" "\\begin{block}{"-                    : tit ++ [RawInline "latex" "}"] )-             : bs ++ [RawBlock "latex" "\\end{block}"]-  | lvl <  slideLevel = do-      let isSec Sec{} = True-          isSec _     = False-      let (contentElts, secElts) = break isSec elts-      let elts' = if null contentElts-                     then secElts-                     else Sec slideLevel [] nullAttr tit contentElts :-                          secElts-      bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts'-      return $ Header lvl (ident,classes,kvs) tit : bs-  | otherwise = do -- lvl == slideLevel-      -- note: [fragile] is required or verbatim breaks-      let hasCodeBlock (CodeBlock _ _) = [True]-          hasCodeBlock _               = []-      let hasCode (Code _ _) = [True]-          hasCode _          = []-      let fragile = "fragile" `elem` classes ||-                    not (null $ query hasCodeBlock elts ++ query hasCode elts)-      let frameoptions = ["allowdisplaybreaks", "allowframebreaks", "fragile",-                          "b", "c", "t", "environment",-                          "label", "plain", "shrink", "standout",-                          "noframenumbering"]-      let optionslist = ["fragile" | fragile-                                   , isNothing (lookup "fragile" kvs)-                                   , "fragile" `notElem` classes] ++-                        [k | k <- classes, k `elem` frameoptions] ++-                        [k ++ "=" ++ v | (k,v) <- kvs, k `elem` frameoptions]-      let options = if null optionslist-                       then ""-                       else "[" ++ intercalate "," optionslist ++ "]"-      let latex = RawInline (Format "latex")-      slideTitle <--            if tit == [Str "\0"] -- marker for hrule-               then return []-               else return $ latex "{" : tit ++ [latex "}"]-      ref <- toLabel ident-      let slideAnchor = if null ident-                           then []-                           else [latex ("\n\\protect\\hypertarget{" ++-                                  ref ++ "}{}")]-      let slideStart = Para $-              RawInline "latex" ("\\begin{frame}" ++ options) :-                 slideTitle ++ slideAnchor-      let slideEnd = RawBlock "latex" "\\end{frame}"-      -- now carve up slide into blocks if there are sections inside-      bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts-      return $ slideStart : bs ++ [slideEnd]+-- this creates section slides and marks slides with class "slide","block"+elementToBeamer :: PandocMonad m => Int -> Block -> LW m Block+elementToBeamer slideLevel d@(Div (ident,dclasses,dkvs)+                              xs@(Header lvl _ _ : _))+  | lvl >  slideLevel = return $ Div (ident,"block":dclasses,dkvs) xs+  | lvl <  slideLevel = return d+  | otherwise = return $ Div (ident,"slide":dclasses,dkvs) xs+elementToBeamer _ x = return x  isListBlock :: Block -> Bool isListBlock (BulletList _)     = True@@ -516,106 +470,112 @@ isListBlock (DefinitionList _) = True isListBlock _                  = False -isLineBreakOrSpace :: Inline -> Bool-isLineBreakOrSpace LineBreak = True-isLineBreakOrSpace SoftBreak = True-isLineBreakOrSpace Space     = True-isLineBreakOrSpace _         = False- -- | Convert Pandoc block element to LaTeX. blockToLaTeX :: PandocMonad m              => Block     -- ^ Block to convert-             -> LW m Doc+             -> LW m (Doc Text) blockToLaTeX Null = return empty-blockToLaTeX (Div (identifier,classes,kvs) bs)-  | "incremental" `elem` classes = do-      let classes' = filter ("incremental"/=) classes-      beamer <- gets stBeamer-      if beamer-        then do oldIncremental <- gets stIncremental-                modify $ \s -> s{ stIncremental = True }-                result <- blockToLaTeX $ Div (identifier,classes',kvs) bs-                modify $ \s -> s{ stIncremental = oldIncremental }-                return result-        else blockToLaTeX $ Div (identifier,classes',kvs) bs-  | "nonincremental" `elem` classes = do-      let classes' = filter ("nonincremental"/=) classes-      beamer <- gets stBeamer-      if beamer-        then do oldIncremental <- gets stIncremental-                modify $ \s -> s{ stIncremental = False }-                result <- blockToLaTeX $ Div (identifier,classes',kvs) bs-                modify $ \s -> s{ stIncremental = oldIncremental }-                return result-        else blockToLaTeX $ Div (identifier,classes',kvs) bs-  | otherwise = do-      beamer <- gets stBeamer-      linkAnchor' <- hypertarget True identifier empty-    -- see #2704 for the motivation for adding \leavevmode:-      let linkAnchor =-            case bs of-              Para _ : _-                | not (isEmpty linkAnchor')-                  -> "\\leavevmode" <> linkAnchor' <> "%"-              _ -> linkAnchor'-      let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir-      lang <- toLang $ lookup "lang" kvs-      let wrapColumns = if beamer && "columns" `elem` classes-                        then \contents ->-                               inCmd "begin" "columns" <> brackets "T"-                               $$ contents-                               $$ inCmd "end" "columns"-                        else id-          wrapColumn  = if beamer && "column" `elem` classes-                        then \contents ->-                               let w = maybe "0.48" fromPct (lookup "width" kvs)-                               in  inCmd "begin" "column" <>-                                   braces (text w <> "\\textwidth")-                                   $$ contents-                                   $$ inCmd "end" "column"-                        else id-          fromPct xs =-            case reverse xs of-              '%':ds -> case safeRead (reverse ds) of-                          Just digits -> showFl (digits / 100 :: Double)-                          Nothing -> xs-              _      -> xs-          wrapDir = case lookup "dir" kvs of-                      Just "rtl" -> align "RTL"-                      Just "ltr" -> align "LTR"-                      _          -> id-          wrapLang txt = case lang of-                           Just lng -> let (l, o) = toPolyglossiaEnv lng-                                           ops = if null o-                                                 then ""-                                                 else brackets $ text o-                                       in  inCmd "begin" (text l) <> ops-                                           $$ blankline <> txt <> blankline-                                           $$ inCmd "end" (text l)-                           Nothing  -> txt-          wrapNotes txt = if beamer && "notes" `elem` classes-                          then "\\note" <> braces txt -- speaker notes-                          else linkAnchor $$ txt-      (wrapColumns . wrapColumn . wrapDir . wrapLang . wrapNotes)-        <$> blockListToLaTeX bs+blockToLaTeX (Div attr@(identifier,"block":_,_) (Header _ _ ils : bs)) = do+  ref <- toLabel identifier+  let anchor = if T.null identifier+                  then empty+                  else cr <> "\\protect\\hypertarget" <>+                       braces (literal ref) <> braces empty+  title' <- inlineListToLaTeX ils+  contents <- blockListToLaTeX bs+  wrapDiv attr $ ("\\begin{block}" <> braces title' <> anchor) $$+                 contents $$ "\\end{block}"+blockToLaTeX (Div (identifier,"slide":dclasses,dkvs)+               (Header _ (_,hclasses,hkvs) ils : bs)) = do+  -- note: [fragile] is required or verbatim breaks+  let hasCodeBlock (CodeBlock _ _) = [True]+      hasCodeBlock _               = []+  let hasCode (Code _ _) = [True]+      hasCode _          = []+  let classes = dclasses ++ hclasses+  let kvs = dkvs ++ hkvs+  let fragile = "fragile" `elem` classes ||+                not (null $ query hasCodeBlock bs ++ query hasCode bs)+  let frameoptions = ["allowdisplaybreaks", "allowframebreaks", "fragile",+                      "b", "c", "t", "environment",+                      "label", "plain", "shrink", "standout",+                      "noframenumbering"]+  let optionslist = ["fragile" | fragile+                               , isNothing (lookup "fragile" kvs)+                               , "fragile" `notElem` classes] +++                    [k | k <- classes, k `elem` frameoptions] +++                    [k <> "=" <> v | (k,v) <- kvs, k `elem` frameoptions]+  let options = if null optionslist+                   then empty+                   else brackets (literal (T.intercalate "," optionslist))+  slideTitle <- if ils == [Str "\0"] -- marker for hrule+                   then return empty+                   else braces <$> inlineListToLaTeX ils+  ref <- toLabel identifier+  let slideAnchor = if T.null identifier+                       then empty+                       else cr <> "\\protect\\hypertarget" <>+                            braces (literal ref) <> braces empty+  contents <- blockListToLaTeX bs >>= wrapDiv (identifier,classes,kvs)+  return $ ("\\begin{frame}" <> options <> slideTitle <> slideAnchor) $$+           contents $$+           "\\end{frame}"+blockToLaTeX (Div (identifier@(T.uncons -> Just (_,_)),dclasses,dkvs)+               (Header lvl ("",hclasses,hkvs) ils : bs)) = do+  -- move identifier from div to header+  blockToLaTeX (Div ("",dclasses,dkvs)+               (Header lvl (identifier,hclasses,hkvs) ils : bs))+blockToLaTeX (Div (identifier,classes,kvs) bs) = do+  beamer <- gets stBeamer+  oldIncremental <- gets stIncremental+  if beamer && "incremental" `elem` classes+     then modify $ \st -> st{ stIncremental = True }+     else if beamer && "nonincremental" `elem` classes+             then modify $ \st -> st { stIncremental = False }+             else return ()+  result <- if identifier == "refs"+               then do+                 inner <- blockListToLaTeX bs+                 modify $ \st -> st{ stHasCslRefs = True+                                   , stCslHangingIndent =+                                      "hanging-indent" `elem` classes }+                 return $ "\\begin{cslreferences}" $$+                          inner $$+                          "\\end{cslreferences}"+               else blockListToLaTeX bs+  modify $ \st -> st{ stIncremental = oldIncremental }+  linkAnchor' <- hypertarget True identifier empty+  -- see #2704 for the motivation for adding \leavevmode:+  let linkAnchor =+        case bs of+          Para _ : _+            | not (isEmpty linkAnchor')+              -> "\\leavevmode" <> linkAnchor' <> "%"+          _ -> linkAnchor'+      wrapNotes txt = if beamer && "notes" `elem` classes+                         then "\\note" <> braces txt -- speaker notes+                         else linkAnchor $$ txt+  wrapNotes <$> wrapDiv (identifier,classes,kvs) result blockToLaTeX (Plain lst) =-  inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst+  inlineListToLaTeX lst -- title beginning with fig: indicates that the image is a figure-blockToLaTeX (Para [Image attr@(ident, _, _) txt (src,'f':'i':'g':':':tit)]) = do-  (capt, captForLof, footnotes) <- getCaption True txt-  lab <- labelFor ident-  let caption = "\\caption" <> captForLof <> braces capt <> lab-  img <- inlineToLaTeX (Image attr txt (src,tit))-  innards <- hypertarget True ident $-                 "\\centering" $$ img $$ caption <> cr-  let figure = cr <> "\\begin{figure}" $$ innards $$ "\\end{figure}"-  st <- get-  return $ (if stInMinipage st-               -- can't have figures in notes or minipage (here, table cell)-               -- http://www.tex.ac.uk/FAQ-ouparmd.html-               then cr <> "\\begin{center}" $$ img $+$ capt $$-                    "\\end{center}"-               else figure) $$ footnotes+blockToLaTeX (Para [Image attr@(ident, _, _) txt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt+  = do+      (capt, captForLof, footnotes) <- getCaption True txt+      lab <- labelFor ident+      let caption = "\\caption" <> captForLof <> braces capt <> lab+      img <- inlineToLaTeX (Image attr txt (src,tit))+      innards <- hypertarget True ident $+                   "\\centering" $$ img $$ caption <> cr+      let figure = cr <> "\\begin{figure}" $$ innards $$ "\\end{figure}"+      st <- get+      return $ (if stInMinipage st+                 -- can't have figures in notes or minipage (here, table cell)+                 -- http://www.tex.ac.uk/FAQ-ouparmd.html+                then cr <> "\\begin{center}" $$ img $+$ capt $$+                       "\\end{center}"+                else figure) $$ footnotes -- . . . indicates pause in beamer slides blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do   beamer <- gets stBeamer@@ -623,7 +583,7 @@      then blockToLaTeX (RawBlock "latex" "\\pause")      else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."] blockToLaTeX (Para lst) =-  inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst+  inlineListToLaTeX lst blockToLaTeX (LineBlock lns) =   blockToLaTeX $ linesToPara lns blockToLaTeX (BlockQuote lst) = do@@ -650,7 +610,7 @@                       else linkAnchor' <> "%"   let lhsCodeBlock = do         modify $ \s -> s{ stLHS = True }-        return $ flush (linkAnchor $$ "\\begin{code}" $$ text str $$+        return $ flush (linkAnchor $$ "\\begin{code}" $$ literal str $$                             "\\end{code}") $$ cr   let rawCodeBlock = do         st <- get@@ -658,41 +618,41 @@                   then modify (\s -> s{ stVerbInNote = True }) >>                        return "Verbatim"                   else return "verbatim"-        return $ flush (linkAnchor $$ text ("\\begin{" ++ env ++ "}") $$-                 text str $$ text ("\\end{" ++ env ++ "}")) <> cr+        return $ flush (linkAnchor $$ literal ("\\begin{" <> env <> "}") $$+                 literal str $$ literal ("\\end{" <> env <> "}")) <> cr   let listingsCodeBlock = do         st <- get         ref <- toLabel identifier         let params = if writerListings (stOptions st)                      then (case getListingsLanguage classes of-                                Just l  -> [ "language=" ++ mbBraced l ]+                                Just l  -> [ "language=" <> mbBraced l ]                                 Nothing -> []) ++                           [ "numbers=left" | "numberLines" `elem` classes                              || "number" `elem` classes                              || "number-lines" `elem` classes ] ++                           [ (if key == "startFrom"                                 then "firstnumber"-                                else key) ++ "=" ++ mbBraced attr |+                                else key) <> "=" <> mbBraced attr |                                 (key,attr) <- keyvalAttr,                                 key `notElem` ["exports", "tangle", "results"]                                 -- see #4889                           ] ++                           (if identifier == ""                                 then []-                                else [ "label=" ++ ref ])+                                else [ "label=" <> ref ])                       else []             printParams                 | null params = empty                 | otherwise   = brackets $ hcat (intersperse ", "-                      (map text params))-        return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$+                      (map literal params))+        return $ flush ("\\begin{lstlisting}" <> printParams $$ literal str $$                  "\\end{lstlisting}") $$ cr   let highlightedCodeBlock =         case highlight (writerSyntaxMap opts)                  formatLaTeXBlock ("",classes,keyvalAttr) str of                Left msg -> do-                 unless (null msg) $+                 unless (T.null msg) $                    report $ CouldNotHighlight msg                  rawCodeBlock                Right h -> do@@ -711,7 +671,7 @@   beamer <- gets stBeamer   if (f == Format "latex" || f == Format "tex" ||        (f == Format "beamer" && beamer))-     then return $ text x+     then return $ literal x      else do        report $ BlockNotRendered b        return empty@@ -724,7 +684,7 @@   let spacing = if isTightList lst                    then text "\\tightlist"                    else empty-  return $ text ("\\begin{itemize}" ++ inc) $$ spacing $$ vcat items $$+  return $ text ("\\begin{itemize}" <> inc) $$ spacing $$ vcat items $$              "\\end{itemize}" blockToLaTeX (OrderedList _ []) = return empty -- otherwise latex error blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do@@ -756,7 +716,7 @@                        LowerAlpha   -> "a"                        Example      -> "1"                        DefaultStyle -> "1"-  let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)+  let enum = literal $ "enum" <> T.toLower (toRomanNumeral oldlevel)   let stylecommand         | numstyle == DefaultStyle && numdelim == DefaultDelim = empty         | beamer && numstyle == Decimal && numdelim == Period = empty@@ -770,7 +730,7 @@   let spacing = if isTightList lst                    then text "\\tightlist"                    else empty-  return $ text ("\\begin{enumerate}" ++ inc)+  return $ text ("\\begin{enumerate}" <> inc)          $$ stylecommand          $$ resetcounter          $$ spacing@@ -785,14 +745,14 @@   let spacing = if all isTightList (map snd lst)                    then text "\\tightlist"                    else empty-  return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$+  return $ text ("\\begin{description}" <> inc) $$ spacing $$ vcat items $$                "\\end{description}" blockToLaTeX HorizontalRule =             return-  "\\begin{center}\\rule{0.5\\linewidth}{\\linethickness}\\end{center}"+  "\\begin{center}\\rule{0.5\\linewidth}{0.5pt}\\end{center}" blockToLaTeX (Header level (id',classes,_) lst) = do   modify $ \s -> s{stInHeading = True}-  hdr <- sectionHeader ("unnumbered" `elem` classes) id' level lst+  hdr <- sectionHeader classes id' level lst   modify $ \s -> s{stInHeading = False}   return hdr blockToLaTeX (Table caption aligns widths heads rows) = do@@ -815,7 +775,7 @@                 else "\\caption" <> captForLof <> braces captionText                          <> "\\tabularnewline"   rows' <- mapM (tableRowToLaTeX False aligns widths) rows-  let colDescriptors = text $ concatMap toColDescriptor aligns+  let colDescriptors = literal $ T.concat $ map toColDescriptor aligns   modify $ \s -> s{ stTable = True }   notes <- notesToLaTeX <$> gets stNotes   return $ "\\begin{longtable}[]" <>@@ -831,7 +791,8 @@          $$ captNotes          $$ notes -getCaption :: PandocMonad m => Bool -> [Inline] -> LW m (Doc, Doc, Doc)+getCaption :: PandocMonad m+           => Bool -> [Inline] -> LW m (Doc Text, Doc Text, Doc Text) getCaption externalNotes txt = do   oldExternalNotes <- gets stExternalNotes   modify $ \st -> st{ stExternalNotes = externalNotes, stNotes = [] }@@ -849,7 +810,7 @@                    else return empty   return (capt, captForLof, footnotes) -toColDescriptor :: Alignment -> String+toColDescriptor :: Alignment -> Text toColDescriptor align =   case align of          AlignLeft    -> "l"@@ -857,7 +818,7 @@          AlignCenter  -> "c"          AlignDefault -> "l" -blockListToLaTeX :: PandocMonad m => [Block] -> LW m Doc+blockListToLaTeX :: PandocMonad m => [Block] -> LW m (Doc Text) blockListToLaTeX lst =   vsep `fmap` mapM (\b -> setEmptyLine True >> blockToLaTeX b) lst @@ -866,7 +827,7 @@                 -> [Alignment]                 -> [Double]                 -> [[Block]]-                -> LW m Doc+                -> LW m (Doc Text) tableRowToLaTeX header aligns widths cols = do   -- scale factor compensates for extra space between columns   -- so the whole table isn't larger than columnwidth@@ -896,9 +857,9 @@                        []     -> []                        [xs]   -> xs                        chunks -> RawInline "tex" "\\vtop{" :-                                 concatMap tohbox chunks +++                                 concatMap tohbox chunks <>                                  [RawInline "tex" "}"]-  where tohbox ys = RawInline "tex" "\\hbox{\\strut " : ys +++  where tohbox ys = RawInline "tex" "\\hbox{\\strut " : ys <>                     [RawInline "tex" "}"]  -- We also change display math to inline math, since display@@ -908,7 +869,7 @@ displayMathToInline x                    = x  tableCellToLaTeX :: PandocMonad m => Bool -> (Double, Alignment, [Block])-                 -> LW m Doc+                 -> LW m (Doc Text) tableCellToLaTeX _      (0,     _,     blocks) =   blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks tableCellToLaTeX header (width, align, blocks) = do@@ -933,7 +894,7 @@             (halign <> cr <> cellContents <> "\\strut" <> cr) <>             "\\end{minipage}") -notesToLaTeX :: [Doc] -> Doc+notesToLaTeX :: [Doc Text] -> Doc Text notesToLaTeX [] = empty notesToLaTeX ns = (case length ns of                               n | n > 1 -> "\\addtocounter" <>@@ -946,7 +907,7 @@                      $ map (\x -> "\\footnotetext" <> braces x)                      $ reverse ns) -listItemToLaTeX :: PandocMonad m => [Block] -> LW m Doc+listItemToLaTeX :: PandocMonad m => [Block] -> LW m (Doc Text) listItemToLaTeX lst   -- we need to put some text before a header if it's the first   -- element in an item. This will look ugly in LaTeX regardless, but@@ -968,7 +929,7 @@       return $ "\\item" <> brackets checkbox         $$ nest 2 (isContents $+$ bsContents) -defListItemToLaTeX :: PandocMonad m => ([Inline], [[Block]]) -> LW m Doc+defListItemToLaTeX :: PandocMonad m => ([Inline], [[Block]]) -> LW m (Doc Text) defListItemToLaTeX (term, defs) = do     -- needed to turn off 'listings' because it breaks inside \item[...]:     modify $ \s -> s{stInItem = True}@@ -976,8 +937,9 @@     modify $ \s -> s{stInItem = False}     -- put braces around term if it contains an internal link,     -- since otherwise we get bad bracket interactions: \item[\hyperref[..]-    let isInternalLink (Link _ _ ('#':_,_)) = True-        isInternalLink _                    = False+    let isInternalLink (Link _ _ (src,_))+          | Just ('#', _) <- T.uncons src = True+        isInternalLink _                  = False     let term'' = if any isInternalLink term                     then braces term'                     else term'@@ -992,16 +954,18 @@  -- | Craft the section header, inserting the secton reference, if supplied. sectionHeader :: PandocMonad m-              => Bool    -- True for unnumbered-              -> [Char]+              => [Text]  -- classes+              -> Text               -> Int               -> [Inline]-              -> LW m Doc-sectionHeader unnumbered ident level lst = do+              -> LW m (Doc Text)+sectionHeader classes ident level lst = do+  let unnumbered = "unnumbered" `elem` classes+  let unlisted = "unlisted" `elem` classes   txt <- inlineListToLaTeX lst-  plain <- stringToLaTeX TextString $ concatMap stringify lst+  plain <- stringToLaTeX TextString $ T.concat $ map stringify lst   let removeInvalidInline (Note _)             = []-      removeInvalidInline (Span (id', _, _) _) | not (null id') = []+      removeInvalidInline (Span (id', _, _) _) | not (T.null id') = []       removeInvalidInline Image{}            = []       removeInvalidInline x                    = [x]   let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst@@ -1017,7 +981,7 @@                     then braces txt                     else braces (text "\\texorpdfstring"                          <> braces txt-                         <> braces (text plain))+                         <> braces (literal plain))   book <- gets stHasChapters   opts <- gets stOptions   let topLevelDivision = if book && writerTopLevelDivision opts == TopLevelDefault@@ -1056,45 +1020,92 @@   return $ if level' > 5               then txt               else prefix $$ stuffing'-                   $$ if unnumbered+                   $$ if unnumbered && not unlisted                          then "\\addcontentsline{toc}" <>                                 braces (text sectionType) <>                                 braces txtNoNotes                          else empty -hypertarget :: PandocMonad m => Bool -> String -> Doc -> LW m Doc+wrapDiv :: PandocMonad m => Attr -> Doc Text -> LW m (Doc Text)+wrapDiv (_,classes,kvs) t = do+  beamer <- gets stBeamer+  let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir+  lang <- toLang $ lookup "lang" kvs+  let wrapColumns = if beamer && "columns" `elem` classes+                    then \contents ->+                           inCmd "begin" "columns" <> brackets "T"+                           $$ contents+                           $$ inCmd "end" "columns"+                    else id+      wrapColumn  = if beamer && "column" `elem` classes+                    then \contents ->+                           let w = maybe "0.48" fromPct (lookup "width" kvs)+                           in  inCmd "begin" "column" <>+                               braces (literal w <> "\\textwidth")+                               $$ contents+                               $$ inCmd "end" "column"+                    else id+      fromPct xs =+        case T.unsnoc xs of+          Just (ds, '%') -> case safeRead ds of+                              Just digits -> showFl (digits / 100 :: Double)+                              Nothing -> xs+          _              -> xs+      wrapDir = case lookup "dir" kvs of+                  Just "rtl" -> align "RTL"+                  Just "ltr" -> align "LTR"+                  _          -> id+      wrapLang txt = case lang of+                       Just lng -> let (l, o) = toPolyglossiaEnv lng+                                       ops = if T.null o+                                             then ""+                                             else brackets $ literal o+                                   in  inCmd "begin" (literal l) <> ops+                                       $$ blankline <> txt <> blankline+                                       $$ inCmd "end" (literal l)+                       Nothing  -> txt+  return $ wrapColumns . wrapColumn . wrapDir . wrapLang $ t++hypertarget :: PandocMonad m => Bool -> Text -> Doc Text -> LW m (Doc Text) hypertarget _ "" x    = return x hypertarget addnewline ident x = do-  ref <- text `fmap` toLabel ident+  ref <- literal `fmap` toLabel ident   return $ text "\\hypertarget"               <> braces ref               <> braces ((if addnewline && not (isEmpty x)                              then ("%" <> cr)                              else empty) <> x) -labelFor :: PandocMonad m => String -> LW m Doc+labelFor :: PandocMonad m => Text -> LW m (Doc Text) labelFor ""    = return empty labelFor ident = do-  ref <- text `fmap` toLabel ident+  ref <- literal `fmap` toLabel ident   return $ text "\\label" <> braces ref  -- | Convert list of inline elements to LaTeX. inlineListToLaTeX :: PandocMonad m                   => [Inline]  -- ^ Inlines to convert-                  -> LW m Doc+                  -> LW m (Doc Text) inlineListToLaTeX lst =-  mapM inlineToLaTeX (fixLineInitialSpaces lst)+  mapM inlineToLaTeX (fixLineInitialSpaces . fixInitialLineBreaks $ lst)     >>= return . hcat     -- nonbreaking spaces (~) in LaTeX don't work after line breaks,     -- so we turn nbsps after hard breaks to \hspace commands.     -- this is mostly used in verse.  where fixLineInitialSpaces [] = []-       fixLineInitialSpaces (LineBreak : Str s@('\160':_) : xs) =-         LineBreak : fixNbsps s ++ fixLineInitialSpaces xs+       fixLineInitialSpaces (LineBreak : Str s : xs)+         | Just ('\160', _) <- T.uncons s+         = LineBreak : fixNbsps s <> fixLineInitialSpaces xs        fixLineInitialSpaces (x:xs) = x : fixLineInitialSpaces xs-       fixNbsps s = let (ys,zs) = span (=='\160') s-                    in  replicate (length ys) hspace ++ [Str zs]+       fixNbsps s = let (ys,zs) = T.span (=='\160') s+                    in  replicate (T.length ys) hspace <> [Str zs]        hspace = RawInline "latex" "\\hspace*{0.333em}"+       -- We need \hfill\break for a line break at the start+       -- of a paragraph. See #5591.+       fixInitialLineBreaks (LineBreak:xs) =+         RawInline (Format "latex") "\\hfill\\break\n" :+           fixInitialLineBreaks xs+       fixInitialLineBreaks xs = xs  isQuoted :: Inline -> Bool isQuoted (Quoted _ _) = True@@ -1103,7 +1114,7 @@ -- | Convert inline element to LaTeX inlineToLaTeX :: PandocMonad m               => Inline    -- ^ Inline to convert-              -> LW m Doc+              -> LW m (Doc Text) inlineToLaTeX (Span (id',classes,kvs) ils) = do   linkAnchor <- hypertarget False id' empty   lang <- toLang $ lookup "lang" kvs@@ -1114,11 +1125,11 @@              ["LR" | ("dir", "ltr") `elem` kvs] ++              (case lang of                 Just lng -> let (l, o) = toPolyglossia lng-                                ops = if null o then "" else ("[" ++ o ++ "]")-                            in  ["text" ++ l ++ ops]+                                ops = if T.null o then "" else ("[" <> o <> "]")+                            in  ["text" <> l <> ops]                 Nothing  -> [])   contents <- inlineListToLaTeX ils-  return $ (if null id'+  return $ (if T.null id'                then empty                else "\\protect" <> linkAnchor) <>            (if null cmds@@ -1162,13 +1173,13 @@                                   , k `notElem` ["exports","tangle","results"]]         let listingsopt = if null listingsopts                              then ""-                             else "[" ++-                                  intercalate ", "-                                  (map (\(k,v) -> k ++ "=" ++ v)-                                   listingsopts) ++ "]"+                             else "[" <>+                                  T.intercalate ", "+                                  (map (\(k,v) -> k <> "=" <> v)+                                   listingsopts) <> "]"         inNote <- gets stInNote         when inNote $ modify $ \s -> s{ stVerbInNote = True }-        let chr = case "!\"'()*,-./:;?@" \\ str of+        let chr = case "!\"'()*,-./:;?@" \\ T.unpack str of                        (c:_) -> c                        []    -> '!'         let str' = escapeStringUsing (backslashEscapes "\\{}%~_&#") str@@ -1176,16 +1187,17 @@         -- (defined in the default template) so that we don't have         -- to change the way we escape characters depending on whether         -- the lstinline is inside another command.  See #1629:-        return $ text $ "\\passthrough{\\lstinline" ++ listingsopt ++ [chr] ++ str' ++ [chr] ++ "}"-  let rawCode = liftM (text . (\s -> "\\texttt{" ++ escapeSpaces s ++ "}"))+        return $ literal $ "\\passthrough{\\lstinline" <>+                        listingsopt <> T.singleton chr <> str' <> T.singleton chr <> "}"+  let rawCode = liftM (literal . (\s -> "\\texttt{" <> escapeSpaces s <> "}"))                  $ stringToLaTeX CodeString str-                where escapeSpaces =  concatMap-                         (\c -> if c == ' ' then "\\ " else [c])+                where escapeSpaces = T.concatMap+                         (\c -> if c == ' ' then "\\ " else T.singleton c)   let highlightCode =         case highlight (writerSyntaxMap opts)                  formatLaTeXInline ("",classes,[]) str of                Left msg -> do-                 unless (null msg) $ report $ CouldNotHighlight msg+                 unless (T.null msg) $ report $ CouldNotHighlight msg                  rawCode                Right h -> modify (\st -> st{ stHighlighting = True }) >>                           return (text (T.unpack h))@@ -1220,20 +1232,20 @@                       else char '\x2018' <> inner <> char '\x2019' inlineToLaTeX (Str str) = do   setEmptyLine False-  liftM text $ stringToLaTeX TextString str+  liftM literal $ stringToLaTeX TextString str inlineToLaTeX (Math InlineMath str) = do   setEmptyLine False-  return $ "\\(" <> text (handleMathComment str) <> "\\)"+  return $ "\\(" <> literal (handleMathComment str) <> "\\)" inlineToLaTeX (Math DisplayMath str) = do   setEmptyLine False-  return $ "\\[" <> text (handleMathComment str) <> "\\]"+  return $ "\\[" <> literal (handleMathComment str) <> "\\]" inlineToLaTeX il@(RawInline f str) = do   beamer <- gets stBeamer   if (f == Format "latex" || f == Format "tex" ||         (f == Format "beamer" && beamer))      then do        setEmptyLine False-       return $ text str+       return $ literal str      else do        report $ InlineNotRendered il        return empty@@ -1248,30 +1260,33 @@        WrapNone     -> return space        WrapPreserve -> return cr inlineToLaTeX Space = return space-inlineToLaTeX (Link _ txt ('#':ident, _)) = do-  contents <- inlineListToLaTeX txt-  lab <- toLabel ident-  return $ text "\\protect\\hyperlink" <> braces (text lab) <> braces contents-inlineToLaTeX (Link _ txt (src, _)) =+inlineToLaTeX (Link _ txt (src,_))+  | Just ('#', ident) <- T.uncons src+  = do+      contents <- inlineListToLaTeX txt+      lab <- toLabel ident+      return $ text "\\protect\\hyperlink" <> braces (literal lab) <> braces contents+  | otherwise =   case txt of-        [Str x] | unEscapeString x == unEscapeString src ->  -- autolink+        [Str x] | unEscapeString (T.unpack x) == unEscapeString (T.unpack src) ->  -- autolink              do modify $ \s -> s{ stUrl = True }                 src' <- stringToLaTeX URLString (escapeURI src)-                return $ text $ "\\url{" ++ src' ++ "}"-        [Str x] | Just rest <- stripPrefix "mailto:" src,-                  unEscapeString x == unEscapeString rest -> -- email autolink+                return $ literal $ "\\url{" <> src' <> "}"+        [Str x] | Just rest <- T.stripPrefix "mailto:" src,+                  unEscapeString (T.unpack x) == unEscapeString (T.unpack rest) -> -- email autolink              do modify $ \s -> s{ stUrl = True }                 src' <- stringToLaTeX URLString (escapeURI src)                 contents <- inlineListToLaTeX txt-                return $ "\\href" <> braces (text src') <>+                return $ "\\href" <> braces (literal src') <>                    braces ("\\nolinkurl" <> braces contents)         _ -> do contents <- inlineListToLaTeX txt                 src' <- stringToLaTeX URLString (escapeURI src)-                return $ text ("\\href{" ++ src' ++ "}{") <>+                return $ literal ("\\href{" <> src' <> "}{") <>                          contents <> char '}'-inlineToLaTeX il@(Image _ _ ('d':'a':'t':'a':':':_, _)) = do-  report $ InlineNotRendered il-  return empty+inlineToLaTeX il@(Image _ _ (src, _))+  | Just _ <- T.stripPrefix "data:" src = do+      report $ InlineNotRendered il+      return empty inlineToLaTeX (Image attr _ (source, _)) = do   setEmptyLine False   modify $ \s -> s{ stGraphics = True }@@ -1279,9 +1294,9 @@   let showDim dir = let d = text (show dir) <> "="                     in case dimension dir attr of                          Just (Pixel a)   ->-                           [d <> text (showInInch opts (Pixel a)) <> "in"]+                           [d <> literal (showInInch opts (Pixel a)) <> "in"]                          Just (Percent a) ->-                           [d <> text (showFl (a / 100)) <>+                           [d <> literal (showFl (a / 100)) <>                              case dir of                                 Width  -> "\\textwidth"                                 Height -> "\\textheight"@@ -1295,18 +1310,18 @@                                 Height | isJust (dimension Width attr) ->                                   [d <> "\\textheight"]                                 _ -> []-      dimList = showDim Width ++ showDim Height+      dimList = showDim Width <> showDim Height       dims = if null dimList                 then empty-                else brackets $ cat (intersperse "," dimList)+                else brackets $ mconcat (intersperse "," dimList)       source' = if isURI source                    then source-                   else unEscapeString source+                   else T.pack $ unEscapeString $ T.unpack source   source'' <- stringToLaTeX URLString source'   inHeading <- gets stInHeading   return $     (if inHeading then "\\protect\\includegraphics" else "\\includegraphics") <>-    dims <> braces (text source'')+    dims <> braces (literal source'') inlineToLaTeX (Note contents) = do   setEmptyLine False   externalNotes <- gets stExternalNotes@@ -1331,13 +1346,14 @@  -- A comment at the end of math needs to be followed by a newline, -- or the closing delimiter gets swallowed.-handleMathComment :: String -> String+handleMathComment :: Text -> Text handleMathComment s =-  let (_, ys) = break (\c -> c == '\n' || c == '%') $ reverse s-  in  case ys of-         '%':'\\':_ -> s-         '%':_      -> s ++ "\n"-         _          -> s+  let (_, ys) = T.break (\c -> c == '\n' || c == '%') $ T.reverse s -- no T.breakEnd+  in  case T.uncons ys of+        Just ('%', ys') -> case T.uncons ys' of+          Just ('\\', _) -> s+          _              -> s <> "\n"+        _                -> s  protectCode :: Inline -> [Inline] protectCode x@(Code _ _) = [ltx "\\mbox{" , x , ltx "}"]@@ -1347,7 +1363,7 @@ setEmptyLine :: PandocMonad m => Bool -> LW m () setEmptyLine b = modify $ \st -> st{ stEmptyLine = b } -citationsToNatbib :: PandocMonad m => [Citation] -> LW m Doc+citationsToNatbib :: PandocMonad m => [Citation] -> LW m (Doc Text) citationsToNatbib             [one]   = citeCommand c p s k@@ -1374,7 +1390,7 @@                  head cits      s         = citationSuffix  $                  last cits-     ks        = intercalate ", " $ map citationId cits+     ks        = T.intercalate ", " $ map citationId cits  citationsToNatbib (c:cs) | citationMode c == AuthorInText = do      author <- citeCommand "citeauthor" [] [] (citationId c)@@ -1398,28 +1414,37 @@                NormalCitation -> citeCommand "citealp"  p s k  citeCommand :: PandocMonad m-            => String -> [Inline] -> [Inline] -> String -> LW m Doc+            => Text -> [Inline] -> [Inline] -> Text -> LW m (Doc Text) citeCommand c p s k = do   args <- citeArguments p s k-  return $ text ("\\" ++ c) <> args+  return $ literal ("\\" <> c) <> args  citeArguments :: PandocMonad m-              => [Inline] -> [Inline] -> String -> LW m Doc+              => [Inline] -> [Inline] -> Text -> LW m (Doc Text) 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+  let s' = stripLocatorBraces $ case s of+        (Str t : r) -> case T.uncons t of+          Just (x, xs)+            | T.null xs+            , isPunctuation x -> dropWhile (== Space) r+            | isPunctuation x -> Str xs : r+          _ -> s+        _   -> 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)+  return $ optargs <> braces (literal k) -citationsToBiblatex :: PandocMonad m => [Citation] -> LW m Doc+-- strip off {} used to define locator in pandoc-citeproc; see #5722+stripLocatorBraces :: [Inline] -> [Inline]+stripLocatorBraces = walk go+  where go (Str xs) = Str $ T.filter (\c -> c /= '{' && c /= '}') xs+        go x        = x++citationsToBiblatex :: PandocMonad m => [Citation] -> LW m (Doc Text) citationsToBiblatex             [one]   = citeCommand cmd p s k@@ -1442,7 +1467,7 @@                     AuthorInText   -> "\\textcite"                     NormalCitation -> "\\autocite"       return $ text cmd <>-               braces (text (intercalate "," (map citationId (c:cs))))+               braces (literal (T.intercalate "," (map citationId (c:cs))))   | otherwise = do     let cmd = case citationMode c of                     SuppressAuthor -> "\\autocites*"@@ -1459,17 +1484,17 @@ citationsToBiblatex _ = return empty  -- Determine listings language from list of class attributes.-getListingsLanguage :: [String] -> Maybe String+getListingsLanguage :: [Text] -> Maybe Text getListingsLanguage xs   = foldr ((<|>) . toListingsLanguage) Nothing xs -mbBraced :: String -> String-mbBraced x = if not (all isAlphaNum x)+mbBraced :: Text -> Text+mbBraced x = if not (T.all isAlphaNum x)                 then "{" <> x <> "}"                 else x  -- Extract a key from divs and spans-extract :: String -> Block -> [String]+extract :: Text -> Block -> [Text] extract key (Div attr _)     = lookKey key attr extract key (Plain ils)      = query (extractInline key) ils extract key (Para ils)       = query (extractInline key) ils@@ -1477,16 +1502,16 @@ extract _ _                  = []  -- Extract a key from spans-extractInline :: String -> Inline -> [String]+extractInline :: Text -> Inline -> [Text] extractInline key (Span attr _) = lookKey key attr extractInline _ _               = []  -- Look up a key in an attribute and give a list of its values-lookKey :: String -> Attr -> [String]-lookKey key (_,_,kvs) =  maybe [] words $ lookup key kvs+lookKey :: Text -> Attr -> [Text]+lookKey key (_,_,kvs) =  maybe [] T.words $ lookup key kvs  -- In environments \Arabic instead of \arabic is used-toPolyglossiaEnv :: Lang -> (String, String)+toPolyglossiaEnv :: Lang -> (Text, Text) toPolyglossiaEnv l =   case toPolyglossia l of     ("arabic", o) -> ("Arabic", o)@@ -1495,7 +1520,7 @@ -- Takes a list of the constituents of a BCP 47 language code and -- converts it to a Polyglossia (language, options) tuple -- http://mirrors.ctan.org/macros/latex/contrib/polyglossia/polyglossia.pdf-toPolyglossia :: Lang -> (String, String)+toPolyglossia :: Lang -> (Text, Text) toPolyglossia (Lang "ar" _ "DZ" _)        = ("arabic", "locale=algeria") toPolyglossia (Lang "ar" _ "IQ" _)        = ("arabic", "locale=mashriq") toPolyglossia (Lang "ar" _ "JO" _)        = ("arabic", "locale=mashriq")@@ -1535,7 +1560,7 @@ -- http://mirrors.ctan.org/macros/latex/required/babel/base/babel.pdf -- List of supported languages (slightly outdated): -- http://tug.ctan.org/language/hyph-utf8/doc/generic/hyph-utf8/hyphenation.pdf-toBabel :: Lang -> String+toBabel :: Lang -> Text toBabel (Lang "de" _ "AT" vars)   | "1901" `elem` vars                  = "austrian"   | otherwise                           = "naustrian"@@ -1567,7 +1592,7 @@ -- Takes a list of the constituents of a BCP 47 language code -- and converts it to a string shared by Babel and Polyglossia. -- https://tools.ietf.org/html/bcp47#section-2.1-commonFromBcp47 :: Lang -> String+commonFromBcp47 :: Lang -> Text commonFromBcp47 (Lang "pt" _ "BR" _)            = "brazil" -- Note: documentation says "brazilian" works too, but it doesn't seem to work -- on some systems.  See #2953.@@ -1658,22 +1683,3 @@     fromIso "vi"  = "vietnamese"     fromIso _     = "" -pDocumentOptions :: P.Parsec String () [String]-pDocumentOptions = do-  P.char '['-  opts <- P.sepBy-    (P.many $ P.spaces *> P.noneOf (" ,]" :: String) <* P.spaces)-    (P.char ',')-  P.char ']'-  return opts--pDocumentClass :: P.Parsec String () String-pDocumentClass =-  do P.skipMany (P.satisfy (/='\\'))-     P.string "\\documentclass"-     classOptions <- pDocumentOptions <|> return []-     if ("article" :: String) `elem` classOptions-       then return "article"-       else do P.skipMany (P.satisfy (/='{'))-               P.char '{'-               P.manyTill P.letter (P.char '}')
src/Text/Pandoc/Writers/Man.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.Man    Copyright   : Copyright (C) 2007-2019 John MacFarlane@@ -12,10 +13,10 @@ Conversion of 'Pandoc' documents to roff man page format.  -}-module Text.Pandoc.Writers.Man ( writeMan) where+module Text.Pandoc.Writers.Man ( writeMan ) where import Prelude import Control.Monad.State.Strict-import Data.List (intersperse, stripPrefix)+import Data.List (intersperse) import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T@@ -24,9 +25,10 @@ import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates+import Text.Pandoc.Walk (walk)+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared import Text.Pandoc.Writers.Roff@@ -43,10 +45,8 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth   titleText <- inlineListToMan opts $ docTitle meta-  let title' = render' titleText+  let title' = render Nothing titleText   let setFieldsFromTitle =        case T.break (== ' ') title' of            (cmdName, rest) -> case T.break (=='(') cmdName of@@ -61,29 +61,30 @@                                                (T.strip $ mconcat hds)                                           [] -> id                                    _  -> defField "title" title'-  metadata <- metaToJSON opts-              (fmap render' . blockListToMan opts)-              (fmap render' . inlineListToMan opts)+  metadata <- metaToContext opts+              (blockListToMan opts)+              (fmap chomp . inlineListToMan opts)               $ deleteMeta "title" meta   body <- blockListToMan opts blocks   notes <- gets stNotes   notes' <- notesToMan opts (reverse notes)-  let main = render' $ body $$ notes' $$ text ""+  let main = body $$ notes' $$ text ""   hasTables <- gets stHasTables   let context = defField "body" main               $ setFieldsFromTitle               $ defField "has-tables" hasTables               $ defField "hyphenate" True               $ defField "pandoc-version" pandocVersion metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context -escString :: WriterOptions -> String -> String+escString :: WriterOptions -> Text -> Text escString _ = escapeString AsciiOnly -- for better portability  -- | Return man representation of notes.-notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState m Doc+notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState m (Doc Text) notesToMan opts notes =   if null notes      then return empty@@ -91,7 +92,7 @@           return . (text ".SH NOTES" $$) . vcat  -- | Return man representation of a note.-noteToMan :: PandocMonad m => WriterOptions -> Int -> [Block] -> StateT WriterState m Doc+noteToMan :: PandocMonad m => WriterOptions -> Int -> [Block] -> StateT WriterState m (Doc Text) noteToMan opts num note = do   contents <- blockListToMan opts note   let marker = cr <> text ".SS " <> brackets (text (show num))@@ -105,7 +106,7 @@ blockToMan :: PandocMonad m            => WriterOptions -- ^ Options            -> Block         -- ^ Block element-           -> StateT WriterState m Doc+           -> StateT WriterState m (Doc Text) blockToMan _ Null = return empty blockToMan opts (Div _ bs) = blockListToMan opts bs blockToMan opts (Plain inlines) =@@ -117,30 +118,30 @@ blockToMan opts (LineBlock lns) =   blockToMan opts $ linesToPara lns blockToMan _ b@(RawBlock f str)-  | f == Format "man" = return $ text str+  | f == Format "man" = return $ literal str   | otherwise         = do       report $ BlockNotRendered b       return empty-blockToMan _ HorizontalRule = return $ text ".PP" $$ text "   *   *   *   *   *"+blockToMan _ HorizontalRule = return $ literal ".PP" $$ literal "   *   *   *   *   *" blockToMan opts (Header level _ inlines) = do   contents <- inlineListToMan opts inlines   let heading = case level of                   1 -> ".SH "                   _ -> ".SS "-  return $ nowrap $ text heading <> contents+  return $ nowrap $ literal heading <> contents blockToMan opts (CodeBlock _ str) = return $-  text ".IP" $$-  text ".nf" $$-  text "\\f[C]" $$-  ((case str of-    '.':_ -> text "\\&"-    _     -> mempty) <>-   text (escString opts str)) $$-  text "\\f[R]" $$-  text ".fi"+  literal ".IP" $$+  literal ".nf" $$+  literal "\\f[C]" $$+  ((case T.uncons str of+    Just ('.',_) -> literal "\\&"+    _            -> mempty) <>+   literal (escString opts str)) $$+  literal "\\f[R]" $$+  literal ".fi" blockToMan opts (BlockQuote blocks) = do   contents <- blockListToMan opts blocks-  return $ text ".RS" $$ contents $$ text ".RE"+  return $ literal ".RS" $$ contents $$ literal ".RE" blockToMan opts (Table caption alignments widths headers rows) =   let aligncode AlignLeft    = "l"       aligncode AlignRight   = "r"@@ -151,24 +152,24 @@   modify $ \st -> st{ stHasTables = True }   let iwidths = if all (== 0) widths                    then repeat ""-                   else map (printf "w(%0.1fn)" . (70 *)) widths+                   else map (T.pack . printf "w(%0.1fn)" . (70 *)) widths   -- 78n default width - 8n indent = 70n-  let coldescriptions = text $ unwords-                        (zipWith (\align width -> aligncode align ++ width)-                        alignments iwidths) ++ "."+  let coldescriptions = literal $ T.unwords+                        (zipWith (\align width -> aligncode align <> width)+                        alignments iwidths) <> "."   colheadings <- mapM (blockListToMan opts) headers-  let makeRow cols = text "T{" $$-                     vcat (intersperse (text "T}@T{") cols) $$-                     text "T}"+  let makeRow cols = literal "T{" $$+                     vcat (intersperse (literal "T}@T{") cols) $$+                     literal "T}"   let colheadings' = if all null headers                         then empty                         else makeRow colheadings $$ char '_'   body <- mapM (\row -> do                          cols <- mapM (blockListToMan opts) row                          return $ makeRow cols) rows-  return $ text ".PP" $$ caption' $$-           text ".TS" $$ text "tab(@);" $$ coldescriptions $$-           colheadings' $$ vcat body $$ text ".TE"+  return $ literal ".PP" $$ caption' $$+           literal ".TS" $$ literal "tab(@);" $$ coldescriptions $$+           colheadings' $$ vcat body $$ literal ".TE"  blockToMan opts (BulletList items) = do   contents <- mapM (bulletListItemToMan opts) items@@ -176,7 +177,7 @@ blockToMan opts (OrderedList attribs items) = do   let markers = take (length items) $ orderedListMarkers attribs   let indent = 1 +-                     maximum (map length markers)+                     maximum (map T.length markers)   contents <- mapM (\(num, item) -> orderedListItemToMan opts num indent item) $               zip markers items   return (vcat contents)@@ -185,30 +186,30 @@   return (vcat contents)  -- | Convert bullet list item (list of blocks) to man.-bulletListItemToMan :: PandocMonad m => WriterOptions -> [Block] -> StateT WriterState m Doc+bulletListItemToMan :: PandocMonad m => WriterOptions -> [Block] -> StateT WriterState m (Doc Text) bulletListItemToMan _ [] = return empty bulletListItemToMan opts (Para first:rest) =   bulletListItemToMan opts (Plain first:rest) bulletListItemToMan opts (Plain first:rest) = do   first' <- blockToMan opts (Plain first)   rest' <- blockListToMan opts rest-  let first'' = text ".IP \\[bu] 2" $$ first'+  let first'' = literal ".IP \\[bu] 2" $$ first'   let rest''  = if null rest                    then empty-                   else text ".RS 2" $$ rest' $$ text ".RE"+                   else literal ".RS 2" $$ rest' $$ literal ".RE"   return (first'' $$ rest'') bulletListItemToMan opts (first:rest) = do   first' <- blockToMan opts first   rest' <- blockListToMan opts rest-  return $ text "\\[bu] .RS 2" $$ first' $$ rest' $$ text ".RE"+  return $ literal "\\[bu] .RS 2" $$ first' $$ rest' $$ literal ".RE"  -- | Convert ordered list item (a list of blocks) to man. orderedListItemToMan :: PandocMonad m                      => WriterOptions -- ^ options-                     -> String   -- ^ order marker for list item+                     -> Text   -- ^ order marker for list item                      -> Int      -- ^ number of spaces to indent                      -> [Block]  -- ^ list item (list of blocks)-                     -> StateT WriterState m Doc+                     -> StateT WriterState m (Doc Text) orderedListItemToMan _ _ _ [] = return empty orderedListItemToMan opts num indent (Para first:rest) =   orderedListItemToMan opts num indent (Plain first:rest)@@ -216,19 +217,21 @@   first' <- blockToMan opts first   rest' <- blockListToMan opts rest   let num' = printf ("%" ++ show (indent - 1) ++ "s") num-  let first'' = text (".IP \"" ++ num' ++ "\" " ++ show indent) $$ first'+  let first'' = literal (".IP \"" <> T.pack num' <> "\" " <> tshow indent) $$ first'   let rest''  = if null rest                    then empty-                   else text ".RS 4" $$ rest' $$ text ".RE"+                   else literal ".RS 4" $$ rest' $$ literal ".RE"   return $ first'' $$ rest''  -- | Convert definition list item (label, list of blocks) to man. definitionListItemToMan :: PandocMonad m                         => WriterOptions                         -> ([Inline],[[Block]])-                        -> StateT WriterState m Doc+                        -> StateT WriterState m (Doc Text) definitionListItemToMan opts (label, defs) = do-  labelText <- inlineListToMan opts label+  -- in most man pages, option and other code in option lists is boldface,+  -- but not other things, so we try to reproduce this style:+  labelText <- inlineListToMan opts $ makeCodeBold label   contents <- if null defs                  then return empty                  else liftM vcat $ forM defs $ \blocks ->@@ -243,24 +246,29 @@                             return $ first' $$                                      if null xs                                         then empty-                                        else text ".RS" $$ rest' $$ text ".RE"+                                        else literal ".RS" $$ rest' $$ literal ".RE"                           [] -> return empty-  return $ text ".TP" $$ nowrap (text ".B " <> labelText) $$ contents+  return $ literal ".TP" $$ nowrap labelText $$ contents +makeCodeBold :: [Inline] -> [Inline]+makeCodeBold = walk go+  where go x@(Code{}) = Strong [x]+        go x          = x+ -- | Convert list of Pandoc block elements to man. blockListToMan :: PandocMonad m                => WriterOptions -- ^ Options                -> [Block]       -- ^ List of block elements-               -> StateT WriterState m Doc+               -> StateT WriterState m (Doc Text) blockListToMan opts blocks =   vcat <$> mapM (blockToMan opts) blocks  -- | Convert list of Pandoc inline elements to man.-inlineListToMan :: PandocMonad m => WriterOptions -> [Inline] -> StateT WriterState m Doc+inlineListToMan :: PandocMonad m => WriterOptions -> [Inline] -> StateT WriterState m (Doc Text) inlineListToMan opts lst = hcat <$> mapM (inlineToMan opts) lst  -- | Convert Pandoc inline element to man.-inlineToMan :: PandocMonad m => WriterOptions -> Inline -> StateT WriterState m Doc+inlineToMan :: PandocMonad m => WriterOptions -> Inline -> StateT WriterState m (Doc Text) inlineToMan opts (Span _ ils) = inlineListToMan opts ils inlineToMan opts (Emph lst) =   withFontFeature 'I' (inlineListToMan opts lst)@@ -268,7 +276,7 @@   withFontFeature 'B' (inlineListToMan opts lst) inlineToMan opts (Strikeout lst) = do   contents <- inlineListToMan opts lst-  return $ text "[STRIKEOUT:" <> contents <> char ']'+  return $ literal "[STRIKEOUT:" <> contents <> char ']' inlineToMan opts (Superscript lst) = do   contents <- inlineListToMan opts lst   return $ char '^' <> contents <> char '^'@@ -281,48 +289,48 @@   return $ char '`' <> contents <> char '\'' inlineToMan opts (Quoted DoubleQuote lst) = do   contents <- inlineListToMan opts lst-  return $ text "\\[lq]" <> contents <> text "\\[rq]"+  return $ literal "\\[lq]" <> contents <> literal "\\[rq]" inlineToMan opts (Cite _ lst) =   inlineListToMan opts lst inlineToMan opts (Code _ str) =-  withFontFeature 'C' (return (text $ escString opts str))-inlineToMan opts (Str str@('.':_)) =-  return $ afterBreak "\\&" <> text (escString opts str)-inlineToMan opts (Str str) = return $ text $ escString opts str+  withFontFeature 'C' (return (literal $ escString opts str))+inlineToMan opts (Str str@(T.uncons -> Just ('.',_))) =+  return $ afterBreak "\\&" <> literal (escString opts str)+inlineToMan opts (Str str) = return $ literal $ escString opts str inlineToMan opts (Math InlineMath str) =   lift (texMathToInlines InlineMath str) >>= inlineListToMan opts inlineToMan opts (Math DisplayMath str) = do   contents <- lift (texMathToInlines DisplayMath str) >>= inlineListToMan opts-  return $ cr <> text ".RS" $$ contents $$ text ".RE"+  return $ cr <> literal ".RS" $$ contents $$ literal ".RE" inlineToMan _ il@(RawInline f str)-  | f == Format "man" = return $ text str+  | f == Format "man" = return $ literal str   | otherwise         = do       report $ InlineNotRendered il       return empty inlineToMan _ LineBreak = return $-  cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr+  cr <> literal ".PD 0" $$ literal ".P" $$ literal ".PD" <> cr inlineToMan _ SoftBreak = return space inlineToMan _ Space = return space-inlineToMan opts (Link _ txt ('#':_, _)) =-  inlineListToMan opts txt -- skip internal links-inlineToMan opts (Link _ txt (src, _)) = do+inlineToMan opts (Link _ txt (src, _))+  | not (isURI src) = inlineListToMan opts txt -- skip relative links+  | otherwise       = do   linktext <- inlineListToMan opts txt-  let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)+  let srcSuffix = fromMaybe src (T.stripPrefix "mailto:" src)   return $ case txt of            [Str s]              | escapeURI s == srcSuffix ->-                                 char '<' <> text srcSuffix <> char '>'-           _                  -> linktext <> text " (" <> text src <> char ')'+                                 char '<' <> literal srcSuffix <> char '>'+           _                  -> linktext <> literal " (" <> literal src <> char ')' inlineToMan opts (Image attr alternate (source, tit)) = do   let txt = if null alternate || (alternate == [Str ""]) ||                (alternate == [Str source]) -- to prevent autolinks                then [Str "image"]                else alternate   linkPart <- inlineToMan opts (Link attr txt (source, tit))-  return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'+  return $ char '[' <> literal "IMAGE: " <> linkPart <> char ']' inlineToMan _ (Note contents) = do   -- add to notes in state   modify $ \st -> st{ stNotes = contents : stNotes st }   notes <- gets stNotes-  let ref = show (length notes)-  return $ char '[' <> text ref <> char ']'+  let ref = tshow (length notes)+  return $ char '[' <> literal ref <> char ']'
src/Text/Pandoc/Writers/Markdown.hs view
@@ -1,8 +1,9 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE MultiWayIf          #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections       #-}+{-# LANGUAGE ViewPatterns        #-} {- |    Module      : Text.Pandoc.Writers.Markdown    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -20,20 +21,15 @@ import Prelude import Control.Monad.Reader import Control.Monad.State.Strict-import Data.Char (isPunctuation, isSpace, isAlphaNum)+import Data.Char (isAlphaNum) import Data.Default-import qualified Data.HashMap.Strict as H-import Data.List (find, group, intersperse, sortBy, stripPrefix, transpose,-                  isPrefixOf)+import Data.List (find, intersperse, sortBy, transpose) import qualified Data.Map as M-import Data.Maybe (fromMaybe)+import Data.Maybe (fromMaybe, catMaybes) import Data.Ord (comparing) import qualified Data.Set as Set-import qualified Data.Scientific as Scientific import Data.Text (Text) import qualified Data.Text as T-import qualified Data.Vector as V-import Data.Aeson (Value (Array, Bool, Number, Object, String)) import Network.HTTP (urlEncode) import Text.HTML.TagSoup (Tag (..), isTagText, parseTags) import Text.Pandoc.Class (PandocMonad, report)@@ -41,17 +37,18 @@ import Text.Pandoc.Logging import Text.Pandoc.Options import Text.Pandoc.Parsing hiding (blankline, blanklines, char, space)-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Writers.Shared+import Text.Pandoc.Templates (renderTemplate)+import Text.DocTemplates (Val(..), Context(..), FromContext(..)) import Text.Pandoc.Walk import Text.Pandoc.Writers.HTML (writeHtml5String) import Text.Pandoc.Writers.Math (texMathToInlines)-import Text.Pandoc.Writers.Shared import Text.Pandoc.XML (toHtml5Entities)  type Notes = [[Block]]-type Ref   = (Doc, Target, Attr)+type Ref   = (Text, Target, Attr) type Refs  = [Ref]  type MD m = ReaderT WriterEnv (StateT WriterState m)@@ -80,7 +77,7 @@                                , stKeys    :: M.Map Key                                                 (M.Map (Target, Attr) Int)                                , stLastIdx  :: Int-                               , stIds     :: Set.Set String+                               , stIds     :: Set.Set Text                                , stNoteNum :: Int                                } @@ -109,69 +106,83 @@ writePlain opts document =   evalMD (pandocToMarkdown opts document) def{ envPlain = True } def -pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc+pandocTitleBlock :: Doc Text -> [Doc Text] -> Doc Text -> Doc Text pandocTitleBlock tit auths dat =   hang 2 (text "% ") tit <> cr <>   hang 2 (text "% ") (vcat $ map nowrap auths) <> cr <>   hang 2 (text "% ") dat <> cr -mmdTitleBlock :: Value -> Doc-mmdTitleBlock (Object hashmap) =-  vcat $ map go $ sortBy (comparing fst) $ H.toList hashmap+mmdTitleBlock :: Context Text -> Doc Text+mmdTitleBlock (Context hashmap) =+  vcat $ map go $ sortBy (comparing fst) $ M.toList hashmap   where go (k,v) =           case (text (T.unpack k), v) of-               (k', Array vec)-                 | V.null vec     -> empty+               (k', ListVal xs)+                 | null xs        -> empty                  | otherwise      -> k' <> ":" <> space <>-                                      hcat (intersperse "; "-                                           (map fromstr $ V.toList vec))-               (_, String "")  -> empty-               (k', x)         -> k' <> ":" <> space <> nest 2 (fromstr x)-        fromstr (String s) = text (removeBlankLines $ T.unpack s)-        fromstr (Bool b)   = text (show b)-        fromstr (Number n) = text (show n)-        fromstr _          = empty-        -- blank lines not allowed in MMD metadata - we replace with .-        removeBlankLines   = trimr . unlines . map (\x ->-                               if all isSpace x then "." else x) . lines-mmdTitleBlock _ = empty+                                      hcat (intersperse "; " $+                                          catMaybes $ map fromVal xs)+               (k', SimpleVal x)+                      | isEmpty x -> empty+                      | otherwise -> k' <> ":" <> space <>+                                     nest 2 (chomp (removeBlankLines x))+               _                  -> empty+        removeBlankLines BlankLines{} = cr <> text "." <> cr+        removeBlankLines (Concat x y) = removeBlankLines x <>+                                        removeBlankLines y+        removeBlankLines x            = x -plainTitleBlock :: Doc -> [Doc] -> Doc -> Doc+plainTitleBlock :: Doc Text -> [Doc Text] -> Doc Text -> Doc Text plainTitleBlock tit auths dat =   tit <> cr <>   (hcat (intersperse (text "; ") auths)) <> cr <>   dat <> cr -yamlMetadataBlock :: Value -> Doc-yamlMetadataBlock v = "---" $$ (jsonToYaml v) $$ "---"+yamlMetadataBlock :: Context Text -> Doc Text+yamlMetadataBlock v = "---" $$ (contextToYaml v) $$ "---" -jsonToYaml :: Value -> Doc-jsonToYaml (Object hashmap) =-  vcat $ map (\(k,v) ->-          case (text (T.unpack k), v, jsonToYaml v) of-               (k', Array vec, x)-                 | V.null vec     -> empty-                 | otherwise      -> (k' <> ":") $$ x-               (k', Object hm, x)-                 | H.null hm      -> k' <> ": {}"-                 | otherwise      -> (k' <> ":") $$ nest 2 x-               (_, String "", _)  -> empty-               (k', _, x)         -> k' <> ":" <> space <> hang 2 "" x)-       $ sortBy (comparing fst) $ H.toList hashmap-jsonToYaml (Array vec) =-  vcat $ map (\v -> hang 2 "- " (jsonToYaml v)) $ V.toList vec-jsonToYaml (String "") = empty-jsonToYaml (String s) =-  case T.unpack s of-     x | '\n' `elem` x -> hang 2 ("|" <> cr) $ text x-       | not (any isPunctuation x) -> text x-       | otherwise     -> text $ "'" ++ substitute "'" "''" x ++ "'"-jsonToYaml (Bool b) = text $ show b-jsonToYaml (Number n)-  | Scientific.isInteger n = text $ show (floor n :: Integer)-  | otherwise              = text $ show n-jsonToYaml _ = empty+contextToYaml :: Context Text -> Doc Text+contextToYaml (Context o) =+  vcat $ map keyvalToYaml $ sortBy (comparing fst) $ M.toList o+ where+  keyvalToYaml (k,v) =+          case (text (T.unpack k), v) of+               (k', ListVal vs)+                 | null vs        -> empty+                 | otherwise      -> (k' <> ":") $$ valToYaml v+               (k', MapVal (Context m))+                 | M.null m       -> k' <> ": {}"+                 | otherwise      -> (k' <> ":") $$ nest 2 (valToYaml v)+               (_, SimpleVal x)+                     | isEmpty x  -> empty+               (_, NullVal)       -> empty+               (k', _)            -> k' <> ":" <+> hang 2 "" (valToYaml v) +valToYaml :: Val Text -> Doc Text+valToYaml (ListVal xs) =+  vcat $ map (\v -> hang 2 "- " (valToYaml v)) xs+valToYaml (MapVal c) = contextToYaml c+valToYaml (SimpleVal x)+  | isEmpty x = empty+  | otherwise =+      if hasNewlines x+         then hang 0 ("|" <> cr) x+         else if any hasPunct x+           then "'" <> fmap escapeSingleQuotes x <> "'"+           else x+    where+      hasNewlines NewLine = True+      hasNewlines BlankLines{} = True+      hasNewlines CarriageReturn = True+      hasNewlines (Concat w z) = hasNewlines w || hasNewlines z+      hasNewlines _ = False+      hasPunct = T.any isYamlPunct+      isYamlPunct = (`elem` ['-','?',':',',','[',']','{','}',+                             '#','&','*','!','|','>','\'','"',+                             '%','@','`',',','[',']','{','}'])+      escapeSingleQuotes = T.replace "'" "''"+valToYaml _ = empty+ -- | Return markdown representation of document. pandocToMarkdown :: PandocMonad m => WriterOptions -> Pandoc -> MD m Text pandocToMarkdown opts (Pandoc meta blocks) = do@@ -179,15 +190,13 @@                     then Just $ writerColumns opts                     else Nothing   isPlain <- asks envPlain-  let render' :: Doc -> Text-      render' = render colwidth . chomp-  metadata <- metaToJSON'-               (fmap render' . blockListToMarkdown opts)-               (fmap render' . blockToMarkdown opts . Plain)+  metadata <- metaToContext'+               (blockListToMarkdown opts)+               (inlineListToMarkdown opts)                meta-  let title' = maybe empty text $ getField "title" metadata-  let authors' = maybe [] (map text) $ getField "author" metadata-  let date' = maybe empty text $ getField "date" metadata+  let title' = maybe empty id $ getField "title" metadata+  let authors' = maybe [] id $ getField "author" metadata+  let date' = maybe empty id $ getField "date" metadata   let titleblock = case writerTemplate opts of                         Just _ | isPlain ->                                  plainTitleBlock title' authors' date'@@ -201,9 +210,8 @@                         Nothing -> empty   let headerBlocks = filter isHeaderBlock blocks   toc <- if writerTableOfContents opts-         then render' <$> blockToMarkdown opts-                            ( toTableOfContents opts headerBlocks )-         else return ""+         then blockToMarkdown opts ( toTableOfContents opts headerBlocks )+         else return mempty   -- Strip off final 'references' header if markdown citations enabled   let blocks' = if isEnabled Ext_citations opts                    then case reverse blocks of@@ -212,7 +220,7 @@                    else blocks   body <- blockListToMarkdown opts blocks'   notesAndRefs' <- notesAndRefs opts-  let main = render' $ body <> notesAndRefs'+  let main = body <> notesAndRefs'   let context  = -- for backwards compatibility we populate toc                  -- with the contents of the toc, rather than a                  -- boolean:@@ -221,31 +229,32 @@                $ defField "body" main                $ (if isNullMeta meta                      then id-                     else defField "titleblock" (render' titleblock))-               $ addVariablesToJSON opts metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+                     else defField "titleblock" titleblock)+               $ addVariablesToContext opts metadata+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Return markdown representation of reference key table.-refsToMarkdown :: PandocMonad m => WriterOptions -> Refs -> MD m Doc+refsToMarkdown :: PandocMonad m => WriterOptions -> Refs -> MD m (Doc Text) refsToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat  -- | Return markdown representation of a reference key. keyToMarkdown :: PandocMonad m               => WriterOptions               -> Ref-              -> MD m Doc+              -> MD m (Doc Text) keyToMarkdown opts (label', (src, tit), attr) = do-  let tit' = if null tit+  let tit' = if T.null tit                 then empty-                else space <> "\"" <> text tit <> "\""+                else space <> "\"" <> literal tit <> "\""   return $ nest 2 $ hang 2-            ("[" <> label' <> "]:" <> space) (text src <> tit')+            ("[" <> literal label' <> "]:" <> space) (literal src <> tit')             <+> linkAttributes opts attr  -- | Return markdown representation of notes.-notesToMarkdown :: PandocMonad m => WriterOptions -> [[Block]] -> MD m Doc+notesToMarkdown :: PandocMonad m => WriterOptions -> [[Block]] -> MD m (Doc Text) notesToMarkdown opts notes = do   n <- gets stNoteNum   notes' <- mapM (\(num, note) -> noteToMarkdown opts num note) (zip [n..] notes)@@ -253,27 +262,27 @@   return $ vsep notes'  -- | Return markdown representation of a note.-noteToMarkdown :: PandocMonad m => WriterOptions -> Int -> [Block] -> MD m Doc+noteToMarkdown :: PandocMonad m => WriterOptions -> Int -> [Block] -> MD m (Doc Text) noteToMarkdown opts num blocks = do   contents  <- blockListToMarkdown opts blocks-  let num' = text $ writerIdentifierPrefix opts ++ show num+  let num' = literal $ writerIdentifierPrefix opts <> tshow num   let marker = if isEnabled Ext_footnotes opts-                  then text "[^" <> num' <> text "]:"-                  else text "[" <> num' <> text "]"+                  then literal "[^" <> num' <> literal "]:"+                  else literal "[" <> num' <> literal "]"   let markerSize = 4 + offset num'   let spacer = case writerTabStop opts - markerSize of-                     n | n > 0  -> text $ replicate n ' '-                     _ -> text " "+                     n | n > 0  -> literal $ T.replicate n " "+                     _ -> literal " "   return $ if isEnabled Ext_footnotes opts               then hang (writerTabStop opts) (marker <> spacer) contents               else marker <> spacer <> contents  -- | Escape special characters for Markdown.-escapeString :: WriterOptions -> String -> String-escapeString opts =+escapeText :: WriterOptions -> Text -> Text+escapeText opts =   (if writerPreferAscii opts-      then T.unpack . toHtml5Entities . T.pack-      else id) . go+      then toHtml5Entities+      else id) . T.pack . go . T.unpack   where   go [] = []   go (c:cs) =@@ -309,15 +318,15 @@                    _            -> '.':go cs        _   -> c : go cs -attrsToMarkdown :: Attr -> Doc+attrsToMarkdown :: Attr -> Doc Text attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]         where attribId = case attribs of-                                ([],_,_) -> empty+                                ("",_,_) -> empty                                 (i,_,_)  -> "#" <> escAttr i               attribClasses = case attribs of                                 (_,[],_) -> empty                                 (_,cs,_) -> hsep $-                                            map (escAttr . ('.':))+                                            map (escAttr . ("."<>))                                             cs               attribKeys = case attribs of                                 (_,_,[]) -> empty@@ -325,34 +334,34 @@                                             map (\(k,v) -> escAttr k                                               <> "=\"" <>                                               escAttr v <> "\"") ks-              escAttr          = mconcat . map escAttrChar-              escAttrChar '"'  = text "\\\""-              escAttrChar '\\' = text "\\\\"-              escAttrChar c    = text [c]+              escAttr          = mconcat . map escAttrChar . T.unpack+              escAttrChar '"'  = literal "\\\""+              escAttrChar '\\' = literal "\\\\"+              escAttrChar c    = literal $ T.singleton c -linkAttributes :: WriterOptions -> Attr -> Doc+linkAttributes :: WriterOptions -> Attr -> Doc Text linkAttributes opts attr =   if isEnabled Ext_link_attributes opts && attr /= nullAttr      then attrsToMarkdown attr      else empty  -- | Ordered list start parser for use in Para below.-olMarker :: Parser [Char] ParserState Char+olMarker :: Parser Text ParserState () olMarker = do (start, style', delim) <- anyOrderedListMarker               if delim == Period &&                           (style' == UpperAlpha || (style' == UpperRoman &&                           start `elem` [1, 5, 10, 50, 100, 500, 1000]))-                          then spaceChar >> spaceChar-                          else spaceChar+                          then mzero -- it needs 2 spaces anyway+                          else eof  -- | True if string begins with an ordered list marker-beginsWithOrderedListMarker :: String -> Bool+beginsWithOrderedListMarker :: Text -> Bool beginsWithOrderedListMarker str =-  case runParser olMarker defaultParserState "para start" (take 10 str) of+  case runParser olMarker defaultParserState "para start" (T.take 10 str) of          Left  _ -> False          Right _ -> True -notesAndRefs :: PandocMonad m => WriterOptions -> MD m Doc+notesAndRefs :: PandocMonad m => WriterOptions -> MD m (Doc Text) notesAndRefs opts = do   notes' <- reverse <$> gets stNotes >>= notesToMarkdown opts   modify $ \s -> s { stNotes = [] }@@ -374,7 +383,7 @@ blockToMarkdown :: PandocMonad m                 => WriterOptions -- ^ Options                 -> Block         -- ^ Block element-                -> MD m Doc+                -> MD m (Doc Text) blockToMarkdown opts blk =   local (\env -> env {envBlockLevel = envBlockLevel env + 1}) $   do doc <- blockToMarkdown' opts blk@@ -386,7 +395,7 @@ blockToMarkdown' :: PandocMonad m                  => WriterOptions -- ^ Options                  -> Block         -- ^ Block element-                 -> MD m Doc+                 -> MD m (Doc Text) blockToMarkdown' _ Null = return empty blockToMarkdown' opts (Div attrs ils) = do   contents <- blockListToMarkdown opts ils@@ -394,9 +403,9 @@     case () of          _ | isEnabled Ext_fenced_divs opts &&              attrs /= nullAttr ->-                nowrap (text ":::" <+> attrsToMarkdown attrs) $$+                nowrap (literal ":::" <+> attrsToMarkdown attrs) $$                 chomp contents $$-                text ":::" <> blankline+                literal ":::" <> blankline            | isEnabled Ext_native_divs opts ||              (isEnabled Ext_raw_html opts &&               isEnabled Ext_markdown_in_html_blocks opts) ->@@ -410,44 +419,40 @@        where (id',classes',kvs') = attrs              attrs' = (id',classes',("markdown","1"):kvs') blockToMarkdown' opts (Plain inlines) = do-  contents <- inlineListToMarkdown opts inlines   -- escape if para starts with ordered list marker   isPlain <- asks envPlain-  let colwidth = if writerWrapText opts == WrapAuto-                    then Just $ writerColumns opts-                    else Nothing-  let rendered = render colwidth contents-  let escapeMarker (x:xs) | x `elem` (".()" :: String) = '\\':x:xs-                          | otherwise                  = x : escapeMarker xs-      escapeMarker []                                  = []-  let contents' =-       case rendered of-            '%':_ | isEnabled Ext_pandoc_title_block opts &&-                    isEnabled Ext_all_symbols_escapable opts ->-                    "\\" <> contents-            '+':s:_ | not isPlain && isSpace s -> "\\" <> contents-            '*':s:_ | not isPlain && isSpace s -> "\\" <> contents-            '-':s:_ | not isPlain && isSpace s -> "\\" <> contents-            '+':[]  | not isPlain -> "\\" <> contents-            '*':[]  | not isPlain -> "\\" <> contents-            '-':[]  | not isPlain -> "\\" <> contents-            '|':_ | (isEnabled Ext_line_blocks opts ||-                     isEnabled Ext_pipe_tables opts)-                    && isEnabled Ext_all_symbols_escapable opts-                  -> "\\" <> contents-            _ | not isPlain && beginsWithOrderedListMarker rendered-                  && isEnabled Ext_all_symbols_escapable opts-                  -> text $ escapeMarker rendered-              | otherwise -> contents-  return $ contents' <> cr+  let escapeMarker = T.concatMap $ \x -> if x `elemText` ".()"+                                         then T.pack ['\\', x]+                                         else T.singleton x+  let startsWithSpace (Space:_)     = True+      startsWithSpace (SoftBreak:_) = True+      startsWithSpace _             = False+  let inlines' =+        if isPlain+           then inlines+           else case inlines of+                  (Str t:ys)+                    | not isPlain+                    , (null ys || startsWithSpace ys)+                    , beginsWithOrderedListMarker t+                    -> RawInline (Format "markdown") (escapeMarker t):ys+                  (Str t:_)+                    | not isPlain+                    , t == "+" || t == "-" ||+                      (t == "%" && isEnabled Ext_pandoc_title_block opts &&+                                   isEnabled Ext_all_symbols_escapable opts)+                    -> RawInline (Format "markdown") "\\" : inlines+                  _ -> inlines+  contents <- inlineListToMarkdown opts inlines'+  return $ contents <> cr -- title beginning with fig: indicates figure-blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)])+blockToMarkdown' opts (Para [Image attr alt (src,tgt@(T.stripPrefix "fig:" -> Just tit))])   | isEnabled Ext_raw_html opts &&     not (isEnabled Ext_link_attributes opts) &&     attr /= nullAttr = -- use raw HTML-    ((<> blankline) . text . T.unpack . T.strip) <$>+    ((<> blankline) . literal . T.strip) <$>       writeHtml5String opts{ writerTemplate = Nothing }-        (Pandoc nullMeta [Para [Image attr alt (src,"fig:" ++ tit)]])+        (Pandoc nullMeta [Para [Image attr alt (src,tgt)]])   | otherwise = blockToMarkdown opts (Para [Image attr alt (src,tit)]) blockToMarkdown' opts (Para inlines) =   (<> blankline) `fmap` blockToMarkdown opts (Plain inlines)@@ -455,39 +460,39 @@   if isEnabled Ext_line_blocks opts   then do     mdLines <- mapM (inlineListToMarkdown opts) lns-    return $ (vcat $ map (hang 2 (text "| ")) mdLines) <> blankline+    return $ (vcat $ map (hang 2 (literal "| ")) mdLines) <> blankline   else blockToMarkdown opts $ linesToPara lns blockToMarkdown' opts b@(RawBlock f str) = do   plain <- asks envPlain   let Format fmt = f   let rawAttribBlock = return $-         (text "```{=" <> text fmt <> "}") $$-         text str $$-         (text "```" <> text "\n")+         (literal "```{=" <> literal fmt <> "}") $$+         literal str $$+         (literal "```" <> literal "\n")   let renderEmpty = mempty <$ report (BlockNotRendered b)   case () of     _ | plain -> renderEmpty+      | isEnabled Ext_raw_attribute opts -> rawAttribBlock       | f `elem` ["markdown", "markdown_github", "markdown_phpextra",                   "markdown_mmd", "markdown_strict"] ->-            return $ text str <> text "\n"+            return $ literal str <> literal "\n"       | f `elem` ["html", "html5", "html4"] ->             case () of               _ | isEnabled Ext_markdown_attribute opts -> return $-                    text (addMarkdownAttribute str) <> text "\n"+                    literal (addMarkdownAttribute str) <> literal "\n"                 | isEnabled Ext_raw_html opts -> return $-                    text str <> text "\n"+                    literal str <> literal "\n"                 | isEnabled Ext_raw_attribute opts -> rawAttribBlock                 | otherwise -> renderEmpty       | f `elem` ["latex", "tex"] ->             case () of               _ | isEnabled Ext_raw_tex opts -> return $-                    text str <> text "\n"+                    literal str <> literal "\n"                 | isEnabled Ext_raw_attribute opts -> rawAttribBlock                 | otherwise -> renderEmpty-      | isEnabled Ext_raw_attribute opts -> rawAttribBlock       | otherwise -> renderEmpty blockToMarkdown' opts HorizontalRule = do-  return $ blankline <> text (replicate (writerColumns opts) '-') <> blankline+  return $ blankline <> literal (T.replicate (writerColumns opts) "-") <> blankline blockToMarkdown' opts (Header level attr inlines) = do   -- first, if we're putting references at the end of a section, we   -- put them here.@@ -507,55 +512,61 @@                    (id',[],[]) | isEnabled Ext_auto_identifiers opts                                  && id' == autoId -> empty                    (id',_,_)   | isEnabled Ext_mmd_header_identifiers opts ->-                                    space <> brackets (text id')+                                    space <> brackets (literal id')                    _ | isEnabled Ext_header_attributes opts ->                                     space <> attrsToMarkdown attr                      | otherwise -> empty   contents <- inlineListToMarkdown opts $                  -- ensure no newlines; see #3736                  walk lineBreakToSpace $-                 if level == 1 && plain+                 if level == 1 && plain && isEnabled Ext_gutenberg opts                     then capitalize inlines                     else inlines   let setext = writerSetextHeaders opts       hdr = nowrap $ case level of-            1 | plain -> blanklines 3 <> contents <> blanklines 2+            1 | plain ->+                if isEnabled Ext_gutenberg opts+                   then blanklines 3 <> contents <> blanklines 2+                   else contents <> blankline               | setext ->-                  contents <> attr' <> cr <> text (replicate (offset contents) '=') <>+                  contents <> attr' <> cr <> literal (T.replicate (offset contents) "=") <>                   blankline-            2 | plain -> blanklines 2 <> contents <> blankline+            2 | plain ->+                if isEnabled Ext_gutenberg opts+                   then blanklines 2 <> contents <> blankline+                   else contents <> blankline               | setext ->-                  contents <> attr' <> cr <> text (replicate (offset contents) '-') <>+                  contents <> attr' <> cr <> literal (T.replicate (offset contents) "-") <>                   blankline             -- ghc interprets '#' characters in column 1 as linenum specifiers.             _ | plain || isEnabled Ext_literate_haskell opts ->                 contents <> blankline-            _ -> text (replicate level '#') <> space <> contents <> attr' <> blankline+            _ -> literal (T.replicate level "#") <> space <> contents <> attr' <> blankline    return $ refs <> hdr blockToMarkdown' opts (CodeBlock (_,classes,_) str)   | "haskell" `elem` classes && "literate" `elem` classes &&     isEnabled Ext_literate_haskell opts =-  return $ prefixed "> " (text str) <> blankline+  return $ prefixed "> " (literal str) <> blankline blockToMarkdown' opts (CodeBlock attribs str) = return $   case attribs == nullAttr of      False | isEnabled Ext_backtick_code_blocks opts ->-          backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline+          backticks <> attrs <> cr <> literal str <> cr <> backticks <> blankline            | isEnabled Ext_fenced_code_blocks opts ->-          tildes <> attrs <> cr <> text str <> cr <> tildes <> blankline-     _ -> nest (writerTabStop opts) (text str) <> blankline-   where endline c = text $ case [length ln-                                   | ln <- map trim (lines str)-                                   , [c,c,c] `isPrefixOf` ln-                                   , all (== c) ln] of-                               [] -> replicate 3 c-                               xs -> replicate (maximum xs + 1) c+          tildes <> attrs <> cr <> literal str <> cr <> tildes <> blankline+     _ -> nest (writerTabStop opts) (literal str) <> blankline+   where endline c = literal $ case [T.length ln+                                   | ln <- map trim (T.lines str)+                                   , T.pack [c,c,c] `T.isPrefixOf` ln+                                   , T.all (== c) ln] of+                               [] -> T.replicate 3 $ T.singleton c+                               xs -> T.replicate (maximum xs + 1) $ T.singleton c          backticks = endline '`'          tildes = endline '~'          attrs  = if isEnabled Ext_fenced_code_attributes opts                      then nowrap $ " " <> attrsToMarkdown attribs                      else case attribs of-                                (_,(cls:_),_) -> " " <> text cls+                                (_,(cls:_),_) -> " " <> literal cls                                 _             -> empty blockToMarkdown' opts (BlockQuote blocks) = do   plain <- asks envPlain@@ -613,41 +624,41 @@                writerColumns opts >= 8 * numcols -> (id,) <$>                 gridTable opts blockListToMarkdown                   (all null headers) aligns' widths' headers rows-            | isEnabled Ext_raw_html opts -> fmap (id,) $-                   (text . T.unpack) <$>-                   (writeHtml5String opts{ writerTemplate = Nothing } $ Pandoc nullMeta [t])             | hasSimpleCells &&               isEnabled Ext_pipe_tables opts -> do                 rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers                 rawRows <- mapM (fmap padRow . mapM (blockListToMarkdown opts))                            rows                 (id,) <$> pipeTable (all null headers) aligns' rawHeaders rawRows-            | otherwise -> return $ (id, text "[TABLE]")-  return $ nst $ tbl $$ caption'' $$ blankline+            | isEnabled Ext_raw_html opts -> fmap (id,) $+                   literal <$>+                   (writeHtml5String opts{ writerTemplate = Nothing } $ Pandoc nullMeta [t])+            | otherwise -> return $ (id, literal "[TABLE]")+  return $ nst (tbl $$ caption'') $$ blankline blockToMarkdown' opts (BulletList items) = do   contents <- inList $ mapM (bulletListItemToMarkdown opts) items-  return $ cat contents <> blankline+  return $ (if isTightList items then vcat else vsep) contents <> blankline blockToMarkdown' opts (OrderedList (start,sty,delim) items) = do   let start' = if isEnabled Ext_startnum opts then start else 1   let sty'   = if isEnabled Ext_fancy_lists opts then sty else DefaultStyle   let delim' = if isEnabled Ext_fancy_lists opts then delim else DefaultDelim   let attribs = (start', sty', delim')   let markers  = orderedListMarkers attribs-  let markers' = map (\m -> if length m < 3-                               then m ++ replicate (3 - length m) ' '+  let markers' = map (\m -> if T.length m < 3+                               then m <> T.replicate (3 - T.length m) " "                                else m) markers   contents <- inList $               mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $               zip markers' items-  return $ cat contents <> blankline+  return $ (if isTightList items then vcat else vsep) contents <> blankline blockToMarkdown' opts (DefinitionList items) = do   contents <- inList $ mapM (definitionListItemToMarkdown opts) items-  return $ cat contents <> blankline+  return $ mconcat contents <> blankline  inList :: Monad m => MD m a -> MD m a inList p = local (\env -> env {envInList = True}) p -addMarkdownAttribute :: String -> String+addMarkdownAttribute :: Text -> Text addMarkdownAttribute s =   case span isTagText $ reverse $ parseTags s of        (xs,(TagOpen t attrs:rest)) ->@@ -656,37 +667,39 @@                                  x /= "markdown"]        _ -> s -pipeTable :: PandocMonad m => Bool -> [Alignment] -> [Doc] -> [[Doc]] -> MD m Doc+pipeTable :: PandocMonad m+          => Bool -> [Alignment] -> [Doc Text] -> [[Doc Text]]+          -> MD m (Doc Text) pipeTable headless aligns rawHeaders rawRows = do-  let sp = text " "+  let sp = literal " "   let blockFor AlignLeft   x y = lblock (x + 2) (sp <> y) <> lblock 0 empty       blockFor AlignCenter x y = cblock (x + 2) (sp <> y) <> lblock 0 empty       blockFor AlignRight  x y = rblock (x + 2) (sp <> y) <> lblock 0 empty       blockFor _           x y = lblock (x + 2) (sp <> y) <> lblock 0 empty   let widths = map (max 3 . maximum . map offset) $ transpose (rawHeaders : rawRows)-  let torow cs = nowrap $ text "|" <>-                    hcat (intersperse (text "|") $+  let torow cs = nowrap $ literal "|" <>+                    hcat (intersperse (literal "|") $                           zipWith3 blockFor aligns widths (map chomp cs))-                    <> text "|"-  let toborder (a, w) = text $ case a of-                             AlignLeft    -> ':':replicate (w + 1) '-'-                             AlignCenter  -> ':':replicate w '-' ++ ":"-                             AlignRight   -> replicate (w + 1) '-' ++ ":"-                             AlignDefault -> replicate (w + 2) '-'+                    <> literal "|"+  let toborder (a, w) = literal $ case a of+                             AlignLeft    -> ":" <> T.replicate (w + 1) "-"+                             AlignCenter  -> ":" <> T.replicate w "-" <> ":"+                             AlignRight   -> T.replicate (w + 1) "-" <> ":"+                             AlignDefault -> T.replicate (w + 2) "-"   -- note:  pipe tables can't completely lack a   -- header; for a headerless table, we need a header of empty cells.   -- see jgm/pandoc#1996.   let header = if headless                   then torow (replicate (length aligns) empty)                   else torow rawHeaders-  let border = nowrap $ text "|" <> hcat (intersperse (text "|") $-                        map toborder $ zip aligns widths) <> text "|"+  let border = nowrap $ literal "|" <> hcat (intersperse (literal "|") $+                        map toborder $ zip aligns widths) <> literal "|"   let body   = vcat $ map torow rawRows   return $ header $$ border $$ body  pandocTable :: PandocMonad m             => WriterOptions -> Bool -> Bool -> [Alignment] -> [Double]-            -> [Doc] -> [[Doc]] -> MD m Doc+            -> [Doc Text] -> [[Doc Text]] -> MD m (Doc Text) pandocTable opts multiline headless aligns widths rawHeaders rawRows = do   let isSimple = all (==0) widths   let alignHeader alignment = case alignment of@@ -712,15 +725,15 @@   let widthsInChars         | isSimple  = map numChars columns         | otherwise = zipWith relWidth widths columns-  let makeRow = hcat . intersperse (lblock 1 (text " ")) .+  let makeRow = hcat . intersperse (lblock 1 (literal " ")) .                    (zipWith3 alignHeader aligns widthsInChars)   let rows' = map makeRow rawRows   let head' = makeRow rawHeaders-  let underline = cat $ intersperse (text " ") $-                  map (\width -> text (replicate width '-')) widthsInChars+  let underline = mconcat $ intersperse (literal " ") $+                  map (\width -> literal (T.replicate width "-")) widthsInChars   let border = if multiline-                  then text (replicate (sum widthsInChars +-                          length widthsInChars - 1) '-')+                  then literal (T.replicate (sum widthsInChars ++                          length widthsInChars - 1) "-")                   else if headless                           then underline                           else empty@@ -746,42 +759,45 @@         _                           -> False  -- | Convert bullet list item (list of blocks) to markdown.-bulletListItemToMarkdown :: PandocMonad m => WriterOptions -> [Block] -> MD m Doc+bulletListItemToMarkdown :: PandocMonad m => WriterOptions -> [Block] -> MD m (Doc Text) bulletListItemToMarkdown opts bs = do   let exts = writerExtensions opts   contents <- blockListToMarkdown opts $ taskListItemToAscii exts bs-  let sps = replicate (writerTabStop opts - 2) ' '-  let start = text ('-' : ' ' : sps)+  let sps = T.replicate (writerTabStop opts - 2) " "+  let start = literal $ "- " <> sps   -- remove trailing blank line if item ends with a tight list   let contents' = if itemEndsWithTightList bs                      then chomp contents <> cr                      else contents-  return $ hang (writerTabStop opts) start $ contents' <> cr+  return $ hang (writerTabStop opts) start $ contents'  -- | Convert ordered list item (a list of blocks) to markdown. orderedListItemToMarkdown :: PandocMonad m                           => WriterOptions -- ^ options-                          -> String        -- ^ list item marker+                          -> Text        -- ^ list item marker                           -> [Block]       -- ^ list item (list of blocks)-                          -> MD m Doc+                          -> MD m (Doc Text) orderedListItemToMarkdown opts marker bs = do   let exts = writerExtensions opts   contents <- blockListToMarkdown opts $ taskListItemToAscii exts bs-  let sps = case length marker - writerTabStop opts of-                   n | n > 0 -> text $ replicate n ' '-                   _ -> text " "-  let start = text marker <> sps+  let sps = case writerTabStop opts - T.length marker of+                   n | n > 0 -> literal $ T.replicate n " "+                   _ -> literal " "+  let ind = if isEnabled Ext_four_space_rule opts+               then writerTabStop opts+               else max (writerTabStop opts) (T.length marker + 1)+  let start = literal marker <> sps   -- remove trailing blank line if item ends with a tight list   let contents' = if itemEndsWithTightList bs                      then chomp contents <> cr                      else contents-  return $ hang (writerTabStop opts) start $ contents' <> cr+  return $ hang ind start $ contents'  -- | Convert definition list item (label, list of blocks) to markdown. definitionListItemToMarkdown :: PandocMonad m                              => WriterOptions                              -> ([Inline],[[Block]])-                             -> MD m Doc+                             -> MD m (Doc Text) definitionListItemToMarkdown opts (label, defs) = do   labelText <- blockToMarkdown opts (Plain label)   defs' <- mapM (mapM (blockToMarkdown opts)) defs@@ -791,30 +807,31 @@        isPlain <- asks envPlain        let leader  = if isPlain then "   " else ":  "        let sps = case writerTabStop opts - 3 of-                      n | n > 0   -> text $ replicate n ' '-                      _ -> text " "+                      n | n > 0   -> literal $ T.replicate n " "+                      _ -> literal " "+       let isTight = case defs of+                        ((Plain _ : _): _) -> True+                        _                  -> False        if isEnabled Ext_compact_definition_lists opts           then do             let contents = vcat $ map (\d -> hang tabStop (leader <> sps)                                 $ vcat d <> cr) defs'             return $ nowrap labelText <> cr <> contents <> cr           else do-            let contents = vcat $ map (\d -> hang tabStop (leader <> sps)-                                $ vcat d <> cr) defs'-            let isTight = case defs of-                               ((Plain _ : _): _) -> True-                               _                  -> False+            let contents = (if isTight then vcat else vsep) $ map+                            (\d -> hang tabStop (leader <> sps) $ vcat d)+                            defs'             return $ blankline <> nowrap labelText $$                      (if isTight then empty else blankline) <> contents <> blankline      else do-       return $ nowrap (chomp labelText <> text "  " <> cr) <>+       return $ nowrap (chomp labelText <> literal "  " <> cr) <>                 vsep (map vsep defs') <> blankline  -- | Convert list of Pandoc block elements to markdown. blockListToMarkdown :: PandocMonad m                     => WriterOptions -- ^ Options                     -> [Block]       -- ^ List of block elements-                    -> MD m Doc+                    -> MD m (Doc Text) blockListToMarkdown opts blocks = do   inlist <- asks envInList   isPlain <- asks envPlain@@ -839,12 +856,12 @@       fixBlocks (Plain ils : bs) =            Para ils : fixBlocks bs       fixBlocks (r@(RawBlock f raw) : b : bs)-        | not (null raw)-        , last raw /= '\n' =+        | not (T.null raw)+        , T.last raw /= '\n' =         case b of              Plain{}    -> r : fixBlocks (b:bs)              RawBlock{} -> r : fixBlocks (b:bs)-             _          -> RawBlock f (raw ++ "\n") : fixBlocks (b:bs) -- #4629+             _          -> RawBlock f (raw <> "\n") : fixBlocks (b:bs) -- #4629       fixBlocks (x : xs)             = x : fixBlocks xs       fixBlocks []                   = []       isListBlock (BulletList _)     = True@@ -856,13 +873,13 @@                        else if isEnabled Ext_raw_html opts                             then RawBlock "html" "<!-- -->\n"                             else RawBlock "markdown" "&nbsp;\n"-  mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat+  mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . mconcat -getKey :: Doc -> Key+getKey :: Doc Text -> Key getKey = toKey . render Nothing -findUsableIndex :: [Doc] -> Int -> Int-findUsableIndex lbls i = if (text (show i)) `elem` lbls+findUsableIndex :: [Text] -> Int -> Int+findUsableIndex lbls i = if (tshow i) `elem` lbls                          then findUsableIndex lbls (i + 1)                          else i @@ -876,7 +893,7 @@  -- | Get reference for target; if none exists, create unique one and return. --   Prefer label if possible; otherwise, generate a unique key.-getReference :: PandocMonad m => Attr -> Doc -> Target -> MD m Doc+getReference :: PandocMonad m => Attr -> Doc Text -> Target -> MD m Text getReference attr label target = do   refs <- gets stRefs   case find (\(_,t,a) -> t == target && a == attr) refs of@@ -889,8 +906,9 @@                                then do                                  i <- getNextIndex                                  modify $ \s -> s{ stLastIdx = i }-                                 return (text (show i), i)-                               else return (label, 0)+                                 return (tshow i, i)+                               else+                                 return (render Nothing label, 0)              modify (\s -> s{                stRefs = (lab', target, attr) : refs,                stKeys = M.insert (getKey label)@@ -901,9 +919,10 @@            Just km -> do -- we have refs with this label              case M.lookup (target, attr) km of                   Just i -> do-                    let lab' = label <> if i == 0+                    let lab' = render Nothing $+                               label <> if i == 0                                            then mempty-                                           else text (show i)+                                           else literal (tshow i)                     -- make sure it's in stRefs; it may be                     -- a duplicate that was printed in a previous                     -- block:@@ -914,7 +933,7 @@                   Nothing -> do -- but this one is to a new target                     i <- getNextIndex                     modify $ \s -> s{ stLastIdx = i }-                    let lab' = text (show i)+                    let lab' = tshow i                     modify (\s -> s{                        stRefs = (lab', target, attr) : refs,                        stKeys = M.insert (getKey label)@@ -923,7 +942,7 @@                     return lab'  -- | Convert list of Pandoc inline elements to markdown.-inlineListToMarkdown :: PandocMonad m => WriterOptions -> [Inline] -> MD m Doc+inlineListToMarkdown :: PandocMonad m => WriterOptions -> [Inline] -> MD m (Doc Text) inlineListToMarkdown opts lst = do   inlist <- asks envInList   go (if inlist then avoidBadWrapsInList lst else lst)@@ -932,28 +951,28 @@             (Link _ _ _) -> case is of                 -- If a link is followed by another link, or '[', '(' or ':'                 -- then we don't shortcut-                (Link _ _ _):_                    -> unshortcutable-                Space:(Link _ _ _):_              -> unshortcutable-                Space:(Str('[':_)):_              -> unshortcutable-                Space:(RawInline _ ('[':_)):_     -> unshortcutable-                Space:(Cite _ _):_                -> unshortcutable-                SoftBreak:(Link _ _ _):_          -> unshortcutable-                SoftBreak:(Str('[':_)):_          -> unshortcutable-                SoftBreak:(RawInline _ ('[':_)):_ -> unshortcutable-                SoftBreak:(Cite _ _):_            -> unshortcutable-                LineBreak:(Link _ _ _):_          -> unshortcutable-                LineBreak:(Str('[':_)):_          -> unshortcutable-                LineBreak:(RawInline _ ('[':_)):_ -> unshortcutable-                LineBreak:(Cite _ _):_            -> unshortcutable-                (Cite _ _):_                      -> unshortcutable-                Str ('[':_):_                     -> unshortcutable-                Str ('(':_):_                     -> unshortcutable-                Str (':':_):_                     -> unshortcutable-                (RawInline _ ('[':_)):_           -> unshortcutable-                (RawInline _ ('(':_)):_           -> unshortcutable-                (RawInline _ (':':_)):_           -> unshortcutable-                (RawInline _ (' ':'[':_)):_       -> unshortcutable-                _                                 -> shortcutable+                (Link _ _ _):_                                  -> unshortcutable+                Space:(Link _ _ _):_                            -> unshortcutable+                Space:(Str(thead -> Just '[')):_                -> unshortcutable+                Space:(RawInline _ (thead -> Just '[')):_       -> unshortcutable+                Space:(Cite _ _):_                              -> unshortcutable+                SoftBreak:(Link _ _ _):_                        -> unshortcutable+                SoftBreak:(Str(thead -> Just '[')):_            -> unshortcutable+                SoftBreak:(RawInline _ (thead -> Just '[')):_   -> unshortcutable+                SoftBreak:(Cite _ _):_                          -> unshortcutable+                LineBreak:(Link _ _ _):_                        -> unshortcutable+                LineBreak:(Str(thead -> Just '[')):_            -> unshortcutable+                LineBreak:(RawInline _ (thead -> Just '[')):_   -> unshortcutable+                LineBreak:(Cite _ _):_                          -> unshortcutable+                (Cite _ _):_                                    -> unshortcutable+                Str (thead -> Just '['):_                       -> unshortcutable+                Str (thead -> Just '('):_                       -> unshortcutable+                Str (thead -> Just ':'):_                       -> unshortcutable+                (RawInline _ (thead -> Just '[')):_             -> unshortcutable+                (RawInline _ (thead -> Just '(')):_             -> unshortcutable+                (RawInline _ (thead -> Just ':')):_             -> unshortcutable+                (RawInline _ (T.stripPrefix " [" -> Just _ )):_ -> unshortcutable+                _                                               -> shortcutable             _ -> shortcutable           where shortcutable = liftM2 (<>) (inlineToMarkdown opts i) (go is)                 unshortcutable = do@@ -961,6 +980,7 @@                              (\env -> env { envRefShortcutable = False })                              (inlineToMarkdown opts i)                     fmap (iMark <>) (go is)+                thead = fmap fst . T.uncons  isSp :: Inline -> Bool isSp Space     = True@@ -969,22 +989,22 @@  avoidBadWrapsInList :: [Inline] -> [Inline] avoidBadWrapsInList [] = []-avoidBadWrapsInList (s:Str ('>':cs):xs) | isSp s =-  Str (' ':'>':cs) : avoidBadWrapsInList xs-avoidBadWrapsInList (s:Str [c]:[])-  | isSp s && c `elem` ['-','*','+'] = Str [' ', c] : []-avoidBadWrapsInList (s:Str [c]:Space:xs)-  | isSp s && c `elem` ['-','*','+'] =-    Str [' ', c] : Space : avoidBadWrapsInList xs+avoidBadWrapsInList (s:Str (T.uncons -> Just ('>',cs)):xs) | isSp s =+  Str (" >" <> cs) : avoidBadWrapsInList xs+avoidBadWrapsInList (s:Str (T.uncons -> Just (c, cs)):[])+  | T.null cs && isSp s && c `elem` ['-','*','+'] = Str (T.pack [' ', c]) : []+avoidBadWrapsInList (s:Str (T.uncons -> Just (c, cs)):Space:xs)+  | T.null cs && isSp s && c `elem` ['-','*','+'] =+    Str (T.pack [' ', c]) : Space : avoidBadWrapsInList xs avoidBadWrapsInList (s:Str cs:Space:xs)   | isSp s && isOrderedListMarker cs =-    Str (' ':cs) : Space : avoidBadWrapsInList xs+    Str (" " <> cs) : Space : avoidBadWrapsInList xs avoidBadWrapsInList (s:Str cs:[])-  | isSp s && isOrderedListMarker cs = Str (' ':cs) : []+  | isSp s && isOrderedListMarker cs = Str (" " <> cs) : [] avoidBadWrapsInList (x:xs) = x : avoidBadWrapsInList xs -isOrderedListMarker :: String -> Bool-isOrderedListMarker xs = not (null xs) && (last xs `elem` ['.',')']) &&+isOrderedListMarker :: Text -> Bool+isOrderedListMarker xs = not (T.null xs) && (T.last xs `elem` ['.',')']) &&               isRight (runParser (anyOrderedListMarker >> eof)                        defaultParserState "" xs) @@ -993,11 +1013,11 @@ isRight (Left  _) = False  -- | Convert Pandoc inline element to markdown.-inlineToMarkdown :: PandocMonad m => WriterOptions -> Inline -> MD m Doc+inlineToMarkdown :: PandocMonad m => WriterOptions -> Inline -> MD m (Doc Text) inlineToMarkdown opts (Span ("",["emoji"],kvs) [Str s]) = do   case lookup "data-emoji" kvs of        Just emojiname | isEnabled Ext_emoji opts ->-            return $ ":" <> text emojiname <> ":"+            return $ ":" <> literal emojiname <> ":"        _ -> inlineToMarkdown opts (Str s) inlineToMarkdown opts (Span attrs ils) = do   plain <- asks envPlain@@ -1012,20 +1032,25 @@                         in "[" <> contents <> "]" <> attrs'                       | isEnabled Ext_raw_html opts ||                         isEnabled Ext_native_spans opts ->-                        tagWithAttrs "span" attrs <> contents <> text "</span>"+                        tagWithAttrs "span" attrs <> contents <> literal "</span>"                       | otherwise -> contents inlineToMarkdown _ (Emph []) = return empty inlineToMarkdown opts (Emph lst) = do   plain <- asks envPlain   contents <- inlineListToMarkdown opts lst   return $ if plain-              then "_" <> contents <> "_"+              then if isEnabled Ext_gutenberg opts+                      then "_" <> contents <> "_"+                      else contents               else "*" <> contents <> "*" inlineToMarkdown _ (Strong []) = return empty inlineToMarkdown opts (Strong lst) = do   plain <- asks envPlain   if plain-     then inlineListToMarkdown opts $ capitalize lst+     then inlineListToMarkdown opts $+          if isEnabled Ext_gutenberg opts+             then capitalize lst+             else lst      else do        contents <- inlineListToMarkdown opts lst        return $ "**" <> contents <> "**"@@ -1047,9 +1072,9 @@                          then "<sup>" <> contents <> "</sup>"                          else                            let rendered = render Nothing contents-                           in  case mapM toSuperscript rendered of-                                    Just r  -> text r-                                    Nothing -> text $ "^(" ++ rendered ++ ")"+                           in  case mapM toSuperscript (T.unpack rendered) of+                                    Just r  -> literal $ T.pack r+                                    Nothing -> literal $ "^(" <> rendered <> ")" inlineToMarkdown _ (Subscript []) = return empty inlineToMarkdown opts (Subscript lst) =   local (\env -> env {envEscapeSpaces = True}) $ do@@ -1060,9 +1085,9 @@                          then "<sub>" <> contents <> "</sub>"                          else                            let rendered = render Nothing contents-                           in  case mapM toSubscript rendered of-                                    Just r  -> text r-                                    Nothing -> text $ "_(" ++ rendered ++ ")"+                           in  case mapM toSubscript (T.unpack rendered) of+                                    Just r  -> literal $ T.pack r+                                    Nothing -> literal $ "_(" <> rendered <> ")" inlineToMarkdown opts (SmallCaps lst) = do   plain <- asks envPlain   if not plain &&@@ -1086,19 +1111,19 @@                    then "&ldquo;" <> contents <> "&rdquo;"                    else "“" <> contents <> "”" inlineToMarkdown opts (Code attr str) = do-  let tickGroups = filter (\s -> '`' `elem` s) $ group str+  let tickGroups = filter (T.any (== '`')) $ T.group str   let longest    = if null tickGroups                      then 0-                     else maximum $ map length tickGroups-  let marker     = replicate (longest + 1) '`'+                     else maximum $ map T.length tickGroups+  let marker     = T.replicate (longest + 1) "`"   let spacer     = if (longest == 0) then "" else " "   let attrs      = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr                       then attrsToMarkdown attr                       else empty   plain <- asks envPlain   if plain-     then return $ text str-     else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs+     then return $ literal str+     else return $ literal (marker <> spacer <> str <> spacer <> marker) <> attrs inlineToMarkdown opts (Str str) = do   isPlain <- asks envPlain   let str' = (if isEnabled Ext_smart opts@@ -1106,18 +1131,18 @@                  else id) $               if isPlain                  then str-                 else escapeString opts str-  return $ text str'+                 else escapeText opts str+  return $ literal str' inlineToMarkdown opts (Math InlineMath str) =   case writerHTMLMathMethod opts of        WebTeX url -> inlineToMarkdown opts-                       (Image nullAttr [Str str] (url ++ urlEncode str, str))+                       (Image nullAttr [Str str] (url <> T.pack (urlEncode $ T.unpack str), str))        _ | isEnabled Ext_tex_math_dollars opts ->-             return $ "$" <> text str <> "$"+             return $ "$" <> literal str <> "$"          | isEnabled Ext_tex_math_single_backslash opts ->-             return $ "\\(" <> text str <> "\\)"+             return $ "\\(" <> literal str <> "\\)"          | isEnabled Ext_tex_math_double_backslash opts ->-             return $ "\\\\(" <> text str <> "\\\\)"+             return $ "\\\\(" <> literal str <> "\\\\)"          | otherwise -> do              plain <- asks envPlain              texMathToInlines InlineMath str >>=@@ -1127,42 +1152,42 @@   case writerHTMLMathMethod opts of       WebTeX url -> (\x -> blankline <> x <> blankline) `fmap`              inlineToMarkdown opts (Image nullAttr [Str str]-                    (url ++ urlEncode str, str))+                    (url <> T.pack (urlEncode $ T.unpack str), str))       _ | isEnabled Ext_tex_math_dollars opts ->-            return $ "$$" <> text str <> "$$"+            return $ "$$" <> literal str <> "$$"         | isEnabled Ext_tex_math_single_backslash opts ->-            return $ "\\[" <> text str <> "\\]"+            return $ "\\[" <> literal str <> "\\]"         | isEnabled Ext_tex_math_double_backslash opts ->-            return $ "\\\\[" <> text str <> "\\\\]"+            return $ "\\\\[" <> literal str <> "\\\\]"         | otherwise -> (\x -> cr <> x <> cr) `fmap`             (texMathToInlines DisplayMath str >>= inlineListToMarkdown opts) inlineToMarkdown opts il@(RawInline f str) = do-  let tickGroups = filter (\s -> '`' `elem` s) $ group str+  let tickGroups = filter (T.any (== '`')) $ T.group str   let numticks   = if null tickGroups                      then 1-                     else 1 + maximum (map length tickGroups)+                     else 1 + maximum (map T.length tickGroups)   plain <- asks envPlain   let Format fmt = f   let rawAttribInline = return $-         text (replicate numticks '`') <> text str <>-         text (replicate numticks '`') <> text "{=" <> text fmt <> text "}"+         literal (T.replicate numticks "`") <> literal str <>+         literal (T.replicate numticks "`") <> literal "{=" <> literal fmt <> literal "}"   let renderEmpty = mempty <$ report (InlineNotRendered il)   case () of     _ | plain -> renderEmpty       | f `elem` ["markdown", "markdown_github", "markdown_phpextra",                   "markdown_mmd", "markdown_strict"] ->-            return $ text str+            return $ literal str+      | isEnabled Ext_raw_attribute opts -> rawAttribInline       | f `elem` ["html", "html5", "html4"] ->             case () of-              _ | isEnabled Ext_raw_html opts -> return $ text str+              _ | isEnabled Ext_raw_html opts -> return $ literal str                 | isEnabled Ext_raw_attribute opts -> rawAttribInline                 | otherwise -> renderEmpty       | f `elem` ["latex", "tex"] ->             case () of-              _ | isEnabled Ext_raw_tex opts -> return $ text str+              _ | isEnabled Ext_raw_tex opts -> return $ literal str                 | isEnabled Ext_raw_attribute opts -> rawAttribInline                 | otherwise -> renderEmpty-      | isEnabled Ext_raw_attribute opts -> rawAttribInline       | otherwise -> renderEmpty inlineToMarkdown opts (LineBreak) = do   plain <- asks envPlain@@ -1192,12 +1217,12 @@            rest <- mapM convertOne cs            let inbr = suffs <+> joincits rest                br   = if isEmpty inbr then empty else char '[' <> inbr <> char ']'-           return $ text ("@" ++ citationId c) <+> br+           return $ literal ("@" <> citationId c) <+> br          else do            cits <- mapM convertOne (c:cs)-           return $ text "[" <> joincits cits <> text "]"+           return $ literal "[" <> joincits cits <> literal "]"   where-        joincits = hcat . intersperse (text "; ") . filter (not . isEmpty)+        joincits = hcat . intersperse (literal "; ") . filter (not . isEmpty)         convertOne Citation { citationId      = k                             , citationPrefix  = pinlines                             , citationSuffix  = sinlines@@ -1205,9 +1230,9 @@                                = do            pdoc <- inlineListToMarkdown opts pinlines            sdoc <- inlineListToMarkdown opts sinlines-           let k' = text (modekey m ++ "@" ++ k)+           let k' = literal (modekey m <> "@" <> k)                r = case sinlines of-                        Str (y:_):_ | y `elem` (",;]@" :: String) -> k' <> sdoc+                        Str (T.uncons -> Just (y,_)):_ | y `elem` (",;]@" :: String) -> k' <> sdoc                         _                                         -> k' <+> sdoc            return $ pdoc <+> r         modekey SuppressAuthor = "-"@@ -1216,15 +1241,15 @@   | isEnabled Ext_raw_html opts &&     not (isEnabled Ext_link_attributes opts) &&     attr /= nullAttr = -- use raw HTML-    (text . T.unpack . T.strip) <$>+    (literal . T.strip) <$>       writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain [lnk]])   | otherwise = do   plain <- asks envPlain   linktext <- inlineListToMarkdown opts txt-  let linktitle = if null tit+  let linktitle = if T.null tit                      then empty-                     else text $ " \"" ++ tit ++ "\""-  let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)+                     else literal $ " \"" <> tit <> "\""+  let srcSuffix = fromMaybe src (T.stripPrefix "mailto:" src)   let useAuto = isURI src &&                 case txt of                       [Str s] | escapeURI s == srcSuffix -> True@@ -1233,12 +1258,13 @@   shortcutable <- asks envRefShortcutable   let useShortcutRefLinks = shortcutable &&                             isEnabled Ext_shortcut_reference_links opts-  reftext <- if useRefLinks then getReference attr linktext (src, tit)-                            else return empty+  reftext <- if useRefLinks+                then literal <$> getReference attr linktext (src, tit)+                else return mempty   return $ if useAuto               then if plain-                      then text srcSuffix-                      else "<" <> text srcSuffix <> ">"+                      then literal srcSuffix+                      else "<" <> literal srcSuffix <> ">"               else if useRefLinks                       then let first  = "[" <> linktext <> "]"                                second = if getKey linktext == getKey reftext@@ -1250,13 +1276,13 @@                       else if plain                               then linktext                               else "[" <> linktext <> "](" <>-                                   text src <> linktitle <> ")" <>+                                   literal src <> linktitle <> ")" <>                                    linkAttributes opts attr inlineToMarkdown opts img@(Image attr alternate (source, tit))   | isEnabled Ext_raw_html opts &&     not (isEnabled Ext_link_attributes opts) &&     attr /= nullAttr = -- use raw HTML-    (text . T.unpack . T.strip) <$>+    (literal . T.strip) <$>       writeHtml5String opts{ writerTemplate = Nothing } (Pandoc nullMeta [Plain [img]])   | otherwise = do   plain <- asks envPlain@@ -1271,7 +1297,7 @@ inlineToMarkdown opts (Note contents) = do   modify (\st -> st{ stNotes = contents : stNotes st })   st <- get-  let ref = text $ writerIdentifierPrefix opts ++ show (stNoteNum st + (length $ stNotes st) - 1)+  let ref = literal $ writerIdentifierPrefix opts <> tshow (stNoteNum st + (length $ stNotes st) - 1)   if isEnabled Ext_footnotes opts      then return $ "[^" <> ref <> "]"      else return $ "[" <> ref <> "]"
src/Text/Pandoc/Writers/Math.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} module Text.Pandoc.Writers.Math   ( texMathToInlines   , convertMath@@ -8,17 +9,19 @@ where  import Prelude+import qualified Data.Text as T import Text.Pandoc.Class import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.TeXMath (DisplayType (..), Exp, readTeX, writePandoc)+import Text.Pandoc.Options (defaultMathJaxURL, defaultKaTeXURL)  -- | Converts a raw TeX math formula to a list of 'Pandoc' inlines. -- Defaults to raw formula between @$@ or @$$@ characters if entire formula -- can't be converted. texMathToInlines :: PandocMonad m                  => MathType-                 -> String    -- ^ String to parse (assumes @'\n'@ line endings)+                 -> T.Text         -- ^ String to parse (assumes @'\n'@ line endings)                  -> m [Inline] texMathToInlines mt inp = do   res <- convertMath writePandoc mt inp@@ -29,8 +32,8 @@          return [mkFallback mt inp]        Left il           -> return [il] -mkFallback :: MathType -> String -> Inline-mkFallback mt str = Str (delim ++ str ++ delim)+mkFallback :: MathType -> T.Text -> Inline+mkFallback mt str = Str (delim <> str <> delim)    where delim = case mt of                       DisplayMath -> "$$"                       InlineMath  -> "$"@@ -39,7 +42,7 @@ -- issuing a warning and producing a fallback (a raw string) -- on failure. convertMath :: PandocMonad m-            => (DisplayType -> [Exp] -> a) -> MathType -> String+            => (DisplayType -> [Exp] -> a) -> MathType -> T.Text             -> m (Either Inline a) convertMath writer mt str =   case writer dt <$> readTeX str of@@ -51,8 +54,3 @@                    DisplayMath -> DisplayBlock                    InlineMath  -> DisplayInline -defaultMathJaxURL :: String-defaultMathJaxURL = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/"--defaultKaTeXURL :: String-defaultKaTeXURL = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/"
src/Text/Pandoc/Writers/MediaWiki.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.MediaWiki    Copyright   : Copyright (C) 2008-2019 John MacFarlane@@ -16,17 +18,18 @@ import Prelude import Control.Monad.Reader import Control.Monad.State.Strict-import Data.List (intercalate)+import Data.Maybe (fromMaybe) import qualified Data.Set as Set-import Data.Text (Text, pack)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty (render)+import Text.DocLayout (render, literal) import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared import Text.Pandoc.XML (escapeStringForXML) @@ -37,7 +40,7 @@  data WriterReader = WriterReader {     options   :: WriterOptions -- Writer options-  , listLevel :: String        -- String at beginning of list items, e.g. "**"+  , listLevel :: [Char]        -- String at beginning of list items, e.g. "**"   , useTags   :: Bool          -- True if we should use HTML tags because we're in a complex list   } @@ -54,60 +57,61 @@ pandocToMediaWiki :: PandocMonad m => Pandoc -> MediaWikiWriter m Text pandocToMediaWiki (Pandoc meta blocks) = do   opts <- asks options-  metadata <- metaToJSON opts-              (fmap trimr . blockListToMediaWiki)-              inlineListToMediaWiki+  metadata <- metaToContext opts+              (fmap (literal . trimr) . blockListToMediaWiki)+              (fmap (literal . trimr) . inlineListToMediaWiki)               meta   body <- blockListToMediaWiki blocks   notesExist <- gets stNotes   let notes = if notesExist                  then "\n<references />"                  else ""-  let main = body ++ notes+  let main = body <> notes   let context = defField "body" main                 $ defField "toc" (writerTableOfContents opts) metadata-  pack <$> case writerTemplate opts of-                Nothing  -> return main-                Just tpl -> renderTemplate' tpl context+  return $+    case writerTemplate opts of+         Nothing  -> main+         Just tpl -> render Nothing $ renderTemplate tpl context  -- | Escape special characters for MediaWiki.-escapeString :: String -> String-escapeString =  escapeStringForXML+escapeText :: Text -> Text+escapeText =  escapeStringForXML  -- | Convert Pandoc block element to MediaWiki. blockToMediaWiki :: PandocMonad m                  => Block         -- ^ Block element-                 -> MediaWikiWriter m String+                 -> MediaWikiWriter m Text  blockToMediaWiki Null = return ""  blockToMediaWiki (Div attrs bs) = do   contents <- blockListToMediaWiki bs-  return $ render Nothing (tagWithAttrs "div" attrs) ++ "\n\n" ++-                     contents ++ "\n\n" ++ "</div>"+  return $ render Nothing (tagWithAttrs "div" attrs) <> "\n\n" <>+                     contents <> "\n\n" <> "</div>"  blockToMediaWiki (Plain inlines) =   inlineListToMediaWiki inlines  -- title beginning with fig: indicates that the image is a figure-blockToMediaWiki (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do+blockToMediaWiki (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just tit)]) = do   capt <- inlineListToMediaWiki txt   img  <- imageToMediaWiki attr-  let opt = if null tit+  let opt = if T.null tit                then-                 if null capt+                 if T.null capt                     then ""-                    else "alt=" ++ capt-               else "alt=" ++ tit-  return $ "[[" ++-            intercalate "|"-            (filter (not . null) ["File:" ++ src+                    else "alt=" <> capt+               else "alt=" <> tit+  return $ "[[" <>+            T.intercalate "|"+            (filter (not . T.null) ["File:" <> src                                  , "thumb"                                  , "none"                                  , img                                  , opt                                  , capt-                                 ]) +++                                 ]) <>             "]]\n"  blockToMediaWiki (Para inlines) = do@@ -115,8 +119,8 @@   lev <- asks listLevel   contents <- inlineListToMediaWiki inlines   return $ if tags-              then  "<p>" ++ contents ++ "</p>"-              else contents ++ if null lev then "\n" else ""+              then  "<p>" <> contents <> "</p>"+              else contents <> if null lev then "\n" else ""  blockToMediaWiki (LineBlock lns) =   blockToMediaWiki $ linesToPara lns@@ -130,109 +134,109 @@  blockToMediaWiki (Header level _ inlines) = do   contents <- inlineListToMediaWiki inlines-  let eqs = replicate level '='-  return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"+  let eqs = T.replicate level "="+  return $ eqs <> " " <> contents <> " " <> eqs <> "\n"  blockToMediaWiki (CodeBlock (_,classes,_) str) = do   let at  = Set.fromList classes `Set.intersection` highlightingLangs   return $     case Set.toList at of-       [] -> "<pre" ++ (if null classes+       [] -> "<pre" <> (if null classes                            then ">"-                           else " class=\"" ++ unwords classes ++ "\">") ++-             escapeString str ++ "</pre>"-       (l:_) -> "<source lang=\"" ++ l ++ "\">" ++ str ++ "</source>"+                           else " class=\"" <> T.unwords classes <> "\">") <>+             escapeText str <> "</pre>"+       (l:_) -> "<source lang=\"" <> l <> "\">" <> str <> "</source>"             -- note:  no escape!  even for <!  blockToMediaWiki (BlockQuote blocks) = do   contents <- blockListToMediaWiki blocks-  return $ "<blockquote>" ++ contents ++ "</blockquote>"+  return $ "<blockquote>" <> contents <> "</blockquote>"  blockToMediaWiki (Table capt aligns widths headers rows') = do   caption <- if null capt                 then return ""                 else do                    c <- inlineListToMediaWiki capt-                   return $ "|+ " ++ trimr c ++ "\n"+                   return $ "|+ " <> trimr c <> "\n"   let headless = all null headers   let allrows = if headless then rows' else headers:rows'-  tableBody <- intercalate "|-\n" `fmap`+  tableBody <- T.intercalate "|-\n" `fmap`                 mapM (tableRowToMediaWiki headless aligns widths)                      (zip [1..] allrows)-  return $ "{|\n" ++ caption ++ tableBody ++ "|}\n"+  return $ "{|\n" <> caption <> tableBody <> "|}\n"  blockToMediaWiki x@(BulletList items) = do   tags <- fmap (|| not (isSimpleList x)) $ asks useTags   if tags      then do         contents <- local (\ s -> s { useTags = True }) $ mapM listItemToMediaWiki items-        return $ "<ul>\n" ++ vcat contents ++ "</ul>\n"+        return $ "<ul>\n" <> vcat contents <> "</ul>\n"      else do         lev <- asks listLevel-        contents <- local (\s -> s { listLevel = listLevel s ++ "*" }) $ mapM listItemToMediaWiki items-        return $ vcat contents ++ if null lev then "\n" else ""+        contents <- local (\s -> s { listLevel = listLevel s <> "*" }) $ mapM listItemToMediaWiki items+        return $ vcat contents <> if null lev then "\n" else ""  blockToMediaWiki x@(OrderedList attribs items) = do   tags <- fmap (|| not (isSimpleList x)) $ asks useTags   if tags      then do         contents <- local (\s -> s { useTags = True }) $ mapM listItemToMediaWiki items-        return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++ "</ol>\n"+        return $ "<ol" <> listAttribsToText attribs <> ">\n" <> vcat contents <> "</ol>\n"      else do         lev <- asks listLevel-        contents <- local (\s -> s { listLevel = listLevel s ++ "#" }) $ mapM listItemToMediaWiki items-        return $ vcat contents ++ if null lev then "\n" else ""+        contents <- local (\s -> s { listLevel = listLevel s <> "#" }) $ mapM listItemToMediaWiki items+        return $ vcat contents <> if null lev then "\n" else ""  blockToMediaWiki x@(DefinitionList items) = do   tags <- fmap (|| not (isSimpleList x)) $ asks useTags   if tags      then do         contents <- local (\s -> s { useTags = True }) $ mapM definitionListItemToMediaWiki items-        return $ "<dl>\n" ++ vcat contents ++ "</dl>\n"+        return $ "<dl>\n" <> vcat contents <> "</dl>\n"      else do         lev <- asks listLevel-        contents <- local (\s -> s { listLevel = listLevel s ++ ";" }) $ mapM definitionListItemToMediaWiki items-        return $ vcat contents ++ if null lev then "\n" else ""+        contents <- local (\s -> s { listLevel = listLevel s <> ";" }) $ mapM definitionListItemToMediaWiki items+        return $ vcat contents <> if null lev then "\n" else ""  -- Auxiliary functions for lists:  -- | Convert ordered list attributes to HTML attribute string-listAttribsToString :: ListAttributes -> String-listAttribsToString (startnum, numstyle, _) =-  let numstyle' = camelCaseToHyphenated $ show numstyle+listAttribsToText :: ListAttributes -> Text+listAttribsToText (startnum, numstyle, _) =+  let numstyle' = camelCaseToHyphenated $ tshow numstyle   in  (if startnum /= 1-          then " start=\"" ++ show startnum ++ "\""-          else "") +++          then " start=\"" <> tshow startnum <> "\""+          else "") <>       (if numstyle /= DefaultStyle-          then " style=\"list-style-type: " ++ numstyle' ++ ";\""+          then " style=\"list-style-type: " <> numstyle' <> ";\""           else "")  -- | Convert bullet or ordered list item (list of blocks) to MediaWiki.-listItemToMediaWiki :: PandocMonad m => [Block] -> MediaWikiWriter m String+listItemToMediaWiki :: PandocMonad m => [Block] -> MediaWikiWriter m Text listItemToMediaWiki items = do   contents <- blockListToMediaWiki items   tags <- asks useTags   if tags-     then return $ "<li>" ++ contents ++ "</li>"+     then return $ "<li>" <> contents <> "</li>"      else do        marker <- asks listLevel-       return $ marker ++ " " ++ contents+       return $ T.pack marker <> " " <> contents  -- | Convert definition list item (label, list of blocks) to MediaWiki. definitionListItemToMediaWiki :: PandocMonad m                               => ([Inline],[[Block]])-                              -> MediaWikiWriter m String+                              -> MediaWikiWriter m Text definitionListItemToMediaWiki (label, items) = do   labelText <- inlineListToMediaWiki label   contents <- mapM blockListToMediaWiki items   tags <- asks useTags   if tags-     then return $ "<dt>" ++ labelText ++ "</dt>\n" ++-           intercalate "\n" (map (\d -> "<dd>" ++ d ++ "</dd>") contents)+     then return $ "<dt>" <> labelText <> "</dt>\n" <>+           T.intercalate "\n" (map (\d -> "<dd>" <> d <> "</dd>") contents)      else do        marker <- asks listLevel-       return $ marker ++ " " ++ labelText ++ "\n" ++-           intercalate "\n" (map (\d -> init marker ++ ": " ++ d) contents)+       return $ T.pack marker <> " " <> labelText <> "\n" <>+           T.intercalate "\n" (map (\d -> T.pack (init marker) <> ": " <> d) contents)  -- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed. isSimpleList :: Block -> Bool@@ -270,8 +274,8 @@ isPlainOrPara _         = False  -- | Concatenates strings with line breaks between them.-vcat :: [String] -> String-vcat = intercalate "\n"+vcat :: [Text] -> Text+vcat = T.intercalate "\n"  -- Auxiliary functions for tables: @@ -280,119 +284,119 @@                     -> [Alignment]                     -> [Double]                     -> (Int, [[Block]])-                    -> MediaWikiWriter m String+                    -> MediaWikiWriter m Text tableRowToMediaWiki headless alignments widths (rownum, cells) = do   cells' <- mapM (tableCellToMediaWiki headless rownum)           $ zip3 alignments widths cells-  return $ unlines cells'+  return $ T.unlines cells'  tableCellToMediaWiki :: PandocMonad m                      => Bool                      -> Int                      -> (Alignment, Double, [Block])-                     -> MediaWikiWriter m String+                     -> MediaWikiWriter m Text tableCellToMediaWiki headless rownum (alignment, width, bs) = do   contents <- blockListToMediaWiki bs   let marker = if rownum == 1 && not headless then "!" else "|"-  let percent w = show (truncate (100*w) :: Integer) ++ "%"-  let attrs = ["align=" ++ show (alignmentToString alignment) |-                 alignment /= AlignDefault && alignment /= AlignLeft] ++-              ["width=\"" ++ percent width ++ "\"" |+  let percent w = tshow (truncate (100*w) :: Integer) <> "%"+  let attrs = ["align=" <> tshow (alignmentToText alignment) |+                 alignment /= AlignDefault && alignment /= AlignLeft] <>+              ["width=\"" <> percent width <> "\"" |                  width /= 0.0 && rownum == 1]   let attr = if null attrs                 then ""-                else unwords attrs ++ "|"+                else T.unwords attrs <> "|"   let sep = case bs of                  [Plain _] -> " "                  [Para  _] -> " "                  []        -> ""                  _         -> "\n"-  return $ marker ++ attr ++ sep ++ trimr contents+  return $ marker <> attr <> sep <> trimr contents -alignmentToString :: Alignment -> String-alignmentToString alignment = case alignment of+alignmentToText :: Alignment -> Text+alignmentToText alignment = case alignment of                                  AlignLeft    -> "left"                                  AlignRight   -> "right"                                  AlignCenter  -> "center"                                  AlignDefault -> "left" -imageToMediaWiki :: PandocMonad m => Attr -> MediaWikiWriter m String+imageToMediaWiki :: PandocMonad m => Attr -> MediaWikiWriter m Text imageToMediaWiki attr = do   opts <- gets stOptions   let (_, cls, _) = attr       toPx = fmap (showInPixel opts) . checkPct       checkPct (Just (Percent _)) = Nothing       checkPct maybeDim           = maybeDim-      go (Just w) Nothing  = w ++ "px"-      go (Just w) (Just h) = w ++ "x" ++ h ++ "px"-      go Nothing  (Just h) = "x" ++ h ++ "px"+      go (Just w) Nothing  = w <> "px"+      go (Just w) (Just h) = w <> "x" <> h <> "px"+      go Nothing  (Just h) = "x" <> h <> "px"       go Nothing  Nothing  = ""       dims = go (toPx $ dimension Width attr) (toPx $ dimension Height attr)       classes = if null cls                    then ""-                   else "class=" ++ unwords cls-  return $ intercalate "|" $ filter (not . null) [dims, classes]+                   else "class=" <> T.unwords cls+  return $ T.intercalate "|" $ filter (not . T.null) [dims, classes]  -- | Convert list of Pandoc block elements to MediaWiki. blockListToMediaWiki :: PandocMonad m                      => [Block]       -- ^ List of block elements-                     -> MediaWikiWriter m String+                     -> MediaWikiWriter m Text blockListToMediaWiki blocks =   fmap vcat $ mapM blockToMediaWiki blocks  -- | Convert list of Pandoc inline elements to MediaWiki.-inlineListToMediaWiki :: PandocMonad m => [Inline] -> MediaWikiWriter m String+inlineListToMediaWiki :: PandocMonad m => [Inline] -> MediaWikiWriter m Text inlineListToMediaWiki lst =-  fmap concat $ mapM inlineToMediaWiki lst+  fmap T.concat $ mapM inlineToMediaWiki lst  -- | Convert Pandoc inline element to MediaWiki.-inlineToMediaWiki :: PandocMonad m => Inline -> MediaWikiWriter m String+inlineToMediaWiki :: PandocMonad m => Inline -> MediaWikiWriter m Text  inlineToMediaWiki (Span attrs ils) = do   contents <- inlineListToMediaWiki ils-  return $ render Nothing (tagWithAttrs "span" attrs) ++ contents ++ "</span>"+  return $ render Nothing (tagWithAttrs "span" attrs) <> contents <> "</span>"  inlineToMediaWiki (Emph lst) = do   contents <- inlineListToMediaWiki lst-  return $ "''" ++ contents ++ "''"+  return $ "''" <> contents <> "''"  inlineToMediaWiki (Strong lst) = do   contents <- inlineListToMediaWiki lst-  return $ "'''" ++ contents ++ "'''"+  return $ "'''" <> contents <> "'''"  inlineToMediaWiki (Strikeout lst) = do   contents <- inlineListToMediaWiki lst-  return $ "<s>" ++ contents ++ "</s>"+  return $ "<s>" <> contents <> "</s>"  inlineToMediaWiki (Superscript lst) = do   contents <- inlineListToMediaWiki lst-  return $ "<sup>" ++ contents ++ "</sup>"+  return $ "<sup>" <> contents <> "</sup>"  inlineToMediaWiki (Subscript lst) = do   contents <- inlineListToMediaWiki lst-  return $ "<sub>" ++ contents ++ "</sub>"+  return $ "<sub>" <> contents <> "</sub>"  inlineToMediaWiki (SmallCaps lst) = inlineListToMediaWiki lst  inlineToMediaWiki (Quoted SingleQuote lst) = do   contents <- inlineListToMediaWiki lst-  return $ "\8216" ++ contents ++ "\8217"+  return $ "\8216" <> contents <> "\8217"  inlineToMediaWiki (Quoted DoubleQuote lst) = do   contents <- inlineListToMediaWiki lst-  return $ "\8220" ++ contents ++ "\8221"+  return $ "\8220" <> contents <> "\8221"  inlineToMediaWiki (Cite _  lst) = inlineListToMediaWiki lst  inlineToMediaWiki (Code _ str) =-  return $ "<code>" ++ escapeString str ++ "</code>"+  return $ "<code>" <> escapeText str <> "</code>" -inlineToMediaWiki (Str str) = return $ escapeString str+inlineToMediaWiki (Str str) = return $ escapeText str  inlineToMediaWiki (Math mt str) = return $-  "<math display=\"" ++-  (if mt == DisplayMath then "block" else "inline") ++-  "\">" ++ str ++ "</math>"+  "<math display=\"" <>+  (if mt == DisplayMath then "block" else "inline") <>+  "\">" <> str <> "</math>"   -- note:  str should NOT be escaped  inlineToMediaWiki il@(RawInline f str)@@ -419,35 +423,34 @@   case txt of      [Str s] | isURI src && escapeURI s == src -> return src      _  -> return $ if isURI src-              then "[" ++ src ++ " " ++ label ++ "]"-              else "[[" ++ src' ++ "|" ++ label ++ "]]"-                     where src' = case src of-                                     '/':xs -> xs  -- with leading / it's a-                                     _      -> src -- link to a help page+              then "[" <> src <> " " <> label <> "]"+              else "[[" <> src' <> "|" <> label <> "]]"+                     -- with leading / it's a link to a help page+                     where src' = fromMaybe src $ T.stripPrefix "/" src  inlineToMediaWiki (Image attr alt (source, tit)) = do   img  <- imageToMediaWiki attr   alt' <- inlineListToMediaWiki alt-  let txt = if null alt'-               then if null tit+  let txt = if T.null alt'+               then if T.null tit                        then ""                        else tit                else alt'-  return $ "[[" ++-           intercalate "|"-           (filter (not . null)-            [ "File:" ++ source+  return $ "[[" <>+           T.intercalate "|"+           (filter (not . T.null)+            [ "File:" <> source             , img             , txt-            ]) ++ "]]"+            ]) <> "]]"  inlineToMediaWiki (Note contents) = do   contents' <- blockListToMediaWiki contents   modify (\s -> s { stNotes = True })-  return $ "<ref>" ++ stripTrailingNewlines contents' ++ "</ref>"+  return $ "<ref>" <> stripTrailingNewlines contents' <> "</ref>"   -- note - does not work for notes with multiple blocks -highlightingLangs :: Set.Set String+highlightingLangs :: Set.Set Text highlightingLangs = Set.fromList [   "abap",   "abl",
src/Text/Pandoc/Writers/Ms.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.Ms    Copyright   : Copyright (C) 2007-2019 John MacFarlane@@ -21,7 +23,7 @@ module Text.Pandoc.Writers.Ms ( writeMs ) where import Prelude import Control.Monad.State.Strict-import Data.Char (isLower, isUpper, toUpper, ord)+import Data.Char (isLower, isUpper, ord) import Data.List (intercalate, intersperse) import qualified Data.Map as Map import Data.Maybe (catMaybes, fromMaybe)@@ -37,9 +39,9 @@ import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared import Text.Pandoc.Writers.Roff@@ -57,14 +59,11 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  metadata <- metaToJSON opts-              (fmap render' . blockListToMs opts)-              (fmap render' . inlineListToMs' opts)+  metadata <- metaToContext opts+              (blockListToMs opts)+              (fmap chomp . inlineListToMs' opts)               meta-  body <- blockListToMs opts blocks-  let main = render' body+  main <- blockListToMs opts blocks   hasInlineMath <- gets stHasInlineMath   let titleMeta = (escapeStr opts . stringify) $ docTitle meta   let authorsMeta = map (escapeStr opts . stringify) $ docAuthors meta@@ -72,7 +71,7 @@   let highlightingMacros = if hasHighlighting                               then case writerHighlightStyle opts of                                         Nothing  -> mempty-                                        Just sty -> render' $ styleToMs sty+                                        Just sty -> styleToMs sty                               else mempty    let context = defField "body" main@@ -81,28 +80,30 @@               $ defField "pandoc-version" pandocVersion               $ defField "toc" (writerTableOfContents opts)               $ defField "title-meta" titleMeta-              $ defField "author-meta" (intercalate "; " authorsMeta)+              $ defField "author-meta" (T.intercalate "; " authorsMeta)               $ defField "highlighting-macros" highlightingMacros metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context -escapeStr :: WriterOptions -> String -> String+escapeStr :: WriterOptions -> Text -> Text escapeStr opts =   escapeString (if writerPreferAscii opts then AsciiOnly else AllowUTF8) -escapeUri :: String -> String-escapeUri = escapeURIString (\c -> c /= '@' && isAllowedInURI c)+escapeUri :: Text -> Text+escapeUri = T.pack . escapeURIString (\c -> c /= '@' && isAllowedInURI c) . T.unpack -toSmallCaps :: WriterOptions -> String -> String-toSmallCaps _ [] = []-toSmallCaps opts (c:cs)-  | isLower c = let (lowers,rest) = span isLower (c:cs)-                in  "\\s-2" ++ escapeStr opts (map toUpper lowers) ++-                    "\\s0" ++ toSmallCaps opts rest-  | isUpper c = let (uppers,rest) = span isUpper (c:cs)-                in  escapeStr opts uppers ++ toSmallCaps opts rest-  | otherwise = escapeStr opts [c] ++ toSmallCaps opts cs+toSmallCaps :: WriterOptions -> Text -> Text+toSmallCaps opts s = case T.uncons s of+  Nothing -> ""+  Just (c, cs)+    | isLower c -> let (lowers,rest) = T.span isLower s+                   in  "\\s-2" <> escapeStr opts (T.toUpper lowers) <>+                       "\\s0" <> toSmallCaps opts rest+    | isUpper c -> let (uppers,rest) = T.span isUpper s+                   in  escapeStr opts uppers <> toSmallCaps opts rest+    | otherwise -> escapeStr opts (T.singleton c) <> toSmallCaps opts cs  -- We split inline lists into sentences, and print one sentence per -- line.  roff treats the line-ending period differently.@@ -111,14 +112,14 @@ blockToMs :: PandocMonad m           => WriterOptions -- ^ Options           -> Block         -- ^ Block element-          -> MS m Doc+          -> MS m (Doc Text) blockToMs _ Null = return empty blockToMs opts (Div (ident,_,_) bs) = do-  let anchor = if null ident+  let anchor = if T.null ident                   then empty                   else nowrap $-                         text ".pdfhref M "-                         <> doubleQuotes (text (toAscii ident))+                         literal ".pdfhref M "+                         <> doubleQuotes (literal (toAscii ident))   setFirstPara   res <- blockListToMs opts bs   setFirstPara@@ -126,38 +127,38 @@ blockToMs opts (Plain inlines) =   liftM vcat $ mapM (inlineListToMs' opts) $ splitSentences inlines blockToMs opts (Para [Image attr alt (src,_tit)])-  | let ext = takeExtension src in (ext == ".ps" || ext == ".eps") = do+  | let ext = takeExtension (T.unpack src) in (ext == ".ps" || ext == ".eps") = do   let (mbW,mbH) = (inPoints opts <$> dimension Width attr,                    inPoints opts <$> dimension Height attr)   let sizeAttrs = case (mbW, mbH) of                        (Just wp, Nothing) -> space <> doubleQuotes-                              (text (show (floor wp :: Int) ++ "p"))+                              (literal (tshow (floor wp :: Int) <> "p"))                        (Just wp, Just hp) -> space <> doubleQuotes-                              (text (show (floor wp :: Int) ++ "p")) <>+                              (literal (tshow (floor wp :: Int) <> "p")) <>                               space <>-                              doubleQuotes (text (show (floor hp :: Int)))+                              doubleQuotes (literal (tshow (floor hp :: Int)))                        _ -> empty   capt <- inlineListToMs' opts alt-  return $ nowrap (text ".PSPIC -C " <>-             doubleQuotes (text (escapeStr opts src)) <>+  return $ nowrap (literal ".PSPIC -C " <>+             doubleQuotes (literal (escapeStr opts src)) <>              sizeAttrs) $$-           text ".ce 1000" $$+           literal ".ce 1000" $$            capt $$-           text ".ce 0"+           literal ".ce 0" blockToMs opts (Para inlines) = do   firstPara <- gets stFirstPara   resetFirstPara   contents <- liftM vcat $ mapM (inlineListToMs' opts) $     splitSentences inlines-  return $ text (if firstPara then ".LP" else ".PP") $$ contents+  return $ literal (if firstPara then ".LP" else ".PP") $$ contents blockToMs _ b@(RawBlock f str)-  | f == Format "ms" = return $ text str+  | f == Format "ms" = return $ literal str   | otherwise        = do       report $ BlockNotRendered b       return empty blockToMs _ HorizontalRule = do   resetFirstPara-  return $ text ".HLINE"+  return $ literal ".HLINE" blockToMs opts (Header level (ident,classes,_) inlines) = do   setFirstPara   modify $ \st -> st{ stInHeader = True }@@ -167,33 +168,33 @@                               "unnumbered" `notElem` classes                              then (".NH", "\\*[SN]")                              else (".SH", "")-  let anchor = if null ident+  let anchor = if T.null ident                   then empty                   else nowrap $-                         text ".pdfhref M "-                         <> doubleQuotes (text (toAscii ident))-  let bookmark = text ".pdfhref O " <> text (show level ++ " ") <>-                      doubleQuotes (text $ secnum ++-                                      (if null secnum+                         literal ".pdfhref M "+                         <> doubleQuotes (literal (toAscii ident))+  let bookmark = literal ".pdfhref O " <> literal (tshow level <> " ") <>+                      doubleQuotes (literal $ secnum <>+                                      (if T.null secnum                                           then ""-                                          else "  ") +++                                          else "  ") <>                                       escapeStr opts (stringify inlines))-  let backlink = nowrap (text ".pdfhref L -D " <>-       doubleQuotes (text (toAscii ident)) <> space <> text "\\") <> cr <>-       text " -- "+  let backlink = nowrap (literal ".pdfhref L -D " <>+       doubleQuotes (literal (toAscii ident)) <> space <> literal "\\") <> cr <>+       literal " -- "   let tocEntry = if writerTableOfContents opts &&                      level <= writerTOCDepth opts-                    then text ".XS"+                    then literal ".XS"                          $$ backlink <> doubleQuotes (-                            nowrap (text (replicate level '\t') <>-                             (if null secnum+                            nowrap (literal (T.replicate level "\t") <>+                             (if T.null secnum                                  then empty-                                 else text secnum <> text "\\~\\~")+                                 else literal secnum <> literal "\\~\\~")                               <> contents))-                         $$ text ".XE"+                         $$ literal ".XE"                     else empty   modify $ \st -> st{ stFirstPara = True }-  return $ (text heading <> space <> text (show level)) $$+  return $ (literal heading <> space <> literal (tshow level)) $$            contents $$            bookmark $$            anchor $$@@ -202,20 +203,20 @@   hlCode <- highlightCode opts attr str   setFirstPara   return $-    text ".IP" $$-    text ".nf" $$-    text "\\f[C]" $$+    literal ".IP" $$+    literal ".nf" $$+    literal "\\f[C]" $$     hlCode $$-    text "\\f[]" $$-    text ".fi"+    literal "\\f[]" $$+    literal ".fi" blockToMs opts (LineBlock ls) = do-  resetFirstPara+  setFirstPara  -- use .LP, see #5588   blockToMs opts $ Para $ intercalate [LineBreak] ls blockToMs opts (BlockQuote blocks) = do   setFirstPara   contents <- blockListToMs opts blocks   setFirstPara-  return $ text ".RS" $$ contents $$ text ".RE"+  return $ literal ".RS" $$ contents $$ literal ".RE" blockToMs opts (Table caption alignments widths headers rows) =   let aligncode AlignLeft    = "l"       aligncode AlignRight   = "r"@@ -225,15 +226,15 @@   caption' <- inlineListToMs' opts caption   let iwidths = if all (== 0) widths                    then repeat ""-                   else map (printf "w(%0.1fn)" . (70 *)) widths+                   else map (T.pack . printf "w(%0.1fn)" . (70 *)) widths   -- 78n default width - 8n indent = 70n-  let coldescriptions = text $ unwords-                        (zipWith (\align width -> aligncode align ++ width)-                        alignments iwidths) ++ "."+  let coldescriptions = literal $ T.unwords+                        (zipWith (\align width -> aligncode align <> width)+                        alignments iwidths) <> "."   colheadings <- mapM (blockListToMs opts) headers-  let makeRow cols = text "T{" $$-                     vcat (intersperse (text "T}\tT{") cols) $$-                     text "T}"+  let makeRow cols = literal "T{" $$+                     vcat (intersperse (literal "T}\tT{") cols) $$+                     literal "T}"   let colheadings' = if all null headers                         then empty                         else makeRow colheadings $$ char '_'@@ -241,9 +242,9 @@                          cols <- mapM (blockListToMs opts) row                          return $ makeRow cols) rows   setFirstPara-  return $ text ".PP" $$ caption' $$-           text ".TS" $$ text "delim(@@) tab(\t);" $$ coldescriptions $$-           colheadings' $$ vcat body $$ text ".TE"+  return $ literal ".PP" $$ caption' $$+           literal ".TS" $$ literal "delim(@@) tab(\t);" $$ coldescriptions $$+           colheadings' $$ vcat body $$ literal ".TE"  blockToMs opts (BulletList items) = do   contents <- mapM (bulletListItemToMs opts) items@@ -252,7 +253,7 @@ blockToMs opts (OrderedList attribs items) = do   let markers = take (length items) $ orderedListMarkers attribs   let indent = 2 +-                     maximum (map length markers)+                     maximum (map T.length markers)   contents <- mapM (\(num, item) -> orderedListItemToMs opts num indent item) $               zip markers items   setFirstPara@@ -263,51 +264,52 @@   return (vcat contents)  -- | Convert bullet list item (list of blocks) to ms.-bulletListItemToMs :: PandocMonad m => WriterOptions -> [Block] -> MS m Doc+bulletListItemToMs :: PandocMonad m => WriterOptions -> [Block] -> MS m (Doc Text) bulletListItemToMs _ [] = return empty bulletListItemToMs opts (Para first:rest) =   bulletListItemToMs opts (Plain first:rest) bulletListItemToMs opts (Plain first:rest) = do   first' <- blockToMs opts (Plain first)   rest' <- blockListToMs opts rest-  let first'' = text ".IP \\[bu] 3" $$ first'+  let first'' = literal ".IP \\[bu] 3" $$ first'   let rest''  = if null rest                    then empty-                   else text ".RS 3" $$ rest' $$ text ".RE"+                   else literal ".RS 3" $$ rest' $$ literal ".RE"   return (first'' $$ rest'') bulletListItemToMs opts (first:rest) = do   first' <- blockToMs opts first   rest' <- blockListToMs opts rest-  return $ text "\\[bu] .RS 3" $$ first' $$ rest' $$ text ".RE"+  return $ literal "\\[bu] .RS 3" $$ first' $$ rest' $$ literal ".RE"  -- | Convert ordered list item (a list of blocks) to ms. orderedListItemToMs :: PandocMonad m                     => WriterOptions -- ^ options-                    -> String   -- ^ order marker for list item+                    -> Text   -- ^ order marker for list item                     -> Int      -- ^ number of spaces to indent                     -> [Block]  -- ^ list item (list of blocks)-                    -> MS m Doc+                    -> MS m (Doc Text) orderedListItemToMs _ _ _ [] = return empty orderedListItemToMs opts num indent (Para first:rest) =   orderedListItemToMs opts num indent (Plain first:rest) orderedListItemToMs opts num indent (first:rest) = do   first' <- blockToMs opts first   rest' <- blockListToMs opts rest-  let num' = printf ("%" ++ show (indent - 1) ++ "s") num-  let first'' = text (".IP \"" ++ num' ++ "\" " ++ show indent) $$ first'+  let num' = T.pack $ printf ("%" <> show (indent - 1) <> "s") num+  let first'' = literal (".IP \"" <> num' <> "\" " <> tshow indent) $$ first'   let rest''  = if null rest                    then empty-                   else text ".RS " <> text (show indent) $$-                         rest' $$ text ".RE"+                   else literal ".RS " <> literal (tshow indent) $$+                         rest' $$ literal ".RE"   return $ first'' $$ rest''  -- | Convert definition list item (label, list of blocks) to ms. definitionListItemToMs :: PandocMonad m                        => WriterOptions                        -> ([Inline],[[Block]])-                       -> MS m Doc+                       -> MS m (Doc Text) definitionListItemToMs opts (label, defs) = do-  labelText <- inlineListToMs' opts $ map breakToSpace label+  labelText <- withFontFeature 'B' $+                 inlineListToMs' opts $ map breakToSpace label   contents <- if null defs                  then return empty                  else liftM vcat $ forM defs $ \blocks -> do@@ -319,33 +321,33 @@                         rest' <- liftM vcat $                                   mapM (\item -> blockToMs opts item) rest                         first' <- blockToMs opts first-                        return $ first' $$ text ".RS" $$ rest' $$ text ".RE"-  return $ nowrap (text ".IP " <> doubleQuotes labelText) $$ contents+                        return $ first' $$ literal ".RS" $$ rest' $$ literal ".RE"+  return $ nowrap (literal ".IP " <> doubleQuotes labelText) $$ contents  -- | Convert list of Pandoc block elements to ms. blockListToMs :: PandocMonad m               => WriterOptions -- ^ Options               -> [Block]       -- ^ List of block elements-              -> MS m Doc+              -> MS m (Doc Text) blockListToMs opts blocks =   vcat <$> mapM (blockToMs opts) blocks  -- | Convert list of Pandoc inline elements to ms.-inlineListToMs :: PandocMonad m => WriterOptions -> [Inline] -> MS m Doc+inlineListToMs :: PandocMonad m => WriterOptions -> [Inline] -> MS m (Doc Text) -- if list starts with ., insert a zero-width character \& so it -- won't be interpreted as markup if it falls at the beginning of a line. inlineListToMs opts lst = hcat <$> mapM (inlineToMs opts) lst  -- This version to be used when there is no further inline content; -- forces a note at the end.-inlineListToMs' :: PandocMonad m => WriterOptions -> [Inline] -> MS m Doc+inlineListToMs' :: PandocMonad m => WriterOptions -> [Inline] -> MS m (Doc Text) inlineListToMs' opts lst = do   x <- hcat <$> mapM (inlineToMs opts) lst   y <- handleNotes opts empty   return $ x <> y  -- | Convert Pandoc inline element to ms.-inlineToMs :: PandocMonad m => WriterOptions -> Inline -> MS m Doc+inlineToMs :: PandocMonad m => WriterOptions -> Inline -> MS m (Doc Text) inlineToMs opts (Span _ ils) = inlineListToMs opts ils inlineToMs opts (Emph lst) =   withFontFeature 'I' (inlineListToMs opts lst)@@ -355,13 +357,13 @@   contents <- inlineListToMs opts lst   -- we use grey color instead of strikeout, which seems quite   -- hard to do in roff for arbitrary bits of text-  return $ text "\\m[strikecolor]" <> contents <> text "\\m[]"+  return $ literal "\\m[strikecolor]" <> contents <> literal "\\m[]" inlineToMs opts (Superscript lst) = do   contents <- inlineListToMs opts lst-  return $ text "\\*{" <> contents <> text "\\*}"+  return $ literal "\\*{" <> contents <> literal "\\*}" inlineToMs opts (Subscript lst) = do   contents <- inlineListToMs opts lst-  return $ text "\\*<" <> contents <> text "\\*>"+  return $ literal "\\*<" <> contents <> literal "\\*>" inlineToMs opts (SmallCaps lst) = do   -- see https://lists.gnu.org/archive/html/groff/2015-01/msg00016.html   modify $ \st -> st{ stSmallCaps = not (stSmallCaps st) }@@ -373,40 +375,40 @@   return $ char '`' <> contents <> char '\'' inlineToMs opts (Quoted DoubleQuote lst) = do   contents <- inlineListToMs opts lst-  return $ text "\\[lq]" <> contents <> text "\\[rq]"+  return $ literal "\\[lq]" <> contents <> literal "\\[rq]" inlineToMs opts (Cite _ lst) =   inlineListToMs opts lst inlineToMs opts (Code attr str) = do   hlCode <- highlightCode opts attr str   withFontFeature 'C' (return hlCode) inlineToMs opts (Str str) = do-  let shim = case str of-                  '.':_ -> afterBreak "\\&"-                  _     -> empty+  let shim = case T.uncons str of+                  Just ('.',_) -> afterBreak "\\&"+                  _            -> empty   smallcaps <- gets stSmallCaps   if smallcaps-     then return $ shim <> text (toSmallCaps opts str)-     else return $ shim <> text (escapeStr opts str)+     then return $ shim <> literal (toSmallCaps opts str)+     else return $ shim <> literal (escapeStr opts str) inlineToMs opts (Math InlineMath str) = do   modify $ \st -> st{ stHasInlineMath = True }   res <- convertMath writeEqn InlineMath str   case res of        Left il -> inlineToMs opts il-       Right r -> return $ text "@" <> text r <> text "@"+       Right r -> return $ literal "@" <> literal r <> literal "@" inlineToMs opts (Math DisplayMath str) = do   res <- convertMath writeEqn InlineMath str   case res of        Left il -> do          contents <- inlineToMs opts il-         return $ cr <> text ".RS" $$ contents $$ text ".RE"+         return $ cr <> literal ".RS" $$ contents $$ literal ".RE"        Right r -> return $-            cr <> text ".EQ" $$ text r $$ text ".EN" <> cr+            cr <> literal ".EQ" $$ literal r $$ literal ".EN" <> cr inlineToMs _ il@(RawInline f str)-  | f == Format "ms" = return $ text str+  | f == Format "ms" = return $ literal str   | otherwise        = do     report $ InlineNotRendered il     return empty-inlineToMs _ LineBreak = return $ cr <> text ".br" <> cr+inlineToMs _ LineBreak = return $ cr <> literal ".br" <> cr inlineToMs opts SoftBreak =   handleNotes opts $     case writerWrapText opts of@@ -414,29 +416,29 @@          WrapNone     -> space          WrapPreserve -> cr inlineToMs opts Space = handleNotes opts space-inlineToMs opts (Link _ txt ('#':ident, _)) = do+inlineToMs opts (Link _ txt (T.uncons -> Just ('#',ident), _)) = do   -- internal link   contents <- inlineListToMs' opts $ map breakToSpace txt-  return $ text "\\c" <> cr <> nowrap (text ".pdfhref L -D " <>-       doubleQuotes (text (toAscii ident)) <> text " -A " <>-       doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>-       text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"+  return $ literal "\\c" <> cr <> nowrap (literal ".pdfhref L -D " <>+       doubleQuotes (literal (toAscii ident)) <> literal " -A " <>+       doubleQuotes (literal "\\c") <> space <> literal "\\") <> cr <>+       literal " -- " <> doubleQuotes (nowrap contents) <> cr <> literal "\\&" inlineToMs opts (Link _ txt (src, _)) = do   -- external link   contents <- inlineListToMs' opts $ map breakToSpace txt-  return $ text "\\c" <> cr <> nowrap (text ".pdfhref W -D " <>-       doubleQuotes (text (escapeUri src)) <> text " -A " <>-       doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>-       text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"+  return $ literal "\\c" <> cr <> nowrap (literal ".pdfhref W -D " <>+       doubleQuotes (literal (escapeUri src)) <> literal " -A " <>+       doubleQuotes (literal "\\c") <> space <> literal "\\") <> cr <>+       literal " -- " <> doubleQuotes (nowrap contents) <> cr <> literal "\\&" inlineToMs opts (Image _ alternate (_, _)) =-  return $ char '[' <> text "IMAGE: " <>-           text (escapeStr opts (stringify alternate))+  return $ char '[' <> literal "IMAGE: " <>+           literal (escapeStr opts (stringify alternate))              <> char ']' inlineToMs _ (Note contents) = do   modify $ \st -> st{ stNotes = contents : stNotes st }-  return $ text "\\**"+  return $ literal "\\**" -handleNotes :: PandocMonad m => WriterOptions -> Doc -> MS m Doc+handleNotes :: PandocMonad m => WriterOptions -> Doc Text -> MS m (Doc Text) handleNotes opts fallback = do   notes <- gets stNotes   if null notes@@ -445,7 +447,7 @@        modify $ \st -> st{ stNotes = [] }        vcat <$> mapM (handleNote opts) notes -handleNote :: PandocMonad m => WriterOptions -> Note -> MS m Doc+handleNote :: PandocMonad m => WriterOptions -> Note -> MS m (Doc Text) handleNote opts bs = do   -- don't start with Paragraph or we'll get a spurious blank   -- line after the note ref:@@ -453,7 +455,7 @@                  (Para ils : rest) -> Plain ils : rest                  _                 -> bs   contents <- blockListToMs opts bs'-  return $ cr <> text ".FS" $$ contents $$ text ".FE" <> cr+  return $ cr <> literal ".FS" $$ contents $$ literal ".FE" <> cr  setFirstPara :: PandocMonad m => MS m () setFirstPara = modify $ \st -> st{ stFirstPara = True }@@ -468,39 +470,39 @@  -- Highlighting -styleToMs :: Style -> Doc-styleToMs sty = vcat $ colordefs ++ map (toMacro sty) alltoktypes+styleToMs :: Style -> Doc Text+styleToMs sty = vcat $ colordefs <> map (toMacro sty) alltoktypes   where alltoktypes = enumFromTo KeywordTok NormalTok         colordefs = map toColorDef allcolors-        toColorDef c = text (".defcolor " ++-            hexColor c ++ " rgb #" ++ hexColor c)+        toColorDef c = literal (".defcolor " <>+            hexColor c <> " rgb #" <> hexColor c)         allcolors = catMaybes $ ordNub $           [defaultColor sty, backgroundColor sty,-           lineNumberColor sty, lineNumberBackgroundColor sty] +++           lineNumberColor sty, lineNumberBackgroundColor sty] <>            concatMap (colorsForToken. snd) (Map.toList (tokenStyles sty))         colorsForToken ts = [tokenColor ts, tokenBackground ts] -hexColor :: Color -> String-hexColor (RGB r g b) = printf "%02x%02x%02x" r g b+hexColor :: Color -> Text+hexColor (RGB r g b) = T.pack $ printf "%02x%02x%02x" r g b -toMacro :: Style -> TokenType -> Doc+toMacro :: Style -> TokenType -> Doc Text toMacro sty toktype =-  nowrap (text ".ds " <> text (show toktype) <> text " " <>+  nowrap (literal ".ds " <> literal (tshow toktype) <> literal " " <>             setbg <> setcolor <> setfont <>-            text "\\\\$1" <>+            literal "\\\\$1" <>             resetfont <> resetcolor <> resetbg)   where setcolor = maybe empty fgcol tokCol-        resetcolor = maybe empty (const $ text "\\\\m[]") tokCol+        resetcolor = maybe empty (const $ literal "\\\\m[]") tokCol         setbg = empty -- maybe empty bgcol tokBg         resetbg = empty -- maybe empty (const $ text "\\\\M[]") tokBg-        fgcol c = text $ "\\\\m[" ++ hexColor c ++ "]"-        -- bgcol c = text $ "\\\\M[" ++ hexColor c ++ "]"+        fgcol c = literal $ "\\\\m[" <> hexColor c <> "]"+        -- bgcol c = literal $ "\\\\M[" <> hexColor c <> "]"         setfont = if tokBold || tokItalic-                     then text $ "\\\\f[C" ++ ['B' | tokBold] ++-                          ['I' | tokItalic] ++ "]"+                     then literal $ T.pack $ "\\\\f[C" <> ['B' | tokBold] <>+                          ['I' | tokItalic] <> "]"                      else empty         resetfont = if tokBold || tokItalic-                       then text "\\\\f[C]"+                       then literal "\\\\f[C]"                        else empty         tokSty = Map.lookup toktype (tokenStyles sty)         tokCol = (tokSty >>= tokenColor) `mplus` defaultColor sty@@ -511,28 +513,28 @@         -- lnColor = lineNumberColor sty         -- lnBkgColor = lineNumberBackgroundColor sty -msFormatter :: WriterOptions -> FormatOptions -> [SourceLine] -> Doc+msFormatter :: WriterOptions -> FormatOptions -> [SourceLine] -> Doc Text msFormatter opts _fmtopts =   vcat . map fmtLine   where fmtLine = hcat . map fmtToken-        fmtToken (toktype, tok) = text "\\*" <>-           brackets (text (show toktype) <> text " \""-             <> text (escapeStr opts (T.unpack tok)) <> text "\"")+        fmtToken (toktype, tok) = literal "\\*" <>+           brackets (literal (tshow toktype) <> literal " \""+             <> literal (escapeStr opts tok) <> literal "\"") -highlightCode :: PandocMonad m => WriterOptions -> Attr -> String -> MS m Doc+highlightCode :: PandocMonad m => WriterOptions -> Attr -> Text -> MS m (Doc Text) highlightCode opts attr str =   case highlight (writerSyntaxMap opts) (msFormatter opts) attr str of          Left msg -> do-           unless (null msg) $ report $ CouldNotHighlight msg-           return $ text (escapeStr opts str)+           unless (T.null msg) $ report $ CouldNotHighlight msg+           return $ literal (escapeStr opts str)          Right h -> do            modify (\st -> st{ stHighlighting = True })            return h  -- This is used for PDF anchors.-toAscii :: String -> String-toAscii = concatMap+toAscii :: Text -> Text+toAscii = T.concatMap   (\c -> case toAsciiChar c of-              Nothing -> '_':'u':show (ord c) ++ "_"-              Just '/' -> '_':'u':show (ord c) ++ "_" -- see #4515-              Just c' -> [c'])+              Nothing -> "_u" <> tshow (ord c) <> "_"+              Just '/' -> "_u" <> tshow (ord c) <> "_" -- see #4515+              Just c' -> T.singleton c')
src/Text/Pandoc/Writers/Muse.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.Muse    Copyright   : Copyright (C) 2017-2019 Alexander Krotov@@ -26,21 +27,24 @@ -} module Text.Pandoc.Writers.Muse (writeMuse) where import Prelude+import Control.Monad.Except (throwError) import Control.Monad.Reader import Control.Monad.State.Strict import Data.Char (isAlphaNum, isAsciiLower, isAsciiUpper, isDigit, isSpace) import Data.Default-import Data.List (intersperse, isInfixOf, transpose)+import Data.List (intersperse, transpose) import qualified Data.Set as Set+import qualified Data.Text as T import Data.Text (Text) import System.FilePath (takeExtension) import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition+import Text.Pandoc.Error import Text.Pandoc.ImageSize import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared @@ -63,7 +67,7 @@ data WriterState =   WriterState { stNotes   :: Notes               , stNoteNum :: Int-              , stIds     :: Set.Set String+              , stIds     :: Set.Set Text               , stUseTags :: Bool -- ^ Use tags for emphasis, for example because previous character is a letter               } @@ -104,26 +108,25 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render Nothing-  metadata <- metaToJSON opts-               (fmap render' . blockListToMuse)-               (fmap render' . inlineListToMuse)+  metadata <- metaToContext opts+               blockListToMuse+               (fmap chomp . inlineListToMuse)                meta   body <- blockListToMuse blocks   notes <- currentNotesToMuse-  let main = render colwidth $ body $+$ notes+  let main = body $+$ notes   let context = defField "body" main metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Helper function for flatBlockListToMuse -- | Render all blocks and insert blank lines between the first two catWithBlankLines :: PandocMonad m                   => [Block]       -- ^ List of block elements                   -> Int           -- ^ Number of blank lines-                  -> Muse m Doc+                  -> Muse m (Doc Text) catWithBlankLines (b : bs) n = do   b' <- blockToMuseWithNotes b   bs' <- flatBlockListToMuse bs@@ -134,7 +137,7 @@ -- | without setting envTopLevel. flatBlockListToMuse :: PandocMonad m                 => [Block]       -- ^ List of block elements-                -> Muse m Doc+                -> Muse m (Doc Text) flatBlockListToMuse bs@(BulletList _ : BulletList _ : _) = catWithBlankLines bs 2 flatBlockListToMuse bs@(OrderedList (_, style1, _) _ : OrderedList (_, style2, _) _ : _) =   catWithBlankLines bs (if style1' == style2' then 2 else 0)@@ -151,7 +154,7 @@             => [Inline]             -> [TableCell]             -> [[TableCell]]-            -> Muse m Doc+            -> Muse m (Doc Text) simpleTable caption headers rows = do   topLevel <- asks envTopLevel   caption' <- inlineListToMuse caption@@ -159,7 +162,7 @@   rows' <- mapM (mapM blockListToMuse) rows   let widthsInChars = maximum . map offset <$> transpose (headers' : rows')   let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks-        where sep' = lblock (length sep) $ text sep+        where sep' = lblock (T.length sep) $ literal sep   let makeRow sep = hpipeBlocks sep . zipWith lblock widthsInChars   let head' = makeRow " || " headers'   rows'' <- mapM (\row -> makeRow rowSeparator <$> mapM blockListToMuse row) rows@@ -174,7 +177,7 @@ -- | Convert list of Pandoc block elements to Muse. blockListToMuse :: PandocMonad m                 => [Block]       -- ^ List of block elements-                -> Muse m Doc+                -> Muse m (Doc Text) blockListToMuse =   local (\env -> env { envTopLevel = not (envInsideBlock env)                      , envInsideBlock = True@@ -183,19 +186,19 @@ -- | Convert Pandoc block element to Muse. blockToMuse :: PandocMonad m             => Block         -- ^ Block element-            -> Muse m Doc+            -> Muse m (Doc Text) blockToMuse (Plain inlines) = inlineListToMuse' inlines blockToMuse (Para inlines) = do   contents <- inlineListToMuse' inlines   return $ contents <> blankline blockToMuse (LineBlock lns) = do   lns' <- local (\env -> env { envOneLine = True }) $ mapM inlineListToMuse lns-  return $ nowrap $ vcat (map (text "> " <>) lns') <> blankline+  return $ nowrap $ vcat (map (literal "> " <>) lns') <> blankline blockToMuse (CodeBlock (_,_,_) str) =-  return $ "<example>" $$ text str $$ "</example>" $$ blankline+  return $ "<example>" $$ literal str $$ "</example>" $$ blankline blockToMuse (RawBlock (Format format) str) =-  return $ blankline $$ "<literal style=\"" <> text format <> "\">" $$-           text str $$ "</literal>" $$ blankline+  return $ blankline $$ "<literal style=\"" <> literal format <> "\">" $$+           literal str $$ "</literal>" $$ blankline blockToMuse (BlockQuote blocks) = do   contents <- flatBlockListToMuse blocks   return $ blankline@@ -210,10 +213,10 @@   topLevel <- asks envTopLevel   return $ (if topLevel then nest 1 else id) (vcat contents) $$ blankline   where orderedListItemToMuse :: PandocMonad m-                              => String   -- ^ marker for list item+                              => Text     -- ^ marker for list item                               -> [Block]  -- ^ list item (list of blocks)-                              -> Muse m Doc-        orderedListItemToMuse marker item = hang (length marker + 1) (text marker <> space)+                              -> Muse m (Doc Text)+        orderedListItemToMuse marker item = hang (T.length marker + 1) (literal marker <> space)           <$> blockListToMuse item blockToMuse (BulletList items) = do   contents <- mapM bulletListItemToMuse items@@ -221,7 +224,7 @@   return $ (if topLevel then nest 1 else id) (vcat contents) $$ blankline   where bulletListItemToMuse :: PandocMonad m                              => [Block]-                             -> Muse m Doc+                             -> Muse m (Doc Text)         bulletListItemToMuse item = do           modify $ \st -> st { stUseTags = False }           hang 2 "- " <$> blockListToMuse item@@ -231,16 +234,17 @@   return $ (if topLevel then nest 1 else id) (vcat contents) $$ blankline   where definitionListItemToMuse :: PandocMonad m                                  => ([Inline], [[Block]])-                                 -> Muse m Doc+                                 -> Muse m (Doc Text)         definitionListItemToMuse (label, defs) = do           modify $ \st -> st { stUseTags = False }           label' <- local (\env -> env { envOneLine = True, envAfterSpace = True }) $ inlineListToMuse' label-          let ind = offset' label' -- using Text.Pandoc.Pretty.offset results in round trip failures+          let ind = offset' label' -- using Text.DocLayout.offset results in round trip failures           hang ind (nowrap label') . vcat <$> mapM descriptionToMuse defs-          where offset' d = maximum (0: map length (lines $ render Nothing d))+          where offset' d = maximum (0: map T.length+                                         (T.lines $ render Nothing d))         descriptionToMuse :: PandocMonad m                           => [Block]-                          -> Muse m Doc+                          -> Muse m (Doc Text)         descriptionToMuse desc = hang 4 " :: " <$> blockListToMuse desc blockToMuse (Header level (ident,_,_) inlines) = do   opts <- asks envOptions@@ -250,10 +254,10 @@   let autoId = uniqueIdent (writerExtensions opts) inlines ids   modify $ \st -> st{ stIds = Set.insert autoId ids } -  let attr' = if null ident || (isEnabled Ext_auto_identifiers opts && ident == autoId)+  let attr' = if T.null ident || (isEnabled Ext_auto_identifiers opts && ident == autoId)                  then empty-                 else "#" <> text ident <> cr-  let header' = if topLevel then text (replicate level '*') <> space else mempty+                 else "#" <> literal ident <> cr+  let header' = if topLevel then literal (T.replicate level "*") <> space else mempty   return $ blankline <> attr' $$ nowrap (header' <> contents) <> blankline -- https://www.gnu.org/software/emacs-muse/manual/muse.html#Horizontal-Rules-and-Anchors blockToMuse HorizontalRule = return $ blankline $$ "----" $$ blankline@@ -273,7 +277,7 @@  -- | Return Muse representation of notes collected so far. currentNotesToMuse :: PandocMonad m-                   => Muse m Doc+                   => Muse m (Doc Text) currentNotesToMuse = do   notes <- reverse <$> gets stNotes   modify $ \st -> st { stNotes = mempty }@@ -282,7 +286,7 @@ -- | Return Muse representation of notes. notesToMuse :: PandocMonad m             => Notes-            -> Muse m Doc+            -> Muse m (Doc Text) notesToMuse notes = do   n <- gets stNoteNum   modify $ \st -> st { stNoteNum = stNoteNum st + length notes }@@ -292,21 +296,21 @@ noteToMuse :: PandocMonad m            => Int            -> [Block]-           -> Muse m Doc+           -> Muse m (Doc Text) noteToMuse num note = do-  res <- hang (length marker) (text marker) <$>+  res <- hang (T.length marker) (literal marker) <$>     local (\env -> env { envInsideBlock = True                        , envInlineStart = True                        , envAfterSpace = True                        }) (blockListToMuse note)   return $ res <> blankline   where-    marker = "[" ++ show num ++ "] "+    marker = "[" <> tshow num <> "] "  -- | Return Muse representation of block and accumulated notes. blockToMuseWithNotes :: PandocMonad m                      => Block-                     -> Muse m Doc+                     -> Muse m (Doc Text) blockToMuseWithNotes blk = do   topLevel <- asks envTopLevel   opts <- asks envOptions@@ -327,30 +331,26 @@     else return b  -- | Escape special characters for Muse.-escapeString :: String -> String-escapeString s =-  "<verbatim>" ++-  substitute "</verbatim>" "<</verbatim><verbatim>/verbatim>" s +++escapeText :: Text -> Text+escapeText s =+  "<verbatim>" <>+  T.replace "</verbatim>" "<</verbatim><verbatim>/verbatim>" s <>   "</verbatim>"  -- | Replace newlines with spaces-replaceNewlines :: String -> String-replaceNewlines ('\n':xs) = ' ':replaceNewlines xs-replaceNewlines (x:xs)    = x:replaceNewlines xs-replaceNewlines []        = []+replaceNewlines :: Text -> Text+replaceNewlines = T.map $ \c ->+  if c == '\n' then ' ' else c -startsWithMarker :: (Char -> Bool) -> String -> Bool-startsWithMarker f (' ':xs) = startsWithMarker f xs-startsWithMarker f (x:xs) =-  f x && (startsWithMarker f xs || startsWithDot xs)+startsWithMarker :: (Char -> Bool) -> Text -> Bool+startsWithMarker f t = case T.uncons $ T.dropWhile f' t of+  Just ('.', xs) -> T.null xs || isSpace (T.head xs)+  _              -> False   where-    startsWithDot ['.']     = True-    startsWithDot ('.':c:_) = isSpace c-    startsWithDot _         = False-startsWithMarker _ [] = False+    f' c = c == ' ' || f c -containsNotes :: Char -> Char -> String -> Bool-containsNotes left right = p+containsNotes :: Char -> Char -> Text -> Bool+containsNotes left right = p . T.unpack -- This ought to be a parser   where p (left':xs)           | left' == left = q xs || p xs           | otherwise = p xs@@ -367,28 +367,29 @@         s []      = False  -- | Return True if string should be escaped with <verbatim> tags-shouldEscapeString :: PandocMonad m-                   => String+shouldEscapeText :: PandocMonad m+                   => Text                    -> Muse m Bool-shouldEscapeString s = do+shouldEscapeText s = do   insideLink <- asks envInsideLinkDescription-  return $ null s ||-           any (`elem` ("#*<=|" :: String)) s ||-           "::" `isInfixOf` s ||-           "~~" `isInfixOf` s ||-           "[[" `isInfixOf` s ||-           ("]" `isInfixOf` s && insideLink) ||+  return $ T.null s ||+           T.any (`elem` ("#*<=|" :: String)) s ||+           "::" `T.isInfixOf` s ||+           "~~" `T.isInfixOf` s ||+           "[[" `T.isInfixOf` s ||+           ">>>" `T.isInfixOf` s ||+           ("]" `T.isInfixOf` s && insideLink) ||            containsNotes '[' ']' s ||            containsNotes '{' '}' s  -- | Escape special characters for Muse if needed.-conditionalEscapeString :: PandocMonad m-                        => String-                        -> Muse m String-conditionalEscapeString s = do-  shouldEscape <- shouldEscapeString s+conditionalEscapeText :: PandocMonad m+                        => Text+                        -> Muse m Text+conditionalEscapeText s = do+  shouldEscape <- shouldEscapeText s   return $ if shouldEscape-             then escapeString s+             then escapeText s              else s  -- Expand Math and Cite before normalizing inline list@@ -412,7 +413,7 @@ removeKeyValues (Code (i, cls, _) xs) = Code (i, cls, []) xs -- Do not remove attributes from Link -- Do not remove attributes, such as "width", from Image-removeKeyValues (Span (i, cls, _) xs) = Span (i, cls, []) xs+-- Do not remove attributes, such as "dir", from Span removeKeyValues x                     = x  normalizeInlineList :: [Inline] -> [Inline]@@ -421,23 +422,23 @@ normalizeInlineList (x : Str "" : xs)   = normalizeInlineList (x:xs) normalizeInlineList (Str x1 : Str x2 : xs)-  = normalizeInlineList $ Str (x1 ++ x2) : xs+  = normalizeInlineList $ Str (x1 <> x2) : xs normalizeInlineList (Emph x1 : Emph x2 : ils)-  = normalizeInlineList $ Emph (x1 ++ x2) : ils+  = normalizeInlineList $ Emph (x1 <> x2) : ils normalizeInlineList (Strong x1 : Strong x2 : ils)-  = normalizeInlineList $ Strong (x1 ++ x2) : ils+  = normalizeInlineList $ Strong (x1 <> x2) : ils normalizeInlineList (Strikeout x1 : Strikeout x2 : ils)-  = normalizeInlineList $ Strikeout (x1 ++ x2) : ils+  = normalizeInlineList $ Strikeout (x1 <> x2) : ils normalizeInlineList (Superscript x1 : Superscript x2 : ils)-  = normalizeInlineList $ Superscript (x1 ++ x2) : ils+  = normalizeInlineList $ Superscript (x1 <> x2) : ils normalizeInlineList (Subscript x1 : Subscript x2 : ils)-  = normalizeInlineList $ Subscript (x1 ++ x2) : ils+  = normalizeInlineList $ Subscript (x1 <> x2) : ils normalizeInlineList (SmallCaps x1 : SmallCaps x2 : ils)-  = normalizeInlineList $ SmallCaps (x1 ++ x2) : ils+  = normalizeInlineList $ SmallCaps (x1 <> x2) : ils normalizeInlineList (Code _ x1 : Code _ x2 : ils)-  = normalizeInlineList $ Code nullAttr (x1 ++ x2) : ils+  = normalizeInlineList $ Code nullAttr (x1 <> x2) : ils normalizeInlineList (RawInline f1 x1 : RawInline f2 x2 : ils) | f1 == f2-  = normalizeInlineList $ RawInline f1 (x1 ++ x2) : ils+  = normalizeInlineList $ RawInline f1 (x1 <> x2) : ils -- Do not join Span's during normalization normalizeInlineList (x:xs) = x : normalizeInlineList xs normalizeInlineList [] = []@@ -457,33 +458,41 @@ endsWithSpace :: [Inline] -> Bool endsWithSpace [Space]     = True endsWithSpace [SoftBreak] = True-endsWithSpace [Str s]     = stringStartsWithSpace $ reverse s+endsWithSpace [Str s]     = stringEndsWithSpace s endsWithSpace (_:xs)      = endsWithSpace xs endsWithSpace []          = False -urlEscapeBrackets :: String -> String-urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs-urlEscapeBrackets (x:xs)   = x:urlEscapeBrackets xs-urlEscapeBrackets []       = []+urlEscapeBrackets :: Text -> Text+urlEscapeBrackets = T.concatMap $ \c -> case c of+  ']' -> "%5D"+  _   -> T.singleton c -isHorizontalRule :: String -> Bool-isHorizontalRule s = length s >= 4 && all (== '-') s+isHorizontalRule :: Text -> Bool+isHorizontalRule s = T.length s >= 4 && T.all (== '-') s -stringStartsWithSpace :: String -> Bool-stringStartsWithSpace (x:_) = isSpace x-stringStartsWithSpace ""    = False+stringStartsWithSpace :: Text -> Bool+stringStartsWithSpace = maybe False (isSpace . fst) . T.uncons +stringEndsWithSpace :: Text -> Bool+stringEndsWithSpace = maybe False (isSpace . snd) . T.unsnoc+ fixOrEscape :: Bool -> Inline -> Bool-fixOrEscape sp (Str "-") = sp-fixOrEscape sp (Str s@('-':x:_)) = (sp && isSpace x) || isHorizontalRule s-fixOrEscape sp (Str ";") = not sp-fixOrEscape sp (Str (';':x:_)) = not sp && isSpace x-fixOrEscape _ (Str ">") = True-fixOrEscape _ (Str ('>':x:_)) = isSpace x-fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||-                                startsWithMarker isAsciiLower s ||-                                startsWithMarker isAsciiUpper s))-                         || stringStartsWithSpace s+fixOrEscape b (Str s) = fixOrEscapeStr b s+  where+    fixOrEscapeStr sp t = case T.uncons t of+      Just ('-', xs)+        | T.null xs -> sp+        | otherwise -> (sp && isSpace (T.head xs)) || isHorizontalRule t+      Just (';', xs)+        | T.null xs -> not sp+        | otherwise -> not sp && isSpace (T.head xs)+      Just ('>', xs)+        | T.null xs -> True+        | otherwise -> isSpace (T.head xs)+      _             -> (sp && (startsWithMarker isDigit s ||+                               startsWithMarker isAsciiLower s ||+                               startsWithMarker isAsciiUpper s))+                       || stringStartsWithSpace s       fixOrEscape _ Space = True fixOrEscape _ SoftBreak = True fixOrEscape _ _ = False@@ -492,14 +501,14 @@                           => [Inline]                           -> Muse m Bool inlineListStartsWithAlnum (Str s:_) = do-  esc <- shouldEscapeString s-  return $ esc || isAlphaNum (head s)+  esc <- shouldEscapeText s+  return $ esc || isAlphaNum (T.head s) inlineListStartsWithAlnum _ = return False  -- | Convert list of Pandoc inline elements to Muse renderInlineList :: PandocMonad m                  => [Inline]-                 -> Muse m Doc+                 -> Muse m (Doc Text) renderInlineList [] = pure "" renderInlineList (x:xs) = do   start <- asks envInlineStart@@ -523,13 +532,13 @@                              , envNearAsterisks = False                              }) $ renderInlineList xs   if start && fixOrEscape afterSpace x-    then pure (text "<verbatim></verbatim>" <> r <> lst')+    then pure (literal "<verbatim></verbatim>" <> r <> lst')     else pure (r <> lst')  -- | Normalize and convert list of Pandoc inline elements to Muse. inlineListToMuse :: PandocMonad m                  => [Inline]-                 -> Muse m Doc+                 -> Muse m (Doc Text) inlineListToMuse lst = do   lst' <- normalizeInlineList . fixNotes <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)   insideAsterisks <- asks envInsideAsterisks@@ -539,7 +548,7 @@     then pure "<verbatim></verbatim>"     else local (\env -> env { envNearAsterisks = insideAsterisks }) $ renderInlineList lst' -inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m Doc+inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m (Doc Text) inlineListToMuse' lst = do   topLevel <- asks envTopLevel   afterSpace <- asks envAfterSpace@@ -547,23 +556,23 @@                      , envAfterSpace = afterSpace || not topLevel                      }) $ inlineListToMuse lst -emphasis :: PandocMonad m => String -> String -> [Inline] -> Muse m Doc+emphasis :: PandocMonad m => Text -> Text -> [Inline] -> Muse m (Doc Text) emphasis b e lst = do   contents <- local (\env -> env { envInsideAsterisks = inAsterisks }) $ inlineListToMuse lst   modify $ \st -> st { stUseTags = useTags }-  return $ text b <> contents <> text e-  where inAsterisks = last b == '*' || head e == '*'-        useTags = last e /= '>'+  return $ literal b <> contents <> literal e+  where inAsterisks = T.last b == '*' || T.head e == '*'+        useTags = T.last e /= '>'  -- | Convert Pandoc inline element to Muse. inlineToMuse :: PandocMonad m              => Inline-             -> Muse m Doc+             -> Muse m (Doc Text) inlineToMuse (Str str) = do-  escapedStr <- conditionalEscapeString $ replaceNewlines str-  let useTags = isAlphaNum $ last escapedStr -- escapedStr is never empty because empty strings are escaped+  escapedStr <- conditionalEscapeText $ replaceNewlines str+  let useTags = isAlphaNum $ T.last escapedStr -- escapedStr is never empty because empty strings are escaped   modify $ \st -> st { stUseTags = useTags }-  return $ text escapedStr+  return $ literal escapedStr inlineToMuse (Emph [Strong lst]) = do   useTags <- gets stUseTags   let lst' = normalizeInlineList lst@@ -605,7 +614,8 @@   modify $ \st -> st { stUseTags = False }   return $ "<sub>" <> contents <> "</sub>" inlineToMuse SmallCaps {} =-  fail "SmallCaps should be expanded before normalization"+  throwError $ PandocShouldNeverHappenError+    "SmallCaps should be expanded before normalization" inlineToMuse (Quoted SingleQuote lst) = do   contents <- inlineListToMuse lst   modify $ \st -> st { stUseTags = False }@@ -615,18 +625,21 @@   modify $ \st -> st { stUseTags = False }   return $ "“" <> contents <> "”" inlineToMuse Cite {} =-  fail "Citations should be expanded before normalization"+  throwError $ PandocShouldNeverHappenError+               "Citations should be expanded before normalization" inlineToMuse (Code _ str) = do   useTags <- gets stUseTags   modify $ \st -> st { stUseTags = False }-  return $ if useTags || null str || '=' `elem` str || isSpace (head str) || isSpace (last str)-             then "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"-             else "=" <> text str <> "="+  return $ if useTags || T.null str || T.any (== '=') str+              || isSpace (T.head str) || isSpace (T.last str)+             then "<code>" <> literal (T.replace "</code>" "<</code><code>/code>" str) <> "</code>"+             else "=" <> literal str <> "=" inlineToMuse Math{} =-  fail "Math should be expanded before normalization"+  throwError $ PandocShouldNeverHappenError+    "Math should be expanded before normalization" inlineToMuse (RawInline (Format f) str) = do   modify $ \st -> st { stUseTags = False }-  return $ "<literal style=\"" <> text f <> "\">" <> text str <> "</literal>"+  return $ "<literal style=\"" <> literal f <> "\">" <> literal str <> "</literal>" inlineToMuse LineBreak = do   oneline <- asks envOneLine   modify $ \st -> st { stUseTags = False }@@ -643,27 +656,27 @@   case txt of         [Str x] | escapeURI x == src -> do              modify $ \st -> st { stUseTags = False }-             return $ "[[" <> text (escapeLink x) <> "]]"+             return $ "[[" <> literal (escapeLink x) <> "]]"         _ -> do contents <- local (\env -> env { envInsideLinkDescription = True }) $ inlineListToMuse txt                 modify $ \st -> st { stUseTags = False }-                return $ "[[" <> text (escapeLink src) <> "][" <> contents <> "]]"-  where escapeLink lnk = if isImageUrl lnk then "URL:" ++ urlEscapeBrackets lnk else urlEscapeBrackets lnk+                return $ "[[" <> literal (escapeLink src) <> "][" <> contents <> "]]"+  where escapeLink lnk = if isImageUrl lnk then "URL:" <> urlEscapeBrackets lnk else urlEscapeBrackets lnk         -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el         imageExtensions = [".eps", ".gif", ".jpg", ".jpeg", ".pbm", ".png", ".tiff", ".xbm", ".xpm"]-        isImageUrl = (`elem` imageExtensions) . takeExtension-inlineToMuse (Image attr alt (source,'f':'i':'g':':':title)) =+        isImageUrl = (`elem` imageExtensions) . takeExtension . T.unpack+inlineToMuse (Image attr alt (source,T.stripPrefix "fig:" -> Just title)) =   inlineToMuse (Image attr alt (source,title)) inlineToMuse (Image attr@(_, classes, _) inlines (source, title)) = do   opts <- asks envOptions   alt <- local (\env -> env { envInsideLinkDescription = True }) $ inlineListToMuse inlines-  title' <- if null title+  title' <- if T.null title             then if null inlines                  then return ""                  else return $ "[" <> alt <> "]"-            else do s <- local (\env -> env { envInsideLinkDescription = True }) $ conditionalEscapeString title-                    return $ "[" <> text s <> "]"+            else do s <- local (\env -> env { envInsideLinkDescription = True }) $ conditionalEscapeText title+                    return $ "[" <> literal s <> "]"   let width = case dimension Width attr of-                Just (Percent x) | isEnabled Ext_amuse opts -> " " ++ show (round x :: Integer)+                Just (Percent x) | isEnabled Ext_amuse opts -> " " <> tshow (round x :: Integer)                 _ -> ""   let leftalign = if "align-left" `elem` classes                   then " l"@@ -672,7 +685,7 @@                    then " r"                    else ""   modify $ \st -> st { stUseTags = False }-  return $ "[[" <> text (urlEscapeBrackets source ++ width ++ leftalign ++ rightalign) <> "]" <> title' <> "]"+  return $ "[[" <> literal (urlEscapeBrackets source <> width <> leftalign <> rightalign) <> "]" <> title' <> "]" inlineToMuse (Note contents) = do   -- add to notes in state   notes <- gets stNotes@@ -680,16 +693,19 @@                      , stUseTags = False                      }   n <- gets stNoteNum-  let ref = show $ n + length notes-  return $ "[" <> text ref <> "]"-inlineToMuse (Span (anchor,names,_) inlines) = do+  let ref = tshow $ n + length notes+  return $ "[" <> literal ref <> "]"+inlineToMuse (Span (anchor,names,kvs) inlines) = do   contents <- inlineListToMuse inlines-  let anchorDoc = if null anchor+  let (contents', hasDir) = case lookup "dir" kvs of+                              Just "rtl" -> ("<<<" <> contents <> ">>>", True)+                              Just "ltr" -> (">>>" <> contents <> "<<<", True)+                              _ -> (contents, False)+  let anchorDoc = if T.null anchor                      then mempty-                     else text ('#':anchor) <> space+                     else literal ("#" <> anchor) <> space   modify $ \st -> st { stUseTags = False }-  return $ anchorDoc <> (if null inlines && not (null anchor)+  return $ anchorDoc <> (if null inlines && not (T.null anchor)                          then mempty-                         else (if null names-                               then "<class>"-                               else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>")+                         else (if null names then (if hasDir then contents' else "<class>" <> contents' <> "</class>")+                               else "<class name=\"" <> literal (head names) <> "\">" <> contents' <> "</class>"))
src/Text/Pandoc/Writers/Native.hs view
@@ -19,15 +19,15 @@ import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options (WrapOption (..), WriterOptions (..))-import Text.Pandoc.Pretty+import Text.DocLayout -prettyList :: [Doc] -> Doc+prettyList :: [Doc Text] -> Doc Text prettyList ds =   "[" <>-  cat (intersperse (cr <> ",") $ map (nest 1) ds) <> "]"+  mconcat (intersperse (cr <> ",") $ map (nest 1) ds) <> "]"  -- | Prettyprint Pandoc block element.-prettyBlock :: Block -> Doc+prettyBlock :: Block -> Doc Text prettyBlock (LineBlock lines') =   "LineBlock" $$ prettyList (map (text . show) lines') prettyBlock (BlockQuote blocks) =
src/Text/Pandoc/Writers/ODT.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings   #-} {- |    Module      : Text.Pandoc.Writers.ODT    Copyright   : Copyright (C) 2008-2019 John MacFarlane@@ -18,9 +19,9 @@ import Control.Monad.State.Strict import qualified Data.ByteString.Lazy as B import Data.Generics (everywhere', mkT)-import Data.List (isPrefixOf, intercalate)-import Data.Maybe (fromMaybe)+import Data.List (isPrefixOf) import qualified Data.Map as Map+import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Data.Time import System.FilePath (takeDirectory, takeExtension, (<.>))@@ -32,8 +33,8 @@ import Text.Pandoc.Logging import Text.Pandoc.MIME (extensionFromMimeType, getMimeType) import Text.Pandoc.Options (WrapOption (..), WriterOptions (..))-import Text.Pandoc.Pretty-import Text.Pandoc.Shared (stringify, pandocVersion)+import Text.DocLayout+import Text.Pandoc.Shared (stringify, pandocVersion, tshow) import Text.Pandoc.Writers.Shared (lookupMetaString, lookupMetaBlocks,                                    fixDisplayMath) import Text.Pandoc.UTF8 (fromStringLazy, fromTextLazy, toStringLazy)@@ -89,7 +90,7 @@                         Nothing  -> empty                         Just m   -> selfClosingTag "manifest:file-entry"                                      [("manifest:media-type", m)-                                     ,("manifest:full-path", fp)+                                     ,("manifest:full-path", T.pack fp)                                      ,("manifest:version", "1.2")                                      ]   let files = [ ent | ent <- filesInArchive archive,@@ -114,7 +115,7 @@   let userDefinedMetaFields = [k | k <- Map.keys (unMeta meta)                               , k `notElem` ["title", "lang", "author"                                            , "description", "subject", "keywords"]]-  let escapedText = text . escapeStringForXML+  let escapedText = text . T.unpack . escapeStringForXML   let keywords = case lookupMeta "keywords" meta of                       Just (MetaList xs) -> map stringify xs                       _                  -> []@@ -136,17 +137,17 @@            ,("xmlns:ooo","http://openoffice.org/2004/office")            ,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")            ,("office:version","1.2")] ( inTags True "office:meta" [] $-                 ( metaTag "meta:generator" ("Pandoc/" ++ pandocVersion)+                 ( metaTag "meta:generator" ("Pandoc/" <> pandocVersion)                    $$                    metaTag "dc:title" (stringify title)                    $$                    metaTag "dc:description"-                          (intercalate "\n" (map stringify $+                          (T.intercalate "\n" (map stringify $                                          lookupMetaBlocks "description" meta))                    $$                    metaTag "dc:subject" (lookupMetaString "subject" meta)                    $$-                   metaTag "meta:keyword" (intercalate ", " keywords)+                   metaTag "meta:keyword" (T.intercalate ", " keywords)                    $$                    case lang of                         Just l  -> metaTag "dc:language" (renderLang l)@@ -156,8 +157,8 @@                          $$ metaTag "dc:creator" a                          $$ metaTag "meta:creation-date" d                          $$ metaTag "dc:date" d-                   ) (formatTime defaultTimeLocale "%FT%XZ" utctime)-                     (intercalate "; " (map stringify authors))+                   ) (T.pack $ formatTime defaultTimeLocale "%FT%XZ" utctime)+                     (T.intercalate "; " (map stringify authors))                    $$                    vcat userDefinedMeta                  )@@ -190,9 +191,9 @@ addLang :: Lang -> Element -> Element addLang lang = everywhere' (mkT updateLangAttr)     where updateLangAttr (Attr n@(QName "language" _ (Just "fo")) _)-                           = Attr n (langLanguage lang)+                           = Attr n (T.unpack $ langLanguage lang)           updateLangAttr (Attr n@(QName "country" _ (Just "fo")) _)-                           = Attr n (langRegion lang)+                           = Attr n (T.unpack $ langRegion lang)           updateLangAttr x = x  -- | transform both Image and Math elements@@ -206,12 +207,12 @@                          return (100, 100)        let dims =              case (getDim Width, getDim Height) of-               (Just w, Just h)              -> [("width", show w), ("height", show h)]-               (Just w@(Percent _), Nothing) -> [("rel-width", show w),("rel-height", "scale"),("width", show ptX ++ "pt"),("height", show ptY ++ "pt")]-               (Nothing, Just h@(Percent _)) -> [("rel-width", "scale"),("rel-height", show h),("width", show ptX ++ "pt"),("height", show ptY ++ "pt")]-               (Just w@(Inch i), Nothing)    -> [("width", show w), ("height", show (i / ratio) ++ "in")]-               (Nothing, Just h@(Inch i))    -> [("width", show (i * ratio) ++ "in"), ("height", show h)]-               _                             -> [("width", show ptX ++ "pt"), ("height", show ptY ++ "pt")]+               (Just w, Just h)              -> [("width", tshow w), ("height", tshow h)]+               (Just w@(Percent _), Nothing) -> [("rel-width", tshow w),("rel-height", "scale"),("width", tshow ptX <> "pt"),("height", tshow ptY <> "pt")]+               (Nothing, Just h@(Percent _)) -> [("rel-width", "scale"),("rel-height", tshow h),("width", tshow ptX <> "pt"),("height", tshow ptY <> "pt")]+               (Just w@(Inch i), Nothing)    -> [("width", tshow w), ("height", tshow (i / ratio) <> "in")]+               (Nothing, Just h@(Inch i))    -> [("width", tshow (i * ratio) <> "in"), ("height", tshow h)]+               _                             -> [("width", tshow ptX <> "pt"), ("height", tshow ptY <> "pt")]              where                ratio = ptX / ptY                getDim dir = case dimension dir attr of@@ -220,16 +221,16 @@                               Nothing          -> Nothing        let  newattr = (id', cls, dims)        entries <- gets stEntries-       let extension = fromMaybe (takeExtension $ takeWhile (/='?') src)+       let extension = maybe (takeExtension $ takeWhile (/='?') $ T.unpack src) T.unpack                            (mbMimeType >>= extensionFromMimeType)        let newsrc = "Pictures/" ++ show (length entries) <.> extension        let toLazy = B.fromChunks . (:[])        epochtime <- floor `fmap` lift P.getPOSIXTime        let entry = toEntry newsrc epochtime $ toLazy img        modify $ \st -> st{ stEntries = entry : entries }-       return $ Image newattr lab (newsrc, t))+       return $ Image newattr lab (T.pack newsrc, t))    (\e -> do-       report $ CouldNotFetchResource src (show e)+       report $ CouldNotFetchResource src $ T.pack (show e)        return $ Emph lab)  transformPicMath _ (Math t math) = do@@ -257,7 +258,7 @@                                            ,("text:anchor-type","paragraph")]                                       else [("draw:style-name","fr1")                                            ,("text:anchor-type","as-char")]) $-             selfClosingTag "draw:object" [("xlink:href", dirname)+             selfClosingTag "draw:object" [("xlink:href", T.pack dirname)                                         , ("xlink:type", "simple")                                         , ("xlink:show", "embed")                                         , ("xlink:actuate", "onLoad")]
src/Text/Pandoc/Writers/OOXML.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Writers.OOXML    Copyright   : Copyright (C) 2012-2019 John MacFarlane@@ -11,6 +12,7 @@ Functions common to OOXML writers (Docx and Powerpoint) -} module Text.Pandoc.Writers.OOXML ( mknode+                                 , mktnode                                  , nodename                                  , toLazy                                  , renderXml@@ -25,10 +27,13 @@ import Prelude import Codec.Archive.Zip import Control.Monad.Reader+import Control.Monad.Except (throwError)+import Text.Pandoc.Error import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BL8 import Data.Maybe (mapMaybe)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad) import qualified Text.Pandoc.UTF8 as UTF8 import Text.XML.Light as XML@@ -37,6 +42,9 @@ mknode s attrs =   add_attrs (map (\(k,v) -> Attr (nodename k) v) attrs) .  node (nodename s) +mktnode :: String -> [(String,String)] -> T.Text -> Element+mktnode s attrs = mknode s attrs . T.unpack+ nodename :: String -> QName nodename s = QName{ qName = name, qURI = Nothing, qPrefix = prefix }  where (name, prefix) = case break (==':') s of@@ -50,13 +58,15 @@ renderXml elt = BL8.pack "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" <>   UTF8.fromStringLazy (showElement elt) -parseXml :: (PandocMonad m) => Archive -> Archive -> String -> m Element+parseXml :: PandocMonad m => Archive -> Archive -> String -> m Element parseXml refArchive distArchive relpath =   case findEntryByPath relpath refArchive `mplus`          findEntryByPath relpath distArchive of-            Nothing -> fail $ relpath ++ " missing in reference file"+            Nothing -> throwError $ PandocSomeError $+                        T.pack relpath <> " missing in reference file"             Just e  -> case parseXMLDoc . UTF8.toStringLazy . fromEntry $ e of-                       Nothing -> fail $ relpath ++ " corrupt in reference file"+                       Nothing -> throwError $ PandocSomeError $+                                   T.pack relpath <> " corrupt in reference file"                        Just d  -> return d  -- Copied from Util
src/Text/Pandoc/Writers/OPML.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP               #-} {- |    Module      : Text.Pandoc.Writers.OPML    Copyright   : Copyright (C) 2013-2019 John MacFarlane@@ -13,18 +14,16 @@ -} module Text.Pandoc.Writers.OPML ( writeOPML) where import Prelude-import Control.Monad.Except (throwError)-import Data.Text (Text, unpack)+import Data.Text (Text) import qualified Data.Text as T import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad) import Data.Time import Text.Pandoc.Definition-import Text.Pandoc.Error import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.HTML (writeHtml5String) import Text.Pandoc.Writers.Markdown (writeMarkdown) import Text.Pandoc.Writers.Shared@@ -33,21 +32,24 @@ -- | Convert Pandoc document to string in OPML format. writeOPML :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeOPML opts (Pandoc meta blocks) = do-  let elements = hierarchicalize blocks-      colwidth = if writerWrapText opts == WrapAuto+  let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing       meta' = B.setMeta "date" (B.str $ convertDate $ docDate meta) meta-  metadata <- metaToJSON opts-              (writeMarkdown def . Pandoc nullMeta)-              (\ils -> T.stripEnd <$> writeMarkdown def (Pandoc nullMeta [Plain ils]))+  metadata <- metaToContext opts+              (fmap literal . writeMarkdown def . Pandoc nullMeta)+              (\ils -> literal . T.stripEnd <$>+                writeMarkdown def (Pandoc nullMeta [Plain ils]))               meta'-  main <- (render colwidth . vcat) <$> mapM (elementToOPML opts) elements+  let blocks' = makeSections False (Just 1) blocks+  main <- (render colwidth . vcat) <$>+             mapM (blockToOPML opts) blocks'   let context = defField "body" main metadata-  (if writerPreferAscii opts then toEntities else id) <$>+  return $+    (if writerPreferAscii opts then toEntities else id) $     case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+       Nothing  -> main+       Just tpl -> render colwidth $ renderTemplate tpl context   writeHtmlInlines :: PandocMonad m => [Inline] -> m Text@@ -55,32 +57,25 @@   T.strip <$> writeHtml5String def (Pandoc nullMeta [Plain ils])  -- date format: RFC 822: Thu, 14 Jul 2005 23:41:05 GMT-showDateTimeRFC822 :: UTCTime -> String-showDateTimeRFC822 = formatTime defaultTimeLocale "%a, %d %b %Y %X %Z"+showDateTimeRFC822 :: UTCTime -> Text+showDateTimeRFC822 = T.pack . formatTime defaultTimeLocale "%a, %d %b %Y %X %Z" -convertDate :: [Inline] -> String+convertDate :: [Inline] -> Text convertDate ils = maybe "" showDateTimeRFC822 $-  parseTimeM True defaultTimeLocale "%F" =<< normalizeDate (stringify ils)---- | Convert an Element to OPML.-elementToOPML :: PandocMonad m => WriterOptions -> Element -> m Doc-elementToOPML _ (Blk _) = return empty-elementToOPML opts (Sec _ _num _ title elements) = do-  let isBlk :: Element -> Bool-      isBlk (Blk _) = True-      isBlk _       = False--      fromBlk :: PandocMonad m => Element -> m Block-      fromBlk (Blk x) = return x-      fromBlk _ = throwError $ PandocSomeError "fromBlk called on non-block"+  parseTimeM True defaultTimeLocale "%F" . T.unpack =<< normalizeDate (stringify ils) -      (blocks, rest) = span isBlk elements+-- | Convert a Block to OPML.+blockToOPML :: PandocMonad m => WriterOptions -> Block -> m (Doc Text)+blockToOPML opts (Div (_,"section":_,_) (Header _ _ title : xs)) = do+  let isSect (Div (_,"section":_,_) (Header{}:_)) = True+      isSect _ = False+  let (blocks, rest) = break isSect xs   htmlIls <- writeHtmlInlines title   md <- if null blocks         then return mempty-        else do blks <- mapM fromBlk blocks-                writeMarkdown def $ Pandoc nullMeta blks-  let attrs = ("text", unpack htmlIls) :-              [("_note", unpack md) | not (null blocks)]-  o <- mapM (elementToOPML opts) rest-  return $ inTags True "outline" attrs $ vcat o+        else writeMarkdown def $ Pandoc nullMeta blocks+  let attrs = ("text", htmlIls) :+              [("_note", T.stripEnd md) | not (null blocks)]+  rest' <- vcat <$> mapM (blockToOPML opts) rest+  return $ inTags True "outline" attrs rest'+blockToOPML _ _ = return empty
src/Text/Pandoc/Writers/OpenDocument.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternGuards     #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.OpenDocument    Copyright   : Copyright (C) 2008-2019 Andrea Rossato and John MacFarlane@@ -18,21 +19,22 @@ import Control.Arrow ((***), (>>>)) import Control.Monad.State.Strict hiding (when) import Data.Char (chr)-import Data.List (sortBy)+import Data.List (sortBy, foldl') import qualified Data.Map as Map import Data.Maybe (fromMaybe) import Data.Ord (comparing) import qualified Data.Set as Set import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.BCP47 (Lang (..), parseBCP47) import Text.Pandoc.Class (PandocMonad, report, translateTerm,                           setTranslations, toLang) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty-import Text.Pandoc.Shared (linesToPara)-import Text.Pandoc.Templates (renderTemplate')+import Text.DocLayout+import Text.Pandoc.Shared (linesToPara, tshow)+import Text.Pandoc.Templates (renderTemplate) import qualified Text.Pandoc.Translations as Term (Term(Figure, Table)) import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared@@ -51,11 +53,12 @@ type OD m = StateT WriterState m  data WriterState =-    WriterState { stNotes          :: [Doc]-                , stTableStyles    :: [Doc]-                , stParaStyles     :: [Doc]-                , stListStyles     :: [(Int, [Doc])]-                , stTextStyles     :: Map.Map (Set.Set TextStyle) (String, Doc)+    WriterState { stNotes          :: [Doc Text]+                , stTableStyles    :: [Doc Text]+                , stParaStyles     :: [Doc Text]+                , stListStyles     :: [(Int, [Doc Text])]+                , stTextStyles     :: Map.Map (Set.Set TextStyle)+                                        (Text, Doc Text)                 , stTextStyleAttr  :: Set.Set TextStyle                 , stIndentPara     :: Int                 , stInDefinition   :: Bool@@ -83,19 +86,20 @@                 , stImageCaptionId = 1                 } -when :: Bool -> Doc -> Doc+when :: Bool -> Doc Text -> Doc Text when p a = if p then a else empty -addTableStyle :: PandocMonad m => Doc -> OD m ()+addTableStyle :: PandocMonad m => Doc Text -> OD m () addTableStyle i = modify $ \s -> s { stTableStyles = i : stTableStyles s } -addNote :: PandocMonad m => Doc -> OD m ()+addNote :: PandocMonad m => Doc Text -> OD m () addNote i = modify $ \s -> s { stNotes = i : stNotes s } -addParaStyle :: PandocMonad m => Doc -> OD m ()+addParaStyle :: PandocMonad m => Doc Text -> OD m () addParaStyle i = modify $ \s -> s { stParaStyles = i : stParaStyles s } -addTextStyle :: PandocMonad m => Set.Set TextStyle -> (String, Doc) -> OD m ()+addTextStyle :: PandocMonad m+             => Set.Set TextStyle -> (Text, Doc Text) -> OD m () addTextStyle attrs i = modify $ \s ->   s { stTextStyles = Map.insert attrs i (stTextStyles s) } @@ -119,7 +123,7 @@ setFirstPara :: PandocMonad m => OD m () setFirstPara =  modify $  \s -> s { stFirstPara = True } -inParagraphTags :: PandocMonad m => Doc -> OD m Doc+inParagraphTags :: PandocMonad m => Doc Text -> OD m (Doc Text) inParagraphTags d = do   b <- gets stFirstPara   a <- if b@@ -128,10 +132,10 @@        else    return   [("text:style-name", "Text_20_body")]   return $ inTags False "text:p" a d -inParagraphTagsWithStyle :: String -> Doc -> Doc+inParagraphTagsWithStyle :: Text -> Doc Text -> Doc Text inParagraphTagsWithStyle sty = inTags False "text:p" [("text:style-name", sty)] -inSpanTags :: String -> Doc -> Doc+inSpanTags :: Text -> Doc Text -> Doc Text inSpanTags s = inTags False "text:span" [("text:style-name",s)]  withTextStyle :: PandocMonad m => TextStyle -> OD m a -> OD m a@@ -142,7 +146,7 @@   modify $ \st -> st{ stTextStyleAttr = oldTextStyleAttr }   return res -inTextStyle :: PandocMonad m => Doc -> OD m Doc+inTextStyle :: PandocMonad m => Doc Text -> OD m (Doc Text) inTextStyle d = do   at <- gets stTextStyleAttr   if Set.null at@@ -153,20 +157,21 @@             Just (styleName, _) -> return $               inTags False "text:span" [("text:style-name",styleName)] d             Nothing -> do-              let styleName = "T" ++ show (Map.size styles + 1)+              let styleName = "T" <> tshow (Map.size styles + 1)               addTextStyle at (styleName,                      inTags False "style:style"                        [("style:name", styleName)                        ,("style:family", "text")]                        $ selfClosingTag "style:text-properties"-                          (concatMap textStyleAttr (Set.toList at)))+                          (sortBy (comparing fst) . Map.toList+                                $ foldl' textStyleAttr mempty (Set.toList at)))               return $ inTags False                   "text:span" [("text:style-name",styleName)] d -formulaStyles :: [Doc]+formulaStyles :: [Doc Text] formulaStyles = [formulaStyle InlineMath, formulaStyle DisplayMath] -formulaStyle :: MathType -> Doc+formulaStyle :: MathType -> Doc Text formulaStyle mt = inTags False "style:style"   [("style:name", if mt == InlineMath then "fr1" else "fr2")   ,("style:family", "graphic")@@ -181,32 +186,33 @@                                                   ,("style:horizontal-rel", "paragraph-content")                                                   ,("style:wrap",           "none")] -inHeaderTags :: PandocMonad m => Int -> String -> Doc -> OD m Doc+inHeaderTags :: PandocMonad m => Int -> Text -> Doc Text -> OD m (Doc Text) inHeaderTags i ident d =-  return $ inTags False "text:h" [ ("text:style-name", "Heading_20_" ++ show i)-                                 , ("text:outline-level", show i)]-         $ if null ident+  return $ inTags False "text:h" [ ("text:style-name", "Heading_20_" <> tshow i)+                                 , ("text:outline-level", tshow i)]+         $ if T.null ident               then d               else selfClosingTag "text:bookmark-start" [ ("text:name", ident) ]                    <> d <>                    selfClosingTag "text:bookmark-end" [ ("text:name", ident) ] -inQuotes :: QuoteType -> Doc -> Doc+inQuotes :: QuoteType -> Doc Text -> Doc Text inQuotes SingleQuote s = char '\8216' <> s <> char '\8217' inQuotes DoubleQuote s = char '\8220' <> s <> char '\8221' -handleSpaces :: String -> Doc-handleSpaces s-    | ( ' ':_) <- s = genTag s-    | ('\t':x) <- s = selfClosingTag "text:tab" [] <> rm x-    | otherwise     = rm s-    where-        genTag       = span (==' ') >>> tag . length *** rm >>> uncurry (<>)-        tag n        = when (n /= 0) $ selfClosingTag "text:s" [("text:c", show n)]-        rm ( ' ':xs) = char ' ' <> genTag xs-        rm ('\t':xs) = selfClosingTag "text:tab" [] <> genTag xs-        rm (   x:xs) = char  x  <> rm xs-        rm        [] = empty+handleSpaces :: Text -> Doc Text+handleSpaces s = case T.uncons s of+  Just (' ', _) -> genTag s+  Just ('\t',x) -> selfClosingTag "text:tab" [] <> rm x+  _             -> rm s+  where+    genTag = T.span (==' ') >>> tag . T.length *** rm >>> uncurry (<>)+    tag n  = when (n /= 0) $ selfClosingTag "text:s" [("text:c", tshow n)]+    rm t   = case T.uncons t of+      Just ( ' ',xs) -> char ' ' <> genTag xs+      Just ('\t',xs) -> selfClosingTag "text:tab" [] <> genTag xs+      Just (   x,xs) -> char x <> rm xs+      Nothing        -> empty  -- | Convert Pandoc document to string in OpenDocument format. writeOpenDocument :: PandocMonad m => WriterOptions -> Pandoc -> m Text@@ -219,54 +225,54 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth   ((body, metadata),s) <- flip runStateT         defaultWriterState $ do-           m <- metaToJSON opts-                  (fmap render' . blocksToOpenDocument opts)-                  (fmap render' . inlinesToOpenDocument opts)+           m <- metaToContext opts+                  (blocksToOpenDocument opts)+                  (fmap chomp . inlinesToOpenDocument opts)                   meta-           b <- render' `fmap` blocksToOpenDocument opts blocks+           b <- blocksToOpenDocument opts blocks            return (b, m)   let styles   = stTableStyles s ++ stParaStyles s ++ formulaStyles ++                      map snd (sortBy (flip (comparing fst)) (                         Map.elems (stTextStyles s)))       listStyle (n,l) = inTags True "text:list-style"-                          [("style:name", "L" ++ show n)] (vcat l)+                          [("style:name", "L" <> tshow n)] (vcat l)   let listStyles  = map listStyle (stListStyles s)   let automaticStyles = vcat $ reverse $ styles ++ listStyles   let context = defField "body" body               $ defField "toc" (writerTableOfContents opts)-              $defField "automatic-styles" (render' automaticStyles) metadata-  case writerTemplate opts of-       Nothing  -> return body-       Just tpl -> renderTemplate' tpl context+              $ defField "automatic-styles" automaticStyles+              $ metadata+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> body+       Just tpl -> renderTemplate tpl context  withParagraphStyle :: PandocMonad m-                   => WriterOptions -> String -> [Block] -> OD m Doc+                   => WriterOptions -> Text -> [Block] -> OD m (Doc Text) withParagraphStyle  o s (b:bs)     | Para l <- b = go =<< inParagraphTagsWithStyle s <$> inlinesToOpenDocument o l     | otherwise   = go =<< blockToOpenDocument o b     where go i = (<>) i <$>  withParagraphStyle o s bs withParagraphStyle _ _ [] = return empty -inPreformattedTags :: PandocMonad m => String -> OD m Doc+inPreformattedTags :: PandocMonad m => Text -> OD m (Doc Text) inPreformattedTags s = do   n <- paraStyle [("style:parent-style-name","Preformatted_20_Text")]-  return . inParagraphTagsWithStyle ("P" ++ show n) . handleSpaces $ s+  return . inParagraphTagsWithStyle ("P" <> tshow n) . handleSpaces $ s  orderedListToOpenDocument :: PandocMonad m-                          => WriterOptions -> Int -> [[Block]] -> OD m Doc+                          => WriterOptions -> Int -> [[Block]] -> OD m (Doc Text) orderedListToOpenDocument o pn bs =     vcat . map (inTagsIndented "text:list-item") <$>     mapM (orderedItemToOpenDocument o pn . map plainToPara) bs  orderedItemToOpenDocument :: PandocMonad m-                          => WriterOptions -> Int -> [Block] -> OD m Doc+                          => WriterOptions -> Int -> [Block] -> OD m (Doc Text) orderedItemToOpenDocument  o n bs = vcat <$> mapM go bs  where go (OrderedList a l) = newLevel a l-       go (Para          l) = inParagraphTagsWithStyle ("P" ++ show n) <$>+       go (Para          l) = inParagraphTagsWithStyle ("P" <> tshow n) <$>                                 inlinesToOpenDocument o l        go b                 = blockToOpenDocument o b        newLevel a l = do@@ -292,21 +298,21 @@   return (ln,pn)  bulletListToOpenDocument :: PandocMonad m-                         => WriterOptions -> [[Block]] -> OD m Doc+                         => WriterOptions -> [[Block]] -> OD m (Doc Text) bulletListToOpenDocument o b = do   ln <- (+) 1 . length <$> gets stListStyles   (pn,ns) <- if isTightList b then inTightList (bulletListStyle ln) else bulletListStyle ln   modify $ \s -> s { stListStyles = ns : stListStyles s }-  is <- listItemsToOpenDocument ("P" ++ show pn) o b-  return $ inTags True "text:list" [("text:style-name", "L" ++ show ln)] is+  is <- listItemsToOpenDocument ("P" <> tshow pn) o b+  return $ inTags True "text:list" [("text:style-name", "L" <> tshow ln)] is  listItemsToOpenDocument :: PandocMonad m-                        => String -> WriterOptions -> [[Block]] -> OD m Doc+                        => Text -> WriterOptions -> [[Block]] -> OD m (Doc Text) listItemsToOpenDocument s o is =     vcat . map (inTagsIndented "text:list-item") <$> mapM (withParagraphStyle o s . map plainToPara) is  deflistItemToOpenDocument :: PandocMonad m-                          => WriterOptions -> ([Inline],[[Block]]) -> OD m Doc+                          => WriterOptions -> ([Inline],[[Block]]) -> OD m (Doc Text) deflistItemToOpenDocument o (t,d) = do   let ts = if isTightList d            then "Definition_20_Term_20_Tight"       else "Definition_20_Term"@@ -317,28 +323,28 @@   return $ t' $$ d'  inBlockQuote :: PandocMonad m-             => WriterOptions -> Int -> [Block] -> OD m Doc+             => WriterOptions -> Int -> [Block] -> OD m (Doc Text) inBlockQuote  o i (b:bs)     | BlockQuote l <- b = do increaseIndent                              ni <- paraStyle                                    [("style:parent-style-name","Quotations")]                              go =<< inBlockQuote o ni (map plainToPara l)-    | Para       l <- b = go =<< inParagraphTagsWithStyle ("P" ++ show  i) <$> inlinesToOpenDocument o l+    | Para       l <- b = go =<< inParagraphTagsWithStyle ("P" <> tshow i) <$> inlinesToOpenDocument o l     | otherwise         = go =<< blockToOpenDocument o b     where go  block  = ($$) block <$> inBlockQuote o i bs inBlockQuote     _ _ [] =  resetIndent >> return empty  -- | Convert a list of Pandoc blocks to OpenDocument.-blocksToOpenDocument :: PandocMonad m => WriterOptions -> [Block] -> OD m Doc+blocksToOpenDocument :: PandocMonad m => WriterOptions -> [Block] -> OD m (Doc Text) blocksToOpenDocument o b = vcat <$> mapM (blockToOpenDocument o) b  -- | Convert a Pandoc block element to OpenDocument.-blockToOpenDocument :: PandocMonad m => WriterOptions -> Block -> OD m Doc+blockToOpenDocument :: PandocMonad m => WriterOptions -> Block -> OD m (Doc Text) blockToOpenDocument o bs     | Plain          b <- bs = if null b                                   then return empty                                   else inParagraphTags =<< inlinesToOpenDocument o b-    | Para [Image attr c (s,'f':'i':'g':':':t)] <- bs+    | Para [Image attr c (s,T.stripPrefix "fig:" -> Just t)] <- bs                              = figure attr c s t     | Para           b <- bs = if null b &&                                     not (isEnabled Ext_empty_paragraphs o)@@ -359,7 +365,7 @@     | HorizontalRule   <- bs = setFirstPara >> return (selfClosingTag "text:p"                                 [ ("text:style-name", "Horizontal_20_Line") ])     | RawBlock f     s <- bs = if f == Format "opendocument"-                                  then return $ text s+                                  then return $ text $ T.unpack s                                   else do                                     report $ BlockNotRendered bs                                     return empty@@ -370,21 +376,21 @@                            r <- vcat  <$> mapM (deflistItemToOpenDocument o) b                            setInDefinitionList False                            return r-      preformatted  s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (lines s)+      preformatted  s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (T.lines s)       mkBlockQuote  b = do increaseIndent                            i <- paraStyle                                  [("style:parent-style-name","Quotations")]                            inBlockQuote o i (map plainToPara b)       orderedList a b = do (ln,pn) <- newOrderedListStyle (isTightList b) a-                           inTags True "text:list" [ ("text:style-name", "L" ++ show ln)]+                           inTags True "text:list" [ ("text:style-name", "L" <> tshow ln)]                                       <$> orderedListToOpenDocument o pn b       table c a w h r = do         tn <- length <$> gets stTableStyles         pn <- length <$> gets stParaStyles         let  genIds      = map chr [65..]-             name        = "Table" ++ show (tn + 1)+             name        = "Table" <> tshow (tn + 1)              columnIds   = zip genIds w-             mkColumn  n = selfClosingTag "table:table-column" [("table:style-name", name ++ "." ++ [fst n])]+             mkColumn  n = selfClosingTag "table:table-column" [("table:style-name", name <> "." <> T.singleton (fst n))]              columns     = map mkColumn columnIds              paraHStyles = paraTableStyles "Heading"  pn a              paraStyles  = paraTableStyles "Contents" (pn + length (newPara paraHStyles)) a@@ -394,72 +400,74 @@         captionDoc <- if null c                       then return empty                       else inlinesToOpenDocument o c >>=-                             if True -- temporary: see #5474-                                then unNumberedCaption "TableCaption"-                                else numberedTableCaption+                             if isEnabled Ext_native_numbering o+                                then numberedTableCaption+                                else unNumberedCaption "TableCaption"         th <- if all null h                  then return empty                  else colHeadsToOpenDocument o (map fst paraHStyles) h         tr <- mapM (tableRowToOpenDocument o (map fst paraStyles)) r-        return $ inTags True "table:table" [ ("table:name"      , name)-                                           , ("table:style-name", name)-                                           ] (vcat columns $$ th $$ vcat tr) $$ captionDoc+        let tableDoc = inTags True "table:table" [+                            ("table:name"      , name)+                          , ("table:style-name", name)+                          ] (vcat columns $$ th $$ vcat tr)+        return $ captionDoc $$ tableDoc       figure attr caption source title | null caption =         withParagraphStyle o "Figure" [Para [Image attr caption (source,title)]]                                   | otherwise    = do         imageDoc <- withParagraphStyle o "FigureWithCaption" [Para [Image attr caption (source,title)]]         captionDoc <- inlinesToOpenDocument o caption >>=-                         if True -- temporary: see #5474-                            then unNumberedCaption "FigureCaption"-                            else numberedFigureCaption+                         if isEnabled Ext_native_numbering o+                            then numberedFigureCaption+                            else unNumberedCaption "FigureCaption"         return $ imageDoc $$ captionDoc  -numberedTableCaption :: PandocMonad m => Doc -> OD m Doc+numberedTableCaption :: PandocMonad m => Doc Text -> OD m (Doc Text) numberedTableCaption caption = do     id' <- gets stTableCaptionId     modify (\st -> st{ stTableCaptionId = id' + 1 })     capterm <- translateTerm Term.Table-    return $ numberedCaption "Table" capterm "Table" id' caption+    return $ numberedCaption "TableCaption" capterm "Table" id' caption -numberedFigureCaption :: PandocMonad m => Doc -> OD m Doc+numberedFigureCaption :: PandocMonad m => Doc Text -> OD m (Doc Text) numberedFigureCaption caption = do     id' <- gets stImageCaptionId     modify (\st -> st{ stImageCaptionId = id' + 1 })     capterm <- translateTerm Term.Figure     return $ numberedCaption "FigureCaption" capterm "Illustration" id' caption -numberedCaption :: String -> String -> String -> Int -> Doc -> Doc+numberedCaption :: Text -> Text -> Text -> Int -> Doc Text -> Doc Text numberedCaption style term name num caption =-    let t = text term+    let t = text $ T.unpack term         r = num - 1-        s = inTags False "text:sequence" [ ("text:ref-name", "ref" ++ name ++ show r),+        s = inTags False "text:sequence" [ ("text:ref-name", "ref" <> name <> tshow r),                                            ("text:name", name),-                                           ("text:formula", "ooow:" ++ name ++ "+1"),+                                           ("text:formula", "ooow:" <> name <> "+1"),                                            ("style:num-format", "1") ] $ text $ show num         c = text ": "     in inParagraphTagsWithStyle style $ hcat [ t, text " ", s, c, caption ] -unNumberedCaption :: Monad m => String -> Doc -> OD m Doc+unNumberedCaption :: Monad m => Text -> Doc Text -> OD m (Doc Text) unNumberedCaption style caption = return $ inParagraphTagsWithStyle style caption  colHeadsToOpenDocument :: PandocMonad m-                       => WriterOptions -> [String] -> [[Block]]-                       -> OD m Doc+                       => WriterOptions -> [Text] -> [[Block]]+                       -> OD m (Doc Text) colHeadsToOpenDocument o ns hs =     inTagsIndented "table:table-header-rows" . inTagsIndented "table:table-row" . vcat <$>     mapM (tableItemToOpenDocument o "TableHeaderRowCell") (zip ns hs)  tableRowToOpenDocument :: PandocMonad m-                       => WriterOptions -> [String] -> [[Block]]-                       -> OD m Doc+                       => WriterOptions -> [Text] -> [[Block]]+                       -> OD m (Doc Text) tableRowToOpenDocument o ns cs =     inTagsIndented "table:table-row" . vcat <$>     mapM (tableItemToOpenDocument o "TableRowCell") (zip ns cs)  tableItemToOpenDocument :: PandocMonad m-                        => WriterOptions -> String -> (String,[Block])-                        -> OD m Doc+                        => WriterOptions -> Text -> (Text,[Block])+                        -> OD m (Doc Text) tableItemToOpenDocument o s (n,i) =   let a = [ ("table:style-name" , s )           , ("office:value-type", "string"     )@@ -468,10 +476,10 @@       withParagraphStyle o n (map plainToPara i)  -- | Convert a list of inline elements to OpenDocument.-inlinesToOpenDocument :: PandocMonad m => WriterOptions -> [Inline] -> OD m Doc+inlinesToOpenDocument :: PandocMonad m => WriterOptions -> [Inline] -> OD m (Doc Text) inlinesToOpenDocument o l = hcat <$> toChunks o l -toChunks :: PandocMonad m => WriterOptions -> [Inline] -> OD m [Doc]+toChunks :: PandocMonad m => WriterOptions -> [Inline] -> OD m [Doc Text] toChunks _ [] = return [] toChunks o (x : xs)   | isChunkable x = do@@ -492,7 +500,7 @@ isChunkable _         = False  -- | Convert an inline element to OpenDocument.-inlineToOpenDocument :: PandocMonad m => WriterOptions -> Inline -> OD m Doc+inlineToOpenDocument :: PandocMonad m => WriterOptions -> Inline -> OD m (Doc Text) inlineToOpenDocument o ils   = case ils of     Space         -> return space@@ -515,7 +523,7 @@                          inlinesToOpenDocument o     Cite      _ l -> inlinesToOpenDocument o l     RawInline f s -> if f == Format "opendocument"-                       then return $ text s+                       then return $ text $ T.unpack s                        else do                          report $ InlineNotRendered ils                          return empty@@ -539,7 +547,7 @@                    getDims (("rel-height", w):xs) = ("style:rel-height", w) : getDims xs                    getDims (_:xs) =                             getDims xs                return $ inTags False "draw:frame"-                        (("draw:name", "img" ++ show id') : getDims kvs) $+                        (("draw:name", "img" <> tshow id') : getDims kvs) $                      selfClosingTag "draw:image" [ ("xlink:href"   , s       )                                                  , ("xlink:type"   , "simple")                                                  , ("xlink:show"   , "embed" )@@ -547,7 +555,7 @@       mkNote     l = do         n <- length <$> gets stNotes         let footNote t = inTags False "text:note"-                         [ ("text:id"        , "ftn" ++ show n)+                         [ ("text:id"        , "ftn" <> tshow n)                          , ("text:note-class", "footnote"     )] $                          inTagsSimple "text:note-citation" (text . show $ n + 1) <>                          inTagsSimple "text:note-body" t@@ -555,20 +563,20 @@         addNote nn         return nn -bulletListStyle :: PandocMonad m => Int -> OD m (Int,(Int,[Doc]))+bulletListStyle :: PandocMonad m => Int -> OD m (Int,(Int,[Doc Text])) bulletListStyle l = do   let doStyles  i = inTags True "text:list-level-style-bullet"-                    [ ("text:level"      , show (i + 1)       )-                    , ("text:style-name" , "Bullet_20_Symbols")-                    , ("style:num-suffix", "."                )-                    , ("text:bullet-char", [bulletList !! i]  )+                    [ ("text:level"      , tshow (i + 1))+                    , ("text:style-name" , "Bullet_20_Symbols"  )+                    , ("style:num-suffix", "."                  )+                    , ("text:bullet-char", T.singleton (bulletList !! i))                     ] (listLevelStyle (1 + i))       bulletList  = map chr $ cycle [8226,9702,9642]       listElStyle = map doStyles [0..9]   pn <- paraListStyle l   return (pn, (l, listElStyle)) -orderedListLevelStyle :: ListAttributes -> (Int, [Doc]) -> (Int,[Doc])+orderedListLevelStyle :: ListAttributes -> (Int, [Doc Text]) -> (Int,[Doc Text]) orderedListLevelStyle (s,n, d) (l,ls) =     let suffix    = case d of                       OneParen  -> [("style:num-suffix", ")")]@@ -582,16 +590,16 @@                       LowerRoman -> "i"                       _          -> "1"         listStyle = inTags True "text:list-level-style-number"-                    ([ ("text:level"      , show $ 1 + length ls  )+                    ([ ("text:level"      , tshow $ 1 + length ls )                      , ("text:style-name" , "Numbering_20_Symbols")                      , ("style:num-format", format                )-                     , ("text:start-value", show s                )+                     , ("text:start-value", tshow s               )                      ] ++ suffix) (listLevelStyle (1 + length ls))     in  (l, ls ++ [listStyle]) -listLevelStyle :: Int -> Doc+listLevelStyle :: Int -> Doc Text listLevelStyle i =-    let indent = show (0.25 + (0.25 * fromIntegral i :: Double)) in+    let indent = tshow (0.25 + (0.25 * fromIntegral i :: Double)) in     inTags True "style:list-level-properties"                        [ ("text:list-level-position-and-space-mode",                           "label-alignment")@@ -599,27 +607,27 @@                        ] $        selfClosingTag "style:list-level-label-alignment"                       [ ("text:label-followed-by", "listtab")-                      , ("text:list-tab-stop-position", indent ++ "in")+                      , ("text:list-tab-stop-position", indent <> "in")                       , ("fo:text-indent", "-0.25in")-                      , ("fo:margin-left", indent ++ "in")+                      , ("fo:margin-left", indent <> "in")                       ] -tableStyle :: Int -> [(Char,Double)] -> Doc+tableStyle :: Int -> [(Char,Double)] -> Doc Text tableStyle num wcs =-    let tableId        = "Table" ++ show (num + 1)+    let tableId        = "Table" <> tshow (num + 1)         table          = inTags True "style:style"                          [("style:name", tableId)                          ,("style:family", "table")] $                          selfClosingTag "style:table-properties"                          [("table:align"    , "center")]         colStyle (c,0) = selfClosingTag "style:style"-                         [ ("style:name"  , tableId ++ "." ++ [c])+                         [ ("style:name"  , tableId <> "." <> T.singleton c)                          , ("style:family", "table-column"       )]         colStyle (c,w) = inTags True "style:style"-                         [ ("style:name"  , tableId ++ "." ++ [c])+                         [ ("style:name"  , tableId <> "." <> T.singleton c)                          , ("style:family", "table-column"       )] $                          selfClosingTag "style:table-column-properties"-                         [("style:rel-column-width", printf "%d*" (floor $ w * 65535 :: Integer))]+                         [("style:rel-column-width", T.pack $ printf "%d*" (floor $ w * 65535 :: Integer))]         headerRowCellStyle = inTags True "style:style"                          [ ("style:name"  , "TableHeaderRowCell")                          , ("style:family", "table-cell"    )] $@@ -636,15 +644,15 @@         columnStyles   = map colStyle wcs     in cellStyles $$ table $$ vcat columnStyles -paraStyle :: PandocMonad m => [(String,String)] -> OD m Int+paraStyle :: PandocMonad m => [(Text,Text)] -> OD m Int paraStyle attrs = do   pn <- (+)   1 . length       <$> gets stParaStyles   i  <- (*) (0.5 :: Double) . fromIntegral <$> gets stIndentPara   b  <- gets stInDefinition   t  <- gets stTight-  let styleAttr = [ ("style:name"             , "P" ++ show pn)+  let styleAttr = [ ("style:name"             , "P" <> tshow pn)                   , ("style:family"           , "paragraph"   )]-      indentVal = flip (++) "in" . show $ if b then max 0.5 i else i+      indentVal = flip (<>) "in" . tshow $ if b then max 0.5 i else i       tight     = if t then [ ("fo:margin-top"          , "0in"    )                             , ("fo:margin-bottom"       , "0in"    )]                        else []@@ -654,30 +662,30 @@                            , ("fo:text-indent"         , "0in"    )                            , ("style:auto-text-indent" , "false"  )]                       else []-      attributes = indent ++ tight+      attributes = indent <> tight       paraProps = if null attributes                      then mempty                      else selfClosingTag                              "style:paragraph-properties" attributes-  addParaStyle $ inTags True "style:style" (styleAttr ++ attrs) paraProps+  addParaStyle $ inTags True "style:style" (styleAttr <> attrs) paraProps   return pn  paraListStyle :: PandocMonad m => Int -> OD m Int paraListStyle l = paraStyle   [("style:parent-style-name","Text_20_body")-  ,("style:list-style-name", "L" ++ show l )]+  ,("style:list-style-name", "L" <> tshow l)] -paraTableStyles :: String -> Int -> [Alignment] -> [(String, Doc)]+paraTableStyles :: Text -> Int -> [Alignment] -> [(Text, Doc Text)] paraTableStyles _ _ [] = [] paraTableStyles t s (a:xs)     | AlignRight  <- a = (         pName s, res s "end"   ) : paraTableStyles t (s + 1) xs     | AlignCenter <- a = (         pName s, res s "center") : paraTableStyles t (s + 1) xs-    | otherwise        = ("Table_20_" ++ t, empty         ) : paraTableStyles t  s      xs-    where pName sn = "P" ++ show (sn + 1)+    | otherwise        = ("Table_20_" <> t, empty         ) : paraTableStyles t  s      xs+    where pName sn = "P" <> tshow (sn + 1)           res sn x = inTags True "style:style"                      [ ("style:name"             , pName sn        )                      , ("style:family"           , "paragraph"     )-                     , ("style:parent-style-name", "Table_20_" ++ t)] $+                     , ("style:parent-style-name", "Table_20_" <> t)] $                      selfClosingTag "style:paragraph-properties"                      [ ("fo:text-align", x)                      , ("style:justify-single-word", "false")]@@ -692,25 +700,27 @@                | Language Lang                deriving ( Eq,Ord ) -textStyleAttr :: TextStyle -> [(String,String)]-textStyleAttr s-    | Italic <- s = [("fo:font-style"                ,"italic"    )-                    ,("style:font-style-asian"       ,"italic"    )-                    ,("style:font-style-complex"     ,"italic"    )]-    | Bold   <- s = [("fo:font-weight"               ,"bold"      )-                    ,("style:font-weight-asian"      ,"bold"      )-                    ,("style:font-weight-complex"    ,"bold"      )]-    | Strike <- s = [("style:text-line-through-style", "solid"    )]-    | Sub    <- s = [("style:text-position"          ,"sub 58%"   )]-    | Sup    <- s = [("style:text-position"          ,"super 58%" )]-    | SmallC <- s = [("fo:font-variant"              ,"small-caps")]-    | Pre    <- s = [("style:font-name"              ,"Courier New")-                    ,("style:font-name-asian"        ,"Courier New")-                    ,("style:font-name-complex"      ,"Courier New")]+textStyleAttr :: Map.Map Text Text+              -> TextStyle+              -> Map.Map Text Text+textStyleAttr m s+    | Italic <- s = Map.insert "fo:font-style" "italic" .+                    Map.insert "style:font-style-asian" "italic" .+                    Map.insert "style:font-style-complex" "italic" $ m+    | Bold   <- s = Map.insert "fo:font-weight" "bold" .+                    Map.insert "style:font-weight-asian" "bold" .+                    Map.insert "style:font-weight-complex" "bold" $ m+    | Strike <- s = Map.insert "style:text-line-through-style" "solid" m+    | Sub    <- s = Map.insert "style:text-position" "sub 58%" m+    | Sup    <- s = Map.insert "style:text-position" "super 58%" m+    | SmallC <- s = Map.insert "fo:font-variant" "small-caps" m+    | Pre    <- s = Map.insert "style:font-name" "Courier New" .+                    Map.insert "style:font-name-asian" "Courier New" .+                    Map.insert "style:font-name-complex" "Courier New" $ m     | Language lang <- s-                  = [("fo:language"                  ,langLanguage lang)-                    ,("fo:country"                   ,langRegion lang)]-    | otherwise   = []+                  = Map.insert "fo:language" (langLanguage lang) .+                    Map.insert "fo:country" (langRegion lang) $ m+    | otherwise   = m  withLangFromAttr :: PandocMonad m => Attr -> OD m a -> OD m a withLangFromAttr (_,_,kvs) action =
src/Text/Pandoc/Writers/Org.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Writers.Org-  Copyright    : © 2010-2015 Puneeth Chaganti <punchagan@gmail.com>+   Copyright   : © 2010-2015 Puneeth Chaganti <punchagan@gmail.com>                    2010-2019 John MacFarlane <jgm@berkeley.edu>                    2016-2019 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>    License     : GNU GPL, version 2 or above@@ -18,16 +18,17 @@ module Text.Pandoc.Writers.Org (writeOrg) where import Prelude import Control.Monad.State.Strict-import Data.Char (isAlphaNum, toLower)-import Data.List (intersect, intersperse, isPrefixOf, partition, transpose)+import Data.Char (isAlphaNum)+import Data.List (intersect, intersperse, partition, transpose) import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared  data WriterState =@@ -53,37 +54,36 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  metadata <- metaToJSON opts-               (fmap render' . blockListToOrg)-               (fmap render' . inlineListToOrg)+  metadata <- metaToContext opts+               blockListToOrg+               (fmap chomp . inlineListToOrg)                meta   body <- blockListToOrg blocks   notes <- gets (reverse . stNotes) >>= notesToOrg   hasMath <- gets stHasMath-  let main = render colwidth . foldl ($+$) empty $ [body, notes]+  let main = body $+$ notes   let context = defField "body" main               . defField "math" hasMath               $ metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Return Org representation of notes.-notesToOrg :: PandocMonad m => [[Block]] -> Org m Doc+notesToOrg :: PandocMonad m => [[Block]] -> Org m (Doc Text) notesToOrg notes =   vsep <$> zipWithM noteToOrg [1..] notes  -- | Return Org representation of a note.-noteToOrg :: PandocMonad m => Int -> [Block] -> Org m Doc+noteToOrg :: PandocMonad m => Int -> [Block] -> Org m (Doc Text) noteToOrg num note = do   contents <- blockListToOrg note   let marker = "[fn:" ++ show num ++ "] "   return $ hang (length marker) (text marker) contents  -- | Escape special characters for Org.-escapeString :: String -> String+escapeString :: Text -> Text escapeString = escapeStringUsing $                [ ('\x2014',"---")                , ('\x2013',"--")@@ -98,14 +98,14 @@ -- | Convert Pandoc block element to Org. blockToOrg :: PandocMonad m            => Block         -- ^ Block element-           -> Org m Doc+           -> Org m (Doc Text) blockToOrg Null = return empty blockToOrg (Div (_,classes@(cls:_),kvs) bs) | "drawer" `elem` classes = do   contents <- blockListToOrg bs-  let drawerNameTag = ":" <> text cls <> ":"+  let drawerNameTag = ":" <> literal cls <> ":"   let keys = vcat $ map (\(k,v) ->-                       ":" <> text k <> ":"-                       <> space <> text v) kvs+                       ":" <> literal k <> ":"+                       <> space <> literal v) kvs   let drawerEndTag = text ":END:"   return $ drawerNameTag $$ cr $$ keys $$            blankline $$ contents $$@@ -116,28 +116,29 @@   -- if one class looks like the name of a greater block then output as such:   -- The ID, if present, is added via the #+NAME keyword; other classes and   -- key-value pairs are kept as #+ATTR_HTML attributes.-  let isGreaterBlockClass = (`elem` ["center", "quote"]) . map toLower+  let isGreaterBlockClass = (`elem` ["center", "quote"]) . T.toLower       (blockTypeCand, classes') = partition isGreaterBlockClass classes   return $ case blockTypeCand of     (blockType:classes'') ->       blankline $$ attrHtml (ident, classes'' <> classes', kv) $$-      "#+BEGIN_" <> text blockType $$ contents $$-      "#+END_" <> text blockType $$ blankline+      "#+BEGIN_" <> literal blockType $$ contents $$+      "#+END_" <> literal blockType $$ blankline     _                     ->       -- fallback with id: add id as an anchor if present, discard classes and       -- key-value pairs, unwrap the content.-      let contents' = if not (null ident)-                      then "<<" <> text ident <> ">>" $$ contents+      let contents' = if not (T.null ident)+                      then "<<" <> literal ident <> ">>" $$ contents                       else contents       in blankline $$ contents' $$ blankline blockToOrg (Plain inlines) = inlineListToOrg inlines -- title beginning with fig: indicates that the image is a figure-blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do-  capt <- if null txt-             then return empty-             else ("#+CAPTION: " <>) `fmap` inlineListToOrg txt-  img <- inlineToOrg (Image attr txt (src,tit))-  return $ capt $$ img $$ blankline+blockToOrg (Para [Image attr txt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt = do+      capt <- if null txt+              then return empty+              else ("#+CAPTION: " <>) `fmap` inlineListToOrg txt+      img <- inlineToOrg (Image attr txt (src,tit))+      return $ capt $$ img $$ blankline blockToOrg (Para inlines) = do   contents <- inlineListToOrg inlines   return $ contents <> blankline@@ -154,9 +155,9 @@            nest 2 contents $$ "#+END_VERSE" <> blankline blockToOrg (RawBlock "html" str) =   return $ blankline $$ "#+BEGIN_HTML" $$-           nest 2 (text str) $$ "#+END_HTML" $$ blankline+           nest 2 (literal str) $$ "#+END_HTML" $$ blankline blockToOrg b@(RawBlock f str)-  | isRawFormat f = return $ text str+  | isRawFormat f = return $ literal str   | otherwise     = do       report $ BlockNotRendered b       return empty@@ -169,17 +170,17 @@                   else cr <> nest (level + 1) (propertiesDrawer attr)   return $ headerStr <> " " <> contents <> drawerStr <> blankline blockToOrg (CodeBlock (_,classes,kvs) str) = do-  let startnum = maybe "" (\x -> ' ' : trimr x) $ lookup "startFrom" kvs+  let startnum = maybe "" (\x -> " " <> trimr x) $ lookup "startFrom" kvs   let numberlines = if "numberLines" `elem` classes                       then if "continuedSourceBlock" `elem` classes-                             then " +n" ++ startnum-                             else " -n" ++ startnum+                             then " +n" <> startnum+                             else " -n" <> startnum                       else ""   let at = map pandocLangToOrg classes `intersect` orgLangIdentifiers   let (beg, end) = case at of-                      []    -> ("#+BEGIN_EXAMPLE" ++ numberlines, "#+END_EXAMPLE")-                      (x:_) -> ("#+BEGIN_SRC " ++ x ++ numberlines, "#+END_SRC")-  return $ text beg $$ nest 2 (text str) $$ text end $$ blankline+                      []    -> ("#+BEGIN_EXAMPLE" <> numberlines, "#+END_EXAMPLE")+                      (x:_) -> ("#+BEGIN_SRC " <> x <> numberlines, "#+END_SRC")+  return $ literal beg $$ nest 2 (literal str) $$ text end $$ blankline blockToOrg (BlockQuote blocks) = do   contents <- blockListToOrg blocks   return $ blankline $$ "#+BEGIN_QUOTE" $$@@ -197,10 +198,9 @@        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 (1 : map height blocks)-              sep'   = lblock 3 $ vcat (replicate h (text " | "))-              beg    = lblock 2 $ vcat (replicate h (text "| "))-              end    = lblock 2 $ vcat (replicate h (text " |"))+        where sep'   = vfill " | "+              beg    = vfill "| "+              end    = vfill " |"               middle = hcat $ intersperse sep' blocks   let makeRow = hpipeBlocks . zipWith lblock widthsInChars   let head' = makeRow headers'@@ -218,82 +218,96 @@ blockToOrg (BulletList items) = do   contents <- mapM bulletListItemToOrg items   -- ensure that sublists have preceding blank line-  return $ blankline $+$ vcat contents $$ blankline+  return $ blankline $$+           (if isTightList items then vcat else vsep) 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+  let maxMarkerLength = maximum $ map T.length markers+  let markers' = map (\m -> let s = maxMarkerLength - T.length m+                            in  m <> T.replicate s " ") markers   contents <- zipWithM orderedListItemToOrg markers' items   -- ensure that sublists have preceding blank line-  return $ blankline $$ vcat contents $$ blankline+  return $ blankline $$+           (if isTightList items then vcat else vsep) contents $$+           blankline blockToOrg (DefinitionList items) = do   contents <- mapM definitionListItemToOrg items   return $ vcat contents $$ blankline  -- | Convert bullet list item (list of blocks) to Org.-bulletListItemToOrg :: PandocMonad m => [Block] -> Org m Doc+bulletListItemToOrg :: PandocMonad m => [Block] -> Org m (Doc Text) bulletListItemToOrg items = do   contents <- blockListToOrg items-  return $ hang 2 "- " (contents <> cr)+  return $ hang 2 "- " contents $$+          if endsWithPlain items+             then cr+             else blankline + -- | Convert ordered list item (a list of blocks) to Org. orderedListItemToOrg :: PandocMonad m-                     => String   -- ^ marker for list item+                     => Text   -- ^ marker for list item                      -> [Block]  -- ^ list item (list of blocks)-                     -> Org m Doc+                     -> Org m (Doc Text) orderedListItemToOrg marker items = do   contents <- blockListToOrg items-  return $ hang (length marker + 1) (text marker <> space) (contents <> cr)+  return $ hang (T.length marker + 1) (literal marker <> space) contents $$+          if endsWithPlain items+             then cr+             else blankline  -- | Convert definition list item (label, list of blocks) to Org. definitionListItemToOrg :: PandocMonad m-                        => ([Inline], [[Block]]) -> Org m Doc+                        => ([Inline], [[Block]]) -> Org m (Doc Text) definitionListItemToOrg (label, defs) = do   label' <- inlineListToOrg label   contents <- vcat <$> mapM blockListToOrg defs-  return . hang 2 "- " $ label' <> " :: " <> (contents <> cr)+  return $ hang 2 "- " (label' <> " :: " <> contents) $$+      if isTightList defs+         then cr+         else blankline  -- | Convert list of key/value pairs to Org :PROPERTIES: drawer.-propertiesDrawer :: Attr -> Doc+propertiesDrawer :: Attr -> Doc Text propertiesDrawer (ident, classes, kv) =   let     drawerStart = text ":PROPERTIES:"     drawerEnd   = text ":END:"-    kv'  = if classes == mempty then kv  else ("CLASS", unwords classes):kv+    kv'  = if classes == mempty then kv  else ("CLASS", T.unwords classes):kv     kv'' = if ident == mempty   then kv' else ("CUSTOM_ID", ident):kv'     properties = vcat $ map kvToOrgProperty kv''   in     drawerStart <> cr <> properties <> cr <> drawerEnd  where-   kvToOrgProperty :: (String, String) -> Doc+   kvToOrgProperty :: (Text, Text) -> Doc Text    kvToOrgProperty (key, value) =-     text ":" <> text key <> text ": " <> text value <> cr+     text ":" <> literal key <> text ": " <> literal value <> cr -attrHtml :: Attr -> Doc+attrHtml :: Attr -> Doc Text attrHtml (""   , []     , []) = mempty attrHtml (ident, classes, kvs) =   let-    name = if null ident then mempty else "#+NAME: " <> text ident <> cr+    name = if T.null ident then mempty else "#+NAME: " <> literal ident <> cr     keyword = "#+ATTR_HTML"-    classKv = ("class", unwords classes)+    classKv = ("class", T.unwords classes)     kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs)-  in name <> keyword <> ": " <> text (unwords kvStrings) <> cr+  in name <> keyword <> ": " <> literal (T.unwords kvStrings) <> cr  -- | Convert list of Pandoc block elements to Org. blockListToOrg :: PandocMonad m                => [Block]       -- ^ List of block elements-               -> Org m Doc+               -> Org m (Doc Text) blockListToOrg blocks = vcat <$> mapM blockToOrg blocks  -- | Convert list of Pandoc inline elements to Org. inlineListToOrg :: PandocMonad m                 => [Inline]-                -> Org m Doc+                -> Org m (Doc Text) inlineListToOrg lst = hcat <$> mapM inlineToOrg (fixMarkers lst)   where fixMarkers [] = []  -- prevent note refs and list markers from wrapping, see #4171         fixMarkers (Space : x : rest) | shouldFix x =@@ -308,9 +322,9 @@         shouldFix _ = False  -- | Convert Pandoc inline element to Org.-inlineToOrg :: PandocMonad m => Inline -> Org m Doc+inlineToOrg :: PandocMonad m => Inline -> Org m (Doc Text) inlineToOrg (Span (uid, [], []) []) =-  return $ "<<" <> text uid <> ">>"+  return $ "<<" <> literal uid <> ">>" inlineToOrg (Span _ lst) =   inlineListToOrg lst inlineToOrg (Emph lst) = do@@ -336,15 +350,15 @@   contents <- inlineListToOrg lst   return $ "\"" <> contents <> "\"" inlineToOrg (Cite _  lst) = inlineListToOrg lst-inlineToOrg (Code _ str) = return $ "=" <> text str <> "="-inlineToOrg (Str str) = return . text $ escapeString str+inlineToOrg (Code _ str) = return $ "=" <> literal str <> "="+inlineToOrg (Str str) = return . literal $ escapeString str inlineToOrg (Math t str) = do   modify $ \st -> st{ stHasMath = True }   return $ if t == InlineMath-              then "$" <> text str <> "$"-              else "$$" <> text str <> "$$"+              then "$" <> literal str <> "$"+              else "$$" <> literal str <> "$$" inlineToOrg il@(RawInline f str)-  | isRawFormat f = return $ text str+  | isRawFormat f = return $ literal str   | otherwise     = do       report $ InlineNotRendered il       return empty@@ -359,39 +373,38 @@ inlineToOrg (Link _ txt (src, _)) =   case txt of         [Str x] | escapeURI x == src ->  -- autolink-             return $ "[[" <> text (orgPath x) <> "]]"+             return $ "[[" <> literal (orgPath x) <> "]]"         _ -> do contents <- inlineListToOrg txt-                return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]"+                return $ "[[" <> literal (orgPath src) <> "][" <> contents <> "]]" inlineToOrg (Image _ _ (source, _)) =-  return $ "[[" <> text (orgPath source) <> "]]"+  return $ "[[" <> literal (orgPath source) <> "]]" inlineToOrg (Note contents) = do   -- add to notes in state   notes <- gets stNotes   modify $ \st -> st { stNotes = contents:notes }-  let ref = show $ length notes + 1-  return $ "[fn:" <> text ref <> "]"+  let ref = tshow $ length notes + 1+  return $ "[fn:" <> literal ref <> "]" -orgPath :: String -> String-orgPath src =-  case src of-    []      -> mempty         -- wiki link-    ('#':_) -> src            -- internal link-    _       | isUrl src      -> src-    _       | isFilePath src -> src-    _       -> "file:" <> src- where-   isFilePath :: String -> Bool-   isFilePath cs = any (`isPrefixOf` cs) ["/", "./", "../", "file:"]+orgPath :: Text -> Text+orgPath src = case T.uncons src of+  Nothing            -> ""             -- wiki link+  Just ('#', _)      -> src            -- internal link+  _ | isUrl src      -> src+  _ | isFilePath src -> src+  _                  -> "file:" <> src+  where+    isFilePath :: Text -> Bool+    isFilePath cs = any (`T.isPrefixOf` cs) ["/", "./", "../", "file:"] -   isUrl :: String -> Bool-   isUrl cs =-     let (scheme, path) = break (== ':') cs-     in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme-          && not (null path)+    isUrl :: Text -> Bool+    isUrl cs =+      let (scheme, path) = T.break (== ':') cs+      in T.all (\c -> isAlphaNum c || c `elemText` ".-") scheme+         && not (T.null path)  -- | Translate from pandoc's programming language identifiers to those used by -- org-mode.-pandocLangToOrg :: String -> String+pandocLangToOrg :: Text -> Text pandocLangToOrg cs =   case cs of     "c"          -> "C"@@ -402,7 +415,7 @@     _            -> cs  -- | List of language identifiers recognized by org-mode.-orgLangIdentifiers :: [String]+orgLangIdentifiers :: [Text] orgLangIdentifiers =   [ "asymptote", "awk", "C", "C++", "clojure", "css", "d", "ditaa", "dot"   , "calc", "emacs-lisp", "fortran", "gnuplot", "haskell", "java", "js"
src/Text/Pandoc/Writers/Powerpoint/Output.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE PatternGuards #-} {- |@@ -24,6 +25,7 @@ import Data.Char (toUpper) import Data.List (intercalate, stripPrefix, nub, union, isPrefixOf, intersperse) import Data.Default+import qualified Data.Text as T import Data.Time (formatTime, defaultTimeLocale) import Data.Time.Clock (UTCTime) import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds, posixSecondsToUTCTime)@@ -43,11 +45,20 @@ import Text.Pandoc.ImageSize import Control.Applicative ((<|>)) import System.FilePath.Glob+import Text.DocTemplates (FromContext(lookupContext)) import Text.TeXMath import Text.Pandoc.Writers.Math (convertMath) import Text.Pandoc.Writers.Powerpoint.Presentation import Skylighting (fromColor) +-- |The 'EMU' type is used to specify sizes in English Metric Units.+type EMU = Integer++-- |The 'pixelsToEmu' function converts a size in pixels to one+-- in English Metric Units. It assumes a DPI of 72.+pixelsToEmu :: Pixels -> EMU+pixelsToEmu = (12700 *)+ -- This populates the global ids map with images already in the -- template, so the ids won't be used by images introduced by the -- user.@@ -125,7 +136,7 @@                            , mInfoLocalId  :: Int                            , mInfoGlobalId :: Int                            , mInfoMimeType :: Maybe MimeType-                           , mInfoExt      :: Maybe String+                           , mInfoExt      :: Maybe T.Text                            , mInfoCaption  :: Bool                            } deriving (Show, Eq) @@ -148,12 +159,30 @@  -------------------------------------------------------------------- +findAttrText :: QName -> Element -> Maybe T.Text+findAttrText n = fmap T.pack . findAttr n++monospaceFont :: Monad m => P m T.Text+monospaceFont = do+  vars <- writerVariables <$> asks envOpts+  case lookupContext "monofont" vars of+    Just s -> return s+    Nothing -> return "Courier"++-- Kept as string for XML.Light+fontSizeAttributes :: Monad m => RunProps -> P m [(String, String)]+fontSizeAttributes RunProps { rPropForceSize = Just sz } =+  return [("sz", show $ sz * 100)]+fontSizeAttributes _ = return []+ copyFileToArchive :: PandocMonad m => Archive -> FilePath -> P m Archive copyFileToArchive arch fp = do   refArchive <- asks envRefArchive   distArchive <- asks envDistArchive   case findEntryByPath fp refArchive `mplus` findEntryByPath fp distArchive of-    Nothing -> fail $ fp ++ " missing in reference file"+    Nothing -> throwError $ PandocSomeError+                          $ T.pack+                          $ fp <> " missing in reference file"     Just e -> return $ addEntryToArchive e arch  alwaysInheritedPatterns :: [Pattern]@@ -172,7 +201,7 @@  -- We only look for these under special conditions contingentInheritedPatterns :: Presentation -> [Pattern]-contingentInheritedPatterns pres = [] +++contingentInheritedPatterns pres = [] <>   if presHasSpeakerNotes pres   then map compile [ "ppt/notesMasters/notesMaster*.xml"                    , "ppt/notesMasters/_rels/notesMaster*.xml.rels"@@ -183,7 +212,7 @@  inheritedPatterns :: Presentation -> [Pattern] inheritedPatterns pres =-  alwaysInheritedPatterns ++ contingentInheritedPatterns pres+  alwaysInheritedPatterns <> contingentInheritedPatterns pres  patternToFilePaths :: PandocMonad m => Pattern -> P m [FilePath] patternToFilePaths pat = do@@ -224,8 +253,8 @@   unless (null missingFiles)     (throwError $       PandocSomeError $-      "The following required files are missing:\n" ++-      (unlines $ map ("  " ++) missingFiles)+      "The following required files are missing:\n" <>+      (T.unlines $ map (T.pack . ("  " <>)) missingFiles)     )    newArch' <- foldM copyFileToArchive emptyArchive filePaths@@ -252,11 +281,11 @@   contentTypesEntry <- presentationToContentTypes p >>= contentTypesToEntry   -- fold everything into our inherited archive and return it.   return $ foldr addEntryToArchive newArch' $-    slideEntries ++-    slideRelEntries ++-    spkNotesEntries ++-    spkNotesRelEntries ++-    mediaEntries +++    slideEntries <>+    slideRelEntries <>+    spkNotesEntries <>+    spkNotesRelEntries <>+    mediaEntries <>     [contentTypesEntry, docPropsEntry, docCustomPropsEntry, relsEntry,      presEntry, presRelsEntry, viewPropsEntry] @@ -328,11 +357,11 @@   distArchive <- asks envDistArchive   parseXml refArchive distArchive layoutpath -shapeHasId :: NameSpaces -> String -> Element -> Bool+shapeHasId :: NameSpaces -> T.Text -> Element -> Bool shapeHasId ns ident element   | Just nvSpPr <- findChild (elemName ns "p" "nvSpPr") element   , Just cNvPr <- findChild (elemName ns "p" "cNvPr") nvSpPr-  , Just nm <- findAttr (QName "id" Nothing Nothing) cNvPr =+  , Just nm <- findAttrText (QName "id" Nothing Nothing) cNvPr =       nm == ident   | otherwise = False @@ -373,7 +402,7 @@   | otherwise = Nothing  -getMasterShapeDimensionsById :: String+getMasterShapeDimensionsById :: T.Text                              -> Element                              -> Maybe ((Integer, Integer), (Integer, Integer)) getMasterShapeDimensionsById ident master = do@@ -398,7 +427,7 @@         Nothing -> do let mbSz =                             findChild (elemName ns "p" "nvSpPr") sp >>=                             findChild (elemName ns "p" "cNvPr") >>=-                            findAttr (QName "id" Nothing Nothing) >>=+                            findAttrText (QName "id" Nothing Nothing) >>=                             flip getMasterShapeDimensionsById master                       case mbSz of                         Just sz' -> return sz'@@ -412,7 +441,7 @@ buildSpTree :: NameSpaces -> Element -> [Element] -> Element buildSpTree ns spTreeElem newShapes =   emptySpTreeElem { elContent = newContent }-  where newContent = elContent emptySpTreeElem ++ map Elem newShapes+  where newContent = elContent emptySpTreeElem <> map Elem newShapes         emptySpTreeElem = spTreeElem { elContent = filter fn (elContent spTreeElem) }         fn :: Content -> Bool         fn (Elem e) = isElem ns "p" "nvGrpSpPr" e ||@@ -482,8 +511,8 @@         [] -> 0         ids -> maximum ids -  (imgBytes, mbMt) <- P.fetchItem fp-  let imgExt = (mbMt >>= extensionFromMimeType >>= (\x -> return $ '.':x))+  (imgBytes, mbMt) <- P.fetchItem $ T.pack fp+  let imgExt = (mbMt >>= extensionFromMimeType >>= (\x -> return $ "." <> x))                <|>                case imageType imgBytes of                  Just Png  -> Just ".png"@@ -522,11 +551,11 @@ makeMediaEntry :: PandocMonad m => MediaInfo -> P m Entry makeMediaEntry mInfo = do   epochtime <- (floor . utcTimeToPOSIXSeconds) <$> asks envUTCTime-  (imgBytes, _) <- P.fetchItem (mInfoFilePath mInfo)+  (imgBytes, _) <- P.fetchItem (T.pack $ mInfoFilePath mInfo)   let ext = case mInfoExt mInfo of               Just e -> e               Nothing -> ""-  let fp = "ppt/media/image" ++ (show $ mInfoGlobalId mInfo) ++ ext+  let fp = "ppt/media/image" <> (show $ mInfoGlobalId mInfo) <> T.unpack ext   return $ toEntry fp epochtime $ BL.fromStrict imgBytes  makeMediaEntries :: PandocMonad m => P m [Entry]@@ -618,7 +647,7 @@   elements <- mapM paragraphToElement [para]   let ((x, y), (cx, cy)) = contentShapeDimensions   let txBody = mknode "p:txBody" [] $-               [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] ++ elements+               [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] <> elements   return $     mknode "p:sp" [] [ mknode "p:nvSpPr" []                        [ mknode "p:cNvPr" [("id","1"), ("name","TextBox 3")] ()@@ -651,7 +680,7 @@   (pageWidth, pageHeight) <- asks envPresentationSize   -- hasHeader <- asks envSlideHasHeader   let hasCaption = mInfoCaption mInfo-  (imgBytes, _) <- P.fetchItem (mInfoFilePath mInfo)+  (imgBytes, _) <- P.fetchItem (T.pack $ mInfoFilePath mInfo)   let (pxX, pxY) = case imageSize opts imgBytes of         Right sz -> sizeInPixels $ sz         Left _   -> sizeInPixels $ def@@ -683,14 +712,14 @@   cNvPr <- case picPropLink picProps of     Just link -> do idNum <- registerLink link                     return $ mknode "p:cNvPr" cNvPrAttr $-                      mknode "a:hlinkClick" [("r:id", "rId" ++ show idNum)] ()+                      mknode "a:hlinkClick" [("r:id", "rId" <> show idNum)] ()     Nothing   -> return $ mknode "p:cNvPr" cNvPrAttr ()   let nvPicPr  = mknode "p:nvPicPr" []                  [ cNvPr                  , cNvPicPr                  , mknode "p:nvPr" [] ()]   let blipFill = mknode "p:blipFill" []-                 [ mknode "a:blip" [("r:embed", "rId" ++ (show $ mInfoLocalId mInfo))] ()+                 [ mknode "a:blip" [("r:embed", "rId" <> (show $ mInfoLocalId mInfo))] ()                  , mknode "a:stretch" [] $                    mknode "a:fillRect" [] () ]   let xfrm =    mknode "a:xfrm" []@@ -721,29 +750,24 @@ paraElemToElements :: PandocMonad m => ParaElem -> P m [Element] paraElemToElements Break = return [mknode "a:br" [] ()] paraElemToElements (Run rpr s) = do-  let sizeAttrs = case rPropForceSize rpr of-                    Just n -> [("sz", (show $ n * 100))]-                    Nothing -> if rPropCode rpr-                               -- hardcoded size for code for now-                               then [("sz", "1800")]-                               else []-      attrs = sizeAttrs ++-        (if rPropBold rpr then [("b", "1")] else []) ++-        (if rPropItalics rpr then [("i", "1")] else []) ++-        (if rPropUnderline rpr then [("u", "sng")] else []) +++  sizeAttrs <- fontSizeAttributes rpr+  let attrs = sizeAttrs <>+        (if rPropBold rpr then [("b", "1")] else []) <>+        (if rPropItalics rpr then [("i", "1")] else []) <>+        (if rPropUnderline rpr then [("u", "sng")] else []) <>         (case rStrikethrough rpr of             Just NoStrike     -> [("strike", "noStrike")]             Just SingleStrike -> [("strike", "sngStrike")]             Just DoubleStrike -> [("strike", "dblStrike")]-            Nothing -> []) +++            Nothing -> []) <>         (case rBaseline rpr of             Just n -> [("baseline", show n)]-            Nothing -> []) +++            Nothing -> []) <>         (case rCap rpr of             Just NoCapitals -> [("cap", "none")]             Just SmallCapitals -> [("cap", "small")]             Just AllCapitals -> [("cap", "all")]-            Nothing -> []) +++            Nothing -> []) <>         []   linkProps <- case rLink rpr of                  Just link -> do@@ -754,14 +778,14 @@                    return $ case link of                      InternalTarget _ ->                        let linkAttrs =-                             [ ("r:id", "rId" ++ show idNum)+                             [ ("r:id", "rId" <> show idNum)                              , ("action", "ppaction://hlinksldjump")                              ]                        in [mknode "a:hlinkClick" linkAttrs ()]                      -- external                      ExternalTarget _ ->                        let linkAttrs =-                             [ ("r:id", "rId" ++ show idNum)+                             [ ("r:id", "rId" <> show idNum)                              ]                        in [mknode "a:hlinkClick" linkAttrs ()]                  Nothing -> return []@@ -773,12 +797,13 @@                                        ]                             _ -> []                         Nothing -> []+  codeFont <- monospaceFont   let codeContents = if rPropCode rpr-                     then [mknode "a:latin" [("typeface", "Courier")] ()]+                     then [mknode "a:latin" [("typeface", T.unpack codeFont)] ()]                      else []-  let propContents = linkProps ++ colorContents ++ codeContents+  let propContents = linkProps <> colorContents <> codeContents   return [mknode "a:r" [] [ mknode "a:rPr" attrs $ propContents-                          , mknode "a:t" [] s+                          , mknode "a:t" [] $ T.unpack s                           ]] paraElemToElements (MathElem mathType texStr) = do   res <- convertMath writeOMML mathType (unTeXString texStr)@@ -819,33 +844,37 @@ paragraphToElement :: PandocMonad m => Paragraph -> P m Element paragraphToElement par = do   let-    attrs = [("lvl", show $ pPropLevel $ paraProps par)] +++    attrs = [("lvl", show $ pPropLevel $ paraProps par)] <>             (case pPropMarginLeft (paraProps par) of-               Just px -> [("marL", show $ 12700 * px), ("indent", "0")]+               Just px -> [("marL", show $ pixelsToEmu px)]                Nothing -> []-            ) +++            ) <>+            (case pPropIndent (paraProps par) of+               Just px -> [("indent", show $ pixelsToEmu px)]+               Nothing -> []+            ) <>             (case pPropAlign (paraProps par) of                Just AlgnLeft -> [("algn", "l")]                Just AlgnRight -> [("algn", "r")]                Just AlgnCenter -> [("algn", "ctr")]                Nothing -> []             )-    props = [] +++    props = [] <>             (case pPropSpaceBefore $ paraProps par of                Just px -> [mknode "a:spcBef" [] [                               mknode "a:spcPts" [("val", show $ 100 * px)] ()                               ]                           ]                Nothing -> []-            ) +++            ) <>             (case pPropBullet $ paraProps par of                Just Bullet -> []                Just (AutoNumbering attrs') ->-                 [mknode "a:buAutoNum" [("type", autoNumberingToType attrs')] ()]+                 [mknode "a:buAutoNum" (autoNumAttrs attrs') ()]                Nothing -> [mknode "a:buNone" [] ()]             )   paras <- concat <$> mapM paraElemToElements (paraElems par)-  return $ mknode "a:p" [] $ [mknode "a:pPr" attrs props] ++ paras+  return $ mknode "a:p" [] $ [mknode "a:pPr" attrs props] <> paras  shapeToElement :: PandocMonad m => Element -> Shape -> P m Element shapeToElement layout (TextBox paras)@@ -855,7 +884,7 @@       sp <- getContentShape ns spTree       elements <- mapM paragraphToElement paras       let txBody = mknode "p:txBody" [] $-                   [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] ++ elements+                   [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] <> elements           emptySpPr = mknode "p:spPr" [] ()       return $         surroundWithMathAlternate $@@ -909,19 +938,19 @@           [ mknode "a:off" [("x", show $ 12700 * x), ("y", show $ 12700 * y)] ()           , mknode "a:ext" [("cx", show $ 12700 * cx), ("cy", show $ 12700 * cy)] ()           ]-        ] ++ elements+        ] <> elements    if (not $ null caption)     then do capElt <- createCaption ((x, y), (cx, cytmp)) caption             return [graphicFrameElts, capElt]     else return [graphicFrameElts] -getDefaultTableStyle :: PandocMonad m => P m (Maybe String)+getDefaultTableStyle :: PandocMonad m => P m (Maybe T.Text) getDefaultTableStyle = do   refArchive <- asks envRefArchive   distArchive <- asks envDistArchive   tblStyleLst <- parseXml refArchive distArchive "ppt/tableStyles.xml"-  return $ findAttr (QName "def" Nothing Nothing) tblStyleLst+  return $ findAttrText (QName "def" Nothing Nothing) tblStyleLst  graphicToElement :: PandocMonad m => Integer -> Graphic -> P m Element graphicToElement tableWidth (Tbl tblPr hdrCells rows) = do@@ -946,7 +975,7 @@              [mknode "a:txBody" [] $                ([ mknode "a:bodyPr" [] ()                 , mknode "a:lstStyle" [] ()]-                 ++ elements')]+                 <> elements')]   headers' <- mapM cellToOpenXML hdrCells   rows' <- mapM (mapM cellToOpenXML) rows   let borderProps = mknode "a:tcPr" [] ()@@ -954,7 +983,7 @@   let mkcell border contents = mknode "a:tc" []                             $ (if null contents                                then emptyCell-                               else contents) ++ [ borderProps | border ]+                               else contents) <> [ borderProps | border ]   let mkrow border cells = mknode "a:tr" [("h", "0")] $ map (mkcell border) cells    let mkgridcol w = mknode "a:gridCol"@@ -967,7 +996,7 @@                  , ("bandRow", if tblPrBandRow tblPr then "1" else "0")                  ] (case mbDefTblStyle of                       Nothing -> []-                      Just sty -> [mknode "a:tableStyleId" [] sty])+                      Just sty -> [mknode "a:tableStyleId" [] $ T.unpack sty])    return $ mknode "a:graphic" [] $     [mknode "a:graphicData" [("uri", "http://schemas.openxmlformats.org/drawingml/2006/table")] $@@ -977,7 +1006,7 @@                                then []                                else map mkgridcol colWidths)       ]-      ++ [ mkrow True headers' | hasHeader ] ++ map (mkrow False) rows'+      <> [ mkrow True headers' | hasHeader ] <> map (mkrow False) rows'      ]     ] @@ -985,7 +1014,7 @@ -- We get the shape by placeholder type. If there is NO type, it -- defaults to a content placeholder. -data PHType = PHType String | ObjType+data PHType = PHType T.Text | ObjType   deriving (Show, Eq)  findPHType :: NameSpaces -> Element -> PHType -> Bool@@ -1000,7 +1029,7 @@         -- if it's a named PHType, we want to check that the attribute         -- value matches.         Just phElem | (PHType tp) <- phType ->-                        case findAttr (QName "type" Nothing Nothing) phElem of+                        case findAttrText (QName "type" Nothing Nothing) phElem of                           Just tp' -> tp == tp'                           Nothing -> False         -- if it's an ObjType, we want to check that there is NO@@ -1039,7 +1068,7 @@       let hdrPara = Paragraph def paraElements       element <- paragraphToElement hdrPara       let txBody = mknode "p:txBody" [] $-                   [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] +++                   [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] <>                    [element]       return $ replaceNamedChildren ns "p" "txBody" [txBody] sp   -- XXX: TODO@@ -1057,7 +1086,7 @@       contentElements <- local                          (\env -> env {envContentType = NormalContent})                          (shapesToElements layout shapes)-      return $ buildSpTree ns spTree (hdrShapeElements ++ contentElements)+      return $ buildSpTree ns spTree (hdrShapeElements <> contentElements) contentToElement _ _ _ = return $ mknode "p:sp" [] ()  twoColumnToElement :: PandocMonad m => Element -> [ParaElem] -> [Shape] -> [Shape] -> P m Element@@ -1077,7 +1106,7 @@                           (shapesToElements layout shapesR)       -- let contentElementsL' = map (setIdx ns "1") contentElementsL       --     contentElementsR' = map (setIdx ns "2") contentElementsR-      return $ buildSpTree ns spTree (hdrShapeElements ++ contentElementsL ++ contentElementsR)+      return $ buildSpTree ns spTree (hdrShapeElements <> contentElementsL <> contentElementsR) twoColumnToElement _ _ _ _= return $ mknode "p:sp" [] ()  @@ -1109,7 +1138,7 @@       dateShapeElements <- if null dateElems                            then return []                            else sequence [nonBodyTextToElement layout [PHType "dt"] dateElems]-      return $ buildSpTree ns spTree (titleShapeElements ++ subtitleShapeElements ++ dateShapeElements)+      return $ buildSpTree ns spTree (titleShapeElements <> subtitleShapeElements <> dateShapeElements) metadataToElement _ _ _ _ _ = return $ mknode "p:sp" [] ()  slideToElement :: PandocMonad m => Slide -> P m Element@@ -1162,7 +1191,7 @@   distArchive <- asks envDistArchive   parseXml refArchive distArchive "ppt/notesMasters/notesMaster1.xml" -getSlideNumberFieldId :: PandocMonad m => Element -> P m String+getSlideNumberFieldId :: PandocMonad m => Element -> P m T.Text getSlideNumberFieldId notesMaster   | ns <- elemToNameSpaces notesMaster   , Just cSld <- findChild (elemName ns "p" "cSld") notesMaster@@ -1171,7 +1200,7 @@   , Just txBody <- findChild (elemName ns "p" "txBody") sp   , Just p <- findChild (elemName ns "a" "p") txBody   , Just fld <- findChild (elemName ns "a" "fld") p-  , Just fldId <- findAttr (QName "id" Nothing Nothing) fld =+  , Just fldId <- findAttrText (QName "id" Nothing Nothing) fld =       return fldId   | otherwise = throwError $                 PandocSomeError $@@ -1212,7 +1241,7 @@ speakerNotesBody paras = do   elements <- mapM paragraphToElement $ spaceParas $ map removeParaLinks paras   let txBody = mknode "p:txBody" [] $-               [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] ++ elements+               [mknode "a:bodyPr" [] (), mknode "a:lstStyle" [] ()] <> elements   return $     mknode "p:sp" [] $     [ mknode "p:nvSpPr" [] $@@ -1228,7 +1257,7 @@     , txBody     ] -speakerNotesSlideNumber :: Int -> String -> Element+speakerNotesSlideNumber :: Int -> T.Text -> Element speakerNotesSlideNumber pgNum fieldId =   mknode "p:sp" [] $   [ mknode "p:nvSpPr" [] $@@ -1249,7 +1278,7 @@     [ mknode "a:bodyPr" [] ()     , mknode "a:lstStyle" [] ()     , mknode "a:p" [] $-      [ mknode "a:fld" [ ("id", fieldId)+      [ mknode "a:fld" [ ("id", T.unpack fieldId)                        , ("type", "slidenum")                        ]         [ mknode "a:rPr" [("lang", "en-US")] ()@@ -1305,24 +1334,24 @@     Just n -> return n     Nothing -> throwError $                PandocShouldNeverHappenError $-               "Slide Id " ++ (show sldId) ++ " not found."+               "Slide Id " <> T.pack (show sldId) <> " not found."  slideNum :: PandocMonad m => Slide -> P m Int slideNum slide = getSlideIdNum $ slideId slide  idNumToFilePath :: Int -> FilePath-idNumToFilePath idNum = "slide" ++ (show $ idNum) ++ ".xml"+idNumToFilePath idNum = "slide" <> (show $ idNum) <> ".xml"  slideToFilePath :: PandocMonad m => Slide -> P m FilePath slideToFilePath slide = do   idNum <- slideNum slide-  return $ "slide" ++ (show $ idNum) ++ ".xml"+  return $ "slide" <> (show $ idNum) <> ".xml" -slideToRelId :: PandocMonad m => Slide -> P m String+slideToRelId :: PandocMonad m => Slide -> P m T.Text slideToRelId slide = do   n <- slideNum slide   offset <- asks envSlideIdOffset-  return $ "rId" ++ (show $ n + offset)+  return $ "rId" <> T.pack (show $ n + offset)   data Relationship = Relationship { relId :: Int@@ -1338,7 +1367,7 @@          num <- case reads numStr :: [(Int, String)] of            (n, _) : _ -> Just n            []         -> Nothing-         type' <- findAttr (QName "Type" Nothing Nothing) element+         type' <- findAttrText (QName "Type" Nothing Nothing) element          target <- findAttr (QName "Target" Nothing Nothing) element          return $ Relationship num type' target   | otherwise = Nothing@@ -1348,7 +1377,7 @@   idNum <- slideNum slide   n <- asks envSlideIdOffset   let rId = idNum + n-      fp = "slides/" ++ idNumToFilePath idNum+      fp = "slides/" <> idNumToFilePath idNum   return $ Relationship { relId = rId                         , relType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"                         , relTarget = fp@@ -1373,7 +1402,7 @@                            , relTarget = "notesMasters/notesMaster1.xml"                            }]         else []-      insertedRels = mySlideRels ++ notesMasterRels+      insertedRels = mySlideRels <> notesMasterRels   rels <- getRels   -- we remove the slide rels and the notesmaster (if it's   -- there). We'll put these back in ourselves, if necessary.@@ -1403,7 +1432,7 @@        relsWeKeep' = map (\r -> r{relId = modifyRelNum $ relId r}) relsWeKeep -  return $ insertedRels ++ relsWeKeep'+  return $ insertedRels <> relsWeKeep'  -- We make this ourselves, in case there's a thumbnail in the one from -- the template.@@ -1431,8 +1460,8 @@ topLevelRelsEntry = elemToEntry "_rels/.rels" $ relsToElement topLevelRels  relToElement :: Relationship -> Element-relToElement rel = mknode "Relationship" [ ("Id", "rId" ++ (show $ relId rel))-                                         , ("Type", relType rel)+relToElement rel = mknode "Relationship" [ ("Id", "rId" <> (show $ relId rel))+                                         , ("Type", T.unpack $ relType rel)                                          , ("Target", relTarget rel) ] ()  relsToElement :: [Relationship] -> Element@@ -1455,7 +1484,7 @@   idNum <- slideNum slide   local (\env -> env{envCurSlideId = idNum}) $ do     element <- slideToElement slide-    elemToEntry ("ppt/slides/" ++ idNumToFilePath idNum) element+    elemToEntry ("ppt/slides/" <> idNumToFilePath idNum) element  slideToSpeakerNotesEntry :: PandocMonad m => Slide -> P m (Maybe Entry) slideToSpeakerNotesEntry slide = do@@ -1468,7 +1497,7 @@       Just element | Just notesIdNum <- mbNotesIdNum ->                        Just <$>                        elemToEntry-                       ("ppt/notesSlides/notesSlide" ++ show notesIdNum ++ ".xml")+                       ("ppt/notesSlides/notesSlide" <> show notesIdNum <> ".xml")                        element       _ -> return Nothing @@ -1481,7 +1510,7 @@     [("xmlns", "http://schemas.openxmlformats.org/package/2006/relationships")]     [ mknode "Relationship" [ ("Id", "rId2")                             , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide")-                            , ("Target", "../slides/slide" ++ show idNum ++ ".xml")+                            , ("Target", "../slides/slide" <> show idNum <> ".xml")                             ] ()     , mknode "Relationship" [ ("Id", "rId1")                             , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster")@@ -1500,7 +1529,7 @@     Just element | Just notesIdNum <- mbNotesIdNum ->       Just <$>       elemToEntry-      ("ppt/notesSlides/_rels/notesSlide" ++ show notesIdNum ++ ".xml.rels")+      ("ppt/notesSlides/_rels/notesSlide" <> show notesIdNum <> ".xml.rels")       element     _ -> return Nothing @@ -1508,21 +1537,21 @@ slideToSlideRelEntry slide = do   idNum <- slideNum slide   element <- slideToSlideRelElement slide-  elemToEntry ("ppt/slides/_rels/" ++ idNumToFilePath idNum ++ ".rels") element+  elemToEntry ("ppt/slides/_rels/" <> idNumToFilePath idNum <> ".rels") element  linkRelElement :: PandocMonad m => Int -> LinkTarget -> P m Element linkRelElement rIdNum (InternalTarget targetId) = do   targetIdNum <- getSlideIdNum targetId   return $-    mknode "Relationship" [ ("Id", "rId" ++ show rIdNum)+    mknode "Relationship" [ ("Id", "rId" <> show rIdNum)                           , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide")-                          , ("Target", "slide" ++ show targetIdNum ++ ".xml")+                          , ("Target", "slide" <> show targetIdNum <> ".xml")                           ] () linkRelElement rIdNum (ExternalTarget (url, _)) = do   return $-    mknode "Relationship" [ ("Id", "rId" ++ show rIdNum)+    mknode "Relationship" [ ("Id", "rId" <> show rIdNum)                           , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")-                          , ("Target", url)+                          , ("Target", T.unpack url)                           , ("TargetMode", "External")                           ] () @@ -1535,9 +1564,9 @@               Just e -> e               Nothing -> ""   in-    mknode "Relationship" [ ("Id", "rId" ++ (show $ mInfoLocalId mInfo))+    mknode "Relationship" [ ("Id", "rId" <> (show $ mInfoLocalId mInfo))                           , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")-                          , ("Target", "../media/image" ++ (show $ mInfoGlobalId mInfo) ++ ext)+                          , ("Target", "../media/image" <> (show $ mInfoGlobalId mInfo) <> T.unpack ext)                           ] ()  speakerNotesSlideRelElement :: PandocMonad m => Slide -> P m (Maybe Element)@@ -1547,7 +1576,7 @@   return $ case M.lookup idNum mp of     Nothing -> Nothing     Just n ->-      let target = "../notesSlides/notesSlide" ++ show n ++ ".xml"+      let target = "../notesSlides/notesSlide" <> show n <> ".xml"       in Just $          mknode "Relationship" [ ("Id", "rId2")                                , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide")@@ -1581,14 +1610,14 @@     ([mknode "Relationship" [ ("Id", "rId1")                            , ("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout")                            , ("Target", target)] ()-    ] ++ speakerNotesRels ++ linkRels ++ mediaRels)+    ] <> speakerNotesRels <> linkRels <> mediaRels)  slideToSldIdElement :: PandocMonad m => Slide -> P m Element slideToSldIdElement slide = do   n <- slideNum slide   let id' = show $ n + 255   rId <- slideToRelId slide-  return $ mknode "p:sldId" [("id", id'), ("r:id", rId)] ()+  return $ mknode "p:sldId" [("id", id'), ("r:id", T.unpack rId)] ()  presentationToSldIdLst :: PandocMonad m => Presentation -> P m Element presentationToSldIdLst (Presentation _ slides) = do@@ -1613,7 +1642,7 @@       notesMasterElem =  mknode "p:notesMasterIdLst" []                          [ mknode                            "p:NotesMasterId"-                           [("r:id", "rId" ++ show notesMasterRId)]+                           [("r:id", "rId" <> show notesMasterRId)]                            ()                          ] @@ -1659,7 +1688,7 @@ docPropsElement docProps = do   utctime <- asks envUTCTime   let keywords = case dcKeywords docProps of-        Just xs -> intercalate ", " xs+        Just xs -> T.intercalate ", " xs         Nothing -> ""   return $     mknode "cp:coreProperties"@@ -1668,16 +1697,16 @@     ,("xmlns:dcterms","http://purl.org/dc/terms/")     ,("xmlns:dcmitype","http://purl.org/dc/dcmitype/")     ,("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")]-    $ (mknode "dc:title" [] $ fromMaybe "" $ dcTitle docProps)-    : (mknode "dc:creator" [] $ fromMaybe "" $ dcCreator docProps)-    : (mknode "cp:keywords" [] keywords)+    $ (mknode "dc:title" [] $ maybe "" T.unpack $ dcTitle docProps)+    : (mknode "dc:creator" [] $ maybe "" T.unpack $ dcCreator docProps)+    : (mknode "cp:keywords" [] $ T.unpack keywords)     : (if isNothing (dcSubject docProps) then [] else-           [mknode "dc:subject" [] $ fromMaybe "" $ dcSubject docProps])-    ++ (if isNothing (dcDescription docProps) then [] else-           [mknode "dc:description" [] $ fromMaybe "" $ dcDescription docProps])-    ++ (if isNothing (cpCategory docProps) then [] else-           [mknode "cp:category" [] $ fromMaybe "" $ cpCategory docProps])-    ++ (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] x+           [mknode "dc:subject" [] $ maybe "" T.unpack $ dcSubject docProps])+    <> (if isNothing (dcDescription docProps) then [] else+           [mknode "dc:description" [] $ maybe "" T.unpack $ dcDescription docProps])+    <> (if isNothing (cpCategory docProps) then [] else+           [mknode "cp:category" [] $ maybe "" T.unpack $ cpCategory docProps])+    <> (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] x              , mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] x              ]) (formatTime defaultTimeLocale "%FT%XZ" utctime) @@ -1691,7 +1720,7 @@   let mkCustomProp (k, v) pid = mknode "property"          [("fmtid","{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")          ,("pid", show pid)-         ,("name", k)] $ mknode "vt:lpwstr" [] v+         ,("name", T.unpack k)] $ mknode "vt:lpwstr" [] (T.unpack v)   return $ mknode "Properties"           [("xmlns","http://schemas.openxmlformats.org/officeDocument/2006/custom-properties")           ,("xmlns:vt","http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes")@@ -1721,15 +1750,15 @@ defaultContentTypeToElem :: DefaultContentType -> Element defaultContentTypeToElem dct =   mknode "Default"-  [("Extension", defContentTypesExt dct),-    ("ContentType", defContentTypesType dct)]+  [("Extension", T.unpack $ defContentTypesExt dct),+    ("ContentType", T.unpack $ defContentTypesType dct)]   ()  overrideContentTypeToElem :: OverrideContentType -> Element overrideContentTypeToElem oct =   mknode "Override"   [("PartName", overrideContentTypesPart oct),-    ("ContentType", overrideContentTypesType oct)]+    ("ContentType", T.unpack $ overrideContentTypesType oct)]   ()  contentTypesToElement :: ContentTypes -> Element@@ -1737,11 +1766,11 @@   let ns = "http://schemas.openxmlformats.org/package/2006/content-types"   in     mknode "Types" [("xmlns", ns)] $-    (map defaultContentTypeToElem $ contentTypesDefaults ct) +++    (map defaultContentTypeToElem $ contentTypesDefaults ct) <>     (map overrideContentTypeToElem $ contentTypesOverrides ct)  data DefaultContentType = DefaultContentType-                           { defContentTypesExt :: String+                           { defContentTypesExt :: T.Text                            , defContentTypesType:: MimeType                            }                          deriving (Show, Eq)@@ -1761,12 +1790,12 @@ contentTypesToEntry ct = elemToEntry "[Content_Types].xml" $ contentTypesToElement ct  pathToOverride :: FilePath -> Maybe OverrideContentType-pathToOverride fp = OverrideContentType ("/" ++ fp) <$> (getContentType fp)+pathToOverride fp = OverrideContentType ("/" <> fp) <$> (getContentType fp)  mediaFileContentType :: FilePath -> Maybe DefaultContentType mediaFileContentType fp = case takeExtension fp of   '.' : ext -> Just $-               DefaultContentType { defContentTypesExt = ext+               DefaultContentType { defContentTypesExt = T.pack ext                                   , defContentTypesType =                                       case getMimeType fp of                                         Just mt -> mt@@ -1776,7 +1805,8 @@  mediaContentType :: MediaInfo -> Maybe DefaultContentType mediaContentType mInfo-  | Just ('.' : ext) <- mInfoExt mInfo =+  | Just t <- mInfoExt mInfo+  , Just ('.', ext) <- T.uncons t =       Just $ DefaultContentType { defContentTypesExt = ext                                 , defContentTypesType =                                     case mInfoMimeType mInfo of@@ -1789,7 +1819,7 @@ getSpeakerNotesFilePaths = do   mp <- asks envSpeakerNotesIdMap   let notesIdNums = M.elems mp-  return $ map (\n -> "ppt/notesSlides/notesSlide" ++ show n ++ ".xml") notesIdNums+  return $ map (\n -> "ppt/notesSlides/notesSlide" <> show n <> ".xml") notesIdNums  presentationToContentTypes :: PandocMonad m => Presentation -> P m ContentTypes presentationToContentTypes p@(Presentation _ slides) = do@@ -1800,7 +1830,7 @@                  , DefaultContentType "rels" "application/vnd.openxmlformats-package.relationships+xml"                  ]       mediaDefaults = nub $-                      (mapMaybe mediaContentType $ mediaInfos) +++                      (mapMaybe mediaContentType $ mediaInfos) <>                       (mapMaybe mediaFileContentType $ mediaFps)        inheritedOverrides = mapMaybe pathToOverride filePaths@@ -1811,51 +1841,56 @@                                                  ]   relativePaths <- mapM slideToFilePath slides   let slideOverrides = mapMaybe-                       (\fp -> pathToOverride $ "ppt/slides/" ++ fp)+                       (\fp -> pathToOverride $ "ppt/slides/" <> fp)                        relativePaths   speakerNotesOverrides <- (mapMaybe pathToOverride) <$> getSpeakerNotesFilePaths   return $ ContentTypes-    (defaults ++ mediaDefaults)-    (inheritedOverrides ++ createdOverrides ++ slideOverrides ++ speakerNotesOverrides)+    (defaults <> mediaDefaults)+    (inheritedOverrides <> createdOverrides <> slideOverrides <> speakerNotesOverrides) -presML :: String+presML :: T.Text presML = "application/vnd.openxmlformats-officedocument.presentationml" -noPresML :: String+noPresML :: T.Text noPresML = "application/vnd.openxmlformats-officedocument"  getContentType :: FilePath -> Maybe MimeType getContentType fp-  | fp == "ppt/presentation.xml" = Just $ presML ++ ".presentation.main+xml"-  | fp == "ppt/presProps.xml" = Just $ presML ++ ".presProps+xml"-  | fp == "ppt/viewProps.xml" = Just $ presML ++ ".viewProps+xml"-  | fp == "ppt/tableStyles.xml" = Just $ presML ++ ".tableStyles+xml"+  | fp == "ppt/presentation.xml" = Just $ presML <> ".presentation.main+xml"+  | fp == "ppt/presProps.xml" = Just $ presML <> ".presProps+xml"+  | fp == "ppt/viewProps.xml" = Just $ presML <> ".viewProps+xml"+  | fp == "ppt/tableStyles.xml" = Just $ presML <> ".tableStyles+xml"   | fp == "docProps/core.xml" = Just $ "application/vnd.openxmlformats-package.core-properties+xml"   | fp == "docProps/custom.xml" = Just $ "application/vnd.openxmlformats-officedocument.custom-properties+xml"-  | fp == "docProps/app.xml" = Just $ noPresML ++ ".extended-properties+xml"+  | fp == "docProps/app.xml" = Just $ noPresML <> ".extended-properties+xml"   | "ppt" : "slideMasters" : f : [] <- splitDirectories fp   , (_, ".xml") <- splitExtension f =-      Just $ presML ++ ".slideMaster+xml"+      Just $ presML <> ".slideMaster+xml"   | "ppt" : "slides" : f : [] <- splitDirectories fp   , (_, ".xml") <- splitExtension f =-      Just $ presML ++ ".slide+xml"+      Just $ presML <> ".slide+xml"   | "ppt" : "notesMasters"  : f : [] <- splitDirectories fp   , (_, ".xml") <- splitExtension f =-      Just $ presML ++ ".notesMaster+xml"+      Just $ presML <> ".notesMaster+xml"   | "ppt" : "notesSlides"  : f : [] <- splitDirectories fp   , (_, ".xml") <- splitExtension f =-      Just $ presML ++ ".notesSlide+xml"+      Just $ presML <> ".notesSlide+xml"   | "ppt" : "theme" : f : [] <- splitDirectories fp   , (_, ".xml") <- splitExtension f =-      Just $ noPresML ++ ".theme+xml"+      Just $ noPresML <> ".theme+xml"   | "ppt" : "slideLayouts" : _ : [] <- splitDirectories fp=-      Just $ presML ++ ".slideLayout+xml"+      Just $ presML <> ".slideLayout+xml"   | otherwise = Nothing -autoNumberingToType :: ListAttributes -> String-autoNumberingToType (_, numStyle, numDelim) =-  typeString ++ delimString+-- Kept as String for XML.Light+autoNumAttrs :: ListAttributes -> [(String, String)]+autoNumAttrs (startNum, numStyle, numDelim) =+  numAttr <> typeAttr   where+    numAttr = if startNum == 1+              then []+              else [("startAt", show startNum)]+    typeAttr = [("type", typeString <> delimString)]     typeString = case numStyle of       Decimal -> "arabic"       UpperAlpha -> "alphaUc"
src/Text/Pandoc/Writers/Powerpoint/Presentation.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE NoImplicitPrelude          #-}+{-# LANGUAGE OverloadedStrings          #-} {-# LANGUAGE PatternGuards              #-}+{-# LANGUAGE ViewPatterns               #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {- |    Module      : Text.Pandoc.Writers.Powerpoint.Presentation@@ -33,6 +35,7 @@                                                    , TableProps(..)                                                    , Strikethrough(..)                                                    , Capitals(..)+                                                   , Pixels                                                    , PicProps(..)                                                    , URL                                                    , TeXString(..)@@ -53,6 +56,7 @@ import Text.Pandoc.Walk import Data.Time (UTCTime) import qualified Text.Pandoc.Shared as Shared -- so we don't overlap "Element"+import Text.Pandoc.Shared (tshow) import Text.Pandoc.Writers.Shared (lookupMetaInlines, lookupMetaBlocks                                  , lookupMetaString, toTableOfContents) import qualified Data.Map as M@@ -92,7 +96,7 @@  data WriterState = WriterState { stNoteIds :: M.Map Int [Block]                                -- associate anchors with slide id-                               , stAnchorMap :: M.Map String SlideId+                               , stAnchorMap :: M.Map T.Text SlideId                                , stSlideIdSet :: S.Set SlideId                                , stLog :: [LogMessage]                                , stSpeakerNotes :: SpeakerNotes@@ -122,17 +126,17 @@                               , endNotesSlideId                               ] -uniqueSlideId' :: Integer -> S.Set SlideId -> String -> SlideId+uniqueSlideId' :: Integer -> S.Set SlideId -> T.Text -> SlideId uniqueSlideId' n idSet s =-  let s' = if n == 0 then s else s ++ "-" ++ show n+  let s' = if n == 0 then s else s <> "-" <> tshow n   in if SlideId s' `S.member` idSet      then uniqueSlideId' (n+1) idSet s      else SlideId s' -uniqueSlideId :: S.Set SlideId -> String -> SlideId+uniqueSlideId :: S.Set SlideId -> T.Text -> SlideId uniqueSlideId = uniqueSlideId' 0 -runUniqueSlideId :: String -> Pres SlideId+runUniqueSlideId :: T.Text -> Pres SlideId runUniqueSlideId s = do   idSet <- gets stSlideIdSet   let sldId = uniqueSlideId idSet s@@ -158,14 +162,14 @@ data Presentation = Presentation DocProps [Slide]   deriving (Show) -data DocProps = DocProps { dcTitle :: Maybe String-                         , dcSubject :: Maybe String-                         , dcCreator :: Maybe String-                         , dcKeywords :: Maybe [String]-                         , dcDescription :: Maybe String-                         , cpCategory :: Maybe String+data DocProps = DocProps { dcTitle :: Maybe T.Text+                         , dcSubject :: Maybe T.Text+                         , dcCreator :: Maybe T.Text+                         , dcKeywords :: Maybe [T.Text]+                         , dcDescription :: Maybe T.Text+                         , cpCategory :: Maybe T.Text                          , dcCreated :: Maybe UTCTime-                         , customProperties :: Maybe [(String, String)]+                         , customProperties :: Maybe [(T.Text, T.Text)]                          } deriving (Show, Eq)  @@ -174,7 +178,7 @@                    , slideSpeakerNotes :: SpeakerNotes                    } deriving (Show, Eq) -newtype SlideId = SlideId String+newtype SlideId = SlideId T.Text   deriving (Show, Eq, Ord)  -- In theory you could have anything on a notes slide but it seems@@ -196,7 +200,7 @@ data Shape = Pic PicProps FilePath [ParaElem]            | GraphicFrame [Graphic] [ParaElem]            | TextBox [Paragraph]-           | RawOOXMLShape String+           | RawOOXMLShape T.Text   deriving (Show, Eq)  type Cell = [Paragraph]@@ -226,6 +230,7 @@                            , pPropBullet :: Maybe BulletType                            , pPropAlign :: Maybe Algnment                            , pPropSpaceBefore :: Maybe Pixels+                           , pPropIndent :: Maybe Pixels                            } deriving (Show, Eq)  instance Default ParaProps where@@ -235,19 +240,20 @@                   , pPropBullet = Nothing                   , pPropAlign = Nothing                   , pPropSpaceBefore = Nothing+                  , pPropIndent = Just 0                   } -newtype TeXString = TeXString {unTeXString :: String}+newtype TeXString = TeXString {unTeXString :: T.Text}   deriving (Eq, Show)  data ParaElem = Break-              | Run RunProps String+              | Run RunProps T.Text               -- It would be more elegant to have native TeXMath               -- Expressions here, but this allows us to use               -- `convertmath` from T.P.Writers.Math. Will perhaps               -- revisit in the future.               | MathElem MathType TeXString-              | RawOOXMLParaElem String+              | RawOOXMLParaElem T.Text               deriving (Show, Eq)  data Strikethrough = NoStrike | SingleStrike | DoubleStrike@@ -256,9 +262,9 @@ data Capitals = NoCapitals | SmallCapitals | AllCapitals   deriving (Show, Eq) -type URL = String+type URL = T.Text -data LinkTarget = ExternalTarget (URL, String)+data LinkTarget = ExternalTarget (URL, T.Text)                 | InternalTarget SlideId                 deriving (Show, Eq) @@ -357,7 +363,7 @@         curNoteId = maxNoteId + 1     modify $ \st -> st { stNoteIds = M.insert curNoteId blks notes }     local (\env -> env{envRunProps = (envRunProps env){rLink = Just $ InternalTarget endNotesSlideId}}) $-      inlineToParElems $ Superscript [Str $ show curNoteId]+      inlineToParElems $ Superscript [Str $ tshow curNoteId] inlineToParElems (Span (_, ["underline"], _) ils) =   local (\r -> r{envRunProps = (envRunProps r){rPropUnderline=True}}) $   inlinesToParElems ils@@ -386,11 +392,11 @@ isListType (DefinitionList _) = True isListType _ = False -registerAnchorId :: String -> Pres ()+registerAnchorId :: T.Text -> Pres () registerAnchorId anchor = do   anchorMap <- gets stAnchorMap   sldId <- asks envCurSlideId-  unless (null anchor) $+  unless (T.null anchor) $     modify $ \st -> st {stAnchorMap = M.insert anchor sldId anchorMap}  -- Currently hardcoded, until I figure out how to make it dynamic.@@ -411,18 +417,23 @@   pProps <- asks envParaProps   return [Paragraph pProps parElems] -- TODO: work out the attributes-blockToParagraphs (CodeBlock attr str) =-  local (\r -> r{ envParaProps = def{pPropMarginLeft = Just 100}+blockToParagraphs (CodeBlock attr str) = do+  pProps <- asks envParaProps+  local (\r -> r{ envParaProps = def{ pPropMarginLeft = Nothing+                                    , pPropBullet = Nothing+                                    , pPropLevel = pPropLevel pProps+                                    , pPropIndent = Just 0+                                    }                 , envRunProps = (envRunProps r){rPropCode = True}}) $ do-  mbSty <- writerHighlightStyle <$> asks envOpts-  synMap <- writerSyntaxMap <$> asks envOpts-  case mbSty of-    Just sty ->-      case highlight synMap (formatSourceLines sty) attr str of-        Right pElems -> do pProps <- asks envParaProps-                           return [Paragraph pProps pElems]-        Left _ -> blockToParagraphs $ Para [Str str]-    Nothing -> blockToParagraphs $ Para [Str str]+    mbSty <- writerHighlightStyle <$> asks envOpts+    synMap <- writerSyntaxMap <$> asks envOpts+    case mbSty of+      Just sty ->+        case highlight synMap (formatSourceLines sty) attr str of+          Right pElems -> do pPropsNew <- asks envParaProps+                             return [Paragraph pPropsNew pElems]+          Left _ -> blockToParagraphs $ Para [Str str]+      Nothing -> blockToParagraphs $ Para [Str str] -- We can't yet do incremental lists, but we should render a -- (BlockQuote List) as a list to maintain compatibility with other -- formats.@@ -431,7 +442,9 @@   ps' <- blockToParagraphs $ BlockQuote blks   return $ ps ++ ps' blockToParagraphs (BlockQuote blks) =-  local (\r -> r{ envParaProps = (envParaProps r){pPropMarginLeft = Just 100}+  local (\r -> r{ envParaProps = (envParaProps r){ pPropMarginLeft = Just 100+                                                 , pPropIndent = Just 0+                                                 }                 , envRunProps = (envRunProps r){rPropForceSize = Just blockQuoteSize}})$   concatMapM blockToParagraphs blks -- TODO: work out the format@@ -455,6 +468,7 @@                     , envParaProps = pProps{ pPropLevel = lvl + 1                                            , pPropBullet = Just Bullet                                            , pPropMarginLeft = Nothing+                                           , pPropIndent = Nothing                                            }}) $     concatMapM multiParBullet blksLst blockToParagraphs (OrderedList listAttr blksLst) = do@@ -464,6 +478,7 @@                     , envParaProps = pProps{ pPropLevel = lvl + 1                                            , pPropBullet = Just (AutoNumbering listAttr)                                            , pPropMarginLeft = Nothing+                                           , pPropIndent = Nothing                                            }}) $     concatMapM multiParBullet blksLst blockToParagraphs (DefinitionList entries) = do@@ -519,11 +534,11 @@ blockToShape :: Block -> Pres Shape blockToShape (Plain ils) = blockToShape (Para ils) blockToShape (Para (il:_))  | Image attr ils (url, _) <- il =-      (withAttr attr . Pic def url) <$> inlinesToParElems ils+      (withAttr attr . Pic def (T.unpack url)) <$> inlinesToParElems ils blockToShape (Para (il:_))  | Link _ (il':_) target <- il                             , Image attr ils (url, _) <- il' =-      (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} url) <$>-      inlinesToParElems ils+      (withAttr attr . Pic def{picPropLink = Just $ ExternalTarget target} (T.unpack url))+      <$> inlinesToParElems ils blockToShape (Table caption algn _ hdrCells rows) = do   caption' <- inlinesToParElems caption   hdrCells' <- rowToParagraphs algn hdrCells@@ -699,7 +714,7 @@  makeNoteEntry :: Int -> [Block] -> [Block] makeNoteEntry n blks =-  let enum = Str (show n ++ ".")+  let enum = Str (tshow n <> ".")   in     case blks of       (Para ils : blks') -> (Para $ enum : Space : ils) : blks'@@ -774,7 +789,7 @@   | Run rPr' s' <- pElem'   , Run rPr s <- pElem   , rPr == rPr' =-    combineParaElems' (Just $ Run rPr' $ s' ++ s) pElems+    combineParaElems' (Just $ Run rPr' $ s' <> s) pElems   | otherwise =     pElem' : combineParaElems' (Just pElem) pElems @@ -819,7 +834,8 @@  replaceAnchor :: ParaElem -> Pres ParaElem replaceAnchor (Run rProps s)-  | Just (ExternalTarget ('#':anchor, _)) <- rLink rProps = do+  | Just (ExternalTarget (T.uncons -> Just ('#', anchor), _)) <- rLink rProps+  = do       anchorMap <- gets stAnchorMap       -- If the anchor is not in the anchormap, we just remove the       -- link.@@ -831,9 +847,9 @@  emptyParaElem :: ParaElem -> Bool emptyParaElem (Run _ s) =-  null $ Shared.trim s+  T.null $ Shared.trim s emptyParaElem (MathElem _ ts) =-  null $ Shared.trim $ unTeXString ts+  T.null $ Shared.trim $ unTeXString ts emptyParaElem _ = False  emptyParagraph :: Paragraph -> Bool@@ -888,7 +904,7 @@   -- slide later   blksLst <- splitBlocks blks'   bodySlideIds <- mapM-                  (\n -> runUniqueSlideId $ "BodySlide" ++ show n)+                  (\n -> runUniqueSlideId $ "BodySlide" <> tshow n)                   (take (length blksLst) [1..] :: [Integer])   bodyslides <- mapM                 (\(bs, ident) ->@@ -923,11 +939,11 @@        authors = case map Shared.stringify $ docAuthors meta of                   [] -> Nothing-                  ss -> Just $ intercalate "; " ss+                  ss -> Just $ T.intercalate "; " ss        description = case map Shared.stringify $ lookupMetaBlocks "description" meta of                   [] -> Nothing-                  ss -> Just $ intercalate "_x000d_\n" ss+                  ss -> Just $ T.intercalate "_x000d_\n" ss        customProperties' = case [(k, lookupMetaString k meta) | k <- M.keys (unMeta meta)                                , k `notElem` (["title", "author", "keywords", "description"@@ -975,7 +991,7 @@         Just tokSty -> applyTokStyToRunProps tokSty rProps         Nothing     -> rProps   in-    Run rProps' $ T.unpack txt+    Run rProps' txt  formatSourceLine :: Style -> FormatOptions -> SourceLine -> [ParaElem] formatSourceLine sty _ srcLn = map (formatToken sty) srcLn
src/Text/Pandoc/Writers/RST.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.RST    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -16,19 +17,20 @@ module Text.Pandoc.Writers.RST ( writeRST, flatten ) where import Prelude import Control.Monad.State.Strict-import Data.Char (isSpace, toLower)-import Data.List (isPrefixOf, stripPrefix, transpose)+import Data.Char (isSpace)+import Data.List (transpose, intersperse) import Data.Maybe (fromMaybe)-import Data.Text (Text, stripEnd)+import qualified Data.Text as T+import Data.Text (Text) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared import Text.Pandoc.Walk @@ -37,7 +39,7 @@ data WriterState =   WriterState { stNotes       :: [[Block]]               , stLinks       :: Refs-              , stImages      :: [([Inline], (Attr, String, String, Maybe String))]+              , stImages      :: [([Inline], (Attr, Text, Text, Maybe Text))]               , stHasMath     :: Bool               , stHasRawTeX   :: Bool               , stOptions     :: WriterOptions@@ -62,13 +64,11 @@   let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth   let subtit = lookupMetaInlines "subtitle" meta   title <- titleToRST (docTitle meta) subtit-  metadata <- metaToJSON opts-                (fmap render' . blockListToRST)-                (fmap (stripEnd . render') . inlineListToRST)+  metadata <- metaToContext opts+                blockListToRST+                (fmap chomp . inlineListToRST)                 meta   body <- blockListToRST' True $ case writerTemplate opts of                                       Just _  -> normalizeHeadings 1 blocks@@ -79,18 +79,19 @@   pics <- gets (reverse . stImages) >>= pictRefsToRST   hasMath <- gets stHasMath   rawTeX <- gets stHasRawTeX-  let main = render' $ foldl ($+$) empty [body, notes, refs, pics]+  let main = vsep [body, notes, refs, pics]   let context = defField "body" main               $ defField "toc" (writerTableOfContents opts)-              $ defField "toc-depth" (show $ writerTOCDepth opts)+              $ defField "toc-depth" (tshow $ writerTOCDepth opts)               $ defField "number-sections" (writerNumberSections opts)               $ defField "math" hasMath-              $ defField "titleblock" (render Nothing title :: String)+              $ defField "titleblock" (render Nothing title :: Text)               $ defField "math" hasMath               $ defField "rawtex" rawTeX metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context   where     normalizeHeadings lev (Header l a i:bs) =       Header lev a i:normalizeHeadings (lev+1) cont ++ normalizeHeadings lev bs'@@ -101,26 +102,26 @@     normalizeHeadings _   []     = []  -- | Return RST representation of reference key table.-refsToRST :: PandocMonad m => Refs -> RST m Doc+refsToRST :: PandocMonad m => Refs -> RST m (Doc Text) refsToRST refs = mapM keyToRST refs >>= return . vcat  -- | Return RST representation of a reference key.-keyToRST :: PandocMonad m => ([Inline], (String, String)) -> RST m Doc+keyToRST :: PandocMonad m => ([Inline], (Text, Text)) -> RST m (Doc Text) keyToRST (label, (src, _)) = do   label' <- inlineListToRST label-  let label'' = if ':' `elem` (render Nothing label' :: String)+  let label'' = if (==':') `T.any` (render Nothing label' :: Text)                    then char '`' <> label' <> char '`'                    else label'-  return $ nowrap $ ".. _" <> label'' <> ": " <> text src+  return $ nowrap $ ".. _" <> label'' <> ": " <> literal src  -- | Return RST representation of notes.-notesToRST :: PandocMonad m => [[Block]] -> RST m Doc+notesToRST :: PandocMonad m => [[Block]] -> RST m (Doc Text) notesToRST notes =    zipWithM noteToRST [1..] notes >>=   return . vsep  -- | Return RST representation of a note.-noteToRST :: PandocMonad m => Int -> [Block] -> RST m Doc+noteToRST :: PandocMonad m => Int -> [Block] -> RST m (Doc Text) noteToRST num note = do   contents <- blockListToRST note   let marker = ".. [" <> text (show num) <> "]"@@ -128,69 +129,72 @@  -- | Return RST representation of picture reference table. pictRefsToRST :: PandocMonad m-              => [([Inline], (Attr, String, String, Maybe String))]-              -> RST m Doc+              => [([Inline], (Attr, Text, Text, Maybe Text))]+              -> RST m (Doc Text) pictRefsToRST refs = mapM pictToRST refs >>= return . vcat  -- | Return RST representation of a picture substitution reference. pictToRST :: PandocMonad m-          => ([Inline], (Attr, String, String, Maybe String))-          -> RST m Doc+          => ([Inline], (Attr, Text, Text, Maybe Text))+          -> RST m (Doc Text) pictToRST (label, (attr, src, _, mbtarget)) = do   label' <- inlineListToRST label   dims   <- imageDimsToRST attr   let (_, cls, _) = attr-      classes = if null cls-                   then empty-                   else ":class: " <> text (unwords cls)+      classes = case cls of+                   []               -> empty+                   ["align-right"]  -> ":align: right"+                   ["align-left"]   -> ":align: left"+                   ["align-center"] -> ":align: center"+                   _                -> ":class: " <> literal (T.unwords cls)   return $ nowrap-         $ ".. |" <> label' <> "| image:: " <> text src $$ hang 3 empty (classes $$ dims)+         $ ".. |" <> label' <> "| image:: " <> literal src $$ hang 3 empty (classes $$ dims)          $$ case mbtarget of                  Nothing -> empty-                 Just t  -> "   :target: " <> text t+                 Just t  -> "   :target: " <> literal t  -- | Escape special characters for RST.-escapeString :: WriterOptions -> String -> String-escapeString = escapeString' True+escapeText :: WriterOptions -> Text -> Text+escapeText o = T.pack . escapeString' True o . T.unpack -- This ought to be parser   where   escapeString' _ _  [] = []   escapeString' firstChar opts (c:cs) =     case c of-         _ | c `elem` ['\\','`','*','_','|'] &&-             (firstChar || null cs) -> '\\':c:escapeString' False opts cs+         _    | c `elemText` "\\`*_|" &&+                (firstChar || null cs) -> '\\':c:escapeString' False opts cs          '\'' | isEnabled Ext_smart opts -> '\\':'\'':escapeString' False opts cs-         '"' | isEnabled Ext_smart opts -> '\\':'"':escapeString' False opts cs-         '-' | isEnabled Ext_smart opts ->-                case cs of-                     '-':_ -> '\\':'-':escapeString' False opts cs-                     _     -> '-':escapeString' False opts cs-         '.' | isEnabled Ext_smart opts ->-                case cs of-                     '.':'.':rest -> '\\':'.':'.':'.':escapeString' False opts rest-                     _            -> '.':escapeString' False opts cs+         '"'  | isEnabled Ext_smart opts -> '\\':'"':escapeString' False opts cs+         '-'  | isEnabled Ext_smart opts ->+                  case cs of+                    '-':_ -> '\\':'-':escapeString' False opts cs+                    _     -> '-':escapeString' False opts cs+         '.'  | isEnabled Ext_smart opts ->+                  case cs of+                    '.':'.':rest -> '\\':'.':'.':'.':escapeString' False opts rest+                    _            -> '.':escapeString' False opts cs          _ -> c : escapeString' False opts cs -titleToRST :: PandocMonad m => [Inline] -> [Inline] -> RST m Doc+titleToRST :: PandocMonad m => [Inline] -> [Inline] -> RST m (Doc Text) titleToRST [] _ = return empty titleToRST tit subtit = do   title <- inlineListToRST tit   subtitle <- inlineListToRST subtit   return $ bordered title '=' $$ bordered subtitle '-' -bordered :: Doc -> Char -> Doc+bordered :: Doc Text -> Char -> Doc Text bordered contents c =   if len > 0      then border $$ contents $$ border      else empty    where len = offset contents-         border = text (replicate len c)+         border = literal (T.replicate len $ T.singleton c)  -- | Convert Pandoc block element to RST. blockToRST :: PandocMonad m            => Block         -- ^ Block element-           -> RST m Doc+           -> RST m (Doc Text) blockToRST Null = return empty-blockToRST (Div ("",["admonition-title"],[]) _) = return empty+blockToRST (Div ("",["title"],[]) _) = return empty   -- this is generated by the rst reader and can safely be   -- omitted when we're generating rst blockToRST (Div (ident,classes,_kvs) bs) = do@@ -200,27 +204,30 @@   let admonition = case classes of                         (cl:_)                           | cl `elem` admonitions-                          -> ".. " <> text cl <> "::"+                          -> ".. " <> literal cl <> "::"                         cls -> ".. container::" <> space <>-                                   text (unwords (filter (/= "container") cls))+                                   literal (T.unwords (filter (/= "container") cls))   return $ blankline $$            admonition $$-           (if null ident+           (if T.null ident                then blankline-               else "   :name: " <> text ident $$ blankline) $$+               else "   :name: " <> literal ident $$ blankline) $$            nest 3 contents $$            blankline blockToRST (Plain inlines) = inlineListToRST inlines -- title beginning with fig: indicates that the image is a figure-blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do+blockToRST (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just tit)]) = do   capt <- inlineListToRST txt   dims <- imageDimsToRST attr-  let fig = "figure:: " <> text src-      alt = ":alt: " <> if null tit then capt else text tit+  let fig = "figure:: " <> literal src+      alt = ":alt: " <> if T.null tit then capt else literal tit       (_,cls,_) = attr-      classes = if null cls-                   then empty-                   else ":figclass: " <> text (unwords cls)+      classes = case cls of+                   []               -> empty+                   ["align-right"]  -> ":align: right"+                   ["align-left"]   -> ":align: left"+                   ["align-center"] -> ":align: center"+                   _                -> ":figclass: " <> literal (T.unwords cls)   return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline blockToRST (Para inlines)   | LineBreak `elem` inlines =@@ -231,11 +238,11 @@ blockToRST (LineBlock lns) =   linesToLineBlock lns blockToRST (RawBlock f@(Format f') str)-  | f == "rst" = return $ text str+  | f == "rst" = return $ literal str   | f == "tex" = blockToRST (RawBlock (Format "latex") str)   | otherwise  = return $ blankline <> ".. raw:: " <>-                    text (map toLower f') $+$-                    nest 3 (text str) $$ blankline+                    literal (T.toLower f') $+$+                    nest 3 (literal str) $$ blankline blockToRST HorizontalRule =   return $ blankline $$ "--------------" $$ blankline blockToRST (Header level (name,classes,_) inlines) = do@@ -248,33 +255,33 @@   if isTopLevel     then do           let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1)-          let border = text $ replicate (offset contents) headerChar-          let anchor | null name || name == autoId = empty-                     | otherwise = ".. _" <> text name <> ":" $$ blankline+          let border = literal $ T.replicate (offset contents) $ T.singleton headerChar+          let anchor | T.null name || name == autoId = empty+                     | otherwise = ".. _" <> literal name <> ":" $$ blankline           return $ nowrap $ anchor $$ contents $$ border $$ blankline     else do           let rub     = "rubric:: " <> contents-          let name' | null name    = empty-                    | otherwise    = ":name: " <> text name-          let cls   | null classes = empty-                    | otherwise    = ":class: " <> text (unwords classes)+          let name' | T.null name    = empty+                    | otherwise      = ":name: " <> literal name+          let cls   | null classes   = empty+                    | otherwise      = ":class: " <> literal (T.unwords classes)           return $ nowrap $ hang 3 ".. " (rub $$ name' $$ cls) $$ blankline blockToRST (CodeBlock (_,classes,kvs) str) = do   opts <- gets stOptions-  let startnum = maybe "" (\x -> " " <> text x) $ lookup "startFrom" kvs+  let startnum = maybe "" (\x -> " " <> literal x) $ lookup "startFrom" kvs   let numberlines = if "numberLines" `elem` classes                        then "   :number-lines:" <> startnum                        else empty   if "haskell" `elem` classes && "literate" `elem` classes &&                   isEnabled Ext_literate_haskell opts-     then return $ prefixed "> " (text str) $$ blankline+     then return $ prefixed "> " (literal str) $$ blankline      else return $           (case [c | c <- classes,                      c `notElem` ["sourceCode","literate","numberLines",                                   "number-lines","example"]] of              []       -> "::"-             (lang:_) -> (".. code:: " <> text lang) $$ numberlines)-          $+$ nest 3 (text str) $$ blankline+             (lang:_) -> (".. code:: " <> literal lang) $$ numberlines)+          $+$ nest 3 (literal str) $$ blankline blockToRST (BlockQuote blocks) = do   contents <- blockListToRST blocks   return $ nest 3 contents <> blankline@@ -289,81 +296,101 @@   opts <- gets stOptions   let isSimple = all (== 0) widths   tbl <- if isSimple-            then simpleTable opts blocksToDoc headers rows+            then do+              tbl' <- simpleTable opts blocksToDoc headers rows+              if offset tbl' > writerColumns opts+                 then gridTable opts blocksToDoc (all null headers)+                      (map (const AlignDefault) aligns) widths+                      headers rows+                 else return tbl'             else gridTable opts blocksToDoc (all null headers)                   (map (const AlignDefault) aligns) widths                   headers rows-  return $ if null caption-              then tbl $$ blankline-              else (".. table:: " <> caption') $$ blankline $$ nest 3 tbl $$-                   blankline+  return $ blankline $$+           (if null caption+               then tbl+               else (".. table:: " <> caption') $$ blankline $$ nest 3 tbl) $$+           blankline blockToRST (BulletList items) = do   contents <- mapM bulletListItemToRST items   -- ensure that sublists have preceding blank line-  return $ blankline $$ chomp (vcat contents) $$ blankline+  return $ blankline $$+           (if isTightList items then vcat else vsep) contents $$+           blankline blockToRST (OrderedList (start, style', delim) items) = do   let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim                    then replicate (length items) "#."                    else take (length items) $ orderedListMarkers                                               (start, style', delim)-  let maxMarkerLength = maximum $ map length markers-  let markers' = map (\m -> let s = maxMarkerLength - length m-                            in  m ++ replicate s ' ') markers+  let maxMarkerLength = maximum $ map T.length markers+  let markers' = map (\m -> let s = maxMarkerLength - T.length m+                            in  m <> T.replicate s " ") markers   contents <- zipWithM orderedListItemToRST markers' items   -- ensure that sublists have preceding blank line-  return $ blankline $$ chomp (vcat contents) $$ blankline+  return $ blankline $$+           (if isTightList items then vcat else vsep) contents $$+           blankline blockToRST (DefinitionList items) = do   contents <- mapM definitionListItemToRST items   -- ensure that sublists have preceding blank line-  return $ blankline $$ chomp (vcat contents) $$ blankline+  return $ blankline $$ vcat contents $$ blankline  -- | Convert bullet list item (list of blocks) to RST.-bulletListItemToRST :: PandocMonad m => [Block] -> RST m Doc+bulletListItemToRST :: PandocMonad m => [Block] -> RST m (Doc Text) bulletListItemToRST items = do   contents <- blockListToRST items-  return $ hang 3 "-  " $ contents <> cr+  return $ hang 3 "-  " contents $$+      if endsWithPlain items+         then cr+         else blankline  -- | Convert ordered list item (a list of blocks) to RST. orderedListItemToRST :: PandocMonad m-                     => String   -- ^ marker for list item+                     => Text   -- ^ marker for list item                      -> [Block]  -- ^ list item (list of blocks)-                     -> RST m Doc+                     -> RST m (Doc Text) orderedListItemToRST marker items = do   contents <- blockListToRST items-  let marker' = marker ++ " "-  return $ hang (length marker') (text marker') $ contents <> cr+  let marker' = marker <> " "+  return $ hang (T.length marker') (literal marker') contents $$+      if endsWithPlain items+         then cr+         else blankline  -- | Convert definition list item (label, list of blocks) to RST.-definitionListItemToRST :: PandocMonad m => ([Inline], [[Block]]) -> RST m Doc+definitionListItemToRST :: PandocMonad m => ([Inline], [[Block]]) -> RST m (Doc Text) definitionListItemToRST (label, defs) = do   label' <- inlineListToRST label   contents <- liftM vcat $ mapM blockListToRST defs-  return $ nowrap label' $$ nest 3 (nestle contents <> cr)+  return $ nowrap label' $$ nest 3 (nestle contents) $$+      if isTightList defs+         then cr+         else blankline  -- | Format a list of lines as line block.-linesToLineBlock :: PandocMonad m => [[Inline]] -> RST m Doc+linesToLineBlock :: PandocMonad m => [[Inline]] -> RST m (Doc Text) linesToLineBlock inlineLines = do   lns <- mapM inlineListToRST inlineLines   return $-                      vcat (map (hang 2 (text "| ")) lns) <> blankline+                      vcat (map (hang 2 (literal "| ")) lns) <> blankline  -- | Convert list of Pandoc block elements to RST. blockListToRST' :: PandocMonad m                 => Bool                 -> [Block]       -- ^ List of block elements-                -> RST m Doc+                -> RST m (Doc Text) blockListToRST' topLevel blocks = do   -- insert comment between list and quoted blocks, see #4248 and #3675   let fixBlocks (b1:b2@(BlockQuote _):bs)         | toClose b1 = b1 : commentSep : b2 : fixBlocks bs         where-          toClose Plain{}                                = False-          toClose Header{}                               = False-          toClose LineBlock{}                            = False-          toClose HorizontalRule                         = False-          toClose (Para [Image _ _ (_,'f':'i':'g':':':_)]) = True-          toClose Para{}                                 = False-          toClose _                                        = True+          toClose Plain{}                  = False+          toClose Header{}                 = False+          toClose LineBlock{}              = False+          toClose HorizontalRule           = False+          toClose (Para [Image _ _ (_,t)]) = "fig:" `T.isPrefixOf` t+          toClose Para{}                   = False+          toClose _                        = True           commentSep  = RawBlock "rst" "..\n\n"       fixBlocks (b:bs) = b : fixBlocks bs       fixBlocks [] = []@@ -375,7 +402,7 @@  blockListToRST :: PandocMonad m                => [Block]       -- ^ List of block elements-               -> RST m Doc+               -> RST m (Doc Text) blockListToRST = blockListToRST' False  transformInlines :: [Inline] -> [Inline]@@ -419,26 +446,30 @@         transformNested :: [Inline] -> [Inline]         transformNested = map (mapNested stripLeadingTrailingSpace)         surroundComplex :: Inline -> Inline -> Bool-        surroundComplex (Str s@(_:_)) (Str s'@(_:_)) =-          case (last s, head s') of-             ('\'','\'') -> True-             ('"','"')   -> True-             ('<','>')   -> True-             ('[',']')   -> True-             ('{','}')   -> True-             _           -> False+        surroundComplex (Str s) (Str s')+          | Just (_, c)  <- T.unsnoc s+          , Just (c', _) <- T.uncons s'+          = case (c, c') of+              ('\'','\'') -> True+              ('"','"')   -> True+              ('<','>')   -> True+              ('[',']')   -> True+              ('{','}')   -> True+              _           -> False         surroundComplex _ _ = False         okAfterComplex :: Inline -> Bool         okAfterComplex Space = True         okAfterComplex SoftBreak = True         okAfterComplex LineBreak = True-        okAfterComplex (Str (c:_)) = isSpace c || c `elem` ("-.,:;!?\\/'\")]}>–—" :: String)+        okAfterComplex (Str (T.uncons -> Just (c,_)))+          = isSpace c || c `elemText` "-.,:;!?\\/'\")]}>–—"         okAfterComplex _ = False         okBeforeComplex :: Inline -> Bool         okBeforeComplex Space = True         okBeforeComplex SoftBreak = True         okBeforeComplex LineBreak = True-        okBeforeComplex (Str (c:_)) = isSpace c || c `elem` ("-:/'\"<([{–—" :: String)+        okBeforeComplex (Str (T.unsnoc -> Just (_,c)))+                          = isSpace c || c `elemText` "-:/'\"<([{–—"         okBeforeComplex _ = False         isComplex :: Inline -> Bool         isComplex (Emph _)        = True@@ -466,7 +497,7 @@         combineAll = foldl combine []          combine :: [Inline] -> Inline -> [Inline]-        combine f i = +        combine f i =           case (outer, i) of           -- quotes are not rendered using RST inlines, so we can keep           -- them and they will be readable and parsable@@ -531,20 +562,20 @@ setInlineChildren (Span a _) i      = Span a i setInlineChildren leaf _            = leaf -inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc+inlineListToRST :: PandocMonad m => [Inline] -> RST m (Doc Text) inlineListToRST = writeInlines . walk transformInlines  -- | Convert list of Pandoc inline elements to RST.-writeInlines :: PandocMonad m => [Inline] -> RST m Doc+writeInlines :: PandocMonad m => [Inline] -> RST m (Doc Text) writeInlines lst = mapM inlineToRST lst >>= return . hcat  -- | Convert Pandoc inline element to RST.-inlineToRST :: PandocMonad m => Inline -> RST m Doc+inlineToRST :: PandocMonad m => Inline -> RST m (Doc Text) inlineToRST (Span (_,_,kvs) ils) = do   contents <- writeInlines ils   return $     case lookup "role" kvs of-          Just role -> ":" <> text role <> ":`" <> contents <> "`"+          Just role -> ":" <> literal role <> ":`" <> contents <> "`"           Nothing   -> contents inlineToRST (Emph lst) = do   contents <- writeInlines lst@@ -577,7 +608,7 @@ inlineToRST (Cite _  lst) =   writeInlines lst inlineToRST (Code (_,["interpreted-text"],[("role",role)]) str) = do-  return $ ":" <> text role <> ":`" <> text str <> "`"+  return $ ":" <> literal role <> ":`" <> literal str <> "`" inlineToRST (Code _ str) = do   opts <- gets stOptions   -- we trim the string because the delimiters must adjoin a@@ -585,28 +616,28 @@   -- we use :literal: when the code contains backticks, since   -- :literal: allows backslash-escapes; see #3974   return $-    if '`' `elem` str-       then ":literal:`" <> text (escapeString opts (trim str)) <> "`"-       else "``" <> text (trim str) <> "``"+    if '`' `elemText` str+       then ":literal:`" <> literal (escapeText opts (trim str)) <> "`"+       else "``" <> literal (trim str) <> "``" inlineToRST (Str str) = do   opts <- gets stOptions-  return $ text $+  return $ literal $     (if isEnabled Ext_smart opts         then unsmartify opts-        else id) $ escapeString opts str+        else id) $ escapeText opts str inlineToRST (Math t str) = do   modify $ \st -> st{ stHasMath = True }   return $ if t == InlineMath-              then ":math:`" <> text str <> "`"-              else if '\n' `elem` str+              then ":math:`" <> literal str <> "`"+              else if '\n' `elemText` str                    then blankline $$ ".. math::" $$-                        blankline $$ nest 3 (text str) $$ blankline-                   else blankline $$ (".. math:: " <> text str) $$ blankline+                        blankline $$ nest 3 (literal str) $$ blankline+                   else blankline $$ (".. math:: " <> literal str) $$ blankline inlineToRST il@(RawInline f x)-  | f == "rst" = return $ text x+  | f == "rst" = return $ literal x   | f == "latex" || f == "tex" = do       modify $ \st -> st{ stHasRawTeX = True }-      return $ ":raw-latex:`" <> text x <> "`"+      return $ ":raw-latex:`" <> literal x <> "`"   | otherwise  = empty <$ report (InlineNotRendered il) inlineToRST LineBreak = return cr -- there's no line break in RST (see Para) inlineToRST Space = return space@@ -619,11 +650,11 @@ -- autolink inlineToRST (Link _ [Str str] (src, _))   | isURI src &&-    if "mailto:" `isPrefixOf` src-       then src == escapeURI ("mailto:" ++ str)+    if "mailto:" `T.isPrefixOf` src+       then src == escapeURI ("mailto:" <> str)        else src == escapeURI str = do-  let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)-  return $ text srcSuffix+  let srcSuffix = fromMaybe src (T.stripPrefix "mailto:" src)+  return $ literal srcSuffix inlineToRST (Link _ [Image attr alt (imgsrc,imgtit)] (src, _tit)) = do   label <- registerImage attr alt (imgsrc,imgtit) (Just src)   return $ "|" <> label <> "|"@@ -637,11 +668,11 @@                    if src == src' && tit == tit'                       then return $ "`" <> linktext <> "`_"                       else-                        return $ "`" <> linktext <> " <" <> text src <> ">`__"+                        return $ "`" <> linktext <> " <" <> literal src <> ">`__"                  Nothing -> do                    modify $ \st -> st { stLinks = (txt,(src,tit)):refs }                    return $ "`" <> linktext <> "`_"-    else return $ "`" <> linktext <> " <" <> text src <> ">`__"+    else return $ "`" <> linktext <> " <" <> literal src <> ">`__" inlineToRST (Image attr alternate (source, tit)) = do   label <- registerImage attr alternate (source,tit) Nothing   return $ "|" <> label <> "|"@@ -652,7 +683,7 @@   let ref = show $ length notes + 1   return $ " [" <> text ref <> "]_" -registerImage :: PandocMonad m => Attr -> [Inline] -> Target -> Maybe String -> RST m Doc+registerImage :: PandocMonad m => Attr -> [Inline] -> Target -> Maybe Text -> RST m (Doc Text) registerImage attr alt (src,tit) mbtarget = do   pics <- gets stImages   txt <- case lookup alt pics of@@ -660,19 +691,19 @@                  -> return alt                _ -> do                  let alt' = if null alt || alt == [Str ""]-                               then [Str $ "image" ++ show (length pics)]+                               then [Str $ "image" <> tshow (length pics)]                                else alt                  modify $ \st -> st { stImages =                         (alt', (attr,src,tit, mbtarget)):stImages st }                  return alt'   inlineListToRST txt -imageDimsToRST :: PandocMonad m => Attr -> RST m Doc+imageDimsToRST :: PandocMonad m => Attr -> RST m (Doc Text) imageDimsToRST attr = do   let (ident, _, _) = attr-      name = if null ident+      name = if T.null ident                 then empty-                else ":name: " <> text ident+                else ":name: " <> literal ident       showDim dir = let cols d = ":" <> text (show dir) <> ": " <> text (show d)                     in  case dimension dir attr of                           Just (Percent a) ->@@ -685,14 +716,14 @@  simpleTable :: PandocMonad m             => WriterOptions-            -> (WriterOptions -> [Block] -> m Doc)+            -> (WriterOptions -> [Block] -> m (Doc Text))             -> [[Block]]             -> [[[Block]]]-            -> m Doc+            -> m (Doc Text) simpleTable opts blocksToDoc headers rows = do   -- can't have empty cells in first column:   let fixEmpties (d:ds) = if isEmpty d-                             then text "\\ " : ds+                             then literal "\\ " : ds                              else d : ds       fixEmpties [] = []   headerDocs <- if all null headers@@ -702,8 +733,8 @@   let numChars [] = 0       numChars xs = maximum . map offset $ xs   let colWidths = map numChars $ transpose (headerDocs : rowDocs)-  let toRow = hsep . zipWith lblock colWidths-  let hline = nowrap $ hsep (map (\n -> text (replicate n '=')) colWidths)+  let toRow = mconcat . intersperse (lblock 1 " ") . zipWith lblock colWidths+  let hline = nowrap $ hsep (map (\n -> literal (T.replicate n "=")) colWidths)   let hdr = if all null headers                then mempty                else hline $$ toRow headerDocs
src/Text/Pandoc/Writers/RTF.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE NoImplicitPrelude   #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings   #-} {- |    Module      : Text.Pandoc.Writers.RTF    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -18,7 +19,6 @@ import Control.Monad import qualified Data.ByteString as B import Data.Char (chr, isDigit, ord)-import Data.List (intercalate, isSuffixOf) import qualified Data.Map as M import Data.Text (Text) import qualified Data.Text as T@@ -30,7 +30,8 @@ import Text.Pandoc.Logging import Text.Pandoc.Options import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate)+import Text.DocLayout (render, literal) import Text.Pandoc.Walk import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared@@ -45,28 +46,28 @@       case result of            (imgdata, Just mime)              | mime == "image/jpeg" || mime == "image/png" -> do-             let bytes = map (printf "%02x") $ B.unpack imgdata+             let bytes = map (T.pack . printf "%02x") $ B.unpack imgdata              filetype <-                 case mime of                      "image/jpeg" -> return "\\jpegblip"                      "image/png"  -> return "\\pngblip"                      _            -> throwError $                                          PandocShouldNeverHappenError $-                                         "Unknown file type " ++ mime+                                         "Unknown file type " <> mime              sizeSpec <-                 case imageSize opts imgdata of                      Left msg -> do                        report $ CouldNotDetermineImageSize src msg                        return ""-                     Right sz -> return $ "\\picw" ++ show xpx ++-                                "\\pich" ++ show ypx ++-                                "\\picwgoal" ++ show (floor (xpt * 20) :: Integer)-                                ++ "\\pichgoal" ++ show (floor (ypt * 20) :: Integer)+                     Right sz -> return $ "\\picw" <> tshow xpx <>+                                "\\pich" <> tshow ypx <>+                                "\\picwgoal" <> tshow (floor (xpt * 20) :: Integer)+                                <> "\\pichgoal" <> tshow (floor (ypt * 20) :: Integer)                         -- twip = 1/1440in = 1/20pt                         where (xpx, ypx) = sizeInPixels sz                               (xpt, ypt) = desiredSizeInPoints opts attr sz-             let raw = "{\\pict" ++ filetype ++ sizeSpec ++ "\\bin " ++-                        concat bytes ++ "}"+             let raw = "{\\pict" <> filetype <> sizeSpec <> "\\bin " <>+                        T.concat bytes <> "}"              if B.null imgdata                 then do                   report $ CouldNotFetchResource src "image contained no data"@@ -79,7 +80,7 @@              report $ CouldNotDetermineMimeType src              return x)   (\e -> do-     report $ CouldNotFetchResource src (show e)+     report $ CouldNotFetchResource src $ tshow e      return x) rtfEmbedImage _ x = return x @@ -96,9 +97,10 @@                     . M.adjust toPlain "author"                     . M.adjust toPlain "date"                     $ metamap-  metadata <- metaToJSON options-              (fmap concat . mapM (blockToRTF 0 AlignDefault))-              inlinesToRTF+  metadata <- metaToContext options+              (fmap (literal . T.concat) .+                mapM (blockToRTF 0 AlignDefault))+              (fmap literal . inlinesToRTF)               meta'   body <- blocksToRTF 0 AlignDefault blocks   toc <- blocksToRTF 0 AlignDefault@@ -112,34 +114,32 @@                         -- of the toc rather than a boolean:                         . defField "toc" toc                    else id) metadata-  T.pack <$>-      case writerTemplate options of-           Just tpl -> renderTemplate' tpl context-           Nothing  -> return $-                       case reverse body of-                            ('\n':_) -> body-                            _        -> body ++ "\n"+  return $+    case writerTemplate options of+       Just tpl -> render Nothing $ renderTemplate tpl context+       Nothing  -> case T.unsnoc body of+                        Just (_,'\n') -> body+                        _             -> body <> T.singleton '\n'  -- | Convert unicode characters (> 127) into rich text format representation.-handleUnicode :: String -> String-handleUnicode [] = []-handleUnicode (c:cs) =+handleUnicode :: Text -> Text+handleUnicode = T.concatMap $ \c ->   if ord c > 127      then if surrogate c           then let x = ord c - 0x10000                    (q, r) = x `divMod` 0x400                    upper = q + 0xd800                    lower = r + 0xDC00-               in enc (chr upper) ++ enc (chr lower) ++ handleUnicode cs-          else enc c ++ handleUnicode cs-     else c:handleUnicode cs+               in enc (chr upper) <> enc (chr lower)+          else enc c+     else T.singleton c   where     surrogate x = not (   (0x0000 <= ord x && ord x <= 0xd7ff)                        || (0xe000 <= ord x && ord x <= 0xffff) )-    enc x = '\\':'u':show (ord x) ++ "?"+    enc x = "\\u" <> tshow (ord x) <> "?"  -- | Escape special characters.-escapeSpecial :: String -> String+escapeSpecial :: Text -> Text escapeSpecial = escapeStringUsing $   [ ('\t',"\\tab ")   , ('\8216',"\\u8216'")@@ -148,47 +148,47 @@   , ('\8221',"\\u8221\"")   , ('\8211',"\\u8211-")   , ('\8212',"\\u8212-")-  ] ++ backslashEscapes "{\\}"+  ] <> backslashEscapes "{\\}"  -- | Escape strings as needed for rich text format.-stringToRTF :: String -> String+stringToRTF :: Text -> Text stringToRTF = handleUnicode . escapeSpecial  -- | Escape things as needed for code block in RTF.-codeStringToRTF :: String -> String-codeStringToRTF str = intercalate "\\line\n" $ lines (stringToRTF str)+codeStringToRTF :: Text -> Text+codeStringToRTF str = T.intercalate "\\line\n" $ T.lines (stringToRTF str)  -- | Make a paragraph with first-line indent, block indent, and space after. rtfParSpaced :: Int       -- ^ space after (in twips)              -> Int       -- ^ block indent (in twips)              -> Int       -- ^ first line indent (relative to block) (in twips)              -> Alignment -- ^ alignment-             -> String    -- ^ string with content-             -> String+             -> Text    -- ^ string with content+             -> Text rtfParSpaced spaceAfter indent firstLineIndent alignment content =   let alignString = case alignment of                            AlignLeft    -> "\\ql "                            AlignRight   -> "\\qr "                            AlignCenter  -> "\\qc "                            AlignDefault -> "\\ql "-  in  "{\\pard " ++ alignString ++-      "\\f0 \\sa" ++ show spaceAfter ++ " \\li" ++ show indent ++-      " \\fi" ++ show firstLineIndent ++ " " ++ content ++ "\\par}\n"+  in  "{\\pard " <> alignString <>+      "\\f0 \\sa" <> tshow spaceAfter <> " \\li" <> T.pack (show indent) <>+      " \\fi" <> tshow firstLineIndent <> " " <> content <> "\\par}\n"  -- | Default paragraph. rtfPar :: Int       -- ^ block indent (in twips)        -> Int       -- ^ first line indent (relative to block) (in twips)        -> Alignment -- ^ alignment-       -> String    -- ^ string with content-       -> String+       -> Text    -- ^ string with content+       -> Text rtfPar = rtfParSpaced 180  -- | Compact paragraph (e.g. for compact list items). rtfCompact ::  Int       -- ^ block indent (in twips)            ->  Int       -- ^ first line indent (relative to block) (in twips)            ->  Alignment -- ^ alignment-           ->  String    -- ^ string with content-           ->  String+           ->  Text    -- ^ string with content+           ->  Text rtfCompact = rtfParSpaced 0  -- number of twips to indent@@ -199,13 +199,13 @@ listIncrement = 360  -- | Returns appropriate bullet list marker for indent level.-bulletMarker :: Int -> String+bulletMarker :: Int -> Text bulletMarker indent = case indent `mod` 720 of                              0 -> "\\bullet "                              _ -> "\\endash "  -- | Returns appropriate (list of) ordered list markers for indent level.-orderedMarkers :: Int -> ListAttributes -> [String]+orderedMarkers :: Int -> ListAttributes -> [Text] orderedMarkers indent (start, style, delim) =   if style == DefaultStyle && delim == DefaultDelim      then case indent `mod` 720 of@@ -217,15 +217,15 @@             => Int             -> Alignment             -> [Block]-            -> m String-blocksToRTF indent align = fmap concat . mapM (blockToRTF indent align)+            -> m Text+blocksToRTF indent align = fmap T.concat . mapM (blockToRTF indent align)  -- | Convert Pandoc block element to RTF. blockToRTF :: PandocMonad m            => Int       -- ^ indent level            -> Alignment -- ^ alignment            -> Block     -- ^ block to convert-           -> m String+           -> m Text blockToRTF _ _ Null = return "" blockToRTF indent alignment (Div _ bs) =   blocksToRTF indent alignment bs@@ -238,139 +238,143 @@ blockToRTF indent alignment (BlockQuote lst) =   blocksToRTF (indent + indentIncrement) alignment lst blockToRTF indent _ (CodeBlock _ str) =-  return $ rtfPar indent 0 AlignLeft ("\\f1 " ++ codeStringToRTF str)+  return $ rtfPar indent 0 AlignLeft ("\\f1 " <> codeStringToRTF str) blockToRTF _ _ b@(RawBlock f str)   | f == Format "rtf" = return str   | otherwise         = do       report $ BlockNotRendered b       return ""-blockToRTF indent alignment (BulletList lst) = (spaceAtEnd . concat) <$>+blockToRTF indent alignment (BulletList lst) = (spaceAtEnd . T.concat) <$>   mapM (listItemToRTF alignment indent (bulletMarker indent)) lst blockToRTF indent alignment (OrderedList attribs lst) =-  (spaceAtEnd . concat) <$>+  (spaceAtEnd . T.concat) <$>    zipWithM (listItemToRTF alignment indent) (orderedMarkers indent attribs) lst-blockToRTF indent alignment (DefinitionList lst) = (spaceAtEnd . concat) <$>+blockToRTF indent alignment (DefinitionList lst) = (spaceAtEnd . T.concat) <$>   mapM (definitionListItemToRTF alignment indent) lst blockToRTF indent _ HorizontalRule = return $   rtfPar indent 0 AlignCenter "\\emdash\\emdash\\emdash\\emdash\\emdash" blockToRTF indent alignment (Header level _ lst) = do   contents <- inlinesToRTF lst   return $ rtfPar indent 0 alignment $-             "\\b \\fs" ++ show (40 - (level * 4)) ++ " " ++ contents+             "\\b \\fs" <> tshow (40 - (level * 4)) <> " " <> contents blockToRTF indent alignment (Table caption aligns sizes headers rows) = do   caption' <- inlinesToRTF caption   header' <- if all null headers                 then return ""                 else tableRowToRTF True indent aligns sizes headers-  rows' <- concat <$> mapM (tableRowToRTF False indent aligns sizes) rows-  return $ header' ++ rows' ++ rtfPar indent 0 alignment caption'+  rows' <- T.concat <$> mapM (tableRowToRTF False indent aligns sizes) rows+  return $ header' <> rows' <> rtfPar indent 0 alignment caption'  tableRowToRTF :: PandocMonad m-              => Bool -> Int -> [Alignment] -> [Double] -> [[Block]] -> m String+              => Bool -> Int -> [Alignment] -> [Double] -> [[Block]] -> m Text tableRowToRTF header indent aligns sizes' cols = do   let totalTwips = 6 * 1440 -- 6 inches   let sizes = if all (== 0) sizes'                  then replicate (length cols) (1.0 / fromIntegral (length cols))                  else sizes'-  columns <- concat <$>+  columns <- T.concat <$>      zipWithM (tableItemToRTF indent) aligns cols   let rightEdges = tail $ scanl (\sofar new -> sofar + floor (new * totalTwips))                                 (0 :: Integer) sizes   let cellDefs = map (\edge -> (if header                                    then "\\clbrdrb\\brdrs"-                                   else "") ++ "\\cellx" ++ show edge)+                                   else "") <> "\\cellx" <> tshow edge)                      rightEdges-  let start = "{\n\\trowd \\trgaph120\n" ++ concat cellDefs ++ "\n" +++  let start = "{\n\\trowd \\trgaph120\n" <> T.concat cellDefs <> "\n" <>               "\\trkeep\\intbl\n{\n"   let end = "}\n\\intbl\\row}\n"-  return $ start ++ columns ++ end+  return $ start <> columns <> end -tableItemToRTF :: PandocMonad m => Int -> Alignment -> [Block] -> m String+tableItemToRTF :: PandocMonad m => Int -> Alignment -> [Block] -> m Text tableItemToRTF indent alignment item = do   contents <- blocksToRTF indent alignment item-  return $ "{" ++ substitute "\\pard" "\\pard\\intbl" contents ++ "\\cell}\n"+  return $ "{" <> T.replace "\\pard" "\\pard\\intbl" contents <> "\\cell}\n"  -- | Ensure that there's the same amount of space after compact -- lists as after regular lists.-spaceAtEnd :: String -> String-spaceAtEnd str =-  if "\\par}\n" `isSuffixOf` str-     then take (length str - 6) str ++ "\\sa180\\par}\n"-     else str+spaceAtEnd :: Text -> Text+spaceAtEnd str = maybe str (<> "\\sa180\\par}\n") $ T.stripSuffix "\\par}\n" str  -- | Convert list item (list of blocks) to RTF. listItemToRTF :: PandocMonad m               => Alignment  -- ^ alignment               -> Int        -- ^ indent level-              -> String     -- ^ list start marker+              -> Text     -- ^ list start marker               -> [Block]    -- ^ list item (list of blocks)-              -> m String+              -> m Text listItemToRTF alignment indent marker [] = return $   rtfCompact (indent + listIncrement) (negate listIncrement) alignment-             (marker ++ "\\tx" ++ show listIncrement ++ "\\tab ")+             (marker <> "\\tx" <> tshow listIncrement <> "\\tab ") listItemToRTF alignment indent marker (listFirst:listRest) = do   let f = blockToRTF (indent + listIncrement) alignment   first <- f listFirst   rest <- mapM f listRest-  let listMarker = "\\fi" ++ show (negate listIncrement) ++ " " ++ marker ++-                   "\\tx" ++ show listIncrement ++ "\\tab"-  let insertListMarker ('\\':'f':'i':'-':d:xs) | isDigit d =-        listMarker ++ dropWhile isDigit xs-      insertListMarker ('\\':'f':'i':d:xs) | isDigit d =-        listMarker ++ dropWhile isDigit xs-      insertListMarker (x:xs) =-        x : insertListMarker xs-      insertListMarker [] = []+  let listMarker = "\\fi" <> tshow (negate listIncrement) <> " " <> marker <>+                   "\\tx" <> tshow listIncrement <> "\\tab"+  -- Find the first occurrence of \\fi or \\fi-, then replace it and the following+  -- digits with the list marker.+  let insertListMarker t = case popDigit $ optionDash $ T.drop 3 suff of+        Just suff' -> pref <> listMarker <> T.dropWhile isDigit suff'+        Nothing    -> t+        where+          (pref, suff) = T.breakOn "\\fi" t+          optionDash x = case T.uncons x of+            Just ('-', xs) -> xs+            _              -> x+          popDigit x+            | Just (d, xs) <- T.uncons x+            , isDigit d = Just xs+            | otherwise = Nothing    -- insert the list marker into the (processed) first block-  return $ insertListMarker first ++ concat rest+  return $ insertListMarker first <> T.concat rest  -- | Convert definition list item (label, list of blocks) to RTF. definitionListItemToRTF :: PandocMonad m                         => Alignment          -- ^ alignment                         -> Int                -- ^ indent level                         -> ([Inline],[[Block]]) -- ^ list item (list of blocks)-                        -> m String+                        -> m Text definitionListItemToRTF alignment indent (label, defs) = do   labelText <- blockToRTF indent alignment (Plain label)   itemsText <- blocksToRTF (indent + listIncrement) alignment (concat defs)-  return $ labelText ++ itemsText+  return $ labelText <> itemsText  -- | Convert list of inline items to RTF. inlinesToRTF :: PandocMonad m              => [Inline]   -- ^ list of inlines to convert-             -> m String-inlinesToRTF lst = concat <$> mapM inlineToRTF lst+             -> m Text+inlinesToRTF lst = T.concat <$> mapM inlineToRTF lst  -- | Convert inline item to RTF. inlineToRTF :: PandocMonad m             => Inline         -- ^ inline to convert-            -> m String+            -> m Text inlineToRTF (Span _ lst) = inlinesToRTF lst inlineToRTF (Emph lst) = do   contents <- inlinesToRTF lst-  return $ "{\\i " ++ contents ++ "}"+  return $ "{\\i " <> contents <> "}" inlineToRTF (Strong lst) = do   contents <- inlinesToRTF lst-  return $ "{\\b " ++ contents ++ "}"+  return $ "{\\b " <> contents <> "}" inlineToRTF (Strikeout lst) = do   contents <- inlinesToRTF lst-  return $ "{\\strike " ++ contents ++ "}"+  return $ "{\\strike " <> contents <> "}" inlineToRTF (Superscript lst) = do   contents <- inlinesToRTF lst-  return $ "{\\super " ++ contents ++ "}"+  return $ "{\\super " <> contents <> "}" inlineToRTF (Subscript lst) = do   contents <- inlinesToRTF lst-  return $ "{\\sub " ++ contents ++ "}"+  return $ "{\\sub " <> contents <> "}" inlineToRTF (SmallCaps lst) = do   contents <- inlinesToRTF lst-  return $ "{\\scaps " ++ contents ++ "}"+  return $ "{\\scaps " <> contents <> "}" inlineToRTF (Quoted SingleQuote lst) = do   contents <- inlinesToRTF lst-  return $ "\\u8216'" ++ contents ++ "\\u8217'"+  return $ "\\u8216'" <> contents <> "\\u8217'" inlineToRTF (Quoted DoubleQuote lst) = do   contents <- inlinesToRTF lst-  return $ "\\u8220\"" ++ contents ++ "\\u8221\""-inlineToRTF (Code _ str) = return $ "{\\f1 " ++ codeStringToRTF str ++ "}"+  return $ "\\u8220\"" <> contents <> "\\u8221\""+inlineToRTF (Code _ str) = return $ "{\\f1 " <> codeStringToRTF str <> "}" inlineToRTF (Str str) = return $ stringToRTF str inlineToRTF (Math t str) = texMathToInlines t str >>= inlinesToRTF inlineToRTF (Cite _ lst) = inlinesToRTF lst@@ -384,11 +388,11 @@ inlineToRTF Space = return " " inlineToRTF (Link _ text (src, _)) = do   contents <- inlinesToRTF text-  return $ "{\\field{\\*\\fldinst{HYPERLINK \"" ++ codeStringToRTF src ++-    "\"}}{\\fldrslt{\\ul\n" ++ contents ++ "\n}}}\n"+  return $ "{\\field{\\*\\fldinst{HYPERLINK \"" <> codeStringToRTF src <>+    "\"}}{\\fldrslt{\\ul\n" <> contents <> "\n}}}\n" inlineToRTF (Image _ _ (source, _)) =-  return $ "{\\cf1 [image: " ++ source ++ "]\\cf0}"+  return $ "{\\cf1 [image: " <> source <> "]\\cf0}" inlineToRTF (Note contents) = do-  body <- concat <$> mapM (blockToRTF 0 AlignDefault) contents-  return $ "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++-    body ++ "}"+  body <- T.concat <$> mapM (blockToRTF 0 AlignDefault) contents+  return $ "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " <>+    body <> "}"
src/Text/Pandoc/Writers/Roff.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Text.Pandoc.Writers.Roff    Copyright   : Copyright (C) 2007-2019 John MacFarlane@@ -24,10 +25,13 @@ import Data.Char (ord, isAscii) import Control.Monad.State.Strict import qualified Data.Map as Map+import Data.Text (Text)+import qualified Data.Text as Text+import Data.String import Data.Maybe (fromMaybe, isJust, catMaybes) import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Printf (printf) import Text.Pandoc.RoffChar (standardEscapes,                               characterCodes, combiningAccents)@@ -65,39 +69,41 @@                 | AsciiOnly        -- ^ escape everything                 deriving Show -combiningAccentsMap :: Map.Map Char String+combiningAccentsMap :: Map.Map Char Text combiningAccentsMap = Map.fromList combiningAccents -essentialEscapes :: Map.Map Char String+essentialEscapes :: Map.Map Char Text essentialEscapes = Map.fromList standardEscapes  -- | Escape special characters for roff.-escapeString :: EscapeMode -> String -> String-escapeString _ [] = []-escapeString escapeMode ('\n':'.':xs) =-  '\n':'\\':'&':'.':escapeString escapeMode xs-escapeString escapeMode (x:xs) =-  case Map.lookup x essentialEscapes of-    Just s  -> s ++ escapeString escapeMode xs-    Nothing-     | isAscii x -> x : escapeString escapeMode xs-     | otherwise ->-        case escapeMode of-          AllowUTF8 -> x : escapeString escapeMode xs-          AsciiOnly ->-            let accents = catMaybes $ takeWhile isJust-                  (map (\c -> Map.lookup c combiningAccentsMap) xs)-                rest = drop (length accents) xs-                s = case Map.lookup x characterCodeMap of-                      Just t  -> "\\[" <> unwords (t:accents) <> "]"-                      Nothing -> "\\[" <> unwords-                       (printf "u%04X" (ord x) : accents) <> "]"-            in  s ++ escapeString escapeMode rest+escapeString :: EscapeMode -> Text -> Text+escapeString e = Text.concat . escapeString' e . Text.unpack+  where+    escapeString' _ [] = []+    escapeString' escapeMode ('\n':'.':xs) =+      "\n\\&." : escapeString' escapeMode xs+    escapeString' escapeMode (x:xs) =+      case Map.lookup x essentialEscapes of+        Just s  -> s : escapeString' escapeMode xs+        Nothing+          | isAscii x -> Text.singleton x : escapeString' escapeMode xs+          | otherwise ->+              case escapeMode of+                AllowUTF8 -> Text.singleton x : escapeString' escapeMode xs+                AsciiOnly ->+                  let accents = catMaybes $ takeWhile isJust+                        (map (\c -> Map.lookup c combiningAccentsMap) xs)+                      rest = drop (length accents) xs+                      s = case Map.lookup x characterCodeMap of+                            Just t  -> "\\[" <> Text.unwords (t:accents) <> "]"+                            Nothing -> "\\[" <> Text.unwords+                              (Text.pack (printf "u%04X" (ord x)) : accents) <> "]"+                  in  s : escapeString' escapeMode rest -characterCodeMap :: Map.Map Char String+characterCodeMap :: Map.Map Char Text characterCodeMap = Map.fromList characterCodes -fontChange :: PandocMonad m => MS m Doc+fontChange :: (HasChars a, IsString a, PandocMonad m) => MS m (Doc a) fontChange = do   features <- gets stFontFeatures   inHeader <- gets stInHeader@@ -110,7 +116,8 @@        then text "\\f[R]"        else text $ "\\f[" ++ filling ++ "]" -withFontFeature :: PandocMonad m => Char -> MS m Doc -> MS m Doc+withFontFeature :: (HasChars a, IsString a, PandocMonad m)+                => Char -> MS m (Doc a) -> MS m (Doc a) withFontFeature c action = do   modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }   begin <- fontChange
src/Text/Pandoc/Writers/Shared.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {- |@@ -13,9 +14,9 @@ Shared utility functions for pandoc writers. -} module Text.Pandoc.Writers.Shared (-                       metaToJSON-                     , metaToJSON'-                     , addVariablesToJSON+                       metaToContext+                     , metaToContext'+                     , addVariablesToContext                      , getField                      , setField                      , resetField@@ -33,159 +34,130 @@                      , toSubscript                      , toSuperscript                      , toTableOfContents+                     , endsWithPlain                      ) where import Prelude+import Safe (lastMay)+import qualified Data.ByteString.Lazy as BL+import Data.Maybe (fromMaybe, isNothing) import Control.Monad (zipWithM)-import qualified Data.Aeson as Aeson-import Data.Aeson (FromJSON (..), Result (..), ToJSON (..), Value (Object),-                   encode, fromJSON)+import Data.Aeson (ToJSON (..), encode) import Data.Char (chr, ord, isSpace)-import qualified Data.HashMap.Strict as H import Data.List (groupBy, intersperse, transpose, foldl')-import Data.Scientific (Scientific)+import Data.Text.Conversions (FromText(..)) import qualified Data.Map as M-import Data.Maybe (isJust) import qualified Data.Text as T-import qualified Data.Traversable as Traversable import qualified Text.Pandoc.Builder as Builder import Text.Pandoc.Definition import Text.Pandoc.Options-import Text.Pandoc.Pretty-import Text.Pandoc.Shared (stringify, hierarchicalize, Element(..), deNote,-                            safeRead)+import Text.DocLayout+import Text.Pandoc.Shared (stringify, makeSections, deNote, deLink) import Text.Pandoc.Walk (walk)-import Text.Pandoc.UTF8 (toStringLazy)+import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.XML (escapeStringForXML)+import Text.DocTemplates (Context(..), Val(..), TemplateTarget,+                          ToContext(..), FromContext(..)) --- | Create JSON value for template from a 'Meta' and an association list+-- | Create template Context from a 'Meta' and an association list -- of variables, specified at the command line or in the writer. -- Variables overwrite metadata fields with the same names. -- If multiple variables are set with the same name, a list is -- assigned.  Does nothing if 'writerTemplate' is Nothing.-metaToJSON :: (Functor m, Monad m, ToJSON a)-           => WriterOptions-           -> ([Block] -> m a)-           -> ([Inline] -> m a)-           -> Meta-           -> m Value-metaToJSON opts blockWriter inlineWriter meta-  | isJust (writerTemplate opts) =-    addVariablesToJSON opts <$> metaToJSON' blockWriter inlineWriter meta-  | otherwise = return (Object H.empty)+metaToContext :: (Monad m, TemplateTarget a)+              => WriterOptions+              -> ([Block] -> m (Doc a))+              -> ([Inline] -> m (Doc a))+              -> Meta+              -> m (Context a)+metaToContext opts blockWriter inlineWriter meta =+  case writerTemplate opts of+    Nothing -> return mempty+    Just _  -> addVariablesToContext opts <$>+                metaToContext' blockWriter inlineWriter meta --- | Like 'metaToJSON', but does not include variables and is+-- | Like 'metaToContext, but does not include variables and is -- not sensitive to 'writerTemplate'.-metaToJSON' :: (Functor m, Monad m, ToJSON a)-           => ([Block] -> m a)-           -> ([Inline] -> m a)+metaToContext' :: (Monad m, TemplateTarget a)+           => ([Block] -> m (Doc a))+           -> ([Inline] -> m (Doc a))            -> Meta-           -> m Value-metaToJSON' blockWriter inlineWriter (Meta metamap) = do-  renderedMap <- Traversable.mapM-                 (metaValueToJSON blockWriter inlineWriter)-                 metamap-  return $ M.foldrWithKey defField (Object H.empty) renderedMap+           -> m (Context a)+metaToContext' blockWriter inlineWriter (Meta metamap) =+  Context <$> mapM (metaValueToVal blockWriter inlineWriter) metamap --- | Add variables to JSON object, replacing any existing values.--- Also include @meta-json@, a field containing a string representation--- of the original JSON object itself, prior to addition of variables.-addVariablesToJSON :: WriterOptions -> Value -> Value-addVariablesToJSON opts metadata =-  foldl (\acc (x,y) -> setField x y acc)-       (defField "meta-json" (toStringLazy $ encode metadata) (Object mempty))-       (writerVariables opts)-    `combineMetadata` metadata-  where combineMetadata (Object o1) (Object o2) = Object $ H.union o1 o2-        combineMetadata x _                     = x+-- | Add variables to a template Context, using monoidal append.+-- Also add `meta-json`.  Note that metadata values are used+-- in template contexts only when like-named variables aren't set.+addVariablesToContext :: TemplateTarget a+                      => WriterOptions -> Context a -> Context a+addVariablesToContext opts c1 =+  c2 <> (fromText <$> writerVariables opts) <> c1+ where+   c2 = Context $+          M.insert "meta-json" (SimpleVal $ literal $ fromText jsonrep)+                               mempty+   jsonrep = UTF8.toText $ BL.toStrict $ encode $ toJSON c1 -metaValueToJSON :: (Functor m, Monad m, ToJSON a)-                => ([Block] -> m a)-                -> ([Inline] -> m a)-                -> MetaValue-                -> m Value-metaValueToJSON blockWriter inlineWriter (MetaMap metamap) = toJSON <$>-  Traversable.mapM (metaValueToJSON blockWriter inlineWriter) metamap-metaValueToJSON blockWriter inlineWriter (MetaList xs) = toJSON <$>-  Traversable.mapM (metaValueToJSON blockWriter inlineWriter) xs-metaValueToJSON _ _ (MetaBool b) = return $ toJSON b-metaValueToJSON _ inlineWriter (MetaString s@('0':_:_)) =-   -- don't treat string with leading 0 as string (#5479)-   toJSON <$> inlineWriter (Builder.toList (Builder.text s))-metaValueToJSON _ inlineWriter (MetaString s) =-  case safeRead s of-     Just (n :: Scientific) -> return $ Aeson.Number n-     Nothing -> toJSON <$> inlineWriter (Builder.toList (Builder.text s))-metaValueToJSON blockWriter _ (MetaBlocks bs) = toJSON <$> blockWriter bs-metaValueToJSON blockWriter inlineWriter (MetaInlines [Str s]) =-  metaValueToJSON blockWriter inlineWriter (MetaString s)-metaValueToJSON _ inlineWriter (MetaInlines is) = toJSON <$> inlineWriter is+metaValueToVal :: (Monad m, TemplateTarget a)+               => ([Block] -> m (Doc a))+               -> ([Inline] -> m (Doc a))+               -> MetaValue+               -> m (Val a)+metaValueToVal blockWriter inlineWriter (MetaMap metamap) =+  MapVal . Context <$> mapM (metaValueToVal blockWriter inlineWriter) metamap+metaValueToVal blockWriter inlineWriter (MetaList xs) = ListVal <$>+  mapM (metaValueToVal blockWriter inlineWriter) xs+metaValueToVal _ _ (MetaBool True) = return $ SimpleVal "true"+metaValueToVal _ _ (MetaBool False) = return NullVal+metaValueToVal _ inlineWriter (MetaString s) =+   SimpleVal <$> inlineWriter (Builder.toList (Builder.text s))+metaValueToVal blockWriter _ (MetaBlocks bs) = SimpleVal <$> blockWriter bs+metaValueToVal _ inlineWriter (MetaInlines is) = SimpleVal <$> inlineWriter is --- | Retrieve a field value from a JSON object.-getField :: FromJSON a-         => String-         -> Value-         -> Maybe a-getField field (Object hashmap) = do-  result <- H.lookup (T.pack field) hashmap-  case fromJSON result of-       Success x -> return x-       _         -> fail "Could not convert from JSON"-getField _ _ = fail "Not a JSON object" -setField :: ToJSON a-         => String-         -> a-         -> Value-         -> Value--- | Set a field of a JSON object.  If the field already has a value,+-- | Retrieve a field value from a template context.+getField   :: FromContext a b => T.Text -> Context a -> Maybe b+getField field (Context m) = M.lookup field m >>= fromVal++-- | Set a field of a template context.  If the field already has a value, -- convert it into a list with the new value appended to the old value(s). -- This is a utility function to be used in preparing template contexts.-setField field val (Object hashmap) =-  Object $ H.insertWith combine (T.pack field) (toJSON val) hashmap-  where combine newval oldval =-          case fromJSON oldval of-                Success xs -> toJSON $ xs ++ [newval]-                _          -> toJSON [oldval, newval]-setField _ _  x = x+setField   :: ToContext a b => T.Text -> b -> Context a -> Context a+setField field val (Context m) =+  Context $ M.insertWith combine field (toVal val) m+ where+  combine newval (ListVal xs)   = ListVal (xs ++ [newval])+  combine newval x              = ListVal [x, newval] -resetField :: ToJSON a-           => String-           -> a-           -> Value-           -> Value--- | Reset a field of a JSON object.  If the field already has a value,--- the new value replaces it.+-- | Reset a field of a template context.  If the field already has a+-- value, the new value replaces it. -- This is a utility function to be used in preparing template contexts.-resetField field val (Object hashmap) =-  Object $ H.insert (T.pack field) (toJSON val) hashmap-resetField _ _  x = x+resetField :: ToContext a b => T.Text -> b -> Context a -> Context a+resetField field val (Context m) =+  Context (M.insert field (toVal val) m) -defField :: ToJSON a-         => String-         -> a-         -> Value-         -> Value--- | Set a field of a JSON object if it currently has no value.+-- | Set a field of a template context if it currently has no value. -- If it has a value, do nothing. -- This is a utility function to be used in preparing template contexts.-defField field val (Object hashmap) =-  Object $ H.insertWith f (T.pack field) (toJSON val) hashmap-    where f _newval oldval = oldval-defField _ _  x = x+defField   :: ToContext a b => T.Text -> b -> Context a -> Context a+defField field val (Context m) =+  Context (M.insertWith f field (toVal val) m)+  where+    f _newval oldval = oldval  -- Produce an HTML tag with the given pandoc attributes.-tagWithAttrs :: String -> Attr -> Doc+tagWithAttrs :: HasChars a => T.Text -> Attr -> Doc a tagWithAttrs tag (ident,classes,kvs) = hsep-  ["<" <> text tag-  ,if null ident+  ["<" <> text (T.unpack tag)+  ,if T.null ident       then empty-      else "id=" <> doubleQuotes (text ident)+      else "id=" <> doubleQuotes (text $ T.unpack ident)   ,if null classes       then empty-      else "class=" <> doubleQuotes (text (unwords classes))-  ,hsep (map (\(k,v) -> text k <> "=" <>-                doubleQuotes (text (escapeStringForXML v))) kvs)+      else "class=" <> doubleQuotes (text $ T.unpack (T.unwords classes))+  ,hsep (map (\(k,v) -> text (T.unpack k) <> "=" <>+                doubleQuotes (text $ T.unpack (escapeStringForXML v))) kvs)   ] <> ">"  isDisplayMath :: Inline -> Bool@@ -221,88 +193,105 @@                          not (isDisplayMath x || isDisplayMath y)) lst fixDisplayMath x = x -unsmartify :: WriterOptions -> String -> String-unsmartify opts ('\8217':xs) = '\'' : unsmartify opts xs-unsmartify opts ('\8230':xs) = "..." ++ unsmartify opts xs-unsmartify opts ('\8211':xs)-  | isEnabled Ext_old_dashes opts = '-' : unsmartify opts xs-  | otherwise                     = "--" ++ unsmartify opts xs-unsmartify opts ('\8212':xs)-  | isEnabled Ext_old_dashes opts = "--" ++ unsmartify opts xs-  | otherwise                     = "---" ++ unsmartify opts xs-unsmartify opts ('\8220':xs) = '"' : unsmartify opts xs-unsmartify opts ('\8221':xs) = '"' : unsmartify opts xs-unsmartify opts ('\8216':xs) = '\'' : unsmartify opts xs-unsmartify opts (x:xs) = x : unsmartify opts xs-unsmartify _ [] = []+unsmartify :: WriterOptions -> T.Text -> T.Text+unsmartify opts = T.concatMap $ \c -> case c of+  '\8217' -> "'"+  '\8230' -> "..."+  '\8211'+    | isEnabled Ext_old_dashes opts -> "-"+    | otherwise                     -> "--"+  '\8212'+    | isEnabled Ext_old_dashes opts -> "--"+    | otherwise                     -> "---"+  '\8220' -> "\""+  '\8221' -> "\""+  '\8216' -> "'"+  _       -> T.singleton c -gridTable :: Monad m+gridTable :: (Monad m, HasChars a)           => WriterOptions-          -> (WriterOptions -> [Block] -> m Doc)+          -> (WriterOptions -> [Block] -> m (Doc a))           -> Bool -- ^ headless           -> [Alignment]           -> [Double]           -> [[Block]]           -> [[[Block]]]-          -> m Doc+          -> m (Doc a) gridTable opts blocksToDoc headless aligns widths headers rows = do   -- the number of columns will be used in case of even widths   let numcols = maximum (length aligns : length widths :                            map length (headers:rows))+  let officialWidthsInChars widths' = map (+                        (\x -> if x < 1 then 1 else x) .+                        (\x -> x - 3) . floor .+                        (fromIntegral (writerColumns opts) *)+                        ) widths'   -- handleGivenWidths wraps the given blocks in order for them to fit   -- in cells with given widths. the returned content can be   -- concatenated with borders and frames-  let handleGivenWidths widths' = do-        let widthsInChars' = map (-                      (\x -> if x < 1 then 1 else x) .-                      (\x -> x - 3) . floor .-                      (fromIntegral (writerColumns opts) *)-                      ) widths'-            -- replace page width (in columns) in the options with a-            -- given width if smaller (adjusting by two)-            useWidth w = opts{writerColumns = min (w - 2) (writerColumns opts)}-            -- prepare options to use with header and row cells-            columnOptions = map useWidth widthsInChars'+  let handleGivenWidthsInChars widthsInChars' = do+        -- replace page width (in columns) in the options with a+        -- given width if smaller (adjusting by two)+        let useWidth w = opts{writerColumns = min (w - 2) (writerColumns opts)}+        -- prepare options to use with header and row cells+        let columnOptions = map useWidth widthsInChars'         rawHeaders' <- zipWithM blocksToDoc columnOptions headers         rawRows' <- mapM              (\cs -> zipWithM blocksToDoc columnOptions cs)              rows         return (widthsInChars', rawHeaders', rawRows')+  let handleGivenWidths widths' = handleGivenWidthsInChars+                                     (officialWidthsInChars widths')   -- handleFullWidths tries to wrap cells to the page width or even   -- more in cases where `--wrap=none`. thus the content here is left   -- as wide as possible-  let handleFullWidths = do+  let handleFullWidths widths' = do         rawHeaders' <- mapM (blocksToDoc opts) headers         rawRows' <- mapM (mapM (blocksToDoc opts)) rows         let numChars [] = 0             numChars xs = maximum . map offset $ xs-        let widthsInChars' =+        let minWidthsInChars =                 map numChars $ transpose (rawHeaders' : rawRows')+        let widthsInChars' = zipWith max+                              minWidthsInChars+                              (officialWidthsInChars widths')         return (widthsInChars', rawHeaders', rawRows')   -- handleZeroWidths calls handleFullWidths to check whether a wide   -- table would fit in the page. if the produced table is too wide,   -- it calculates even widths and passes the content to   -- handleGivenWidths-  let handleZeroWidths = do-        (widthsInChars', rawHeaders', rawRows') <- handleFullWidths+  let handleZeroWidths widths' = do+        (widthsInChars', rawHeaders', rawRows') <- handleFullWidths widths'         if foldl' (+) 0 widthsInChars' > writerColumns opts-           then -- use even widths-                handleGivenWidths-                  (replicate numcols (1.0 / fromIntegral numcols) :: [Double])+           then do -- use even widths except for thin columns+             let evenCols  = max 5+                              (((writerColumns opts - 1) `div` numcols) - 3)+             let (numToExpand, colsToExpand) =+                   foldr (\w (n, tot) -> if w < evenCols+                                            then (n, tot + (evenCols - w))+                                            else (n + 1, tot))+                                   (0,0) widthsInChars'+             let expandAllowance = colsToExpand `div` numToExpand+             let newWidthsInChars = map (\w -> if w < evenCols+                                                  then w+                                                  else min+                                                       (evenCols + expandAllowance)+                                                       w)+                                        widthsInChars'+             handleGivenWidthsInChars newWidthsInChars            else return (widthsInChars', rawHeaders', rawRows')   -- render the contents of header and row cells differently depending   -- on command line options, widths given in this specific table, and   -- cells' contents   let handleWidths-        | writerWrapText opts == WrapNone  = handleFullWidths-        | all (== 0) widths                  = handleZeroWidths+        | writerWrapText opts == WrapNone    = handleFullWidths widths+        | all (== 0) widths                  = handleZeroWidths widths         | otherwise                          = handleGivenWidths widths   (widthsInChars, rawHeaders, rawRows) <- handleWidths   let hpipeBlocks blocks = hcat [beg, middle, end]-        where h       = maximum (1 : map height blocks)-              sep'    = lblock 3 $ vcat (replicate h (text " | "))-              beg     = lblock 2 $ vcat (replicate h (text "| "))-              end     = lblock 2 $ vcat (replicate h (text " |"))+        where sep'    = vfill " | "+              beg     = vfill "| "+              end     = vfill " |"               middle  = chomp $ hcat $ intersperse sep' blocks   let makeRow = hpipeBlocks . zipWith lblock widthsInChars   let head' = makeRow rawHeaders@@ -335,22 +324,20 @@            body $$            border '-' (repeat AlignDefault) widthsInChars -- -- | Retrieve the metadata value for a given @key@ -- and convert to Bool.-lookupMetaBool :: String -> Meta -> Bool+lookupMetaBool :: T.Text -> Meta -> Bool lookupMetaBool key meta =   case lookupMeta key meta of-      Just (MetaBlocks _)     -> True-      Just (MetaInlines _)    -> True-      Just (MetaString (_:_)) -> True-      Just (MetaBool True)    -> True-      _                       -> False+      Just (MetaBlocks _)  -> True+      Just (MetaInlines _) -> True+      Just (MetaString x)  -> not (T.null x)+      Just (MetaBool True) -> True+      _                    -> False  -- | Retrieve the metadata value for a given @key@ -- and extract blocks.-lookupMetaBlocks :: String -> Meta -> [Block]+lookupMetaBlocks :: T.Text -> Meta -> [Block] lookupMetaBlocks key meta =   case lookupMeta key meta of          Just (MetaBlocks bs)   -> bs@@ -360,7 +347,7 @@  -- | Retrieve the metadata value for a given @key@ -- and extract inlines.-lookupMetaInlines :: String -> Meta -> [Inline]+lookupMetaInlines :: T.Text -> Meta -> [Inline] lookupMetaInlines key meta =   case lookupMeta key meta of          Just (MetaString s)           -> [Str s]@@ -371,16 +358,15 @@  -- | Retrieve the metadata value for a given @key@ -- and convert to String.-lookupMetaString :: String -> Meta -> String+lookupMetaString :: T.Text -> Meta -> T.Text lookupMetaString key meta =   case lookupMeta key meta of          Just (MetaString s)    -> s          Just (MetaInlines ils) -> stringify ils          Just (MetaBlocks bs)   -> stringify bs-         Just (MetaBool b)      -> show b+         Just (MetaBool b)      -> T.pack (show b)          _                      -> "" - toSuperscript :: Char -> Maybe Char toSuperscript '1' = Just '\x00B9' toSuperscript '2' = Just '\x00B2'@@ -413,17 +399,32 @@                   -> [Block]                   -> Block toTableOfContents opts bs =-  BulletList $ map (elementToListItem opts) (hierarchicalize bs)+  BulletList $ filter (not . null)+             $ map (sectionToListItem opts)+             $ makeSections (writerNumberSections opts) Nothing bs  -- | Converts an Element to a list item for a table of contents,-elementToListItem :: WriterOptions -> Element -> [Block]-elementToListItem opts (Sec lev _nums (ident,_,_) headerText subsecs)-  = Plain headerLink : [BulletList listContents | not (null subsecs)-                                                , lev < writerTOCDepth opts]+sectionToListItem :: WriterOptions -> Block -> [Block]+sectionToListItem opts (Div (ident,_,_)+                         (Header lev (_,classes,kvs) ils : subsecs))+  | not (isNothing (lookup "number" kvs) && "unlisted" `elem` classes)+  = Plain headerLink : [BulletList listContents | not (null listContents)+                                              , lev < writerTOCDepth opts]  where-   headerText' = walk deNote headerText-   headerLink = if null ident+   num = fromMaybe "" $ lookup "number" kvs+   addNumber  = if T.null num+                   then id+                   else (Span ("",["toc-section-number"],[])+                           [Str num] :) . (Space :)+   headerText' = addNumber $ walk (deLink . deNote) ils+   headerLink = if T.null ident                    then headerText'-                   else [Link nullAttr headerText' ('#':ident, "")]-   listContents = map (elementToListItem opts) subsecs-elementToListItem _ (Blk _) = []+                   else [Link nullAttr headerText' ("#" <> ident, "")]+   listContents = filter (not . null) $ map (sectionToListItem opts) subsecs+sectionToListItem _ _ = []++endsWithPlain :: [Block] -> Bool+endsWithPlain xs =+  case lastMay xs of+    Just (Plain{}) -> True+    _              -> False
src/Text/Pandoc/Writers/TEI.hs view
@@ -14,71 +14,48 @@ -} module Text.Pandoc.Writers.TEI (writeTEI) where import Prelude-import Data.Char (toLower)-import Data.List (isPrefixOf, stripPrefix) import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (languages, languagesByExtension) import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared import Text.Pandoc.XML  -- | Convert Pandoc document to string in Docbook format. writeTEI :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeTEI opts (Pandoc meta blocks) = do-  let elements = hierarchicalize blocks-      colwidth = if writerWrapText opts == WrapAuto+  let colwidth = if writerWrapText opts == WrapAuto                     then Just $ writerColumns opts                     else Nothing-      render' :: Doc -> Text-      render' = render colwidth-      startLvl = case writerTopLevelDivision opts of+  let startLvl = case writerTopLevelDivision opts of                    TopLevelPart    -> -1                    TopLevelChapter -> 0                    TopLevelSection -> 1                    TopLevelDefault -> 1-  metadata <- metaToJSON opts-                 (fmap (render' . vcat) .-                   mapM (elementToTEI opts startLvl) . hierarchicalize)-                 (fmap render' . inlinesToTEI opts)+  let fromBlocks = blocksToTEI opts . makeSections False (Just startLvl)+  metadata <- metaToContext opts+                 fromBlocks+                 (fmap chomp . inlinesToTEI opts)                  meta-  main    <- (render' . vcat) <$> mapM (elementToTEI opts startLvl) elements+  main    <- fromBlocks blocks   let context = defField "body" main-              $-                  defField "mathml" (case writerHTMLMathMethod opts of+              $ defField "mathml" (case writerHTMLMathMethod opts of                                           MathML -> True                                           _      -> False) metadata-  case writerTemplate opts of-       Nothing  -> return main-       Just tpl -> renderTemplate' tpl context---- | Convert an Element to TEI.-elementToTEI :: PandocMonad m => WriterOptions -> Int -> Element -> m Doc-elementToTEI opts _   (Blk block) = blockToTEI opts block-elementToTEI opts lvl (Sec _ _num attr title elements) = do-  -- TEI doesn't allow sections with no content, so insert some if needed-  let elements' = if null elements-                    then [Blk (Para [])]-                    else elements-      -- level numbering correspond to LaTeX internals-      divType = case lvl of-                 n | n == -1          -> "part"-                   | n == 0           -> "chapter"-                   | n >= 1 && n <= 5 -> "level" ++ show n-                   | otherwise        -> "section"-  contents <- vcat <$> mapM (elementToTEI opts (lvl + 1)) elements'-  titleContents <- inlinesToTEI opts title-  return $ inTags True "div" (("type", divType) : idFromAttr opts attr) $-      inTagsSimple "head" titleContents $$ contents+  return $ render colwidth $+    case writerTemplate opts of+       Nothing  -> main+       Just tpl -> renderTemplate tpl context  -- | Convert a list of Pandoc blocks to TEI.-blocksToTEI :: PandocMonad m => WriterOptions -> [Block] -> m Doc+blocksToTEI :: PandocMonad m => WriterOptions -> [Block] -> m (Doc Text) blocksToTEI opts bs = vcat <$> mapM (blockToTEI opts) bs  -- | Auxiliary function to convert Plain block to Para.@@ -89,13 +66,13 @@ -- | Convert a list of pairs of terms and definitions into a TEI -- list with labels and items. deflistItemsToTEI :: PandocMonad m-                  => WriterOptions -> [([Inline],[[Block]])] -> m Doc+                  => WriterOptions -> [([Inline],[[Block]])] -> m (Doc Text) deflistItemsToTEI opts items =  vcat <$> mapM (uncurry (deflistItemToTEI opts)) items  -- | Convert a term and a list of blocks into a TEI varlistentry. deflistItemToTEI :: PandocMonad m-                 => WriterOptions -> [Inline] -> [[Block]] -> m Doc+                 => WriterOptions -> [Inline] -> [[Block]] -> m (Doc Text) deflistItemToTEI opts term defs = do   term' <- inlinesToTEI opts term   defs' <- blocksToTEI opts $ concatMap (map plainToPara) defs@@ -103,26 +80,42 @@            inTagsIndented "item" defs'  -- | Convert a list of lists of blocks to a list of TEI list items.-listItemsToTEI :: PandocMonad m => WriterOptions -> [[Block]] -> m Doc+listItemsToTEI :: PandocMonad m => WriterOptions -> [[Block]] -> m (Doc Text) listItemsToTEI opts items = vcat <$> mapM (listItemToTEI opts) items  -- | Convert a list of blocks into a TEI list item.-listItemToTEI :: PandocMonad m => WriterOptions -> [Block] -> m Doc+listItemToTEI :: PandocMonad m => WriterOptions -> [Block] -> m (Doc Text) listItemToTEI opts item =   inTagsIndented "item" <$> blocksToTEI opts (map plainToPara item) -imageToTEI :: PandocMonad m => WriterOptions -> Attr -> String -> m Doc+imageToTEI :: PandocMonad m => WriterOptions -> Attr -> Text -> m (Doc Text) imageToTEI opts attr src = return $ selfClosingTag "graphic" $   ("url", src) : idFromAttr opts attr ++ dims   where     dims = go Width "width" ++ go Height "height"     go dir dstr = case dimension dir attr of-                    Just a  -> [(dstr, show a)]+                    Just a  -> [(dstr, tshow a)]                     Nothing -> []  -- | Convert a Pandoc block element to TEI.-blockToTEI :: PandocMonad m => WriterOptions -> Block -> m Doc+blockToTEI :: PandocMonad m => WriterOptions -> Block -> m (Doc Text) blockToTEI _ Null = return empty+blockToTEI opts (Div attr@(_,"section":_,_) (Header lvl _ ils : xs)) =+  do+  -- TEI doesn't allow sections with no content, so insert some if needed+  let xs' = if null xs+               then [Para []]+               else xs+      -- level numbering correspond to LaTeX internals+      divType = case lvl of+                 n | n == -1          -> "part"+                   | n == 0           -> "chapter"+                   | n >= 1 && n <= 5 -> "level" <> tshow n+                   | otherwise        -> "section"+  titleContents <- inlinesToTEI opts ils+  contents <- blocksToTEI opts xs'+  return $ inTags True "div" (("type", divType) : idFromAttr opts attr) $+      inTagsSimple "head" titleContents $$ contents -- Add ids to paragraphs in divs with ids - this is needed for -- pandoc-citeproc to get link anchors in bibliographies: blockToTEI opts (Div attr [Para lst]) = do@@ -130,7 +123,7 @@   inTags False "p" attribs <$> inlinesToTEI opts lst blockToTEI opts (Div _ bs) = blocksToTEI opts $ map plainToPara bs blockToTEI _ h@Header{} = do-  -- should not occur after hierarchicalize, except inside lists/blockquotes+  -- should not occur after makeSections, except inside lists/blockquotes   report $ BlockNotRendered h   return empty -- For TEI simple, text must be within containing block element, so@@ -156,15 +149,15 @@ blockToTEI opts (BlockQuote blocks) =   inTagsIndented "quote" <$> blocksToTEI opts blocks blockToTEI _ (CodeBlock (_,classes,_) str) =-  return $ text ("<ab type='codeblock " ++ lang ++ "'>") <> cr <>-     flush (text (escapeStringForXML str) <> cr <> text "</ab>")+  return $ literal ("<ab type='codeblock " <> lang <> "'>") <> cr <>+     flush (literal (escapeStringForXML str) <> cr <> text "</ab>")     where lang  = if null langs                      then ""                      else escapeStringForXML (head langs)-          isLang l    = map toLower l `elem` map (map toLower) languages+          isLang l    = T.toLower l `elem` map T.toLower languages           langsFrom s = if isLang s                            then [s]-                           else languagesByExtension . map toLower $ s+                           else languagesByExtension . T.toLower $ s           langs       = concatMap langsFrom classes blockToTEI opts (BulletList lst) = do   let attribs = [("type", "unordered")]@@ -184,13 +177,13 @@               else do                 fi <- blocksToTEI opts $ map plainToPara first                 re <- listItemsToTEI opts rest-                return $ inTags True "item" [("n",show start)] fi $$ re+                return $ inTags True "item" [("n",tshow start)] fi $$ re   return $ inTags True "list" attribs items blockToTEI opts (DefinitionList lst) = do   let attribs = [("type", "definition")]   inTags True "list" attribs <$> deflistItemsToTEI opts lst blockToTEI _ b@(RawBlock f str)-  | f == "tei"     = return $ text str+  | f == "tei"     = return $ literal str   -- raw TEI block (should such a thing exist).   | otherwise      = do     report $ BlockNotRendered b@@ -211,14 +204,14 @@ tableRowToTEI :: PandocMonad m               => WriterOptions               -> [[Block]]-              -> m Doc+              -> m (Doc Text) tableRowToTEI opts cols =   (inTagsIndented "row" . vcat) <$> mapM (tableItemToTEI opts) cols  tableHeadersToTEI :: PandocMonad m                   => WriterOptions                   -> [[Block]]-                  -> m Doc+                  -> m (Doc Text) tableHeadersToTEI opts cols =   (inTags True "row" [("role","label")] . vcat) <$>     mapM (tableItemToTEI opts) cols@@ -226,17 +219,17 @@ tableItemToTEI :: PandocMonad m                => WriterOptions                -> [Block]-               -> m Doc+               -> m (Doc Text) tableItemToTEI opts item =   (inTags False "cell" [] . vcat) <$> mapM (blockToTEI opts) item  -- | Convert a list of inline elements to TEI.-inlinesToTEI :: PandocMonad m => WriterOptions -> [Inline] -> m Doc+inlinesToTEI :: PandocMonad m => WriterOptions -> [Inline] -> m (Doc Text) inlinesToTEI opts lst = hcat <$> mapM (inlineToTEI opts) lst  -- | Convert an inline element to TEI.-inlineToTEI :: PandocMonad m => WriterOptions -> Inline -> m Doc-inlineToTEI _ (Str str) = return $ text $ escapeStringForXML str+inlineToTEI :: PandocMonad m => WriterOptions -> Inline -> m (Doc Text)+inlineToTEI _ (Str str) = return $ literal $ escapeStringForXML str inlineToTEI opts (Emph lst) =   inTags False "hi" [("rendition","simple:italic")] <$> inlinesToTEI opts lst inlineToTEI opts (Strong lst) =@@ -260,16 +253,16 @@ inlineToTEI opts (Span _ ils) =   inlinesToTEI opts ils inlineToTEI _ (Code _ str) = return $-  inTags False "seg" [("type","code")] $ text (escapeStringForXML str)+  inTags False "seg" [("type","code")] $ literal (escapeStringForXML str) -- Distinguish display from inline math by wrapping the former in a "figure." inlineToTEI _ (Math t str) = return $   case t of     InlineMath  -> inTags False "formula" [("notation","TeX")] $-                   text str+                   literal str     DisplayMath -> inTags True "figure" [("type","math")] $-                   inTags False "formula" [("notation","TeX")] $ text str+                   inTags False "formula" [("notation","TeX")] $ literal str -inlineToTEI _ il@(RawInline f x) | f == "tei"     = return $ text x+inlineToTEI _ il@(RawInline f x) | f == "tei"     = return $ literal x                                  | otherwise      = empty <$                                      report (InlineNotRendered il) inlineToTEI _ LineBreak = return $ selfClosingTag "lb" []@@ -279,8 +272,8 @@ inlineToTEI _ SoftBreak =             return space inlineToTEI opts (Link attr txt (src, _))-  | Just email <- stripPrefix "mailto:" src = do-      let emailLink = text $+  | Just email <- T.stripPrefix "mailto:" src = do+      let emailLink = literal $                       escapeStringForXML email       case txt of            [Str s] | escapeURI s == email ->@@ -289,17 +282,13 @@               linktext <- inlinesToTEI opts txt               return $ linktext <+> char '(' <> emailLink <> char ')'   | otherwise =-      (if "#" `isPrefixOf` src-            then inTags False "ref" $ ("target", drop 1 src)-                 : idFromAttr opts attr-            else inTags False "ref" $ ("target", src)-                 : idFromAttr opts attr ) <$>-        inlinesToTEI opts txt+      (inTags False "ref" $ ("target", src) : idFromAttr opts attr)+                 <$> inlinesToTEI opts txt inlineToTEI opts (Image attr description (src, tit)) = do-  let titleDoc = if null tit+  let titleDoc = if T.null tit                    then empty                    else inTags False "figDesc" []-                           (text $ escapeStringForXML tit)+                           (literal $ escapeStringForXML tit)   imageDesc <- if null description                   then return empty                   else inTags False "head" []@@ -309,8 +298,8 @@ inlineToTEI opts (Note contents) =   inTagsIndented "note" <$> blocksToTEI opts contents -idFromAttr :: WriterOptions -> Attr -> [(String, String)]+idFromAttr :: WriterOptions -> Attr -> [(Text, Text)] idFromAttr opts (id',_,_) =-  if null id'+  if T.null id'      then []-     else [("xml:id", writerIdentifierPrefix opts ++ id')]+     else [("xml:id", writerIdentifierPrefix opts <> id')]
src/Text/Pandoc/Writers/Texinfo.hs view
@@ -21,6 +21,7 @@ import Data.Ord (comparing) import qualified Data.Set as Set import Data.Text (Text)+import qualified Data.Text as T import Network.URI (unEscapeString) import System.FilePath import Text.Pandoc.Class (PandocMonad, report)@@ -29,16 +30,16 @@ import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty+import Text.DocLayout import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared import Text.Printf (printf)  data WriterState =   WriterState { stStrikeout   :: Bool  -- document contains strikeout               , stEscapeComma :: Bool -- in a context where we need @comma-              , stIdentifiers :: Set.Set String -- header ids used already+              , stIdentifiers :: Set.Set Text -- header ids used already               , stOptions     :: WriterOptions -- writer options               } @@ -68,26 +69,23 @@   let colwidth = if writerWrapText options == WrapAuto                     then Just $ writerColumns options                     else Nothing-  let render' :: Doc -> Text-      render' = render colwidth-  metadata <- metaToJSON options-              (fmap render' . blockListToTexinfo)-              (fmap render' . inlineListToTexinfo)+  metadata <- metaToContext options+              (blockListToTexinfo)+              (fmap chomp .inlineListToTexinfo)               meta-  main <- blockListToTexinfo blocks+  body <- blockListToTexinfo blocks   st <- get-  let body = render colwidth main   let context = defField "body" body               $ defField "toc" (writerTableOfContents options)               $ defField "titlepage" titlePage-              $-        defField "strikeout" (stStrikeout st) metadata-  case writerTemplate options of-       Nothing  -> return body-       Just tpl -> renderTemplate' tpl context+              $ defField "strikeout" (stStrikeout st) metadata+  return $ render colwidth $+    case writerTemplate options of+       Nothing  -> body+       Just tpl -> renderTemplate tpl context  -- | Escape things as needed for Texinfo.-stringToTexinfo :: String -> String+stringToTexinfo :: Text -> Text stringToTexinfo = escapeStringUsing texinfoEscapes   where texinfoEscapes = [ ('{', "@{")                          , ('}', "@}")@@ -99,7 +97,7 @@                          , ('\x2019', "'")                          ] -escapeCommas :: PandocMonad m => TI m Doc -> TI m Doc+escapeCommas :: PandocMonad m => TI m (Doc Text) -> TI m (Doc Text) escapeCommas parser = do   oldEscapeComma <- gets stEscapeComma   modify $ \st -> st{ stEscapeComma = True }@@ -108,13 +106,13 @@   return res  -- | Puts contents into Texinfo command.-inCmd :: String -> Doc -> Doc-inCmd cmd contents = char '@' <> text cmd <> braces contents+inCmd :: Text -> Doc Text -> Doc Text+inCmd cmd contents = char '@' <> literal cmd <> braces contents  -- | Convert Pandoc block element to Texinfo. blockToTexinfo :: PandocMonad m                => Block     -- ^ Block to convert-               -> TI m Doc+               -> TI m (Doc Text)  blockToTexinfo Null = return empty @@ -124,13 +122,14 @@   inlineListToTexinfo lst  -- title beginning with fig: indicates that the image is a figure-blockToTexinfo (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do-  capt <- if null txt-             then return empty-             else (\c -> text "@caption" <> braces c) `fmap`-                    inlineListToTexinfo txt-  img  <- inlineToTexinfo (Image attr txt (src,tit))-  return $ text "@float" $$ img $$ capt $$ text "@end float"+blockToTexinfo (Para [Image attr txt (src,tgt)])+  | Just tit <- T.stripPrefix "fig:" tgt = do+      capt <- if null txt+              then return empty+              else (\c -> text "@caption" <> braces c) `fmap`+                     inlineListToTexinfo txt+      img  <- inlineToTexinfo (Image attr txt (src,tit))+      return $ text "@float" $$ img $$ capt $$ text "@end float"  blockToTexinfo (Para lst) =   inlineListToTexinfo lst    -- this is handled differently from Plain in blockListToTexinfo@@ -147,13 +146,13 @@ blockToTexinfo (CodeBlock _ str) =   return $ blankline $$          text "@verbatim" $$-         flush (text str) $$+         flush (literal str) $$          text "@end verbatim" <> blankline  blockToTexinfo b@(RawBlock f str)-  | f == "texinfo" = return $ text str+  | f == "texinfo" = return $ literal str   | f == "latex" || f == "tex" =-                      return $ text "@tex" $$ text str $$ text "@end tex"+                      return $ text "@tex" $$ literal str $$ text "@end tex"   | otherwise      = do       report $ BlockNotRendered b       return empty@@ -213,18 +212,18 @@     txt <- inlineListToTexinfo lst     idsUsed <- gets stIdentifiers     opts <- gets stOptions-    let id' = if null ident+    let id' = if T.null ident                  then uniqueIdent (writerExtensions opts) lst idsUsed                  else ident     modify $ \st -> st{ stIdentifiers = Set.insert id' idsUsed }     sec <- seccmd level     return $ if (level > 0) && (level <= 4)                 then blankline <> text "@node " <> node $$-                     text sec <> txt $$-                     text "@anchor" <> braces (text $ '#':id')+                     literal sec <> txt $$+                     text "@anchor" <> braces (literal $ "#" <> id')                 else txt     where-      seccmd :: PandocMonad m => Int -> TI m String+      seccmd :: PandocMonad m => Int -> TI m Text       seccmd 1 = return "@chapter "       seccmd 2 = return "@section "       seccmd 3 = return "@subsection "@@ -240,7 +239,7 @@   colDescriptors <-     if all (== 0) widths        then do -- use longest entry instead of column widths-            cols <- mapM (mapM (liftM (render Nothing . hcat) . mapM blockToTexinfo)) $+            cols <- mapM (mapM (liftM (T.unpack . render Nothing . hcat) . mapM blockToTexinfo)) $                         transpose $ heads : rows             return $ concatMap ((\x -> "{"++x++"} ") .  maximumBy (comparing length)) cols        else return $ "@columnfractions " ++ concatMap (printf "%.2f ") widths@@ -258,29 +257,29 @@ tableHeadToTexinfo :: PandocMonad m                    => [Alignment]                    -> [[Block]]-                   -> TI m Doc+                   -> TI m (Doc Text) tableHeadToTexinfo = tableAnyRowToTexinfo "@headitem "  tableRowToTexinfo :: PandocMonad m                   => [Alignment]                   -> [[Block]]-                  -> TI m Doc+                  -> TI m (Doc Text) tableRowToTexinfo = tableAnyRowToTexinfo "@item "  tableAnyRowToTexinfo :: PandocMonad m-                     => String+                     => Text                      -> [Alignment]                      -> [[Block]]-                     -> TI m Doc+                     -> TI m (Doc Text) tableAnyRowToTexinfo itemtype aligns cols =   zipWithM alignedBlock aligns cols >>=-  return . (text itemtype $$) . foldl (\row item -> row $$+  return . (literal itemtype $$) . foldl (\row item -> row $$   (if isEmpty row then empty else text " @tab ") <> item) empty  alignedBlock :: PandocMonad m              => Alignment              -> [Block]-             -> TI m Doc+             -> TI m (Doc Text) -- XXX @flushleft and @flushright text won't get word wrapped.  Since word -- wrapping is more important than alignment, we ignore the alignment. alignedBlock _ = blockListToTexinfo@@ -297,7 +296,7 @@ -- | Convert Pandoc block elements to Texinfo. blockListToTexinfo :: PandocMonad m                    => [Block]-                   -> TI m Doc+                   -> TI m (Doc Text) blockListToTexinfo [] = return empty blockListToTexinfo (x:xs) = do   x' <- blockToTexinfo x@@ -339,7 +338,7 @@  makeMenuLine :: PandocMonad m              => Block-             -> TI m Doc+             -> TI m (Doc Text) makeMenuLine (Header _ _ lst) = do   txt <- inlineListForNode lst   return $ text "* " <> txt <> text "::"@@ -347,7 +346,7 @@  listItemToTexinfo :: PandocMonad m                   => [Block]-                  -> TI m Doc+                  -> TI m (Doc Text) listItemToTexinfo lst = do   contents <- blockListToTexinfo lst   let spacer = case reverse lst of@@ -357,7 +356,7 @@  defListItemToTexinfo :: PandocMonad m                      => ([Inline], [[Block]])-                     -> TI m Doc+                     -> TI m (Doc Text) defListItemToTexinfo (term, defs) = do     term' <- inlineListToTexinfo term     let defToTexinfo bs = do d <- blockListToTexinfo bs@@ -370,15 +369,15 @@ -- | Convert list of inline elements to Texinfo. inlineListToTexinfo :: PandocMonad m                     => [Inline]  -- ^ Inlines to convert-                    -> TI m Doc+                    -> TI m (Doc Text) inlineListToTexinfo lst = hcat <$> mapM inlineToTexinfo lst  -- | Convert list of inline elements to Texinfo acceptable for a node name. inlineListForNode :: PandocMonad m                   => [Inline]  -- ^ Inlines to convert-                  -> TI m Doc-inlineListForNode = return . text . stringToTexinfo .-                    filter (not . disallowedInNode) . stringify+                  -> TI m (Doc Text)+inlineListForNode = return . literal . stringToTexinfo .+                    T.filter (not . disallowedInNode) . stringify  -- periods, commas, colons, and parentheses are disallowed in node names disallowedInNode :: Char -> Bool@@ -387,7 +386,7 @@ -- | Convert inline element to Texinfo inlineToTexinfo :: PandocMonad m                 => Inline    -- ^ Inline to convert-                -> TI m Doc+                -> TI m (Doc Text)  inlineToTexinfo (Span _ lst) =   inlineListToTexinfo lst@@ -415,7 +414,7 @@   inCmd "sc" <$> inlineListToTexinfo lst  inlineToTexinfo (Code _ str) =-  return $ text $ "@code{" ++ stringToTexinfo str ++ "}"+  return $ literal $ "@code{" <> stringToTexinfo str <> "}"  inlineToTexinfo (Quoted SingleQuote lst) = do   contents <- inlineListToTexinfo lst@@ -427,12 +426,12 @@  inlineToTexinfo (Cite _ lst) =   inlineListToTexinfo lst-inlineToTexinfo (Str str) = return $ text (stringToTexinfo str)-inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str+inlineToTexinfo (Str str) = return $ literal (stringToTexinfo str)+inlineToTexinfo (Math _ str) = return $ inCmd "math" $ literal str inlineToTexinfo il@(RawInline f str)   | f == "latex" || f == "tex" =-                      return $ text "@tex" $$ text str $$ text "@end tex"-  | f == "texinfo" =  return $ text str+                      return $ text "@tex" $$ literal str $$ text "@end tex"+  | f == "texinfo" =  return $ literal str   | otherwise      =  do       report $ InlineNotRendered il       return empty@@ -445,35 +444,36 @@       WrapPreserve -> return cr inlineToTexinfo Space = return space -inlineToTexinfo (Link _ txt (src@('#':_), _)) = do-  contents <- escapeCommas $ inlineListToTexinfo txt-  return $ text "@ref" <>-           braces (text (stringToTexinfo src) <> text "," <> contents)-inlineToTexinfo (Link _ txt (src, _)) =-  case txt of-        [Str x] | escapeURI x == src ->  -- autolink-             return $ text $ "@url{" ++ x ++ "}"-        _ -> do contents <- escapeCommas $ inlineListToTexinfo txt-                let src1 = stringToTexinfo src-                return $ text ("@uref{" ++ src1 ++ ",") <> contents <>-                         char '}'+inlineToTexinfo (Link _ txt (src, _))+  | Just ('#', _) <- T.uncons src = do+      contents <- escapeCommas $ inlineListToTexinfo txt+      return $ text "@ref" <>+        braces (literal (stringToTexinfo src) <> text "," <> contents)+  | otherwise = case txt of+      [Str x] | escapeURI x == src ->  -- autolink+                  return $ literal $ "@url{" <> x <> "}"+      _ -> do+        contents <- escapeCommas $ inlineListToTexinfo txt+        let src1 = stringToTexinfo src+        return $ literal ("@uref{" <> src1 <> ",") <> contents <>+                 char '}'  inlineToTexinfo (Image attr alternate (source, _)) = do   content <- escapeCommas $ inlineListToTexinfo alternate   opts <- gets stOptions   let showDim dim = case dimension dim attr of-                      (Just (Pixel a))   -> showInInch opts (Pixel a) ++ "in"+                      (Just (Pixel a))   -> showInInch opts (Pixel a) <> "in"                       (Just (Percent _)) -> ""-                      (Just d)           -> show d+                      (Just d)           -> tshow d                       Nothing            -> ""-  return $ text ("@image{" ++ base ++ ',':(showDim Width) ++ ',':(showDim Height) ++ ",")-           <> content <> text "," <> text (ext ++ "}")+  return $ literal ("@image{" <> base <> "," <> showDim Width <> "," <> showDim Height <> ",")+           <> content <> text "," <> literal (ext <> "}")   where-    ext     = drop 1 $ takeExtension source'-    base    = dropExtension source'+    ext     = T.drop 1 $ T.pack $ takeExtension source'+    base    = T.pack $ dropExtension source'     source' = if isURI source-                 then source-                 else unEscapeString source+              then T.unpack source+              else unEscapeString $ T.unpack source  inlineToTexinfo (Note contents) = do   contents' <- blockListToTexinfo contents
src/Text/Pandoc/Writers/Textile.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.Textile    Copyright   : Copyright (C) 2010-2019 John MacFarlane@@ -16,24 +18,24 @@ import Prelude import Control.Monad.State.Strict import Data.Char (isSpace)-import Data.List (intercalate)-import Data.Text (Text, pack)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Pretty (render)+import Text.DocLayout (render, literal) import Text.Pandoc.Shared-import Text.Pandoc.Templates (renderTemplate')+import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Writers.Shared import Text.Pandoc.XML (escapeStringForXML)  data WriterState = WriterState {-    stNotes     :: [String]        -- Footnotes-  , stListLevel :: [Char]          -- String at beginning of list items, e.g. "**"-  , stStartNum  :: Maybe Int       -- Start number if first list item-  , stUseTags   :: Bool            -- True if we should use HTML tags because we're in a complex list+    stNotes     :: [Text]        -- Footnotes+  , stListLevel :: [Char]        -- String at beginning of list items, e.g. "**"+  , stStartNum  :: Maybe Int     -- Start number if first list item+  , stUseTags   :: Bool          -- True if we should use HTML tags because we're in a complex list   }  type TW = StateT WriterState@@ -51,15 +53,17 @@ pandocToTextile :: PandocMonad m                 => WriterOptions -> Pandoc -> TW m Text pandocToTextile opts (Pandoc meta blocks) = do-  metadata <- metaToJSON opts (blockListToTextile opts)-                 (inlineListToTextile opts) meta+  metadata <- metaToContext opts+                 (fmap literal . blockListToTextile opts)+                 (fmap literal . inlineListToTextile opts) meta   body <- blockListToTextile opts blocks-  notes <- gets $ unlines . reverse . stNotes-  let main = pack $ body ++ if null notes then "" else "\n\n" ++ notes+  notes <- gets $ T.unlines . reverse . stNotes+  let main = body <> if T.null notes then "" else "\n\n" <> notes   let context = defField "body" main metadata-  case writerTemplate opts of-         Nothing  -> return main-         Just tpl -> renderTemplate' tpl context+  return $+    case writerTemplate opts of+         Nothing  -> main+         Just tpl -> render Nothing $ renderTemplate tpl context  withUseTags :: PandocMonad m => TW m a -> TW m a withUseTags action = do@@ -70,7 +74,7 @@   return result  -- | Escape one character as needed for Textile.-escapeCharForTextile :: Char -> String+escapeCharForTextile :: Char -> Text escapeCharForTextile x = case x of                          '&'      -> "&amp;"                          '<'      -> "&lt;"@@ -86,17 +90,17 @@                          '\x2013' -> " - "                          '\x2019' -> "'"                          '\x2026' -> "..."-                         c        -> [c]+                         c        -> T.singleton c  -- | Escape string as needed for Textile.-escapeStringForTextile :: String -> String-escapeStringForTextile = concatMap escapeCharForTextile+escapeTextForTextile :: Text -> Text+escapeTextForTextile = T.concatMap escapeCharForTextile  -- | Convert Pandoc block element to Textile. blockToTextile :: PandocMonad m                => WriterOptions -- ^ Options                -> Block         -- ^ Block element-               -> TW m String+               -> TW m Text  blockToTextile _ Null = return "" @@ -104,24 +108,24 @@   let startTag = render Nothing $ tagWithAttrs "div" attr   let endTag = "</div>"   contents <- blockListToTextile opts bs-  return $ startTag ++ "\n\n" ++ contents ++ "\n\n" ++ endTag ++ "\n"+  return $ startTag <> "\n\n" <> contents <> "\n\n" <> endTag <> "\n"  blockToTextile opts (Plain inlines) =   inlineListToTextile opts inlines  -- title beginning with fig: indicates that the image is a figure-blockToTextile opts (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do+blockToTextile opts (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just tit)]) = do   capt <- blockToTextile opts (Para txt)   im <- inlineToTextile opts (Image attr txt (src,tit))-  return $ im ++ "\n" ++ capt+  return $ im <> "\n" <> capt  blockToTextile opts (Para inlines) = do   useTags <- gets stUseTags   listLevel <- gets stListLevel   contents <- inlineListToTextile opts inlines   return $ if useTags-              then "<p>" ++ contents ++ "</p>"-              else contents ++ if null listLevel then "\n" else ""+              then "<p>" <> contents <> "</p>"+              else contents <> if null listLevel then "\n" else ""  blockToTextile opts (LineBlock lns) =   blockToTextile opts $ linesToPara lns@@ -136,41 +140,41 @@  blockToTextile opts (Header level (ident,classes,keyvals) inlines) = do   contents <- inlineListToTextile opts inlines-  let identAttr = if null ident then "" else '#':ident-  let attribs = if null identAttr && null classes+  let identAttr = if T.null ident then "" else "#" <> ident+  let attribs = if T.null identAttr && null classes                    then ""-                   else "(" ++ unwords classes ++ identAttr ++ ")"-  let lang = maybe "" (\x -> "[" ++ x ++ "]") $ lookup "lang" keyvals-  let styles = maybe "" (\x -> "{" ++ x ++ "}") $ lookup "style" keyvals-  let prefix = 'h' : show level ++ attribs ++ styles ++ lang ++ ". "-  return $ prefix ++ contents ++ "\n"+                   else "(" <> T.unwords classes <> identAttr <> ")"+  let lang = maybe "" (\x -> "[" <> x <> "]") $ lookup "lang" keyvals+  let styles = maybe "" (\x -> "{" <> x <> "}") $ lookup "style" keyvals+  let prefix = "h" <> tshow level <> attribs <> styles <> lang <> ". "+  return $ prefix <> contents <> "\n" -blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =-  return $ "<pre"  ++ classes' ++ ">\n" ++ escapeStringForXML str +++blockToTextile _ (CodeBlock (_,classes,_) str) | any (T.all isSpace) (T.lines str) =+  return $ "<pre"  <> classes' <> ">\n" <> escapeStringForXML str <>            "\n</pre>\n"     where classes' = if null classes                         then ""-                        else " class=\"" ++ unwords classes ++ "\""+                        else " class=\"" <> T.unwords classes <> "\""  blockToTextile _ (CodeBlock (_,classes,_) str) =-  return $ "bc" ++ classes' ++ ". " ++ str ++ "\n\n"+  return $ "bc" <> classes' <> ". " <> str <> "\n\n"     where classes' = if null classes                         then ""-                        else "(" ++ unwords classes ++ ")"+                        else "(" <> T.unwords classes <> ")"  blockToTextile opts (BlockQuote bs@[Para _]) = do   contents <- blockListToTextile opts bs-  return $ "bq. " ++ contents ++ "\n\n"+  return $ "bq. " <> contents <> "\n\n"  blockToTextile opts (BlockQuote blocks) = do   contents <- blockListToTextile opts blocks-  return $ "<blockquote>\n\n" ++ contents ++ "\n</blockquote>\n"+  return $ "<blockquote>\n\n" <> contents <> "\n</blockquote>\n"  blockToTextile opts (Table [] aligns widths headers rows') |          all (==0) widths = do-  hs <- mapM (liftM (("_. " ++) . stripTrailingNewlines) . blockListToTextile opts) headers-  let cellsToRow cells = "|" ++ intercalate "|" cells ++ "|"-  let header = if all null headers then "" else cellsToRow hs ++ "\n"+  hs <- mapM (liftM (("_. " <>) . stripTrailingNewlines) . blockListToTextile opts) headers+  let cellsToRow cells = "|" <> T.intercalate "|" cells <> "|"+  let header = if all null headers then "" else cellsToRow hs <> "\n"   let blocksToCell (align, bs) = do         contents <- stripTrailingNewlines <$> blockListToTextile opts bs         let alignMarker = case align of@@ -178,32 +182,32 @@                                AlignRight   -> ">. "                                AlignCenter  -> "=. "                                AlignDefault -> ""-        return $ alignMarker ++ contents+        return $ alignMarker <> contents   let rowToCells = mapM blocksToCell . zip aligns   bs <- mapM rowToCells rows'-  let body = unlines $ map cellsToRow bs-  return $ header ++ body+  let body = T.unlines $ map cellsToRow bs+  return $ header <> body  blockToTextile opts (Table capt aligns widths headers rows') = do-  let alignStrings = map alignmentToString aligns+  let alignStrings = map alignmentToText 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) ++ "%"+                      return $ "<caption>" <> c <> "</caption>\n"+  let percent w = tshow (truncate (100*w) :: Integer) <> "%"   let coltags = if all (== 0.0) widths                    then ""-                   else unlines $ map-                         (\w -> "<col width=\"" ++ percent w ++ "\" />") widths+                   else T.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"+                 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"+  return $ "<table>\n" <> captionDoc <> coltags <> head' <>+            "<tbody>\n" <> T.unlines body' <> "</tbody>\n</table>\n"  blockToTextile opts x@(BulletList items) = do   oldUseTags <- gets stUseTags@@ -211,13 +215,13 @@   if useTags      then do         contents <- withUseTags $ mapM (listItemToTextile opts) items-        return $ "<ul>\n" ++ vcat contents ++ "\n</ul>\n"+        return $ "<ul>\n" <> vcat contents <> "\n</ul>\n"      else do-        modify $ \s -> s { stListLevel = stListLevel s ++ "*" }+        modify $ \s -> s { stListLevel = stListLevel s <> "*" }         level <- gets $ length . stListLevel         contents <- mapM (listItemToTextile opts) items         modify $ \s -> s { stListLevel = init (stListLevel s) }-        return $ vcat contents ++ (if level > 1 then "" else "\n")+        return $ vcat contents <> (if level > 1 then "" else "\n")  blockToTextile opts x@(OrderedList attribs@(start, _, _) items) = do   oldUseTags <- gets stUseTags@@ -225,10 +229,10 @@   if useTags      then do         contents <- withUseTags $ mapM (listItemToTextile opts) items-        return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents +++        return $ "<ol" <> listAttribsToString attribs <> ">\n" <> vcat contents <>                    "\n</ol>\n"      else do-        modify $ \s -> s { stListLevel = stListLevel s ++ "#"+        modify $ \s -> s { stListLevel = stListLevel s <> "#"                          , stStartNum = if start > 1                                            then Just start                                            else Nothing }@@ -236,52 +240,52 @@         contents <- mapM (listItemToTextile opts) items         modify $ \s -> s { stListLevel = init (stListLevel s),                            stStartNum = Nothing }-        return $ vcat contents ++ (if level > 1 then "" else "\n")+        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"+  return $ "<dl>\n" <> vcat contents <> "\n</dl>\n"  -- Auxiliary functions for lists:  -- | Convert ordered list attributes to HTML attribute string-listAttribsToString :: ListAttributes -> String+listAttribsToString :: ListAttributes -> Text listAttribsToString (startnum, numstyle, _) =-  let numstyle' = camelCaseToHyphenated $ show numstyle+  let numstyle' = camelCaseToHyphenated $ tshow numstyle   in  (if startnum /= 1-          then " start=\"" ++ show startnum ++ "\""-          else "") +++          then " start=\"" <> tshow startnum <> "\""+          else "") <>       (if numstyle /= DefaultStyle-          then " style=\"list-style-type: " ++ numstyle' ++ ";\""+          then " style=\"list-style-type: " <> numstyle' <> ";\""           else "")  -- | Convert bullet or ordered list item (list of blocks) to Textile. listItemToTextile :: PandocMonad m-                  => WriterOptions -> [Block] -> TW m String+                  => WriterOptions -> [Block] -> TW m Text listItemToTextile opts items = do   contents <- blockListToTextile opts items   useTags <- gets stUseTags   if useTags-     then return $ "<li>" ++ contents ++ "</li>"+     then return $ "<li>" <> contents <> "</li>"      else do        marker <- gets stListLevel        mbstart <- gets stStartNum        case mbstart of             Just n -> do               modify $ \s -> s{ stStartNum = Nothing }-              return $ marker ++ show n ++ " " ++ contents-            Nothing -> return $ marker ++ " " ++ contents+              return $ T.pack marker <> tshow n <> " " <> contents+            Nothing -> return $ T.pack marker <> " " <> contents  -- | Convert definition list item (label, list of blocks) to Textile. definitionListItemToTextile :: PandocMonad m                             => WriterOptions                              -> ([Inline],[[Block]])-                             -> TW m String+                             -> TW m Text 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)+  return $ "<dt>" <> labelText <> "</dt>\n" <>+          T.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@@ -316,18 +320,18 @@ isPlainOrPara _         = False  -- | Concatenates strings with line breaks between them.-vcat :: [String] -> String-vcat = intercalate "\n"+vcat :: [Text] -> Text+vcat = T.intercalate "\n"  -- Auxiliary functions for tables. (TODO: these are common to HTML, MediaWiki, -- and Textile writers, and should be abstracted out.)  tableRowToTextile :: PandocMonad m                   => WriterOptions-                  -> [String]+                  -> [Text]                   -> Int                   -> [[Block]]-                  -> TW m String+                  -> TW m Text tableRowToTextile opts alignStrings rownum cols' = do   let celltype = if rownum == 0 then "th" else "td"   let rowclass = case rownum of@@ -337,10 +341,10 @@   cols'' <- zipWithM             (\alignment item -> tableItemToTextile opts celltype alignment item)             alignStrings cols'-  return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"+  return $ "<tr class=\"" <> rowclass <> "\">\n" <> T.unlines cols'' <> "</tr>" -alignmentToString :: Alignment -> [Char]-alignmentToString alignment = case alignment of+alignmentToText :: Alignment -> Text+alignmentToText alignment = case alignment of                                  AlignLeft    -> "left"                                  AlignRight   -> "right"                                  AlignCenter  -> "center"@@ -348,13 +352,13 @@  tableItemToTextile :: PandocMonad m                    => WriterOptions-                   -> String-                   -> String+                   -> Text+                   -> Text                    -> [Block]-                   -> TW m String+                   -> TW m Text tableItemToTextile opts celltype align' item = do-  let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++-                    x ++ "</" ++ celltype ++ ">"+  let mkcell x = "<" <> celltype <> " align=\"" <> align' <> "\">" <>+                    x <> "</" <> celltype <> ">"   contents <- blockListToTextile opts item   return $ mkcell contents @@ -362,73 +366,73 @@ blockListToTextile :: PandocMonad m                    => WriterOptions -- ^ Options                    -> [Block]       -- ^ List of block elements-                   -> TW m String+                   -> TW m Text blockListToTextile opts blocks =   vcat <$> mapM (blockToTextile opts) blocks  -- | Convert list of Pandoc inline elements to Textile. inlineListToTextile :: PandocMonad m-                    => WriterOptions -> [Inline] -> TW m String+                    => WriterOptions -> [Inline] -> TW m Text inlineListToTextile opts lst =-  concat <$> mapM (inlineToTextile opts) lst+  T.concat <$> mapM (inlineToTextile opts) lst  -- | Convert Pandoc inline element to Textile.-inlineToTextile :: PandocMonad m => WriterOptions -> Inline -> TW m String+inlineToTextile :: PandocMonad m => WriterOptions -> Inline -> TW m Text  inlineToTextile opts (Span _ lst) =   inlineListToTextile opts lst  inlineToTextile opts (Emph lst) = do   contents <- inlineListToTextile opts lst-  return $ if '_' `elem` contents-              then "<em>" ++ contents ++ "</em>"-              else "_" ++ contents ++ "_"+  return $ if '_' `elemText` 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 ++ "*"+  return $ if '*' `elemText` 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 ++ "-"+  return $ if '-' `elemText` 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 ++ "^]"+  return $ if '^' `elemText` 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 ++ "~]"+  return $ if '~' `elemText` 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 ++ "'"+  return $ "'" <> contents <> "'"  inlineToTextile opts (Quoted DoubleQuote lst) = do   contents <- inlineListToTextile opts lst-  return $ "\"" ++ contents ++ "\""+  return $ "\"" <> contents <> "\""  inlineToTextile opts (Cite _  lst) = inlineListToTextile opts lst  inlineToTextile _ (Code _ str) =-  return $ if '@' `elem` str-           then "<tt>" ++ escapeStringForXML str ++ "</tt>"-           else "@" ++ str ++ "@"+  return $ if '@' `elemText` str+           then "<tt>" <> escapeStringForXML str <> "</tt>"+           else "@" <> str <> "@" -inlineToTextile _ (Str str) = return $ escapeStringForTextile str+inlineToTextile _ (Str str) = return $ escapeTextForTextile str  inlineToTextile _ (Math _ str) =-  return $ "<span class=\"math\">" ++ escapeStringForXML str ++ "</span>"+  return $ "<span class=\"math\">" <> escapeStringForXML str <> "</span>"  inlineToTextile opts il@(RawInline f str)   | f == Format "html" || f == Format "textile" = return str@@ -453,36 +457,36 @@                 _           -> inlineListToTextile opts txt   let classes = if null cls || cls == ["uri"] && label == "$"                    then ""-                   else "(" ++ unwords cls ++ ")"-  return $ "\"" ++ classes ++ label ++ "\":" ++ src+                   else "(" <> T.unwords cls <> ")"+  return $ "\"" <> classes <> label <> "\":" <> src  inlineToTextile opts (Image attr@(_, cls, _) alt (source, tit)) = do   alt' <- inlineListToTextile opts alt-  let txt = if null tit-               then if null alt'+  let txt = if T.null tit+               then if T.null alt'                        then ""-                       else "(" ++ alt' ++ ")"-               else "(" ++ tit ++ ")"+                       else "(" <> alt' <> ")"+               else "(" <> tit <> ")"       classes = if null cls                    then ""-                   else "(" ++ unwords cls ++ ")"-      showDim dir = let toCss str = Just $ show dir ++ ":" ++ str ++ ";"+                   else "(" <> T.unwords cls <> ")"+      showDim dir = let toCss str = Just $ tshow dir <> ":" <> str <> ";"                     in case dimension dir attr of-                         Just (Percent a) -> toCss $ show (Percent a)-                         Just dim         -> toCss $ showInPixel opts dim ++ "px"+                         Just (Percent a) -> toCss $ tshow (Percent a)+                         Just dim         -> toCss $ showInPixel opts dim <> "px"                          Nothing          -> Nothing       styles = case (showDim Width, showDim Height) of-                 (Just w, Just h)   -> "{" ++ w ++ h ++ "}"-                 (Just w, Nothing)  -> "{" ++ w ++ "height:auto;}"-                 (Nothing, Just h)  -> "{" ++ "width:auto;" ++ h ++ "}"+                 (Just w, Just h)   -> "{" <> w <> h <> "}"+                 (Just w, Nothing)  -> "{" <> w <> "height:auto;}"+                 (Nothing, Just h)  -> "{" <> "width:auto;" <> h <> "}"                  (Nothing, Nothing) -> ""-  return $ "!" ++ classes ++ styles ++ source ++ txt ++ "!"+  return $ "!" <> classes <> styles <> source <> txt <> "!"  inlineToTextile opts (Note contents) = do   curNotes <- gets stNotes   let newnum = length curNotes + 1   contents' <- blockListToTextile opts contents-  let thisnote = "fn" ++ show newnum ++ ". " ++ contents' ++ "\n"+  let thisnote = "fn" <> tshow newnum <> ". " <> contents' <> "\n"   modify $ \s -> s { stNotes = thisnote : curNotes }-  return $ "[" ++ show newnum ++ "]"+  return $ "[" <> tshow newnum <> "]"   -- note - may not work for notes with multiple blocks
src/Text/Pandoc/Writers/XWiki.hs view
@@ -38,12 +38,12 @@ import Control.Monad.Reader (ReaderT, asks, local, runReaderT) import qualified Data.Set as Set import qualified Data.Text as Text-import Data.Text (Text, intercalate, pack, replace, split)+import Data.Text (Text, intercalate, replace, split) import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Shared (escapeURI, isURI, linesToPara)+import Text.Pandoc.Shared import Text.Pandoc.Writers.MediaWiki (highlightingLangs)  data WriterState = WriterState {@@ -65,10 +65,10 @@  -- If an id is provided, we can generate an anchor using the id macro -- https://extensions.xwiki.org/xwiki/bin/view/Extension/Id%20Macro-genAnchor :: String -> Text-genAnchor id' = if null id'+genAnchor :: Text -> Text+genAnchor id' = if Text.null id'   then ""-  else pack $ "{{id name=\"" ++ id' ++ "\" /}}"+  else "{{id name=\"" <> id' <> "\" /}}"  blockListToXWiki :: PandocMonad m => [Block] -> XWikiReader m Text blockListToXWiki blocks =@@ -93,7 +93,7 @@   blockToXWiki $ linesToPara lns  blockToXWiki b@(RawBlock f str)-  | f == Format "xwiki" = return $ pack str+  | f == Format "xwiki" = return str   | otherwise           = "" <$ report (BlockNotRendered b)  blockToXWiki HorizontalRule = return "\n----\n"@@ -139,17 +139,19 @@ tableCellXWiki :: PandocMonad m => Bool -> [Block] -> XWikiReader m Text tableCellXWiki isHeader cell = do   contents <- blockListToXWiki cell+  let isMultiline = (length . split (== '\n')) contents > 1+  let contents' = intercalate contents $ if isMultiline then ["(((", ")))"] else [mempty, mempty]   let cellBorder = if isHeader then "|=" else "|"-  return $ cellBorder <> contents-  +  return $ cellBorder <> contents' + inlineListToXWiki :: PandocMonad m => [Inline] -> XWikiReader m Text inlineListToXWiki lst =   mconcat <$> mapM inlineToXWiki lst  inlineToXWiki :: PandocMonad m => Inline -> XWikiReader m Text -inlineToXWiki (Str str) = return $ escapeXWikiString $ pack str+inlineToXWiki (Str str) = return $ escapeXWikiString str  inlineToXWiki Space = return " " @@ -191,39 +193,37 @@   contents <- inlineListToXWiki lst   return $ "“" <> contents <> "”" -inlineToXWiki (Code (_,classes,_) contents') = do+inlineToXWiki (Code (_,classes,_) contents) = do   let at  = Set.fromList classes `Set.intersection` highlightingLangs-  let contents = pack contents'   return $     case Set.toList at of       [] -> "{{code}}" <> contents <> "{{/code}}"-      (l:_) -> "{{code language=\"" <> (pack l) <> "\"}}" <> contents <> "{{/code}}"+      (l:_) -> "{{code language=\"" <> l <> "\"}}" <> contents <> "{{/code}}"  inlineToXWiki (Cite _ lst) = inlineListToXWiki lst  -- FIXME: optionally support this (plugin?) -inlineToXWiki (Math _ str) = return $ "{{formula}}" <> (pack str) <> "{{/formula}}"+inlineToXWiki (Math _ str) = return $ "{{formula}}" <> str <> "{{/formula}}"  inlineToXWiki il@(RawInline frmt str)-  | frmt == Format "xwiki" = return $ pack str+  | frmt == Format "xwiki" = return str   | otherwise              = "" <$ report (InlineNotRendered il)  -- TODO: Handle anchors inlineToXWiki (Link (id', _, _) txt (src, _)) = do   label <- inlineListToXWiki txt   case txt of-     [Str s] | isURI src && escapeURI s == src -> return $ (pack src) <> (genAnchor id')-     _  -> return $ "[[" <> label <> ">>" <> (pack src) <> "]]" <> (genAnchor id')+     [Str s] | isURI src && escapeURI s == src -> return $ src <> (genAnchor id')+     _  -> return $ "[[" <> label <> ">>" <> src <> "]]" <> (genAnchor id')  inlineToXWiki (Image _ alt (source, tit)) = do   alt' <- inlineListToXWiki alt   let-    titText = pack tit     params = intercalate " " $ filter (not . Text.null) [         if Text.null alt' then "" else "alt=\"" <> alt' <> "\"",-          if Text.null titText then "" else "title=\"" <> titText <> "\""+          if Text.null tit then "" else "title=\"" <> tit <> "\""         ]-  return $ "[[image:" <> (pack source) <> (if Text.null params then "" else "||" <> params) <> "]]"+  return $ "[[image:" <> source <> (if Text.null params then "" else "||" <> params) <> "]]"  inlineToXWiki (Note contents) = do   contents' <- blockListToXWiki contents
src/Text/Pandoc/Writers/ZimWiki.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.Writers.ZimWiki    Copyright   : Copyright (C) 2008-2019 John MacFarlane, 2017-2019 Alex Ivkin@@ -18,22 +20,25 @@ import Control.Monad (zipWithM) import Control.Monad.State.Strict (StateT, evalStateT, gets, modify) import Data.Default (Default (..))-import Data.List (intercalate, isInfixOf, isPrefixOf, transpose)+import Data.List (transpose) import qualified Data.Map as Map+import Text.DocLayout (render, literal) import Data.Maybe (fromMaybe)-import Data.Text (Text, breakOnAll, pack)+import Data.Text (Text)+import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize import Text.Pandoc.Logging-import Text.Pandoc.Options (WrapOption (..), WriterOptions (writerTableOfContents, writerTemplate, writerWrapText))-import Text.Pandoc.Shared (escapeURI, isURI, linesToPara, removeFormatting,-                           substitute, trimr)-import Text.Pandoc.Templates (renderTemplate')-import Text.Pandoc.Writers.Shared (defField, metaToJSON)+import Text.Pandoc.Options (WrapOption (..),+           WriterOptions (writerTableOfContents, writerTemplate,+                          writerWrapText))+import Text.Pandoc.Shared (escapeURI, isURI, linesToPara, removeFormatting, trimr)+import Text.Pandoc.Templates (renderTemplate)+import Text.Pandoc.Writers.Shared (defField, metaToContext)  data WriterState = WriterState {-    stIndent  :: String,         -- Indent after the marker at the beginning of list items+    stIndent  :: Text,           -- Indent after the marker at the beginning of list items     stInTable :: Bool,           -- Inside a table     stInLink  :: Bool            -- Inside a link description   }@@ -50,53 +55,53 @@ -- | Return ZimWiki representation of document. pandocToZimWiki :: PandocMonad m => WriterOptions -> Pandoc -> ZW m Text pandocToZimWiki opts (Pandoc meta blocks) = do-  metadata <- metaToJSON opts-              (fmap trimr . blockListToZimWiki opts)-              (inlineListToZimWiki opts)+  metadata <- metaToContext opts+              (fmap (literal . trimr) . blockListToZimWiki opts)+              (fmap (literal . trimr) . inlineListToZimWiki opts)               meta-  body <- pack <$> blockListToZimWiki opts blocks+  main <- blockListToZimWiki opts blocks   --let header = "Content-Type: text/x-zim-wiki\nWiki-Format: zim 0.4\n"-  let main = body   let context = defField "body" main                 $ defField "toc" (writerTableOfContents opts) metadata-  case writerTemplate opts of-       Just tpl -> renderTemplate' tpl context-       Nothing  -> return main+  return $+    case writerTemplate opts of+       Just tpl -> render Nothing $ renderTemplate tpl context+       Nothing  -> main  -- | Escape special characters for ZimWiki.-escapeString :: String -> String-escapeString = substitute "__" "''__''" .-               substitute "**" "''**''" .-               substitute "~~" "''~~''" .-               substitute "//" "''//''"+escapeText :: Text -> Text+escapeText = T.replace "__" "''__''" .+               T.replace "**" "''**''" .+               T.replace "~~" "''~~''" .+               T.replace "//" "''//''"  -- | Convert Pandoc block element to ZimWiki.-blockToZimWiki :: PandocMonad m => WriterOptions -> Block -> ZW m String+blockToZimWiki :: PandocMonad m => WriterOptions -> Block -> ZW m Text  blockToZimWiki _ Null = return ""  blockToZimWiki opts (Div _attrs bs) = do   contents <- blockListToZimWiki opts bs-  return $ contents ++ "\n"+  return $ contents <> "\n"  blockToZimWiki opts (Plain inlines) = inlineListToZimWiki opts inlines  -- title beginning with fig: indicates that the image is a figure -- ZimWiki doesn't support captions - so combine together alt and caption into alt-blockToZimWiki opts (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do+blockToZimWiki opts (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just tit)]) = do   capt <- if null txt              then return ""-             else (" " ++) `fmap` inlineListToZimWiki opts txt+             else (" " <>) `fmap` inlineListToZimWiki opts txt   let opt = if null txt                then ""-               else "|" ++ if null tit then capt else tit ++ capt-  return $ "{{" ++ src ++ imageDims opts attr ++ opt ++ "}}\n"+               else "|" <> if T.null tit then capt else tit <> capt+  return $ "{{" <> src <> imageDims opts attr <> opt <> "}}\n"  blockToZimWiki opts (Para inlines) = do   indent <- gets stIndent   -- useTags <- gets stUseTags   contents <- inlineListToZimWiki opts inlines-  return $ contents ++ if null indent then "\n" else ""+  return $ contents <> if T.null indent then "\n" else ""  blockToZimWiki opts (LineBlock lns) =   blockToZimWiki opts $ linesToPara lns@@ -112,63 +117,63 @@  blockToZimWiki opts (Header level _ inlines) = do   contents <- inlineListToZimWiki opts $ removeFormatting inlines   -- emphasis, links etc. not allowed in headers-  let eqs = replicate ( 7 - level ) '='-  return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"+  let eqs = T.replicate ( 7 - level ) "="+  return $ eqs <> " " <> contents <> " " <> eqs <> "\n"  blockToZimWiki _ (CodeBlock (_,classes,_) str) = do   -- Remap languages into the gtksourceview2 convention that ZimWiki source code plugin is using   let langal = [("javascript", "js"), ("bash", "sh"), ("winbatch", "dosbatch")]   let langmap = Map.fromList langal   return $ case classes of-                []      -> "'''\n" ++ cleanupCode str ++ "\n'''\n"   -- turn no lang block into a quote block-                (x:_)   -> "{{{code: lang=\"" ++-                        fromMaybe x (Map.lookup x langmap) ++ "\" linenumbers=\"True\"\n" ++ str ++ "\n}}}\n"  -- for zim's code plugin, go verbatim on the lang spec+                []      -> "'''\n" <> cleanupCode str <> "\n'''\n"   -- turn no lang block into a quote block+                (x:_)   -> "{{{code: lang=\"" <>+                        fromMaybe x (Map.lookup x langmap) <> "\" linenumbers=\"True\"\n" <> str <> "\n}}}\n"  -- for zim's code plugin, go verbatim on the lang spec  blockToZimWiki opts (BlockQuote blocks) = do   contents <- blockListToZimWiki opts blocks-  return $ unlines $ map ("> " ++) $ lines contents+  return $ T.unlines $ map ("> " <>) $ T.lines contents  blockToZimWiki opts (Table capt aligns _ headers rows) = do   captionDoc <- if null capt                    then return ""                    else do                       c <- inlineListToZimWiki opts capt-                      return $ "" ++ c ++ "\n"+                      return $ "" <> c <> "\n"   headers' <- if all null headers                  then zipWithM (tableItemToZimWiki opts) aligns (head rows)                  else mapM (inlineListToZimWiki opts . removeFormatting)headers  -- emphasis, links etc. are not allowed in table headers   rows' <- mapM (zipWithM (tableItemToZimWiki opts) aligns) rows-  let widths = map (maximum . map length) $ transpose (headers':rows')+  let widths = map (maximum . map T.length) $ transpose (headers':rows')   let padTo (width, al) s =-          case width - length s of+          case width - T.length s of                x | x > 0 ->                  if al == AlignLeft || al == AlignDefault-                    then s ++ replicate x ' '+                    then s <> T.replicate x " "                     else if al == AlignRight-                            then replicate x ' ' ++ s-                            else replicate (x `div` 2) ' ' ++-                                 s ++ replicate (x - x `div` 2) ' '+                            then T.replicate x " " <> s+                            else T.replicate (x `div` 2) " " <>+                                 s <> T.replicate (x - x `div` 2) " "                  | otherwise -> s   let borderCell (width, al) _-        | al == AlignLeft = ":"++ replicate (width-1) '-'-        | al == AlignDefault = replicate width '-'-        | al == AlignRight = replicate (width-1) '-' ++ ":"-        | otherwise = ":" ++ replicate (width-2) '-' ++ ":"-  let underheader  = "|" ++ intercalate "|" (zipWith borderCell (zip widths aligns) headers') ++ "|"-  let renderRow cells = "|" ++ intercalate "|" (zipWith padTo (zip widths aligns) cells) ++ "|"-  return $ captionDoc ++-           (if null headers' then "" else renderRow headers' ++ "\n") ++ underheader ++ "\n" ++-           unlines (map renderRow rows')+        | al == AlignLeft = ":"<> T.replicate (width-1) "-"+        | al == AlignDefault = T.replicate width "-"+        | al == AlignRight = T.replicate (width-1) "-" <> ":"+        | otherwise = ":" <> T.replicate (width-2) "-" <> ":"+  let underheader  = "|" <> T.intercalate "|" (zipWith borderCell (zip widths aligns) headers') <> "|"+  let renderRow cells = "|" <> T.intercalate "|" (zipWith padTo (zip widths aligns) cells) <> "|"+  return $ captionDoc <>+           (if null headers' then "" else renderRow headers' <> "\n") <> underheader <> "\n" <>+           T.unlines (map renderRow rows')  blockToZimWiki opts (BulletList items) = do   contents <- mapM (listItemToZimWiki opts) items   indent <- gets stIndent-  return $ vcat contents ++ if null indent then "\n" else ""+  return $ vcat contents <> if T.null indent then "\n" else ""  blockToZimWiki opts (OrderedList _ items) = do   contents <- zipWithM (orderedListItemToZimWiki opts) [1..] items   indent <- gets stIndent-  return $ vcat contents ++ if null indent then "\n" else ""+  return $ vcat contents <> if T.null indent then "\n" else ""  blockToZimWiki opts (DefinitionList items) = do   contents <- mapM (definitionListItemToZimWiki opts) items@@ -177,71 +182,71 @@ definitionListItemToZimWiki :: PandocMonad m                             => WriterOptions                             -> ([Inline],[[Block]])-                            -> ZW m String+                            -> ZW m Text definitionListItemToZimWiki opts (label, items) = do   labelText <- inlineListToZimWiki opts label   contents <- mapM (blockListToZimWiki opts) items   indent <- gets stIndent-  return $ indent ++ "* **" ++ labelText ++ "** " ++ concat contents+  return $ indent <> "* **" <> labelText <> "** " <> T.concat contents  -- Auxiliary functions for lists:-indentFromHTML :: PandocMonad m => WriterOptions -> String -> ZW m String+indentFromHTML :: PandocMonad m => WriterOptions -> Text -> ZW m Text indentFromHTML _ str = do    indent <- gets stIndent-   if "<li>" `isInfixOf` str+   if "<li>" `T.isInfixOf` str       then return indent-      else if "</li>" `isInfixOf` str+      else if "</li>" `T.isInfixOf` str         then return "\n"-        else if "<li value=" `isInfixOf` str+        else if "<li value=" `T.isInfixOf` str           then return ""-          else if "<ol>" `isInfixOf` str+          else if "<ol>" `T.isInfixOf` str             then do               let olcount=countSubStrs "<ol>" str-              modify $ \s -> s { stIndent = stIndent s ++-                                 replicate olcount '\t' }+              modify $ \s -> s { stIndent = stIndent s <>+                                 T.replicate olcount "\t" }               return ""-            else if "</ol>" `isInfixOf` str+            else if "</ol>" `T.isInfixOf` str               then do                 let olcount=countSubStrs "/<ol>" str-                modify $ \s -> s{ stIndent = drop olcount (stIndent s) }+                modify $ \s -> s{ stIndent = T.drop olcount (stIndent s) }                 return ""               else return "" -countSubStrs :: String -> String -> Int-countSubStrs sub str = length $ breakOnAll (pack sub) (pack str)+countSubStrs :: Text -> Text -> Int+countSubStrs sub str = length $ T.breakOnAll sub str -cleanupCode :: String -> String-cleanupCode = substitute "<nowiki>" "" . substitute "</nowiki>" ""+cleanupCode :: Text -> Text+cleanupCode = T.replace "<nowiki>" "" . T.replace "</nowiki>" "" -vcat :: [String] -> String-vcat = intercalate "\n"+vcat :: [Text] -> Text+vcat = T.intercalate "\n"  -- | Convert bullet list item (list of blocks) to ZimWiki.-listItemToZimWiki :: PandocMonad m => WriterOptions -> [Block] -> ZW m String+listItemToZimWiki :: PandocMonad m => WriterOptions -> [Block] -> ZW m Text listItemToZimWiki opts items = do   indent <- gets stIndent-  modify $ \s -> s { stIndent = indent ++ "\t" }+  modify $ \s -> s { stIndent = indent <> "\t" }   contents <- blockListToZimWiki opts items   modify $ \s -> s{ stIndent = indent }-  return $ indent ++ "* " ++ contents+  return $ indent <> "* " <> contents  -- | Convert ordered list item (list of blocks) to ZimWiki. orderedListItemToZimWiki :: PandocMonad m-                         => WriterOptions -> Int -> [Block] -> ZW m String+                         => WriterOptions -> Int -> [Block] -> ZW m Text orderedListItemToZimWiki opts itemnum items = do   indent <- gets stIndent-  modify $ \s -> s { stIndent = indent ++ "\t" }+  modify $ \s -> s { stIndent = indent <> "\t" }   contents <- blockListToZimWiki opts items   modify $ \s -> s{ stIndent = indent }-  return $ indent ++ show itemnum ++ ". " ++ contents+  return $ indent <> T.pack (show itemnum) <> ". " <> contents  -- Auxiliary functions for tables: tableItemToZimWiki :: PandocMonad m-                   => WriterOptions -> Alignment -> [Block] -> ZW m String+                   => WriterOptions -> Alignment -> [Block] -> ZW m Text tableItemToZimWiki opts align' item = do   let mkcell x = (if align' == AlignRight || align' == AlignCenter                      then "  "-                     else "") ++ x +++                     else "") <> x <>                  (if align' == AlignLeft || align' == AlignCenter                      then "  "                      else "")@@ -252,45 +257,45 @@  -- | Convert list of Pandoc block elements to ZimWiki. blockListToZimWiki :: PandocMonad m-                   => WriterOptions -> [Block] -> ZW m String+                   => WriterOptions -> [Block] -> ZW m Text blockListToZimWiki opts blocks = vcat <$> mapM (blockToZimWiki opts) blocks  -- | Convert list of Pandoc inline elements to ZimWiki. inlineListToZimWiki :: PandocMonad m-                    => WriterOptions -> [Inline] -> ZW m String-inlineListToZimWiki opts lst =  concat <$> mapM (inlineToZimWiki opts) lst+                    => WriterOptions -> [Inline] -> ZW m Text+inlineListToZimWiki opts lst = T.concat <$> mapM (inlineToZimWiki opts) lst  -- | Convert Pandoc inline element to ZimWiki. inlineToZimWiki :: PandocMonad m-                => WriterOptions -> Inline -> ZW m String+                => WriterOptions -> Inline -> ZW m Text  inlineToZimWiki opts (Emph lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "//" ++ contents ++ "//"+  return $ "//" <> contents <> "//"  inlineToZimWiki opts (Strong lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "**" ++ contents ++ "**"+  return $ "**" <> contents <> "**"  inlineToZimWiki opts (Strikeout lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "~~" ++ contents ++ "~~"+  return $ "~~" <> contents <> "~~"  inlineToZimWiki opts (Superscript lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "^{" ++ contents ++ "}"+  return $ "^{" <> contents <> "}"  inlineToZimWiki opts (Subscript lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "_{" ++ contents ++ "}"+  return $ "_{" <> contents <> "}"  inlineToZimWiki opts (Quoted SingleQuote lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "\8216" ++ contents ++ "\8217"+  return $ "\8216" <> contents <> "\8217"  inlineToZimWiki opts (Quoted DoubleQuote lst) = do   contents <- inlineListToZimWiki opts lst-  return $ "\8220" ++ contents ++ "\8221"+  return $ "\8220" <> contents <> "\8221"  inlineToZimWiki opts (Span _attrs ils) = inlineListToZimWiki opts ils @@ -298,24 +303,24 @@  inlineToZimWiki opts (Cite _  lst) = inlineListToZimWiki opts lst -inlineToZimWiki _ (Code _ str) = return $ "''" ++ str ++ "''"+inlineToZimWiki _ (Code _ str) = return $ "''" <> str <> "''"  inlineToZimWiki _ (Str str) = do   inTable <- gets stInTable   inLink  <- gets stInLink   if inTable-      then return $ substitute "|" "\\|" . escapeString $ str+      then return $ T.replace "|" "\\|" . escapeText $ str       else           if inLink           then return str-          else return $ escapeString str+          else return $ escapeText str -inlineToZimWiki _ (Math mathType str) = return $ delim ++ str ++ delim   -- note:  str should NOT be escaped+inlineToZimWiki _ (Math mathType str) = return $ delim <> str <> delim   -- note:  str should NOT be escaped   where delim = case mathType of                      DisplayMath -> "$$"                      InlineMath  -> "$" --- | f == Format "html"     = return $ "<html>" ++ str ++ "</html>"+-- | f == Format "html"     = return $ "<html>" <> str <> "</html>" inlineToZimWiki opts il@(RawInline f str)   | f == Format "zimwiki" = return str   | f == Format "html"    = indentFromHTML opts str@@ -344,38 +349,39 @@   modify $ \s -> s { stInLink = False }   let label'= if inTable             then "" -- no label is allowed in a table-            else "|"++label+            else "|"<>label   case txt of-     [Str s] | "mailto:" `isPrefixOf` src -> return $ "<" ++ s ++ ">"+     [Str s] | "mailto:" `T.isPrefixOf` src -> return $ "<" <> s <> ">"              | escapeURI 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+              then return $ "[[" <> src  <> label' <> "]]"+              else return $ "[[" <> src' <> label' <> "]]"+  where+    -- with leading / it's a link to a help page+    src' = fromMaybe src $ T.stripPrefix "/" src+ inlineToZimWiki opts (Image attr alt (source, tit)) = do   alt' <- inlineListToZimWiki opts alt   inTable <- gets stInTable   let txt = case (tit, alt, inTable) of               ("",[], _)      -> ""-              ("", _, False ) -> "|" ++ alt'-              (_ , _, False ) -> "|" ++ tit+              ("", _, False ) -> "|" <> alt'+              (_ , _, False ) -> "|" <> tit               (_ , _, True )  -> ""-  return $ "{{" ++ source ++ imageDims opts attr ++ txt ++ "}}"+  return $ "{{" <> source <> imageDims opts attr <> txt <> "}}"  inlineToZimWiki opts (Note contents) = do   -- no concept of notes in zim wiki, use a text block   contents' <- blockListToZimWiki opts contents-  return $ " **{Note:** " ++ trimr contents' ++ "**}**"+  return $ " **{Note:** " <> trimr contents' <> "**}**" -imageDims :: WriterOptions -> Attr -> String+imageDims :: WriterOptions -> Attr -> Text imageDims opts attr = go (toPx $ dimension Width attr) (toPx $ dimension Height attr)   where     toPx = fmap (showInPixel opts) . checkPct     checkPct (Just (Percent _)) = Nothing     checkPct maybeDim           = maybeDim-    go (Just w) Nothing  = "?" ++ w-    go (Just w) (Just h) = "?" ++ w ++ "x" ++ h-    go Nothing  (Just h) = "?0x" ++ h+    go (Just w) Nothing  = "?" <> w+    go (Just w) (Just h) = "?" <> w <> "x" <> h+    go Nothing  (Just h) = "?0x" <> h     go Nothing  Nothing  = ""
src/Text/Pandoc/XML.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns      #-} {- |    Module      : Text.Pandoc.XML    Copyright   : Copyright (C) 2006-2019 John MacFarlane@@ -25,21 +27,23 @@ import Data.Text (Text) import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity, htmlEntities)-import Text.Pandoc.Pretty+import Text.DocLayout+import Text.Printf (printf) import qualified Data.Map as M+import Data.String  -- | Escape one character as needed for XML.-escapeCharForXML :: Char -> String+escapeCharForXML :: Char -> Text escapeCharForXML x = case x of                        '&' -> "&amp;"                        '<' -> "&lt;"                        '>' -> "&gt;"                        '"' -> "&quot;"-                       c   -> [c]+                       c   -> T.singleton c  -- | Escape string as needed for XML.  Entity references are not preserved.-escapeStringForXML :: String -> String-escapeStringForXML = concatMap escapeCharForXML . filter isLegalXMLChar+escapeStringForXML :: Text -> Text+escapeStringForXML = T.concatMap escapeCharForXML . T.filter isLegalXMLChar   where isLegalXMLChar c = c == '\t' || c == '\n' || c == '\r' ||                            (c >= '\x20' && c <= '\xD7FF') ||                            (c >= '\xE000' && c <= '\xFFFD') ||@@ -47,47 +51,50 @@   -- see https://www.w3.org/TR/xml/#charsets  -- | Escape newline characters as &#10;-escapeNls :: String -> String-escapeNls (x:xs)-  | x == '\n' = "&#10;" ++ escapeNls xs-  | otherwise = x : escapeNls xs-escapeNls []     = []+escapeNls :: Text -> Text+escapeNls = T.concatMap $ \x -> case x of+  '\n' -> "&#10;"+  c    -> T.singleton c  -- | Return a text object with a string of formatted XML attributes.-attributeList :: [(String, String)] -> Doc+attributeList :: (HasChars a, IsString a) => [(Text, Text)] -> Doc a attributeList = hcat . map-  (\(a, b) -> text (' ' : escapeStringForXML a ++ "=\"" ++-  escapeNls (escapeStringForXML b) ++ "\""))+  (\(a, b) -> text (T.unpack $ " " <> escapeStringForXML a <> "=\"" <>+  escapeNls (escapeStringForXML b) <> "\""))  -- | Put the supplied contents between start and end tags of tagType, --   with specified attributes and (if specified) indentation.-inTags:: Bool -> String -> [(String, String)] -> Doc -> Doc+inTags :: (HasChars a, IsString a)+      => Bool -> Text -> [(Text, Text)] -> Doc a -> Doc a inTags isIndented tagType attribs contents =-  let openTag = char '<' <> text tagType <> attributeList attribs <>+  let openTag = char '<' <> text (T.unpack tagType) <> attributeList attribs <>                 char '>'-      closeTag  = text "</" <> text tagType <> char '>'+      closeTag  = text "</" <> text (T.unpack tagType) <> char '>'   in  if isIndented          then openTag $$ nest 2 contents $$ closeTag          else openTag <> contents <> closeTag  -- | Return a self-closing tag of tagType with specified attributes-selfClosingTag :: String -> [(String, String)] -> Doc+selfClosingTag :: (HasChars a, IsString a)+               => Text -> [(Text, Text)] -> Doc a selfClosingTag tagType attribs =-  char '<' <> text tagType <> attributeList attribs <> text " />"+  char '<' <> text (T.unpack tagType) <> attributeList attribs <> text " />"  -- | Put the supplied contents between start and end tags of tagType.-inTagsSimple :: String -> Doc -> Doc+inTagsSimple :: (HasChars a, IsString a)+             => Text -> Doc a -> Doc a inTagsSimple tagType = inTags False tagType []  -- | Put the supplied contents in indented block btw start and end tags.-inTagsIndented :: String -> Doc -> Doc+inTagsIndented :: (HasChars a, IsString a)+               => Text -> Doc a -> Doc a inTagsIndented tagType = inTags True tagType []  -- | Escape all non-ascii characters using numerical entities. toEntities :: Text -> Text toEntities = T.concatMap go   where go c | isAscii c = T.singleton c-             | otherwise = T.pack ("&#" ++ show (ord c) ++ ";")+             | otherwise = T.pack (printf "&#x%X;" (ord c))  -- | Escape all non-ascii characters using HTML5 entities, falling -- back to numerical entities.@@ -112,18 +119,21 @@   -- Unescapes XML entities-fromEntities :: String -> String-fromEntities ('&':xs) =-  case lookupEntity ent' of-        Just c  -> c ++ fromEntities rest-        Nothing -> '&' : fromEntities xs-    where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of-                             (zs,';':ys) -> (zs,ys)-                             (zs,    ys) -> (zs,ys)-          ent' = case ent of-                      '#':'X':ys -> '#':'x':ys  -- workaround tagsoup bug-                      '#':_      -> ent-                      _          -> ent ++ ";"+fromEntities :: Text -> Text+fromEntities = T.pack . fromEntities' -fromEntities (x:xs) = x : fromEntities xs-fromEntities [] = []+fromEntities' :: Text -> String+fromEntities' (T.uncons -> Just ('&', xs)) =+  case lookupEntity $ T.unpack ent' of+        Just c  -> c <> fromEntities' rest+        Nothing -> "&" <> fromEntities' xs+    where (ent, rest) = case T.break (\c -> isSpace c || c == ';') xs of+                          (zs,T.uncons -> Just (';',ys)) -> (zs,ys)+                          (zs, ys) -> (zs,ys)+          ent'+            | Just ys <- T.stripPrefix "#X" ent = "#x" <> ys  -- workaround tagsoup bug+            | Just ('#', _) <- T.uncons ent     = ent+            | otherwise                         = ent <> ";"+fromEntities' t = case T.uncons t of+  Just (x, xs) -> x : fromEntities' xs+  Nothing      -> ""
stack.yaml view
@@ -2,6 +2,7 @@   pandoc:     trypandoc: false     embed_data_files: true+    static: false   pandoc-citeproc:     bibutils: true     embed_data_files: true@@ -11,14 +12,17 @@ packages: - '.' extra-deps:-- pandoc-citeproc-0.16.2-- ipynb-0.1-- cmark-gfm-0.2.0-- hslua-1.0.3.1-- hslua-module-system-0.2.0-- tasty-lua-0.2.0-- skylighting-core-0.8.1-- skylighting-0.8.1+- pandoc-types-1.20+- texmath-0.12+- haddock-library-1.8.0+- skylighting-0.8.2.3+- skylighting-core-0.8.2.3+- regex-pcre-builtin-0.95.0.8.8.35+- doclayout-0.2.0.1+- HsYAML-0.2.0.0+- HsYAML-aeson-0.2.0.0+- doctemplates-0.7.1+- pandoc-citeproc-0.16.4 ghc-options:-   "$locals": -Wall -fno-warn-unused-do-bind -Wincomplete-record-updates -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances -Wincomplete-uni-patterns -Widentities -Wcpp-undef -fhide-source-paths -Wno-missing-home-modules-resolver: lts-13.17+   "$locals": -fhide-source-paths -Wno-missing-home-modules+resolver: lts-14.6
test/Tests/Command.hs view
@@ -16,6 +16,7 @@ import Prelude import Data.Algorithm.Diff import qualified Data.ByteString as BS+import qualified Data.Text as T import Data.List (isSuffixOf) import Prelude hiding (readFile) import System.Directory@@ -77,7 +78,7 @@ isCodeBlock _               = False  extractCode :: Block -> String-extractCode (CodeBlock _ code) = code+extractCode (CodeBlock _ code) = T.unpack code extractCode _                  = ""  dropPercent :: String -> String
test/Tests/Helpers.hs view
@@ -136,13 +136,13 @@    where s = case d of                   (Pandoc (Meta m) _)                     | M.null m  -> Nothing-                    | otherwise -> Just "" -- need this to get meta output+                    | otherwise -> Just mempty -- need this to get meta output  instance ToString Blocks where   toString = unpack . purely (writeNative def) . toPandoc  instance ToString Inlines where-  toString = trimr . unpack . purely (writeNative def) . toPandoc+  toString = unpack . trimr . purely (writeNative def) . toPandoc  instance ToString String where   toString = id
test/Tests/Lua.hs view
@@ -33,7 +33,8 @@ import Text.Pandoc.Shared (pandocVersion)  import qualified Foreign.Lua as Lua-import qualified Data.ByteString.Char8 as BS+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE  tests :: [TestTree] tests = map (localOption (QuickCheckTests 20))@@ -132,12 +133,12 @@     assertFilterConversion "unexpected script name"       "script-name.lua"       (doc $ para "ignored")-      (doc $ para (str $ "lua" </> "script-name.lua"))+      (doc $ para (str $ T.pack $ "lua" </> "script-name.lua"))    , testCase "Pandoc version is set" . runLuaTest $ do       Lua.getglobal "PANDOC_VERSION"       Lua.liftIO .-        assertEqual "pandoc version is wrong" (BS.pack pandocVersion)+        assertEqual "pandoc version is wrong" (TE.encodeUtf8 pandocVersion)         =<< Lua.tostring' Lua.stackTop    , testCase "Pandoc types version is set" . runLuaTest $ do@@ -192,7 +193,7 @@ roundtripEqual :: (Eq a, Lua.Peekable a, Lua.Pushable a) => a -> IO Bool roundtripEqual x = (x ==) <$> roundtripped  where-  roundtripped :: (Lua.Peekable a, Lua.Pushable a) => IO a+  roundtripped :: Lua.Peekable a => IO a   roundtripped = runLuaTest $ do     oldSize <- Lua.gettop     Lua.push x
test/Tests/Old.hs view
@@ -86,6 +86,8 @@     , test' "reader" ["-r", "docbook", "-w", "native", "-s"]       "docbook-reader.docbook" "docbook-reader.native"     , test' "reader" ["-r", "docbook", "-w", "native", "-s"]+      "docbook-chapter.docbook" "docbook-chapter.native"+    , test' "reader" ["-r", "docbook", "-w", "native", "-s"]       "docbook-xref.docbook" "docbook-xref.native"     ]   , testGroup "docbook5"
test/Tests/Readers/Docx.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Tests.Readers.Docx    Copyright   : © 2017-2019 Jesse Rosenthal, John MacFarlane@@ -46,7 +47,7 @@    where s = case d of                   NoNormPandoc (Pandoc (Meta m) _)                     | M.null m  -> Nothing-                    | otherwise -> Just "" -- need this to get meta output+                    | otherwise -> Just mempty -- need this to get meta output  instance ToPandoc NoNormPandoc where   toPandoc = unNoNorm@@ -79,7 +80,7 @@   df <- B.readFile docxFile   logs <-  runIOorExplode $ setVerbosity ERROR >> readDocx opts df >> P.getLog   let warns = [m | DocxParserWarning m <- logs]-  return $ test id name (unlines warns, unlines expected)+  return $ test id name (T.unlines warns, unlines expected)  testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> TestTree testForWarningsWithOpts opts name docxFile expected =@@ -256,6 +257,10 @@             "docx/lists.docx"             "docx/lists.native"           , testCompare+            "compact lists"+            "docx/lists-compact.docx"+            "docx/lists-compact.native"+          , testCompare             "lists with level overrides"             "docx/lists_level_override.docx"             "docx/lists_level_override.native"@@ -268,6 +273,10 @@             "docx/lists_restarting.docx"             "docx/lists_restarting.native"           , testCompare+            "sublists reset numbering to 1"+            "docx/lists_sublist_reset.docx"+            "docx/lists_sublist_reset.native"+          , testCompare             "definition lists"             "docx/definition_list.docx"             "docx/definition_list.native"@@ -425,6 +434,11 @@             "custom styles (`+styles`) enabled"             "docx/custom-style-reference.docx"             "docx/custom-style-with-styles.native"+          , testCompareWithOpts+            def{readerExtensions=extensionsFromList [Ext_styles]}+            "custom styles (`+styles`): Compact style is removed from output"+            "docx/compact-style-removal.docx"+            "docx/compact-style-removal.native"           ]         , testGroup "metadata"           [ testCompareWithOpts def{readerStandalone=True}
test/Tests/Readers/DokuWiki.hs view
@@ -46,6 +46,9 @@           , "Monospaced" =:             "''monospaced''" =?>             para (code "monospaced")+          , "Monospaced with nowiki" =:+            "''%%monospaced%%''" =?>+            para (code "monospaced")           , "Combined" =:             "**__//''combine''//__**" =?>             para (strong $ underlineSpan $ emph $ code "combine")
test/Tests/Readers/EPUB.hs view
@@ -14,6 +14,7 @@  import Prelude import qualified Data.ByteString.Lazy as BL+import qualified Data.Text as T import Test.Tasty import Test.Tasty.HUnit import qualified Text.Pandoc.Class as P@@ -35,7 +36,9 @@              ++ show bag              ++ "\nActual: "              ++ show actBag)-             (actBag == bag)+             (actBag == packBag bag)+  where+    packBag = map $ \(x, y, z) -> (x, T.pack y, z)  featuresBag :: [(String, String, Int)] featuresBag = [("img/check.gif","image/gif",1340)@@ -44,10 +47,42 @@               ,("img/multiscripts_and_greek_alphabet.png","image/png",10060)               ] +-- with additional meta tag for cover in EPUB2 format+epub3CoverBag :: [(String, String, Int)]+epub3CoverBag = [("wasteland-cover.jpg","image/jpeg",103477)]++epub3NoCoverBag :: [(String, String, Int)]+epub3NoCoverBag = [("img/check.gif","image/gif",1340)+                  ,("img/check.jpg","image/jpeg",2661)+                  ,("img/check.png","image/png",2815)+                  ]++-- content.opf uses the word `picture` to refer to the cover as much as validly possible+-- to check if references are resolved correctly+epub2PictureBag :: [(String, String, Int)]+epub2PictureBag = [("image/image.jpg","image/jpeg",9713)]++-- content.opf contains the word `cover` as much as possible, to check if possible multiple matches cause errors+epub2CoverBag :: [(String, String, Int)]+epub2CoverBag = [("image/cover.jpg","image/jpeg",9713)]++epub2NoCoverBag :: [(String, String, Int)]+epub2NoCoverBag = []+ tests :: [TestTree] tests =   [ testGroup "EPUB Mediabag"     [ testCase "features bag"-      (testMediaBag "epub/img.epub" featuresBag)+      (testMediaBag "epub/img.epub" featuresBag),+      testCase "EPUB3 cover bag"+      (testMediaBag "epub/wasteland.epub" epub3CoverBag),+      testCase "EPUB3 no cover bag"+      (testMediaBag "epub/img_no_cover.epub" epub3NoCoverBag),+      testCase "EPUB2 picture bag"+      (testMediaBag "epub/epub2_picture.epub" epub2PictureBag),+      testCase "EPUB2 cover bag"+      (testMediaBag "epub/epub2_cover.epub" epub2CoverBag),+      testCase "EPUB2 no cover bag"+      (testMediaBag "epub/epub2_no_cover.epub" epub2NoCoverBag)     ]   ]
test/Tests/Readers/FB2.hs view
@@ -18,16 +18,17 @@ import Test.Tasty.Golden (goldenVsString) import qualified Data.ByteString as BS import Text.Pandoc-import Text.Pandoc.UTF8 (toText, fromTextLazy)-import Data.Text (Text)-import Data.Text.Lazy (fromStrict)+import Text.Pandoc.UTF8 (toText, fromStringLazy)+import Data.Text (Text, unpack) import System.FilePath (replaceExtension)  fb2ToNative :: Text -> Text-fb2ToNative = purely (writeNative def{ writerTemplate = Just "" }) . purely (readFB2 def)+fb2ToNative = purely (writeNative def{ writerTemplate = Just mempty }) . purely (readFB2 def)  fb2Test :: TestName -> FilePath -> TestTree-fb2Test name path = goldenVsString name native (fromTextLazy . fromStrict . fb2ToNative . toText <$> BS.readFile path)+fb2Test name path = goldenVsString name native+  (fromStringLazy . filter (/='\r') . unpack . fb2ToNative . toText+    <$> BS.readFile path)   where native = replaceExtension path ".native"  tests :: [TestTree]
test/Tests/Readers/HTML.hs view
@@ -89,6 +89,18 @@           , test htmlNativeDivs "<main> followed by text" $ "<main>main content</main>non-main content" =?>             doc (divWith ("", [], [("role", "main")]) (plain (text "main content")) <> plain (text "non-main content"))           ]+        , testGroup "samp"+          [+            test html "inline samp block" $ +            "<samp>Answer is 42</samp>" =?> +            plain (codeWith ("",["sample"],[]) "Answer is 42")+          ]+        , testGroup "var"+        [+          test html "inline var block" $ +          "<var>result</var>" =?> +          plain (codeWith ("",["variable"],[]) "result")+        ]         , askOption $ \(QuickCheckTests numtests) ->             testProperty "Round trip" $               withMaxSuccess (if QuickCheckTests numtests == defaultValue
test/Tests/Readers/LaTeX.hs view
@@ -169,10 +169,10 @@           testGroup "Character Escapes"           [ "Two-character escapes" =:             mconcat ["^^" <> T.pack [i,j] | i <- hex, j <- hex] =?>-            para (str ['\0'..'\255'])+            para (str $ T.pack ['\0'..'\255'])           , "One-character escapes" =:             mconcat ["^^" <> T.pack [i] | i <- hex] =?>-            para (str $ ['p'..'y']++['!'..'&'])+            para (str $ T.pack $ ['p'..'y']++['!'..'&'])           ]         , testGroup "memoir scene breaks"           [ "plainbreak" =:@@ -255,7 +255,7 @@                        }  rt :: String -> Inlines-rt = rawInline "latex"+rt = rawInline "latex" . T.pack  natbibCitations :: TestTree natbibCitations = testGroup "natbib"
test/Tests/Readers/Man.hs view
@@ -74,7 +74,7 @@       =?> para (text "hi " <> emph (text "there " <> strong (text "bold")) <>                                    text " ok")     , "skip" =:-      "a\\%\\{\\}\\\n\\:b\\0"+      "a\\%\\\n\\:b\\0"       =?> (para $ str "ab\8199")     , "replace" =:       "\\-\\ \\\\\\[lq]\\[rq]\\[em]\\[en]\\*(lq\\*(rq"
test/Tests/Readers/Markdown.hs view
@@ -53,7 +53,8 @@ autolink = autolinkWith ("",["uri"],[])  autolinkWith :: Attr -> String -> Inlines-autolinkWith attr s = linkWith attr s "" (str s)+autolinkWith attr s = linkWith attr s' "" (str s')+  where s' = T.pack s  bareLinkTests :: [(Text, Inlines)] bareLinkTests =
test/Tests/Readers/Muse.hs view
@@ -133,6 +133,38 @@         "**foo *bar* baz**" =?>         para (strong (text "foo " <> emph (text "bar") <> text " baz")) +      , "Opening asterisk can't be preceded by another one" =:+        "**foo*" =?>+        para "**foo*"++      , "Asterisk between words does not terminate emphasis" =:+        "*foo*bar*" =?>+        para (emph "foo*bar")++      , "Two asterisks between words do not terminate emphasis" =:+        "*foo**bar*" =?>+        para (emph "foo**bar")++      , "Three asterisks between words do not terminate emphasis" =:+        "*foo***bar*" =?>+        para (emph "foo***bar")++      , "Two asterisks between words do not terminate strong" =:+        "**foo**bar**" =?>+        para (strong "foo**bar")++      , "Three asterisks between words do not terminate strong" =:+        "**foo***bar**" =?>+        para (strong "foo***bar")++      , "Three asterisks between words do not terminate strong emphasis" =:+        "***foo***bar***" =?>+        para (strong . emph $ "foo***bar")++      , "Six asterisks between words do not terminate strong emphasis" =:+        "***foo******bar***" =?>+        para (strong . emph $ "foo******bar")+       , test emacsMuse "Underline"         ("_Underline_" =?> para (underlineSpan "Underline")) @@ -236,6 +268,9 @@       , "Class tag" =: "<class name=\"foo\">bar</class>" =?> para (spanWith ("", ["foo"], []) "bar")       , "Class tag without name" =: "<class>foobar</class>" =?> para (spanWith ("", [], []) "foobar") +      , "RTL" =: "<<<foo bar>>>" =?> para (spanWith ("", [], [("dir", "rtl")]) "foo bar")+      , "LTR" =: ">>>foo bar<<<" =?> para (spanWith ("", [], [("dir", "ltr")]) "foo bar")+       -- <em> tag should match with the last </em> tag, not verbatim one       , "Nested \"</em>\" inside em tag" =: "<em>foo<verbatim></em></verbatim>bar</em>" =?> para (emph "foo</em>bar") @@ -291,7 +326,7 @@           para (link "https://amusewiki.org/" "" (text "foo[1"))         , "Image inside link" =:           "[[https://amusewiki.org/][Image [[image.png][with it's own description]] inside link description]]" =?>-          para (link "https://amusewiki.org/" "" (text "Image " <> (image "image.png" "" (text "with it's own description")) <> text " inside link description"))+          para (link "https://amusewiki.org/" "" (text "Image " <> image "image.png" "" (text "with it's own description") <> text " inside link description"))         , "Link inside image description" =:           "[[image.jpg][Image from [[https://amusewiki.org/]]]]" =?>           para (image "image.jpg" "" (text "Image from " <> link "https://amusewiki.org/" "" (str "https://amusewiki.org/")))
test/Tests/Readers/Odt.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Tests.Readers.Odt    Copyright   : © 2015-2019 John MacFarlane@@ -61,7 +62,7 @@    where s = case d of                   NoNormPandoc (Pandoc (Meta m) _)                     | M.null m  -> Nothing-                    | otherwise -> Just "" -- need this for Meta output+                    | otherwise -> Just mempty -- need this for Meta output  instance ToPandoc NoNormPandoc where   toPandoc = unNoNorm@@ -152,6 +153,7 @@                                    , "endnote"                                    , "externalLink"                                    , "footnote"+                                   , "formula"                                    , "headers" --                                 , "horizontalRule"                                    , "italic"
test/Tests/Readers/Org/Block.hs view
@@ -73,13 +73,23 @@       "----- em and en dash" =?>       para "\8212\8211 em and en dash" -  , "Comment Block" =:+  , testGroup "Comments"+    [ "Comment Block" =:       T.unlines [ "#+BEGIN_COMMENT"                 , "stuff"                 , "bla"                 , "#+END_COMMENT"] =?>       (mempty::Blocks) +    , "Comment line" =:+      T.unlines [ "# this is a comment" ] =?>+      (mempty :: Blocks)++    , "Empty comment line" =:+      T.unlines [ "  #" ] =?>+      (mempty :: Blocks)+    ]+   , testGroup "Blocks and fragments"     [ "HTML block" =:       T.unlines [ "#+BEGIN_HTML"@@ -169,7 +179,7 @@                 , "\\end{equation}"                 ] =?>       rawBlock "latex"-      (unlines [ "\\begin{equation}"+      (T.unlines [ "\\begin{equation}"                , "X_i = \\begin{cases}"                , "      G_{\\alpha(i)} & \\text{if }\\alpha(i-1) =" <>                  " \\alpha(i)\\\\"
test/Tests/Readers/Org/Block/CodeBlock.hs view
@@ -80,7 +80,7 @@            params = [ ("org-language", "emacs-lisp")                     , ("exports", "both")                     ]-           code' = unlines [ "(progn (message \"Hello, World!\")"+           code' = T.unlines [ "(progn (message \"Hello, World!\")"                            , "       (+ 23 42))" ]        in codeBlockWith ("", classes, params) code' @@ -96,8 +96,8 @@            params = [ ("org-language", "emacs-lisp")                     , ("exports", "both")                     ]-           code' = unlines [ "(progn (message \"Hello, World!\")"-                           , "       (+ 23 42))" ]+           code' = T.unlines [ "(progn (message \"Hello, World!\")"+                             , "       (+ 23 42))" ]            results' = "65\n"        in codeBlockWith ("", classes, params) code'           <>@@ -115,8 +115,8 @@            params = [ ("org-language", "emacs-lisp")                     , ("exports", "code")                     ]-           code' = unlines [ "(progn (message \"Hello, World!\")"-                           , "       (+ 23 42))" ]+           code' = T.unlines [ "(progn (message \"Hello, World!\")"+                             , "       (+ 23 42))" ]        in codeBlockWith ("", classes, params) code'    , "Source block with results and :exports results" =:@@ -190,9 +190,9 @@           (plain $ spanWith ("", ["label"], [])                             (spcSep [ "Functor", "laws", "in", "Haskell" ]))           (codeBlockWith ("functor-laws", ["haskell"], [])-                         (unlines [ "fmap id = id"-                                  , "fmap (p . q) = (fmap p) . (fmap q)"-                                  ])))+                         (T.unlines [ "fmap id = id"+                                    , "fmap (p . q) = (fmap p) . (fmap q)"+                                    ])))    , "Non-letter chars in source block parameters" =:       T.unlines [ "#+BEGIN_SRC C :tangle xxxx.c :city Zürich"
test/Tests/Readers/Org/Block/Figure.hs view
@@ -54,6 +54,13 @@           caption = "mah brain just explodid"       in para (imageWith (mempty, mempty, kv) "lambdacat.jpg" name caption) +  , "LaTeX attributes are ignored" =:+      T.unlines [ "#+CAPTION: Attribute after caption"+                , "#+ATTR_LATEX: :float nil"+                , "[[file:test.png]]"+                ] =?>+      para (image "test.png" "fig:" "Attribute after caption")+   , "Labelled figure" =:       T.unlines [ "#+CAPTION: My figure"                 , "#+LABEL: fig:myfig"
test/Tests/Readers/Org/Shared.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Tests.Readers.Org.Shared    Copyright   : © 2014-2019 Albert Krewinkel@@ -38,5 +39,5 @@ spcSep = mconcat . intersperse space  -- | Create a span for the given tag.-tagSpan :: String -> Inlines+tagSpan :: Text -> Inlines tagSpan t = spanWith ("", ["tag"], [("tag-name", t)]) . smallcaps $ str t
test/Tests/Shared.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- |    Module      : Tests.Shared    Copyright   : © 2006-2019 John MacFarlane
test/Tests/Writers/AsciiDoc.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} module Tests.Writers.AsciiDoc (tests) where  import Prelude@@ -12,29 +13,35 @@ asciidoc :: (ToPandoc a) => a -> String asciidoc = unpack . purely (writeAsciiDoc def{ writerWrapText = WrapNone }) . toPandoc +testAsciidoc :: (ToString a, ToPandoc a)+             => String+             -> (a, String)+             -> TestTree+testAsciidoc = test asciidoc+ tests :: [TestTree] tests = [ testGroup "emphasis"-          [ test asciidoc "emph word before" $+          [ testAsciidoc "emph word before" $                para (text "foo" <> emph (text "bar")) =?>                  "foo__bar__"-          , test asciidoc "emph word after" $+          , testAsciidoc "emph word after" $                para (emph (text "foo") <> text "bar") =?>                  "__foo__bar"-          , test asciidoc "emph quoted" $+          , testAsciidoc "emph quoted" $                para (doubleQuoted (emph (text "foo"))) =?>                  "``__foo__''"-          , test asciidoc "strong word before" $+          , testAsciidoc "strong word before" $                para (text "foo" <> strong (text "bar")) =?>                  "foo**bar**"-          , test asciidoc "strong word after" $+          , testAsciidoc "strong word after" $                para (strong (text "foo") <> text "bar") =?>                  "**foo**bar"-          , test asciidoc "strong quoted" $+          , testAsciidoc "strong quoted" $                para (singleQuoted (strong (text "foo"))) =?>                  "`**foo**'"           ]         , testGroup "tables"-          [ test asciidoc "empty cells" $+          [ testAsciidoc "empty cells" $                simpleTable [] [[mempty],[mempty]] =?> unlines                                            [ "[cols=\"\",]"                                            , "|==="
test/Tests/Writers/ConTeXt.hs view
@@ -3,7 +3,7 @@ module Tests.Writers.ConTeXt (tests) where  import Prelude-import Data.Text (unpack)+import Data.Text (unpack, pack) import Test.Tasty import Test.Tasty.QuickCheck import Tests.Helpers@@ -44,11 +44,11 @@ tests = [ testGroup "inline code"           [ "with '}'" =: code "}" =?> "\\mono{\\}}"           , "without '}'" =: code "]" =?> "\\type{]}"-          , testProperty "code property" $ \s -> null s ||+          , testProperty "code property" $ \s -> null s || '\n' `elem` s ||                 if '{' `elem` s || '}' `elem` s-                   then context' (code s) == "\\mono{" ++-                             context' (str s) ++ "}"-                   else context' (code s) == "\\type{" ++ s ++ "}"+                   then context' (code $ pack s) == "\\mono{" +++                             context' (str $ pack s) ++ "}"+                   else context' (code $ pack s) == "\\type{" ++ s ++ "}"           ]         , testGroup "headers"           [ "level 1" =:
test/Tests/Writers/Docx.hs view
@@ -155,6 +155,10 @@             def{writerReferenceDoc = Just "docx/custom-style-reference.docx"}             "docx/custom_style.native"             "docx/golden/custom_style_reference.docx"+          , docxTest "suppress custom style for headers and blockquotes"+            def+            "docx/custom-style-preserve.native"+            "docx/golden/custom_style_preserve.docx"           ]         , testGroup "metadata"           [ docxTest "document properties (core, custom)"
test/Tests/Writers/HTML.hs view
@@ -13,6 +13,11 @@ html :: (ToPandoc a) => a -> String html = unpack . purely (writeHtml4String def{ writerWrapText = WrapNone }) . toPandoc +htmlQTags :: (ToPandoc a) => a -> String+htmlQTags = unpack+  . purely (writeHtml4String def{ writerWrapText = WrapNone, writerHtmlQTags = True })+  . toPandoc+ {-   "my test" =: X =?> Y @@ -48,4 +53,38 @@             definitionList [(mempty, [para $ text "foo bar"])]             =?> "<dl><dt></dt><dd><p>foo bar</p></dd></dl>"           ]+        , testGroup "quotes"+          [ "quote with cite attribute (without q-tags)" =:+            doubleQuoted (spanWith ("", [], [("cite", "http://example.org")]) (str "examples"))+            =?> "“<span cite=\"http://example.org\">examples</span>”"+          , tQ "quote with cite attribute (with q-tags)" $+            doubleQuoted (spanWith ("", [], [("cite", "http://example.org")]) (str "examples"))+            =?> "<q cite=\"http://example.org\">examples</q>"+          ]+        , testGroup "sample"+          [ "sample should be rendered correctly" =:+            plain (codeWith ("",["sample"],[]) "Answer is 42") =?>+            "<samp>Answer is 42</samp>"+          ]+        , testGroup "variable"+          [ "variable should be rendered correctly" =:+            plain (codeWith ("",["variable"],[]) "result") =?>+            "<var>result</var>"+          ]+        , testGroup "sample with style"+          [ "samp should wrap highlighted code" =:+            codeWith ("",["sample","haskell"],[]) ">>="+            =?> ("<samp><code class=\"sourceCode haskell\">" ++ +                "<span class=\"op\">&gt;&gt;=</span></code></samp>")+          ]+        , testGroup "variable with style"+          [ "var should wrap highlighted code" =:+            codeWith ("",["haskell","variable"],[]) ">>="+            =?> ("<var><code class=\"sourceCode haskell\">" ++ +                "<span class=\"op\">&gt;&gt;=</span></code></var>")+          ]         ]+        where+          tQ :: (ToString a, ToPandoc a)+               => String -> (a, String) -> TestTree+          tQ = test htmlQTags
test/Tests/Writers/Markdown.hs view
@@ -40,7 +40,7 @@ tests :: [TestTree] tests = [ "indented code after list"              =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test")-             =?> "1.  one\n\n    two\n\n<!-- -->\n\n    test"+             =?> "1.  one\n\n    two\n\n```{=html}\n<!-- -->\n```\n    test"         , "list with tight sublist"              =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],                              plain "baz" ]
test/Tests/Writers/Muse.hs view
@@ -620,6 +620,13 @@           , "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <>                                 spanWith ("", ["syllable"], []) (str "ter")                              =?> "<class name=\"syllable\">wa</class><class name=\"syllable\">ter</class>"+          , testGroup "RTL"+            [ "RTL span" =: spanWith ("",[],[("dir", "rtl")]) (text "foo bar") =?> "<<<foo bar>>>"+            , "LTR span" =: spanWith ("",[],[("dir", "ltr")]) (text "foo bar") =?> ">>>foo bar<<<"+            , "RTL span with a class" =: spanWith ("",["foobar"],[("dir", "rtl")]) (text "foo bar") =?> "<class name=\"foobar\"><<<foo bar>>></class>"+            , "LTR span with a class" =: spanWith ("",["foobar"],[("dir", "ltr")]) (text "foo bar") =?> "<class name=\"foobar\">>>>foo bar<<<</class>"+            , "Escape <<< and >>>" =: plain (text "<<< foo bar >>>") =?> "<verbatim><<<</verbatim> foo bar <verbatim>>>></verbatim>"+            ]           , testGroup "combined"             [ "emph word before" =:                 para ("foo" <> emph "bar") =?>
test/Tests/Writers/Native.hs view
@@ -11,7 +11,7 @@  p_write_rt :: Pandoc -> Bool p_write_rt d =-  read (unpack $ purely (writeNative def{ writerTemplate = Just "" }) d) == d+  read (unpack $ purely (writeNative def{ writerTemplate = Just mempty }) d) == d  p_write_blocks_rt :: [Block] -> Bool p_write_blocks_rt bs =
test/Tests/Writers/Plain.hs view
@@ -13,7 +13,9 @@ infix 4 =: (=:) :: (ToString a, ToPandoc a)      => String -> (a, String) -> TestTree-(=:) = test (purely (writePlain def) . toPandoc)+(=:) = test (purely (writePlain def{ writerExtensions =+                          enableExtension Ext_gutenberg plainExtensions }) .+                      toPandoc)   tests :: [TestTree]
test/Tests/Writers/Powerpoint.hs view
@@ -6,6 +6,9 @@ import Text.Pandoc import Test.Tasty import System.FilePath+import Text.DocTemplates (ToContext(toVal), Context(..))+import qualified Data.Map as M+import Data.Text (pack)  -- templating is important enough, and can break enough things, that -- we want to run all our tests with both default formatting and a@@ -59,6 +62,10 @@                          def                          "pptx/lists.native"                          "pptx/lists.pptx"+                       , pptxTests "start ordered list at specified num"+                         def+                         "pptx/start_numbering_at.native"+                         "pptx/start_numbering_at.pptx"                        , pptxTests "tables"                          def                          "pptx/tables.native"@@ -115,4 +122,13 @@                          def                          "pptx/document-properties-short-desc.native"                          "pptx/document-properties-short-desc.pptx"+                       , pptxTests "inline code and code blocks"+                         def+                         "pptx/code.native"+                         "pptx/code.pptx"+                       , pptxTests "inline code and code blocks, custom formatting"+                         def { writerVariables = Context $ M.fromList+                                 [(pack "monofont", toVal $ pack "Consolas")] }+                         "pptx/code.native"+                         "pptx/code-custom.pptx"                        ]
test/Tests/Writers/RST.hs view
@@ -3,6 +3,7 @@ module Tests.Writers.RST (tests) where  import Prelude+import Control.Monad.Identity import Test.Tasty import Test.Tasty.HUnit import Tests.Helpers@@ -10,6 +11,7 @@ import Text.Pandoc.Arbitrary () import Text.Pandoc.Builder import Text.Pandoc.Writers.RST+import qualified Data.Text as T  infix 4 =: (=:) :: (ToString a, ToPandoc a)@@ -18,9 +20,16 @@  testTemplate :: (ToString a, ToString c, ToPandoc a) =>                 String -> String -> (a, c) -> TestTree-testTemplate t =-  test (purely (writeRST def{ writerTemplate = Just t }) . toPandoc)+testTemplate t = case runIdentity (compileTemplate [] (T.pack t)) of+    Left e -> error $ "Could not compile RST template: " ++ e+    Right templ -> test (purely (writeRST def{ writerTemplate = Just templ }) . toPandoc) +bodyTemplate :: Template T.Text+bodyTemplate = case runIdentity (compileTemplate [] "$body$\n") of+                    Left e      -> error $+                      "Could not compile RST bodyTemplate" ++ e+                    Right templ -> templ+ tests :: [TestTree] tests = [ testGroup "rubrics"           [ "in list item" =:@@ -96,6 +105,9 @@           , "keeps quotes" =:             strong (str "f" <> doubleQuoted (str "d") <> str "l") =?>             "**f“d”l**"+          , "backslash inserted between str and code" =:+            str "/api?query=" <> code "foo" =?>+            "/api?query=\\ ``foo``"           ]         , testGroup "headings"           [ "normal heading" =:@@ -104,7 +116,8 @@               [ "foo"               , "==="]           -- note: heading normalization is only done in standalone mode-          , test (purely (writeRST def{ writerTemplate = Just "$body$\n" }) . toPandoc)+          , test (purely (writeRST def{ writerTemplate = Just bodyTemplate })+                       . toPandoc)             "heading levels" $               header 1 (text "Header 1") <>               header 3 (text "Header 2") <>@@ -134,7 +147,7 @@               , ""               , "Header 2"               , "--------"]-          , test (purely (writeRST def{ writerTemplate = Just "$body$\n" }) . toPandoc)+          , test (purely (writeRST def{ writerTemplate = Just bodyTemplate }) . toPandoc)             "minimal heading levels" $               header 2 (text "Header 1") <>               header 3 (text "Header 2") <>
test/command/1710.md view
@@ -56,7 +56,6 @@ ^D \begin{frame}{Slide one} \protect\hypertarget{slide-one}{}- \begin{columns}[T] \begin{column}{0.4\textwidth} \begin{itemize}@@ -82,6 +81,5 @@ ok \end{column} \end{columns}- \end{frame} ```
+ test/command/1762.md view
@@ -0,0 +1,18 @@+```+% pandoc -t latex+# One {.unlisted}++# Two {.unnumbered}++# Three {.unlisted .unnumbered}+^D+\hypertarget{one}{%+\section{One}\label{one}}++\hypertarget{two}{%+\section*{Two}\label{two}}+\addcontentsline{toc}{section}{Two}++\hypertarget{three}{%+\section*{Three}\label{three}}+```
+ test/command/3324.md view
@@ -0,0 +1,18 @@+```+pandoc -t latex+Signatures++\+\+___________________________\+Peter Foobar\+*The Foo Company*+^D+Signatures++\hfill\break+\hfill\break+\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\\+Peter Foobar\\+\emph{The Foo Company}+```
+ test/command/3523.md view
@@ -0,0 +1,31 @@+```+% pandoc -f latex -t html +\documentclass{article}+\usepackage{epigraph}+\begin{document}++\epigraph{+    Das Recht hat kein Dasein f{\"u}r sich, sein Wesen vielmehr ist das Leben des Menschen selbst, von einer besonderen Seite angesehen. +    +    Das Recht hat kein Dasein f{\"u}r sich, sein Wesen vielmehr ist das Leben des Menschen selbst, von einer besonderen Seite angesehen.+    +    \begin{itemize}+        \item hey+        \item hey+        \item hey+    \end{itemize}+    +    }{ Friedrich Carl von Savigny }+\end{document}+^D+<div class="epigraph">+<p>Das Recht hat kein Dasein f<span>ü</span>r sich, sein Wesen vielmehr ist das Leben des Menschen selbst, von einer besonderen Seite angesehen.</p>+<p>Das Recht hat kein Dasein f<span>ü</span>r sich, sein Wesen vielmehr ist das Leben des Menschen selbst, von einer besonderen Seite angesehen.</p>+<ul>+<li><p>hey</p></li>+<li><p>hey</p></li>+<li><p>hey</p></li>+</ul>+<p>Friedrich Carl von Savigny</p>+</div>+```
test/command/3530.md view
@@ -14,9 +14,6 @@ \subfile{command/sub-file-chapter-1} \subfile{command/sub-file-chapter-2} ^D-[Header 1 ("chapter-1",[],[]) [Str "Chapter",Space,Str "1"]-,Para [Str "This",Space,Str "is",Space,Str "Chapter",Space,Str "1,",Space,Str "provided",Space,Str "in",Space,Str "a",Space,Str "sub",Space,Str "file."]-,Header 1 ("chapter-2",[],[]) [Str "Chapter",Space,Str "2"]-,Para [Str "This",Space,Str "is",Space,Str "Chapter",Space,Str "2,",Space,Str "provided",Space,Str "in",Space,Str "a",Space,Str "second",Space,Str "sub",Space,Str "file."]]-+[RawBlock (Format "latex") "\\subfile{command/sub-file-chapter-1}"+,RawBlock (Format "latex") "\\subfile{command/sub-file-chapter-2}"] ```
test/command/3531.md view
@@ -17,5 +17,4 @@ A paragraph can span multiple lines without being broken into pieces. - ```
test/command/3734.md view
@@ -4,27 +4,9 @@ |--------------|-------|--------------------------------------------------------------------------| | aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc | ^D-<table>-<colgroup>-<col style="width: 14%" />-<col style="width: 7%" />-<col style="width: 77%" />-</colgroup>-<thead>-<tr class="header">-<th>aaaaaaaaaaaa</th>-<th>bbbbb</th>-<th>ccccccccccc</th>-</tr>-</thead>-<tbody>-<tr class="odd">-<td>aaaaaaaaaaaa</td>-<td></td>-<td>cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</td>-</tr>-</tbody>-</table>+| aaaaaaaaaaaa | bbbbb | ccccccccccc                                                              |+|--------------|-------|--------------------------------------------------------------------------|+| aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc | ```  ```
test/command/3824.md view
@@ -10,5 +10,4 @@ </code>   * ok - ```
test/command/4016.md view
@@ -15,32 +15,28 @@ ^D \begin{frame}{Level 2 blocks} \protect\hypertarget{level-2-blocks}{}- \begin{columns}[T] \begin{column}{0.4\textwidth} \begin{block}{Block one}-+\protect\hypertarget{block-one}{} \begin{itemize} \tightlist \item   Item \end{itemize}- \end{block} \end{column}  \begin{column}{0.6\textwidth} \begin{block}{Block two}-+\protect\hypertarget{block-two}{} \begin{itemize} \tightlist \item   Item \end{itemize}- \end{block} \end{column} \end{columns}- \end{frame} ```
test/command/4164.md view
@@ -12,7 +12,7 @@  <div> -<balise> bla bla+`<balise>`{=html} bla bla  </div> 
+ test/command/4186.md view
@@ -0,0 +1,60 @@+```+% pandoc -f org -t native+#+BEGIN_EXAMPLE -i+    This should retain the four leading spaces+#+END_EXAMPLE+^D+[CodeBlock ("",["example"],[]) "    This should retain the four leading spaces\n"]+```++```+% pandoc -f org -t html+- depth 1+  #+NAME: bob+  #+BEGIN_EXAMPLE -i+    Vertical alignment is four spaces beyond the appearance of the word "depth".+  #+END_EXAMPLE+       - depth 2+         #+begin_example+                          Vertically aligned with the second appearance of the word "depth".+         #+end_example+              #+begin_example -i+    Vertical alignment is four spaces beyond the second+    appearance of the word "depth".+    The "begin" portion is a component of+    this deeper list element, so that guarantees+    that the entire block must be a component of the+    inner list element.+    #+end_example+         Still inside the inner list element+   #+NAME: carrie+                         #+BEGIN_EXAMPLE+                           This belongs to the outer list element, and is aligned accordingly, since the NAME attribute is not indented deeply enough. It is not enough for the BEGIN alone to be aligned deeply if the block is meant to have a NAME.+                           #+END_EXAMPLE+                 Still in the shallower list element since the preceding example+                 block forced the deeper list element to terminate.+Outside all lists.+^D+<ul>+<li><p>depth 1</p>+<pre id="bob" class="example"><code>    Vertical alignment is four spaces beyond the appearance of the word &quot;depth&quot;.+</code></pre>+<ul>+<li><p>depth 2</p>+<pre class="example"><code>Vertically aligned with the second appearance of the word &quot;depth&quot;.+</code></pre>+<pre class="example"><code>    Vertical alignment is four spaces beyond the second+    appearance of the word &quot;depth&quot;.+    The &quot;begin&quot; portion is a component of+    this deeper list element, so that guarantees+    that the entire block must be a component of the+    inner list element.+</code></pre>+<p>Still inside the inner list element</p></li>+</ul>+<pre id="carrie" class="example"><code>This belongs to the outer list element, and is aligned accordingly, since the NAME attribute is not indented deeply enough. It is not enough for the BEGIN alone to be aligned deeply if the block is meant to have a NAME.+</code></pre>+<p>Still in the shallower list element since the preceding example block forced the deeper list element to terminate.</p></li>+</ul>+<p>Outside all lists.</p>+```
test/command/4320.md view
@@ -1,15 +1,15 @@ ``` % pandoc -f native -t rst --wrap=none-[Table [] [AlignDefault,AlignDefault] [0.47368421052631576,0.5263157894736842]+[Table [] [AlignDefault,AlignDefault] [0.3,0.3]  [[Plain [Str "one"]]  ,[Plain [Str "two"]]]  [[[Plain [Str "ports"]]   ,[BlockQuote     [Para [Strong [Str "thisIsGoingToBeTooLongAnyway"]]]]]]] ^D-+-------+-------------------------------------+-| one   | two                                 |-+=======+=====================================+-| ports |    **thisIsGoingToBeTooLongAnyway** |-+-------+-------------------------------------+++--------------------+-------------------------------------++| one                | two                                 |++====================+=====================================++| ports              |    **thisIsGoingToBeTooLongAnyway** |++--------------------+-------------------------------------+ ```
+ test/command/4420.md view
@@ -0,0 +1,22 @@+```+% pandoc -f native -t rst+[Image ("",["align-right"],[("width","100px")]) [Str "image"] ("foo.png","")]+^D+|image|++.. |image| image:: foo.png+   :align: right+   :width: 100px+```++```+% pandoc -f native -t rst+[Para [Image ("",["align-right"],[("width","100px")]) [Str "image"] ("foo.png","fig:test")]]+^D+.. figure:: foo.png+   :alt: test+   :align: right+   :width: 100px++   image+```
+ test/command/4442.md view
@@ -0,0 +1,9 @@+```+% pandoc -f markdown -t latex+\newcommand{\myFruit}{Mango\xspace}+\myFruit is the king of fruits.+^D+\newcommand{\myFruit}{Mango\xspace}++Mango\xspace is the king of fruits.+```
+ test/command/4499.md view
@@ -0,0 +1,87 @@+```+% pandoc -f latex -t html+\mbox{abc def} ghi+^D+<p>abc def ghi</p>+```++```+% pandoc -f latex+raw_tex -t native+\mbox{abc def}+^D+[Para [RawInline (Format "latex") "\\mbox{abc def}"]]+```++```+% pandoc -f latex -t html+abc \mbox{\textit{def ghi} jkl} mno+^D+<p>abc <em>def ghi</em> jkl mno</p>+```++```+% pandoc -f latex -t html+abc \mbox{def \\ ghi} jkl+^D+<p>abc defghi jkl</p>+```++```+% pandoc -f latex -t html+abc \mbox{def+ghi}+^D+<p>abc def ghi</p>+```++```+% pandoc -f latex -t html+abc \mbox{def \textit{ghi \\ jkl}+mno} pqr+^D+<p>abc def <em>ghijkl</em> mno pqr</p>+```++```+% pandoc -f latex -t html+\hbox{abc def} ghi+^D+<p>abc def ghi</p>+```++```+% pandoc -f latex+raw_tex -t native+\hbox{abc def}+^D+[Para [RawInline (Format "latex") "\\hbox{abc def}"]]+```++```+% pandoc -f latex -t html+abc \hbox{\textit{def ghi} jkl} mno+^D+<p>abc <em>def ghi</em> jkl mno</p>+```++```+% pandoc -f latex -t html+abc \hbox{def \\ ghi} jkl+^D+<p>abc defghi jkl</p>+```++```+% pandoc -f latex -t html+abc \hbox{def+ghi}+^D+<p>abc def ghi</p>+```++```+% pandoc -f latex -t html+abc \hbox{def \textit{ghi \\ jkl}+mno} pqr+^D+<p>abc def <em>ghijkl</em> mno pqr</p>+```
test/command/4529.md view
@@ -1,5 +1,5 @@ ```-% pandoc -f latex -t plain+% pandoc -f latex -t plain+gutenberg \chapter{First chapter}\label{sec:chp1} The next chapter is Chapter~\ref{sec:chp2}. \section{First section}\label{sec:chp1sec1}
test/command/4669.md view
@@ -6,7 +6,7 @@   while (n > 0) { \end{verbatim} ^D-[Para [Span ("",[],[]) [Str "<-"]]+[Para [Span ("",[],[]) [Code ("",[],[]) "<-"]] ,CodeBlock ("",[],[]) "  while (n > 0) {"] ``` 
test/command/4690.md view
@@ -13,7 +13,6 @@ ^D \begin{frame}{title} \protect\hypertarget{title}{}- \begin{columns}[T] \begin{column}{0.08\textwidth} content@@ -23,6 +22,5 @@ content2 \end{column} \end{columns}- \end{frame} ```
test/command/4794.md view
@@ -14,5 +14,4 @@ | text |} - ```
test/command/4833.md view
@@ -1,7 +1,7 @@ ``` pandoc -f native -t rst [Div ("",["warning"],[])- [Div ("",["admonition-title"],[])+ [Div ("",["title"],[])   [Para [Str "Warning"]]  ,Para [Str "Hi"]]] ^D
+ test/command/4933.md view
@@ -0,0 +1,6 @@+```+% pandoc -f latex -t native+\includegraphics{lalune}+^D+[Para [Image ("",[],[]) [Str "image"] ("lalune.jpg","")]]+```
+ test/command/5107.md view
@@ -0,0 +1,23 @@+```+% pandoc -f muse -t dokuwiki+ - foo+   1. bar+   - baz+^D+  * foo+    - bar+    * baz++```+```+% pandoc -f muse -t dokuwiki+ - foo+   1. bar+   2. baz+^D+  * foo+    - bar+    - baz++```+
test/command/5128.md view
@@ -1,5 +1,5 @@ ```-pandoc -f org -t rst+pandoc -f org -t rst --columns=78 | Option | Meaning                                                                                                                                                                                                    | |--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | =<=    | Left alignment, additional characters are added to the right (default for string).                                                                                                                         |@@ -7,12 +7,20 @@ | =^=     | Centered , the same amount of characters is added to the left and the right.                                                                                                                               | | ===      | Padding. If a numeric value is printed with a sign, then additional characters are added after the sign. Otherwise it behaves like "=>=". This option is only available for numbers (default for numbers). | ^D-====== ============================================================================================================================================================================================================-Option Meaning-====== ============================================================================================================================================================================================================-``<``  Left alignment, additional characters are added to the right (default for string).-``>``  Right alignment, additional characters are added to the left.-``^``  Centered , the same amount of characters is added to the left and the right.-``=``  Padding. If a numeric value is printed with a sign, then additional characters are added after the sign. Otherwise it behaves like "``>``". This option is only available for numbers (default for numbers).-====== ============================================================================================================================================================================================================++--------+------------------------------------------------------------------++| Option | Meaning                                                          |++========+==================================================================++| ``<``  | Left alignment, additional characters are added to the right     |+|        | (default for string).                                            |++--------+------------------------------------------------------------------++| ``>``  | Right alignment, additional characters are added to the left.    |++--------+------------------------------------------------------------------++| ``^``  | Centered , the same amount of characters is added to the left    |+|        | and the right.                                                   |++--------+------------------------------------------------------------------++| ``=``  | Padding. If a numeric value is printed with a sign, then         |+|        | additional characters are added after the sign. Otherwise it     |+|        | behaves like "``>``". This option is only available for numbers  |+|        | (default for numbers).                                           |++--------+------------------------------------------------------------------+ ```
+ test/command/5410.md view
@@ -0,0 +1,7 @@+```+% pandoc -f man -t native+.ie n \{\+'br\}+^D+[Para [LineBreak]]+```
+ test/command/5474-figures.md view
@@ -0,0 +1,15 @@+```+% pandoc -t opendocument+native_numbering++![First image](lalune.jpg)++![Second image](lalune.jpg)++^D+<text:p text:style-name="FigureWithCaption"><draw:frame draw:name="img1"><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p>+<text:p text:style-name="FigureCaption">Figure <text:sequence text:ref-name="refIllustration0" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">1</text:sequence>: First+image</text:p>+<text:p text:style-name="FigureWithCaption"><draw:frame draw:name="img2"><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p>+<text:p text:style-name="FigureCaption">Figure <text:sequence text:ref-name="refIllustration1" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">2</text:sequence>: Second+image</text:p>+```
+ test/command/5474-tables.md view
@@ -0,0 +1,63 @@+```+% pandoc -t opendocument+native_numbering+  Right     Left  +-------     ------+     12     11++: First table++  Right     Left  +-------     ------+     13     14    ++: Second Table+^D+<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable0" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">1</text:sequence>: First+table</text:p>+<table:table table:name="Table1" table:style-name="Table1">+  <table:table-column table:style-name="Table1.A" />+  <table:table-column table:style-name="Table1.B" />+  <table:table-header-rows>+    <table:table-row>+      <table:table-cell table:style-name="TableHeaderRowCell" office:value-type="string">+        <text:p text:style-name="P1">Right</text:p>+      </table:table-cell>+      <table:table-cell table:style-name="TableHeaderRowCell" office:value-type="string">+        <text:p text:style-name="Table_20_Heading">Left</text:p>+      </table:table-cell>+    </table:table-row>+  </table:table-header-rows>+  <table:table-row>+    <table:table-cell table:style-name="TableRowCell" office:value-type="string">+      <text:p text:style-name="P2">12</text:p>+    </table:table-cell>+    <table:table-cell table:style-name="TableRowCell" office:value-type="string">+      <text:p text:style-name="Table_20_Contents">11</text:p>+    </table:table-cell>+  </table:table-row>+</table:table>+<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable1" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">2</text:sequence>: Second+Table</text:p>+<table:table table:name="Table2" table:style-name="Table2">+  <table:table-column table:style-name="Table2.A" />+  <table:table-column table:style-name="Table2.B" />+  <table:table-header-rows>+    <table:table-row>+      <table:table-cell table:style-name="TableHeaderRowCell" office:value-type="string">+        <text:p text:style-name="P3">Right</text:p>+      </table:table-cell>+      <table:table-cell table:style-name="TableHeaderRowCell" office:value-type="string">+        <text:p text:style-name="Table_20_Heading">Left</text:p>+      </table:table-cell>+    </table:table-row>+  </table:table-header-rows>+  <table:table-row>+    <table:table-cell table:style-name="TableRowCell" office:value-type="string">+      <text:p text:style-name="P4">13</text:p>+    </table:table-cell>+    <table:table-cell table:style-name="TableRowCell" office:value-type="string">+      <text:p text:style-name="Table_20_Contents">14</text:p>+    </table:table-cell>+  </table:table-row>+</table:table>+```
+ test/command/5619.md view
@@ -0,0 +1,10 @@+```+% pandoc -f rst -t native+.. figure:: img1.jpg+  :width: 1in+  :name: test++  The caption. Here's what piggybacking on caption would look like {#fig:1}+^D+[Para [Image ("test",[],[("width","1in")]) [Str "The",Space,Str "caption.",Space,Str "Here's",Space,Str "what",Space,Str "piggybacking",Space,Str "on",Space,Str "caption",Space,Str "would",Space,Str "look",Space,Str "like",Space,Str "{#fig:1}"] ("img1.jpg","fig:")]]+```
+ test/command/5620.md view
@@ -0,0 +1,9 @@+```+% pandoc -t man+`-o`, `--output=`*OUTFILE*+:   Write output to *OUTFILE* instead of `stdout`(3)+^D+.TP+\f[B]\f[CB]-o\f[B]\f[R], \f[B]\f[CB]--output=\f[B]\f[R]\f[I]OUTFILE\f[R]+Write output to \f[I]OUTFILE\f[R] instead of \f[C]stdout\f[R](3)+```
+ test/command/5627.md view
@@ -0,0 +1,83 @@+```+% pandoc -t html+## Example++1. One+2. Two `-->something<!--`+3. Three++~~~html+--><!--<script>alert('Escaped!')</script>+~~~++~~~html+Something+~~~+^D+<h2 id="example">Example</h2>+<ol type="1">+<li>One</li>+<li>Two <code>--&gt;something&lt;!--</code></li>+<li>Three</li>+</ol>+<div class="sourceCode" id="cb1"><pre class="sourceCode html"><code class="sourceCode html"><span id="cb1-1"><a href="#cb1-1"></a>--&gt;<span class="co">&lt;!--&lt;script&gt;alert(&#39;Escaped!&#39;)&lt;/script&gt;</span></span></code></pre></div>+<div class="sourceCode" id="cb2"><pre class="sourceCode html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1"></a>Something</span></code></pre></div>+```++```+% pandoc -t html+## Example 2++- `-->something<!--`+- `-->something<!--`+- bye `-->something else<!--`++~~~html+--><!--<script>alert('Escaped!')</script>+~~~++~~~html+Something+~~~+^D+<h2 id="example-2">Example 2</h2>+<ul>+<li><code>--&gt;something&lt;!--</code></li>+<li><code>--&gt;something&lt;!--</code></li>+<li>bye <code>--&gt;something else&lt;!--</code></li>+</ul>+<div class="sourceCode" id="cb1"><pre class="sourceCode html"><code class="sourceCode html"><span id="cb1-1"><a href="#cb1-1"></a>--&gt;<span class="co">&lt;!--&lt;script&gt;alert(&#39;Escaped!&#39;)&lt;/script&gt;</span></span></code></pre></div>+<div class="sourceCode" id="cb2"><pre class="sourceCode html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1"></a>Something</span></code></pre></div>+```++```+% pandoc -t html+## Example 3++1. `-->one<!--`+5. bye `-->two <!--`+3. ` three, not in block+1. four, not in block  `+2. five+5. six+6. seven `+-  separate unordered list `+42. forty-two, separate ordered list+^D+<h2 id="example-3">Example 3</h2>+<ol type="1">+<li><code>--&gt;one&lt;!--</code></li>+<li>bye <code>--&gt;two &lt;!--</code></li>+<li>` three, not in block</li>+<li>four, not in block `</li>+<li>five</li>+<li>six</li>+<li>seven `</li>+</ol>+<ul>+<li>separate unordered list `</li>+</ul>+<ol start="42" type="1">+<li>forty-two, separate ordered list</li>+</ol>+```
+ test/command/5635.md view
@@ -0,0 +1,23 @@+```+% pandoc -f latex -t plain+\providecommand{\test}{foo}+\providecommand{\test}{bar}++The value is: \test+^D+The value is: foo+```++```+% pandoc -f latex -t plain+\provideenvironment{test}{startfoo}{stopfoo}+\provideenvironment{test}{startbar}{stopbar}++\begin{test}+Hi+\end{test}+^D+startfoo Hi stopfoo+```++
+ test/command/5642.md view
@@ -0,0 +1,8 @@+```+% pandoc -t html5 -f markdown+![test](foo){aria-describedby="barbaz"}+^D+<figure>+<img src="foo" aria-describedby="barbaz" alt="" /><figcaption>test</figcaption>+</figure>+```
+ test/command/5650.md view
@@ -0,0 +1,22 @@+````+% pandoc --id-prefix foo+```haskell+a+b+```+^D+<div class="sourceCode" id="foocb1"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="foocb1-1"><a href="#foocb1-1"></a>a</span>+<span id="foocb1-2"><a href="#foocb1-2"></a>b</span></code></pre></div>+````++````+% pandoc --id-prefix foo+``` {.haskell #bar}+a+b+```+^D+<div class="sourceCode" id="foobar"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="foobar-1"><a href="#foobar-1"></a>a</span>+<span id="foobar-2"><a href="#foobar-2"></a>b</span></code></pre></div>+````+
+ test/command/5654.md view
@@ -0,0 +1,6 @@+```+% pandoc -f latex -t markdown+This is {\tt monospaced too} done.+^D+This is `monospaced too` done.+```
+ test/command/5655.md view
@@ -0,0 +1,14 @@+````+% pandoc --webtex+$T_n={n+1 \choose 2}$+^D+<p><img style="vertical-align:middle" src="https://latex.codecogs.com/png.latex?%5Ctextstyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D" alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" /></p>+````++````+% pandoc --webtex+$$T_n={n+1 \choose 2}$$+^D+<p><br /><img style="vertical-align:middle" src="https://latex.codecogs.com/png.latex?%5Cdisplaystyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D" alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" /><br /></p>+````+
+ test/command/5682.md view
@@ -0,0 +1,8 @@+```+% pandoc -t native -f latex+\newcommand{\ittakestwo}[2][defaultone]{#2}+\ittakestwo[to]{tango}+^D+[Para [Str "tango"]]+```+
+ test/command/5684.md view
@@ -0,0 +1,6 @@+```+% pandoc -f native -t latex+[Str "\8222\8218Der",Space,Str "Erz\228hler.",Space,Str "Betrachtungen",Space,Str "zum",Space,Str "Werk",Space,Str "Nikolai",Space,Str "Lesskows\8216\8220."]+^D+„‚Der Erzähler. Betrachtungen zum Werk Nikolai Lesskows`\,``.+```
+ test/command/5686.md view
@@ -0,0 +1,9 @@+```+% pandoc -t native+FOO\t0BAR++This part does not make it to the html output.+^D+[Para [Str "FOO",RawInline (Format "tex") "\\t0BAR"]+,Para [Str "This",Space,Str "part",Space,Str "does",Space,Str "not",Space,Str "make",Space,Str "it",Space,Str "to",Space,Str "the",Space,Str "html",Space,Str "output."]]+```
+ test/command/5690.md view
@@ -0,0 +1,16 @@+```+% pandoc -f docbook -t asciidoc+<warning>+<title>My warning!</title>+<para>A warning.</para>+<para>Another paragraph.</para>+</warning>+^D+[WARNING]+.My warning!+====+A warning.++Another paragraph.+====+```
+ test/command/5700-metadata-file-1.yml view
@@ -0,0 +1,1 @@+title: This title should be overridden by 5700-metadta-file-2.yml
+ test/command/5700-metadata-file-2.yml view
@@ -0,0 +1,2 @@+title: Multiple metadata files test+desc: Both of these files should be loaded.
+ test/command/5700.md view
@@ -0,0 +1,6 @@+```+% pandoc -t native -s --metadata-file command/5700-metadata-file-1.yml --metadata-file command/5700-metadata-file-2.yml+^D+Pandoc (Meta {unMeta = fromList [("desc",MetaInlines [Str "Both",Space,Str "of",Space,Str "these",Space,Str "files",Space,Str "should",Space,Str "be",Space,Str "loaded."]),("title",MetaInlines [Str "Multiple",Space,Str "metadata",Space,Str "files",Space,Str "test"])]})+[]+```
+ test/command/5705.md view
@@ -0,0 +1,11 @@+```+% pandoc -f native -t markdown+[OrderedList (8,UpperRoman,Period)+ [[Plain [Str "Blah"]+  ,BulletList+   [[Plain [Str "Blah"]]]]]]+^D+VIII. Blah+      -   Blah+```+
+ test/command/5708.md view
@@ -0,0 +1,12 @@+```+% pandoc -f rst -t native++--------+----------------++| 123456 | :math:`a + b`  |++--------+----------------++^D+[Table [] [AlignDefault,AlignDefault] [0.125,0.2361111111111111]+ [[]+ ,[]]+ [[[Plain [Str "123456"]]+  ,[Plain [Math InlineMath "a + b"]]]]]+```
+ test/command/5711.md view
@@ -0,0 +1,13 @@+```+% pandoc -t native -f latex+\documentclass{article}+\begin{document}+\begin{tabular}{c}+\parbox{2cm}{d\\e}+\end{tabular}+\end{document}+^D+[Table [] [AlignCenter] [0.0]+ [[]]+ [[[Plain [Str "d",LineBreak,Str "e"]]]]]+```
+ test/command/5714.md view
@@ -0,0 +1,13 @@+```+% pandoc -t native+# hi _a+b_++# hi _c+c+^D+[Header 1 ("hi-_a",[],[]) [Str "hi",Space,Str "_a"]+,Para [Str "b_"]+,Header 1 ("hi-_c",[],[]) [Str "hi",Space,Str "_c"]+,Para [Str "c"]]+```
+ test/command/5740.md view
@@ -0,0 +1,9 @@+```+% pandoc -t latex+\newcommand\parenthesize[1][x]{(#1)}+$\parenthesize$, $\parenthesize[y]$, $\parenthesize[\textsc{head}]$+^D+\newcommand\parenthesize[1][x]{(#1)}++\((x)\), \((y)\), \((\textsc{head})\)+```
+ test/command/5753.md view
@@ -0,0 +1,15 @@+```+% pandoc -f rst -t native+.. math::++    q_3+   + 4++  - 5 ++    q_5++end+^D+[Para [Math DisplayMath "q_3\n+ 4",Math DisplayMath "- 5 +\nq_5"]+,Para [Str "end"]]+```
+ test/command/5795.md view
@@ -0,0 +1,20 @@+```+% pandoc -f html -t html+<dfn class="dfn" id="foo" title="bax"><span>foo</span></dfn>+^D+<dfn id="foo" class="dfn" title="bax"><span>foo</span></dfn>+```++```+% pandoc -f html -t native+<dfn class="dfn" id="foo" title="bax"><span>foo</span></dfn>+^D+[Plain [Span ("foo",["dfn","dfn"],[("title","bax")]) [Span ("",[],[]) [Str "foo"]]]]+```++```+% pandoc -f native -t html+[Plain [Span ("foo",["dfn","dfn"],[("title","bax")]) [Span ("",[],[]) [Str "foo"]]]]+^D+<dfn id="foo" class="dfn" title="bax"><span>foo</span></dfn>+```
+ test/command/5797.md view
@@ -0,0 +1,20 @@+```+% pandoc -f html -t html+<mark>Ctrl-C</mark>+^D+<mark>Ctrl-C</mark>+```++```+% pandoc -f html -t native+<mark>Ctrl-C</mark>+^D+[Plain [Span ("",["mark"],[]) [Str "Ctrl-C"]]]+```++```+% pandoc -f native -t html+[Plain [Span ("",["mark"],[]) [Str "Ctrl-C"]]]+^D+<mark>Ctrl-C</mark>+```
+ test/command/5805.md view
@@ -0,0 +1,20 @@+```+% pandoc -f html -t html+<kbd>Ctrl-C</kbd>+^D+<kbd>Ctrl-C</kbd>+```++```+% pandoc -f html -t native+<kbd>Ctrl-C</kbd>+^D+[Plain [Span ("",["kbd"],[]) [Str "Ctrl-C"]]]+```++```+% pandoc -f native -t html+[Plain [Span ("",["kbd"],[]) [Str "Ctrl-C"]]]+^D+<kbd>Ctrl-C</kbd>+```
+ test/command/5813.md view
@@ -0,0 +1,6 @@+```+% pandoc -f gfm+### Jekyll Plugins & Gems :gem:+^D+<h3 id="jekyll-plugins--gems-gem">Jekyll Plugins &amp; Gems <span class="emoji" data-emoji="gem">💎</span></h3>+```
+ test/command/5836.md view
@@ -0,0 +1,27 @@+```+% pandoc -f markdown -t latex+\newcommand{\vara}{\alpha}+\newcommand{\varb}{b}+$\vara \varb$+^D+\newcommand{\vara}{\alpha}+\newcommand{\varb}{b}++\(\alpha b\)+```+```+% pandoc -f latex -t latex+\newcommand{\vara}{\alpha}+\newcommand{\varb}{b}+$\vara \varb$+^D+\(\alpha b\)+```+```+% pandoc -f latex -t latex+\newcommand{\vara}{\alpha}+\newcommand{\varb}{b}+\[\vara \varb\]+^D+\[\alpha b\]+```
+ test/command/5845.md view
@@ -0,0 +1,16 @@+```+% pandoc -t native+\parbox{1em}{#1}+^D+[Para [Str "\\parbox{1em}{#1}"]]+```++```+% pandoc -t native+\newcommand{\highlight}[1]{\colorbox{yellow}{\parbox{\dimexpr\linewidth-2\fboxsep}{#1}}++Hello World+^D+[Para [Str "\\newcommand{",RawInline (Format "tex") "\\highlight",Str "}[1]{\\colorbox{yellow}{\\parbox{",RawInline (Format "tex") "\\dimexpr",RawInline (Format "tex") "\\linewidth-2",RawInline (Format "tex") "\\fboxsep",Str "}{#1}}"]+,Para [Str "Hello",Space,Str "World"]]+```
+ test/command/5846.md view
@@ -0,0 +1,170 @@+```+% pandoc --section-divs+::: {.mydiv}+# header 1a++one++# header 1b++two+:::+^D+<div class="mydiv">+<section id="header-1a" class="level1">+<h1>header 1a</h1>+<p>one</p>+</section>+<section id="header-1b" class="level1">+<h1>header 1b</h1>+<p>two</p>+</section>+</div>+```++```+% pandoc --section-divs+::: mydiv+# head 1+## head 1.1+# head 2+:::++## head 2.1+^D+<div class="mydiv">+<section id="head-1" class="level1">+<h1>head 1</h1>+<section id="head-1.1" class="level2">+<h2>head 1.1</h2>+</section>+</section>+<section id="head-2" class="level1">+<h1>head 2</h1>+</section>+</div>+<section id="head-2.1" class="level2">+<h2>head 2.1</h2>+</section>+```++```+% pandoc --section-divs+# One+## One A+::: fence+## One B+# Two+:::+^D+<section id="one" class="level1">+<h1>One</h1>+<section id="one-a" class="level2">+<h2>One A</h2>+</section>+<div class="fence">+<section id="one-b" class="level2">+<h2>One B</h2>+</section>+<section id="two" class="level1">+<h1>Two</h1>+</section>+</div>+</section>+```++```+% pandoc --section-divs+# Beginning++::: exterior++At first...++:::++In the beginning...++::: interior++# Middle++So it continued...++:::++# Ending++::: exterior++And finally...++:::+^D+<section id="beginning" class="level1">+<h1>Beginning</h1>+<div class="exterior">+<p>At first…</p>+</div>+<p>In the beginning…</p>+</section>+<section id="middle" class="level1 interior">+<h1>Middle</h1>+<p>So it continued…</p>+</section>+<section id="ending" class="level1">+<h1>Ending</h1>+<div class="exterior">+<p>And finally…</p>+</div>+</section>+```++```+% pandoc --section-divs+::: part+# One+# Two+:::+::: part+# Three+# Four+# Five+:::+::: part+# Six+# Seven+# Eight+:::+^D+<div class="part">+<section id="one" class="level1">+<h1>One</h1>+</section>+<section id="two" class="level1">+<h1>Two</h1>+</section>+</div>+<div class="part">+<section id="three" class="level1">+<h1>Three</h1>+</section>+<section id="four" class="level1">+<h1>Four</h1>+</section>+<section id="five" class="level1">+<h1>Five</h1>+</section>+</div>+<div class="part">+<section id="six" class="level1">+<h1>Six</h1>+</section>+<section id="seven" class="level1">+<h1>Seven</h1>+</section>+<section id="eight" class="level1">+<h1>Eight</h1>+</section>+</div>+```
+ test/command/5857.md view
@@ -0,0 +1,11 @@+```+% pandoc -f native -t markdown+[BulletList+ [[Plain [Str "a"]]+ ,[]+ ,[Plain [Str "b"]]]]+^D+-   a+-   +-   b+```
+ test/command/5878.md view
@@ -0,0 +1,7 @@+```+% pandoc -t native+Zozime^[],+Synésius^[]+^D+[Para [Str "Zozime",Note [Para []],Str ",",SoftBreak,Str "Syn\233sius",Note [Para []]]]+```
+ test/command/5881.md view
@@ -0,0 +1,14 @@+```+% pandoc -t markdown -s -H command/D.txt -d command/defaults1.yaml -d command/defaults2.yaml+Ok+^D+here's d++this is a++here is b++and this is c++Ok+```
+ test/command/5885.md view
@@ -0,0 +1,20 @@+```+% pandoc -f docbook -t latex+<equation>+  <mathphrase>+    J(x, y) = \left\{ \begin{array}{ll}+    0 &amp; \text{if $I(x, y) &lt; t$} \\+    1 &amp; \text{if $I(x, y) \ge t$}+    \end{array}+    \right.+  </mathphrase>+</equation>+^D+\[+    J(x, y) = \left\{ \begin{array}{ll}+    0 & \text{if $I(x, y) < t$} \\+    1 & \text{if $I(x, y) \ge t$}+    \end{array}+    \right.+  \]+```
+ test/command/5898.md view
@@ -0,0 +1,36 @@+```+% pandoc -f html -t rst+<html>+  <body>+    <ul>+      <li>A list of stuff with a table inside+	<table>+	  <thead>+	    <tr>+	      <th>First</th><th>Second</th><th>Third</th>+	    </tr>+	  </thead>+	  <tbody>+	    <tr>+	      <td>First</td>+	      <td>Second</td>+	      <td>Third</td>+	    </tr>+	  </tbody>+	</table>+      </li>+      <li>Another list item</li>+    </ul>+  </body>+</html>+^D+-  A list of stuff with a table inside++   ===== ====== =====+   First Second Third+   ===== ====== =====+   First Second Third+   ===== ====== =====++-  Another list item+```
+ test/command/5899.md view
@@ -0,0 +1,51 @@+```+% pandoc -f html -t rst+<html>+  <body>+    <ul>+      <li>A list of stuff with a table inside+        <table>+          <thead>+            <tr>+              <th>First</th><th>Second</th><th>Third</th>+            </tr>+          </thead>+          <tbody>+            <tr>+              <td>First</td>+              <td>+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+                The big long table cell.+              </td>+              <td>Third</td>+            </tr>+          </tbody>+        </table>+      </li>+      <li>Another list item</li>+    </ul>+  </body>+</html>+^D+-  A list of stuff with a table inside++   +-------+----------------------------------------------------+-------++   | First | Second                                             | Third |+   +=======+====================================================+=======++   | First | The big long table cell. The big long table cell.  | Third |+   |       | The big long table cell. The big long table cell.  |       |+   |       | The big long table cell. The big long table cell.  |       |+   |       | The big long table cell. The big long table cell.  |       |+   |       | The big long table cell. The big long table cell.  |       |+   +-------+----------------------------------------------------+-------+++-  Another list item+ ```
+ test/command/5904.md view
@@ -0,0 +1,10 @@+```+%  pandoc -s -t markdown -H command/B.txt --variable header-includes:foo+Hi+^D+foo++here is b++Hi+```
+ test/command/5918.md view
@@ -0,0 +1,6 @@+```+% pandoc -t markdown -f latex+1. \textsc{excessive}+^D+1\. [excessive]{.smallcaps}+```
+ test/command/A.txt view
@@ -0,0 +1,1 @@+this is a
+ test/command/B.txt view
@@ -0,0 +1,1 @@+here is b
+ test/command/C.txt view
@@ -0,0 +1,1 @@+and this is c
+ test/command/D.txt view
@@ -0,0 +1,1 @@+here's d
test/command/ascii.md view
@@ -2,7 +2,7 @@ pandoc -t html --ascii äéıå ^D-<p>&auml;&eacute;&imath;&aring;</p>+<p>&#xE4;&#xE9;&#x131;&#xE5;</p> ```  ```@@ -33,7 +33,7 @@ äéıå ^D <para>-  &#228;&#233;&#305;&#229;+  &#xE4;&#xE9;&#x131;&#xE5; </para> ``` @@ -41,7 +41,7 @@ pandoc -t jats --ascii äéıå ^D-<p>&#228;&#233;&#305;&#229;</p>+<p>&#xE4;&#xE9;&#x131;&#xE5;</p> ```  ```
+ test/command/defaults1.yaml view
@@ -0,0 +1,1 @@+include-in-header: command/A.txt
+ test/command/defaults2.yaml view
@@ -0,0 +1,4 @@+include-in-header:+- command/B.txt+- command/C.txt+
test/command/empty_paragraphs.md view
@@ -37,8 +37,6 @@ [Para [Str "hi"], Para [], Para [], Para [Str "lo"]] ^D <p>hi</p>-- <p>lo</p> ``` 
test/command/lua-pandoc-state.md view
@@ -2,7 +2,7 @@ % pandoc --lua-filter=command/lua-pandoc-state.lua --data-dir=foo Hello ^D-   # input files: 0+   # input files: 1      output file: nil # request header: 0    resource path: .
+ test/command/macro-defs-in-preamble.md view
@@ -0,0 +1,16 @@+```+% pandoc -s -f latex-latex_macros -t native+\documentclass[11pt]{article}++\newcommand{\vara}{\alpha}+\newcommand{\varb}{b}++\begin{document}+$\vara \varb$+\end{document}+^D+Pandoc (Meta {unMeta = fromList []})+[RawBlock (Format "latex") "\\newcommand{\\vara}{\\alpha}"+,RawBlock (Format "latex") "\\newcommand{\\varb}{b}"+,Para [Math InlineMath "\\vara \\varb"]]+```
test/command/macros.md view
@@ -1,5 +1,5 @@ ```-% pandoc -f markdown+latex_macros -t markdown+% pandoc -f markdown+latex_macros -t markdown+raw_tex-raw_attribute \newcommand{\my}{\phi} $\my+\my$ ^D@@ -9,7 +9,7 @@ ```  ```-% pandoc -f markdown-latex_macros -t markdown+% pandoc -f markdown-latex_macros -t markdown+raw_tex-raw_attribute \newcommand{\my}{\phi} $\my+\my$ ^D@@ -70,7 +70,7 @@ ```  ```-% pandoc -f markdown+latex_macros -t markdown+% pandoc -f markdown+latex_macros -t markdown+raw_tex-raw_attribute \newcommand{\my}{\phi} \begin{equation} \my+\my@@ -84,7 +84,7 @@ ```  ```-% pandoc -f markdown-latex_macros -t markdown+% pandoc -f markdown-latex_macros -t markdown+raw_tex-raw_attribute \newcommand{\my}{\phi} \begin{equation} \my+\my@@ -98,7 +98,7 @@ ```  ```-% pandoc -f markdown+latex_macros -t markdown+% pandoc -f markdown+latex_macros -t markdown+raw_tex-raw_attribute \newcommand{\my}{\emph{a}} \my ^D
test/command/multiple-metadata-blocks.md view
@@ -10,6 +10,6 @@ foo: bim ... ^D-Pandoc (Meta {unMeta = fromList [("foo",MetaInlines [Str "bar"])]})+Pandoc (Meta {unMeta = fromList [("foo",MetaInlines [Str "bim"])]}) [] ```
test/command/parse-raw.md view
@@ -2,7 +2,7 @@ % pandoc -f latex+raw_tex -t markdown \emph{Hi \foo{there}} ^D-*Hi \foo{there}*+*Hi `\foo{there}`{=latex}* ```  ```@@ -16,7 +16,7 @@ % pandoc -f html+raw_html -t markdown <em>Hi <blink>there</blink></em> ^D-*Hi <blink>there</blink>*+*Hi `<blink>`{=html}there`</blink>`{=html}* ```  ```
+ test/command/shift-heading-level-by.md view
@@ -0,0 +1,33 @@+```+% pandoc --shift-heading-level-by 1 -t native -s+---+title: My title+...++# First heading++## Second+^D+Pandoc (Meta {unMeta = fromList []})+[Header 1 ("",[],[]) [Str "My",Space,Str "title"]+,Header 2 ("first-heading",[],[]) [Str "First",Space,Str "heading"]+,Header 3 ("second",[],[]) [Str "Second"]]+```++```+% pandoc --shift-heading-level-by -1 -t native -s+---+title: Old title+...++# First heading++## Second++# Another top-level heading+^D+Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "First",Space,Str "heading"])]})+[Header 1 ("second",[],[]) [Str "Second"]+,Para [Str "Another",Space,Str "top-level",Space,Str "heading"]]+```+
+ test/docbook-chapter.docbook view
@@ -0,0 +1,30 @@+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"+          "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">+<!-- This matches the example from+https://tdg.docbook.org/tdg/4.5/section.html, sans sectioninfo and subtitle, as+they're currently not supported -->+<chapter><title>Test Chapter</title>+<para>This chapter uses recursive sections.</para>+<section>+<title>Like a Sect1</title>+<para>This section is like a Sect1.</para>+<section><title>Like a Sect2</title>+<para>This section is like a Sect2.</para>+<section><title>Like a Sect3</title>+<para>This section is like a Sect3.</para>+<section><title>Like a Sect4</title>+<para>This section is like a Sect4.</para>+<section><title>Like a Sect5</title>+<para>This section is like a Sect5.</para>+<section><title>Would be like a Sect6</title>+<para>This section would be like a Sect6, if there was one.</para>+<section><title>Would be like a Sect7</title>+<para>This section would be like a Sect7, if there was one.</para>+</section>+</section>+</section>+</section>+</section>+</section>+</section>+</chapter>
+ test/docbook-chapter.native view
@@ -0,0 +1,17 @@+Pandoc (Meta {unMeta = fromList []})+[Header 1 ("",[],[]) [Str "Test",Space,Str "Chapter"]+,Para [Str "This",Space,Str "chapter",Space,Str "uses",Space,Str "recursive",Space,Str "sections."]+,Header 2 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect1"]+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect1."]+,Header 3 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect2"]+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect2."]+,Header 4 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect3"]+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect3."]+,Header 5 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect4"]+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect4."]+,Header 6 ("",[],[]) [Str "Like",Space,Str "a",Space,Str "Sect5"]+,Para [Str "This",Space,Str "section",Space,Str "is",Space,Str "like",Space,Str "a",Space,Str "Sect5."]+,Header 7 ("",[],[]) [Str "Would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect6"]+,Para [Str "This",Space,Str "section",Space,Str "would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect6,",Space,Str "if",Space,Str "there",Space,Str "was",Space,Str "one."]+,Header 8 ("",[],[]) [Str "Would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect7"]+,Para [Str "This",Space,Str "section",Space,Str "would",Space,Str "be",Space,Str "like",Space,Str "a",Space,Str "Sect7,",Space,Str "if",Space,Str "there",Space,Str "was",Space,Str "one."]]
test/docx/0_level_headers.native view
@@ -15,10 +15,10 @@ ,Para [Str "FIGURES",Space,Str "iv"] ,Para [Str "TABLES",Space,Str "v"] ,Para [Str "SECTION",Space,Str "1",Space,Str "Introduction",Space,Str "2"]-,Header 1 ("figures",["Heading0"],[]) [Str "FIGURES"]+,Header 1 ("figures",["Heading-0"],[]) [Str "FIGURES"] ,Para [Strong [Str "Figure",Space,Str "Page"]] ,Para [Strong [Str "No",Space,Str "table",Space,Str "of",Space,Str "figures",Space,Str "entries",Space,Str "found."]]-,Header 1 ("tables",["Heading0"],[]) [Str "TABLES"]+,Header 1 ("tables",["Heading-0"],[]) [Str "TABLES"] ,Para [Strong [Str "Table",Space,Str "Page"]] ,Para [Strong [Str "No",Space,Str "table",Space,Str "of",Space,Str "figures",Space,Str "entries",Space,Str "found."]] ,Header 1 ("introduction",[],[]) [Str "Introduction"]
test/docx/adjacent_codeblocks.docx view

binary file changed (22437 → 22264 bytes)

+ test/docx/compact-style-removal.docx view

binary file changed (absent → 9951 bytes)

+ test/docx/compact-style-removal.native view
@@ -0,0 +1,5 @@+[OrderedList (1,Decimal,Period)+ [[Plain [Str "One"]]+ ,[Plain [Str "Two"]]+ ,[Plain [Str "Three"]]+ ,[Plain [Str "Four"]]]]
+ test/docx/custom-style-preserve.native view
@@ -0,0 +1,15 @@+[Para [Span ("",[],[("custom-style","MyStyle")]) [Str "This",Space,Str "span",Note [Para [Str "Neither",Space,Str "footnote",Space,Str "nor",Space,Str "footnote",Space,Str "reference",Space,Str "should",Space,Str "get",Space,Str "a",Space,Str "custom",Space,Str "style",Space,Str "from",Space,Str "its",Space,Str "span."]],Space,Str "should",Space,Str "have",Space,Str "a",Space,Str "custom",Space,Str "style",Space,Str "(",Link ("",[],[]) [Str "link"] ("http://example.com/",""),Str "),"],Space,Str "but",Space,Str "the",Space,Str "text",Space,Str "after",Space,Str "the",Space,Str "comma",Space,Str "shouldn\8217t,",Space,Str "nor",Space,Str "should",Space,Str "the",Space,Str "link."]+,Div ("",[],[("custom-style","MyOtherStyle")])+ [Para [Str "The",Space,Str "contents",Space,Str "of",Space,Str "this",Space,Str "div",Space,Str "should",Space,Str "have",Space,Str "a",Space,Str "custom",Space,Str "style,",Space,Str "but",Space,Link ("",[],[]) [Str "this",Space,Str "link",Space,Str "should",Space,Str "not"] ("http://example.com/",""),Str "."]+ ,Header 2 ("this-header-should-not-have-the-divs-custom-style",[],[]) [Str "This",Space,Str "header",Space,Str "should",Space,Str "not",Space,Str "have",Space,Str "the",Space,Str "div\8217s",Space,Str "custom",Space,Str "style"]+ ,BlockQuote+  [Para [Str "This",Space,Str "blockquote",Space,Str "should",Space,Str "not."]]+ ,CodeBlock ("",[],[]) "# This code block should not."+ ,Para [Str "But",Space,Str "this",Space,Str "paragraph",Space,Str "should.",Note [Para [Str "Neither",Space,Str "footnote",Space,Str "nor",Space,Str "footnote",Space,Str "reference",Space,Str "should",Space,Str "get",Space,Str "a",Space,Str "custom",Space,Str "style",Space,Str "from",Space,Str "its",Space,Str "div."]]]]+,Div ("",[],[("custom-style","MyOuterStyle")])+ [Div ("",[],[("custom-style","MyInnerStyle")])+  [Para [Str "This",Space,Str "should",Space,Str "have",Space,Str "MyInnerStyle."]+  ,Header 3 ("this-heading-should-not",[],[]) [Str "This",Space,Str "heading",Space,Str "should",Space,Str "not"]]+ ,Para [Str "This",Space,Str "should",Space,Str "have",Space,Str "MyOuterStyle,",Space,Str "but",Space,Str "the",Space,Str "following",Space,Str "elision",Space,Str "should",Space,Str "have",Space,Str "its",SoftBreak,Str "own",Space,Str "style.",Space,Span ("",[],[("custom-style","Elision")]) [Str "..."]]+ ,BlockQuote+  [Para [Str "This",Space,Str "blockquote",Space,Str "should",Space,Str "include",Space,Strong [Str "bold",Space,Str "text",Space,Str "with",Space,Str "an",Space,Str "elision:",SoftBreak,Span ("",[],[("custom-style","Elision")]) [Str "..."]]]]]]
test/docx/custom-style-with-styles.native view
@@ -1,7 +1,7 @@-[Div ("",[],[("custom-style","FirstParagraph")])+[Div ("",[],[("custom-style","First Paragraph")])  [Para [Str "This",Space,Str "is",Space,Str "some",Space,Str "text."]]-,Div ("",[],[("custom-style","BodyText")])+,Div ("",[],[("custom-style","Body Text")])  [Para [Str "This",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "an",Space,Span ("",[],[("custom-style","Emphatic")]) [Str "emphasized"],Space,Str "text",Space,Str "style.",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "text",Space,Str "with",Space,Str "a",Space,Span ("",[],[("custom-style","Strengthened")]) [Str "strengthened"],Space,Str "text",Space,Str "style."]]-,Div ("",[],[("custom-style","MyBlockStyle")])+,Div ("",[],[("custom-style","My Block Style")])  [BlockQuote   [Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "styled",Space,Str "paragraph",Space,Str "that",Space,Str "inherits",Space,Str "from",Space,Str "Block",Space,Str "Text."]]]]
test/docx/golden/block_quotes.docx view

binary file changed (10022 → 10035 bytes)

test/docx/golden/codeblock.docx view

binary file changed (9868 → 9881 bytes)

test/docx/golden/comments.docx view

binary file changed (10203 → 10216 bytes)

test/docx/golden/custom_style_no_reference.docx view

binary file changed (9967 → 9980 bytes)

+ test/docx/golden/custom_style_preserve.docx view

binary file changed (absent → 10606 bytes)

test/docx/golden/definition_list.docx view

binary file changed (9861 → 9872 bytes)

test/docx/golden/document-properties-short-desc.docx view

binary file changed (9872 → 9884 bytes)

test/docx/golden/document-properties.docx view

binary file changed (10358 → 10361 bytes)

test/docx/golden/headers.docx view

binary file changed (10009 → 10022 bytes)

test/docx/golden/image.docx view

binary file changed (26685 → 26698 bytes)

test/docx/golden/inline_code.docx view

binary file changed (9804 → 9817 bytes)

test/docx/golden/inline_formatting.docx view

binary file changed (9974 → 9987 bytes)

test/docx/golden/inline_images.docx view

binary file changed (26740 → 26753 bytes)

binary file changed (10025 → 10038 bytes)

test/docx/golden/links.docx view

binary file changed (10204 → 10217 bytes)

test/docx/golden/lists.docx view

binary file changed (10281 → 10295 bytes)

test/docx/golden/lists_continuing.docx view

binary file changed (10078 → 10090 bytes)

test/docx/golden/lists_restarting.docx view

binary file changed (10077 → 10090 bytes)

test/docx/golden/nested_anchors_in_header.docx view

binary file changed (10166 → 10179 bytes)

test/docx/golden/notes.docx view

binary file changed (9975 → 9988 bytes)

test/docx/golden/table_one_row.docx view

binary file changed (9825 → 9838 bytes)

test/docx/golden/table_with_list_cell.docx view

binary file changed (10197 → 10207 bytes)

test/docx/golden/tables.docx view

binary file changed (10207 → 10220 bytes)

test/docx/golden/track_changes_deletion.docx view

binary file changed (9848 → 9861 bytes)

test/docx/golden/track_changes_insertion.docx view

binary file changed (9831 → 9844 bytes)

test/docx/golden/track_changes_move.docx view

binary file changed (9865 → 9878 bytes)

test/docx/golden/unicode.docx view

binary file changed (9789 → 9802 bytes)

test/docx/golden/verbatim_subsuper.docx view

binary file changed (9837 → 9850 bytes)

+ test/docx/lists-compact.docx view

binary file changed (absent → 9952 bytes)

+ test/docx/lists-compact.native view
@@ -0,0 +1,5 @@+[OrderedList (1,Decimal,Period)+ [[Plain [Str "One"]]+ ,[Plain [Str "Two"]]+ ,[Plain [Str "Three"]]+ ,[Plain [Str "Four"]]]]
test/docx/lists.docx view

binary file changed (19845 → 9473 bytes)

test/docx/lists.native view
@@ -15,4 +15,4 @@       ,Para [Str "Sub",Space,Str "paragraph"]]]]]]  ,[Para [Str "Same",Space,Str "list"]]] ,BulletList- [[Para [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]]+ [[Plain [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]]
+ test/docx/lists_sublist_reset.docx view

binary file changed (absent → 12757 bytes)

+ test/docx/lists_sublist_reset.native view
@@ -0,0 +1,8 @@+[OrderedList (1,Decimal,Period)+ [[Para [Str "Head",Space,Str "1"]+  ,OrderedList (1,Decimal,DefaultDelim)+   [[Para [Str "Head",Space,Str "1.1"]]+   ,[Para [Str "Head",Space,Str "1.2"]]]]+ ,[Para [Str "Head",Space,Str "2"]+  ,OrderedList (1,Decimal,DefaultDelim)+   [[Para [Str "Head",Space,Str "2.1"]]]]]]
test/docx/nested_anchors_in_header.native view
@@ -1,4 +1,4 @@-[Header 1 ("\1086\1075\1083\1072\1074\1083\1077\1085\1080\1077",["TOCHeading"],[]) [Str "\1054\1075\1083\1072\1074\1083\1077\1085\1080\1077"]+[Header 1 ("\1086\1075\1083\1072\1074\1083\1077\1085\1080\1077",["TOC-Heading"],[]) [Str "\1054\1075\1083\1072\1074\1083\1077\1085\1080\1077"] ,Para [Link ("",[],[]) [Str "Short",Space,Str "instructions",Space,Str "1"] ("#short-instructions","")] ,Para [Link ("",[],[]) [Str "Some",Space,Str "instructions",Space,Str "1"] ("#some-instructions","")] ,Para [Link ("",[],[]) [Str "Remote",Space,Str "folder",Space,Str "or",Space,Str "longlonglonglonglong",Space,Str "file",Space,Str "with",Space,Str "manymanymanymany",Space,Str "letters",Space,Str "inside",Space,Str "opening",Space,Str "2"] ("#remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-opening","")]
+ test/epub/epub2_cover.epub view

binary file changed (absent → 17937 bytes)

+ test/epub/epub2_no_cover.epub view

binary file changed (absent → 9730 bytes)

+ test/epub/epub2_picture.epub view

binary file changed (absent → 17939 bytes)

+ test/epub/img_no_cover.epub view

binary file changed (absent → 50594 bytes)

test/html-reader.html view
@@ -81,6 +81,10 @@ </blockquote> <p>And a following paragraph.</p> <hr />+<h1>Inline quotes</h1>+<p>Normal text but then a <q cite="https://www.imdb.com/title/tt0062622/quotes/qt0396921">inline quote</q>.</p>+<p><q>Missing a cite attribute means its just normal text</q></p>+<hr /> <h1>Code Blocks</h1> <p>Code:</p> <pre><code>---- (should be four hyphens)
test/html-reader.native view
@@ -51,6 +51,10 @@   [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 ("inline-quotes",[],[]) [Str "Inline",Space,Str "quotes"]+,Para [Str "Normal",Space,Str "text",Space,Str "but",Space,Str "then",Space,Str "a",Space,Quoted DoubleQuote [Span ("",[],[("cite","https://www.imdb.com/title/tt0062622/quotes/qt0396921")]) [Str "inline",Space,Str "quote"]],Str "."]+,Para [Quoted DoubleQuote [Str "Missing",Space,Str "a",Space,Str "cite",Space,Str "attribute",Space,Str "means",Space,Str "its",Space,Str "just",Space,Str "normal",Space,Str "text"]]+,HorizontalRule ,Header 1 ("code-blocks",[],[]) [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"
test/lhs-test.html view
@@ -6,75 +6,73 @@   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />   <title>lhs-test</title>   <style>-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-  </style>-  <style>-code.sourceCode > span { display: inline-block; line-height: 1.25; }-code.sourceCode > span { color: inherit; text-decoration: inherit; }-code.sourceCode > span:empty { height: 1.2em; }-.sourceCode { overflow: visible; }-code.sourceCode { white-space: pre; position: relative; }-div.sourceCode { margin: 1em 0; }-pre.sourceCode { margin: 0; }-@media screen {-div.sourceCode { overflow: auto; }-}-@media print {-code.sourceCode { white-space: pre-wrap; }-code.sourceCode > span { text-indent: -5em; padding-left: 5em; }-}-pre.numberSource code-  { counter-reset: source-line 0; }-pre.numberSource code > span-  { position: relative; left: -4em; counter-increment: source-line; }-pre.numberSource code > span > a:first-child::before-  { content: counter(source-line);-    position: relative; left: -1em; text-align: right; vertical-align: baseline;-    border: none; display: inline-block;-    -webkit-touch-callout: none; -webkit-user-select: none;-    -khtml-user-select: none; -moz-user-select: none;-    -ms-user-select: none; user-select: none;-    padding: 0 4px; width: 4em;-    color: #aaaaaa;-  }-pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }-div.sourceCode-  {   }-@media screen {-code.sourceCode > span > a:first-child::before { text-decoration: underline; }-}-code span.al { color: #ff0000; font-weight: bold; } /* Alert */-code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */-code span.at { color: #7d9029; } /* Attribute */-code span.bn { color: #40a070; } /* BaseN */-code span.bu { } /* BuiltIn */-code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */-code span.ch { color: #4070a0; } /* Char */-code span.cn { color: #880000; } /* Constant */-code span.co { color: #60a0b0; font-style: italic; } /* Comment */-code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */-code span.do { color: #ba2121; font-style: italic; } /* Documentation */-code span.dt { color: #902000; } /* DataType */-code span.dv { color: #40a070; } /* DecVal */-code span.er { color: #ff0000; font-weight: bold; } /* Error */-code span.ex { } /* Extension */-code span.fl { color: #40a070; } /* Float */-code span.fu { color: #06287e; } /* Function */-code span.im { } /* Import */-code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */-code span.kw { color: #007020; font-weight: bold; } /* Keyword */-code span.op { color: #666666; } /* Operator */-code span.ot { color: #007020; } /* Other */-code span.pp { color: #bc7a00; } /* Preprocessor */-code span.sc { color: #4070a0; } /* SpecialChar */-code span.ss { color: #bb6688; } /* SpecialString */-code span.st { color: #4070a0; } /* String */-code span.va { color: #19177c; } /* Variable */-code span.vs { color: #4070a0; } /* VerbatimString */-code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}+    pre > code.sourceCode { white-space: pre; position: relative; }+    pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }+    pre > code.sourceCode > span:empty { height: 1.2em; }+    code.sourceCode > span { color: inherit; text-decoration: inherit; }+    div.sourceCode { margin: 1em 0; }+    pre.sourceCode { margin: 0; }+    @media screen {+    div.sourceCode { overflow: auto; }+    }+    @media print {+    pre > code.sourceCode { white-space: pre-wrap; }+    pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }+    }+    pre.numberSource code+      { counter-reset: source-line 0; }+    pre.numberSource code > span+      { position: relative; left: -4em; counter-increment: source-line; }+    pre.numberSource code > span > a:first-child::before+      { content: counter(source-line);+        position: relative; left: -1em; text-align: right; vertical-align: baseline;+        border: none; display: inline-block;+        -webkit-touch-callout: none; -webkit-user-select: none;+        -khtml-user-select: none; -moz-user-select: none;+        -ms-user-select: none; user-select: none;+        padding: 0 4px; width: 4em;+        color: #aaaaaa;+      }+    pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }+    div.sourceCode+      {   }+    @media screen {+    pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }+    }+    code span.al { color: #ff0000; font-weight: bold; } /* Alert */+    code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */+    code span.at { color: #7d9029; } /* Attribute */+    code span.bn { color: #40a070; } /* BaseN */+    code span.bu { } /* BuiltIn */+    code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */+    code span.ch { color: #4070a0; } /* Char */+    code span.cn { color: #880000; } /* Constant */+    code span.co { color: #60a0b0; font-style: italic; } /* Comment */+    code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */+    code span.do { color: #ba2121; font-style: italic; } /* Documentation */+    code span.dt { color: #902000; } /* DataType */+    code span.dv { color: #40a070; } /* DecVal */+    code span.er { color: #ff0000; font-weight: bold; } /* Error */+    code span.ex { } /* Extension */+    code span.fl { color: #40a070; } /* Float */+    code span.fu { color: #06287e; } /* Function */+    code span.im { } /* Import */+    code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */+    code span.kw { color: #007020; font-weight: bold; } /* Keyword */+    code span.op { color: #666666; } /* Operator */+    code span.ot { color: #007020; } /* Other */+    code span.pp { color: #bc7a00; } /* Preprocessor */+    code span.sc { color: #4070a0; } /* SpecialChar */+    code span.ss { color: #bb6688; } /* SpecialString */+    code span.st { color: #4070a0; } /* String */+    code span.va { color: #19177c; } /* Variable */+    code span.vs { color: #4070a0; } /* VerbatimString */+    code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */   </style>   <!--[if lt IE 9]>     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
test/lhs-test.html+lhs view
@@ -6,75 +6,73 @@   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />   <title>lhs-test</title>   <style>-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}-  </style>-  <style>-code.sourceCode > span { display: inline-block; line-height: 1.25; }-code.sourceCode > span { color: inherit; text-decoration: inherit; }-code.sourceCode > span:empty { height: 1.2em; }-.sourceCode { overflow: visible; }-code.sourceCode { white-space: pre; position: relative; }-div.sourceCode { margin: 1em 0; }-pre.sourceCode { margin: 0; }-@media screen {-div.sourceCode { overflow: auto; }-}-@media print {-code.sourceCode { white-space: pre-wrap; }-code.sourceCode > span { text-indent: -5em; padding-left: 5em; }-}-pre.numberSource code-  { counter-reset: source-line 0; }-pre.numberSource code > span-  { position: relative; left: -4em; counter-increment: source-line; }-pre.numberSource code > span > a:first-child::before-  { content: counter(source-line);-    position: relative; left: -1em; text-align: right; vertical-align: baseline;-    border: none; display: inline-block;-    -webkit-touch-callout: none; -webkit-user-select: none;-    -khtml-user-select: none; -moz-user-select: none;-    -ms-user-select: none; user-select: none;-    padding: 0 4px; width: 4em;-    color: #aaaaaa;-  }-pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }-div.sourceCode-  {   }-@media screen {-code.sourceCode > span > a:first-child::before { text-decoration: underline; }-}-code span.al { color: #ff0000; font-weight: bold; } /* Alert */-code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */-code span.at { color: #7d9029; } /* Attribute */-code span.bn { color: #40a070; } /* BaseN */-code span.bu { } /* BuiltIn */-code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */-code span.ch { color: #4070a0; } /* Char */-code span.cn { color: #880000; } /* Constant */-code span.co { color: #60a0b0; font-style: italic; } /* Comment */-code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */-code span.do { color: #ba2121; font-style: italic; } /* Documentation */-code span.dt { color: #902000; } /* DataType */-code span.dv { color: #40a070; } /* DecVal */-code span.er { color: #ff0000; font-weight: bold; } /* Error */-code span.ex { } /* Extension */-code span.fl { color: #40a070; } /* Float */-code span.fu { color: #06287e; } /* Function */-code span.im { } /* Import */-code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */-code span.kw { color: #007020; font-weight: bold; } /* Keyword */-code span.op { color: #666666; } /* Operator */-code span.ot { color: #007020; } /* Other */-code span.pp { color: #bc7a00; } /* Preprocessor */-code span.sc { color: #4070a0; } /* SpecialChar */-code span.ss { color: #bb6688; } /* SpecialString */-code span.st { color: #4070a0; } /* String */-code span.va { color: #19177c; } /* Variable */-code span.vs { color: #4070a0; } /* VerbatimString */-code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}+    pre > code.sourceCode { white-space: pre; position: relative; }+    pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }+    pre > code.sourceCode > span:empty { height: 1.2em; }+    code.sourceCode > span { color: inherit; text-decoration: inherit; }+    div.sourceCode { margin: 1em 0; }+    pre.sourceCode { margin: 0; }+    @media screen {+    div.sourceCode { overflow: auto; }+    }+    @media print {+    pre > code.sourceCode { white-space: pre-wrap; }+    pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }+    }+    pre.numberSource code+      { counter-reset: source-line 0; }+    pre.numberSource code > span+      { position: relative; left: -4em; counter-increment: source-line; }+    pre.numberSource code > span > a:first-child::before+      { content: counter(source-line);+        position: relative; left: -1em; text-align: right; vertical-align: baseline;+        border: none; display: inline-block;+        -webkit-touch-callout: none; -webkit-user-select: none;+        -khtml-user-select: none; -moz-user-select: none;+        -ms-user-select: none; user-select: none;+        padding: 0 4px; width: 4em;+        color: #aaaaaa;+      }+    pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }+    div.sourceCode+      {   }+    @media screen {+    pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }+    }+    code span.al { color: #ff0000; font-weight: bold; } /* Alert */+    code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */+    code span.at { color: #7d9029; } /* Attribute */+    code span.bn { color: #40a070; } /* BaseN */+    code span.bu { } /* BuiltIn */+    code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */+    code span.ch { color: #4070a0; } /* Char */+    code span.cn { color: #880000; } /* Constant */+    code span.co { color: #60a0b0; font-style: italic; } /* Comment */+    code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */+    code span.do { color: #ba2121; font-style: italic; } /* Documentation */+    code span.dt { color: #902000; } /* DataType */+    code span.dv { color: #40a070; } /* DecVal */+    code span.er { color: #ff0000; font-weight: bold; } /* Error */+    code span.ex { } /* Extension */+    code span.fl { color: #40a070; } /* Float */+    code span.fu { color: #06287e; } /* Function */+    code span.im { } /* Import */+    code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */+    code span.kw { color: #007020; font-weight: bold; } /* Keyword */+    code span.op { color: #666666; } /* Operator */+    code span.ot { color: #007020; } /* Other */+    code span.pp { color: #bc7a00; } /* Preprocessor */+    code span.sc { color: #4070a0; } /* SpecialChar */+    code span.ss { color: #bb6688; } /* SpecialString */+    code span.st { color: #4070a0; } /* String */+    code span.va { color: #19177c; } /* Variable */+    code span.vs { color: #4070a0; } /* VerbatimString */+    code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */   </style>   <!--[if lt IE 9]>     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
test/lhs-test.latex view
@@ -94,9 +94,9 @@  \begin{Shaded} \begin{Highlighting}[]-\OtherTok{unsplit ::}\NormalTok{ (}\DataTypeTok{Arrow}\NormalTok{ a) }\OtherTok{=>}\NormalTok{ (b }\OtherTok{->}\NormalTok{ c }\OtherTok{->}\NormalTok{ d) }\OtherTok{->}\NormalTok{ a (b, c) d}+\OtherTok{unsplit ::}\NormalTok{ (}\DataTypeTok{Arrow}\NormalTok{ a) }\OtherTok{=>}\NormalTok{ (b }\OtherTok{{-}>}\NormalTok{ c }\OtherTok{{-}>}\NormalTok{ d) }\OtherTok{{-}>}\NormalTok{ a (b, c) d} \NormalTok{unsplit }\OtherTok{=}\NormalTok{ arr }\OperatorTok{.} \FunctionTok{uncurry}-          \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y)}+          \CommentTok{{-}{-} arr (\textbackslash{}op (x,y) {-}> x \textasciigrave{}op\textasciigrave{} y)} \end{Highlighting} \end{Shaded} 
test/lua/module/pandoc-utils.lua view
@@ -39,20 +39,17 @@     end)   }, -  group 'hierarchicalize' {+  group 'make_sections' {     test('sanity check', function ()       local blks = {         pandoc.Header(1, {pandoc.Str 'First'}),         pandoc.Header(2, {pandoc.Str 'Second'}),         pandoc.Header(2, {pandoc.Str 'Third'}),       }-      local hblks = utils.hierarchicalize(blks)-      -- cannot create Elements directly; performing only an approximate-      -- sanity checking instead of a full equality comparison.-      assert.are_equal('Sec', hblks[1].t)-      assert.are_equal('Sec', hblks[1].contents[1].t)-      assert.are_equal(1, hblks[1].contents[2].numbering[1])-      assert.are_equal(2, hblks[1].contents[2].numbering[2])+      local hblks = utils.make_sections(true, 1, blks)+      assert.are_equal('Div', hblks[1].t)+      assert.are_equal('Header', hblks[1].content[1].t)+      assert.are_equal('1', hblks[1].content[1].attributes['number'])     end)   }, 
test/lua/module/pandoc.lua view
@@ -86,7 +86,86 @@         assert.are_equal(count, 3)       end)     },+    group 'HTML-like attribute tables' {+      test('in element constructor', function ()+        local html_attributes = {+          id = 'the-id',+          class = 'class1 class2',+          width = '11',+          height = '12'+        }+        local attr = pandoc.Span('test', html_attributes).attr+        assert.are_equal(attr.identifier, 'the-id')+        assert.are_equal(attr.classes[1], 'class1')+        assert.are_equal(attr.classes[2], 'class2')+        assert.are_equal(attr.attributes.width, '11')+        assert.are_equal(attr.attributes.height, '12')+      end),+      test('element attr setter', function ()+        local html_attributes = {+          id = 'the-id',+          class = 'class1 class2',+          width = "11",+          height = "12"+        }+        local span = pandoc.Span 'test'+        span.attr = html_attributes+        assert.are_equal(span.attr.identifier, 'the-id')+        assert.are_equal(span.attr.classes[1], 'class1')+        assert.are_equal(span.attr.classes[2], 'class2')+        assert.are_equal(span.attr.attributes.width, '11')+        assert.are_equal(span.attr.attributes.height, '12')+      end),+      test('element attrbutes setter', function ()+        local attributes = {+          width = "11",+          height = "12"+        }+        local span = pandoc.Span 'test'+        span.attributes = attributes+        assert.are_equal(span.attr.attributes.width, '11')+        assert.are_equal(span.attr.attributes.height, '12')+      end)+    }   },++  group 'clone' {+    test('clones Attr', function ()+      local attr = pandoc.Attr('test', {'my-class'}, {foo = 'bar'})+      local cloned = attr:clone()+      attr.identifier = ''+      attr.classes = {}+      attr.attributes = {}+      assert.are_same(cloned.identifier, 'test')+      assert.are_same(cloned.classes, {'my-class'})+      assert.are_same(cloned.attributes.foo, 'bar')+    end),+    test('clones ListAttributes', function ()+      local la = pandoc.ListAttributes(2, pandoc.DefaultStyle, pandoc.Period)+      local cloned = la:clone()+      la.start = 9+      assert.are_same(cloned.start, 2)+    end),+    test('clones Para', function ()+      local para = pandoc.Para {pandoc.Str 'Hello'}+      local cloned = para:clone()+      para.content[1].text = 'bye'+      assert.are_same(cloned, pandoc.Para {pandoc.Str 'Hello'})+    end),+    test('clones Str', function ()+      local str = pandoc.Str 'Hello'+      local cloned = str:clone()+      str.text = 'bye'+      assert.are_same(cloned.text, 'Hello')+    end),+    test('clones Citation', function ()+      local cite = pandoc.Citation('leibniz', pandoc.AuthorInText)+      local cloned = cite:clone()+      cite.id = 'newton'+      assert.are_same(cloned.id, 'leibniz')+    end),+  },+   group 'pipe' {     test('external string processing', function ()       if os_is_windows() then@@ -133,4 +212,42 @@       )     end)   },++  group 'walk_block' {+    test('block walking order', function ()+     local acc = {}+     local nested_nums = pandoc.Div {+       pandoc.Para{pandoc.Str'1'},+       pandoc.Div{+         pandoc.Para{pandoc.Str'2'},+         pandoc.Para{pandoc.Str'3'}+       },+       pandoc.Para{pandoc.Str'4'}+     }+     pandoc.walk_block(+       nested_nums,+       {Para = function (p) table.insert(acc, p.content[1].text) end}+     )+     assert.are_equal('1234', table.concat(acc))+    end)+  },++  group 'walk_inline' {+    test('inline walking order', function ()+      local acc = {}+      local nested_nums = pandoc.Span {+        pandoc.Str'1',+        pandoc.Emph {+          pandoc.Str'2',+          pandoc.Str'3'+        },+        pandoc.Str'4'+      }+      pandoc.walk_inline(+        nested_nums,+        {Str = function (s) table.insert(acc, s.text) end}+      )+      assert.are_equal('1234', table.concat(acc))+    end)+  } }
+ test/odt/markdown/formula.md view
@@ -0,0 +1,1 @@+$$E = {m \cdot c^{2}}$$
+ test/pptx/code-custom.pptx view

binary file changed (absent → 28230 bytes)

+ test/pptx/code-custom_templated.pptx view

binary file changed (absent → 395524 bytes)

+ test/pptx/code.native view
@@ -0,0 +1,21 @@+[Header 1 ("header-with-inline-code",[],[]) [Str "Header",Space,Str "with",Space,Code ("",[],[]) "inline code"]+,CodeBlock ("",[],[]) "Code at level 0"+,BulletList+ [[Para [Str "Bullet",Space,Str "item",Space,Str "with",Space,Code ("",[],[]) "inline code"]+  ,CodeBlock ("",[],[]) "Code block at level 1"+  ,BulletList+   [[Para [Str "with",Space,Code ("",[],[]) "nested"]+    ,CodeBlock ("",[],[]) "lvl2\nlvl2\nlvl2"+    ,Header 2 ("second-heading-level-with-code",[],[]) [Str "Second",Space,Str "heading",Space,Str "level",Space,Str "with",Space,Code ("",[],[]) "code"]]]]]+,Header 1 ("syntax-highlighting",[],[]) [Str "Syntax",Space,Str "highlighting"]+,CodeBlock ("",["haskell"],[]) "id :: a -> a\nid x = x"+,BulletList+ [[Para [Str "Nested"]+  ,CodeBlock ("",["haskell"],[]) "g :: Int -> Int\ng x = x * 3"]]+,Header 1 ("two-column-slide",[],[]) [Str "Two",Space,Str "column",Space,Str "slide"]+,Div ("",["columns"],[])+ [Div ("",["column"],[("width","50%")])+  [BulletList+   [[Plain [Str "A",Space,Str "total",Space,Str "alternative",Space,Str "for",Space,Code ("",[],[]) "head"]]]]+ ,Div ("",["column"],[("width","50%")])+  [CodeBlock ("",[],[]) "safeHead :: [a] -> Maybe a\nsafeHead [] = Nothing\nsafeHead (x:_) = Just x"]]]
+ test/pptx/code.pptx view

binary file changed (absent → 28229 bytes)

+ test/pptx/code_templated.pptx view

binary file changed (absent → 395522 bytes)

+ test/pptx/start_numbering_at.native view
@@ -0,0 +1,9 @@+[Header 2 ("example-numbering-mwe",[],[]) [Str "Example",Space,Str "numbering",Space,Str "MWE"]+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "slide",Space,Str "with",Space,Str "examples",Space,Str "in",Space,Str "(1)",Space,Str "and",Space,Str "(2)"]+,OrderedList (1,Example,TwoParens)+ [[Plain [Str "First"]]+ ,[Plain [Str "Second"]]]+,Header 2 ("a-second-slide",[],[]) [Str "A",Space,Str "second",Space,Str "slide"]+,Para [Str "This",Space,Str "second",Space,Str "slide",Space,Str "has",Space,Str "a",Space,Str "third",Space,Str "example",Space,Str "in",Space,Str "(3)."]+,OrderedList (3,Example,TwoParens)+ [[Plain [Str "Third"]]]]
+ test/pptx/start_numbering_at.pptx view

binary file changed (absent → 27031 bytes)

+ test/pptx/start_numbering_at_templated.pptx view

binary file changed (absent → 394323 bytes)

test/s5-basic.html view
@@ -11,10 +11,11 @@   <meta name="date" content="2006-07-15" />   <title>My S5 Document</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}   </style>   <!-- configuration parameters -->   <meta name="defaultView" content="slideshow" />
test/s5-fancy.html view
@@ -11,10 +11,11 @@   <meta name="date" content="2006-07-15" />   <title>My S5 Document</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}   </style>   <!-- configuration parameters -->   <meta name="defaultView" content="slideshow" />@@ -26,7 +27,7 @@   <link rel="stylesheet" href="s5/default/opera.css" type="text/css" media="projection" id="operaFix" />   <!-- S5 JS -->   <script src="s5/default/slides.js" type="text/javascript"></script>-  <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_CHTML-full" type="text/javascript"></script>+  <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" type="text/javascript"></script> </head> <body> <div class="layout">
test/s5-inserts.html view
@@ -9,10 +9,11 @@   <meta name="date" content="2006-07-15" />   <title>My S5 Document</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}   </style>   <link rel="stylesheet" href="main.css" type="text/css" />   STUFF INSERTED
test/tables.custom view
@@ -198,4 +198,3 @@ the blank line between rows.</td> </tr> </table>-
test/tables.dokuwiki view
@@ -44,4 +44,3 @@  |  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.|-
test/tables.fb2 view
@@ -13,4 +13,3 @@ the blank line between rows.</td></tr></table><p><emphasis /></p><p>Table without column headers:</p><table><tr><th align="right" /><th align="left" /><th align="center" /><th align="right" /></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="right">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="right">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="right">1</td></tr></table><p><emphasis /></p><p>Multiline table without column headers:</p><table><tr><th align="center" /><th align="left" /><th align="right" /><th align="left" /></tr><tr><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><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></table><p><emphasis /></p></section></body></FictionBook>-
test/tables.jira view
@@ -23,13 +23,13 @@  ||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.|+|Second|row|5.0|Here’s another one. Note the blank line between rows.|  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.|+|Second|row|5.0|Here’s another one. Note the blank line between rows.|  Table without column headers: @@ -40,5 +40,4 @@ 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.|-+|Second|row|5.0|Here’s another one. Note the blank line between rows.|
test/tables.mediawiki view
@@ -143,4 +143,3 @@ |align="right"| 5.0 | Here’s another one. Note the blank line between rows. |}-
test/tables.opendocument view
@@ -1,4 +1,6 @@ <text:p text:style-name="Text_20_body">Simple table with caption:</text:p>+<text:p text:style-name="TableCaption">Demonstration of simple table+syntax.</text:p> <table:table table:name="Table1" table:style-name="Table1">   <table:table-column table:style-name="Table1.A" />   <table:table-column table:style-name="Table1.B" />@@ -63,8 +65,6 @@     </table:table-cell>   </table:table-row> </table:table>-<text:p text:style-name="TableCaption">Demonstration of simple table-syntax.</text:p> <text:p text:style-name="First_20_paragraph">Simple table without caption:</text:p> <table:table table:name="Table2" table:style-name="Table2">@@ -133,6 +133,8 @@ </table:table> <text:p text:style-name="First_20_paragraph">Simple table indented two spaces:</text:p>+<text:p text:style-name="TableCaption">Demonstration of simple table+syntax.</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" />@@ -197,10 +199,10 @@     </table:table-cell>   </table:table-row> </table:table>-<text:p text:style-name="TableCaption">Demonstration of simple table-syntax.</text:p> <text:p text:style-name="First_20_paragraph">Multiline table with caption:</text:p>+<text:p text:style-name="TableCaption">Here’s the caption. It may span+multiple lines.</text:p> <table:table table:name="Table4" table:style-name="Table4">   <table:table-column table:style-name="Table4.A" />   <table:table-column table:style-name="Table4.B" />@@ -253,8 +255,6 @@     </table:table-cell>   </table:table-row> </table:table>-<text:p text:style-name="TableCaption">Here’s the caption. It may span-multiple lines.</text:p> <text:p text:style-name="First_20_paragraph">Multiline table without caption:</text:p> <table:table table:name="Table5" table:style-name="Table5">
test/tables.rtf view
@@ -357,4 +357,3 @@ } \intbl\row} {\pard \ql \f0 \sa180 \li0 \fi0 \par}-
test/tables.textile view
@@ -164,4 +164,3 @@ </tr> </tbody> </table>-
test/tables.txt view
@@ -72,4 +72,3 @@    Second   row                5.0  Here's another one.  Note                                     the blank line between rows. ----------  ---------  -----------  ----------------------------
test/tables.xwiki view
@@ -43,4 +43,3 @@ |= |= |= |= |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.-
test/tables.zimwiki view
@@ -53,4 +53,3 @@ |:--------:|:----|-----:|-----------------------------------------------------| |  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.|-
test/writer.asciidoc view
@@ -423,7 +423,7 @@  So is *_this_* word. -This is code: `+>+`, `+$+`, `+\+`, `+\$+`, `+<html>+`.+This is code: `>`, `$`, `\`, `\$`, `<html>`.  [line-through]*This is _strikeout_.* @@ -446,7 +446,7 @@  `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+Here is some quoted ``code`' and a ``http://example.com/?foo=1&bar=2[quoted link]''.  Some dashes: one—two — three—four — five.@@ -476,11 +476,11 @@  These shouldn’t be math: -* To get the famous equation, write `+$e = mc^2$+`.+* 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$.+* Escaped `$`: $73 _this should be emphasized_ 23$.  Here’s a LaTeX table: @@ -610,7 +610,7 @@ Blockquoted: http://example.com/ ____ -Auto-links should not occur here: `+<http://example.com/>+`+Auto-links should not occur here: `<http://example.com/>`  .... or here: <http://example.com/>@@ -635,7 +635,7 @@ document.] and another.[multiblock footnote omitted] This should _not_ be a footnote reference, because it contains a space.[^my note] Here is an inline note.footnote:[This is _easier_ to type. Inline notes may contain-http://google.com[links] and `+]+` verbatim characters, as well as [bracketed+http://google.com[links] and `]` verbatim characters, as well as [bracketed text].]  ____
test/writer.context view
@@ -10,8 +10,10 @@ % make chapter, section bookmarks visible when opening document \placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section] \setupinteractionscreen[option=bookmark]-\setuptagging[state=start] +\setuppagenumbering[location={footer,middle}]+\setupbackend[export=yes]+\setupstructure[state=start,method=auto]  % use microtypography \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]
test/writer.custom view
@@ -780,4 +780,3 @@ <li id="fn4"><p>In quote. <a href="#fnref4">&#8617;</a></p></li> <li id="fn5"><p>In list. <a href="#fnref5">&#8617;</a></p></li> </ol>-
test/writer.docbook4 view
@@ -16,1401 +16,1403 @@     </authorgroup>     <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.-</para>-<sect1 id="headers">-  <title>Headers</title>-  <sect2 id="level-2-with-an-embedded-link">-    <title>Level 2 with an <ulink url="/url">embedded link</ulink></title>-    <sect3 id="level-3-with-emphasis">-      <title>Level 3 with <emphasis>emphasis</emphasis></title>-      <sect4 id="level-4">-        <title>Level 4</title>-        <sect5 id="level-5">-          <title>Level 5</title>-          <para>-          </para>-        </sect5>-      </sect4>-    </sect3>-  </sect2>-</sect1>-<sect1 id="level-1">-  <title>Level 1</title>-  <sect2 id="level-2-with-emphasis">-    <title>Level 2 with <emphasis>emphasis</emphasis></title>-    <sect3 id="level-3">-      <title>Level 3</title>-      <para>-        with no blank line-      </para>-    </sect3>-  </sect2>-  <sect2 id="level-2">-    <title>Level 2</title>-    <para>-      with no blank line-    </para>-  </sect2>-</sect1>-<sect1 id="paragraphs">-  <title>Paragraphs</title>-  <para>-    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.-  </para>-  <para>-    Here’s one with a bullet. * criminey.-  </para>-<literallayout>There should be a hard line break-here.</literallayout>-</sect1>-<sect1 id="block-quotes">-  <title>Block Quotes</title>-  <para>-    E-mail style:-  </para>-  <blockquote>-    <para>-      This is a block quote. It is pretty short.-    </para>-  </blockquote>-  <blockquote>-    <para>-      Code in a block quote:-    </para>-    <programlisting>-sub status {-    print &quot;working&quot;;-}-</programlisting>-    <para>-      A list:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          item one-        </para>-      </listitem>-      <listitem>-        <para>-          item two-        </para>-      </listitem>-    </orderedlist>-    <para>-      Nested block quotes:-    </para>-    <blockquote>-      <para>-        nested-      </para>-    </blockquote>-    <blockquote>-      <para>-        nested-      </para>-    </blockquote>-  </blockquote>-  <para>-    This should not be a block quote: 2 &gt; 1.-  </para>-  <para>-    And a following paragraph.-  </para>-</sect1>-<sect1 id="code-blocks">-  <title>Code Blocks</title>-  <para>-    Code:-  </para>-  <programlisting>----- (should be four hyphens)--sub status {-    print &quot;working&quot;;-}--this code block is indented by one tab-</programlisting>-  <para>-    And:-  </para>-  <programlisting>-    this code block is indented by two tabs--These should not be escaped:  \$ \\ \&gt; \[ \{-</programlisting>-</sect1>-<sect1 id="lists">-  <title>Lists</title>-  <sect2 id="unordered">-    <title>Unordered</title>-    <para>-      Asterisks tight:-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          asterisk 1-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 2-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Asterisks loose:-    </para>-    <itemizedlist>-      <listitem>-        <para>-          asterisk 1-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 2-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Pluses tight:-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          Plus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Pluses loose:-    </para>-    <itemizedlist>-      <listitem>-        <para>-          Plus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Minuses tight:-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          Minus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Minuses loose:-    </para>-    <itemizedlist>-      <listitem>-        <para>-          Minus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 3-        </para>-      </listitem>-    </itemizedlist>-  </sect2>-  <sect2 id="ordered">-    <title>Ordered</title>-    <para>-      Tight:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second-        </para>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-    <para>-      and:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          One-        </para>-      </listitem>-      <listitem>-        <para>-          Two-        </para>-      </listitem>-      <listitem>-        <para>-          Three-        </para>-      </listitem>-    </orderedlist>-    <para>-      Loose using tabs:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second-        </para>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-    <para>-      and using spaces:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          One-        </para>-      </listitem>-      <listitem>-        <para>-          Two-        </para>-      </listitem>-      <listitem>-        <para>-          Three-        </para>-      </listitem>-    </orderedlist>-    <para>-      Multiple paragraphs:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          Item 1, graf one.-        </para>-        <para>-          Item 1. graf two. The quick brown fox jumped over the lazy dog’s-          back.-        </para>-      </listitem>-      <listitem>-        <para>-          Item 2.-        </para>-      </listitem>-      <listitem>-        <para>-          Item 3.-        </para>-      </listitem>-    </orderedlist>-  </sect2>-  <sect2 id="nested">-    <title>Nested</title>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          Tab-        </para>-        <itemizedlist spacing="compact">-          <listitem>-            <para>-              Tab-            </para>-            <itemizedlist spacing="compact">-              <listitem>-                <para>-                  Tab-                </para>-              </listitem>-            </itemizedlist>-          </listitem>-        </itemizedlist>-      </listitem>-    </itemizedlist>-    <para>-      Here’s another:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second:-        </para>-        <itemizedlist spacing="compact">-          <listitem>-            <para>-              Fee-            </para>-          </listitem>-          <listitem>-            <para>-              Fie-            </para>-          </listitem>-          <listitem>-            <para>-              Foe-            </para>-          </listitem>-        </itemizedlist>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-    <para>-      Same thing but with paragraphs:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second:-        </para>-        <itemizedlist spacing="compact">-          <listitem>-            <para>-              Fee-            </para>-          </listitem>-          <listitem>-            <para>-              Fie-            </para>-          </listitem>-          <listitem>-            <para>-              Foe-            </para>-          </listitem>-        </itemizedlist>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-  </sect2>-  <sect2 id="tabs-and-spaces">-    <title>Tabs and spaces</title>-    <itemizedlist>-      <listitem>-        <para>-          this is a list item indented with tabs-        </para>-      </listitem>-      <listitem>-        <para>-          this is a list item indented with spaces-        </para>-        <itemizedlist>-          <listitem>-            <para>-              this is an example list item indented with tabs-            </para>-          </listitem>-          <listitem>-            <para>-              this is an example list item indented with spaces-            </para>-          </listitem>-        </itemizedlist>-      </listitem>-    </itemizedlist>-  </sect2>-  <sect2 id="fancy-list-markers">-    <title>Fancy list markers</title>-    <orderedlist numeration="arabic">-      <listitem override="2">-        <para>-          begins with 2-        </para>-      </listitem>-      <listitem>-        <para>-          and now 3-        </para>-        <para>-          with a continuation-        </para>-        <orderedlist numeration="lowerroman" spacing="compact">-          <listitem override="4">-            <para>-              sublist with roman numerals, starting with 4-            </para>-          </listitem>-          <listitem>-            <para>-              more items-            </para>-            <orderedlist numeration="upperalpha" spacing="compact">-              <listitem>-                <para>-                  a subsublist-                </para>-              </listitem>-              <listitem>-                <para>-                  a subsublist-                </para>-              </listitem>-            </orderedlist>-          </listitem>-        </orderedlist>-      </listitem>-    </orderedlist>-    <para>-      Nesting:-    </para>-    <orderedlist numeration="upperalpha" spacing="compact">-      <listitem>-        <para>-          Upper Alpha-        </para>-        <orderedlist numeration="upperroman" spacing="compact">-          <listitem>-            <para>-              Upper Roman.-            </para>-            <orderedlist numeration="arabic" spacing="compact">-              <listitem override="6">-                <para>-                  Decimal start with 6-                </para>-                <orderedlist numeration="loweralpha" spacing="compact">-                  <listitem override="3">-                    <para>-                      Lower alpha with paren-                    </para>-                  </listitem>-                </orderedlist>-              </listitem>-            </orderedlist>-          </listitem>-        </orderedlist>-      </listitem>-    </orderedlist>-    <para>-      Autonumbering:-    </para>-    <orderedlist spacing="compact">-      <listitem>-        <para>-          Autonumber.-        </para>-      </listitem>-      <listitem>-        <para>-          More.-        </para>-        <orderedlist spacing="compact">-          <listitem>-            <para>-              Nested.-            </para>-          </listitem>-        </orderedlist>-      </listitem>-    </orderedlist>-    <para>-      Should not be a list item:-    </para>-    <para>-      M.A. 2007-    </para>-    <para>-      B. Williams-    </para>-  </sect2>-</sect1>-<sect1 id="definition-lists">-  <title>Definition Lists</title>-  <para>-    Tight using spaces:-  </para>-  <variablelist spacing="compact">-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        banana-      </term>-      <listitem>-        <para>-          yellow fruit-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Tight using tabs:-  </para>-  <variablelist spacing="compact">-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        banana-      </term>-      <listitem>-        <para>-          yellow fruit-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Loose:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        banana-      </term>-      <listitem>-        <para>-          yellow fruit-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Multiple blocks with italics:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        <emphasis>apple</emphasis>-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          contains seeds, crisp, pleasant to taste-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        <emphasis>orange</emphasis>-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <programlisting>-{ orange code block }-</programlisting>-        <blockquote>-          <para>-            orange block quote-          </para>-        </blockquote>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Multiple definitions, tight:-  </para>-  <variablelist spacing="compact">-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          computer-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <para>-          bank-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Multiple definitions, loose:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          computer-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <para>-          bank-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Blank line after term, indented marker, alternate markers:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          computer-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <orderedlist numeration="arabic" spacing="compact">-          <listitem>-            <para>-              sublist-            </para>-          </listitem>-          <listitem>-            <para>-              sublist-            </para>-          </listitem>-        </orderedlist>-      </listitem>-    </varlistentry>-  </variablelist>-</sect1>-<sect1 id="html-blocks">-  <title>HTML Blocks</title>-  <para>-    Simple block on one line:-  </para>-  <para>-    foo-  </para>-  <para>-    And nested without indentation:-  </para>-  <para>-    foo-  </para>-  <para>-    bar-  </para>-  <para>-    Interpreted markdown in a table:-  </para>-  <table>-  <tr>-  <td>-  This is <emphasis>emphasized</emphasis>-  </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>-  <para>-    Here’s a simple block:-  </para>-  <para>-    foo-  </para>-  <para>-    This should be a code block, though:-  </para>-  <programlisting>-&lt;div&gt;-    foo-&lt;/div&gt;-</programlisting>-  <para>-    As should this:-  </para>-  <programlisting>-&lt;div&gt;foo&lt;/div&gt;-</programlisting>-  <para>-    Now, nested:-  </para>-  <para>-    foo-  </para>-  <para>-    This should just be an HTML comment:-  </para>-  <!-- Comment -->-  <para>-    Multiline:-  </para>-  <!---  Blah-  Blah-  -->-  <!---      This is another comment.-  -->-  <para>-    Code block:-  </para>-  <programlisting>-&lt;!-- Comment --&gt;-</programlisting>-  <para>-    Just plain comment, with trailing spaces on the line:-  </para>-  <!-- foo -->-  <para>-    Code:-  </para>-  <programlisting>-&lt;hr /&gt;-</programlisting>-  <para>-    Hr’s:-  </para>-  <hr>-  <hr />-  <hr />-  <hr>-  <hr />-  <hr />-  <hr class="foo" id="bar" />-  <hr class="foo" id="bar" />-  <hr class="foo" id="bar">-</sect1>-<sect1 id="inline-markup">-  <title>Inline Markup</title>-  <para>-    This is <emphasis>emphasized</emphasis>, and so <emphasis>is-    this</emphasis>.-  </para>-  <para>-    This is <emphasis role="strong">strong</emphasis>, and so-    <emphasis role="strong">is this</emphasis>.-  </para>-  <para>-    An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>.-  </para>-  <para>-    <emphasis role="strong"><emphasis>This is strong and-    em.</emphasis></emphasis>-  </para>-  <para>-    So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.-  </para>-  <para>-    <emphasis role="strong"><emphasis>This is strong and-    em.</emphasis></emphasis>-  </para>-  <para>-    So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.-  </para>-  <para>-    This is code: <literal>&gt;</literal>, <literal>$</literal>,-    <literal>\</literal>, <literal>\$</literal>,-    <literal>&lt;html&gt;</literal>.-  </para>-  <para>-    <emphasis role="strikethrough">This is-    <emphasis>strikeout</emphasis>.</emphasis>-  </para>-  <para>-    Superscripts: a<superscript>bc</superscript>d-    a<superscript><emphasis>hello</emphasis></superscript>-    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.-  </para>-  <para>-    These should not be superscripts or subscripts, because of the unescaped-    spaces: a^b c^d, a~b c~d.-  </para>-</sect1>-<sect1 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>-  </para>-  <para>-    <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>-  </para>-  <para>-    <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>.-  </para>-  <para>-    Some dashes: one—two — three—four — five.-  </para>-  <para>-    Dashes between numbers: 5–7, 255–66, 1987–1999.-  </para>-  <para>-    Ellipses…and…and….-  </para>-</sect1>-<sect1 id="latex">-  <title>LaTeX</title>-  <itemizedlist spacing="compact">-    <listitem>-      <para>-      </para>-    </listitem>-    <listitem>-      <para>-        2 + 2 = 4-      </para>-    </listitem>-    <listitem>-      <para>-        <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>-      </para>-    </listitem>-    <listitem>-      <para>-        <emphasis>α</emphasis> ∧ <emphasis>ω</emphasis>-      </para>-    </listitem>-    <listitem>-      <para>-        223-      </para>-    </listitem>-    <listitem>-      <para>-        <emphasis>p</emphasis>-Tree-      </para>-    </listitem>-    <listitem>-      <para>-        Here’s some display math:-        $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$-      </para>-    </listitem>-    <listitem>-      <para>-        Here’s one that has a line break in it:-        <emphasis>α</emphasis> + <emphasis>ω</emphasis> × <emphasis>x</emphasis><superscript>2</superscript>.-      </para>-    </listitem>-  </itemizedlist>-  <para>-    These shouldn’t be math:-  </para>-  <itemizedlist spacing="compact">-    <listitem>-      <para>-        To get the famous equation, write <literal>$e = mc^2$</literal>.-      </para>-    </listitem>-    <listitem>-      <para>-        $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It-        worked if <quote>lot</quote> is emphasized.)-      </para>-    </listitem>-    <listitem>-      <para>-        Shoes ($20) and socks ($5).-      </para>-    </listitem>-    <listitem>-      <para>-        Escaped <literal>$</literal>: $73 <emphasis>this should be-        emphasized</emphasis> 23$.-      </para>-    </listitem>-  </itemizedlist>-  <para>-    Here’s a LaTeX table:-  </para>-</sect1>-<sect1 id="special-characters">-  <title>Special Characters</title>-  <para>-    Here is some unicode:-  </para>-  <itemizedlist spacing="compact">-    <listitem>-      <para>-        I hat: Î-      </para>-    </listitem>-    <listitem>-      <para>-        o umlaut: ö-      </para>-    </listitem>-    <listitem>-      <para>-        section: §-      </para>-    </listitem>-    <listitem>-      <para>-        set membership: ∈-      </para>-    </listitem>-    <listitem>-      <para>-        copyright: ©-      </para>-    </listitem>-  </itemizedlist>-  <para>-    AT&amp;T has an ampersand in their name.-  </para>-  <para>-    AT&amp;T is another way to write it.-  </para>-  <para>-    This &amp; that.-  </para>-  <para>-    4 &lt; 5.-  </para>-  <para>-    6 &gt; 5.-  </para>-  <para>-    Backslash: \-  </para>-  <para>-    Backtick: `-  </para>-  <para>-    Asterisk: *-  </para>-  <para>-    Underscore: _-  </para>-  <para>-    Left brace: {-  </para>-  <para>-    Right brace: }-  </para>-  <para>-    Left bracket: [-  </para>-  <para>-    Right bracket: ]-  </para>-  <para>-    Left paren: (-  </para>-  <para>-    Right paren: )-  </para>-  <para>-    Greater-than: &gt;-  </para>-  <para>-    Hash: #-  </para>-  <para>-    Period: .-  </para>-  <para>-    Bang: !-  </para>-  <para>-    Plus: +-  </para>-  <para>-    Minus: --  </para>-</sect1>-<sect1 id="links">-  <title>Links</title>-  <sect2 id="explicit">-    <title>Explicit</title>-    <para>-      Just a <ulink url="/url/">URL</ulink>.-    </para>-    <para>-      <ulink url="/url/">URL and title</ulink>.-    </para>-    <para>-      <ulink url="/url/">URL and title</ulink>.-    </para>-    <para>-      <ulink url="/url/">URL and title</ulink>.-    </para>-    <para>-      <ulink url="/url/">URL and title</ulink>-    </para>-    <para>-      <ulink url="/url/">URL and title</ulink>-    </para>-    <para>-      <ulink url="/url/with_underscore">with_underscore</ulink>-    </para>-    <para>-      Email link (<email>nobody@nowhere.net</email>)-    </para>-    <para>-      <ulink url="">Empty</ulink>.-    </para>-  </sect2>-  <sect2 id="reference">-    <title>Reference</title>-    <para>-      Foo <ulink url="/url/">bar</ulink>.-    </para>-    <para>-      With <ulink url="/url/">embedded [brackets]</ulink>.-    </para>-    <para>-      <ulink url="/url/">b</ulink> by itself should be a link.-    </para>-    <para>-      Indented <ulink url="/url">once</ulink>.-    </para>-    <para>-      Indented <ulink url="/url">twice</ulink>.-    </para>-    <para>-      Indented <ulink url="/url">thrice</ulink>.-    </para>-    <para>-      This should [not][] be a link.-    </para>-    <programlisting>-[not]: /url-</programlisting>-    <para>-      Foo <ulink url="/url/">bar</ulink>.-    </para>-    <para>-      Foo <ulink url="/url/">biz</ulink>.-    </para>-  </sect2>-  <sect2 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>.-    </para>-    <para>-      Here’s a link with an amersand in the link text:-      <ulink url="http://att.com/">AT&amp;T</ulink>.-    </para>-    <para>-      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>.-    </para>-  </sect2>-  <sect2 id="autolinks">-    <title>Autolinks</title>-    <para>-      With an ampersand:-      <ulink url="http://example.com/?foo=1&amp;bar=2" role="uri">http://example.com/?foo=1&amp;bar=2</ulink>-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          In a list?-        </para>-      </listitem>-      <listitem>-        <para>-          <ulink url="http://example.com/" role="uri">http://example.com/</ulink>-        </para>-      </listitem>-      <listitem>-        <para>-          It should.-        </para>-      </listitem>-    </itemizedlist>-    <para>-      An e-mail address: <email>nobody@nowhere.net</email>-    </para>-    <blockquote>-      <para>-        Blockquoted:-        <ulink url="http://example.com/" role="uri">http://example.com/</ulink>-      </para>-    </blockquote>-    <para>-      Auto-links should not occur here:-      <literal>&lt;http://example.com/&gt;</literal>-    </para>-    <programlisting>-or here: &lt;http://example.com/&gt;-</programlisting>-  </sect2>-</sect1>-<sect1 id="images">-  <title>Images</title>-  <para>-    From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):-  </para>-  <figure>-    <title>lalune</title>-    <mediaobject>-      <imageobject>-        <imagedata fileref="lalune.jpg" />-      </imageobject>-      <textobject><phrase>lalune</phrase></textobject>-    </mediaobject>-  </figure>-  <para>-    Here is a movie <inlinemediaobject>-      <imageobject>-        <imagedata fileref="movie.jpg" />-      </imageobject>-    </inlinemediaobject> icon.-  </para>-</sect1>-<sect1 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>-      <programlisting>-  { &lt;code&gt; }-</programlisting>-      <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>-    </para>-  </blockquote>-  <orderedlist numeration="arabic" spacing="compact">-    <listitem>-      <para>-        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.-  </para>-</sect1>+  <para>+    This is a set of tests for pandoc. Most of them are adapted from John+    Gruber’s markdown test suite.+  </para>+  <sect1 id="headers">+    <title>Headers</title>+    <sect2 id="level-2-with-an-embedded-link">+      <title>Level 2 with an <ulink url="/url">embedded link</ulink></title>+      <sect3 id="level-3-with-emphasis">+        <title>Level 3 with <emphasis>emphasis</emphasis></title>+        <sect4 id="level-4">+          <title>Level 4</title>+          <sect5 id="level-5">+            <title>Level 5</title>+            <para>+            </para>+          </sect5>+        </sect4>+      </sect3>+    </sect2>+  </sect1>+  <sect1 id="level-1">+    <title>Level 1</title>+    <sect2 id="level-2-with-emphasis">+      <title>Level 2 with <emphasis>emphasis</emphasis></title>+      <sect3 id="level-3">+        <title>Level 3</title>+        <para>+          with no blank line+        </para>+      </sect3>+    </sect2>+    <sect2 id="level-2">+      <title>Level 2</title>+      <para>+        with no blank line+      </para>+    </sect2>+  </sect1>+  <sect1 id="paragraphs">+    <title>Paragraphs</title>+    <para>+      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.+    </para>+    <para>+      Here’s one with a bullet. * criminey.+    </para>+<literallayout>There should be a hard line break+here.</literallayout>+  </sect1>+  <sect1 id="block-quotes">+    <title>Block Quotes</title>+    <para>+      E-mail style:+    </para>+    <blockquote>+      <para>+        This is a block quote. It is pretty short.+      </para>+    </blockquote>+    <blockquote>+      <para>+        Code in a block quote:+      </para>+      <programlisting>+sub status {+    print &quot;working&quot;;+}+</programlisting>+      <para>+        A list:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            item one+          </para>+        </listitem>+        <listitem>+          <para>+            item two+          </para>+        </listitem>+      </orderedlist>+      <para>+        Nested block quotes:+      </para>+      <blockquote>+        <para>+          nested+        </para>+      </blockquote>+      <blockquote>+        <para>+          nested+        </para>+      </blockquote>+    </blockquote>+    <para>+      This should not be a block quote: 2 &gt; 1.+    </para>+    <para>+      And a following paragraph.+    </para>+  </sect1>+  <sect1 id="code-blocks">+    <title>Code Blocks</title>+    <para>+      Code:+    </para>+    <programlisting>+---- (should be four hyphens)++sub status {+    print &quot;working&quot;;+}++this code block is indented by one tab+</programlisting>+    <para>+      And:+    </para>+    <programlisting>+    this code block is indented by two tabs++These should not be escaped:  \$ \\ \&gt; \[ \{+</programlisting>+  </sect1>+  <sect1 id="lists">+    <title>Lists</title>+    <sect2 id="unordered">+      <title>Unordered</title>+      <para>+        Asterisks tight:+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            asterisk 1+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 2+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Asterisks loose:+      </para>+      <itemizedlist>+        <listitem>+          <para>+            asterisk 1+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 2+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Pluses tight:+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            Plus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Pluses loose:+      </para>+      <itemizedlist>+        <listitem>+          <para>+            Plus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Minuses tight:+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            Minus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Minuses loose:+      </para>+      <itemizedlist>+        <listitem>+          <para>+            Minus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 3+          </para>+        </listitem>+      </itemizedlist>+    </sect2>+    <sect2 id="ordered">+      <title>Ordered</title>+      <para>+        Tight:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second+          </para>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+      <para>+        and:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            One+          </para>+        </listitem>+        <listitem>+          <para>+            Two+          </para>+        </listitem>+        <listitem>+          <para>+            Three+          </para>+        </listitem>+      </orderedlist>+      <para>+        Loose using tabs:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second+          </para>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+      <para>+        and using spaces:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            One+          </para>+        </listitem>+        <listitem>+          <para>+            Two+          </para>+        </listitem>+        <listitem>+          <para>+            Three+          </para>+        </listitem>+      </orderedlist>+      <para>+        Multiple paragraphs:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            Item 1, graf one.+          </para>+          <para>+            Item 1. graf two. The quick brown fox jumped over the lazy dog’s+            back.+          </para>+        </listitem>+        <listitem>+          <para>+            Item 2.+          </para>+        </listitem>+        <listitem>+          <para>+            Item 3.+          </para>+        </listitem>+      </orderedlist>+    </sect2>+    <sect2 id="nested">+      <title>Nested</title>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            Tab+          </para>+          <itemizedlist spacing="compact">+            <listitem>+              <para>+                Tab+              </para>+              <itemizedlist spacing="compact">+                <listitem>+                  <para>+                    Tab+                  </para>+                </listitem>+              </itemizedlist>+            </listitem>+          </itemizedlist>+        </listitem>+      </itemizedlist>+      <para>+        Here’s another:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second:+          </para>+          <itemizedlist spacing="compact">+            <listitem>+              <para>+                Fee+              </para>+            </listitem>+            <listitem>+              <para>+                Fie+              </para>+            </listitem>+            <listitem>+              <para>+                Foe+              </para>+            </listitem>+          </itemizedlist>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+      <para>+        Same thing but with paragraphs:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second:+          </para>+          <itemizedlist spacing="compact">+            <listitem>+              <para>+                Fee+              </para>+            </listitem>+            <listitem>+              <para>+                Fie+              </para>+            </listitem>+            <listitem>+              <para>+                Foe+              </para>+            </listitem>+          </itemizedlist>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+    </sect2>+    <sect2 id="tabs-and-spaces">+      <title>Tabs and spaces</title>+      <itemizedlist>+        <listitem>+          <para>+            this is a list item indented with tabs+          </para>+        </listitem>+        <listitem>+          <para>+            this is a list item indented with spaces+          </para>+          <itemizedlist>+            <listitem>+              <para>+                this is an example list item indented with tabs+              </para>+            </listitem>+            <listitem>+              <para>+                this is an example list item indented with spaces+              </para>+            </listitem>+          </itemizedlist>+        </listitem>+      </itemizedlist>+    </sect2>+    <sect2 id="fancy-list-markers">+      <title>Fancy list markers</title>+      <orderedlist numeration="arabic">+        <listitem override="2">+          <para>+            begins with 2+          </para>+        </listitem>+        <listitem>+          <para>+            and now 3+          </para>+          <para>+            with a continuation+          </para>+          <orderedlist numeration="lowerroman" spacing="compact">+            <listitem override="4">+              <para>+                sublist with roman numerals, starting with 4+              </para>+            </listitem>+            <listitem>+              <para>+                more items+              </para>+              <orderedlist numeration="upperalpha" spacing="compact">+                <listitem>+                  <para>+                    a subsublist+                  </para>+                </listitem>+                <listitem>+                  <para>+                    a subsublist+                  </para>+                </listitem>+              </orderedlist>+            </listitem>+          </orderedlist>+        </listitem>+      </orderedlist>+      <para>+        Nesting:+      </para>+      <orderedlist numeration="upperalpha" spacing="compact">+        <listitem>+          <para>+            Upper Alpha+          </para>+          <orderedlist numeration="upperroman" spacing="compact">+            <listitem>+              <para>+                Upper Roman.+              </para>+              <orderedlist numeration="arabic" spacing="compact">+                <listitem override="6">+                  <para>+                    Decimal start with 6+                  </para>+                  <orderedlist numeration="loweralpha" spacing="compact">+                    <listitem override="3">+                      <para>+                        Lower alpha with paren+                      </para>+                    </listitem>+                  </orderedlist>+                </listitem>+              </orderedlist>+            </listitem>+          </orderedlist>+        </listitem>+      </orderedlist>+      <para>+        Autonumbering:+      </para>+      <orderedlist spacing="compact">+        <listitem>+          <para>+            Autonumber.+          </para>+        </listitem>+        <listitem>+          <para>+            More.+          </para>+          <orderedlist spacing="compact">+            <listitem>+              <para>+                Nested.+              </para>+            </listitem>+          </orderedlist>+        </listitem>+      </orderedlist>+      <para>+        Should not be a list item:+      </para>+      <para>+        M.A. 2007+      </para>+      <para>+        B. Williams+      </para>+    </sect2>+  </sect1>+  <sect1 id="definition-lists">+    <title>Definition Lists</title>+    <para>+      Tight using spaces:+    </para>+    <variablelist spacing="compact">+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          banana+        </term>+        <listitem>+          <para>+            yellow fruit+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Tight using tabs:+    </para>+    <variablelist spacing="compact">+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          banana+        </term>+        <listitem>+          <para>+            yellow fruit+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Loose:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          banana+        </term>+        <listitem>+          <para>+            yellow fruit+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Multiple blocks with italics:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          <emphasis>apple</emphasis>+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            contains seeds, crisp, pleasant to taste+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          <emphasis>orange</emphasis>+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <programlisting>+{ orange code block }+</programlisting>+          <blockquote>+            <para>+              orange block quote+            </para>+          </blockquote>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Multiple definitions, tight:+    </para>+    <variablelist spacing="compact">+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            computer+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <para>+            bank+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Multiple definitions, loose:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            computer+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <para>+            bank+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Blank line after term, indented marker, alternate markers:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            computer+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <orderedlist numeration="arabic" spacing="compact">+            <listitem>+              <para>+                sublist+              </para>+            </listitem>+            <listitem>+              <para>+                sublist+              </para>+            </listitem>+          </orderedlist>+        </listitem>+      </varlistentry>+    </variablelist>+  </sect1>+  <sect1 id="html-blocks">+    <title>HTML Blocks</title>+    <para>+      Simple block on one line:+    </para>+    <para>+      foo+    </para>+    <para>+      And nested without indentation:+    </para>+    <para>+      foo+    </para>+    <para>+      bar+    </para>+    <para>+      Interpreted markdown in a table:+    </para>+    <table>+    <tr>+    <td>+    This is <emphasis>emphasized</emphasis>+    </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>+    <para>+      Here’s a simple block:+    </para>+    <para>+      foo+    </para>+    <para>+      This should be a code block, though:+    </para>+    <programlisting>+&lt;div&gt;+    foo+&lt;/div&gt;+</programlisting>+    <para>+      As should this:+    </para>+    <programlisting>+&lt;div&gt;foo&lt;/div&gt;+</programlisting>+    <para>+      Now, nested:+    </para>+    <para>+      foo+    </para>+    <para>+      This should just be an HTML comment:+    </para>+    <!-- Comment -->+    <para>+      Multiline:+    </para>+    <!--+    Blah+    Blah+    -->+    <!--+        This is another comment.+    -->+    <para>+      Code block:+    </para>+    <programlisting>+&lt;!-- Comment --&gt;+</programlisting>+    <para>+      Just plain comment, with trailing spaces on the line:+    </para>+    <!-- foo -->+    <para>+      Code:+    </para>+    <programlisting>+&lt;hr /&gt;+</programlisting>+    <para>+      Hr’s:+    </para>+    <hr>+    <hr />+    <hr />+    <hr>+    <hr />+    <hr />+    <hr class="foo" id="bar" />+    <hr class="foo" id="bar" />+    <hr class="foo" id="bar">+  </sect1>+  <sect1 id="inline-markup">+    <title>Inline Markup</title>+    <para>+      This is <emphasis>emphasized</emphasis>, and so <emphasis>is+      this</emphasis>.+    </para>+    <para>+      This is <emphasis role="strong">strong</emphasis>, and so+      <emphasis role="strong">is this</emphasis>.+    </para>+    <para>+      An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>.+    </para>+    <para>+      <emphasis role="strong"><emphasis>This is strong and+      em.</emphasis></emphasis>+    </para>+    <para>+      So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.+    </para>+    <para>+      <emphasis role="strong"><emphasis>This is strong and+      em.</emphasis></emphasis>+    </para>+    <para>+      So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.+    </para>+    <para>+      This is code: <literal>&gt;</literal>, <literal>$</literal>,+      <literal>\</literal>, <literal>\$</literal>,+      <literal>&lt;html&gt;</literal>.+    </para>+    <para>+      <emphasis role="strikethrough">This is+      <emphasis>strikeout</emphasis>.</emphasis>+    </para>+    <para>+      Superscripts: a<superscript>bc</superscript>d+      a<superscript><emphasis>hello</emphasis></superscript>+      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.+    </para>+    <para>+      These should not be superscripts or subscripts, because of the unescaped+      spaces: a^b c^d, a~b c~d.+    </para>+  </sect1>+  <sect1 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>+    </para>+    <para>+      <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>+    </para>+    <para>+      <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>.+    </para>+    <para>+      Some dashes: one—two — three—four — five.+    </para>+    <para>+      Dashes between numbers: 5–7, 255–66, 1987–1999.+    </para>+    <para>+      Ellipses…and…and….+    </para>+  </sect1>+  <sect1 id="latex">+    <title>LaTeX</title>+    <itemizedlist spacing="compact">+      <listitem>+        <para>+        </para>+      </listitem>+      <listitem>+        <para>+          2 + 2 = 4+        </para>+      </listitem>+      <listitem>+        <para>+          <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>+        </para>+      </listitem>+      <listitem>+        <para>+          <emphasis>α</emphasis> ∧ <emphasis>ω</emphasis>+        </para>+      </listitem>+      <listitem>+        <para>+          223+        </para>+      </listitem>+      <listitem>+        <para>+          <emphasis>p</emphasis>-Tree+        </para>+      </listitem>+      <listitem>+        <para>+          Here’s some display math:+          $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$+        </para>+      </listitem>+      <listitem>+        <para>+          Here’s one that has a line break in it:+          <emphasis>α</emphasis> + <emphasis>ω</emphasis> × <emphasis>x</emphasis><superscript>2</superscript>.+        </para>+      </listitem>+    </itemizedlist>+    <para>+      These shouldn’t be math:+    </para>+    <itemizedlist spacing="compact">+      <listitem>+        <para>+          To get the famous equation, write <literal>$e = mc^2$</literal>.+        </para>+      </listitem>+      <listitem>+        <para>+          $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It+          worked if <quote>lot</quote> is emphasized.)+        </para>+      </listitem>+      <listitem>+        <para>+          Shoes ($20) and socks ($5).+        </para>+      </listitem>+      <listitem>+        <para>+          Escaped <literal>$</literal>: $73 <emphasis>this should be+          emphasized</emphasis> 23$.+        </para>+      </listitem>+    </itemizedlist>+    <para>+      Here’s a LaTeX table:+    </para>+  </sect1>+  <sect1 id="special-characters">+    <title>Special Characters</title>+    <para>+      Here is some unicode:+    </para>+    <itemizedlist spacing="compact">+      <listitem>+        <para>+          I hat: Î+        </para>+      </listitem>+      <listitem>+        <para>+          o umlaut: ö+        </para>+      </listitem>+      <listitem>+        <para>+          section: §+        </para>+      </listitem>+      <listitem>+        <para>+          set membership: ∈+        </para>+      </listitem>+      <listitem>+        <para>+          copyright: ©+        </para>+      </listitem>+    </itemizedlist>+    <para>+      AT&amp;T has an ampersand in their name.+    </para>+    <para>+      AT&amp;T is another way to write it.+    </para>+    <para>+      This &amp; that.+    </para>+    <para>+      4 &lt; 5.+    </para>+    <para>+      6 &gt; 5.+    </para>+    <para>+      Backslash: \+    </para>+    <para>+      Backtick: `+    </para>+    <para>+      Asterisk: *+    </para>+    <para>+      Underscore: _+    </para>+    <para>+      Left brace: {+    </para>+    <para>+      Right brace: }+    </para>+    <para>+      Left bracket: [+    </para>+    <para>+      Right bracket: ]+    </para>+    <para>+      Left paren: (+    </para>+    <para>+      Right paren: )+    </para>+    <para>+      Greater-than: &gt;+    </para>+    <para>+      Hash: #+    </para>+    <para>+      Period: .+    </para>+    <para>+      Bang: !+    </para>+    <para>+      Plus: ++    </para>+    <para>+      Minus: -+    </para>+  </sect1>+  <sect1 id="links">+    <title>Links</title>+    <sect2 id="explicit">+      <title>Explicit</title>+      <para>+        Just a <ulink url="/url/">URL</ulink>.+      </para>+      <para>+        <ulink url="/url/">URL and title</ulink>.+      </para>+      <para>+        <ulink url="/url/">URL and title</ulink>.+      </para>+      <para>+        <ulink url="/url/">URL and title</ulink>.+      </para>+      <para>+        <ulink url="/url/">URL and title</ulink>+      </para>+      <para>+        <ulink url="/url/">URL and title</ulink>+      </para>+      <para>+        <ulink url="/url/with_underscore">with_underscore</ulink>+      </para>+      <para>+        Email link (<email>nobody@nowhere.net</email>)+      </para>+      <para>+        <ulink url="">Empty</ulink>.+      </para>+    </sect2>+    <sect2 id="reference">+      <title>Reference</title>+      <para>+        Foo <ulink url="/url/">bar</ulink>.+      </para>+      <para>+        With <ulink url="/url/">embedded [brackets]</ulink>.+      </para>+      <para>+        <ulink url="/url/">b</ulink> by itself should be a link.+      </para>+      <para>+        Indented <ulink url="/url">once</ulink>.+      </para>+      <para>+        Indented <ulink url="/url">twice</ulink>.+      </para>+      <para>+        Indented <ulink url="/url">thrice</ulink>.+      </para>+      <para>+        This should [not][] be a link.+      </para>+      <programlisting>+[not]: /url+</programlisting>+      <para>+        Foo <ulink url="/url/">bar</ulink>.+      </para>+      <para>+        Foo <ulink url="/url/">biz</ulink>.+      </para>+    </sect2>+    <sect2 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>.+      </para>+      <para>+        Here’s a link with an amersand in the link text:+        <ulink url="http://att.com/">AT&amp;T</ulink>.+      </para>+      <para>+        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>.+      </para>+    </sect2>+    <sect2 id="autolinks">+      <title>Autolinks</title>+      <para>+        With an ampersand:+        <ulink url="http://example.com/?foo=1&amp;bar=2" role="uri">http://example.com/?foo=1&amp;bar=2</ulink>+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            In a list?+          </para>+        </listitem>+        <listitem>+          <para>+            <ulink url="http://example.com/" role="uri">http://example.com/</ulink>+          </para>+        </listitem>+        <listitem>+          <para>+            It should.+          </para>+        </listitem>+      </itemizedlist>+      <para>+        An e-mail address: <email>nobody@nowhere.net</email>+      </para>+      <blockquote>+        <para>+          Blockquoted:+          <ulink url="http://example.com/" role="uri">http://example.com/</ulink>+        </para>+      </blockquote>+      <para>+        Auto-links should not occur here:+        <literal>&lt;http://example.com/&gt;</literal>+      </para>+      <programlisting>+or here: &lt;http://example.com/&gt;+</programlisting>+    </sect2>+  </sect1>+  <sect1 id="images">+    <title>Images</title>+    <para>+      From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):+    </para>+    <figure>+      <title>lalune</title>+      <mediaobject>+        <imageobject>+          <imagedata fileref="lalune.jpg" />+        </imageobject>+        <textobject><phrase>lalune</phrase></textobject>+      </mediaobject>+    </figure>+    <para>+      Here is a movie <inlinemediaobject>+        <imageobject>+          <imagedata fileref="movie.jpg" />+        </imageobject>+      </inlinemediaobject> icon.+    </para>+  </sect1>+  <sect1 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>+        <programlisting>+  { &lt;code&gt; }+</programlisting>+        <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>+      </para>+    </blockquote>+    <orderedlist numeration="arabic" spacing="compact">+      <listitem>+        <para>+          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.+    </para>+  </sect1> </article>
test/writer.docbook5 view
@@ -17,1375 +17,1378 @@     </authorgroup>     <date>July 17, 2006</date>   </info>-<para>-  This is a set of tests for pandoc. Most of them are adapted from John-  Gruber’s markdown test suite.-</para>-<section xml:id="headers">-  <title>Headers</title>-  <section xml:id="level-2-with-an-embedded-link">-    <title>Level 2 with an <link xlink:href="/url">embedded-    link</link></title>-    <section xml:id="level-3-with-emphasis">-      <title>Level 3 with <emphasis>emphasis</emphasis></title>-      <section xml:id="level-4">-        <title>Level 4</title>-        <section xml:id="level-5">-          <title>Level 5</title>-          <para>-          </para>-        </section>-      </section>-    </section>-  </section>-</section>-<section xml:id="level-1">-  <title>Level 1</title>-  <section xml:id="level-2-with-emphasis">-    <title>Level 2 with <emphasis>emphasis</emphasis></title>-    <section xml:id="level-3">-      <title>Level 3</title>-      <para>-        with no blank line-      </para>-    </section>-  </section>-  <section xml:id="level-2">-    <title>Level 2</title>-    <para>-      with no blank line-    </para>-  </section>-</section>-<section xml:id="paragraphs">-  <title>Paragraphs</title>-  <para>-    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.-  </para>-  <para>-    Here’s one with a bullet. * criminey.-  </para>-<literallayout>There should be a hard line break-here.</literallayout>-</section>-<section xml:id="block-quotes">-  <title>Block Quotes</title>-  <para>-    E-mail style:-  </para>-  <blockquote>-    <para>-      This is a block quote. It is pretty short.-    </para>-  </blockquote>-  <blockquote>-    <para>-      Code in a block quote:-    </para>-    <programlisting>-sub status {-    print &quot;working&quot;;-}-</programlisting>-    <para>-      A list:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          item one-        </para>-      </listitem>-      <listitem>-        <para>-          item two-        </para>-      </listitem>-    </orderedlist>-    <para>-      Nested block quotes:-    </para>-    <blockquote>-      <para>-        nested-      </para>-    </blockquote>-    <blockquote>-      <para>-        nested-      </para>-    </blockquote>-  </blockquote>-  <para>-    This should not be a block quote: 2 &gt; 1.-  </para>-  <para>-    And a following paragraph.-  </para>-</section>-<section xml:id="code-blocks">-  <title>Code Blocks</title>-  <para>-    Code:-  </para>-  <programlisting>----- (should be four hyphens)--sub status {-    print &quot;working&quot;;-}--this code block is indented by one tab-</programlisting>-  <para>-    And:-  </para>-  <programlisting>-    this code block is indented by two tabs--These should not be escaped:  \$ \\ \&gt; \[ \{-</programlisting>-</section>-<section xml:id="lists">-  <title>Lists</title>-  <section xml:id="unordered">-    <title>Unordered</title>-    <para>-      Asterisks tight:-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          asterisk 1-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 2-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Asterisks loose:-    </para>-    <itemizedlist>-      <listitem>-        <para>-          asterisk 1-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 2-        </para>-      </listitem>-      <listitem>-        <para>-          asterisk 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Pluses tight:-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          Plus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Pluses loose:-    </para>-    <itemizedlist>-      <listitem>-        <para>-          Plus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Plus 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Minuses tight:-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          Minus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 3-        </para>-      </listitem>-    </itemizedlist>-    <para>-      Minuses loose:-    </para>-    <itemizedlist>-      <listitem>-        <para>-          Minus 1-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 2-        </para>-      </listitem>-      <listitem>-        <para>-          Minus 3-        </para>-      </listitem>-    </itemizedlist>-  </section>-  <section xml:id="ordered">-    <title>Ordered</title>-    <para>-      Tight:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second-        </para>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-    <para>-      and:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          One-        </para>-      </listitem>-      <listitem>-        <para>-          Two-        </para>-      </listitem>-      <listitem>-        <para>-          Three-        </para>-      </listitem>-    </orderedlist>-    <para>-      Loose using tabs:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second-        </para>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-    <para>-      and using spaces:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          One-        </para>-      </listitem>-      <listitem>-        <para>-          Two-        </para>-      </listitem>-      <listitem>-        <para>-          Three-        </para>-      </listitem>-    </orderedlist>-    <para>-      Multiple paragraphs:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          Item 1, graf one.-        </para>-        <para>-          Item 1. graf two. The quick brown fox jumped over the lazy dog’s-          back.-        </para>-      </listitem>-      <listitem>-        <para>-          Item 2.-        </para>-      </listitem>-      <listitem>-        <para>-          Item 3.-        </para>-      </listitem>-    </orderedlist>-  </section>-  <section xml:id="nested">-    <title>Nested</title>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          Tab-        </para>-        <itemizedlist spacing="compact">-          <listitem>-            <para>-              Tab-            </para>-            <itemizedlist spacing="compact">-              <listitem>-                <para>-                  Tab-                </para>-              </listitem>-            </itemizedlist>-          </listitem>-        </itemizedlist>-      </listitem>-    </itemizedlist>-    <para>-      Here’s another:-    </para>-    <orderedlist numeration="arabic" spacing="compact">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second:-        </para>-        <itemizedlist spacing="compact">-          <listitem>-            <para>-              Fee-            </para>-          </listitem>-          <listitem>-            <para>-              Fie-            </para>-          </listitem>-          <listitem>-            <para>-              Foe-            </para>-          </listitem>-        </itemizedlist>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-    <para>-      Same thing but with paragraphs:-    </para>-    <orderedlist numeration="arabic">-      <listitem>-        <para>-          First-        </para>-      </listitem>-      <listitem>-        <para>-          Second:-        </para>-        <itemizedlist spacing="compact">-          <listitem>-            <para>-              Fee-            </para>-          </listitem>-          <listitem>-            <para>-              Fie-            </para>-          </listitem>-          <listitem>-            <para>-              Foe-            </para>-          </listitem>-        </itemizedlist>-      </listitem>-      <listitem>-        <para>-          Third-        </para>-      </listitem>-    </orderedlist>-  </section>-  <section xml:id="tabs-and-spaces">-    <title>Tabs and spaces</title>-    <itemizedlist>-      <listitem>-        <para>-          this is a list item indented with tabs-        </para>-      </listitem>-      <listitem>-        <para>-          this is a list item indented with spaces-        </para>-        <itemizedlist>-          <listitem>-            <para>-              this is an example list item indented with tabs-            </para>-          </listitem>-          <listitem>-            <para>-              this is an example list item indented with spaces-            </para>-          </listitem>-        </itemizedlist>-      </listitem>-    </itemizedlist>-  </section>-  <section xml:id="fancy-list-markers">-    <title>Fancy list markers</title>-    <orderedlist numeration="arabic">-      <listitem override="2">-        <para>-          begins with 2-        </para>-      </listitem>-      <listitem>-        <para>-          and now 3-        </para>-        <para>-          with a continuation-        </para>-        <orderedlist numeration="lowerroman" spacing="compact">-          <listitem override="4">-            <para>-              sublist with roman numerals, starting with 4-            </para>-          </listitem>-          <listitem>-            <para>-              more items-            </para>-            <orderedlist numeration="upperalpha" spacing="compact">-              <listitem>-                <para>-                  a subsublist-                </para>-              </listitem>-              <listitem>-                <para>-                  a subsublist-                </para>-              </listitem>-            </orderedlist>-          </listitem>-        </orderedlist>-      </listitem>-    </orderedlist>-    <para>-      Nesting:-    </para>-    <orderedlist numeration="upperalpha" spacing="compact">-      <listitem>-        <para>-          Upper Alpha-        </para>-        <orderedlist numeration="upperroman" spacing="compact">-          <listitem>-            <para>-              Upper Roman.-            </para>-            <orderedlist numeration="arabic" spacing="compact">-              <listitem override="6">-                <para>-                  Decimal start with 6-                </para>-                <orderedlist numeration="loweralpha" spacing="compact">-                  <listitem override="3">-                    <para>-                      Lower alpha with paren-                    </para>-                  </listitem>-                </orderedlist>-              </listitem>-            </orderedlist>-          </listitem>-        </orderedlist>-      </listitem>-    </orderedlist>-    <para>-      Autonumbering:-    </para>-    <orderedlist spacing="compact">-      <listitem>-        <para>-          Autonumber.-        </para>-      </listitem>-      <listitem>-        <para>-          More.-        </para>-        <orderedlist spacing="compact">-          <listitem>-            <para>-              Nested.-            </para>-          </listitem>-        </orderedlist>-      </listitem>-    </orderedlist>-    <para>-      Should not be a list item:-    </para>-    <para>-      M.A. 2007-    </para>-    <para>-      B. Williams-    </para>-  </section>-</section>-<section xml:id="definition-lists">-  <title>Definition Lists</title>-  <para>-    Tight using spaces:-  </para>-  <variablelist spacing="compact">-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        banana-      </term>-      <listitem>-        <para>-          yellow fruit-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Tight using tabs:-  </para>-  <variablelist spacing="compact">-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        banana-      </term>-      <listitem>-        <para>-          yellow fruit-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Loose:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        banana-      </term>-      <listitem>-        <para>-          yellow fruit-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Multiple blocks with italics:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        <emphasis>apple</emphasis>-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          contains seeds, crisp, pleasant to taste-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        <emphasis>orange</emphasis>-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <programlisting>-{ orange code block }-</programlisting>-        <blockquote>-          <para>-            orange block quote-          </para>-        </blockquote>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Multiple definitions, tight:-  </para>-  <variablelist spacing="compact">-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          computer-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <para>-          bank-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Multiple definitions, loose:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          computer-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <para>-          bank-        </para>-      </listitem>-    </varlistentry>-  </variablelist>-  <para>-    Blank line after term, indented marker, alternate markers:-  </para>-  <variablelist>-    <varlistentry>-      <term>-        apple-      </term>-      <listitem>-        <para>-          red fruit-        </para>-        <para>-          computer-        </para>-      </listitem>-    </varlistentry>-    <varlistentry>-      <term>-        orange-      </term>-      <listitem>-        <para>-          orange fruit-        </para>-        <orderedlist numeration="arabic" spacing="compact">-          <listitem>-            <para>-              sublist-            </para>-          </listitem>-          <listitem>-            <para>-              sublist-            </para>-          </listitem>-        </orderedlist>-      </listitem>-    </varlistentry>-  </variablelist>-</section>-<section xml:id="html-blocks">-  <title>HTML Blocks</title>-  <para>-    Simple block on one line:-  </para>-  <para>-    foo-  </para>-  <para>-    And nested without indentation:-  </para>-  <para>-    foo-  </para>-  <para>-    bar-  </para>-  <para>-    Interpreted markdown in a table:-  </para>-  This is <emphasis>emphasized</emphasis>-  And this is <emphasis role="strong">strong</emphasis>-  <para>-    Here’s a simple block:-  </para>-  <para>-    foo-  </para>-  <para>-    This should be a code block, though:-  </para>-  <programlisting>-&lt;div&gt;-    foo-&lt;/div&gt;-</programlisting>-  <para>-    As should this:-  </para>-  <programlisting>-&lt;div&gt;foo&lt;/div&gt;-</programlisting>-  <para>-    Now, nested:-  </para>-  <para>-    foo-  </para>-  <para>-    This should just be an HTML comment:-  </para>-  <para>-    Multiline:-  </para>-  <para>-    Code block:-  </para>-  <programlisting>-&lt;!-- Comment --&gt;-</programlisting>-  <para>-    Just plain comment, with trailing spaces on the line:-  </para>-  <para>-    Code:-  </para>-  <programlisting>-&lt;hr /&gt;-</programlisting>-  <para>-    Hr’s:-  </para>-</section>-<section xml:id="inline-markup">-  <title>Inline Markup</title>-  <para>-    This is <emphasis>emphasized</emphasis>, and so <emphasis>is-    this</emphasis>.-  </para>-  <para>-    This is <emphasis role="strong">strong</emphasis>, and so-    <emphasis role="strong">is this</emphasis>.-  </para>-  <para>-    An <emphasis><link xlink:href="/url">emphasized link</link></emphasis>.-  </para>-  <para>-    <emphasis role="strong"><emphasis>This is strong and-    em.</emphasis></emphasis>-  </para>-  <para>-    So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.-  </para>-  <para>-    <emphasis role="strong"><emphasis>This is strong and-    em.</emphasis></emphasis>-  </para>-  <para>-    So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.-  </para>-  <para>-    This is code: <literal>&gt;</literal>, <literal>$</literal>,-    <literal>\</literal>, <literal>\$</literal>,-    <literal>&lt;html&gt;</literal>.-  </para>-  <para>-    <emphasis role="strikethrough">This is-    <emphasis>strikeout</emphasis>.</emphasis>-  </para>-  <para>-    Superscripts: a<superscript>bc</superscript>d-    a<superscript><emphasis>hello</emphasis></superscript>-    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.-  </para>-  <para>-    These should not be superscripts or subscripts, because of the unescaped-    spaces: a^b c^d, a~b c~d.-  </para>-</section>-<section xml: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>-  </para>-  <para>-    <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>-  </para>-  <para>-    <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><link xlink:href="http://example.com/?foo=1&amp;bar=2">quoted-    link</link></quote>.-  </para>-  <para>-    Some dashes: one—two — three—four — five.-  </para>-  <para>-    Dashes between numbers: 5–7, 255–66, 1987–1999.-  </para>-  <para>-    Ellipses…and…and….-  </para>-</section>-<section xml:id="latex">-  <title>LaTeX</title>-  <itemizedlist spacing="compact">-    <listitem>-      <para>-      </para>-    </listitem>-    <listitem>-      <para>-        2 + 2 = 4-      </para>-    </listitem>-    <listitem>-      <para>-        <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>-      </para>-    </listitem>-    <listitem>-      <para>-        <emphasis>α</emphasis> ∧ <emphasis>ω</emphasis>-      </para>-    </listitem>-    <listitem>-      <para>-        223-      </para>-    </listitem>-    <listitem>-      <para>-        <emphasis>p</emphasis>-Tree-      </para>-    </listitem>-    <listitem>-      <para>-        Here’s some display math:-        $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$-      </para>-    </listitem>-    <listitem>-      <para>-        Here’s one that has a line break in it:-        <emphasis>α</emphasis> + <emphasis>ω</emphasis> × <emphasis>x</emphasis><superscript>2</superscript>.-      </para>-    </listitem>-  </itemizedlist>-  <para>-    These shouldn’t be math:-  </para>-  <itemizedlist spacing="compact">-    <listitem>-      <para>-        To get the famous equation, write <literal>$e = mc^2$</literal>.-      </para>-    </listitem>-    <listitem>-      <para>-        $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It-        worked if <quote>lot</quote> is emphasized.)-      </para>-    </listitem>-    <listitem>-      <para>-        Shoes ($20) and socks ($5).-      </para>-    </listitem>-    <listitem>-      <para>-        Escaped <literal>$</literal>: $73 <emphasis>this should be-        emphasized</emphasis> 23$.-      </para>-    </listitem>-  </itemizedlist>-  <para>-    Here’s a LaTeX table:-  </para>-</section>-<section xml:id="special-characters">-  <title>Special Characters</title>-  <para>-    Here is some unicode:-  </para>-  <itemizedlist spacing="compact">-    <listitem>-      <para>-        I hat: Î-      </para>-    </listitem>-    <listitem>-      <para>-        o umlaut: ö-      </para>-    </listitem>-    <listitem>-      <para>-        section: §-      </para>-    </listitem>-    <listitem>-      <para>-        set membership: ∈-      </para>-    </listitem>-    <listitem>-      <para>-        copyright: ©-      </para>-    </listitem>-  </itemizedlist>-  <para>-    AT&amp;T has an ampersand in their name.-  </para>-  <para>-    AT&amp;T is another way to write it.-  </para>-  <para>-    This &amp; that.-  </para>-  <para>-    4 &lt; 5.-  </para>-  <para>-    6 &gt; 5.-  </para>-  <para>-    Backslash: \-  </para>-  <para>-    Backtick: `-  </para>-  <para>-    Asterisk: *-  </para>-  <para>-    Underscore: _-  </para>-  <para>-    Left brace: {-  </para>-  <para>-    Right brace: }-  </para>-  <para>-    Left bracket: [-  </para>-  <para>-    Right bracket: ]-  </para>-  <para>-    Left paren: (-  </para>-  <para>-    Right paren: )-  </para>-  <para>-    Greater-than: &gt;-  </para>-  <para>-    Hash: #-  </para>-  <para>-    Period: .-  </para>-  <para>-    Bang: !-  </para>-  <para>-    Plus: +-  </para>-  <para>-    Minus: --  </para>-</section>-<section xml:id="links">-  <title>Links</title>-  <section xml:id="explicit">-    <title>Explicit</title>-    <para>-      Just a <link xlink:href="/url/">URL</link>.-    </para>-    <para>-      <link xlink:href="/url/">URL and title</link>.-    </para>-    <para>-      <link xlink:href="/url/">URL and title</link>.-    </para>-    <para>-      <link xlink:href="/url/">URL and title</link>.-    </para>-    <para>-      <link xlink:href="/url/">URL and title</link>-    </para>-    <para>-      <link xlink:href="/url/">URL and title</link>-    </para>-    <para>-      <link xlink:href="/url/with_underscore">with_underscore</link>-    </para>-    <para>-      Email link (<email>nobody@nowhere.net</email>)-    </para>-    <para>-      <link xlink:href="">Empty</link>.-    </para>-  </section>-  <section xml:id="reference">-    <title>Reference</title>-    <para>-      Foo <link xlink:href="/url/">bar</link>.-    </para>-    <para>-      With <link xlink:href="/url/">embedded [brackets]</link>.-    </para>-    <para>-      <link xlink:href="/url/">b</link> by itself should be a link.-    </para>-    <para>-      Indented <link xlink:href="/url">once</link>.-    </para>-    <para>-      Indented <link xlink:href="/url">twice</link>.-    </para>-    <para>-      Indented <link xlink:href="/url">thrice</link>.-    </para>-    <para>-      This should [not][] be a link.-    </para>-    <programlisting>-[not]: /url-</programlisting>-    <para>-      Foo <link xlink:href="/url/">bar</link>.-    </para>-    <para>-      Foo <link xlink:href="/url/">biz</link>.-    </para>-  </section>-  <section xml:id="with-ampersands">-    <title>With ampersands</title>-    <para>-      Here’s a <link xlink:href="http://example.com/?foo=1&amp;bar=2">link-      with an ampersand in the URL</link>.-    </para>-    <para>-      Here’s a link with an amersand in the link text:-      <link xlink:href="http://att.com/">AT&amp;T</link>.-    </para>-    <para>-      Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link</link>.-    </para>-    <para>-      Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link in-      pointy braces</link>.-    </para>-  </section>-  <section xml:id="autolinks">-    <title>Autolinks</title>-    <para>-      With an ampersand:-      <link xlink:href="http://example.com/?foo=1&amp;bar=2" role="uri">http://example.com/?foo=1&amp;bar=2</link>-    </para>-    <itemizedlist spacing="compact">-      <listitem>-        <para>-          In a list?-        </para>-      </listitem>-      <listitem>-        <para>-          <link xlink:href="http://example.com/" role="uri">http://example.com/</link>-        </para>-      </listitem>-      <listitem>-        <para>-          It should.-        </para>-      </listitem>-    </itemizedlist>-    <para>-      An e-mail address: <email>nobody@nowhere.net</email>-    </para>-    <blockquote>-      <para>-        Blockquoted:-        <link xlink:href="http://example.com/" role="uri">http://example.com/</link>-      </para>-    </blockquote>-    <para>-      Auto-links should not occur here:-      <literal>&lt;http://example.com/&gt;</literal>-    </para>-    <programlisting>-or here: &lt;http://example.com/&gt;-</programlisting>-  </section>-</section>-<section xml:id="images">-  <title>Images</title>-  <para>-    From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):-  </para>-  <figure>-    <title>lalune</title>-    <mediaobject>-      <imageobject>-        <imagedata fileref="lalune.jpg" />-      </imageobject>-      <textobject><phrase>lalune</phrase></textobject>-    </mediaobject>-  </figure>-  <para>-    Here is a movie <inlinemediaobject>-      <imageobject>-        <imagedata fileref="movie.jpg" />-      </imageobject>-    </inlinemediaobject> icon.-  </para>-</section>-<section xml: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>-      <programlisting>-  { &lt;code&gt; }-</programlisting>-      <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-        <link xlink:href="http://google.com">links</link> 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>-    </para>-  </blockquote>-  <orderedlist numeration="arabic" spacing="compact">-    <listitem>-      <para>-        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.-  </para>-</section>+  <para>+    This is a set of tests for pandoc. Most of them are adapted from John+    Gruber’s markdown test suite.+  </para>+  <section xml:id="headers">+    <title>Headers</title>+    <section xml:id="level-2-with-an-embedded-link">+      <title>Level 2 with an <link xlink:href="/url">embedded+      link</link></title>+      <section xml:id="level-3-with-emphasis">+        <title>Level 3 with <emphasis>emphasis</emphasis></title>+        <section xml:id="level-4">+          <title>Level 4</title>+          <section xml:id="level-5">+            <title>Level 5</title>+            <para>+            </para>+          </section>+        </section>+      </section>+    </section>+  </section>+  <section xml:id="level-1">+    <title>Level 1</title>+    <section xml:id="level-2-with-emphasis">+      <title>Level 2 with <emphasis>emphasis</emphasis></title>+      <section xml:id="level-3">+        <title>Level 3</title>+        <para>+          with no blank line+        </para>+      </section>+    </section>+    <section xml:id="level-2">+      <title>Level 2</title>+      <para>+        with no blank line+      </para>+    </section>+  </section>+  <section xml:id="paragraphs">+    <title>Paragraphs</title>+    <para>+      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.+    </para>+    <para>+      Here’s one with a bullet. * criminey.+    </para>+<literallayout>There should be a hard line break+here.</literallayout>+  </section>+  <section xml:id="block-quotes">+    <title>Block Quotes</title>+    <para>+      E-mail style:+    </para>+    <blockquote>+      <para>+        This is a block quote. It is pretty short.+      </para>+    </blockquote>+    <blockquote>+      <para>+        Code in a block quote:+      </para>+      <programlisting>+sub status {+    print &quot;working&quot;;+}+</programlisting>+      <para>+        A list:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            item one+          </para>+        </listitem>+        <listitem>+          <para>+            item two+          </para>+        </listitem>+      </orderedlist>+      <para>+        Nested block quotes:+      </para>+      <blockquote>+        <para>+          nested+        </para>+      </blockquote>+      <blockquote>+        <para>+          nested+        </para>+      </blockquote>+    </blockquote>+    <para>+      This should not be a block quote: 2 &gt; 1.+    </para>+    <para>+      And a following paragraph.+    </para>+  </section>+  <section xml:id="code-blocks">+    <title>Code Blocks</title>+    <para>+      Code:+    </para>+    <programlisting>+---- (should be four hyphens)++sub status {+    print &quot;working&quot;;+}++this code block is indented by one tab+</programlisting>+    <para>+      And:+    </para>+    <programlisting>+    this code block is indented by two tabs++These should not be escaped:  \$ \\ \&gt; \[ \{+</programlisting>+  </section>+  <section xml:id="lists">+    <title>Lists</title>+    <section xml:id="unordered">+      <title>Unordered</title>+      <para>+        Asterisks tight:+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            asterisk 1+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 2+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Asterisks loose:+      </para>+      <itemizedlist>+        <listitem>+          <para>+            asterisk 1+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 2+          </para>+        </listitem>+        <listitem>+          <para>+            asterisk 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Pluses tight:+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            Plus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Pluses loose:+      </para>+      <itemizedlist>+        <listitem>+          <para>+            Plus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Plus 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Minuses tight:+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            Minus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 3+          </para>+        </listitem>+      </itemizedlist>+      <para>+        Minuses loose:+      </para>+      <itemizedlist>+        <listitem>+          <para>+            Minus 1+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 2+          </para>+        </listitem>+        <listitem>+          <para>+            Minus 3+          </para>+        </listitem>+      </itemizedlist>+    </section>+    <section xml:id="ordered">+      <title>Ordered</title>+      <para>+        Tight:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second+          </para>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+      <para>+        and:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            One+          </para>+        </listitem>+        <listitem>+          <para>+            Two+          </para>+        </listitem>+        <listitem>+          <para>+            Three+          </para>+        </listitem>+      </orderedlist>+      <para>+        Loose using tabs:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second+          </para>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+      <para>+        and using spaces:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            One+          </para>+        </listitem>+        <listitem>+          <para>+            Two+          </para>+        </listitem>+        <listitem>+          <para>+            Three+          </para>+        </listitem>+      </orderedlist>+      <para>+        Multiple paragraphs:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            Item 1, graf one.+          </para>+          <para>+            Item 1. graf two. The quick brown fox jumped over the lazy dog’s+            back.+          </para>+        </listitem>+        <listitem>+          <para>+            Item 2.+          </para>+        </listitem>+        <listitem>+          <para>+            Item 3.+          </para>+        </listitem>+      </orderedlist>+    </section>+    <section xml:id="nested">+      <title>Nested</title>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            Tab+          </para>+          <itemizedlist spacing="compact">+            <listitem>+              <para>+                Tab+              </para>+              <itemizedlist spacing="compact">+                <listitem>+                  <para>+                    Tab+                  </para>+                </listitem>+              </itemizedlist>+            </listitem>+          </itemizedlist>+        </listitem>+      </itemizedlist>+      <para>+        Here’s another:+      </para>+      <orderedlist numeration="arabic" spacing="compact">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second:+          </para>+          <itemizedlist spacing="compact">+            <listitem>+              <para>+                Fee+              </para>+            </listitem>+            <listitem>+              <para>+                Fie+              </para>+            </listitem>+            <listitem>+              <para>+                Foe+              </para>+            </listitem>+          </itemizedlist>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+      <para>+        Same thing but with paragraphs:+      </para>+      <orderedlist numeration="arabic">+        <listitem>+          <para>+            First+          </para>+        </listitem>+        <listitem>+          <para>+            Second:+          </para>+          <itemizedlist spacing="compact">+            <listitem>+              <para>+                Fee+              </para>+            </listitem>+            <listitem>+              <para>+                Fie+              </para>+            </listitem>+            <listitem>+              <para>+                Foe+              </para>+            </listitem>+          </itemizedlist>+        </listitem>+        <listitem>+          <para>+            Third+          </para>+        </listitem>+      </orderedlist>+    </section>+    <section xml:id="tabs-and-spaces">+      <title>Tabs and spaces</title>+      <itemizedlist>+        <listitem>+          <para>+            this is a list item indented with tabs+          </para>+        </listitem>+        <listitem>+          <para>+            this is a list item indented with spaces+          </para>+          <itemizedlist>+            <listitem>+              <para>+                this is an example list item indented with tabs+              </para>+            </listitem>+            <listitem>+              <para>+                this is an example list item indented with spaces+              </para>+            </listitem>+          </itemizedlist>+        </listitem>+      </itemizedlist>+    </section>+    <section xml:id="fancy-list-markers">+      <title>Fancy list markers</title>+      <orderedlist numeration="arabic">+        <listitem override="2">+          <para>+            begins with 2+          </para>+        </listitem>+        <listitem>+          <para>+            and now 3+          </para>+          <para>+            with a continuation+          </para>+          <orderedlist numeration="lowerroman" spacing="compact">+            <listitem override="4">+              <para>+                sublist with roman numerals, starting with 4+              </para>+            </listitem>+            <listitem>+              <para>+                more items+              </para>+              <orderedlist numeration="upperalpha" spacing="compact">+                <listitem>+                  <para>+                    a subsublist+                  </para>+                </listitem>+                <listitem>+                  <para>+                    a subsublist+                  </para>+                </listitem>+              </orderedlist>+            </listitem>+          </orderedlist>+        </listitem>+      </orderedlist>+      <para>+        Nesting:+      </para>+      <orderedlist numeration="upperalpha" spacing="compact">+        <listitem>+          <para>+            Upper Alpha+          </para>+          <orderedlist numeration="upperroman" spacing="compact">+            <listitem>+              <para>+                Upper Roman.+              </para>+              <orderedlist numeration="arabic" spacing="compact">+                <listitem override="6">+                  <para>+                    Decimal start with 6+                  </para>+                  <orderedlist numeration="loweralpha" spacing="compact">+                    <listitem override="3">+                      <para>+                        Lower alpha with paren+                      </para>+                    </listitem>+                  </orderedlist>+                </listitem>+              </orderedlist>+            </listitem>+          </orderedlist>+        </listitem>+      </orderedlist>+      <para>+        Autonumbering:+      </para>+      <orderedlist spacing="compact">+        <listitem>+          <para>+            Autonumber.+          </para>+        </listitem>+        <listitem>+          <para>+            More.+          </para>+          <orderedlist spacing="compact">+            <listitem>+              <para>+                Nested.+              </para>+            </listitem>+          </orderedlist>+        </listitem>+      </orderedlist>+      <para>+        Should not be a list item:+      </para>+      <para>+        M.A. 2007+      </para>+      <para>+        B. Williams+      </para>+    </section>+  </section>+  <section xml:id="definition-lists">+    <title>Definition Lists</title>+    <para>+      Tight using spaces:+    </para>+    <variablelist spacing="compact">+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          banana+        </term>+        <listitem>+          <para>+            yellow fruit+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Tight using tabs:+    </para>+    <variablelist spacing="compact">+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          banana+        </term>+        <listitem>+          <para>+            yellow fruit+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Loose:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          banana+        </term>+        <listitem>+          <para>+            yellow fruit+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Multiple blocks with italics:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          <emphasis>apple</emphasis>+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            contains seeds, crisp, pleasant to taste+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          <emphasis>orange</emphasis>+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <programlisting>+{ orange code block }+</programlisting>+          <blockquote>+            <para>+              orange block quote+            </para>+          </blockquote>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Multiple definitions, tight:+    </para>+    <variablelist spacing="compact">+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            computer+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <para>+            bank+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Multiple definitions, loose:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            computer+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <para>+            bank+          </para>+        </listitem>+      </varlistentry>+    </variablelist>+    <para>+      Blank line after term, indented marker, alternate markers:+    </para>+    <variablelist>+      <varlistentry>+        <term>+          apple+        </term>+        <listitem>+          <para>+            red fruit+          </para>+          <para>+            computer+          </para>+        </listitem>+      </varlistentry>+      <varlistentry>+        <term>+          orange+        </term>+        <listitem>+          <para>+            orange fruit+          </para>+          <orderedlist numeration="arabic" spacing="compact">+            <listitem>+              <para>+                sublist+              </para>+            </listitem>+            <listitem>+              <para>+                sublist+              </para>+            </listitem>+          </orderedlist>+        </listitem>+      </varlistentry>+    </variablelist>+  </section>+  <section xml:id="html-blocks">+    <title>HTML Blocks</title>+    <para>+      Simple block on one line:+    </para>+    <para>+      foo+    </para>+    <para>+      And nested without indentation:+    </para>+    <para>+      foo+    </para>+    <para>+      bar+    </para>+    <para>+      Interpreted markdown in a table:+    </para>+    This is <emphasis>emphasized</emphasis>+    And this is <emphasis role="strong">strong</emphasis>+    <para>+      Here’s a simple block:+    </para>+    <para>+      foo+    </para>+    <para>+      This should be a code block, though:+    </para>+    <programlisting>+&lt;div&gt;+    foo+&lt;/div&gt;+</programlisting>+    <para>+      As should this:+    </para>+    <programlisting>+&lt;div&gt;foo&lt;/div&gt;+</programlisting>+    <para>+      Now, nested:+    </para>+    <para>+      foo+    </para>+    <para>+      This should just be an HTML comment:+    </para>+    <para>+      Multiline:+    </para>+    <para>+      Code block:+    </para>+    <programlisting>+&lt;!-- Comment --&gt;+</programlisting>+    <para>+      Just plain comment, with trailing spaces on the line:+    </para>+    <para>+      Code:+    </para>+    <programlisting>+&lt;hr /&gt;+</programlisting>+    <para>+      Hr’s:+    </para>+  </section>+  <section xml:id="inline-markup">+    <title>Inline Markup</title>+    <para>+      This is <emphasis>emphasized</emphasis>, and so <emphasis>is+      this</emphasis>.+    </para>+    <para>+      This is <emphasis role="strong">strong</emphasis>, and so+      <emphasis role="strong">is this</emphasis>.+    </para>+    <para>+      An <emphasis><link xlink:href="/url">emphasized link</link></emphasis>.+    </para>+    <para>+      <emphasis role="strong"><emphasis>This is strong and+      em.</emphasis></emphasis>+    </para>+    <para>+      So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.+    </para>+    <para>+      <emphasis role="strong"><emphasis>This is strong and+      em.</emphasis></emphasis>+    </para>+    <para>+      So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.+    </para>+    <para>+      This is code: <literal>&gt;</literal>, <literal>$</literal>,+      <literal>\</literal>, <literal>\$</literal>,+      <literal>&lt;html&gt;</literal>.+    </para>+    <para>+      <emphasis role="strikethrough">This is+      <emphasis>strikeout</emphasis>.</emphasis>+    </para>+    <para>+      Superscripts: a<superscript>bc</superscript>d+      a<superscript><emphasis>hello</emphasis></superscript>+      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.+    </para>+    <para>+      These should not be superscripts or subscripts, because of the unescaped+      spaces: a^b c^d, a~b c~d.+    </para>+  </section>+  <section xml: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>+    </para>+    <para>+      <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>+    </para>+    <para>+      <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><link xlink:href="http://example.com/?foo=1&amp;bar=2">quoted+      link</link></quote>.+    </para>+    <para>+      Some dashes: one—two — three—four — five.+    </para>+    <para>+      Dashes between numbers: 5–7, 255–66, 1987–1999.+    </para>+    <para>+      Ellipses…and…and….+    </para>+  </section>+  <section xml:id="latex">+    <title>LaTeX</title>+    <itemizedlist spacing="compact">+      <listitem>+        <para>+        </para>+      </listitem>+      <listitem>+        <para>+          2 + 2 = 4+        </para>+      </listitem>+      <listitem>+        <para>+          <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>+        </para>+      </listitem>+      <listitem>+        <para>+          <emphasis>α</emphasis> ∧ <emphasis>ω</emphasis>+        </para>+      </listitem>+      <listitem>+        <para>+          223+        </para>+      </listitem>+      <listitem>+        <para>+          <emphasis>p</emphasis>-Tree+        </para>+      </listitem>+      <listitem>+        <para>+          Here’s some display math:+          $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$+        </para>+      </listitem>+      <listitem>+        <para>+          Here’s one that has a line break in it:+          <emphasis>α</emphasis> + <emphasis>ω</emphasis> × <emphasis>x</emphasis><superscript>2</superscript>.+        </para>+      </listitem>+    </itemizedlist>+    <para>+      These shouldn’t be math:+    </para>+    <itemizedlist spacing="compact">+      <listitem>+        <para>+          To get the famous equation, write <literal>$e = mc^2$</literal>.+        </para>+      </listitem>+      <listitem>+        <para>+          $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It+          worked if <quote>lot</quote> is emphasized.)+        </para>+      </listitem>+      <listitem>+        <para>+          Shoes ($20) and socks ($5).+        </para>+      </listitem>+      <listitem>+        <para>+          Escaped <literal>$</literal>: $73 <emphasis>this should be+          emphasized</emphasis> 23$.+        </para>+      </listitem>+    </itemizedlist>+    <para>+      Here’s a LaTeX table:+    </para>+  </section>+  <section xml:id="special-characters">+    <title>Special Characters</title>+    <para>+      Here is some unicode:+    </para>+    <itemizedlist spacing="compact">+      <listitem>+        <para>+          I hat: Î+        </para>+      </listitem>+      <listitem>+        <para>+          o umlaut: ö+        </para>+      </listitem>+      <listitem>+        <para>+          section: §+        </para>+      </listitem>+      <listitem>+        <para>+          set membership: ∈+        </para>+      </listitem>+      <listitem>+        <para>+          copyright: ©+        </para>+      </listitem>+    </itemizedlist>+    <para>+      AT&amp;T has an ampersand in their name.+    </para>+    <para>+      AT&amp;T is another way to write it.+    </para>+    <para>+      This &amp; that.+    </para>+    <para>+      4 &lt; 5.+    </para>+    <para>+      6 &gt; 5.+    </para>+    <para>+      Backslash: \+    </para>+    <para>+      Backtick: `+    </para>+    <para>+      Asterisk: *+    </para>+    <para>+      Underscore: _+    </para>+    <para>+      Left brace: {+    </para>+    <para>+      Right brace: }+    </para>+    <para>+      Left bracket: [+    </para>+    <para>+      Right bracket: ]+    </para>+    <para>+      Left paren: (+    </para>+    <para>+      Right paren: )+    </para>+    <para>+      Greater-than: &gt;+    </para>+    <para>+      Hash: #+    </para>+    <para>+      Period: .+    </para>+    <para>+      Bang: !+    </para>+    <para>+      Plus: ++    </para>+    <para>+      Minus: -+    </para>+  </section>+  <section xml:id="links">+    <title>Links</title>+    <section xml:id="explicit">+      <title>Explicit</title>+      <para>+        Just a <link xlink:href="/url/">URL</link>.+      </para>+      <para>+        <link xlink:href="/url/">URL and title</link>.+      </para>+      <para>+        <link xlink:href="/url/">URL and title</link>.+      </para>+      <para>+        <link xlink:href="/url/">URL and title</link>.+      </para>+      <para>+        <link xlink:href="/url/">URL and title</link>+      </para>+      <para>+        <link xlink:href="/url/">URL and title</link>+      </para>+      <para>+        <link xlink:href="/url/with_underscore">with_underscore</link>+      </para>+      <para>+        Email link (<email>nobody@nowhere.net</email>)+      </para>+      <para>+        <link xlink:href="">Empty</link>.+      </para>+    </section>+    <section xml:id="reference">+      <title>Reference</title>+      <para>+        Foo <link xlink:href="/url/">bar</link>.+      </para>+      <para>+        With <link xlink:href="/url/">embedded [brackets]</link>.+      </para>+      <para>+        <link xlink:href="/url/">b</link> by itself should be a link.+      </para>+      <para>+        Indented <link xlink:href="/url">once</link>.+      </para>+      <para>+        Indented <link xlink:href="/url">twice</link>.+      </para>+      <para>+        Indented <link xlink:href="/url">thrice</link>.+      </para>+      <para>+        This should [not][] be a link.+      </para>+      <programlisting>+[not]: /url+</programlisting>+      <para>+        Foo <link xlink:href="/url/">bar</link>.+      </para>+      <para>+        Foo <link xlink:href="/url/">biz</link>.+      </para>+    </section>+    <section xml:id="with-ampersands">+      <title>With ampersands</title>+      <para>+        Here’s a <link xlink:href="http://example.com/?foo=1&amp;bar=2">link+        with an ampersand in the URL</link>.+      </para>+      <para>+        Here’s a link with an amersand in the link text:+        <link xlink:href="http://att.com/">AT&amp;T</link>.+      </para>+      <para>+        Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline+        link</link>.+      </para>+      <para>+        Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link in+        pointy braces</link>.+      </para>+    </section>+    <section xml:id="autolinks">+      <title>Autolinks</title>+      <para>+        With an ampersand:+        <link xlink:href="http://example.com/?foo=1&amp;bar=2" role="uri">http://example.com/?foo=1&amp;bar=2</link>+      </para>+      <itemizedlist spacing="compact">+        <listitem>+          <para>+            In a list?+          </para>+        </listitem>+        <listitem>+          <para>+            <link xlink:href="http://example.com/" role="uri">http://example.com/</link>+          </para>+        </listitem>+        <listitem>+          <para>+            It should.+          </para>+        </listitem>+      </itemizedlist>+      <para>+        An e-mail address: <email>nobody@nowhere.net</email>+      </para>+      <blockquote>+        <para>+          Blockquoted:+          <link xlink:href="http://example.com/" role="uri">http://example.com/</link>+        </para>+      </blockquote>+      <para>+        Auto-links should not occur here:+        <literal>&lt;http://example.com/&gt;</literal>+      </para>+      <programlisting>+or here: &lt;http://example.com/&gt;+</programlisting>+    </section>+  </section>+  <section xml:id="images">+    <title>Images</title>+    <para>+      From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):+    </para>+    <figure>+      <title>lalune</title>+      <mediaobject>+        <imageobject>+          <imagedata fileref="lalune.jpg" />+        </imageobject>+        <textobject><phrase>lalune</phrase></textobject>+      </mediaobject>+    </figure>+    <para>+      Here is a movie <inlinemediaobject>+        <imageobject>+          <imagedata fileref="movie.jpg" />+        </imageobject>+      </inlinemediaobject> icon.+    </para>+  </section>+  <section xml: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>+        <programlisting>+  { &lt;code&gt; }+</programlisting>+        <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 <link xlink:href="http://google.com">links</link> 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>+      </para>+    </blockquote>+    <orderedlist numeration="arabic" spacing="compact">+      <listitem>+        <para>+          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.+    </para>+  </section> </article>
test/writer.html4 view
@@ -9,10 +9,11 @@   <meta name="date" content="2006-07-17" />   <title>Pandoc Test Suite</title>   <style type="text/css">-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}   </style> </head> <body>@@ -441,7 +442,6 @@ <li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li> </ul> <p>Here’s a LaTeX table:</p>- <hr /> <h1 id="special-characters">Special Characters</h1> <p>Here is some unicode:</p>
test/writer.html5 view
@@ -9,10 +9,11 @@   <meta name="dcterms.date" content="2006-07-17" />   <title>Pandoc Test Suite</title>   <style>-      code{white-space: pre-wrap;}-      span.smallcaps{font-variant: small-caps;}-      span.underline{text-decoration: underline;}-      div.column{display: inline-block; vertical-align: top; width: 50%;}+    code{white-space: pre-wrap;}+    span.smallcaps{font-variant: small-caps;}+    span.underline{text-decoration: underline;}+    div.column{display: inline-block; vertical-align: top; width: 50%;}+    div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}   </style>   <!--[if lt IE 9]>     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>@@ -444,7 +445,6 @@ <li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li> </ul> <p>Here’s a LaTeX table:</p>- <hr /> <h1 id="special-characters">Special Characters</h1> <p>Here is some unicode:</p>
test/writer.icml view
@@ -64,7 +64,7 @@         <Properties>           <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>         </Properties>-      </CharacterStyle> +      </CharacterStyle>     </RootCharacterStyleGroup>     <RootParagraphStyleGroup Self="pandoc_paragraph_styles">       <ParagraphStyle Self="$ID/NormalParagraphStyle" Name="$ID/NormalParagraphStyle"@@ -420,7 +420,7 @@         <Properties>           <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>         </Properties>-      </ParagraphStyle> +      </ParagraphStyle>     </RootParagraphStyleGroup>     <RootTableStyleGroup Self="pandoc_table_styles">       <TableStyle Self="TableStyle/Table" Name="Table" />
test/writer.jats view
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8" ?>-<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"+<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1 20151215//EN"                   "JATS-journalpublishing1.dtd">-<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">+<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.1" article-type="other"> <front> <journal-meta> <journal-title-group>
test/writer.jira view
@@ -1,4 +1,4 @@-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.  ---- @@ -28,11 +28,11 @@  h1. {anchor:paragraphs}Paragraphs -Here's a regular paragraph.+Here’s a regular paragraph. -In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard&hyphen;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. &ast; criminey.+Here’s one with a bullet. \* criminey.  There should be a hard line break here.@@ -41,17 +41,16 @@  h1. {anchor:block-quotes}Block Quotes -E&hyphen;mail style:+E\-mail style:  bq. This is a block quote. It is pretty short. - {quote} Code in a block quote:  {code}-sub status \{-    print &quot;working&quot;;+sub status {+    print "working"; } {code} @@ -64,14 +63,13 @@  bq. nested - bq. nested - {quote} -This should not be a block quote: 2 &gt; 1. +This should not be a block quote: 2 > 1.+ And a following paragraph.  ----@@ -81,10 +79,10 @@ Code:  {code}-&hyphen;&hyphen;&hyphen;&hyphen; (should be four hyphens)+---- (should be four hyphens) -sub status \{-    print &quot;working&quot;;+sub status {+    print "working"; }  this code block is indented by one tab@@ -95,7 +93,7 @@ {code}     this code block is indented by two tabs -These should not be escaped:  \$ \\ \&gt; \[ \\{+These should not be escaped:  \$ \\ \> \[ \{ {code}  ----@@ -169,7 +167,7 @@ Multiple paragraphs:  # 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 2. # Item 3. @@ -179,7 +177,7 @@ ** Tab *** Tab -Here's another:+Here’s another:  # First # Second:@@ -272,7 +270,7 @@ * *_orange_* orange fruit {code}-\{ orange code block }+{ orange code block } {code} bq. orange block quote @@ -327,22 +325,22 @@   -Here's a simple block:+Here’s a simple block:  foo  This should be a code block, though:  {code}-&lt;div&gt;+<div>     foo-&lt;/div&gt;+</div> {code}  As should this:  {code}-&lt;div&gt;foo&lt;/div&gt;+<div>foo</div> {code}  Now, nested:@@ -358,7 +356,7 @@ Code block:  {code}-&lt;!&hyphen;&hyphen; Comment &hyphen;&hyphen;&gt;+<!-- Comment --> {code}  Just plain comment, with trailing spaces on the line:@@ -367,10 +365,10 @@ Code:  {code}-&lt;hr /&gt;+<hr /> {code} -Hr's:+Hr’s:   @@ -399,7 +397,7 @@  So is *_this_* word. -This is code: {{&gt;}}, {{$}}, {{\}}, {{\$}}, {{&lt;html&gt;}}.+This is code: {{>}}, {{$}}, {{\}}, {{\$}}, {{<html>}}.  -This is _strikeout_.- @@ -407,7 +405,7 @@  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.  ---- @@ -419,13 +417,13 @@  'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.' -'He said, "I want to go."' Were you alive in the 70's?+'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.+Some dashes: one --- two  ---  three --- four  ---  five. -Dashes between numbers: 5 - 7, 255 - 66, 1987 - 1999.+Dashes between numbers: 5 -- 7, 255 -- 66, 1987 -- 1999.  Ellipses...and...and.... @@ -434,22 +432,22 @@ h1. {anchor:latex}LaTeX  * -* 2 &plus; 2 = 4+* 2 \+ 2 = 4 * _x_ ∈ _y_ * _α_ ∧ _ω_ * 223-* _p_&hyphen;Tree-* Here's some display math: \\$$\frac\{d}\{dx}f(x)=\lim&lowbar;\{h\to 0}\frac\{f(x&plus;h)&hyphen;f(x)}\{h}$$\\-* Here's one that has a line break in it: _α_ &plus; _ω_ × _x_{^2^}.+* _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: _α_ \+ _ω_ × _x_{^2^}. -These shouldn't be 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:+Here’s a LaTeX table:   ----@@ -464,47 +462,47 @@ * set membership: ∈ * copyright: © -AT&amp;T has an ampersand in their name.+AT&T has an ampersand in their name. -AT&amp;T is another way to write it.+AT&T is another way to write it. -This &amp; that.+This & that. -4 &lt; 5.+4 < 5. -6 &gt; 5.+6 > 5.  Backslash: \  Backtick: ` -Asterisk: &ast;+Asterisk: \* -Underscore: &lowbar;+Underscore: \_  Left brace: \{ -Right brace: }+Right brace: \} -Left bracket: [+Left bracket: \[ -Right bracket: ]+Right bracket: \]  Left paren: (  Right paren: ) -Greater&hyphen;than: &gt;+Greater\-than: >  Hash: #  Period: . -Bang: !+Bang: \! -Plus: &plus;+Plus: \+ -Minus: &hyphen;+Minus: \-  ---- @@ -524,7 +522,7 @@  [URL and title|/url/] -[with&lowbar;underscore|/url/with_underscore]+[with\_underscore|/url/with_underscore]  [Email link|mailto:nobody@nowhere.net] @@ -534,7 +532,7 @@  Foo [bar|/url/]. -With [embedded [brackets]|/url/].+With [embedded \[brackets\]|/url/].  [b|/url/] by itself should be a link. @@ -544,7 +542,7 @@  Indented [thrice|/url]. -This should [not][] be a link.+This should \[not\]\[\] be a link.  {code} [not]: /url@@ -556,31 +554,30 @@  h2. {anchor:with-ampersands}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&amp;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].+Here’s an [inline link|/script?foo=1&bar=2]. -Here's an [inline link in pointy braces|/script?foo=1&bar=2].+Here’s an [inline link in pointy braces|/script?foo=1&bar=2].  h2. {anchor:autolinks}Autolinks -With an ampersand: [http://example.com/?foo=1&amp;bar=2|http://example.com/?foo=1&bar=2]+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&hyphen;mail address: [nobody&commat;nowhere.net|mailto:nobody@nowhere.net]+An e\-mail address: [nobody@nowhere.net|mailto:nobody@nowhere.net]  bq. Blockquoted: [http://example.com/|http://example.com/] --Auto&hyphen;links should not occur here: {{&lt;http://example.com/&gt;}}+Auto\-links should not occur here: {{<http://example.com/>}}  {code}-or here: &lt;http://example.com/&gt;+or here: <http://example.com/> {code}  ----@@ -597,11 +594,10 @@  h1. {anchor:footnotes}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]  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.@@ -610,18 +606,18 @@ [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).  {code}-  \{ &lt;code&gt; }+  { <code> } {code}  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].+[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.
test/writer.latex view
@@ -43,7 +43,7 @@   pdfcreator={LaTeX via pandoc}} \urlstyle{same} % disable monospaced font for URLs \VerbatimFootnotes % allow verbatim text in footnotes-\usepackage{graphicx,grffile}+\usepackage{graphicx} \makeatletter \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}@@ -74,7 +74,7 @@ This is a set of tests for pandoc. Most of them are adapted from John Gruber's markdown test suite. -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{headers}{% \section{Headers}\label{headers}}@@ -110,7 +110,7 @@  with no blank line -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{paragraphs}{% \section{Paragraphs}\label{paragraphs}}@@ -126,7 +126,7 @@ There should be a hard line break\\ here. -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{block-quotes}{% \section{Block Quotes}\label{block-quotes}}@@ -172,7 +172,7 @@  And a following paragraph. -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{code-blocks}{% \section{Code Blocks}\label{code-blocks}}@@ -197,7 +197,7 @@ These should not be escaped:  \$ \\ \> \[ \{ \end{verbatim} -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{lists}{% \section{Lists}\label{lists}}@@ -511,7 +511,7 @@  B. Williams -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{definition-lists}{% \section{Definition Lists}\label{definition-lists}}@@ -678,7 +678,7 @@  Hr's: -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{inline-markup}{% \section{Inline Markup}\label{inline-markup}}@@ -711,7 +711,7 @@ These should not be superscripts or subscripts, because of the unescaped spaces: a\^{}b c\^{}d, a\textasciitilde b c\textasciitilde d. -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{smart-quotes-ellipses-dashes}{% \section{Smart quotes, ellipses, dashes}\label{smart-quotes-ellipses-dashes}}@@ -733,7 +733,7 @@  Ellipses\ldots and\ldots and\ldots. -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{latex}{% \section{LaTeX}\label{latex}}@@ -782,7 +782,7 @@ Cat    & 1      \\ \hline \end{tabular} -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{special-characters}{% \section{Special Characters}\label{special-characters}}@@ -845,7 +845,7 @@  Minus: - -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{links}{% \section{Links}\label{links}}@@ -938,7 +938,7 @@ or here: <http://example.com/> \end{verbatim} -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{images}{% \section{Images}\label{images}}@@ -953,7 +953,7 @@  Here is a movie \includegraphics{movie.jpg} icon. -\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}+\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}  \hypertarget{footnotes}{% \section{Footnotes}\label{footnotes}}
test/writer.man view
@@ -6,7 +6,7 @@ .PP    *   *   *   *   * .SH Headers-.SS Level 2 with an embedded link (/url)+.SS Level 2 with an embedded link .SS Level 3 with \f[I]emphasis\f[R] .SS Level 4 .SS Level 5@@ -318,47 +318,47 @@ .PP Tight using spaces: .TP-.B apple+apple red fruit .TP-.B orange+orange orange fruit .TP-.B banana+banana yellow fruit .PP Tight using tabs: .TP-.B apple+apple red fruit .TP-.B orange+orange orange fruit .TP-.B banana+banana yellow fruit .PP Loose: .TP-.B apple+apple red fruit .TP-.B orange+orange orange fruit .TP-.B banana+banana yellow fruit .PP Multiple blocks with italics: .TP-.B \f[I]apple\f[R]+\f[I]apple\f[R] red fruit .RS .PP contains seeds, crisp, pleasant to taste .RE .TP-.B \f[I]orange\f[R]+\f[I]orange\f[R] orange fruit .RS .IP@@ -375,31 +375,31 @@ .PP Multiple definitions, tight: .TP-.B apple+apple red fruit computer .TP-.B orange+orange orange fruit bank .PP Multiple definitions, loose: .TP-.B apple+apple red fruit computer .TP-.B orange+orange orange fruit bank .PP Blank line after term, indented marker, alternate markers: .TP-.B apple+apple red fruit computer .TP-.B orange+orange orange fruit .RS .IP "1." 3@@ -477,7 +477,7 @@ .PP This is \f[B]strong\f[R], and so \f[B]is this\f[R]. .PP-An \f[I]emphasized link (/url)\f[R].+An \f[I]emphasized link\f[R]. .PP \f[B]\f[BI]This is strong and em.\f[B]\f[R] .PP@@ -618,36 +618,36 @@ .SH Links .SS Explicit .PP-Just a URL (/url/).+Just a URL. .PP-URL and title (/url/).+URL and title. .PP-URL and title (/url/).+URL and title. .PP-URL and title (/url/).+URL and title. .PP-URL and title (/url/)+URL and title .PP-URL and title (/url/)+URL and title .PP-with_underscore (/url/with_underscore)+with_underscore .PP Email link (mailto:nobody@nowhere.net) .PP-Empty ().+Empty. .SS Reference .PP-Foo bar (/url/).+Foo bar. .PP-With embedded [brackets] (/url/).+With embedded [brackets]. .PP-b (/url/) by itself should be a link.+b by itself should be a link. .PP-Indented once (/url).+Indented once. .PP-Indented twice (/url).+Indented twice. .PP-Indented thrice (/url).+Indented thrice. .PP This should [not][] be a link. .IP@@ -657,9 +657,9 @@ \f[R] .fi .PP-Foo bar (/url/).+Foo bar. .PP-Foo biz (/url/).+Foo biz. .SS With ampersands .PP Here\[cq]s a link with an ampersand in the@@ -667,9 +667,9 @@ .PP Here\[cq]s a link with an amersand in the link text: AT&T (http://att.com/). .PP-Here\[cq]s an inline link (/script?foo=1&bar=2).+Here\[cq]s an inline link. .PP-Here\[cq]s an inline link in pointy braces (/script?foo=1&bar=2).+Here\[cq]s an inline link in pointy braces. .SS Autolinks .PP With an ampersand: <http://example.com/?foo=1&bar=2>@@ -699,9 +699,9 @@ .PP From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902): .PP-[IMAGE: lalune (lalune.jpg)]+[IMAGE: lalune] .PP-Here is a movie [IMAGE: movie (movie.jpg)] icon.+Here is a movie [IMAGE: movie] icon. .PP    *   *   *   *   * .SH Footnotes
test/writer.markdown view
@@ -399,18 +399,35 @@  Interpreted markdown in a table: +```{=html} <table>+```+```{=html} <tr>+```+```{=html} <td>+``` This is *emphasized*+```{=html} </td>+```+```{=html} <td>+``` And this is **strong**+```{=html} </td>+```+```{=html} </tr>+```+```{=html} </table>+```+```{=html} <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>-+``` Here's a simple block:  <div>@@ -447,41 +464,64 @@  This should just be an HTML comment: +```{=html} <!-- Comment -->-+``` Multiline: +```{=html} <!-- Blah Blah -->+```+```{=html} <!--     This is another comment. -->-+``` Code block:      <!-- Comment -->  Just plain comment, with trailing spaces on the line: +```{=html} <!-- foo -->-+``` Code:      <hr />  Hr's: +```{=html} <hr>+```+```{=html} <hr />+```+```{=html} <hr />+```+```{=html} <hr>+```+```{=html} <hr />+```+```{=html} <hr />+```+```{=html} <hr class="foo" id="bar" />+```+```{=html} <hr class="foo" id="bar" />+```+```{=html} <hr class="foo" id="bar">+```  ------------------------------------------------------------------------------ @@ -540,7 +580,7 @@ LaTeX ===== --   \cite[22-23]{smith.1899}+-   `\cite[22-23]{smith.1899}`{=tex} -   $2+2=4$ -   $x \in y$ -   $\alpha \wedge \omega$@@ -560,11 +600,13 @@  Here's a LaTeX table: +```{=tex} \begin{tabular}{|l|l|}\hline Animal & Number \\ \hline Dog    & 2      \\ Cat    & 1      \\ \hline \end{tabular}+```  ------------------------------------------------------------------------------ 
test/writer.ms view
@@ -27,11 +27,11 @@ .\" line height .nr VS 12p .\" font family: A, BM, H, HN, N, P, T, ZCM-.fam T+.fam P .\" paragraph indent-.nr PI 2m+.nr PI 0m .\" interparagraph space-.nr PD 0.33v+.nr PD 0.4v .\" footnote width .nr FL \n[LL] .\" footnote point size@@ -49,6 +49,9 @@ .\" comment these out if you want a dot after section numbers: .als SN SN-NO-DOT .als SN-STYLE SN-NO-DOT+.\" page numbers in footer, centered+.rm CH+.ds CF % .\" pdf outline fold level .nr PDFOUTLINE.FOLDLEVEL 3 .\" start out in outline view@@ -442,55 +445,55 @@ .pdfhref M "definition-lists" .LP Tight using spaces:-.IP "apple"+.IP "\f[B]apple\f[R]" red fruit .RS .RE-.IP "orange"+.IP "\f[B]orange\f[R]" orange fruit .RS .RE-.IP "banana"+.IP "\f[B]banana\f[R]" yellow fruit .RS .RE .LP Tight using tabs:-.IP "apple"+.IP "\f[B]apple\f[R]" red fruit .RS .RE-.IP "orange"+.IP "\f[B]orange\f[R]" orange fruit .RS .RE-.IP "banana"+.IP "\f[B]banana\f[R]" yellow fruit .RS .RE .LP Loose:-.IP "apple"+.IP "\f[B]apple\f[R]" red fruit .RS .RE-.IP "orange"+.IP "\f[B]orange\f[R]" orange fruit .RS .RE-.IP "banana"+.IP "\f[B]banana\f[R]" yellow fruit .RS .RE .LP Multiple blocks with italics:-.IP "\f[I]apple\f[R]"+.IP "\f[B]\f[BI]apple\f[B]\f[R]" red fruit .RS .PP contains seeds, crisp, pleasant to taste .RE-.IP "\f[I]orange\f[R]"+.IP "\f[B]\f[BI]orange\f[B]\f[R]" orange fruit .RS .IP@@ -506,14 +509,14 @@ .RE .LP Multiple definitions, tight:-.IP "apple"+.IP "\f[B]apple\f[R]" red fruit .RS .RE computer .RS .RE-.IP "orange"+.IP "\f[B]orange\f[R]" orange fruit .RS .RE@@ -522,14 +525,14 @@ .RE .LP Multiple definitions, loose:-.IP "apple"+.IP "\f[B]apple\f[R]" red fruit .RS .RE computer .RS .RE-.IP "orange"+.IP "\f[B]orange\f[R]" orange fruit .RS .RE@@ -538,14 +541,14 @@ .RE .LP Blank line after term, indented marker, alternate markers:-.IP "apple"+.IP "\f[B]apple\f[R]" red fruit .RS .RE computer .RS .RE-.IP "orange"+.IP "\f[B]orange\f[R]" orange fruit .RS .IP " 1." 4
test/writer.muse view
@@ -1,4 +1,4 @@-#author John MacFarlane+#author John MacFarlane; Anonymous #title Pandoc Test Suite #date July 17, 2006 
test/writer.opendocument view
@@ -1011,7 +1011,7 @@     </text:list-style>     <style:style style:name="T1" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" /></style:style>     <style:style style:name="T2" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>-    <style:style style:name="T3" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>+    <style:style style:name="T3" style:family="text"><style:text-properties fo:font-style="italic" fo:font-weight="bold" style:font-style-asian="italic" style:font-style-complex="italic" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>     <style:style style:name="T4" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>     <style:style style:name="T5" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-line-through-style="solid" /></style:style>     <style:style style:name="T6" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>@@ -1576,7 +1576,8 @@ 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="T1">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+<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="First_20_paragraph">Multiple definitions, tight:</text:p>
test/writer.plain view
@@ -7,41 +7,31 @@  ------------------------------------------------------------------------------ ---HEADERS-+Headers  Level 2 with an embedded link -Level 3 with _emphasis_+Level 3 with emphasis  Level 4  Level 5 ---LEVEL 1-+Level 1 -Level 2 with _emphasis_+Level 2 with emphasis  Level 3  with no blank line - Level 2  with no blank line  ------------------------------------------------------------------------------ ---PARAGRAPHS-+Paragraphs  Here’s a regular paragraph. @@ -56,10 +46,7 @@  ------------------------------------------------------------------------------ ---BLOCK QUOTES-+Block Quotes  E-mail style: @@ -88,10 +75,7 @@  ------------------------------------------------------------------------------ ---CODE BLOCKS-+Code Blocks  Code: @@ -111,10 +95,7 @@  ------------------------------------------------------------------------------ ---LISTS-+Lists  Unordered @@ -160,7 +141,6 @@  -   Minus 3 - Ordered  Tight:@@ -201,7 +181,6 @@  3.  Item 3. - Nested  -   Tab@@ -229,7 +208,6 @@  3.  Third - Tabs and spaces  -   this is a list item indented with tabs@@ -240,7 +218,6 @@      -   this is an example list item indented with spaces - Fancy list markers  (2) begins with 2@@ -275,10 +252,7 @@  ------------------------------------------------------------------------------ ---DEFINITION LISTS-+Definition Lists  Tight using spaces: @@ -318,13 +292,13 @@  Multiple blocks with italics: -_apple_+apple      red fruit      contains seeds, crisp, pleasant to taste -_orange_+orange      orange fruit @@ -371,10 +345,7 @@     1.  sublist     2.  sublist ---HTML BLOCKS-+HTML Blocks  Simple block on one line: @@ -388,8 +359,8 @@  Interpreted markdown in a table: -This is _emphasized_-And this is STRONG+This is emphasized+And this is strong Here’s a simple block:  foo@@ -426,30 +397,27 @@  ------------------------------------------------------------------------------ ---INLINE MARKUP-+Inline Markup -This is _emphasized_, and so _is this_.+This is emphasized, and so is this. -This is STRONG, and so IS THIS.+This is strong, and so is this. -An _emphasized link_.+An emphasized link. -_THIS IS STRONG AND EM._+This is strong and em. -So is _THIS_ word.+So is this word. -_THIS IS STRONG AND EM._+This is strong and em. -So is _THIS_ word.+So is this word.  This is code: >, $, \, \$, <html>. -~~This is _strikeout_.~~+~~This is strikeout.~~ -Superscripts: a^(bc)d a^(_hello_) a^(hello there).+Superscripts: a^(bc)d a^(hello) a^(hello there).  Subscripts: H₂O, H₂₃O, H_(many of them)O. @@ -458,10 +426,7 @@  ------------------------------------------------------------------------------ ---SMART QUOTES, ELLIPSES, DASHES-+Smart quotes, ellipses, dashes  “Hello,” said the spider. “‘Shelob’ is my name.” @@ -481,10 +446,7 @@  ------------------------------------------------------------------------------ ---LATEX-+LaTeX  -    -   2 + 2 = 4@@ -499,19 +461,16 @@ 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+-   $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$.+-   Escaped $: $73 this should be emphasized 23$.  Here’s a LaTeX table:  ------------------------------------------------------------------------------ ---SPECIAL CHARACTERS-+Special Characters  Here is some unicode: @@ -565,10 +524,7 @@  ------------------------------------------------------------------------------ ---LINKS-+Links  Explicit @@ -590,7 +546,6 @@  Empty. - Reference  Foo bar.@@ -613,7 +568,6 @@  Foo biz. - With ampersands  Here’s a link with an ampersand in the URL.@@ -624,7 +578,6 @@  Here’s an inline link in pointy braces. - Autolinks  With an ampersand: http://example.com/?foo=1&bar=2@@ -643,10 +596,7 @@  ------------------------------------------------------------------------------ ---IMAGES-+Images  From “Voyage dans la Lune” by Georges Melies (1902): @@ -656,14 +606,10 @@  ------------------------------------------------------------------------------ ---FOOTNOTES-+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] @@ -684,7 +630,7 @@ 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+[3] This is easier to type. Inline notes may contain links and ] verbatim characters, as well as [bracketed text].  [4] In quote.
test/writer.rst view
@@ -619,7 +619,6 @@ -  Here’s some display math:     .. 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: :math:`\alpha + \omega \times x^2`.  These shouldn’t be math:
test/writers-lang-and-dir.context view
@@ -8,8 +8,10 @@ % make chapter, section bookmarks visible when opening document \placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section] \setupinteractionscreen[option=bookmark]-\setuptagging[state=start] +\setuppagenumbering[location={footer,middle}]+\setupbackend[export=yes]+\setupstructure[state=start,method=auto]  % use microtypography \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]@@ -97,10 +99,10 @@  and more text. -Next paragraph with a \start\language[en-gb]British span\stop  and a-word-that-includesa\start\language[de-ch]Swiss German span\stop right?+Next paragraph with a {\language[en-gb]British span} and a+word-that-includesa{\language[de-ch]Swiss German span}right? -Some \start\language[es]Spanish text\stop .+Some {\language[es]Spanish text}.  \section[title={Combined},reference={combined}] @@ -115,9 +117,8 @@  and more text. -Next paragraph with a \start\language[en-gb]{\lefttoright British ltr-span}\stop  and a-word-that-includesa\start\language[de-ch]{\lefttoright Swiss German ltr-span}\stop right?+Next paragraph with a {\language[en-gb]{\lefttoright British ltr span}}+and a word-that-includesa{\language[de-ch]{\lefttoright Swiss German ltr+span}}right?  \stoptext
trypandoc/trypandoc.hs view
@@ -41,12 +41,12 @@   text <- getParam "text" >>= checkLength . fromMaybe T.empty   fromFormat <- fromMaybe "" <$> getParam "from"   toFormat <- fromMaybe "" <$> getParam "to"-  let reader = case getReader (T.unpack fromFormat) of+  let reader = case runPure $ getReader (T.unpack fromFormat) of                     Right (TextReader r, es) -> r readerOpts{                        readerExtensions = es }                     _ -> error $ "could not find reader for "                                   ++ T.unpack fromFormat-  let writer = case getWriter (T.unpack toFormat) of+  let writer = case runPure $ getWriter (T.unpack toFormat) of                     Right (TextWriter w, es) -> w writerOpts{                        writerExtensions = es }                     _ -> error $ "could not find writer for " ++@@ -72,7 +72,7 @@ writerOpts = def { writerReferenceLinks = True,                    writerEmailObfuscation = NoObfuscation,                    writerHTMLMathMethod = MathJax (defaultMathJaxURL ++-                       "MathJax.js?config=TeX-AMS_CHTML-full"),+                       "tex-mml-chtml.js"),                    writerHighlightStyle = Just pygments }  readerOpts :: ReaderOptions