pandoc 2.3.1 → 2.4
raw patch · 162 files changed
+14495/−10313 lines, 162 filesdep +unicode-transformsdep ~QuickCheckdep ~basedep ~binarybinary-addedPVP ok
version bump matches the API change (PVP)
Dependencies added: unicode-transforms
Dependency ranges changed: QuickCheck, base, binary, containers, haddock-library, hslua, skylighting
API changes (from Hackage documentation)
Files
- AUTHORS.md +4/−0
- INSTALL.md +15/−1
- MANUAL.txt +33/−22
- README.md +4/−4
- benchmark/benchmark-pandoc.hs +17/−12
- changelog +481/−0
- data/abbreviations +1/−0
- data/docx/[Content_Types].xml +1/−1
- data/docx/_rels/.rels +2/−1
- data/docx/docProps/custom.xml +2/−0
- data/pandoc.lua +97/−3
- data/sample.lua +26/−16
- data/templates/default.asciidoc +1/−1
- data/templates/default.latex +4/−1
- data/templates/default.revealjs +1/−1
- man/pandoc.1 +5736/−6104
- pandoc.cabal +49/−25
- src/Text/Pandoc/App.hs +425/−1647
- src/Text/Pandoc/App/CommandLineOptions.hs +1090/−0
- src/Text/Pandoc/App/OutputSettings.hs +317/−0
- src/Text/Pandoc/Class.hs +1/−1
- src/Text/Pandoc/Filter.hs +14/−6
- src/Text/Pandoc/Filter/JSON.hs +1/−4
- src/Text/Pandoc/Filter/Lua.hs +19/−9
- src/Text/Pandoc/Logging.hs +2/−1
- src/Text/Pandoc/Lua.hs +12/−51
- src/Text/Pandoc/Lua/Filter.hs +24/−5
- src/Text/Pandoc/Lua/Global.hs +108/−0
- src/Text/Pandoc/Lua/Init.hs +23/−21
- src/Text/Pandoc/Lua/StackInstances.hs +157/−31
- src/Text/Pandoc/Lua/Util.hs +37/−3
- src/Text/Pandoc/Options.hs +2/−0
- src/Text/Pandoc/Parsing.hs +59/−60
- src/Text/Pandoc/Pretty.hs +2/−4
- src/Text/Pandoc/Readers.hs +2/−0
- src/Text/Pandoc/Readers/Creole.hs +3/−4
- src/Text/Pandoc/Readers/Docx/Parse.hs +4/−2
- src/Text/Pandoc/Readers/HTML.hs +10/−8
- src/Text/Pandoc/Readers/JATS.hs +2/−4
- src/Text/Pandoc/Readers/LaTeX.hs +128/−523
- src/Text/Pandoc/Readers/LaTeX/Lang.hs +173/−0
- src/Text/Pandoc/Readers/LaTeX/Parsing.hs +114/−85
- src/Text/Pandoc/Readers/Man.hs +522/−0
- src/Text/Pandoc/Readers/Markdown.hs +12/−6
- src/Text/Pandoc/Readers/Muse.hs +175/−231
- src/Text/Pandoc/Readers/Org/DocumentTree.hs +8/−15
- src/Text/Pandoc/Readers/Org/Inlines.hs +13/−7
- src/Text/Pandoc/Readers/Org/Meta.hs +14/−0
- src/Text/Pandoc/Readers/Org/ParserState.hs +8/−0
- src/Text/Pandoc/Readers/Org/Parsing.hs +8/−0
- src/Text/Pandoc/Readers/RST.hs +23/−18
- src/Text/Pandoc/Readers/Roff.hs +756/−0
- src/Text/Pandoc/Readers/TWiki.hs +50/−61
- src/Text/Pandoc/Readers/Vimwiki.hs +16/−21
- src/Text/Pandoc/RoffChar.hs +441/−0
- src/Text/Pandoc/Shared.hs +50/−2
- src/Text/Pandoc/Writers/AsciiDoc.hs +18/−30
- src/Text/Pandoc/Writers/CommonMark.hs +42/−10
- src/Text/Pandoc/Writers/Custom.hs +9/−9
- src/Text/Pandoc/Writers/Docbook.hs +4/−3
- src/Text/Pandoc/Writers/Docx.hs +34/−25
- src/Text/Pandoc/Writers/EPUB.hs +4/−3
- src/Text/Pandoc/Writers/HTML.hs +22/−12
- src/Text/Pandoc/Writers/ICML.hs +2/−1
- src/Text/Pandoc/Writers/JATS.hs +2/−1
- src/Text/Pandoc/Writers/LaTeX.hs +146/−57
- src/Text/Pandoc/Writers/Man.hs +23/−95
- src/Text/Pandoc/Writers/Markdown.hs +43/−51
- src/Text/Pandoc/Writers/Math.hs +1/−1
- src/Text/Pandoc/Writers/Ms.hs +32/−141
- src/Text/Pandoc/Writers/Muse.hs +106/−112
- src/Text/Pandoc/Writers/ODT.hs +26/−7
- src/Text/Pandoc/Writers/OPML.hs +2/−1
- src/Text/Pandoc/Writers/OpenDocument.hs +75/−29
- src/Text/Pandoc/Writers/Powerpoint/Output.hs +13/−10
- src/Text/Pandoc/Writers/Powerpoint/Presentation.hs +20/−16
- src/Text/Pandoc/Writers/RST.hs +35/−8
- src/Text/Pandoc/Writers/Roff.hs +138/−0
- src/Text/Pandoc/Writers/Shared.hs +80/−8
- src/Text/Pandoc/Writers/ZimWiki.hs +31/−35
- src/Text/Pandoc/XML.hs +18/−0
- stack.yaml +8/−5
- test/Tests/Lua.hs +16/−17
- test/Tests/Old.hs +4/−0
- test/Tests/Readers/HTML.hs +6/−1
- test/Tests/Readers/Man.hs +121/−0
- test/Tests/Readers/Muse.hs +111/−6
- test/Tests/Writers/Muse.hs +4/−0
- test/Tests/Writers/Powerpoint.hs +4/−1
- test/command/3123.md +13/−0
- test/command/3494.md +1/−1
- test/command/3568.md +4/−3
- test/command/3577.md +0/−2
- test/command/3983.md +3/−3
- test/command/4284.md +40/−0
- test/command/4306.md +10/−0
- test/command/4382.md +10/−0
- test/command/4527.md +17/−2
- test/command/4528.md +156/−0
- test/command/4550.md +1/−1
- test/command/4624.md +30/−0
- test/command/4635.md +31/−0
- test/command/4715.md +16/−0
- test/command/4880.md +7/−0
- test/command/4960.md +22/−0
- test/command/5010.md +21/−0
- test/command/5039.md +27/−0
- test/command/ascii.md +53/−0
- test/command/ifstrequal.md +1/−2
- test/command/lua-pandoc-state.lua +11/−0
- test/command/lua-pandoc-state.md +14/−0
- test/command/macros.md +22/−0
- test/docx/golden/block_quotes.docx binary
- test/docx/golden/codeblock.docx binary
- test/docx/golden/comments.docx binary
- test/docx/golden/custom_style_no_reference.docx binary
- test/docx/golden/custom_style_reference.docx binary
- test/docx/golden/definition_list.docx binary
- test/docx/golden/headers.docx binary
- test/docx/golden/image.docx binary
- test/docx/golden/inline_code.docx binary
- test/docx/golden/inline_formatting.docx binary
- test/docx/golden/inline_images.docx binary
- test/docx/golden/link_in_notes.docx binary
- test/docx/golden/links.docx binary
- test/docx/golden/lists.docx binary
- test/docx/golden/lists_continuing.docx binary
- test/docx/golden/lists_restarting.docx binary
- test/docx/golden/nested_anchors_in_header.docx binary
- test/docx/golden/notes.docx binary
- test/docx/golden/table_one_row.docx binary
- test/docx/golden/table_with_list_cell.docx binary
- test/docx/golden/tables.docx binary
- test/docx/golden/track_changes_deletion.docx binary
- test/docx/golden/track_changes_insertion.docx binary
- test/docx/golden/track_changes_move.docx binary
- test/docx/golden/unicode.docx binary
- test/docx/golden/verbatim_subsuper.docx binary
- test/lhs-test.html +4/−4
- test/lhs-test.html+lhs +4/−4
- test/lhs-test.latex +1/−1
- test/man-reader.man +391/−0
- test/man-reader.native +180/−0
- test/markdown-citations.native +1/−1
- test/pptx/raw_ooxml.native +3/−0
- test/pptx/raw_ooxml.pptx binary
- test/pptx/raw_ooxml_templated.pptx binary
- test/tables-rstsubset.native +4/−4
- test/tables.man +4/−4
- test/tables.ms +4/−4
- test/tables.muse +24/−11
- test/tables.opendocument +6/−4
- test/tables.rst +26/−34
- test/test-pandoc.hs +2/−0
- test/vimwiki-reader.native +2/−0
- test/vimwiki-reader.wiki +6/−1
- test/writer.asciidoc +32/−63
- test/writer.man +85/−122
- test/writer.markdown +4/−0
- test/writer.ms +47/−47
- test/writer.opendocument +568/−190
- test/writer.zimwiki +88/−88
@@ -122,6 +122,7 @@ - Masayoshi Takahashi - Matej Kollar - Mathias Schenner+- Mathias Walter - Mathieu Duponchelle - Matthew Eddey - Matthew Pickering@@ -139,6 +140,7 @@ - Nathan Gass - Neil Mayhew - Nick Bart+- Nick Fleisher - Nicolas Kaiser - Nikolay Yakimov - Nils Carlson@@ -192,6 +194,8 @@ - Waldir Pimenta - Wikiwide - Xavier Olive+- Yan Pashkovsky+- Yoan Blanc - Yuchen Pei - bucklereed - bumper314
@@ -39,7 +39,8 @@ - For PDF output, you'll also need LaTeX. Because a full [MacTeX] installation takes more than a gigabyte of disk space, we recommend installing [BasicTeX](http://www.tug.org/mactex/morepackages.html)- (64M) and using the `tlmgr` tool to install additional packages+ (64M) or [TinyTeX](https://yihui.name/tinytex/)+ and using the `tlmgr` tool to install additional packages as needed. If you get errors warning of fonts not found, try tlmgr install collection-fontsrecommended@@ -91,6 +92,19 @@ - For PDF output, you'll need LaTeX. We recommend installing [TeX Live](http://www.tug.org/texlive/) via your package manager. (On Debian/Ubuntu, `apt-get install texlive`.)++## Chrome OS++On Chrome OS, pandoc can be installed using the+[chromebrew](https://github.com/skycocker/chromebrew) package manager+with the command:++```sh+crew install pandoc+```++This will automatically build and configure pandoc for the specific+device you are using. ## BSD
@@ -1,6 +1,6 @@ % Pandoc User's Guide % John MacFarlane-% September 27, 2018+% November 01, 2018 Synopsis ========@@ -285,13 +285,13 @@ - `jats` ([JATS] XML) - `json` (JSON version of native AST) - `latex` ([LaTeX])- - `man` ([groff man])+ - `man` ([roff man]) - `markdown` ([Pandoc's Markdown]) - `markdown_mmd` ([MultiMarkdown]) - `markdown_phpextra` ([PHP Markdown Extra]) - `markdown_strict` (original unextended [Markdown]) - `mediawiki` ([MediaWiki markup])- - `ms` ([groff ms])+ - `ms` ([roff ms]) - `muse` ([Muse]), - `native` (native Haskell), - `odt` ([OpenOffice text document][ODT])@@ -442,8 +442,8 @@ [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-[groff man]: http://man7.org/linux/man-pages/man7/groff_man.7.html-[groff ms]: http://man7.org/linux/man-pages/man7/groff_ms.7.html+[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@@ -859,9 +859,12 @@ `--ascii` : Use only ASCII characters in output. Currently supported for- XML and HTML formats (which use numerical entities instead of- UTF-8 when this option is selected) and for groff ms and man- (which use hexadecimal escapes).+ XML and HTML formats (which use entities instead of+ UTF-8 when this option is selected), Markdown (which uses+ 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` @@ -879,7 +882,7 @@ `--atx-headers` -: Use ATX-style headers in Markdown and AsciiDoc output. The default is+: Use ATX-style headers in Markdown output. The default is to use setext-style headers for levels 1-2, and then ATX headers. (Note: for `gfm` output, ATX headers are always used.) @@ -973,8 +976,8 @@ 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 `stylesheet` metadata- field), pandoc will look for a file `epub.css` in the+ 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. @@ -1521,13 +1524,13 @@ `fontfamily` set to [`mathpazo`] provides Palatino with old-style figures and true small caps; may be repeated for multiple options -`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`+`mainfont`, `romanfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont` : font families for use with `xelatex` or `lualatex`: take the name of any system font, using the [`fontspec`] package. Note that if `CJKmainfont` is used, the [`xecjk`] package must be available. -`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`+`mainfontoptions`, `romanfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions` : options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont` in `xelatex` and `lualatex`. Allow for any choices available through [`fontspec`], such as the OpenType features@@ -3331,7 +3334,7 @@ Texinfo ~ It will be rendered inside a `@math` command. -groff man+roff man ~ It will be rendered verbatim without `$`'s. MediaWiki, DokuWiki@@ -3379,9 +3382,15 @@ be disabled if desired.) The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,-DZSlides, EPUB, Markdown, Emacs Org mode, and Textile output, and suppressed-in other formats.+DZSlides, EPUB, Markdown, CommonMark, Emacs Org mode, and Textile+output, and suppressed in other formats. +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@@ -3465,7 +3474,7 @@ 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-groff `ms` block:+roff `ms` block: ```{=ms} .MYMACRO@@ -3702,10 +3711,12 @@ 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- `<img href="file.jpg" style="width: 50%;" />` (HTML),- `\includegraphics[width=0.5\textwidth]{file.jpg}` (LaTeX), or- `\externalfigure[file.jpg][width=0.5\textwidth]` (ConTeXt).+ 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).@@ -4604,7 +4615,7 @@ `cover-image` ~ A string value (path to cover image). -`stylesheet`+`css` (or legacy: `stylesheet`) ~ A string value (path to CSS stylesheet). `page-progression-direction`
@@ -97,8 +97,8 @@ not supported in [`gfm`](#markdown-variants). - `haddock` ([Haddock markup](https://www.haskell.org/haddock/doc/html/ch03s08.html))- - `html` or `html5` ([HTML](http://www.w3.org/html/), i.e.- [HTML5](http://www.w3.org/TR/html5/)/XHTML [polyglot+ - `html` or `html5` ([HTML](http://www.w3.org/html/),+ i.e. [HTML5](http://www.w3.org/TR/html5/)/XHTML [polyglot markup](https://www.w3.org/TR/html-polyglot/)) - `html4` ([XHTML](http://www.w3.org/TR/xhtml1/) 1.0 Transitional) - `icml` ([InDesign@@ -106,7 +106,7 @@ - `jats` ([JATS](https://jats.nlm.nih.gov) XML) - `json` (JSON version of native AST) - `latex` ([LaTeX](http://latex-project.org))- - `man` ([groff+ - `man` ([roff man](http://man7.org/linux/man-pages/man7/groff_man.7.html)) - `markdown` ([Pandoc’s Markdown](#pandocs-markdown)) - `markdown_mmd`@@ -117,7 +117,7 @@ [Markdown](http://daringfireball.net/projects/markdown/)) - `mediawiki` ([MediaWiki markup](https://www.mediawiki.org/wiki/Help:Formatting))- - `ms` ([groff+ - `ms` ([roff ms](http://man7.org/linux/man-pages/man7/groff_ms.7.html)) - `muse` ([Muse](https://amusewiki.org/library/manual)), - `native` (native Haskell),
@@ -19,6 +19,8 @@ -} import Prelude import Text.Pandoc+import Text.Pandoc.Error (PandocError(..))+import Control.Monad.Except (throwError) import qualified Text.Pandoc.UTF8 as UTF8 import qualified Data.ByteString as B import Criterion.Main@@ -37,14 +39,15 @@ $ nf (\i -> either (error . show) id $ runPure (readerFun i)) inp Left _ -> Nothing- where res = runPure $ do- (TextReader r, rexts)- <- either (fail . show) return $ getReader name- (TextWriter w, wexts)- <- either (fail . show) return $ getWriter name- inp <- w def{ writerWrapText = WrapAuto, writerExtensions = wexts }- doc- return (r def{ readerExtensions = rexts }, inp)+ 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 writerBench :: Pandoc -> String@@ -55,11 +58,13 @@ Just $ bench (name ++ " writer") $ nf (\d -> either (error . show) id $ runPure (writerFun d)) doc- _ -> Nothing+ Left _ -> Nothing where res = runPure $ do- (TextWriter w, wexts)- <- either (fail . show) return $ getWriter name- return $ w def{ writerExtensions = wexts }+ case (getWriter name) of+ Right (TextWriter w, wexts) ->+ return $ w def{ writerExtensions = wexts }+ _ -> throwError $ PandocSomeError+ $ "could not get text reader and writer for " ++ name main :: IO () main = do
@@ -1,3 +1,484 @@+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:
@@ -46,5 +46,6 @@ Sgt. Sr. St.+viz. vol. vs.
@@ -1,2 +1,2 @@ <?xml version="1.0" encoding="UTF-8"?>-<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" /><Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" /><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" /><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" /><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" /><Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>+<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" /><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" /><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" /><Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" /><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" /><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" /><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /><Override PartName="/docProps/custom.xml" ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" /><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" /><Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>
@@ -1,2 +1,3 @@ <?xml version="1.0" encoding="UTF-8"?>-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /></Relationships>+<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml"/>+</Relationships>
@@ -0,0 +1,2 @@+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>+<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"></Properties>
@@ -73,6 +73,39 @@ return res end +--- Get list of top-level fields from field descriptor table.+-- E.g.: `top_level_fields{'foo', {bar='baz'}, {'qux', 'quux'}}`+-- gives {'foo, 'bar', 'qux', 'quux'}+-- @local+local function top_level_fields (fields)+ local result = List:new{}+ for _, v in ipairs(fields) do+ if type(v) == 'string' then+ table.insert(result, v)+ elseif type(v) == 'table' and #v == 0 and next(v) then+ table.insert(result, (next(v)))+ else+ result:extend(top_level_fields(v))+ end+ end+ return result+end++--- Creates a function which behaves like next, but respects field names.+-- @local+local function make_next_function (fields)+ local field_indices = {}+ for i, f in ipairs(fields) do+ field_indices[f] = i+ end++ return function (t, field)+ local raw_idx = field == nil and 0 or field_indices[field]+ local next_field = fields[raw_idx + 1]+ return next_field, t[next_field]+ end+end+ --- Create a new table which allows to access numerical indices via accessor -- functions. -- @local@@ -102,6 +135,15 @@ rawset(t, k, v) end end+ behavior.__pairs = function (t)+ if accessors == nil then+ return next, t+ end+ local iterable_fields = type(accessors) == 'string'+ and {accessors}+ or top_level_fields(accessors)+ return make_next_function(iterable_fields), t+ end return behavior end @@ -267,8 +309,16 @@ -- @tparam {MetaValue,...} meta_values list of meta values M.MetaList = M.MetaValue:create_constructor( 'MetaList',- function (content) return ensureList(content) end+ function (content)+ if content.tag == 'MetaList' then+ return content+ end+ return ensureList(content)+ end )+for k, v in pairs(List) do+ M.MetaList.behavior[k] = v+end --- Meta map -- @function MetaMap@@ -403,7 +453,7 @@ M.OrderedList = M.Block:create_constructor( "OrderedList", function(items, listAttributes)- listAttributes = listAttributes or {1, M.DefaultStyle, M.DefaultDelim}+ listAttributes = listAttributes or M.ListAttributes() return {c = {listAttributes, ensureList(items)}} end, {{listAttributes = {"start", "style", "delimiter"}}, "content"}@@ -487,7 +537,7 @@ --- Creates a Code inline element -- @function Code--- @tparam string text brief image description+-- @tparam string text code string -- @tparam[opt] Attr attr additional attributes -- @treturn Inline code element M.Code = M.Inline:create_constructor(@@ -834,6 +884,14 @@ rawset(t, k, v) end end+M.Attr.behavior.__pairs = function(t)+ local field_names = M.Attr.behavior._field_names+ local fields = {}+ for name, i in pairs(field_names) do+ fields[i] = name+ end+ return make_next_function(fields), t, nil+end -- Citation M.Citation = AstElement:make_subtype'Citation'@@ -855,6 +913,42 @@ note_num = note_num or 0, hash = hash or 0, }+end++-- ListAttributes+M.ListAttributes = AstElement:make_subtype 'ListAttributes'++--- Creates a set of list attributes.+-- @function ListAttributes+-- @tparam[opt] integer start number of the first list item+-- @tparam[opt] string style style used for list numbering+-- @tparam[opt] DefaultDelim|Period|OneParen|TwoParens delimiter delimiter of list numbers+-- @treturn table list attributes table+function M.ListAttributes:new (start, style, delimiter)+ start = start or 1+ style = style or 'DefaultStyle'+ delimiter = delimiter or 'DefaultDelim'+ return {start, style, delimiter}+end+M.ListAttributes.behavior._field_names = {start = 1, style = 2, delimiter = 3}+M.ListAttributes.behavior.__index = function (t, k)+ return rawget(t, getmetatable(t)._field_names[k]) or+ getmetatable(t)[k]+end+M.ListAttributes.behavior.__newindex = function (t, k, v)+ if getmetatable(t)._field_names[k] then+ rawset(t, getmetatable(t)._field_names[k], v)+ else+ rawset(t, k, v)+ end+end+M.ListAttributes.behavior.__pairs = function(t)+ local field_names = M.ListAttributes.behavior._field_names+ local fields = {}+ for name, i in pairs(field_names) do+ fields[i] = name+ end+ return make_next_function(fields), t, nil end
@@ -2,7 +2,8 @@ -- that is very similar to that of pandoc's HTML writer. -- There is one new feature: code blocks marked with class 'dot' -- are piped through graphviz and images are included in the HTML--- output using 'data:' URLs.+-- output using 'data:' URLs. The image format can be controlled+-- via the `image_format` metadata field. -- -- Invoke with: pandoc -t sample.lua --@@ -12,6 +13,28 @@ -- produce informative error messages if your code contains -- syntax errors. +local pipe = pandoc.pipe+local stringify = (require "pandoc.utils").stringify++-- The global variable PANDOC_DOCUMENT contains the full AST of+-- the document which is going to be written. It can be used to+-- configure the writer.+local meta = PANDOC_DOCUMENT.meta++-- Chose the image format based on the value of the+-- `image_format` meta value.+local image_format = meta.image_format+ and stringify(meta.image_format)+ or "png"+local image_mime_type = ({+ jpeg = "image/jpeg",+ jpg = "image/jpeg",+ gif = "image/gif",+ png = "image/png",+ svg = "image/svg+xml",+ })[image_format]+ or error("unsupported image format `" .. img_format .. "`")+ -- Character escaping local function escape(s, in_attribute) return s:gsub("[<>&\"']",@@ -44,19 +67,6 @@ return table.concat(attr_table) end --- Run cmd on a temporary file containing inp and return result.-local function pipe(cmd, inp)- local tmp = os.tmpname()- local tmph = io.open(tmp, "w")- tmph:write(inp)- tmph:close()- local outh = io.popen(cmd .. " " .. tmp,"r")- local result = outh:read("*all")- outh:close()- os.remove(tmp)- return result-end- -- Table to store footnotes, so they can be included at the end. local notes = {} @@ -217,8 +227,8 @@ -- If code block has class 'dot', pipe the contents through dot -- and base64, and include the base64-encoded png as a data: URL. if attr.class and string.match(' ' .. attr.class .. ' ',' dot ') then- local png = pipe("base64", pipe("dot -Tpng", s))- return '<img src="data:image/png;base64,' .. png .. '"/>'+ local img = pipe("base64", {}, pipe("dot", {"-T" .. image_format}, s))+ return '<img src="data:' .. image_mime_type .. ';base64,' .. img .. '"/>' -- otherwise treat as code (one could pipe through a highlighter) else return "<pre><code" .. attributes(attr) .. ">" .. escape(s) ..
@@ -1,5 +1,5 @@ $if(titleblock)$-$title$+= $title$ $if(author)$ $for(author)$$author$$sep$; $endfor$ $endif$
@@ -1,4 +1,4 @@-\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere+\PassOptionsToPackage{unicode=true$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} % options for packages loaded elsewhere \PassOptionsToPackage{hyphens}{url} $if(colorlinks)$ \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}@@ -91,6 +91,9 @@ $endfor$ $if(mainfont)$ \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}+$endif$+$if(romanfont)$+ \setromanfont[$for(romanfontoptions)$$romanfontoptions$$sep$,$endfor$]{$romanfont$} $endif$ $if(sansfont)$ \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
@@ -263,7 +263,7 @@ { src: '$revealjs-url$/lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: '$revealjs-url$/plugin/zoom-js/zoom.js', async: true }, $if(notes-server)$- { src: '$revealjs-url$/socket.io/socker.io.js', async: true },+ { src: '$revealjs-url$/socket.io/socket.io.js', async: true }, { src: '$revealjs-url$/plugin/notes-server/client.js', async: true }, $endif$ $if(mathjax)$
@@ -1,6108 +1,5740 @@ .\"t-.TH PANDOC 1 "September 27, 2018" "pandoc 2.3.1"-.SH NAME-pandoc - general markup converter-.SH SYNOPSIS-.PP-\f[C]pandoc\f[] [\f[I]options\f[]] [\f[I]input\-file\f[]]...-.SH DESCRIPTION-.PP-Pandoc is a Haskell library for converting from one markup format to-another, and a command\-line tool that uses this library.-.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[] and \f[C]\-\-to\f[] 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[] 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 \f[C]pandoc\f[]-.PP-If no \f[I]input\-files\f[] are specified, input is read from-\f[I]stdin\f[].-Output goes to \f[I]stdout\f[] by default.-For output to a file, use the \f[C]\-o\f[] option:-.IP-.nf-\f[C]-pandoc\ \-o\ output.html\ input.txt-\f[]-.fi-.PP-By default, pandoc produces a document fragment.-To produce a standalone document (e.g.-a valid HTML file including \f[C]<head>\f[] and \f[C]<body>\f[]), use-the \f[C]\-s\f[] or \f[C]\-\-standalone\f[] flag:-.IP-.nf-\f[C]-pandoc\ \-s\ \-o\ output.html\ input.txt-\f[]-.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[] will concatenate them-all (with blank lines between them) before parsing.-(Use \f[C]\-\-file\-scope\f[] 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[]-option, the output format using the \f[C]\-t/\-\-to\f[] option.-Thus, to convert \f[C]hello.txt\f[] from Markdown to LaTeX, you could-type:-.IP-.nf-\f[C]-pandoc\ \-f\ markdown\ \-t\ latex\ hello.txt-\f[]-.fi-.PP-To convert \f[C]hello.html\f[] from HTML to Markdown:-.IP-.nf-\f[C]-pandoc\ \-f\ html\ \-t\ markdown\ hello.html-\f[]-.fi-.PP-Supported input and output formats are listed below under Options (see-\f[C]\-f\f[] for input formats and \f[C]\-t\f[] for output formats).-You can also use \f[C]pandoc\ \-\-list\-input\-formats\f[] and-\f[C]pandoc\ \-\-list\-output\-formats\f[] to print lists of supported-formats.-.PP-If the input or output format is not specified explicitly,-\f[C]pandoc\f[] will attempt to guess it from the extensions of the-filenames.-Thus, for example,-.IP-.nf-\f[C]-pandoc\ \-o\ hello.tex\ hello.txt-\f[]-.fi-.PP-will convert \f[C]hello.txt\f[] from Markdown to LaTeX.-If no output file is specified (so that output goes to \f[I]stdout\f[]),-or if the output file\[aq]s extension is unknown, the output format will-default to HTML.-If no input file is specified (so that input comes from \f[I]stdin\f[]),-or if the input files\[aq] extensions are unknown, the input format will-be assumed to be Markdown.-.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[]:-.IP-.nf-\f[C]-iconv\ \-t\ utf\-8\ input.txt\ |\ pandoc\ |\ iconv\ \-f\ utf\-8-\f[]-.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[] option.-.SS Creating a PDF-.PP-To produce a PDF, specify an output file with a \f[C]\&.pdf\f[]-extension:-.IP-.nf-\f[C]-pandoc\ test.txt\ \-o\ test.pdf-\f[]-.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[] below).-.PP-Alternatively, pandoc can use ConTeXt, \f[C]pdfroff\f[], or any of the-following HTML/CSS\-to\-PDF\-engines, to create a PDF:-\f[C]wkhtmltopdf\f[], \f[C]weasyprint\f[] or \f[C]prince\f[].-To do this, specify an output file with a \f[C]\&.pdf\f[] extension, as-before, but add the \f[C]\-\-pdf\-engine\f[] option or-\f[C]\-t\ context\f[], \f[C]\-t\ html\f[], or \f[C]\-t\ ms\f[] to the-command line (\f[C]\-t\ html\f[] defaults to-\f[C]\-\-pdf\-engine=wkhtmltopdf\f[]).-.PP-PDF output can be controlled using variables for LaTeX (if LaTeX is-used) and variables for ConTeXt (if ConTeXt is used).-When using an HTML/CSS\-to\-PDF\-engine, \f[C]\-\-css\f[] affects the-output.-If \f[C]wkhtmltopdf\f[] is used, then the variables-\f[C]margin\-left\f[], \f[C]margin\-right\f[], \f[C]margin\-top\f[],-\f[C]margin\-bottom\f[], \f[C]footer\-html\f[], \f[C]header\-html\f[]-and \f[C]papersize\f[] will affect 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[], use for example-\f[C]\-s\ \-o\ test.tex\f[] to output the generated LaTeX.-You can then test it with \f[C]pdflatex\ test.tex\f[].-.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[],-\f[C]amsmath\f[], \f[C]lm\f[], \f[C]unicode\-math\f[], \f[C]ifxetex\f[],-\f[C]ifluatex\f[], \f[C]listings\f[] (if the \f[C]\-\-listings\f[]-option is used), \f[C]fancyvrb\f[], \f[C]longtable\f[],-\f[C]booktabs\f[], \f[C]graphicx\f[] and \f[C]grffile\f[] (if the-document contains images), \f[C]hyperref\f[], \f[C]xcolor\f[] (with-\f[C]colorlinks\f[]), \f[C]ulem\f[], \f[C]geometry\f[] (with the-\f[C]geometry\f[] variable set), \f[C]setspace\f[] (with-\f[C]linestretch\f[]), and \f[C]babel\f[] (with \f[C]lang\f[]).-The use of \f[C]xelatex\f[] or \f[C]lualatex\f[] as the LaTeX engine-requires \f[C]fontspec\f[].-\f[C]xelatex\f[] uses \f[C]polyglossia\f[] (with \f[C]lang\f[]),-\f[C]xecjk\f[], and \f[C]bidi\f[] (with the \f[C]dir\f[] variable set).-If the \f[C]mathspec\f[] variable is set, \f[C]xelatex\f[] will use-\f[C]mathspec\f[] instead of \f[C]unicode\-math\f[].-The \f[C]upquote\f[] and \f[C]microtype\f[] packages are used if-available, and \f[C]csquotes\f[] will be used for typography if-\f[C]\\usepackage{csquotes}\f[] is present in the template or included-via \f[C]/H/\-\-include\-in\-header\f[].-The \f[C]natbib\f[], \f[C]biblatex\f[], \f[C]bibtex\f[], and-\f[C]biber\f[] packages can optionally be used for citation rendering.-.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[]-.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:"Mozilla/5.0"\ \\-\ \ http://www.fsf.org-\f[]-.fi-.SH OPTIONS-.SS General options-.TP-.B \f[C]\-f\f[] \f[I]FORMAT\f[], \f[C]\-r\f[] \f[I]FORMAT\f[], \f[C]\-\-from=\f[]\f[I]FORMAT\f[], \f[C]\-\-read=\f[]\f[I]FORMAT\f[]-Specify input format.-\f[I]FORMAT\f[] can be:-.RS-.IP \[bu] 2-\f[C]commonmark\f[] (CommonMark Markdown)-.IP \[bu] 2-\f[C]creole\f[] (Creole 1.0)-.IP \[bu] 2-\f[C]docbook\f[] (DocBook)-.IP \[bu] 2-\f[C]docx\f[] (Word docx)-.IP \[bu] 2-\f[C]epub\f[] (EPUB)-.IP \[bu] 2-\f[C]fb2\f[] (FictionBook2 e\-book)-.IP \[bu] 2-\f[C]gfm\f[] (GitHub\-Flavored Markdown), or the deprecated and less-accurate \f[C]markdown_github\f[]; use \f[C]markdown_github\f[] only if-you need extensions not supported in \f[C]gfm\f[].-.IP \[bu] 2-\f[C]haddock\f[] (Haddock markup)-.IP \[bu] 2-\f[C]html\f[] (HTML)-.IP \[bu] 2-\f[C]jats\f[] (JATS XML)-.IP \[bu] 2-\f[C]json\f[] (JSON version of native AST)-.IP \[bu] 2-\f[C]latex\f[] (LaTeX)-.IP \[bu] 2-\f[C]markdown\f[] (Pandoc\[aq]s Markdown)-.IP \[bu] 2-\f[C]markdown_mmd\f[] (MultiMarkdown)-.IP \[bu] 2-\f[C]markdown_phpextra\f[] (PHP Markdown Extra)-.IP \[bu] 2-\f[C]markdown_strict\f[] (original unextended Markdown)-.IP \[bu] 2-\f[C]mediawiki\f[] (MediaWiki markup)-.IP \[bu] 2-\f[C]muse\f[] (Muse)-.IP \[bu] 2-\f[C]native\f[] (native Haskell)-.IP \[bu] 2-\f[C]odt\f[] (ODT)-.IP \[bu] 2-\f[C]opml\f[] (OPML)-.IP \[bu] 2-\f[C]org\f[] (Emacs Org mode)-.IP \[bu] 2-\f[C]rst\f[] (reStructuredText)-.IP \[bu] 2-\f[C]t2t\f[] (txt2tags)-.IP \[bu] 2-\f[C]textile\f[] (Textile)-.IP \[bu] 2-\f[C]tikiwiki\f[] (TikiWiki markup)-.IP \[bu] 2-\f[C]twiki\f[] (TWiki markup)-.IP \[bu] 2-\f[C]vimwiki\f[] (Vimwiki)-.PP-Extensions can be individually enabled or disabled by appending-\f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format name.-See Extensions below, for a list of extensions and their names.-See \f[C]\-\-list\-input\-formats\f[] and \f[C]\-\-list\-extensions\f[],-below.-.RE-.TP-.B \f[C]\-t\f[] \f[I]FORMAT\f[], \f[C]\-w\f[] \f[I]FORMAT\f[], \f[C]\-\-to=\f[]\f[I]FORMAT\f[], \f[C]\-\-write=\f[]\f[I]FORMAT\f[]-Specify output format.-\f[I]FORMAT\f[] can be:-.RS-.IP \[bu] 2-\f[C]asciidoc\f[] (AsciiDoc)-.IP \[bu] 2-\f[C]beamer\f[] (LaTeX beamer slide show)-.IP \[bu] 2-\f[C]commonmark\f[] (CommonMark Markdown)-.IP \[bu] 2-\f[C]context\f[] (ConTeXt)-.IP \[bu] 2-\f[C]docbook\f[] or \f[C]docbook4\f[] (DocBook 4)-.IP \[bu] 2-\f[C]docbook5\f[] (DocBook 5)-.IP \[bu] 2-\f[C]docx\f[] (Word docx)-.IP \[bu] 2-\f[C]dokuwiki\f[] (DokuWiki markup)-.IP \[bu] 2-\f[C]epub\f[] or \f[C]epub3\f[] (EPUB v3 book)-.IP \[bu] 2-\f[C]epub2\f[] (EPUB v2)-.IP \[bu] 2-\f[C]fb2\f[] (FictionBook2 e\-book)-.IP \[bu] 2-\f[C]gfm\f[] (GitHub\-Flavored Markdown), or the deprecated and less-accurate \f[C]markdown_github\f[]; use \f[C]markdown_github\f[] only if-you need extensions not supported in \f[C]gfm\f[].-.IP \[bu] 2-\f[C]haddock\f[] (Haddock markup)-.IP \[bu] 2-\f[C]html\f[] or \f[C]html5\f[] (HTML, i.e.-HTML5/XHTML polyglot markup)-.IP \[bu] 2-\f[C]html4\f[] (XHTML 1.0 Transitional)-.IP \[bu] 2-\f[C]icml\f[] (InDesign ICML)-.IP \[bu] 2-\f[C]jats\f[] (JATS XML)-.IP \[bu] 2-\f[C]json\f[] (JSON version of native AST)-.IP \[bu] 2-\f[C]latex\f[] (LaTeX)-.IP \[bu] 2-\f[C]man\f[] (groff man)-.IP \[bu] 2-\f[C]markdown\f[] (Pandoc\[aq]s Markdown)-.IP \[bu] 2-\f[C]markdown_mmd\f[] (MultiMarkdown)-.IP \[bu] 2-\f[C]markdown_phpextra\f[] (PHP Markdown Extra)-.IP \[bu] 2-\f[C]markdown_strict\f[] (original unextended Markdown)-.IP \[bu] 2-\f[C]mediawiki\f[] (MediaWiki markup)-.IP \[bu] 2-\f[C]ms\f[] (groff ms)-.IP \[bu] 2-\f[C]muse\f[] (Muse),-.IP \[bu] 2-\f[C]native\f[] (native Haskell),-.IP \[bu] 2-\f[C]odt\f[] (OpenOffice text document)-.IP \[bu] 2-\f[C]opml\f[] (OPML)-.IP \[bu] 2-\f[C]opendocument\f[] (OpenDocument)-.IP \[bu] 2-\f[C]org\f[] (Emacs Org mode)-.IP \[bu] 2-\f[C]plain\f[] (plain text),-.IP \[bu] 2-\f[C]pptx\f[] (PowerPoint slide show)-.IP \[bu] 2-\f[C]rst\f[] (reStructuredText)-.IP \[bu] 2-\f[C]rtf\f[] (Rich Text Format)-.IP \[bu] 2-\f[C]texinfo\f[] (GNU Texinfo)-.IP \[bu] 2-\f[C]textile\f[] (Textile)-.IP \[bu] 2-\f[C]slideous\f[] (Slideous HTML and JavaScript slide show)-.IP \[bu] 2-\f[C]slidy\f[] (Slidy HTML and JavaScript slide show)-.IP \[bu] 2-\f[C]dzslides\f[] (DZSlides HTML5 + JavaScript slide show),-.IP \[bu] 2-\f[C]revealjs\f[] (reveal.js HTML5 + JavaScript slide show)-.IP \[bu] 2-\f[C]s5\f[] (S5 HTML and JavaScript slide show)-.IP \[bu] 2-\f[C]tei\f[] (TEI Simple)-.IP \[bu] 2-\f[C]zimwiki\f[] (ZimWiki markup)-.IP \[bu] 2-the path of a custom lua writer, see Custom writers below-.PP-Note that \f[C]odt\f[], \f[C]docx\f[], and \f[C]epub\f[] output will not-be directed to \f[I]stdout\f[] unless forced with \f[C]\-o\ \-\f[].-.PP-Extensions can be individually enabled or disabled by appending-\f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format name.-See Extensions below, for a list of extensions and their names.-See \f[C]\-\-list\-output\-formats\f[] and-\f[C]\-\-list\-extensions\f[], below.-.RE-.TP-.B \f[C]\-o\f[] \f[I]FILE\f[], \f[C]\-\-output=\f[]\f[I]FILE\f[]-Write output to \f[I]FILE\f[] instead of \f[I]stdout\f[].-If \f[I]FILE\f[] is \f[C]\-\f[], output will go to \f[I]stdout\f[], even-if a non\-textual format (\f[C]docx\f[], \f[C]odt\f[], \f[C]epub2\f[],-\f[C]epub3\f[]) is specified.-.RS-.RE-.TP-.B \f[C]\-\-data\-dir=\f[]\f[I]DIRECTORY\f[]-Specify the user data directory to search for pandoc data files.-If this option is not specified, the default user data directory will be-used.-This is, in UNIX:-.RS-.IP-.nf-\f[C]-$HOME/.pandoc-\f[]-.fi-.PP-in Windows XP:-.IP-.nf-\f[C]-C:\\Documents\ And\ Settings\\USERNAME\\Application\ Data\\pandoc-\f[]-.fi-.PP-and in Windows Vista or later:-.IP-.nf-\f[C]-C:\\Users\\USERNAME\\AppData\\Roaming\\pandoc-\f[]-.fi-.PP-You can find the default user data directory on your system by looking-at the output of \f[C]pandoc\ \-\-version\f[].-A \f[C]reference.odt\f[], \f[C]reference.docx\f[], \f[C]epub.css\f[],-\f[C]templates\f[], \f[C]slidy\f[], \f[C]slideous\f[], or \f[C]s5\f[]-directory placed in this directory will override pandoc\[aq]s normal-defaults.-.RE-.TP-.B \f[C]\-\-bash\-completion\f[]-Generate a bash completion script.-To enable bash completion with pandoc, add this to your-\f[C]\&.bashrc\f[]:-.RS-.IP-.nf-\f[C]-eval\ "$(pandoc\ \-\-bash\-completion)"-\f[]-.fi-.RE-.TP-.B \f[C]\-\-verbose\f[]-Give verbose debugging output.-Currently this only has an effect with PDF output.-.RS-.RE-.TP-.B \f[C]\-\-quiet\f[]-Suppress warning messages.-.RS-.RE-.TP-.B \f[C]\-\-fail\-if\-warnings\f[]-Exit with error status if there are any warnings.-.RS-.RE-.TP-.B \f[C]\-\-log=\f[]\f[I]FILE\f[]-Write log messages in machine\-readable JSON format to \f[I]FILE\f[].-All messages above DEBUG level will be written, regardless of verbosity-settings (\f[C]\-\-verbose\f[], \f[C]\-\-quiet\f[]).-.RS-.RE-.TP-.B \f[C]\-\-list\-input\-formats\f[]-List supported input formats, one per line.-.RS-.RE-.TP-.B \f[C]\-\-list\-output\-formats\f[]-List supported output formats, one per line.-.RS-.RE-.TP-.B \f[C]\-\-list\-extensions\f[][\f[C]=\f[]\f[I]FORMAT\f[]]-List supported extensions, one per line, preceded by a \f[C]+\f[] or-\f[C]\-\f[] indicating whether it is enabled by default in-\f[I]FORMAT\f[].-If \f[I]FORMAT\f[] is not specified, defaults for pandoc\[aq]s Markdown-are given.-.RS-.RE-.TP-.B \f[C]\-\-list\-highlight\-languages\f[]-List supported languages for syntax highlighting, one per line.-.RS-.RE-.TP-.B \f[C]\-\-list\-highlight\-styles\f[]-List supported styles for syntax highlighting, one per line.-See \f[C]\-\-highlight\-style\f[].-.RS-.RE-.TP-.B \f[C]\-v\f[], \f[C]\-\-version\f[]-Print version.-.RS-.RE-.TP-.B \f[C]\-h\f[], \f[C]\-\-help\f[]-Show usage message.-.RS-.RE-.SS Reader options-.TP-.B \f[C]\-\-base\-header\-level=\f[]\f[I]NUMBER\f[]-Specify the base level for headers (defaults to 1).-.RS-.RE-.TP-.B \f[C]\-\-strip\-empty\-paragraphs\f[]-\f[I]Deprecated. Use the \f[CI]+empty_paragraphs\f[I] extension-instead.\f[] 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.-.RS-.RE-.TP-.B \f[C]\-\-indented\-code\-classes=\f[]\f[I]CLASSES\f[]-Specify classes to use for indented code blocks\-\-for example,-\f[C]perl,numberLines\f[] or \f[C]haskell\f[].-Multiple classes may be separated by spaces or commas.-.RS-.RE-.TP-.B \f[C]\-\-default\-image\-extension=\f[]\f[I]EXTENSION\f[]-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.-.RS-.RE-.TP-.B \f[C]\-\-file\-scope\f[]-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[].-.RS-.RE-.TP-.B \f[C]\-F\f[] \f[I]PROGRAM\f[], \f[C]\-\-filter=\f[]\f[I]PROGRAM\f[]-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[]-.fi-.PP-is equivalent to-.IP-.nf-\f[C]-pandoc\ \-t\ json\ |\ ./caps.py\ latex\ |\ pandoc\ \-f\ json\ \-t\ latex-\f[]-.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[] exports \f[C]toJSONFilter\f[] to facilitate-writing filters in Haskell.-Those who would prefer to write filters in python can use the module-\f[C]pandocfilters\f[], 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[] (executable or non\-executable) where-\f[C]$DATADIR\f[] is the user data directory (see-\f[C]\-\-data\-dir\f[], above).-.IP "3." 3-\f[C]$PATH\f[] (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[]\f[I]SCRIPT\f[]-Transform the document in a similar fashion as JSON filters (see-\f[C]\-\-filter\f[]), 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[] 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\ "Hello,\ World"\ }-\ \ else-\ \ \ \ return\ inline-\ \ end-end--return\ {{Str\ =\ expand_hello_world}}-\f[]-.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[] (executable or non\-executable) where-\f[C]$DATADIR\f[] is the user data directory (see-\f[C]\-\-data\-dir\f[], above).-.RE-.TP-.B \f[C]\-M\f[] \f[I]KEY\f[][\f[C]=\f[]\f[I]VAL\f[]], \f[C]\-\-metadata=\f[]\f[I]KEY\f[][\f[C]:\f[]\f[I]VAL\f[]]-Set the metadata field \f[I]KEY\f[] to the value \f[I]VAL\f[].-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[], \f[C]\-\-metadata\f[] causes template-variables to be set.-But unlike \f[C]\-\-variable\f[], \f[C]\-\-metadata\f[] 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.-.RS-.RE-.TP-.B \f[C]\-\-metadata\-file=\f[]\f[I]FILE\f[]-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[],-overwrite values specified with this option.-.RS-.RE-.TP-.B \f[C]\-p\f[], \f[C]\-\-preserve\-tabs\f[]-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.-.RS-.RE-.TP-.B \f[C]\-\-tab\-stop=\f[]\f[I]NUMBER\f[]-Specify the number of spaces per tab (default is 4).-.RS-.RE-.TP-.B \f[C]\-\-track\-changes=accept\f[]|\f[C]reject\f[]|\f[C]all\f[]-Specifies what to do with insertions, deletions, and comments produced-by the MS Word "Track Changes" feature.-\f[C]accept\f[] (the default), inserts all insertions, and ignores all-deletions.-\f[C]reject\f[] inserts all deletions and ignores insertions.-Both \f[C]accept\f[] and \f[C]reject\f[] ignore comments.-\f[C]all\f[] puts in insertions, deletions, and comments, wrapped in-spans with \f[C]insertion\f[], \f[C]deletion\f[],-\f[C]comment\-start\f[], and \f[C]comment\-end\f[] classes,-respectively.-The author and time of change is included.-\f[C]all\f[] 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[]-produces a span with the class-\f[C]paragraph\-insertion\f[]/\f[C]paragraph\-deletion\f[] before the-affected paragraph break.-This option only affects the docx reader.-.RS-.RE-.TP-.B \f[C]\-\-extract\-media=\f[]\f[I]DIR\f[]-Extract images and other media contained in or linked from the source-document to the path \f[I]DIR\f[], 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.-.RS-.RE-.TP-.B \f[C]\-\-abbreviations=\f[]\f[I]FILE\f[]-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[] 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[].-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.-.RS-.RE-.SS General writer options-.TP-.B \f[C]\-s\f[], \f[C]\-\-standalone\f[]-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[], \f[C]epub\f[],-\f[C]epub3\f[], \f[C]fb2\f[], \f[C]docx\f[], and \f[C]odt\f[] output.-For \f[C]native\f[] output, this option causes metadata to be included;-otherwise, metadata is suppressed.-.RS-.RE-.TP-.B \f[C]\-\-template=\f[]\f[I]FILE\f[]|\f[I]URL\f[]-Use the specified file as a custom template for the generated document.-Implies \f[C]\-\-standalone\f[].-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[] looks for-\f[C]special.html\f[] for HTML output.-If the template is not found, pandoc will search for it in the-\f[C]templates\f[] subdirectory of the user data directory (see-\f[C]\-\-data\-dir\f[]).-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[]).-.RS-.RE-.TP-.B \f[C]\-V\f[] \f[I]KEY\f[][\f[C]=\f[]\f[I]VAL\f[]], \f[C]\-\-variable=\f[]\f[I]KEY\f[][\f[C]:\f[]\f[I]VAL\f[]]-Set the template variable \f[I]KEY\f[] to the value \f[I]VAL\f[] when-rendering the document in standalone mode.-This is generally only useful when the \f[C]\-\-template\f[] option is-used to specify a custom template, since pandoc automatically sets the-variables used in the default templates.-If no \f[I]VAL\f[] is specified, the key will be given the value-\f[C]true\f[].-.RS-.RE-.TP-.B \f[C]\-D\f[] \f[I]FORMAT\f[], \f[C]\-\-print\-default\-template=\f[]\f[I]FORMAT\f[]-Print the system default template for an output \f[I]FORMAT\f[].-(See \f[C]\-t\f[] for a list of possible \f[I]FORMAT\f[]s.) Templates in-the user data directory are ignored.-.RS-.RE-.TP-.B \f[C]\-\-print\-default\-data\-file=\f[]\f[I]FILE\f[]-Print a system default data file.-Files in the user data directory are ignored.-.RS-.RE-.TP-.B \f[C]\-\-eol=crlf\f[]|\f[C]lf\f[]|\f[C]native\f[]-Manually specify line endings: \f[C]crlf\f[] (Windows), \f[C]lf\f[]-(macOS/Linux/UNIX), or \f[C]native\f[] (line endings appropriate to the-OS on which pandoc is being run).-The default is \f[C]native\f[].-.RS-.RE-.TP-.B \f[C]\-\-dpi\f[]=\f[I]NUMBER\f[]-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).-.RS-.RE-.TP-.B \f[C]\-\-wrap=auto\f[]|\f[C]none\f[]|\f[C]preserve\f[]-Determine how text is wrapped in the output (the source code, not the-rendered version).-With \f[C]auto\f[] (the default), pandoc will attempt to wrap lines to-the column width specified by \f[C]\-\-columns\f[] (default 72).-With \f[C]none\f[], pandoc will not wrap lines at all.-With \f[C]preserve\f[], 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.-.RS-.RE-.TP-.B \f[C]\-\-columns=\f[]\f[I]NUMBER\f[]-Specify length of lines in characters.-This affects text wrapping in the generated source code (see-\f[C]\-\-wrap\f[]).-It also affects calculation of column widths for plain text tables (see-Tables below).-.RS-.RE-.TP-.B \f[C]\-\-toc\f[], \f[C]\-\-table\-of\-contents\f[]-Include an automatically generated table of contents (or, in the case of-\f[C]latex\f[], \f[C]context\f[], \f[C]docx\f[], \f[C]odt\f[],-\f[C]opendocument\f[], \f[C]rst\f[], or \f[C]ms\f[], an instruction to-create one) in the output document.-This option has no effect unless \f[C]\-s/\-\-standalone\f[] is used,-and it has no effect on \f[C]man\f[], \f[C]docbook4\f[],-\f[C]docbook5\f[], or \f[C]jats\f[] output.-.RS-.RE-.TP-.B \f[C]\-\-toc\-depth=\f[]\f[I]NUMBER\f[]-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 headers will be-listed in the contents).-.RS-.RE-.TP-.B \f[C]\-\-strip\-comments\f[]-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[] extension is not set.-.RS-.RE-.TP-.B \f[C]\-\-no\-highlight\f[]-Disables syntax highlighting for code blocks and inlines, even when a-language attribute is given.-.RS-.RE-.TP-.B \f[C]\-\-highlight\-style=\f[]\f[I]STYLE\f[]|\f[I]FILE\f[]-Specifies the coloring style to be used in highlighted source code.-Options are \f[C]pygments\f[] (the default), \f[C]kate\f[],-\f[C]monochrome\f[], \f[C]breezeDark\f[], \f[C]espresso\f[],-\f[C]zenburn\f[], \f[C]haddock\f[], and \f[C]tango\f[].-For more information on syntax highlighting in pandoc, see Syntax-highlighting, below.-See also \f[C]\-\-list\-highlight\-styles\f[].-.RS-.PP-Instead of a \f[I]STYLE\f[] name, a JSON file with extension-\f[C]\&.theme\f[] 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[].-.RE-.TP-.B \f[C]\-\-print\-highlight\-style=\f[]\f[I]STYLE\f[]|\f[I]FILE\f[]-Prints a JSON version of a highlighting style, which can be modified,-saved with a \f[C]\&.theme\f[] extension, and used with-\f[C]\-\-highlight\-style\f[].-.RS-.RE-.TP-.B \f[C]\-\-syntax\-definition=\f[]\f[I]FILE\f[]-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.-.RS-.RE-.TP-.B \f[C]\-H\f[] \f[I]FILE\f[], \f[C]\-\-include\-in\-header=\f[]\f[I]FILE\f[]-Include contents of \f[I]FILE\f[], verbatim, at the end of the header.-This can be used, for example, to include special CSS or JavaScript in-HTML documents.-This option can be used repeatedly to include multiple files in the-header.-They will be included in the order specified.-Implies \f[C]\-\-standalone\f[].-.RS-.RE-.TP-.B \f[C]\-B\f[] \f[I]FILE\f[], \f[C]\-\-include\-before\-body=\f[]\f[I]FILE\f[]-Include contents of \f[I]FILE\f[], verbatim, at the beginning of the-document body (e.g.-after the \f[C]<body>\f[] tag in HTML, or the \f[C]\\begin{document}\f[]-command in LaTeX).-This can be used to include navigation bars or banners in HTML-documents.-This option can be used repeatedly to include multiple files.-They will be included in the order specified.-Implies \f[C]\-\-standalone\f[].-.RS-.RE-.TP-.B \f[C]\-A\f[] \f[I]FILE\f[], \f[C]\-\-include\-after\-body=\f[]\f[I]FILE\f[]-Include contents of \f[I]FILE\f[], verbatim, at the end of the document-body (before the \f[C]</body>\f[] tag in HTML, or the-\f[C]\\end{document}\f[] command in LaTeX).-This option can be used repeatedly to include multiple files.-They will be included in the order specified.-Implies \f[C]\-\-standalone\f[].-.RS-.RE-.TP-.B \f[C]\-\-resource\-path=\f[]\f[I]SEARCHPATH\f[]-List of paths to search for images and other resources.-The paths should be separated by \f[C]:\f[] on Linux, UNIX, and macOS-systems, and by \f[C];\f[] on Windows.-If \f[C]\-\-resource\-path\f[] is not specified, the default resource-path is the working directory.-Note that, if \f[C]\-\-resource\-path\f[] is specified, the working-directory must be explicitly listed or it will not be searched.-For example: \f[C]\-\-resource\-path=.:test\f[] will search the working-directory and the \f[C]test\f[] subdirectory, in that order.-.RS-.PP-\f[C]\-\-resource\-path\f[] only has an effect if (a) the output format-embeds images (for example, \f[C]docx\f[], \f[C]pdf\f[], or-\f[C]html\f[] with \f[C]\-\-self\-contained\f[]) or (b) it is used-together with \f[C]\-\-extract\-media\f[].-.RE-.TP-.B \f[C]\-\-request\-header=\f[]\f[I]NAME\f[]\f[C]:\f[]\f[I]VAL\f[]-Set the request header \f[I]NAME\f[] to the value \f[I]VAL\f[] 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[] to \f[C]http://...\f[].-.RS-.RE-.SS Options affecting specific writers-.TP-.B \f[C]\-\-self\-contained\f[]-Produce a standalone HTML file with no external dependencies, using-\f[C]data:\f[] URIs to incorporate the contents of linked scripts,-stylesheets, images, and videos.-Implies \f[C]\-\-standalone\f[].-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-\f[C]html4\f[], \f[C]html5\f[], \f[C]html+lhs\f[], \f[C]html5+lhs\f[],-\f[C]s5\f[], \f[C]slidy\f[], \f[C]slideous\f[], \f[C]dzslides\f[], and-\f[C]revealjs\f[].-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="1"\f[] 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[] does-not work with \f[C]\-\-mathjax\f[], and some advanced features (e.g.-zoom or speaker notes) may not work in an offline "self\-contained"-\f[C]reveal.js\f[] slide show.-.RS-.RE-.TP-.B \f[C]\-\-html\-q\-tags\f[]-Use \f[C]<q>\f[] tags for quotes in HTML.-.RS-.RE-.TP-.B \f[C]\-\-ascii\f[]-Use only ASCII characters in output.-Currently supported for XML and HTML formats (which use numerical-entities instead of UTF\-8 when this option is selected) and for groff-ms and man (which use hexadecimal escapes).-.RS-.RE-.TP-.B \f[C]\-\-reference\-links\f[]-Use reference\-style links, rather than inline links, in writing-Markdown or reStructuredText.-By default inline links are used.-The placement of link references is affected by the-\f[C]\-\-reference\-location\f[] option.-.RS-.RE-.TP-.B \f[C]\-\-reference\-location\ =\ block\f[]|\f[C]section\f[]|\f[C]document\f[]-Specify whether footnotes (and references, if \f[C]reference\-links\f[]-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[].-Currently only affects the markdown writer.-.RS-.RE-.TP-.B \f[C]\-\-atx\-headers\f[]-Use ATX\-style headers in Markdown and AsciiDoc output.-The default is to use setext\-style headers for levels 1\-2, and then-ATX headers.-(Note: for \f[C]gfm\f[] output, ATX headers are always used.)-.RS-.RE-.TP-.B \f[C]\-\-top\-level\-division=[default|section|chapter|part]\f[]-Treat top\-level headers as the given division type in LaTeX, ConTeXt,-DocBook, and TEI output.-The hierarchy order is part, chapter, then section; all headers are-shifted such that the top\-level header becomes the specified type.-The default behavior is to determine the best division type via-heuristics: unless other conditions apply, \f[C]section\f[] is chosen.-When the LaTeX document class is set to \f[C]report\f[], \f[C]book\f[],-or \f[C]memoir\f[] (unless the \f[C]article\f[] option is specified),-\f[C]chapter\f[] is implied as the setting for this option.-If \f[C]beamer\f[] is the output format, specifying either-\f[C]chapter\f[] or \f[C]part\f[] will cause top\-level headers to-become \f[C]\\part{..}\f[], while second\-level headers remain as their-default type.-.RS-.RE-.TP-.B \f[C]\-N\f[], \f[C]\-\-number\-sections\f[]-Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.-By default, sections are not numbered.-Sections with class \f[C]unnumbered\f[] will never be numbered, even if-\f[C]\-\-number\-sections\f[] is specified.-.RS-.RE-.TP-.B \f[C]\-\-number\-offset=\f[]\f[I]NUMBER\f[][\f[C],\f[]\f[I]NUMBER\f[]\f[C],\f[]\f[I]...\f[]]-Offset for section headings in HTML output (ignored in other output-formats).-The first number is added to the section number for top\-level headers,-the second for second\-level headers, and so on.-So, for example, if you want the first top\-level header in your-document to be numbered "6", specify \f[C]\-\-number\-offset=5\f[].-If your document starts with a level\-2 header which you want to be-numbered "1.5", specify \f[C]\-\-number\-offset=1,4\f[].-Offsets are 0 by default.-Implies \f[C]\-\-number\-sections\f[].-.RS-.RE-.TP-.B \f[C]\-\-listings\f[]-Use the \f[C]listings\f[] 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.-.RS-.RE-.TP-.B \f[C]\-i\f[], \f[C]\-\-incremental\f[]-Make list items in slide shows display incrementally (one by one).-The default is for lists to be displayed all at once.-.RS-.RE-.TP-.B \f[C]\-\-slide\-level=\f[]\f[I]NUMBER\f[]-Specifies that headers with the specified level create slides (for-\f[C]beamer\f[], \f[C]s5\f[], \f[C]slidy\f[], \f[C]slideous\f[],-\f[C]dzslides\f[]).-Headers above this level in the hierarchy are used to divide the slide-show into sections; headers below this level create subheads within a-slide.-Note that content that is not contained under slide\-level headers 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.-.RS-.RE-.TP-.B \f[C]\-\-section\-divs\f[]-Wrap sections in \f[C]<section>\f[] tags (or \f[C]<div>\f[] tags for-\f[C]html4\f[]), and attach identifiers to the enclosing-\f[C]<section>\f[] (or \f[C]<div>\f[]) rather than the header itself.-See Header identifiers, below.-.RS-.RE-.TP-.B \f[C]\-\-email\-obfuscation=none\f[]|\f[C]javascript\f[]|\f[C]references\f[]-Specify a method for obfuscating \f[C]mailto:\f[] links in HTML-documents.-\f[C]none\f[] leaves \f[C]mailto:\f[] links as they are.-\f[C]javascript\f[] obfuscates them using JavaScript.-\f[C]references\f[] obfuscates them by printing their letters as decimal-or hexadecimal character references.-The default is \f[C]none\f[].-.RS-.RE-.TP-.B \f[C]\-\-id\-prefix=\f[]\f[I]STRING\f[]-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.-.RS-.RE-.TP-.B \f[C]\-T\f[] \f[I]STRING\f[], \f[C]\-\-title\-prefix=\f[]\f[I]STRING\f[]-Specify \f[I]STRING\f[] as a prefix at the beginning of the title that-appears in the HTML header (but not in the title as it appears at the-beginning of the HTML body).-Implies \f[C]\-\-standalone\f[].-.RS-.RE-.TP-.B \f[C]\-c\f[] \f[I]URL\f[], \f[C]\-\-css=\f[]\f[I]URL\f[]-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]stylesheet\f[]-metadata field), pandoc will look for a file \f[C]epub.css\f[] in the-user data directory (see \f[C]\-\-data\-dir\f[]).-If it is not found there, sensible defaults will be used.-.RE-.TP-.B \f[C]\-\-reference\-doc=\f[]\f[I]FILE\f[]-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[] in the user data directory (see-\f[C]\-\-data\-dir\f[]).-If this is not found either, sensible defaults will be used.-.RS-.PP-To produce a custom \f[C]reference.docx\f[], first get a copy of the-default \f[C]reference.docx\f[]:-\f[C]pandoc\ \-\-print\-default\-data\-file\ reference.docx\ >\ custom\-reference.docx\f[].-Then open \f[C]custom\-reference.docx\f[] 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] 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] Default Paragraph-Font, Body Text Char, Verbatim Char, Footnote Reference, Hyperlink;-[table] 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[] in the user data directory (see-\f[C]\-\-data\-dir\f[]).-If this is not found either, sensible defaults will be used.-.RS-.PP-To produce a custom \f[C]reference.odt\f[], first get a copy of the-default \f[C]reference.odt\f[]:-\f[C]pandoc\ \-\-print\-default\-data\-file\ reference.odt\ >\ custom\-reference.odt\f[].-Then open \f[C]custom\-reference.odt\f[] in LibreOffice, modify the-styles as you wish, and save the file.-.RE-.TP-.B PowerPoint-Any template included with a recent install of Microsoft PowerPoint-(either with \f[C]\&.pptx\f[] or \f[C]\&.potx\f[] extension) should-work, as will most templates derived from these.-.RS-.PP-The specific requirement is that the template should contain the-following four layouts as its 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[] under the \f[C]Home\f[] menu to-check.)-.PP-You can also modify the default \f[C]reference.pptx\f[]: first run-\f[C]pandoc\ \-\-print\-default\-data\-file\ reference.pptx\ >\ custom\-reference.pptx\f[],-and then modify \f[C]custom\-reference.pptx\f[] in MS PowerPoint (pandoc-will use the first four layout slides, as mentioned above).-.RE-.RE-.TP-.B \f[C]\-\-epub\-cover\-image=\f[]\f[I]FILE\f[]-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[] in a YAML metadata block (see EPUB Metadata,-below).-.RS-.RE-.TP-.B \f[C]\-\-epub\-metadata=\f[]\f[I]FILE\f[]-Look in the specified XML file for metadata for the EPUB.-The file should contain a series of Dublin Core elements.-For example:-.RS-.IP-.nf-\f[C]-\ <dc:rights>Creative\ Commons</dc:rights>-\ <dc:language>es\-AR</dc:language>-\f[]-.fi-.PP-By default, pandoc will include the following metadata elements:-\f[C]<dc:title>\f[] (from the document title), \f[C]<dc:creator>\f[]-(from the document authors), \f[C]<dc:date>\f[] (from the document date,-which should be in ISO 8601 format), \f[C]<dc:language>\f[] (from the-\f[C]lang\f[] variable, or, if is not set, the locale), and-\f[C]<dc:identifier\ id="BookId">\f[] (a randomly generated UUID).-Any of these may be overridden by elements in the metadata file.-.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[]\f[I]FILE\f[]-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[].-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[]):-.RS-.IP-.nf-\f[C]-\@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";\ }-\f[]-.fi-.RE-.TP-.B \f[C]\-\-epub\-chapter\-level=\f[]\f[I]NUMBER\f[]-Specify the header level at which to split the EPUB into separate-"chapter" files.-The default is to split into chapters at level 1 headers.-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 headers, one might want to use a-chapter level of 2 or 3.-.RS-.RE-.TP-.B \f[C]\-\-epub\-subdirectory=\f[]\f[I]DIRNAME\f[]-Specify the subdirectory in the OCF container that is to hold the-EPUB\-specific contents.-The default is \f[C]EPUB\f[].-To put the EPUB contents in the top level, use an empty string.-.RS-.RE-.TP-.B \f[C]\-\-pdf\-engine=pdflatex\f[]|\f[C]lualatex\f[]|\f[C]xelatex\f[]|\f[C]wkhtmltopdf\f[]|\f[C]weasyprint\f[]|\f[C]prince\f[]|\f[C]context\f[]|\f[C]pdfroff\f[]-Use the specified engine when producing PDF output.-The default is \f[C]pdflatex\f[].-If the engine is not in your PATH, the full path of the engine may be-specified here.-.RS-.RE-.TP-.B \f[C]\-\-pdf\-engine\-opt=\f[]\f[I]STRING\f[]-Use the given string as a command\-line argument to the-\f[C]pdf\-engine\f[].-If used multiple times, the arguments are provided with spaces between-them.-Note that no check for duplicate options is done.-.RS-.RE-.SS Citation rendering-.TP-.B \f[C]\-\-bibliography=\f[]\f[I]FILE\f[]-Set the \f[C]bibliography\f[] field in the document\[aq]s metadata to-\f[I]FILE\f[], overriding any value set in the metadata, and process-citations using \f[C]pandoc\-citeproc\f[].-(This is equivalent to-\f[C]\-\-metadata\ bibliography=FILE\ \-\-filter\ pandoc\-citeproc\f[].)-If \f[C]\-\-natbib\f[] or \f[C]\-\-biblatex\f[] is also supplied,-\f[C]pandoc\-citeproc\f[] is not used, making this equivalent to-\f[C]\-\-metadata\ bibliography=FILE\f[].-If you supply this argument multiple times, each \f[I]FILE\f[] will be-added to bibliography.-.RS-.RE-.TP-.B \f[C]\-\-csl=\f[]\f[I]FILE\f[]-Set the \f[C]csl\f[] field in the document\[aq]s metadata to-\f[I]FILE\f[], overriding any value set in the metadata.-(This is equivalent to \f[C]\-\-metadata\ csl=FILE\f[].) This option is-only relevant with \f[C]pandoc\-citeproc\f[].-.RS-.RE-.TP-.B \f[C]\-\-citation\-abbreviations=\f[]\f[I]FILE\f[]-Set the \f[C]citation\-abbreviations\f[] field in the document\[aq]s-metadata to \f[I]FILE\f[], overriding any value set in the metadata.-(This is equivalent to-\f[C]\-\-metadata\ citation\-abbreviations=FILE\f[].) This option is-only relevant with \f[C]pandoc\-citeproc\f[].-.RS-.RE-.TP-.B \f[C]\-\-natbib\f[]-Use \f[C]natbib\f[] for citations in LaTeX output.-This option is not for use with the \f[C]pandoc\-citeproc\f[] filter or-with PDF output.-It is intended for use in producing a LaTeX file that can be processed-with \f[C]bibtex\f[].-.RS-.RE-.TP-.B \f[C]\-\-biblatex\f[]-Use \f[C]biblatex\f[] for citations in LaTeX output.-This option is not for use with the \f[C]pandoc\-citeproc\f[] filter or-with PDF output.-It is intended for use in producing a LaTeX file that can be processed-with \f[C]bibtex\f[] or \f[C]biber\f[].-.RS-.RE-.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[] with \f[C]class="math"\f[], 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[] or another of the following-options.-.TP-.B \f[C]\-\-mathjax\f[][\f[C]=\f[]\f[I]URL\f[]]-Use MathJax to display embedded TeX math in HTML output.-TeX math will be put between \f[C]\\(...\\)\f[] (for inline math) or-\f[C]\\[...\\]\f[] (for display math) and wrapped in \f[C]<span>\f[]-tags with class \f[C]math\f[].-Then the MathJax JavaScript will render it.-The \f[I]URL\f[] should point to the \f[C]MathJax.js\f[] load script.-If a \f[I]URL\f[] is not provided, a link to the Cloudflare CDN will be-inserted.-.RS-.RE-.TP-.B \f[C]\-\-mathml\f[]-Convert TeX math to MathML (in \f[C]epub3\f[], \f[C]docbook4\f[],-\f[C]docbook5\f[], \f[C]jats\f[], \f[C]html4\f[] and \f[C]html5\f[]).-This is the default in \f[C]odt\f[] output.-Note that currently only Firefox and Safari (and select e\-book readers)-natively support MathML.-.RS-.RE-.TP-.B \f[C]\-\-webtex\f[][\f[C]=\f[]\f[I]URL\f[]]-Convert TeX formulas to \f[C]<img>\f[] tags that link to an external-script that converts formulas to images.-The formula will be URL\-encoded and concatenated with the URL provided.-For SVG images you can for example use-\f[C]\-\-webtex\ https://latex.codecogs.com/svg.latex?\f[].-If no URL is specified, the CodeCogs URL generating PNGs will be used-(\f[C]https://latex.codecogs.com/png.latex?\f[]).-Note: the \f[C]\-\-webtex\f[] 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.-.RS-.RE-.TP-.B \f[C]\-\-katex\f[][\f[C]=\f[]\f[I]URL\f[]]-Use KaTeX to display embedded TeX math in HTML output.-The \f[I]URL\f[] is the base URL for the KaTeX library.-That directory should contain a \f[C]katex.min.js\f[] and a-\f[C]katex.min.css\f[] file.-If a \f[I]URL\f[] is not provided, a link to the KaTeX CDN will be-inserted.-.RS-.RE-.TP-.B \f[C]\-\-gladtex\f[]-Enclose TeX math in \f[C]<eq>\f[] 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[]-.fi-.RE-.SS Options for wrapper scripts-.TP-.B \f[C]\-\-dump\-args\f[]-Print information about command\-line arguments to \f[I]stdout\f[], then-exit.-This option is intended primarily for use in wrapper scripts.-The first line of output contains the name of the output file specified-with the \f[C]\-o\f[] option, or \f[C]\-\f[] (for \f[I]stdout\f[]) if no-output file was specified.-The remaining lines contain the command\-line arguments, one per line,-in the order they appear.-These do not include regular pandoc options and their arguments, but do-include any options appearing after a \f[C]\-\-\f[] separator at the end-of the line.-.RS-.RE-.TP-.B \f[C]\-\-ignore\-args\f[]-Ignore command\-line arguments (for use in wrapper scripts).-Regular pandoc options are not ignored.-Thus, for example,-.RS-.IP-.nf-\f[C]-pandoc\ \-\-ignore\-args\ \-o\ foo.html\ \-s\ foo.txt\ \-\-\ \-e\ latin1-\f[]-.fi-.PP-is equivalent to-.IP-.nf-\f[C]-pandoc\ \-o\ foo.html\ \-s-\f[]-.fi-.RE-.SH TEMPLATES-.PP-When the \f[C]\-s/\-\-standalone\f[] option is used, pandoc uses a-template to add header and footer material that is needed for a-self\-standing document.-To see the default template that is used, just type-.IP-.nf-\f[C]-pandoc\ \-D\ *FORMAT*-\f[]-.fi-.PP-where \f[I]FORMAT\f[] is the name of the output format.-A custom template can be specified using the \f[C]\-\-template\f[]-option.-You can also override the system default templates for a given output-format \f[I]FORMAT\f[] by putting a file-\f[C]templates/default.*FORMAT*\f[] in the user data directory (see-\f[C]\-\-data\-dir\f[], above).-\f[I]Exceptions:\f[]-.IP \[bu] 2-For \f[C]odt\f[] output, customize the \f[C]default.opendocument\f[]-template.-.IP \[bu] 2-For \f[C]pdf\f[] output, customize the \f[C]default.latex\f[] template-(or the \f[C]default.context\f[] template, if you use-\f[C]\-t\ context\f[], or the \f[C]default.ms\f[] template, if you use-\f[C]\-t\ ms\f[], or the \f[C]default.html\f[] template, if you use-\f[C]\-t\ html\f[]).-.IP \[bu] 2-\f[C]docx\f[] has no template (however, you can use-\f[C]\-\-reference\-doc\f[] to customize the output).-.PP-Templates contain \f[I]variables\f[], 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[]-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]\-\-metadata\f[] option.-.SS Variables set by pandoc-.PP-Some variables are set automatically by pandoc.-These vary somewhat depending on the output format, but include the-following:-.TP-.B \f[C]sourcefile\f[], \f[C]outputfile\f[]-source and destination filenames, as given on the command line.-\f[C]sourcefile\f[] 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[]-.fi-.PP-Similarly, \f[C]outputfile\f[] can be \f[C]\-\f[] if output goes to the-terminal.-.RE-.TP-.B \f[C]title\f[], \f[C]author\f[], \f[C]date\f[]-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[]-.fi-.RE-.TP-.B \f[C]subtitle\f[]-document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word-docx; renders in LaTeX only when using a document class that supports-\f[C]\\subtitle\f[], such as \f[C]beamer\f[] or the KOMA\-Script series-(\f[C]scrartcl\f[], \f[C]scrreprt\f[], \f[C]scrbook\f[]).-.RS-.RE-.TP-.B \f[C]institute\f[]-author affiliations (in LaTeX and Beamer only).-Can be a list, when there are multiple authors.-.RS-.RE-.TP-.B \f[C]abstract\f[]-document summary, included in LaTeX, ConTeXt, AsciiDoc, and Word docx-.RS-.RE-.TP-.B \f[C]keywords\f[]-list of keywords to be included in HTML, PDF, and AsciiDoc metadata; may-be repeated as for \f[C]author\f[], above-.RS-.RE-.TP-.B \f[C]header\-includes\f[]-contents specified by \f[C]\-H/\-\-include\-in\-header\f[] (may have-multiple values)-.RS-.RE-.TP-.B \f[C]toc\f[]-non\-null value if \f[C]\-\-toc/\-\-table\-of\-contents\f[] was-specified-.RS-.RE-.TP-.B \f[C]toc\-title\f[]-title of table of contents (works only with EPUB, opendocument, odt,-docx, pptx, beamer, LaTeX)-.RS-.RE-.TP-.B \f[C]include\-before\f[]-contents specified by \f[C]\-B/\-\-include\-before\-body\f[] (may have-multiple values)-.RS-.RE-.TP-.B \f[C]include\-after\f[]-contents specified by \f[C]\-A/\-\-include\-after\-body\f[] (may have-multiple values)-.RS-.RE-.TP-.B \f[C]body\f[]-body of document-.RS-.RE-.TP-.B \f[C]meta\-json\f[]-JSON representation of all of the document\[aq]s metadata.-Field values are transformed to the selected output format.-.RS-.RE-.SS Language variables-.TP-.B \f[C]lang\f[]-identifies the main language of the document, using a code according to-BCP 47 (e.g.-\f[C]en\f[] or \f[C]en\-GB\f[]).-For some output formats, pandoc will convert it to an appropriate format-stored in the additional variables \f[C]babel\-lang\f[],-\f[C]polyglossia\-lang\f[] (LaTeX) and \f[C]context\-lang\f[] (ConTeXt).-.RS-.PP-Native pandoc Spans and Divs with the lang attribute (value in BCP 47)-can be used to switch the language in that range.-In LaTeX output, \f[C]babel\-otherlangs\f[] and-\f[C]polyglossia\-otherlangs\f[] variables will be generated-automatically based on the \f[C]lang\f[] attributes of Spans and Divs in-the document.-.RE-.TP-.B \f[C]dir\f[]-the base direction of the document, either \f[C]rtl\f[]-(right\-to\-left) or \f[C]ltr\f[] (left\-to\-right).-.RS-.PP-For bidirectional documents, native pandoc \f[C]span\f[]s and-\f[C]div\f[]s with the \f[C]dir\f[] attribute (value \f[C]rtl\f[] or-\f[C]ltr\f[]) 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[]-engine is fully supported (use \f[C]\-\-pdf\-engine=xelatex\f[]).-.RE-.SS Variables for slides-.PP-Variables are available for producing slide shows with pandoc, including-all reveal.js configuration options.-.TP-.B \f[C]titlegraphic\f[]-title graphic for Beamer documents-.RS-.RE-.TP-.B \f[C]logo\f[]-logo for Beamer documents-.RS-.RE-.TP-.B \f[C]slidy\-url\f[]-base URL for Slidy documents (defaults to-\f[C]https://www.w3.org/Talks/Tools/Slidy2\f[])-.RS-.RE-.TP-.B \f[C]slideous\-url\f[]-base URL for Slideous documents (defaults to \f[C]slideous\f[])-.RS-.RE-.TP-.B \f[C]s5\-url\f[]-base URL for S5 documents (defaults to \f[C]s5/default\f[])-.RS-.RE-.TP-.B \f[C]revealjs\-url\f[]-base URL for reveal.js documents (defaults to \f[C]reveal.js\f[])-.RS-.RE-.TP-.B \f[C]theme\f[], \f[C]colortheme\f[], \f[C]fonttheme\f[], \f[C]innertheme\f[], \f[C]outertheme\f[]-themes for LaTeX \f[C]beamer\f[] documents-.RS-.RE-.TP-.B \f[C]themeoptions\f[]-options for LaTeX beamer themes (a list).-.RS-.RE-.TP-.B \f[C]navigation\f[]-controls navigation symbols in \f[C]beamer\f[] documents (default is-\f[C]empty\f[] for no navigation symbols; other valid values are-\f[C]frame\f[], \f[C]vertical\f[], and \f[C]horizontal\f[]).-.RS-.RE-.TP-.B \f[C]section\-titles\f[]-enables on "title pages" for new sections in \f[C]beamer\f[] documents-(default = true).-.RS-.RE-.TP-.B \f[C]beamerarticle\f[]-when true, the \f[C]beamerarticle\f[] package is loaded (for producing-an article from beamer slides).-.RS-.RE-.TP-.B \f[C]aspectratio\f[]-aspect ratio of slides (for beamer only, \f[C]1610\f[] for 16:10,-\f[C]169\f[] for 16:9, \f[C]149\f[] for 14:9, \f[C]141\f[] for 1.41:1,-\f[C]54\f[] for 5:4, \f[C]43\f[] for 4:3 which is the default, and-\f[C]32\f[] for 3:2).-.RS-.RE-.SS Variables for LaTeX-.PP-LaTeX variables are used when creating a PDF.-.TP-.B \f[C]papersize\f[]-paper size, e.g.-\f[C]letter\f[], \f[C]a4\f[]-.RS-.RE-.TP-.B \f[C]fontsize\f[]-font size for body text (e.g.-\f[C]10pt\f[], \f[C]12pt\f[])-.RS-.RE-.TP-.B \f[C]documentclass\f[]-document class, e.g.-\f[C]article\f[], \f[C]report\f[], \f[C]book\f[], \f[C]memoir\f[]-.RS-.RE-.TP-.B \f[C]classoption\f[]-option for document class, e.g.-\f[C]oneside\f[]; may be repeated for multiple options-.RS-.RE-.TP-.B \f[C]beameroption\f[]-In beamer, add extra beamer option with \f[C]\\setbeameroption{}\f[]-.RS-.RE-.TP-.B \f[C]geometry\f[]-option for \f[C]geometry\f[] package, e.g.-\f[C]margin=1in\f[]; may be repeated for multiple options-.RS-.RE-.TP-.B \f[C]margin\-left\f[], \f[C]margin\-right\f[], \f[C]margin\-top\f[], \f[C]margin\-bottom\f[]-sets margins, if \f[C]geometry\f[] is not used (otherwise-\f[C]geometry\f[] overrides these)-.RS-.RE-.TP-.B \f[C]linestretch\f[]-adjusts line spacing using the \f[C]setspace\f[] package, e.g.-\f[C]1.25\f[], \f[C]1.5\f[]-.RS-.RE-.TP-.B \f[C]fontfamily\f[]-font package for use with \f[C]pdflatex\f[]: TeX Live includes many-options, documented in the LaTeX Font Catalogue.-The default is Latin Modern.-.RS-.RE-.TP-.B \f[C]fontfamilyoptions\f[]-options for package used as \f[C]fontfamily\f[]: e.g.-\f[C]osf,sc\f[] with \f[C]fontfamily\f[] set to \f[C]mathpazo\f[]-provides Palatino with old\-style figures and true small caps; may be-repeated for multiple options-.RS-.RE-.TP-.B \f[C]mainfont\f[], \f[C]sansfont\f[], \f[C]monofont\f[], \f[C]mathfont\f[], \f[C]CJKmainfont\f[]-font families for use with \f[C]xelatex\f[] or \f[C]lualatex\f[]: take-the name of any system font, using the \f[C]fontspec\f[] package.-Note that if \f[C]CJKmainfont\f[] is used, the \f[C]xecjk\f[] package-must be available.-.RS-.RE-.TP-.B \f[C]mainfontoptions\f[], \f[C]sansfontoptions\f[], \f[C]monofontoptions\f[], \f[C]mathfontoptions\f[], \f[C]CJKoptions\f[]-options to use with \f[C]mainfont\f[], \f[C]sansfont\f[],-\f[C]monofont\f[], \f[C]mathfont\f[], \f[C]CJKmainfont\f[] in-\f[C]xelatex\f[] and \f[C]lualatex\f[].-Allow for any choices available through \f[C]fontspec\f[], such as the-OpenType features \f[C]Numbers=OldStyle,Numbers=Proportional\f[].-May be repeated for multiple options.-.RS-.RE-.TP-.B \f[C]fontenc\f[]-allows font encoding to be specified through \f[C]fontenc\f[] package-(with \f[C]pdflatex\f[]); default is \f[C]T1\f[] (see guide to LaTeX-font encodings)-.RS-.RE-.TP-.B \f[C]microtypeoptions\f[]-options to pass to the microtype package-.RS-.RE-.TP-.B \f[C]colorlinks\f[]-add color to link text; automatically enabled if any of-\f[C]linkcolor\f[], \f[C]filecolor\f[], \f[C]citecolor\f[],-\f[C]urlcolor\f[], or \f[C]toccolor\f[] are set-.RS-.RE-.TP-.B \f[C]linkcolor\f[], \f[C]filecolor\f[], \f[C]citecolor\f[], \f[C]urlcolor\f[], \f[C]toccolor\f[]-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[], including the \f[C]dvipsnames\f[], \f[C]svgnames\f[],-and \f[C]x11names\f[] lists-.RS-.RE-.TP-.B \f[C]links\-as\-notes\f[]-causes links to be printed as footnotes-.RS-.RE-.TP-.B \f[C]indent\f[]-uses document class settings for indentation (the default LaTeX template-otherwise removes indentation and adds space between paragraphs)-.RS-.RE-.TP-.B \f[C]subparagraph\f[]-disables default behavior of LaTeX template that redefines-(sub)paragraphs as sections, changing the appearance of nested headings-in some classes-.RS-.RE-.TP-.B \f[C]thanks\f[]-specifies contents of acknowledgments footnote after document title.-.RS-.RE-.TP-.B \f[C]toc\f[]-include table of contents (can also be set using-\f[C]\-\-toc/\-\-table\-of\-contents\f[])-.RS-.RE-.TP-.B \f[C]toc\-depth\f[]-level of section to include in table of contents-.RS-.RE-.TP-.B \f[C]secnumdepth\f[]-numbering depth for sections, if sections are numbered-.RS-.RE-.TP-.B \f[C]lof\f[], \f[C]lot\f[]-include list of figures, list of tables-.RS-.RE-.TP-.B \f[C]bibliography\f[]-bibliography to use for resolving references-.RS-.RE-.TP-.B \f[C]biblio\-style\f[]-bibliography style, when used with \f[C]\-\-natbib\f[] and-\f[C]\-\-biblatex\f[].-.RS-.RE-.TP-.B \f[C]biblio\-title\f[]-bibliography title, when used with \f[C]\-\-natbib\f[] and-\f[C]\-\-biblatex\f[].-.RS-.RE-.TP-.B \f[C]biblatexoptions\f[]-list of options for biblatex.-.RS-.RE-.TP-.B \f[C]natbiboptions\f[]-list of options for natbib.-.RS-.RE-.TP-.B \f[C]pagestyle\f[]-An option for LaTeX\[aq]s \f[C]\\pagestyle{}\f[].-The default article class supports \[aq]plain\[aq] (default),-\[aq]empty\[aq], and \[aq]headings\[aq]; headings puts section titles in-the header.-.RS-.RE-.SS Variables for ConTeXt-.TP-.B \f[C]papersize\f[]-paper size, e.g.-\f[C]letter\f[], \f[C]A4\f[], \f[C]landscape\f[] (see ConTeXt Paper-Setup); may be repeated for multiple options-.RS-.RE-.TP-.B \f[C]layout\f[]-options for page margins and text arrangement (see ConTeXt Layout); may-be repeated for multiple options-.RS-.RE-.TP-.B \f[C]margin\-left\f[], \f[C]margin\-right\f[], \f[C]margin\-top\f[], \f[C]margin\-bottom\f[]-sets margins, if \f[C]layout\f[] is not used (otherwise \f[C]layout\f[]-overrides these)-.RS-.RE-.TP-.B \f[C]fontsize\f[]-font size for body text (e.g.-\f[C]10pt\f[], \f[C]12pt\f[])-.RS-.RE-.TP-.B \f[C]mainfont\f[], \f[C]sansfont\f[], \f[C]monofont\f[], \f[C]mathfont\f[]-font families: take the name of any system font (see ConTeXt Font-Switching)-.RS-.RE-.TP-.B \f[C]linkcolor\f[], \f[C]contrastcolor\f[]-color for links outside and inside a page, e.g.-\f[C]red\f[], \f[C]blue\f[] (see ConTeXt Color)-.RS-.RE-.TP-.B \f[C]linkstyle\f[]-typeface style for links, e.g.-\f[C]normal\f[], \f[C]bold\f[], \f[C]slanted\f[], \f[C]boldslanted\f[],-\f[C]type\f[], \f[C]cap\f[], \f[C]small\f[]-.RS-.RE-.TP-.B \f[C]indenting\f[]-controls indentation of paragraphs, e.g.-\f[C]yes,small,next\f[] (see ConTeXt Indentation); may be repeated for-multiple options-.RS-.RE-.TP-.B \f[C]whitespace\f[]-spacing between paragraphs, e.g.-\f[C]none\f[], \f[C]small\f[] (using \f[C]setupwhitespace\f[])-.RS-.RE-.TP-.B \f[C]interlinespace\f[]-adjusts line spacing, e.g.-\f[C]4ex\f[] (using \f[C]setupinterlinespace\f[]); may be repeated for-multiple options-.RS-.RE-.TP-.B \f[C]headertext\f[], \f[C]footertext\f[]-text to be placed in running header or footer (see ConTeXt Headers and-Footers); may be repeated up to four times for different placement-.RS-.RE-.TP-.B \f[C]pagenumbering\f[]-page number style and location (using \f[C]setuppagenumbering\f[]); may-be repeated for multiple options-.RS-.RE-.TP-.B \f[C]toc\f[]-include table of contents (can also be set using-\f[C]\-\-toc/\-\-table\-of\-contents\f[])-.RS-.RE-.TP-.B \f[C]lof\f[], \f[C]lot\f[]-include list of figures, list of tables-.RS-.RE-.TP-.B \f[C]pdfa\f[]-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.-.RS-.RE-.SS Variables for man pages-.TP-.B \f[C]section\f[]-section number in man pages-.RS-.RE-.TP-.B \f[C]header\f[]-header in man pages-.RS-.RE-.TP-.B \f[C]footer\f[]-footer in man pages-.RS-.RE-.TP-.B \f[C]adjusting\f[]-adjusts text to left (\f[C]l\f[]), right (\f[C]r\f[]), center-(\f[C]c\f[]), or both (\f[C]b\f[]) margins-.RS-.RE-.TP-.B \f[C]hyphenate\f[]-if \f[C]true\f[] (the default), hyphenation will be used-.RS-.RE-.SS Variables for ms-.TP-.B \f[C]pointsize\f[]-point size (e.g.-\f[C]10p\f[])-.RS-.RE-.TP-.B \f[C]lineheight\f[]-line height (e.g.-\f[C]12p\f[])-.RS-.RE-.TP-.B \f[C]fontfamily\f[]-font family (e.g.-\f[C]T\f[] or \f[C]P\f[])-.RS-.RE-.TP-.B \f[C]indent\f[]-paragraph indent (e.g.-\f[C]2m\f[])-.RS-.RE-.SS Using variables in templates-.PP-Variable names are sequences of alphanumerics, \f[C]\-\f[], and-\f[C]_\f[], starting with a letter.-A variable name surrounded by \f[C]$\f[] signs will be replaced by its-value.-For example, the string \f[C]$title$\f[] in-.IP-.nf-\f[C]-<title>$title$</title>-\f[]-.fi-.PP-will be replaced by the document title.-.PP-To write a literal \f[C]$\f[] in a template, use \f[C]$$\f[].-.PP-Templates may contain conditionals.-The syntax is as follows:-.IP-.nf-\f[C]-$if(variable)$-X-$else$-Y-$endif$-\f[]-.fi-.PP-This will include \f[C]X\f[] in the template if \f[C]variable\f[] has a-truthy value; otherwise it will include \f[C]Y\f[].-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[] (to specify the boolean \f[C]true\f[] value-using YAML metadata or the \f[C]\-\-metadata\f[] flag, use-\f[C]true\f[], \f[C]True\f[], or \f[C]TRUE\f[]; with the-\f[C]\-\-variable\f[] flag, simply omit a value for the variable, e.g.-\f[C]\-\-variable\ draft\f[]).-.PP-\f[C]X\f[] and \f[C]Y\f[] are placeholders for any valid template text,-and may include interpolated variables or other conditionals.-The \f[C]$else$\f[] section may be omitted.-.PP-When variables can have multiple values (for example, \f[C]author\f[] in-a multi\-author document), you can use the \f[C]$for$\f[] keyword:-.IP-.nf-\f[C]-$for(author)$-<meta\ name="author"\ content="$author$"\ />-$endfor$-\f[]-.fi-.PP-You can optionally specify a separator to be used between consecutive-items:-.IP-.nf-\f[C]-$for(author)$$author$$sep$,\ $endfor$-\f[]-.fi-.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[]-.fi-.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[]-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[] to the format-name and disabled by adding \f[C]\-EXTENSION\f[].-For example, \f[C]\-\-from\ markdown_strict+footnotes\f[] is strict-Markdown with footnotes enabled, while-\f[C]\-\-from\ markdown\-footnotes\-pipe_tables\f[] 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[] and \f[C]gfm\f[].) In the following, extensions that-also work for other formats are covered.-.SS Typography-.SS Extension: \f[C]smart\f[]-.PP-Interpret straight quotes as curly quotes, \f[C]\-\-\-\f[] as-em\-dashes, \f[C]\-\-\f[] as en\-dashes, and \f[C]\&...\f[] as ellipses.-Nonbreaking spaces are inserted after certain abbreviations, such as-"Mr."-.PP-This extension can be enabled/disabled for the following formats:-.TP-.B input formats-\f[C]markdown\f[], \f[C]commonmark\f[], \f[C]latex\f[],-\f[C]mediawiki\f[], \f[C]org\f[], \f[C]rst\f[], \f[C]twiki\f[]-.RS-.RE-.TP-.B output formats-\f[C]markdown\f[], \f[C]latex\f[], \f[C]context\f[], \f[C]rst\f[]-.RS-.RE-.TP-.B enabled by default in-\f[C]markdown\f[], \f[C]latex\f[], \f[C]context\f[] (both input and-output)-.RS-.RE-.PP-Note: If you are \f[I]writing\f[] Markdown, then the \f[C]smart\f[]-extension has the reverse effect: what would have been curly quotes-comes out straight.-.PP-In LaTeX, \f[C]smart\f[] means to use the standard TeX ligatures for-quotation marks (\f[C]``\f[] and \f[C]\[aq]\[aq]\f[] for double quotes,-\f[C]`\f[] and \f[C]\[aq]\f[] for single quotes) and dashes-(\f[C]\-\-\f[] for en\-dash and \f[C]\-\-\-\f[] for em\-dash).-If \f[C]smart\f[] is disabled, then in reading LaTeX pandoc will parse-these characters literally.-In writing LaTeX, enabling \f[C]smart\f[] tells pandoc to use the-ligatures when possible; if \f[C]smart\f[] is disabled pandoc will use-unicode quotation mark and dash characters.-.SS Headers and sections-.SS Extension: \f[C]auto_identifiers\f[]-.PP-A header without an explicitly specified identifier will be-automatically assigned a unique identifier based on the header text.-.PP-This extension can be enabled/disabled for the following formats:-.TP-.B input formats-\f[C]markdown\f[], \f[C]latex\f[], \f[C]rst\f[], \f[C]mediawiki\f[],-\f[C]textile\f[]-.RS-.RE-.TP-.B output formats-\f[C]markdown\f[], \f[C]muse\f[]-.RS-.RE-.TP-.B enabled by default in-\f[C]markdown\f[], \f[C]muse\f[]-.RS-.RE-.PP-The algorithm used to derive the identifier from the header text is:-.IP \[bu] 2-Remove all formatting, links, etc.-.IP \[bu] 2-Remove all footnotes.-.IP \[bu] 2-Remove all punctuation, except underscores, hyphens, and periods.-.IP \[bu] 2-Replace all spaces and newlines with hyphens.-.IP \[bu] 2-Convert all alphabetic characters to lowercase.-.IP \[bu] 2-Remove everything up to the first letter (identifiers may not begin with-a number or punctuation mark).-.IP \[bu] 2-If nothing is left after this, use the identifier \f[C]section\f[].-.PP-Thus, for example,-.PP-.TS-tab(@);-l l.-T{-Header-T}@T{-Identifier-T}-_-T{-\f[C]Header\ identifiers\ in\ HTML\f[]-T}@T{-\f[C]header\-identifiers\-in\-html\f[]-T}-T{-\f[C]*Dogs*?\-\-in\ *my*\ house?\f[]-T}@T{-\f[C]dogs\-\-in\-my\-house\f[]-T}-T{-\f[C][HTML],\ [S5],\ or\ [RTF]?\f[]-T}@T{-\f[C]html\-s5\-or\-rtf\f[]-T}-T{-\f[C]3.\ Applications\f[]-T}@T{-\f[C]applications\f[]-T}-T{-\f[C]33\f[]-T}@T{-\f[C]section\f[]-T}-.TE-.PP-These rules should, in most cases, allow one to determine the identifier-from the header text.-The exception is when several headers have the same text; in this case,-the first will get an identifier as described above; the second will get-the same identifier with \f[C]\-1\f[] appended; the third with-\f[C]\-2\f[]; and so on.-.PP-These identifiers are used to provide link targets in the table of-contents generated by the \f[C]\-\-toc|\-\-table\-of\-contents\f[]-option.-They also make it easy to provide links from one section of a document-to another.-A link to this section, for example, might look like this:-.IP-.nf-\f[C]-See\ the\ section\ on-[header\ identifiers](#header\-identifiers\-in\-html\-latex\-and\-context).-\f[]-.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[] option is specified, then each section-will be wrapped in a \f[C]section\f[] (or a \f[C]div\f[], if-\f[C]html4\f[] was specified), and the identifier will be attached to-the enclosing \f[C]<section>\f[] (or \f[C]<div>\f[]) tag rather than the-header itself.-This allows entire sections to be manipulated using JavaScript or-treated differently in CSS.-.SS Extension: \f[C]ascii_identifiers\f[]-.PP-Causes the identifiers produced by \f[C]auto_identifiers\f[] to be pure-ASCII.-Accents are stripped off of accented Latin letters, and non\-Latin-letters are omitted.-.SS Math Input-.PP-The extensions \f[C]tex_math_dollars\f[],-\f[C]tex_math_single_backslash\f[], and-\f[C]tex_math_double_backslash\f[] 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[]-.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[]-.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[]):-.TP-.B input formats-\f[C]latex\f[], \f[C]org\f[], \f[C]textile\f[], \f[C]html\f[]-(environments, \f[C]\\ref\f[], and \f[C]\\eqref\f[] only)-.RS-.RE-.TP-.B output formats-\f[C]textile\f[], \f[C]commonmark\f[]-.RS-.RE-.SS Extension: \f[C]native_divs\f[]-.PP-This extension is enabled by default for HTML input.-This means that \f[C]div\f[]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[].)-.PP-When converting HTML to Markdown, for example, you may want to drop all-\f[C]div\f[]s and \f[C]span\f[]s:-.IP-.nf-\f[C]-pandoc\ \-f\ html\-native_divs\-native_spans\ \-t\ markdown-\f[]-.fi-.SS Extension: \f[C]native_spans\f[]-.PP-Analogous to \f[C]native_divs\f[] above.-.SS Literate Haskell support-.SS Extension: \f[C]literate_haskell\f[]-.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[], \f[C]rst\f[], \f[C]latex\f[]-.RS-.RE-.TP-.B output formats-\f[C]markdown\f[], \f[C]rst\f[], \f[C]latex\f[], \f[C]html\f[]-.RS-.RE-.PP-If you append \f[C]+lhs\f[] (or \f[C]+literate_haskell\f[]) to one of-the formats above, pandoc will treat the document as literate Haskell-source.-This means that-.IP \[bu] 2-In Markdown input, "bird track" sections will be parsed as Haskell code-rather than block quotations.-Text between \f[C]\\begin{code}\f[] and \f[C]\\end{code}\f[] will also-be treated as Haskell code.-For ATX\-style headers 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[] and-\f[C]literate\f[] will be rendered using bird tracks, and block-quotations will be indented one space, so they will not be treated as-Haskell code.-In addition, headers will be rendered setext\-style (with underlines)-rather than ATX\-style (with \[aq]#\[aq] characters).-(This is because ghc treats \[aq]#\[aq] characters in column 1 as-introducing line numbers.)-.IP \[bu] 2-In restructured text input, "bird track" sections will be parsed as-Haskell code.-.IP \[bu] 2-In restructured text output, code blocks with class \f[C]haskell\f[]-will be rendered using bird tracks.-.IP \[bu] 2-In LaTeX input, text in \f[C]code\f[] environments will be parsed as-Haskell code.-.IP \[bu] 2-In LaTeX output, code blocks with class \f[C]haskell\f[] will be-rendered inside \f[C]code\f[] environments.-.IP \[bu] 2-In HTML output, code blocks with class \f[C]haskell\f[] will be rendered-with class \f[C]literatehaskell\f[] and bird tracks.-.PP-Examples:-.IP-.nf-\f[C]-pandoc\ \-f\ markdown+lhs\ \-t\ html-\f[]-.fi-.PP-reads literate Haskell source formatted with Markdown conventions and-writes ordinary HTML (without bird tracks).-.IP-.nf-\f[C]-pandoc\ \-f\ markdown+lhs\ \-t\ html+lhs-\f[]-.fi-.PP-writes HTML with the Haskell code in bird tracks, so it can be copied-and pasted as literate Haskell source.-.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[]-.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[], \f[C]html\f[]-.RS-.RE-.TP-.B output formats-\f[C]docx\f[], \f[C]odt\f[], \f[C]opendocument\f[], \f[C]html\f[]-.RS-.RE-.SS Extension: \f[C]styles\f[]-.PP-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[]-.RS-.RE-.SS Extension: \f[C]amuse\f[]-.PP-In the \f[C]muse\f[] input format, this enables Text::Amuse extensions-to Emacs Muse markup.-.SS Extension: \f[C]citations\f[]-.PP-Some aspects of Pandoc\[aq]s Markdown citation syntax are also accepted-in \f[C]org\f[] input.-.SS Extension: \f[C]ntb\f[]-.PP-In the \f[C]context\f[] 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[] format instead of \f[C]markdown\f[].-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[]-.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 Headers-.PP-There are two kinds of headers: Setext and ATX.-.SS Setext\-style headers-.PP-A setext\-style header is a line of text "underlined" with a row of-\f[C]=\f[] signs (for a level one header) or \f[C]\-\f[] signs (for a-level two header):-.IP-.nf-\f[C]-A\ level\-one\ header-==================--A\ level\-two\ header-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\f[]-.fi-.PP-The header text can contain inline formatting, such as emphasis (see-Inline formatting, below).-.SS ATX\-style headers-.PP-An ATX\-style header consists of one to six \f[C]#\f[] signs and a line-of text, optionally followed by any number of \f[C]#\f[] signs.-The number of \f[C]#\f[] signs at the beginning of the line is the-header level:-.IP-.nf-\f[C]-##\ A\ level\-two\ header--###\ A\ level\-three\ header\ ###-\f[]-.fi-.PP-As with setext\-style headers, the header text can contain formatting:-.IP-.nf-\f[C]-#\ A\ level\-one\ header\ with\ a\ [link](/url)\ and\ *emphasis*-\f[]-.fi-.SS Extension: \f[C]blank_before_header\f[]-.PP-Standard Markdown syntax does not require a blank line before a header.-Pandoc does require this (except, of course, at the beginning of the-document).-The reason for the requirement is that it is all too easy for a-\f[C]#\f[] to end up at the beginning of a line by accident (perhaps-through line wrapping).-Consider, for example:-.IP-.nf-\f[C]-I\ like\ several\ of\ their\ flavors\ of\ ice\ cream:-#22,\ for\ example,\ and\ #5.-\f[]-.fi-.SS Extension: \f[C]space_in_atx_header\f[]-.PP-Many Markdown implementations do not require a space between the opening-\f[C]#\f[]s of an ATX header and the header text, so that-\f[C]#5\ bolt\f[] and \f[C]#hashtag\f[] count as headers.-With this extension, pandoc does require the space.-.SS Header identifiers-.PP-See also the \f[C]auto_identifiers\f[] extension above.-.SS Extension: \f[C]header_attributes\f[]-.PP-Headers can be assigned attributes using this syntax at the end of the-line containing the header text:-.IP-.nf-\f[C]-{#identifier\ .class\ .class\ key=value\ key=value}-\f[]-.fi-.PP-Thus, for example, the following headers will all be assigned the-identifier \f[C]foo\f[]:-.IP-.nf-\f[C]-#\ My\ header\ {#foo}--##\ My\ header\ ##\ \ \ \ {#foo}--My\ other\ header\ \ \ {#foo}-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\f[]-.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, and AsciiDoc writers.-.PP-Headers with the class \f[C]unnumbered\f[] will not be numbered, even if-\f[C]\-\-number\-sections\f[] is specified.-A single hyphen (\f[C]\-\f[]) in an attribute context is equivalent to-\f[C]\&.unnumbered\f[], and preferable in non\-English documents.-So,-.IP-.nf-\f[C]-#\ My\ header\ {\-}-\f[]-.fi-.PP-is just the same as-.IP-.nf-\f[C]-#\ My\ header\ {.unnumbered}-\f[]-.fi-.SS Extension: \f[C]implicit_header_references\f[]-.PP-Pandoc behaves as if reference links have been defined for each header.-So, to link to a header-.IP-.nf-\f[C]-#\ Header\ identifiers\ in\ HTML-\f[]-.fi-.PP-you can simply write-.IP-.nf-\f[C]-[Header\ identifiers\ in\ HTML]-\f[]-.fi-.PP-or-.IP-.nf-\f[C]-[Header\ identifiers\ in\ HTML][]-\f[]-.fi-.PP-or-.IP-.nf-\f[C]-[the\ section\ on\ header\ identifiers][header\ identifiers\ in-HTML]-\f[]-.fi-.PP-instead of giving the identifier explicitly:-.IP-.nf-\f[C]-[Header\ identifiers\ in\ HTML](#header\-identifiers\-in\-html)-\f[]-.fi-.PP-If there are multiple headers 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-header references.-So, in the following example, the link will point to \f[C]bar\f[], not-to \f[C]#foo\f[]:-.IP-.nf-\f[C]-#\ Foo--[foo]:\ bar--See\ [foo]-\f[]-.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 headers), with each line preceded by a \f[C]>\f[]-character and an optional space.-(The \f[C]>\f[] need not start at the left margin, but it should not be-indented more than three spaces.)-.IP-.nf-\f[C]->\ This\ is\ a\ block\ quote.\ This->\ paragraph\ has\ two\ lines.->->\ 1.\ This\ is\ a\ list\ inside\ a\ block\ quote.->\ 2.\ Second\ item.-\f[]-.fi-.PP-A "lazy" form, which requires the \f[C]>\f[] character only on the first-line of each block, is also allowed:-.IP-.nf-\f[C]->\ This\ is\ a\ block\ quote.\ This-paragraph\ has\ two\ lines.-->\ 1.\ This\ is\ a\ list\ inside\ a\ block\ quote.-2.\ Second\ item.-\f[]-.fi-.PP-Among the block elements that can be contained in a block quote are-other block quotes.-That is, block quotes can be nested:-.IP-.nf-\f[C]->\ This\ is\ a\ block\ quote.->->\ >\ A\ block\ quote\ within\ a\ block\ quote.-\f[]-.fi-.PP-If the \f[C]>\f[] 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[]:-.IP-.nf-\f[C]->\ \ \ \ \ code-\f[]-.fi-.SS Extension: \f[C]blank_before_blockquote\f[]-.PP-Standard Markdown syntax does not require a blank line before a block-quote.-Pandoc does require this (except, of course, at the beginning of the-document).-The reason for the requirement is that it is all too easy for a-\f[C]>\f[] to end up at the beginning of a line by accident (perhaps-through line wrapping).-So, unless the \f[C]markdown_strict\f[] 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[]-.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[]-.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[]-.PP-In addition to standard indented code blocks, pandoc supports-\f[I]fenced\f[] code blocks.-These begin with a row of three or more tildes (\f[C]~\f[]) and end with-a row of tildes that must be at least as long as the starting row.-Everything between these lines is treated as code.-No indentation is necessary:-.IP-.nf-\f[C]-~~~~~~~-if\ (a\ >\ 3)\ {-\ \ moveShip(5\ *\ gravity,\ DOWN);-}-~~~~~~~-\f[]-.fi-.PP-Like regular code blocks, 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]-~~~~~~~~~~~~~~~~-~~~~~~~~~~-code\ including\ tildes-~~~~~~~~~~-~~~~~~~~~~~~~~~~-\f[]-.fi-.SS Extension: \f[C]backtick_code_blocks\f[]-.PP-Same as \f[C]fenced_code_blocks\f[], but uses backticks (\f[C]`\f[])-instead of tildes (\f[C]~\f[]).-.SS Extension: \f[C]fenced_code_attributes\f[]-.PP-Optionally, you may attach attributes to fenced or backtick code block-using this syntax:-.IP-.nf-\f[C]-~~~~\ {#mycode\ .haskell\ .numberLines\ startFrom="100"}-qsort\ []\ \ \ \ \ =\ []-qsort\ (x:xs)\ =\ qsort\ (filter\ (<\ x)\ xs)\ ++\ [x]\ ++-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ qsort\ (filter\ (>=\ x)\ xs)-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-\f[]-.fi-.PP-Here \f[C]mycode\f[] is an identifier, \f[C]haskell\f[] and-\f[C]numberLines\f[] are classes, and \f[C]startFrom\f[] is an attribute-with value \f[C]100\f[].-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[].) Otherwise, the code-block above will appear as follows:-.IP-.nf-\f[C]-<pre\ id="mycode"\ class="haskell\ numberLines"\ startFrom="100">-\ \ <code>-\ \ ...-\ \ </code>-</pre>-\f[]-.fi-.PP-The \f[C]numberLines\f[] (or \f[C]number\-lines\f[]) class will cause-the lines of the code block to be numbered, starting with \f[C]1\f[] or-the value of the \f[C]startFrom\f[] attribute.-The \f[C]lineAnchors\f[] (or \f[C]line\-anchors\f[]) 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]-```haskell-qsort\ []\ =\ []-```-\f[]-.fi-.PP-This is equivalent to:-.IP-.nf-\f[C]-```\ {.haskell}-qsort\ []\ =\ []-```-\f[]-.fi-.PP-If the \f[C]fenced_code_attributes\f[] 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[] flag.-To set the highlighting style, use \f[C]\-\-highlight\-style\f[].-For more information on highlighting, see Syntax highlighting, below.-.SS Line blocks-.SS Extension: \f[C]line_blocks\f[]-.PP-A line block is a sequence of lines beginning with a vertical bar-(\f[C]|\f[]) 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[]-.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[]-.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[], \f[C]+\f[], or-\f[C]\-\f[]).-Here is a simple example:-.IP-.nf-\f[C]-*\ one-*\ two-*\ three-\f[]-.fi-.PP-This will produce a "compact" list.-If you want a "loose" list, in which each item is formatted as a-paragraph, put spaces between the items:-.IP-.nf-\f[C]-*\ one--*\ two--*\ three-\f[]-.fi-.PP-The bullets need not be flush with the left margin; they may be indented-one, two, or three spaces.-The bullet must be followed by whitespace.-.PP-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[]-.fi-.PP-But Markdown also allows a "lazy" format:-.IP-.nf-\f[C]-*\ here\ is\ my\ first-list\ item.-*\ and\ my\ second.-\f[]-.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[]-.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[]-.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[]-.fi-.PP-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.-.IP-.nf-\f[C]-+\ A\ lazy,\ lazy,\ list-item.--+\ Another\ one;\ this\ looks-bad\ but\ is\ legal.--\ \ \ \ Second\ paragraph\ of\ second-list\ item.-\f[]-.fi-.SS Ordered lists-.PP-Ordered lists work just like bulleted lists, except that the items begin-with enumerators rather than bullets.-.PP-In standard Markdown, enumerators are decimal numbers followed by a-period and a space.-The numbers themselves are ignored, so there is no difference between-this list:-.IP-.nf-\f[C]-1.\ \ one-2.\ \ two-3.\ \ three-\f[]-.fi-.PP-and this one:-.IP-.nf-\f[C]-5.\ \ one-7.\ \ two-1.\ \ three-\f[]-.fi-.SS Extension: \f[C]fancy_lists\f[]-.PP-Unlike standard Markdown, pandoc allows ordered list items to be marked-with uppercase and lowercase letters and roman numerals, in addition to-Arabic numerals.-List markers may be enclosed in parentheses or followed by a single-right\-parentheses or period.-They must be separated from the text that follows by at least one space,-and, if the list marker is a capital letter with a period, by at least-two spaces.-.PP-The \f[C]fancy_lists\f[] extension also allows \[aq]\f[C]#\f[]\[aq] to-be used as an ordered list marker in place of a numeral:-.IP-.nf-\f[C]-#.\ one-#.\ two-\f[]-.fi-.SS Extension: \f[C]startnum\f[]-.PP-Pandoc also pays attention to the type of list marker used, and to the-starting number, and both of these are preserved where possible in the-output format.-Thus, the following yields a list with numbers followed by a single-parenthesis, starting with 9, and a sublist with lowercase roman-numerals:-.IP-.nf-\f[C]-\ 9)\ \ Ninth-10)\ \ Tenth-11)\ \ Eleventh-\ \ \ \ \ \ \ i.\ subone-\ \ \ \ \ \ ii.\ subtwo-\ \ \ \ \ iii.\ subthree-\f[]-.fi-.PP-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[]-.fi-.PP-If default list markers are desired, use \f[C]#.\f[]:-.IP-.nf-\f[C]-#.\ \ one-#.\ \ two-#.\ \ three-\f[]-.fi-.SS Definition lists-.SS Extension: \f[C]definition_lists\f[]-.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[]-.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 "lazily" 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[]-.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-\ \ ~\ Definition\ 1--Term\ 2-\ \ ~\ Definition\ 2a-\ \ ~\ Definition\ 2b-\f[]-.fi-.PP-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 \f[C]compact_definition_lists\f[]: see-Non\-pandoc extensions, below.)-.SS Numbered example lists-.SS Extension: \f[C]example_lists\f[]-.PP-The special list marker \f[C]\@\f[] can be used for sequentially-numbered examples.-The first list item with a \f[C]\@\f[] marker will be numbered-\[aq]1\[aq], the next \[aq]2\[aq], and so on, throughout the document.-The numbered examples need not occur in a single list; each new list-using \f[C]\@\f[] will take up where the last stopped.-So, for example:-.IP-.nf-\f[C]-(\@)\ \ My\ first\ example\ will\ be\ numbered\ (1).-(\@)\ \ My\ second\ example\ will\ be\ numbered\ (2).--Explanation\ of\ examples.--(\@)\ \ My\ third\ example\ will\ be\ numbered\ (3).-\f[]-.fi-.PP-Numbered examples can be labeled and referred to elsewhere in the-document:-.IP-.nf-\f[C]-(\@good)\ \ This\ is\ a\ good\ example.--As\ (\@good)\ illustrates,\ ...-\f[]-.fi-.PP-The label can be any string of alphanumeric characters, underscores, or-hyphens.-.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[]-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[] on some "edge-cases" involving lists.-Consider this source:-.IP-.nf-\f[C]-+\ \ \ First-+\ \ \ Second:-\ \ \ \ \-\ \ \ Fee-\ \ \ \ \-\ \ \ Fie-\ \ \ \ \-\ \ \ Foe--+\ \ \ Third-\f[]-.fi-.PP-Pandoc transforms this into a "compact list" (with no \f[C]<p>\f[] tags-around "First", "Second", or "Third"), while Markdown puts \f[C]<p>\f[]-tags around "Second" and "Third" (but not "First"), because of the blank-space around "Third".-Pandoc follows a simple rule: if the text is followed by a blank line,-it is treated as a paragraph.-Since "Second" is followed by a list, and not a blank line, it isn\[aq]t-treated as a paragraph.-The fact that the list is followed by a blank line is irrelevant.-(Note: Pandoc works this way even when the \f[C]markdown_strict\f[]-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[].)-.SS Ending a list-.PP-What if you want to put an indented code block after a list?-.IP-.nf-\f[C]-\-\ \ \ item\ one-\-\ \ \ item\ two--\ \ \ \ {\ my\ code\ block\ }-\f[]-.fi-.PP-Trouble! Here pandoc (like other Markdown implementations) will treat-\f[C]{\ my\ code\ block\ }\f[] as the second paragraph of item two, and-not as a code block.-.PP-To "cut off" the list after item two, you can insert some non\-indented-content, like an HTML comment, which won\[aq]t produce visible output in-any format:-.IP-.nf-\f[C]-\-\ \ \ item\ one-\-\ \ \ item\ two--<!\-\-\ end\ of\ list\ \-\->--\ \ \ \ {\ my\ code\ block\ }-\f[]-.fi-.PP-You can use the same trick if you want two consecutive lists instead of-one big list:-.IP-.nf-\f[C]-1.\ \ one-2.\ \ two-3.\ \ three--<!\-\-\ \-\->--1.\ \ uno-2.\ \ dos-3.\ \ tres-\f[]-.fi-.SS Horizontal rules-.PP-A line containing a row of three or more \f[C]*\f[], \f[C]\-\f[], or-\f[C]_\f[] characters (optionally separated by spaces) produces a-horizontal rule:-.IP-.nf-\f[C]-*\ \ *\ \ *\ \ *--\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\f[]-.fi-.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[]-.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[] (or-just \f[C]:\f[]), which will be stripped off.-It may appear either before or after the table.-.SS Extension: \f[C]simple_tables\f[]-.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[]-.fi-.PP-The headers and table rows must each fit on one line.-Column alignments are determined by the position of the header text-relative to the dashed line below it:-.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 headers may be omitted, provided a dashed line is used to end-the table.-For example:-.IP-.nf-\f[C]-\-\-\-\-\-\-\-\ \ \ \ \ \-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\ \ \ \-\-\-\-\-\-\--\ \ \ \ \ 12\ \ \ \ \ 12\ \ \ \ \ \ \ \ 12\ \ \ \ \ \ \ \ \ \ \ \ \ 12-\ \ \ \ 123\ \ \ \ \ 123\ \ \ \ \ \ \ 123\ \ \ \ \ \ \ \ \ \ \ 123-\ \ \ \ \ \ 1\ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ 1-\-\-\-\-\-\-\-\ \ \ \ \ \-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\ \ \ \-\-\-\-\-\-\--\f[]-.fi-.PP-When headers are omitted, column alignments are determined on the basis-of the first line of the table body.-So, in the tables above, the columns would be right, left, center, and-right aligned, respectively.-.SS Extension: \f[C]multiline_tables\f[]-.PP-Multiline tables allow headers and table rows to span multiple lines of-text (but cells that span multiple columns or rows of the table are not-supported).-Here is an example:-.IP-.nf-\f[C]-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ Centered\ \ \ Default\ \ \ \ \ \ \ \ \ \ \ Right\ Left-\ \ Header\ \ \ \ Aligned\ \ \ \ \ \ \ \ \ Aligned\ Aligned-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ First\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 12.0\ Example\ of\ a\ row\ that-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spans\ multiple\ lines.--\ \ Second\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 5.0\ Here\[aq]s\ another\ one.\ Note-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ blank\ line\ between-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\---Table:\ Here\[aq]s\ the\ caption.\ It,\ too,\ may\ span-multiple\ lines.-\f[]-.fi-.PP-These work like simple tables, but with the following differences:-.IP \[bu] 2-They must begin with a row of dashes, before the header text (unless the-headers are omitted).-.IP \[bu] 2-They must end with a row of dashes, then a blank line.-.IP \[bu] 2-The rows must be separated by blank lines.-.PP-In multiline tables, the table parser pays attention to the widths of-the columns, and the writers try to reproduce these relative widths in-the output.-So, if you find that one of the columns is too narrow in the output, try-widening it in the Markdown source.-.PP-Headers may be omitted in multiline tables as well as simple tables:-.IP-.nf-\f[C]-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\--\ \ \ First\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 12.0\ Example\ of\ a\ row\ that-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ spans\ multiple\ lines.--\ \ Second\ \ \ \ row\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 5.0\ Here\[aq]s\ another\ one.\ Note-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ the\ blank\ line\ between-\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\---:\ Here\[aq]s\ a\ multiline\ table\ without\ headers.-\f[]-.fi-.PP-It is possible for a multiline table to have just one row, but the row-should be followed by a blank line (and then the row of dashes that ends-the table), or the table may be interpreted as a simple table.-.SS Extension: \f[C]grid_tables\f[]-.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[]-.fi-.PP-The row of \f[C]=\f[]s separates the header from the table body, and can-be omitted for a headerless table.-The cells of grid tables may contain arbitrary block elements (multiple-paragraphs, code blocks, lists, etc.).-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[]-.fi-.PP-For headerless tables, the colons go on the top line instead:-.IP-.nf-\f[C]-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-:+:\-\-\-\-\-\-\-\-\-\-\-\-\-\-+:\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-:+-|\ Right\ \ \ \ \ \ \ \ \ |\ Left\ \ \ \ \ \ \ \ \ \ |\ Centered\ \ \ \ \ \ \ \ \ \ \ |-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+-\f[]-.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[]-.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[]-.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[]-.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[]), 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[] 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[]-.fi-.PP-The difference is that \f[C]+\f[] is used instead of \f[C]|\f[].-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[]-.PP-If the file begins with a title block-.IP-.nf-\f[C]-%\ title-%\ author(s)\ (separated\ by\ semicolons)-%\ date-\f[]-.fi-.PP-it will be parsed as bibliographic information, not regular text.-(It will be used, for example, in the title of standalone LaTeX or HTML-output.) The block may contain just a title, a title and an author, or-all three elements.-If you want to include an author but no title, or a title and a date but-no author, you need a blank line:-.IP-.nf-\f[C]-%-%\ Author--%\ My\ title-%-%\ June\ 15,\ 2006-\f[]-.fi-.PP-The title may occupy multiple lines, but continuation lines must begin-with leading space, thus:-.IP-.nf-\f[C]-%\ My\ title-\ \ on\ multiple\ lines-\f[]-.fi-.PP-If a document has multiple authors, the authors may be put on separate-lines with leading space, or separated by semicolons, or both.-So, all of the following are equivalent:-.IP-.nf-\f[C]-%\ Author\ One-\ \ Author\ Two--%\ Author\ One;\ Author\ Two--%\ Author\ One;-\ \ Author\ Two-\f[]-.fi-.PP-The date must fit on one line.-.PP-All three metadata fields may contain standard inline formatting-(italics, links, footnotes, etc.).-.PP-Title blocks will always be parsed, but they will affect the output only-when the \f[C]\-\-standalone\f[] (\f[C]\-s\f[]) option is chosen.-In HTML output, titles will appear twice: once in the document head \-\--this is the title that will appear at the top of the window in a browser-\-\- and once at the beginning of the document body.-The title in the document head can have an optional prefix attached-(\f[C]\-\-title\-prefix\f[] or \f[C]\-T\f[] option).-The title in the body appears as an H1 element with class "title", so it-can be suppressed or reformatted with CSS.-If a title prefix is specified with \f[C]\-T\f[] and no title block-appears in the document, the title prefix will be used by itself as the-HTML title.-.PP-The man page writer extracts a title, man page section number, and other-header and footer information from the title line.-The title is assumed to be the first word on the title line, which may-optionally end with a (single\-digit) section number in parentheses.-(There should be no space between the title and the parentheses.)-Anything after this is assumed to be additional footer and header text.-A single pipe character (\f[C]|\f[]) should be used to separate the-footer text from the header text.-Thus,-.IP-.nf-\f[C]-%\ PANDOC(1)-\f[]-.fi-.PP-will yield a man page with the title \f[C]PANDOC\f[] and section 1.-.IP-.nf-\f[C]-%\ PANDOC(1)\ Pandoc\ User\ Manuals-\f[]-.fi-.PP-will also have "Pandoc User Manuals" in the footer.-.IP-.nf-\f[C]-%\ PANDOC(1)\ Pandoc\ User\ Manuals\ |\ Version\ 4.0-\f[]-.fi-.PP-will also have "Version 4.0" in the header.-.SS Extension: \f[C]yaml_metadata_block\f[]-.PP-A YAML metadata block is a valid YAML object, delimited by a line of-three hyphens (\f[C]\-\-\-\f[]) at the top and a line of three hyphens-(\f[C]\-\-\-\f[]) or three dots (\f[C]\&...\f[]) 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[]-.fi-.PP-Just be sure that the YAML file begins with \f[C]\-\-\-\f[] and ends-with \f[C]\-\-\-\f[] or \f[C]\&...\f[].) Alternatively, you can use the-\f[C]\-\-metadata\-file\f[] 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[], \f[C]True\f[], and \f[C]15\f[] 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[]: 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[] to create a Markdown-document, a YAML metadata block will be produced only if the-\f[C]\-s/\-\-standalone\f[] 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[]) 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[]-.fi-.PP-Template variables will be set automatically from the metadata.-Thus, for example, in writing HTML, the variable \f[C]abstract\f[] will-be set to the HTML equivalent of the Markdown in the \f[C]abstract\f[]-field:-.IP-.nf-\f[C]-<p>This\ is\ the\ abstract.</p>-<p>It\ consists\ of\ two\ paragraphs.</p>-\f[]-.fi-.PP-Variables can contain arbitrary YAML structures, but the template must-match this structure.-The \f[C]author\f[] 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[]-.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[]-.fi-.PP-Raw content to include in the document\[aq]s header may be specified-using \f[C]header\-includes\f[]; however, it is important to mark up-this content as raw code for a particular output format, using the-\f[C]raw_attribute\f[] extension), or it will be interpreted as-markdown.-For example:-.IP-.nf-\f[C]-header\-includes:-\-\ |-\ \ ```{=latex}-\ \ \\let\\oldsection\\section-\ \ \\renewcommand{\\section}[1]{\\clearpage\\oldsection{#1}}-\ \ ```-\f[]-.fi-.SS Backslash escapes-.SS Extension: \f[C]all_symbols_escapable\f[]-.PP-Except inside a code block or inline code, any punctuation or space-character preceded by a backslash will be treated literally, even if it-would normally indicate formatting.-Thus, for example, if one writes-.IP-.nf-\f[C]-*\\*hello\\**-\f[]-.fi-.PP-one will get-.IP-.nf-\f[C]-<em>*hello*</em>-\f[]-.fi-.PP-instead of-.IP-.nf-\f[C]-<strong>hello</strong>-\f[]-.fi-.PP-This rule is easier to remember than standard Markdown\[aq]s rule, which-allows only the following characters to be backslash\-escaped:-.IP-.nf-\f[C]-\\`*_{}[]()>#+\-.!-\f[]-.fi-.PP-(However, if the \f[C]markdown_strict\f[] 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]~\f[] and in HTML and XML as-\f[C]\\ \f[] or \f[C]\\ \f[].-.PP-A backslash\-escaped newline (i.e.-a backslash occurring at the end of a line) is parsed as a hard line-break.-It will appear in TeX output as \f[C]\\\\\f[] and in HTML as-\f[C]<br\ />\f[].-This is a nice alternative to Markdown\[aq]s "invisible" way of-indicating hard line breaks using two trailing spaces on a line.-.PP-Backslash escapes do not work in verbatim contexts.-.SS Inline formatting-.SS Emphasis-.PP-To \f[I]emphasize\f[] some text, surround it with \f[C]*\f[]s or-\f[C]_\f[], like this:-.IP-.nf-\f[C]-This\ text\ is\ _emphasized\ with\ underscores_,\ and\ this-is\ *emphasized\ with\ asterisks*.-\f[]-.fi-.PP-Double \f[C]*\f[] or \f[C]_\f[] produces \f[B]strong emphasis\f[]:-.IP-.nf-\f[C]-This\ is\ **strong\ emphasis**\ and\ __with\ underscores__.-\f[]-.fi-.PP-A \f[C]*\f[] or \f[C]_\f[] character surrounded by spaces, or-backslash\-escaped, will not trigger emphasis:-.IP-.nf-\f[C]-This\ is\ *\ not\ emphasized\ *,\ and\ \\*neither\ is\ this\\*.-\f[]-.fi-.SS Extension: \f[C]intraword_underscores\f[]-.PP-Because \f[C]_\f[] is sometimes used inside words and identifiers,-pandoc does not interpret a \f[C]_\f[] surrounded by alphanumeric-characters as an emphasis marker.-If you want to emphasize just part of a word, use \f[C]*\f[]:-.IP-.nf-\f[C]-feas*ible*,\ not\ feas*able*.-\f[]-.fi-.SS Strikeout-.SS Extension: \f[C]strikeout\f[]-.PP-To strikeout a section of text with a horizontal line, begin and end it-with \f[C]~~\f[].-Thus, for example,-.IP-.nf-\f[C]-This\ ~~is\ deleted\ text.~~-\f[]-.fi-.SS Superscripts and subscripts-.SS Extension: \f[C]superscript\f[], \f[C]subscript\f[]-.PP-Superscripts may be written by surrounding the superscripted text by-\f[C]^\f[] characters; subscripts may be written by surrounding the-subscripted text by \f[C]~\f[] characters.-Thus, for example,-.IP-.nf-\f[C]-H~2~O\ is\ a\ liquid.\ \ 2^10^\ is\ 1024.-\f[]-.fi-.PP-If the superscripted or subscripted text contains spaces, these spaces-must be escaped with backslashes.-(This is to prevent accidental superscripting and subscripting through-the ordinary use of \f[C]~\f[] and \f[C]^\f[].) Thus, if you want the-letter P with \[aq]a cat\[aq] in subscripts, use \f[C]P~a\\\ cat~\f[],-not \f[C]P~a\ cat~\f[].-.SS Verbatim-.PP-To make a short span of text verbatim, put it inside backticks:-.IP-.nf-\f[C]-What\ is\ the\ difference\ between\ `>>=`\ and\ `>>`?-\f[]-.fi-.PP-If the verbatim text includes a backtick, use double backticks:-.IP-.nf-\f[C]-Here\ is\ a\ literal\ backtick\ ``\ `\ ``.-\f[]-.fi-.PP-(The spaces after the opening backticks and before the closing backticks-will be ignored.)-.PP-The general rule is that a verbatim span starts with a string of-consecutive backticks (optionally followed by a space) and ends with a-string of the same number of backticks (optionally preceded by a space).-.PP-Note that backslash\-escapes (and other Markdown constructs) do not work-in verbatim contexts:-.IP-.nf-\f[C]-This\ is\ a\ backslash\ followed\ by\ an\ asterisk:\ `\\*`.-\f[]-.fi-.SS Extension: \f[C]inline_code_attributes\f[]-.PP-Attributes can be attached to verbatim text, just as with fenced code-blocks:-.IP-.nf-\f[C]-`<$>`{.haskell}-\f[]-.fi-.SS Small caps-.PP-To write small caps, use the \f[C]smallcaps\f[] class:-.IP-.nf-\f[C]-[Small\ caps]{.smallcaps}-\f[]-.fi-.PP-Or, without the \f[C]bracketed_spans\f[] extension:-.IP-.nf-\f[C]-<span\ class="smallcaps">Small\ caps</span>-\f[]-.fi-.PP-For compatibility with other Markdown flavors, CSS is also supported:-.IP-.nf-\f[C]-<span\ style="font\-variant:small\-caps;">Small\ caps</span>-\f[]-.fi-.PP-This will work in all output formats that support small caps.-.SS Math-.SS Extension: \f[C]tex_math_dollars\f[]-.PP-Anything between two \f[C]$\f[] characters will be treated as TeX math.-The opening \f[C]$\f[] must have a non\-space character immediately to-its right, while the closing \f[C]$\f[] 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[] won\[aq]t parse as math.-If for some reason you need to enclose text in literal \f[C]$\f[]-characters, backslash\-escape them and they won\[aq]t be treated as math-delimiters.-.PP-TeX math will be printed in all output formats.-How it is rendered depends on the output format:-.TP-.B LaTeX-It will appear verbatim surrounded by \f[C]\\(...\\)\f[] (for inline-math) or \f[C]\\[...\\]\f[] (for display math).-.RS-.RE-.TP-.B Markdown, Emacs Org mode, ConTeXt, ZimWiki-It will appear verbatim surrounded by \f[C]$...$\f[] (for inline math)-or \f[C]$$...$$\f[] (for display math).-.RS-.RE-.TP-.B reStructuredText-It will be rendered using an interpreted text role \f[C]:math:\f[].-.RS-.RE-.TP-.B AsciiDoc-It will be rendered as \f[C]latexmath:[...]\f[].-.RS-.RE-.TP-.B Texinfo-It will be rendered inside a \f[C]\@math\f[] command.-.RS-.RE-.TP-.B groff man-It will be rendered verbatim without \f[C]$\f[]\[aq]s.-.RS-.RE-.TP-.B MediaWiki, DokuWiki-It will be rendered inside \f[C]<math>\f[] tags.-.RS-.RE-.TP-.B Textile-It will be rendered inside \f[C]<span\ class="math">\f[] tags.-.RS-.RE-.TP-.B RTF, OpenDocument-It will be rendered, if possible, using Unicode characters, and will-otherwise appear verbatim.-.RS-.RE-.TP-.B ODT-It will be rendered, if possible, using MathML.-.RS-.RE-.TP-.B DocBook-If the \f[C]\-\-mathml\f[] flag is used, it will be rendered using-MathML in an \f[C]inlineequation\f[] or \f[C]informalequation\f[] tag.-Otherwise it will be rendered, if possible, using Unicode characters.-.RS-.RE-.TP-.B Docx-It will be rendered using OMML math markup.-.RS-.RE-.TP-.B FictionBook2-If the \f[C]\-\-webtex\f[] 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.-.RS-.RE-.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.-.RS-.RE-.SS Raw HTML-.SS Extension: \f[C]raw_html\f[]-.PP-Markdown allows you to insert raw HTML (or DocBook) anywhere in a-document (except verbatim contexts, where \f[C]<\f[], \f[C]>\f[], and-\f[C]&\f[] 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, Emacs Org mode, and Textile output, and-suppressed in other formats.-.SS Extension: \f[C]markdown_in_html_blocks\f[]-.PP-Standard Markdown allows you to include HTML "blocks": blocks of HTML-between balanced tags that are separated from the surrounding text with-blank lines, and start and end at the left margin.-Within these blocks, everything is interpreted as HTML, not Markdown; so-(for example), \f[C]*\f[] does not signify emphasis.-.PP-Pandoc behaves this way when the \f[C]markdown_strict\f[] 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[]-.fi-.PP-into-.IP-.nf-\f[C]-<table>-<tr>-<td><em>one</em></td>-<td><a\ href="http://google.com">a\ link</a></td>-</tr>-</table>-\f[]-.fi-.PP-whereas \f[C]Markdown.pl\f[] will preserve it as is.-.PP-There is one exception to this rule: text between \f[C]<script>\f[] and-\f[C]<style>\f[] tags is not interpreted as Markdown.-.PP-This departure from standard Markdown should make it easier to mix-Markdown with HTML block elements.-For example, one can surround a block of Markdown text with-\f[C]<div>\f[] tags without preventing it from being interpreted as-Markdown.-.SS Extension: \f[C]native_divs\f[]-.PP-Use native pandoc \f[C]Div\f[] blocks for content inside \f[C]<div>\f[]-tags.-For the most part this should give the same output as-\f[C]markdown_in_html_blocks\f[], but it makes it easier to write pandoc-filters to manipulate groups of blocks.-.SS Extension: \f[C]native_spans\f[]-.PP-Use native pandoc \f[C]Span\f[] blocks for content inside-\f[C]<span>\f[] tags.-For the most part this should give the same output as \f[C]raw_html\f[],-but it makes it easier to write pandoc filters to manipulate groups of-inlines.-.SS Extension: \f[C]raw_tex\f[]-.PP-In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be-included in a document.-Inline TeX commands will be preserved and passed unchanged to the LaTeX-and ConTeXt writers.-Thus, for example, you can use LaTeX to include BibTeX citations:-.IP-.nf-\f[C]-This\ result\ was\ proved\ in\ \\cite{jones.1967}.-\f[]-.fi-.PP-Note that in LaTeX environments, like-.IP-.nf-\f[C]-\\begin{tabular}{|l|l|}\\hline-Age\ &\ Frequency\ \\\\\ \\hline-18\-\-25\ \ &\ 15\ \\\\-26\-\-35\ \ &\ 33\ \\\\-36\-\-45\ \ &\ 22\ \\\\\ \\hline-\\end{tabular}-\f[]-.fi-.PP-the material between the begin and end tags will be interpreted as raw-LaTeX, not as Markdown.-.PP-Inline LaTeX is ignored in output formats other than Markdown, LaTeX,-Emacs Org mode, and ConTeXt.-.SS Generic raw attribute-.SS Extension: \f[C]raw_attribute\f[]-.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 groff \f[C]ms\f[] block:-.IP-.nf-\f[C]-```{=ms}-\&.MYMACRO-blah\ blah-```-\f[]-.fi-.PP-And the following produces a raw \f[C]html\f[] inline element:-.IP-.nf-\f[C]-This\ is\ `<a>html</a>`{=html}-\f[]-.fi-.PP-This can be useful to insert raw xml into \f[C]docx\f[] documents, e.g.-a pagebreak:-.IP-.nf-\f[C]-```{=openxml}-<w:p>-\ \ <w:r>-\ \ \ \ <w:br\ w:type="page"/>-\ \ </w:r>-</w:p>-```-\f[]-.fi-.PP-The format name should match the target format name (see-\f[C]\-t/\-\-to\f[], above, for a list, or use-\f[C]pandoc\ \-\-list\-output\-formats\f[]).-Use \f[C]openxml\f[] for \f[C]docx\f[] output, \f[C]opendocument\f[] for-\f[C]odt\f[] output, \f[C]html5\f[] for \f[C]epub3\f[] output,-\f[C]html4\f[] for \f[C]epub2\f[] output, and \f[C]latex\f[],-\f[C]beamer\f[], \f[C]ms\f[], or \f[C]html5\f[] for \f[C]pdf\f[] output-(depending on what you use for \f[C]\-\-pdf\-engine\f[]).-.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[] must be enabled.-.PP-The raw attribute cannot be combined with regular attributes.-.SS LaTeX macros-.SS Extension: \f[C]latex_macros\f[]-.PP-For output formats other than LaTeX, 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]-\\newcommand{\\tuple}[1]{\\langle\ #1\ \\rangle}--$\\tuple{a,\ b,\ c}$-\f[]-.fi-.PP-Note that LaTeX macros will not be applied if they occur inside inside a-raw span or block marked with the \f[C]raw_attribute\f[] extension.-.PP-When \f[C]latex_macros\f[] 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[] 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\@green.eggs.ham>-\f[]-.fi-.SS Inline links-.PP-An inline link consists of the link text in square brackets, followed by-the URL in parentheses.-(Optionally, the URL can be followed by a link title, in quotes.)-.IP-.nf-\f[C]-This\ is\ an\ [inline\ link](/url),\ and\ here\[aq]s\ [one\ with-a\ title](http://fsf.org\ "click\ here\ for\ a\ good\ time!").-\f[]-.fi-.PP-There can be no space between the bracketed part and the parenthesized-part.-The link text can contain formatting (such as emphasis), but the title-cannot.-.PP-Email addresses in inline links are not autodetected, so they have to be-prefixed with \f[C]mailto\f[]:-.IP-.nf-\f[C]-[Write\ me!](mailto:sam\@green.eggs.ham)-\f[]-.fi-.SS Reference links-.PP-An \f[I]explicit\f[] reference link has two parts, the link itself and-the link definition, which may occur elsewhere in the document (either-before or after the link).-.PP-The link consists of link text in square brackets, followed by a label-in square brackets.-(There cannot be space between the two unless the-\f[C]spaced_reference_links\f[] 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[] extension is enabled): citations take precedence over-link labels.-.PP-Here are some examples:-.IP-.nf-\f[C]-[my\ label\ 1]:\ /foo/bar.html\ \ "My\ title,\ optional"-[my\ label\ 2]:\ /foo-[my\ label\ 3]:\ http://fsf.org\ (The\ free\ software\ foundation)-[my\ label\ 4]:\ /bar#special\ \ \[aq]A\ title\ in\ single\ quotes\[aq]-\f[]-.fi-.PP-The URL may optionally be surrounded by angle brackets:-.IP-.nf-\f[C]-[my\ label\ 5]:\ <http://foo.bar.baz>-\f[]-.fi-.PP-The title may go on the next line:-.IP-.nf-\f[C]-[my\ label\ 3]:\ http://fsf.org-\ \ "The\ free\ software\ foundation"-\f[]-.fi-.PP-Note that link labels are not case sensitive.-So, this will work:-.IP-.nf-\f[C]-Here\ is\ [my\ link][FOO]--[Foo]:\ /bar/baz-\f[]-.fi-.PP-In an \f[I]implicit\f[] reference link, the second pair of brackets is-empty:-.IP-.nf-\f[C]-See\ [my\ website][].--[my\ website]:\ http://foo.bar.baz-\f[]-.fi-.PP-Note: In \f[C]Markdown.pl\f[] 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[]-.fi-.SS Extension: \f[C]shortcut_reference_links\f[]-.PP-In a \f[I]shortcut\f[] 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[]-.fi-.SS Internal links-.PP-To link to another section of the same document, use the automatically-generated identifier (see Header identifiers).-For example:-.IP-.nf-\f[C]-See\ the\ [Introduction](#introduction).-\f[]-.fi-.PP-or-.IP-.nf-\f[C]-See\ the\ [Introduction].--[Introduction]:\ #introduction-\f[]-.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[] will be treated as an image.-The link text will be used as the image\[aq]s alt text:-.IP-.nf-\f[C]---![movie\ reel]--[movie\ reel]:\ movie.gif-\f[]-.fi-.SS Extension: \f[C]implicit_figures\f[]-.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]--\f[]-.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)\\-\f[]-.fi-.PP-Note that in reveal.js slide shows, an image in a paragraph by itself-that has the \f[C]stretch\f[] class will fill the screen, and the-caption and figure tags will be omitted.-.SS Extension: \f[C]link_attributes\f[]-.PP-Attributes can be set on links and images:-.IP-.nf-\f[C]-An\ inline\ {#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"}-\f[]-.fi-.PP-(This syntax is compatible with PHP Markdown Extra when only-\f[C]#id\f[] and \f[C]\&.class\f[] are used.)-.PP-For HTML and EPUB, all attributes except \f[C]width\f[] and-\f[C]height\f[] (but including \f[C]srcset\f[] and \f[C]sizes\f[]) are-passed through as is.-The other writers ignore attributes that are not supported by their-output format.-.PP-The \f[C]width\f[] and \f[C]height\f[] 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[],-\f[C]cm\f[], \f[C]mm\f[], \f[C]in\f[], \f[C]inch\f[] and \f[C]%\f[].-There must not be any spaces between the number and the unit.-For example:-.IP-.nf-\f[C]-{\ width=50%\ }-\f[]-.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[] option to specify the number of pixels per-inch.-The default is 96dpi.-.IP \[bu] 2-The \f[C]%\f[] unit is generally relative to some available space.-For example the above example will render to-\f[C]<img\ href="file.jpg"\ style="width:\ 50%;"\ />\f[] (HTML),-\f[C]\\includegraphics[width=0.5\\textwidth]{file.jpg}\f[] (LaTeX), or-\f[C]\\externalfigure[file.jpg][width=0.5\\textwidth]\f[] (ConTeXt).-.IP \[bu] 2-Some output formats have a notion of a class (ConTeXt) or a unique-identifier (LaTeX \f[C]\\caption\f[]), or both (HTML).-.IP \[bu] 2-When no \f[C]width\f[] or \f[C]height\f[] 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[] and \f[C]native_spans\f[] extensions (see-above), HTML syntax can be used as part of markdown to create native-\f[C]Div\f[] and \f[C]Span\f[] elements in the pandoc AST (as opposed to-raw HTML).-However, there is also nicer syntax available:-.SS Extension: \f[C]fenced_divs\f[]-.PP-Allow special fenced syntax for native \f[C]Div\f[] 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[]).-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[]-.fi-.PP-Fenced divs can be nested.-Opening fences are distinguished because they \f[I]must\f[] have-attributes:-.IP-.nf-\f[C]-:::\ Warning\ ::::::-This\ is\ a\ warning.--:::\ Danger-This\ is\ a\ warning\ within\ a\ warning.-:::-::::::::::::::::::-\f[]-.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[]-.PP-A bracketed sequence of inlines, as one would use to begin a link, will-be treated as a \f[C]Span\f[] with attributes if it is followed-immediately by attributes:-.IP-.nf-\f[C]-[This\ is\ *some\ text*]{.class\ key="val"}-\f[]-.fi-.SS Footnotes-.SS Extension: \f[C]footnotes\f[]-.PP-Pandoc\[aq]s Markdown allows footnotes, using the following syntax:-.IP-.nf-\f[C]-Here\ is\ a\ footnote\ reference,[^1]\ and\ another.[^longnote]--[^1]:\ Here\ is\ the\ footnote.--[^longnote]:\ Here\[aq]s\ one\ with\ multiple\ blocks.--\ \ \ \ Subsequent\ paragraphs\ are\ indented\ to\ show\ that\ they-belong\ to\ the\ previous\ footnote.--\ \ \ \ \ \ \ \ {\ some.code\ }--\ \ \ \ The\ whole\ paragraph\ can\ be\ indented,\ or\ just\ the\ first-\ \ \ \ line.\ \ In\ this\ way,\ multi\-paragraph\ footnotes\ work\ like-\ \ \ \ multi\-paragraph\ list\ items.--This\ paragraph\ won\[aq]t\ be\ part\ of\ the\ note,\ because\ it-isn\[aq]t\ indented.-\f[]-.fi-.PP-The identifiers in footnote references may not contain spaces, tabs, or-newlines.-These identifiers are used only to correlate the footnote reference with-the note itself; in the output, footnotes will be numbered sequentially.-.PP-The footnotes themselves need not be placed at the end of the document.-They may appear anywhere except inside other block elements (lists,-block quotes, tables, etc.).-Each footnote should be separated from surrounding content (including-other footnotes) by blank lines.-.SS Extension: \f[C]inline_notes\f[]-.PP-Inline footnotes are also allowed (though, unlike regular notes, they-cannot contain multiple paragraphs).-The syntax is as follows:-.IP-.nf-\f[C]-Here\ is\ an\ inline\ note.^[Inlines\ notes\ are\ easier\ to\ write,\ since-you\ don\[aq]t\ have\ to\ pick\ an\ identifier\ and\ move\ down\ to\ type\ the-note.]-\f[]-.fi-.PP-Inline and regular footnotes may be mixed freely.-.SS Citations-.SS Extension: \f[C]citations\f[]-.PP-Using an external filter, \f[C]pandoc\-citeproc\f[], 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[]-.fi-.PP-In order to use this feature, you will need to specify a bibliography-file using the \f[C]bibliography\f[] metadata field in a YAML metadata-section, or \f[C]\-\-bibliography\f[] command line argument.-You can supply multiple \f[C]\-\-bibliography\f[] arguments or set-\f[C]bibliography\f[] 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[] can be used with both BibTeX and BibLaTeX-files; use \f[C]\&.bibtex\f[] to force BibTeX.-.PP-Note that \f[C]pandoc\-citeproc\ \-\-bib2json\f[] and-\f[C]pandoc\-citeproc\ \-\-bib2yaml\f[] can produce \f[C]\&.json\f[] and-\f[C]\&.yaml\f[] 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[]-italics-.RS-.RE-.TP-.B \f[C]<b>...</b>\f[]-bold-.RS-.RE-.TP-.B \f[C]<span\ style="font\-variant:small\-caps;">...</span>\f[] or \f[C]<sc>...</sc>\f[]-small capitals-.RS-.RE-.TP-.B \f[C]<sub>...</sub>\f[]-subscript-.RS-.RE-.TP-.B \f[C]<sup>...</sup>\f[]-superscript-.RS-.RE-.TP-.B \f[C]<span\ class="nocase">...</span>\f[]-prevent a phrase from being capitalized as title case-.RS-.RE-.PP-\f[C]pandoc\-citeproc\ \-j\f[] and \f[C]\-y\f[] 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[] or the YAML metadata field-\f[C]bibliography\f[], you can include the citation data directly in the-\f[C]references\f[] 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[]-.fi-.PP-(\f[C]pandoc\-citeproc\ \-\-bib2yaml\f[] 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[] option or the-\f[C]csl\f[] metadata field.-By default, \f[C]pandoc\-citeproc\f[] 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[] to your YAML metadata.-.PP-Citations go inside square brackets and are separated by semicolons.-Each citation must have a key, composed of \[aq]\@\[aq] + the citation-identifier from the database, and may optionally have a prefix, a-locator, and a suffix.-The citation key must begin with a letter, digit, or \f[C]_\f[], and may-contain alphanumerics, \f[C]_\f[], and internal punctuation characters-(\f[C]:.#$%&\-+?<>~/\f[]).-Here are some examples:-.IP-.nf-\f[C]-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].-\f[]-.fi-.PP-\f[C]pandoc\-citeproc\f[] detects locator terms in the CSL locale files.-Either abbreviated or unabbreviated forms are accepted.-In the \f[C]en\-US\f[] locale, locator terms can be written in either-singular or plural forms, as \f[C]book\f[], \f[C]bk.\f[]/\f[C]bks.\f[];-\f[C]chapter\f[], \f[C]chap.\f[]/\f[C]chaps.\f[]; \f[C]column\f[],-\f[C]col.\f[]/\f[C]cols.\f[]; \f[C]figure\f[],-\f[C]fig.\f[]/\f[C]figs.\f[]; \f[C]folio\f[],-\f[C]fol.\f[]/\f[C]fols.\f[]; \f[C]number\f[],-\f[C]no.\f[]/\f[C]nos.\f[]; \f[C]line\f[], \f[C]l.\f[]/\f[C]ll.\f[];-\f[C]note\f[], \f[C]n.\f[]/\f[C]nn.\f[]; \f[C]opus\f[],-\f[C]op.\f[]/\f[C]opp.\f[]; \f[C]page\f[], \f[C]p.\f[]/\f[C]pp.\f[];-\f[C]paragraph\f[], \f[C]para.\f[]/\f[C]paras.\f[]; \f[C]part\f[],-\f[C]pt.\f[]/\f[C]pts.\f[]; \f[C]section\f[],-\f[C]sec.\f[]/\f[C]secs.\f[]; \f[C]sub\ verbo\f[],-\f[C]s.v.\f[]/\f[C]s.vv.\f[]; \f[C]verse\f[], \f[C]v.\f[]/\f[C]vv.\f[];-\f[C]volume\f[], \f[C]vol.\f[]/\f[C]vols.\f[]; \f[C]¶\f[]/\f[C]¶¶\f[];-\f[C]§\f[]/\f[C]§§\f[].-If no locator term is used, "page" is assumed.-.PP-A minus sign (\f[C]\-\f[]) before the \f[C]\@\f[] will suppress mention-of the author in the citation.-This can be useful when the author is already mentioned in the text:-.IP-.nf-\f[C]-Smith\ says\ blah\ [\-\@smith04].-\f[]-.fi-.PP-You can also write an in\-text citation, as follows:-.IP-.nf-\f[C]-\@smith04\ says\ blah.--\@smith04\ [p.\ 33]\ says\ blah.-\f[]-.fi-.PP-If the style calls for a list of works cited, it will be placed at the-end of the document.-Normally, you will want to end your document with an appropriate header:-.IP-.nf-\f[C]-last\ paragraph...--#\ References-\f[]-.fi-.PP-The bibliography will be inserted after this header.-Note that the \f[C]unnumbered\f[] class will be added to this header, 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[] metadata-field and put the citations there:-.IP-.nf-\f[C]-\-\-\--nocite:\ |-\ \ \@item1,\ \@item2-\&...--\@item3-\f[]-.fi-.PP-In this example, the document will contain a citation for \f[C]item3\f[]-only, but the bibliography will contain entries for \f[C]item1\f[],-\f[C]item2\f[], and \f[C]item3\f[].-.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:\ |-\ \ \@*-\&...-\f[]-.fi-.PP-For LaTeX output, you can also use \f[C]natbib\f[] or \f[C]biblatex\f[]-to render the bibliography.-In order to do so, specify bibliography files as outlined above, and add-\f[C]\-\-natbib\f[] or \f[C]\-\-biblatex\f[] argument to \f[C]pandoc\f[]-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[] to the format-name, where \f[C]EXTENSION\f[] is the name of the extension.-Thus, for example, \f[C]markdown+hard_line_breaks\f[] is Markdown with-hard line breaks.-.SS Extension: \f[C]old_dashes\f[]-.PP-Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:-\f[C]\-\f[] before a numeral is an en\-dash, and \f[C]\-\-\f[] is an-em\-dash.-This option only has an effect if \f[C]smart\f[] is enabled.-It is selected automatically for \f[C]textile\f[] input.-.SS Extension: \f[C]angle_brackets_escapable\f[]-.PP-Allow \f[C]<\f[] and \f[C]>\f[] 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[].-.SS Extension: \f[C]lists_without_preceding_blankline\f[]-.PP-Allow a list to occur right after a paragraph, with no intervening blank-space.-.SS Extension: \f[C]four_space_rule\f[]-.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[]-.PP-Allow whitespace between the two components of a reference link, for-example,-.IP-.nf-\f[C]-[foo]\ [bar].-\f[]-.fi-.SS Extension: \f[C]hard_line_breaks\f[]-.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[]-.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[]-.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[] for texts that-include a mix of East Asian wide characters and other characters.-.SS Extension: \f[C]emoji\f[]-.PP-Parses textual emojis like \f[C]:smile:\f[] as Unicode emoticons.-.SS Extension: \f[C]tex_math_single_backslash\f[]-.PP-Causes anything between \f[C]\\(\f[] and \f[C]\\)\f[] to be interpreted-as inline TeX math, and anything between \f[C]\\[\f[] and \f[C]\\]\f[]-to be interpreted as display TeX math.-Note: a drawback of this extension is that it precludes escaping-\f[C](\f[] and \f[C][\f[].-.SS Extension: \f[C]tex_math_double_backslash\f[]-.PP-Causes anything between \f[C]\\\\(\f[] and \f[C]\\\\)\f[] to be-interpreted as inline TeX math, and anything between \f[C]\\\\[\f[] and-\f[C]\\\\]\f[] to be interpreted as display TeX math.-.SS Extension: \f[C]markdown_attribute\f[]-.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[].-.SS Extension: \f[C]mmd_title_block\f[]-.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[]-.fi-.PP-See the MultiMarkdown documentation for details.-If \f[C]pandoc_title_block\f[] or \f[C]yaml_metadata_block\f[] is-enabled, it will take precedence over \f[C]mmd_title_block\f[].-.SS Extension: \f[C]abbreviations\f[]-.PP-Parses PHP Markdown Extra abbreviation keys, like-.IP-.nf-\f[C]-*[HTML]:\ Hypertext\ Markup\ Language-\f[]-.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[]-.PP-Makes all absolute URIs into links, even when not surrounded by pointy-braces \f[C]<...>\f[].-.SS Extension: \f[C]mmd_link_attributes\f[]-.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[]-extension.-.IP-.nf-\f[C]-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"-\f[]-.fi-.SS Extension: \f[C]mmd_header_identifiers\f[]-.PP-Parses multimarkdown style header identifiers (in square brackets, after-the header but before any trailing \f[C]#\f[]s in an ATX header).-.SS Extension: \f[C]compact_definition_lists\f[]-.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 "tight" or "compact" 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[] (PHP Markdown Extra)-\f[C]footnotes\f[], \f[C]pipe_tables\f[], \f[C]raw_html\f[],-\f[C]markdown_attribute\f[], \f[C]fenced_code_blocks\f[],-\f[C]definition_lists\f[], \f[C]intraword_underscores\f[],-\f[C]header_attributes\f[], \f[C]link_attributes\f[],-\f[C]abbreviations\f[], \f[C]shortcut_reference_links\f[],-\f[C]spaced_reference_links\f[].-.RS-.RE-.TP-.B \f[C]markdown_github\f[] (deprecated GitHub\-Flavored Markdown)-\f[C]pipe_tables\f[], \f[C]raw_html\f[], \f[C]fenced_code_blocks\f[],-\f[C]gfm_auto_identifiers\f[], \f[C]ascii_identifiers\f[],-\f[C]backtick_code_blocks\f[], \f[C]autolink_bare_uris\f[],-\f[C]space_in_atx_header\f[], \f[C]intraword_underscores\f[],-\f[C]strikeout\f[], \f[C]emoji\f[], \f[C]shortcut_reference_links\f[],-\f[C]angle_brackets_escapable\f[],-\f[C]lists_without_preceding_blankline\f[].-.RS-.RE-.TP-.B \f[C]markdown_mmd\f[] (MultiMarkdown)-\f[C]pipe_tables\f[], \f[C]raw_html\f[], \f[C]markdown_attribute\f[],-\f[C]mmd_link_attributes\f[], \f[C]tex_math_double_backslash\f[],-\f[C]intraword_underscores\f[], \f[C]mmd_title_block\f[],-\f[C]footnotes\f[], \f[C]definition_lists\f[],-\f[C]all_symbols_escapable\f[], \f[C]implicit_header_references\f[],-\f[C]auto_identifiers\f[], \f[C]mmd_header_identifiers\f[],-\f[C]shortcut_reference_links\f[], \f[C]implicit_figures\f[],-\f[C]superscript\f[], \f[C]subscript\f[], \f[C]backtick_code_blocks\f[],-\f[C]spaced_reference_links\f[], \f[C]raw_attribute\f[].-.RS-.RE-.TP-.B \f[C]markdown_strict\f[] (Markdown.pl)-\f[C]raw_html\f[], \f[C]shortcut_reference_links\f[],-\f[C]spaced_reference_links\f[].-.RS-.RE-.PP-We also support \f[C]commonmark\f[] and \f[C]gfm\f[] (GitHub\-Flavored-Markdown, which is implemented as a set of extensions on-\f[C]commonmark\f[]).-.PP-Note, however, that \f[C]commonmark\f[] and \f[C]gfm\f[] have limited-support for extensions.-Only those listed below (and \f[C]smart\f[] and \f[C]raw_tex\f[]) will-work.-The extensions can, however, all be individually disabled.-Also, \f[C]raw_tex\f[] only affects \f[C]gfm\f[] output, not input.-.TP-.B \f[C]gfm\f[] (GitHub\-Flavored Markdown)-\f[C]pipe_tables\f[], \f[C]raw_html\f[], \f[C]fenced_code_blocks\f[],-\f[C]gfm_auto_identifiers\f[], \f[C]ascii_identifiers\f[],-\f[C]backtick_code_blocks\f[], \f[C]autolink_bare_uris\f[],-\f[C]intraword_underscores\f[], \f[C]strikeout\f[],-\f[C]hard_line_breaks\f[], \f[C]emoji\f[],-\f[C]shortcut_reference_links\f[], \f[C]angle_brackets_escapable\f[].-.RS-.RE-.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[], or-slides shows in Microsoft PowerPoint format.-.PP-Here\[aq]s the Markdown source for a simple slide show,-\f[C]habits.txt\f[]:-.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--\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-----##\ Going\ to\ sleep--\-\ Get\ in\ bed-\-\ Count\ sheep-\f[]-.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[]-.fi-.PP-where \f[C]FORMAT\f[] is either \f[C]s5\f[], \f[C]slidy\f[],-\f[C]slideous\f[], \f[C]dzslides\f[], or \f[C]revealjs\f[].-.PP-For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with-the \f[C]\-s/\-\-standalone\f[] option embeds a link to JavaScript and-CSS files, which are assumed to be available at the relative path-\f[C]s5/default\f[] (for S5), \f[C]slideous\f[] (for Slideous),-\f[C]reveal.js\f[] (for reveal.js), or at the Slidy website at-\f[C]w3.org\f[] (for Slidy).-(These paths can be changed by setting the \f[C]slidy\-url\f[],-\f[C]slideous\-url\f[], \f[C]revealjs\-url\f[], or \f[C]s5\-url\f[]-variables; see Variables for 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[] 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[]-.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[]-.fi-.SS Structuring the slide show-.PP-By default, the \f[I]slide level\f[] is the highest header level in the-hierarchy that is followed immediately by content, and not another-header, somewhere in the document.-In the example above, level 1 headers are always followed by level 2-headers, which are followed by content, so 2 is the slide level.-This default can be overridden using the \f[C]\-\-slide\-level\f[]-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 header at the slide level always starts a new slide.-.IP \[bu] 2-Headers \f[I]below\f[] the slide level in the hierarchy create headers-\f[I]within\f[] a slide.-.IP \[bu] 2-Headers \f[I]above\f[] the slide level in the hierarchy create "title-slides," which just contain the section title and help to break the-slide show into sections.-.IP \[bu] 2-Content \f[I]above\f[] the slide level will not appear in the slide-show.-.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 headers 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 headers building horizontally and-level 2 headers 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 "all at once." If-you want your lists to display incrementally (one item at a time), use-the \f[C]\-i\f[] option.-If you want a particular list to depart from the default, put it in a-\f[C]div\f[] block with class \f[C]incremental\f[] or-\f[C]nonincremental\f[].-So, for example, using the \f[C]fenced\ div\f[] syntax, the following-would be incremental regardless of the document default:-.IP-.nf-\f[C]-:::\ incremental--\-\ Eat\ spaghetti-\-\ Drink\ wine--:::-\f[]-.fi-.PP-or-.IP-.nf-\f[C]-:::\ nonincremental--\-\ Eat\ spaghetti-\-\ Drink\ wine--:::-\f[]-.fi-.PP-While using \f[C]incremental\f[] and \f[C]nonincremental\f[] 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[] option and all at once-with the \f[C]\-i\f[] option):-.IP-.nf-\f[C]->\ \-\ Eat\ spaghetti->\ \-\ Drink\ wine-\f[]-.fi-.PP-Both methods allow incremental and nonincremental lists to be mixed in a-single document.-.SS Inserting pauses-.PP-You can add "pauses" 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[]-.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[] (for S5), \f[C]$DATADIR/slidy\f[] (for-Slidy), or \f[C]$DATADIR/slideous\f[] (for Slideous), where-\f[C]$DATADIR\f[] is the user data directory (see-\f[C]\-\-data\-dir\f[], above).-The originals may be found in pandoc\[aq]s system data directory-(generally \f[C]$CABALDIR/pandoc\-VERSION/s5/default\f[]).-Pandoc will look there for any files it does not find in the user data-directory.-.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[] variable:-.IP-.nf-\f[C]-\-V\ theme=moon-\f[]-.fi-.PP-Or you can specify a custom stylesheet using the \f[C]\-\-css\f[]-option.-.PP-To style beamer slides, you can specify a \f[C]theme\f[],-\f[C]colortheme\f[], \f[C]fonttheme\f[], \f[C]innertheme\f[], and-\f[C]outertheme\f[], using the \f[C]\-V\f[] option:-.IP-.nf-\f[C]-pandoc\ \-t\ beamer\ habits.txt\ \-V\ theme:Warsaw\ \-o\ habits.pdf-\f[]-.fi-.PP-Note that header attributes will turn into slide attributes (on a-\f[C]<div>\f[] or \f[C]<section>\f[]) in HTML slide formats, allowing-you to style individual slides.-In beamer, the only header attribute that affects slides is the-\f[C]allowframebreaks\f[] class, which sets the-\f[C]allowframebreaks\f[] 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[]-.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[]-.fi-.PP-To show the notes window in reveal.js, press \f[C]s\f[] 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[], containing two or more div-containers with class \f[C]column\f[] and a \f[C]width\f[] attribute:-.IP-.nf-\f[C]-::::::::::::::\ {.columns}-:::\ {.column\ width="40%"}-contents...-:::-:::\ {.column\ width="60%"}-contents...-:::-::::::::::::::-\f[]-.fi-.SS Frame attributes in beamer-.PP-Sometimes it is necessary to add the LaTeX \f[C][fragile]\f[] option to-a frame in beamer (for example, when using the \f[C]minted\f[]-environment).-This can be forced by adding the \f[C]fragile\f[] class to the header-introducing the slide:-.IP-.nf-\f[C]-#\ Fragile\ slide\ {.fragile}-\f[]-.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[],-\f[C]allowframebreaks\f[], \f[C]b\f[], \f[C]c\f[], \f[C]t\f[],-\f[C]environment\f[], \f[C]label\f[], \f[C]plain\f[], \f[C]shrink\f[],-\f[C]standout\f[], \f[C]noframenumbering\f[].-.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[] 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[].-You can also set \f[C]parallaxBackgroundHorizontal\f[] and-\f[C]parallaxBackgroundVertical\f[] the same way and must also set-\f[C]parallaxBackgroundSize\f[] to have your values take effect.-.PP-To set an image for a particular reveal.js slide, add-\f[C]{data\-background\-image="/path/to/image"}\f[] to the first-slide\-level header 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[],-\f[C]data\-background\-repeat\f[], \f[C]data\-background\-color\f[],-\f[C]data\-transition\f[], and \f[C]data\-transition\-speed\f[].-.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="/path/to/special_image.jpg"}--Slide\ 2\ has\ a\ special\ image\ for\ its\ background,\ even\ though\ the\ header\ has\ no\ content.-\f[]-.fi-.SH CREATING EPUBS WITH PANDOC-.SS EPUB Metadata-.PP-EPUB metadata may be specified using the \f[C]\-\-epub\-metadata\f[]-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:\ ©\ 2007\ John\ Smith,\ CC\ BY\-NC-ibooks:-\ \ version:\ 1.3.4-\&...-\f[]-.fi-.PP-The following fields are recognized:-.TP-.B \f[C]identifier\f[]-Either a string value or an object with fields \f[C]text\f[] and-\f[C]scheme\f[].-Valid values for \f[C]scheme\f[] are \f[C]ISBN\-10\f[],-\f[C]GTIN\-13\f[], \f[C]UPC\f[], \f[C]ISMN\-10\f[], \f[C]DOI\f[],-\f[C]LCCN\f[], \f[C]GTIN\-14\f[], \f[C]ISBN\-13\f[],-\f[C]Legal\ deposit\ number\f[], \f[C]URN\f[], \f[C]OCLC\f[],-\f[C]ISMN\-13\f[], \f[C]ISBN\-A\f[], \f[C]JP\f[], \f[C]OLCC\f[].-.RS-.RE-.TP-.B \f[C]title\f[]-Either a string value, or an object with fields \f[C]file\-as\f[] and-\f[C]type\f[], or a list of such objects.-Valid values for \f[C]type\f[] are \f[C]main\f[], \f[C]subtitle\f[],-\f[C]short\f[], \f[C]collection\f[], \f[C]edition\f[],-\f[C]extended\f[].-.RS-.RE-.TP-.B \f[C]creator\f[]-Either a string value, or an object with fields \f[C]role\f[],-\f[C]file\-as\f[], and \f[C]text\f[], or a list of such objects.-Valid values for \f[C]role\f[] are MARC relators, but pandoc will-attempt to translate the human\-readable versions (like "author" and-"editor") to the appropriate marc relators.-.RS-.RE-.TP-.B \f[C]contributor\f[]-Same format as \f[C]creator\f[].-.RS-.RE-.TP-.B \f[C]date\f[]-A string value in \f[C]YYYY\-MM\-DD\f[] format.-(Only the year is necessary.) Pandoc will attempt to convert other-common date formats.-.RS-.RE-.TP-.B \f[C]lang\f[] (or legacy: \f[C]language\f[])-A string value in BCP 47 format.-Pandoc will default to the local language if nothing is specified.-.RS-.RE-.TP-.B \f[C]subject\f[]-A string value or a list of such values.-.RS-.RE-.TP-.B \f[C]description\f[]-A string value.-.RS-.RE-.TP-.B \f[C]type\f[]-A string value.-.RS-.RE-.TP-.B \f[C]format\f[]-A string value.-.RS-.RE-.TP-.B \f[C]relation\f[]-A string value.-.RS-.RE-.TP-.B \f[C]coverage\f[]-A string value.-.RS-.RE-.TP-.B \f[C]rights\f[]-A string value.-.RS-.RE-.TP-.B \f[C]cover\-image\f[]-A string value (path to cover image).-.RS-.RE-.TP-.B \f[C]stylesheet\f[]-A string value (path to CSS stylesheet).-.RS-.RE-.TP-.B \f[C]page\-progression\-direction\f[]-Either \f[C]ltr\f[] or \f[C]rtl\f[].-Specifies the \f[C]page\-progression\-direction\f[] attribute for the-\f[C]spine\f[] element.-.RS-.RE-.TP-.B \f[C]ibooks\f[]-iBooks\-specific metadata, with the following fields:-.RS-.IP \[bu] 2-\f[C]version\f[]: (string)-.IP \[bu] 2-\f[C]specified\-fonts\f[]: \f[C]true\f[]|\f[C]false\f[] (default-\f[C]false\f[])-.IP \[bu] 2-\f[C]ipad\-orientation\-lock\f[]:-\f[C]portrait\-only\f[]|\f[C]landscape\-only\f[]-.IP \[bu] 2-\f[C]iphone\-orientation\-lock\f[]:-\f[C]portrait\-only\f[]|\f[C]landscape\-only\f[]-.IP \[bu] 2-\f[C]binding\f[]: \f[C]true\f[]|\f[C]false\f[] (default \f[C]true\f[])-.IP \[bu] 2-\f[C]scroll\-axis\f[]:-\f[C]vertical\f[]|\f[C]horizontal\f[]|\f[C]default\f[]-.RE-.SS The \f[C]epub:type\f[] attribute-.PP-For \f[C]epub3\f[] output, you can mark up the header that corresponds-to an EPUB chapter using the \f[C]epub:type\f[] attribute.-For example, to set the attribute to the value \f[C]prologue\f[], use-this markdown:-.IP-.nf-\f[C]-#\ My\ chapter\ {epub:type=prologue}-\f[]-.fi-.PP-Which will result in:-.IP-.nf-\f[C]-<body\ epub:type="frontmatter">-\ \ <section\ epub:type="prologue">-\ \ \ \ <h1>My\ chapter</h1>-\f[]-.fi-.PP-Pandoc will output \f[C]<body\ epub:type="bodymatter">\f[], unless you-use one of the following values, in which case either-\f[C]frontmatter\f[] or \f[C]backmatter\f[] will be output.-.PP-.TS-tab(@);-l l.-T{-\f[C]epub:type\f[] of first section-T}@T{-\f[C]epub:type\f[] 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{-foreword-T}@T{-frontmatter-T}-T{-halftitle,-T}@T{-frontmatter-T}-T{-introduction-T}@T{-frontmatter-T}-T{-preface-T}@T{-frontmatter-T}-T{-seriespage-T}@T{-frontmatter-T}-T{-titlepage-T}@T{-frontmatter-T}-T{-afterword-T}@T{-backmatter-T}-T{-appendix-T}@T{-backmatter-T}-T{-colophon-T}@T{-backmatter-T}-T{-conclusion-T}@T{-backmatter-T}-T{-epigraph-T}@T{-backmatter-T}-.TE-.SS Linked media-.PP-By default, pandoc will download media referenced from any-\f[C]<img>\f[], \f[C]<audio>\f[], \f[C]<video>\f[] or \f[C]<source>\f[]-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="1"\f[] to the tag with the-\f[C]src\f[] attribute.-For example:-.IP-.nf-\f[C]-<audio\ controls="1">-\ \ <source\ src="http://example.com/music/toccata.mp3"-\ \ \ \ \ \ \ \ \ \ data\-external="1"\ type="audio/mpeg">-\ \ </source>-</audio>-\f[]-.fi-.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[].-.PP-The color scheme can be selected using the \f[C]\-\-highlight\-style\f[]-option.-The default color scheme is \f[C]pygments\f[], 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[].-.PP-If you are not satisfied with the predefined styles, you can use-\f[C]\-\-print\-highlight\-style\f[] to generate a JSON-\f[C]\&.theme\f[] file which can be modified and used as the argument to-\f[C]\-\-highlight\-style\f[].-To get a JSON version of the \f[C]pygments\f[] style, for example:-.IP-.nf-\f[C]-pandoc\ \-\-print\-highlight\-style\ pygments\ >\ my.theme-\f[]-.fi-.PP-Then edit \f[C]my.theme\f[] and use it like this:-.IP-.nf-\f[C]-pandoc\ \-\-highlight\-style\ my.theme-\f[]-.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[] 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[] option.-.SH CUSTOM STYLES IN DOCX-.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[] extension in the docx reader-(\f[C]\-f\ docx+styles\f[]), you can produce output that maintains the-styles of the input document, using the \f[C]custom\-style\f[] 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[] file in-the test directory, we have the following different outputs:-.PP-Without the \f[C]+styles\f[] 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[]-.fi-.PP-And with the extension:-.IP-.nf-\f[C]-$\ 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.-:::-\f[]-.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.-.SS Output-.PP-By default, pandoc\[aq]s docx 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[] 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[]s and \f[C]span\f[]s, respectively.-.PP-If you define a \f[C]div\f[] or \f[C]span\f[] with the attribute-\f[C]custom\-style\f[], pandoc will apply your specified style to the-contained elements.-So, for example using the \f[C]bracketed_spans\f[] syntax,-.IP-.nf-\f[C]-[Get\ out]{custom\-style="Emphatically"},\ he\ said.-\f[]-.fi-.PP-would produce a docx file with "Get out" styled with character style-\f[C]Emphatically\f[].-Similarly, using the \f[C]fenced_divs\f[] syntax,-.IP-.nf-\f[C]-Dickinson\ starts\ the\ poem\ simply:--:::\ {custom\-style="Poetry"}-|\ A\ Bird\ came\ down\ the\ Walk\-\-\--|\ He\ did\ not\ know\ I\ saw\-\-\--:::-\f[]-.fi-.PP-would style the two contained lines with the \f[C]Poetry\f[] paragraph-style.-.PP-If the styles are not yet in your reference.docx, they will be defined-in the output file as inheriting from normal text.-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[]-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[] custom\-style \f[C]span\f[].-.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[]-.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[]-.fi-.SH AUTHORS-.PP-Copyright 2006\-2017 John MacFarlane (jgm\@berkeley.edu).+.TH PANDOC 1 "November 01, 2018" "pandoc 2.4"+.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 \f[C]pandoc\f[R]+.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 can be controlled using variables for LaTeX (if LaTeX is+used) and variables for ConTeXt (if ConTeXt is used).+When using an HTML/CSS\-to\-PDF\-engine, \f[C]\-\-css\f[R] affects the+output.+If \f[C]wkhtmltopdf\f[R] is used, then the variables+\f[C]margin\-left\f[R], \f[C]margin\-right\f[R], \f[C]margin\-top\f[R],+\f[C]margin\-bottom\f[R], \f[C]footer\-html\f[R], \f[C]header\-html\f[R]+and \f[C]papersize\f[R] will affect 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] (with \f[C]colorlinks\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 LaTeX 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.+.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]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]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]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)+.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]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]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]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.+This is, in UNIX:+.RS+.IP+.nf+\f[C]+$HOME/.pandoc+\f[R]+.fi+.PP+in Windows XP:+.IP+.nf+\f[C]+C:\[rs]Documents And Settings\[rs]USERNAME\[rs]Application Data\[rs]pandoc+\f[R]+.fi+.PP+and in Windows Vista or later:+.IP+.nf+\f[C]+C:\[rs]Users\[rs]USERNAME\[rs]AppData\[rs]Roaming\[rs]pandoc+\f[R]+.fi+.PP+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.+.RE+.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 headers (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.+.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.+.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.+.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.+.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 headers 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].+.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]+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]+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]+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), Markdown (which uses 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 headers in Markdown output.+The default is to use setext\-style headers for levels 1\-2, and then+ATX headers.+(Note: for \f[C]gfm\f[R] output, ATX headers are always used.)+.TP+.B \f[C]\-\-top\-level\-division=[default|section|chapter|part]\f[R]+Treat top\-level headers as the given division type in LaTeX, ConTeXt,+DocBook, and TEI output.+The hierarchy order is part, chapter, then section; all headers are+shifted such that the top\-level header 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 headers to+become \f[C]\[rs]part{..}\f[R], while second\-level headers 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 headers,+the second for second\-level headers, and so on.+So, for example, if you want the first top\-level header 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 header 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 headers 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]).+Headers above this level in the hierarchy are used to divide the slide+show into sections; headers below this level create subheads within a+slide.+Note that content that is not contained under slide\-level headers 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 header itself.+See Header 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 \-\-print\-default\-data\-file reference.docx > custom\-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: [paragraph] 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] Default Paragraph+Font, Body Text Char, Verbatim Char, Footnote Reference, Hyperlink;+[table] 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 \-\-print\-default\-data\-file reference.odt > custom\-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+Any template included with a recent install of Microsoft PowerPoint+(either with \f[C].pptx\f[R] or \f[C].potx\f[R] extension) should work,+as will most templates derived from these.+.RS+.PP+The specific requirement is that the template should contain the+following four layouts as its 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 \-\-print\-default\-data\-file reference.pptx > custom\-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 header level at which to split the EPUB into separate+\[dq]chapter\[dq] files.+The default is to split into chapters at level 1 headers.+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 headers, 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]\-\-pdf\-engine=pdflatex\f[R]|\f[C]lualatex\f[R]|\f[C]xelatex\f[R]|\f[C]wkhtmltopdf\f[R]|\f[C]weasyprint\f[R]|\f[C]prince\f[R]|\f[C]context\f[R]|\f[C]pdfroff\f[R]+Use the specified engine when producing PDF output.+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].+If used multiple times, the arguments are provided with spaces between+them.+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] has 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]\-\-metadata\f[R] option.+.SS Variables set by pandoc+.PP+Some variables are set automatically by pandoc.+These vary somewhat depending on the output format, but include the+following:+.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.+.RE+.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+.RE+.TP+.B \f[C]subtitle\f[R]+document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word+docx; renders in LaTeX only when using a document class that supports+\f[C]\[rs]subtitle\f[R], such as \f[C]beamer\f[R] or the KOMA\-Script+series (\f[C]scrartcl\f[R], \f[C]scrreprt\f[R], \f[C]scrbook\f[R]).+.TP+.B \f[C]institute\f[R]+author affiliations (in LaTeX and Beamer only).+Can be a list, when there are multiple authors.+.TP+.B \f[C]abstract\f[R]+document summary, included in LaTeX, ConTeXt, AsciiDoc, and Word docx+.TP+.B \f[C]keywords\f[R]+list of keywords to be included in HTML, PDF, and AsciiDoc metadata; may+be repeated as for \f[C]author\f[R], above+.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]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)+.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]body\f[R]+body of document+.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.+.SS Language variables+.TP+.B \f[C]lang\f[R]+identifies the main language of the document, using a code according to+BCP 47 (e.g.+\f[C]en\f[R] or \f[C]en\-GB\f[R]).+For some output formats, pandoc will convert it to an appropriate format+stored in the additional variables \f[C]babel\-lang\f[R],+\f[C]polyglossia\-lang\f[R] (LaTeX) and \f[C]context\-lang\f[R]+(ConTeXt).+.RS+.PP+Native pandoc Spans and Divs with the lang attribute (value in BCP 47)+can be used to switch the language in that range.+In LaTeX output, \f[C]babel\-otherlangs\f[R] and+\f[C]polyglossia\-otherlangs\f[R] variables will be generated+automatically based on the \f[C]lang\f[R] attributes of Spans and Divs+in the document.+.RE+.TP+.B \f[C]dir\f[R]+the base direction of the document, 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 slides+.PP+Variables are available for producing slide shows with pandoc, including+all reveal.js configuration options.+.TP+.B \f[C]titlegraphic\f[R]+title graphic for Beamer documents+.TP+.B \f[C]logo\f[R]+logo for Beamer documents+.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])+.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]revealjs\-url\f[R]+base URL for reveal.js documents (defaults to \f[C]reveal.js\f[R])+.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]+themes for LaTeX \f[C]beamer\f[R] documents+.TP+.B \f[C]themeoptions\f[R]+options for LaTeX beamer themes (a list).+.TP+.B \f[C]navigation\f[R]+controls navigation symbols in \f[C]beamer\f[R] documents (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 on \[dq]title pages\[dq] for new sections in \f[C]beamer\f[R]+documents (default = true).+.TP+.B \f[C]beamerarticle\f[R]+when true, the \f[C]beamerarticle\f[R] package is loaded (for producing+an article from beamer slides).+.TP+.B \f[C]aspectratio\f[R]+aspect ratio of slides (for beamer only, \f[C]1610\f[R] for 16:10,+\f[C]169\f[R] for 16:9, \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]43\f[R] for 4:3 which is the default,+and \f[C]32\f[R] for 3:2).+.SS Variables for LaTeX+.PP+LaTeX variables are used when creating a PDF.+.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]fontsize\f[R]+font size for body text (e.g.+\f[C]10pt\f[R], \f[C]12pt\f[R])+.TP+.B \f[C]documentclass\f[R]+document class, e.g.+\f[C]article\f[R], \f[C]report\f[R], \f[C]book\f[R], \f[C]memoir\f[R]+.TP+.B \f[C]classoption\f[R]+option for document class, e.g.+\f[C]oneside\f[R]; may be repeated for multiple options+.TP+.B \f[C]beameroption\f[R]+In beamer, add extra beamer option with \f[C]\[rs]setbeameroption{}\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]; may be repeated for multiple options+.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]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]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]: e.g.+\f[C]osf,sc\f[R] with \f[C]fontfamily\f[R] set to \f[C]mathpazo\f[R]+provides Palatino with old\-style figures and true small caps; may be+repeated for multiple options+.TP+.B \f[C]mainfont\f[R], \f[C]romanfont\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.+Note that if \f[C]CJKmainfont\f[R] is used, the \f[C]xecjk\f[R] package+must be available.+.TP+.B \f[C]mainfontoptions\f[R], \f[C]romanfontoptions\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], such as the+OpenType features \f[C]Numbers=OldStyle,Numbers=Proportional\f[R].+May be repeated for multiple options.+.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 guide to LaTeX+font encodings)+.TP+.B \f[C]microtypeoptions\f[R]+options to pass to the microtype package+.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+.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]subparagraph\f[R]+disables default behavior of LaTeX template that redefines+(sub)paragraphs as sections, changing the appearance of nested headings+in some classes+.TP+.B \f[C]thanks\f[R]+specifies 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+.TP+.B \f[C]secnumdepth\f[R]+numbering depth for sections, if sections are numbered+.TP+.B \f[C]lof\f[R], \f[C]lot\f[R]+include list of figures, list of tables+.TP+.B \f[C]bibliography\f[R]+bibliography to use for resolving references+.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]biblatexoptions\f[R]+list of options for biblatex.+.TP+.B \f[C]natbiboptions\f[R]+list of options for natbib.+.TP+.B \f[C]pagestyle\f[R]+An option for LaTeX\[aq]s \f[C]\[rs]pagestyle{}\f[R].+The default article class supports \[aq]plain\[aq] (default),+\[aq]empty\[aq], and \[aq]headings\[aq]; headings puts section titles in+the header.+.SS Variables for ConTeXt+.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); may be repeated for multiple options+.TP+.B \f[C]layout\f[R]+options for page margins and text arrangement (see ConTeXt Layout); may+be repeated for multiple options+.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]fontsize\f[R]+font size for body text (e.g.+\f[C]10pt\f[R], \f[C]12pt\f[R])+.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]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]indenting\f[R]+controls indentation of paragraphs, e.g.+\f[C]yes,small,next\f[R] (see ConTeXt Indentation); may be repeated for+multiple options+.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])+.TP+.B \f[C]interlinespace\f[R]+adjusts line spacing, e.g.+\f[C]4ex\f[R] (using \f[C]setupinterlinespace\f[R]); may be repeated for+multiple options+.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); may be repeated up to four times for different placement+.TP+.B \f[C]pagenumbering\f[R]+page number style and location (using \f[C]setuppagenumbering\f[R]); may+be repeated for multiple options+.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]lof\f[R], \f[C]lot\f[R]+include list of figures, list of tables+.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.+.SS Variables for man pages+.TP+.B \f[C]section\f[R]+section number in man pages+.TP+.B \f[C]header\f[R]+header in man pages+.TP+.B \f[C]footer\f[R]+footer in 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]hyphenate\f[R]+if \f[C]true\f[R] (the default), hyphenation will be used+.SS Variables for ms+.TP+.B \f[C]pointsize\f[R]+point size (e.g.+\f[C]10p\f[R])+.TP+.B \f[C]lineheight\f[R]+line height (e.g.+\f[C]12p\f[R])+.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])+.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+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+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.+.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 Headers and sections+.SS Extension: \f[C]auto_identifiers\f[R]+.PP+A header without an explicitly specified identifier will be+automatically assigned a unique identifier based on the header 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 algorithm used to derive the identifier from the header text is:+.IP \[bu] 2+Remove all formatting, links, etc.+.IP \[bu] 2+Remove all footnotes.+.IP \[bu] 2+Remove all punctuation, except underscores, hyphens, and periods.+.IP \[bu] 2+Replace all spaces and newlines with hyphens.+.IP \[bu] 2+Convert all alphabetic characters to lowercase.+.IP \[bu] 2+Remove everything up to the first letter (identifiers may not begin with+a number or punctuation mark).+.IP \[bu] 2+If nothing is left after this, use the identifier \f[C]section\f[R].+.PP+Thus, for example,+.PP+.TS+tab(@);+l l.+T{+Header+T}@T{+Identifier+T}+_+T{+\f[C]Header identifiers in HTML\f[R]+T}@T{+\f[C]header\-identifiers\-in\-html\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 header text.+The exception is when several headers have the same text; in this case,+the first will get an identifier as described above; the second will get+the same identifier with \f[C]\-1\f[R] appended; the third with+\f[C]\-2\f[R]; and so on.+.PP+These identifiers are used to provide link targets in the table of+contents generated by the \f[C]\-\-toc|\-\-table\-of\-contents\f[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+[header identifiers](#header\-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 header 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 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)+.TP+.B output formats+\f[C]textile\f[R], \f[C]commonmark\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 headers 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, headers will be rendered setext\-style (with underlines)+rather than ATX\-style (with \[aq]#\[aq] characters).+(This is because ghc treats \[aq]#\[aq] characters in column 1 as+introducing line numbers.)+.IP \[bu] 2+In restructured text input, \[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+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 Headers+.PP+There are two kinds of headers: Setext and ATX.+.SS Setext\-style headers+.PP+A setext\-style header is a line of text \[dq]underlined\[dq] with a row+of \f[C]=\f[R] signs (for a level one header) or \f[C]\-\f[R] signs (for+a level two header):+.IP+.nf+\f[C]+A level\-one header+==================++A level\-two header+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\f[R]+.fi+.PP+The header text can contain inline formatting, such as emphasis (see+Inline formatting, below).+.SS ATX\-style headers+.PP+An ATX\-style header consists of one to six \f[C]#\f[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+header level:+.IP+.nf+\f[C]+## A level\-two header++### A level\-three header ###+\f[R]+.fi+.PP+As with setext\-style headers, the header text can contain formatting:+.IP+.nf+\f[C]+# A level\-one header with a [link](/url) and *emphasis*+\f[R]+.fi+.SS Extension: \f[C]blank_before_header\f[R]+.PP+Standard Markdown syntax does not require a blank line before a header.+Pandoc does require this (except, of course, at the beginning of the+document).+The reason for the requirement is that it is all too easy for a+\f[C]#\f[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 header and the header text, so that+\f[C]#5 bolt\f[R] and \f[C]#hashtag\f[R] count as headers.+With this extension, pandoc does require the space.+.SS Header identifiers+.PP+See also the \f[C]auto_identifiers\f[R] extension above.+.SS Extension: \f[C]header_attributes\f[R]+.PP+Headers can be assigned attributes using this syntax at the end of the+line containing the header text:+.IP+.nf+\f[C]+{#identifier .class .class key=value key=value}+\f[R]+.fi+.PP+Thus, for example, the following headers will all be assigned the+identifier \f[C]foo\f[R]:+.IP+.nf+\f[C]+# My header {#foo}++## My header ## {#foo}++My other header {#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, and AsciiDoc writers.+.PP+Headers 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 header {\-}+\f[R]+.fi+.PP+is just the same as+.IP+.nf+\f[C]+# My header {.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 header.+So, to link to a header+.IP+.nf+\f[C]+# Header identifiers in HTML+\f[R]+.fi+.PP+you can simply write+.IP+.nf+\f[C]+[Header identifiers in HTML]+\f[R]+.fi+.PP+or+.IP+.nf+\f[C]+[Header identifiers in HTML][]+\f[R]+.fi+.PP+or+.IP+.nf+\f[C]+[the section on header identifiers][header identifiers in+HTML]+\f[R]+.fi+.PP+instead of giving the identifier explicitly:+.IP+.nf+\f[C]+[Header identifiers in HTML](#header\-identifiers\-in\-html)+\f[R]+.fi+.PP+If there are multiple headers 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+header 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 headers), 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 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 headers and table rows must each fit on one line.+Column alignments are determined by the position of the header text+relative to the dashed line below it:+.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 headers may be omitted, provided a dashed line is used to end+the table.+For example:+.IP+.nf+\f[C]+\-\-\-\-\-\-\- \-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-+ 12 12 12 12+ 123 123 123 123+ 1 1 1 1+\-\-\-\-\-\-\- \-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-+\f[R]+.fi+.PP+When headers are omitted, column alignments are determined on the basis+of the first line of the table body.+So, in the tables above, the columns would be right, left, center, and+right aligned, respectively.+.SS Extension: \f[C]multiline_tables\f[R]+.PP+Multiline tables allow headers and table rows to span multiple lines of+text (but cells that span multiple columns or rows of the table are not+supported).+Here is an example:+.IP+.nf+\f[C]+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ Centered Default Right Left+ Header Aligned Aligned Aligned+\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ First row 12.0 Example of a row that+ spans multiple lines.++ Second row 5.0 Here\[aq]s another one. Note+ the blank line between+ rows.+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++Table: Here\[aq]s the caption. It, too, may span+multiple lines.+\f[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+headers are omitted).+.IP \[bu] 2+They must end with a row of dashes, then a blank line.+.IP \[bu] 2+The rows must be separated by blank lines.+.PP+In multiline tables, the table parser pays attention to the widths of+the columns, and the writers try to reproduce these relative widths in+the output.+So, if you find that one of the columns is too narrow in the output, try+widening it in the Markdown source.+.PP+Headers may be omitted in multiline tables as well as simple tables:+.IP+.nf+\f[C]+\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ First row 12.0 Example of a row that+ spans multiple lines.++ Second row 5.0 Here\[aq]s another one. Note+ the blank line between+ rows.+\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++: Here\[aq]s a multiline table without headers.+\f[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] \f[R] or \f[C]\[rs] \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 reStructuredText+It will be rendered using an interpreted text role \f[C]:math:\f[R].+.TP+.B AsciiDoc+It will be rendered as \f[C]latexmath:[...]\f[R].+.TP+.B Texinfo+It will be rendered inside a \f[C]\[at]math\f[R] command.+.TP+.B roff man+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+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+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+For output formats other than LaTeX, 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 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 Header 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]+++![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]++\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 {#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]+{ 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+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 at the+end of the document.+Normally, you will want to end your document with an appropriate header:+.IP+.nf+\f[C]+last paragraph...++# References+\f[R]+.fi+.PP+The bibliography will be inserted after this header.+Note that the \f[C]unnumbered\f[R] class will be added to this header,+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 header identifiers (in square brackets, after+the header but before any trailing \f[C]#\f[R]s in an ATX header).+.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]gfm_auto_identifiers\f[R], \f[C]ascii_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]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] and \f[C]raw_tex\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]gfm_auto_identifiers\f[R], \f[C]ascii_identifiers\f[R],+\f[C]backtick_code_blocks\f[R], \f[C]autolink_bare_uris\f[R],+\f[C]intraword_underscores\f[R], \f[C]strikeout\f[R],+\f[C]hard_line_breaks\f[R], \f[C]emoji\f[R],+\f[C]shortcut_reference_links\f[R], \f[C]angle_brackets_escapable\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++\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-++++## 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 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 header level in the+hierarchy that is followed immediately by content, and not another+header, somewhere in the document.+In the example above, level 1 headers are always followed by level 2+headers, which are followed by content, so 2 is the slide level.+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 header at the slide level always starts a new slide.+.IP \[bu] 2+Headers \f[I]below\f[R] the slide level in the hierarchy create headers+\f[I]within\f[R] a slide.+.IP \[bu] 2+Headers \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.+.IP \[bu] 2+Content \f[I]above\f[R] the slide level will not appear in the slide+show.+.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 headers 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 headers building horizontally and+level 2 headers 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 header 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 header 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 header+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 header 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 header 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 header 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{+foreword+T}@T{+frontmatter+T}+T{+halftitle,+T}@T{+frontmatter+T}+T{+introduction+T}@T{+frontmatter+T}+T{+preface+T}@T{+frontmatter+T}+T{+seriespage+T}@T{+frontmatter+T}+T{+titlepage+T}@T{+frontmatter+T}+T{+afterword+T}@T{+backmatter+T}+T{+appendix+T}@T{+backmatter+T}+T{+colophon+T}@T{+backmatter+T}+T{+conclusion+T}@T{+backmatter+T}+T{+epigraph+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 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 IN DOCX+.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.+.SS Output+.PP+By default, pandoc\[aq]s docx 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+If the styles are not yet in your reference.docx, they will be defined+in the output file as inheriting from normal text.+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].+.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+.SH AUTHORS+.PP+Copyright 2006\-2017 John MacFarlane (jgm\[at]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
@@ -1,5 +1,5 @@ name: pandoc-version: 2.3.1+version: 2.4 cabal-version: 2.0 build-type: Custom license: GPL-2@@ -11,7 +11,8 @@ stability: alpha homepage: https://pandoc.org category: Text-tested-with: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3+tested-with: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3,+ GHC == 8.6.1 synopsis: Conversion between markup formats description: Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses@@ -19,15 +20,16 @@ (subsets of) HTML, reStructuredText, LaTeX, DocBook, JATS, MediaWiki markup, TWiki markup, TikiWiki markup, Creole 1.0, Haddock markup, OPML, Emacs Org-Mode, Emacs Muse, txt2tags,- Vimwiki, Word Docx, ODT, EPUB, FictionBook2, and Textile,- and it can write Markdown, reStructuredText, XHTML, HTML 5,- LaTeX, ConTeXt, DocBook, JATS, OPML, TEI, OpenDocument,- ODT, Word docx, RTF, MediaWiki, DokuWiki, ZimWiki, Textile,- groff man, groff ms, plain text, Emacs Org-Mode, AsciiDoc,- Haddock markup, EPUB (v2 and v3), FictionBook2, InDesign- ICML, Muse, LaTeX beamer slides, PowerPoint, and several- kinds of HTML/JavaScript slide shows (S5, Slidy, Slideous,- DZSlides, reveal.js).+ Vimwiki, Word Docx, ODT, EPUB, FictionBook2, roff man,+ and Textile, and it can write Markdown, reStructuredText,+ XHTML, HTML 5, LaTeX, ConTeXt, DocBook, JATS, OPML, TEI,+ OpenDocument, ODT, Word docx, PowerPoint pptx,+ RTF, MediaWiki, DokuWiki, ZimWiki, Textile,+ roff man, roff ms, plain text, Emacs Org-Mode,+ AsciiDoc, Haddock markup, EPUB (v2 and v3),+ FictionBook2, InDesign ICML, Muse, LaTeX beamer slides,+ and several kinds of HTML/JavaScript slide shows+ (S5, Slidy, Slideous, DZSlides, reveal.js). . In contrast to most existing tools for converting Markdown to HTML, pandoc has a modular design: it consists of a set of@@ -79,6 +81,7 @@ data/docx/_rels/.rels data/docx/docProps/app.xml data/docx/docProps/core.xml+ data/docx/docProps/custom.xml data/docx/word/document.xml data/docx/word/fontTable.xml data/docx/word/comments.xml@@ -190,6 +193,7 @@ test/command/SVG_logo.svg test/command/corrupt.svg test/command/inkscape-cube.svg+ test/command/lua-pandoc-state.lua test/command/sub-file-chapter-1.tex test/command/sub-file-chapter-2.tex test/command/bar.tex@@ -205,6 +209,7 @@ test/haddock-reader.haddock test/insert test/lalune.jpg+ test/man-reader.man test/movie.jpg test/media/rId25.jpg test/media/rId26.jpg@@ -340,9 +345,9 @@ setup-depends: base, Cabal >= 2.0 library- build-depends: base >= 4.7 && < 5,+ build-depends: base >= 4.8 && < 5, syb >= 0.1 && < 0.8,- containers >= 0.4.2.1 && < 0.6,+ containers >= 0.4.2.1 && < 0.7, unordered-containers >= 0.2 && < 0.3, parsec >= 3.1 && < 3.2, mtl >= 2.2 && < 2.3,@@ -366,17 +371,17 @@ tagsoup >= 0.14.6 && < 0.15, base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.7,- skylighting >= 0.7.2 && < 0.8,+ skylighting >= 0.7.4 && < 0.8, data-default >= 0.4 && < 0.8, temporary >= 1.1 && < 1.4, blaze-html >= 0.9 && < 0.10, blaze-markup >= 0.8 && < 0.9, vector >= 0.10 && < 0.13,- hslua >= 1.0 && < 1.1,+ hslua >= 1.0.1 && < 1.1, hslua-module-text >= 0.2 && < 0.3,- binary >= 0.5 && < 0.10,+ binary >= 0.5 && < 0.11, SHA >= 1.6 && < 1.7,- haddock-library >= 1.6 && < 1.7,+ haddock-library >= 1.7 && < 1.8, deepseq >= 1.3 && < 1.5, JuicyPixels >= 3.1.6.1 && < 3.4, Glob >= 0.7 && < 0.10,@@ -388,6 +393,7 @@ http-client-tls >= 0.2.4 && < 0.4, 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 if impl(ghc < 8.0) build-depends: semigroups == 0.18.*,@@ -409,7 +415,15 @@ other-modules: Text.Pandoc.Data if os(windows) cpp-options: -D_WINDOWS- ghc-options: -Wall -fno-warn-unused-do-bind+ 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)+ ghc-options: -Wincomplete-uni-patterns+ -Widentities+ -Werror=missing-home-modules default-language: Haskell2010 other-extensions: NoImplicitPrelude hs-source-dirs: src@@ -422,6 +436,7 @@ Text.Pandoc.Shared, Text.Pandoc.MediaBag, Text.Pandoc.Error,+ Text.Pandoc.Filter, Text.Pandoc.Readers, Text.Pandoc.Readers.HTML, Text.Pandoc.Readers.LaTeX,@@ -446,6 +461,7 @@ Text.Pandoc.Readers.Odt, Text.Pandoc.Readers.EPUB, Text.Pandoc.Readers.Muse,+ Text.Pandoc.Readers.Man, Text.Pandoc.Readers.FB2, Text.Pandoc.Writers, Text.Pandoc.Writers.Native,@@ -498,7 +514,8 @@ Text.Pandoc.ImageSize, Text.Pandoc.BCP47, Text.Pandoc.Class- other-modules: Text.Pandoc.Filter,+ other-modules: Text.Pandoc.App.CommandLineOptions,+ Text.Pandoc.App.OutputSettings, Text.Pandoc.Filter.JSON, Text.Pandoc.Filter.Lua, Text.Pandoc.Filter.Path,@@ -509,6 +526,7 @@ Text.Pandoc.Readers.Docx.StyleMap, Text.Pandoc.Readers.Docx.Fields, Text.Pandoc.Readers.LaTeX.Parsing,+ Text.Pandoc.Readers.LaTeX.Lang, Text.Pandoc.Readers.Odt.Base, Text.Pandoc.Readers.Odt.Namespaces, Text.Pandoc.Readers.Odt.StyleReader,@@ -529,9 +547,12 @@ Text.Pandoc.Readers.Org.ParserState, Text.Pandoc.Readers.Org.Parsing, Text.Pandoc.Readers.Org.Shared,+ Text.Pandoc.Readers.Roff,+ Text.Pandoc.Writers.Roff, Text.Pandoc.Writers.Powerpoint.Presentation, Text.Pandoc.Writers.Powerpoint.Output, Text.Pandoc.Lua.Filter,+ Text.Pandoc.Lua.Global, Text.Pandoc.Lua.Init, Text.Pandoc.Lua.Module.MediaBag, Text.Pandoc.Lua.Module.Pandoc,@@ -541,6 +562,7 @@ Text.Pandoc.Lua.Util, Text.Pandoc.CSS, Text.Pandoc.CSV,+ Text.Pandoc.RoffChar, Text.Pandoc.UUID, Text.Pandoc.Translations, Text.Pandoc.Slides,@@ -549,7 +571,7 @@ buildable: True executable pandoc- build-depends: pandoc, base >= 4.7 && < 5+ build-depends: pandoc, base >= 4.8 && < 5 if impl(ghc < 8.0) build-depends: semigroups == 0.18.* if impl(ghc < 8.4)@@ -589,7 +611,7 @@ main-is: weigh-pandoc.hs hs-source-dirs: benchmark build-depends: pandoc,- base >= 4.2 && < 5,+ base >= 4.8 && < 5, text, weigh >= 0.0 && < 0.1, mtl >= 2.2 && < 2.3@@ -607,7 +629,7 @@ type: exitcode-stdio-1.0 main-is: test-pandoc.hs hs-source-dirs: test- build-depends: base >= 4.2 && < 5,+ build-depends: base >= 4.8 && < 5, pandoc, pandoc-types >= 1.17.5 && < 1.18, bytestring >= 0.9 && < 0.11,@@ -624,8 +646,8 @@ tasty-hunit >= 0.9 && < 0.11, tasty-quickcheck >= 0.8 && < 0.11, tasty-golden >= 2.3 && < 2.4,- QuickCheck >= 2.4 && < 2.12,- containers >= 0.4.2.1 && < 0.6,+ QuickCheck >= 2.4 && < 2.13,+ containers >= 0.4.2.1 && < 0.7, executable-path >= 0.0 && < 0.1, zip-archive >= 0.2.3.4 && < 0.4, xml >= 1.3.12 && < 1.4,@@ -666,6 +688,7 @@ Tests.Readers.EPUB Tests.Readers.Muse Tests.Readers.Creole+ Tests.Readers.Man Tests.Readers.FB2 Tests.Writers.Native Tests.Writers.ConTeXt@@ -694,8 +717,9 @@ hs-source-dirs: benchmark build-depends: pandoc, time, bytestring, containers,- base >= 4.2 && < 5,+ base >= 4.8 && < 5, text >= 0.11 && < 1.3,+ mtl >= 2.2 && < 2.3, criterion >= 1.0 && < 1.6 if impl(ghc < 8.0) build-depends: semigroups == 0.18.*
@@ -1,1649 +1,427 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TupleSections #-}-{--Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>--This program is free software; you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation; either version 2 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program; if not, write to the Free Software-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA--}--{- |- Module : Text.Pandoc.App- Copyright : Copyright (C) 2006-2018 John MacFarlane- License : GNU GPL, version 2 or above-- Maintainer : John MacFarlane <jgm@berkeley@edu>- Stability : alpha- Portability : portable--Does a pandoc conversion based on command-line options.--}-module Text.Pandoc.App (- convertWithOpts- , Opt(..)- , LineEnding(..)- , Filter(..)- , defaultOpts- , parseOptions- , options- , applyFilters- ) where-import Prelude-import qualified Control.Exception as E-import Control.Monad-import Control.Monad.Except (catchError, throwError)-import Control.Monad.Trans-import Data.Aeson (defaultOptions)-import Data.Aeson.TH (deriveJSON)-import qualified Data.ByteString as BS-import qualified Data.ByteString.Lazy as B-import Data.Char (toLower, toUpper, isAscii, ord)-import Data.List (find, intercalate, isPrefixOf, isSuffixOf, sort)-import qualified Data.Map as M-import Data.Maybe (fromMaybe, isJust, isNothing)-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.Text.Lazy.Encoding as TE-import qualified Data.Text.Encoding.Error as TE-import qualified Data.YAML as YAML-import GHC.Generics-import Network.URI (URI (..), parseURI)-#ifdef EMBED_DATA_FILES-import Text.Pandoc.Data (dataFiles)-#else-import System.Directory (getDirectoryContents)-import Paths_pandoc (getDataDir)-#endif-import Data.Aeson.Encode.Pretty (encodePretty', Config(..), keyOrder,- defConfig, Indent(..), NumberFormat(..))-import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme,- pygments)-import Skylighting.Parser (addSyntaxDefinition, parseSyntaxDefinition)-import System.Console.GetOpt-import System.Directory (getAppUserDataDirectory)-import System.Environment (getArgs, getProgName)-import System.Exit (exitSuccess)-import System.FilePath-import System.IO (nativeNewline, stdout)-import qualified System.IO as IO (Newline (..))-import Text.Pandoc-import Text.Pandoc.BCP47 (Lang (..), parseBCP47)-import Text.Pandoc.Builder (setMeta, deleteMeta)-import Text.Pandoc.Filter (Filter (JSONFilter, LuaFilter), applyFilters)-import Text.Pandoc.Highlighting (highlightingStyles)-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, ordNub, safeRead, tabFilter, uriPathToPath)-import qualified Text.Pandoc.UTF8 as UTF8-import Text.Pandoc.Writers.Math (defaultKaTeXURL, defaultMathJaxURL)-import Text.Pandoc.XML (toEntities)-import Text.Printf-#ifndef _WINDOWS-import System.Posix.IO (stdOutput)-import System.Posix.Terminal (queryTerminal)-#endif--data LineEnding = LF | CRLF | Native deriving (Show, Generic)--parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt-parseOptions options' defaults = do- rawArgs <- map UTF8.decodeArg <$> getArgs- prg <- getProgName-- let (actions, args, unrecognizedOpts, errors) =- getOpt' Permute options' rawArgs-- let unknownOptionErrors =- foldr (handleUnrecognizedOption . takeWhile (/= '=')) []- unrecognizedOpts-- unless (null errors && null unknownOptionErrors) $- E.throwIO $ PandocOptionError $- 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 = args })--latexEngines :: [String]-latexEngines = ["pdflatex", "lualatex", "xelatex"]--htmlEngines :: [String]-htmlEngines = ["wkhtmltopdf", "weasyprint", "prince"]--engines :: [(String, String)]-engines = map ("html",) htmlEngines ++- map ("html5",) htmlEngines ++- map ("latex",) latexEngines ++- map ("beamer",) latexEngines ++- [ ("ms", "pdfroff")- , ("context", "context")- ]--pdfEngines :: [String]-pdfEngines = ordNub $ map snd engines--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)."--pdfWriterAndProg :: Maybe String -- ^ 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- case go mWriter mEngine of- Right (writ, prog) -> return (writ, Just prog)- Left err -> panErr err- where- go Nothing Nothing = Right ("latex", "pdflatex")- go (Just writer) Nothing = (writer,) <$> engineForWriter writer- go Nothing (Just engine) = (,engine) <$> writerForEngine (takeBaseName engine)- 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-- writerForEngine eng = case [f | (f,e) <- engines, e == eng] of- fmt : _ -> Right fmt- [] -> Left $- "pdf-engine " ++ eng ++ " not known"-- engineForWriter "pdf" = Left pdfIsNoWriterErrorMsg- engineForWriter w = case [e | (f,e) <- engines, f == baseWriterName w] of- eng : _ -> Right eng- [] -> Left $- "cannot produce pdf output from " ++ w--convertWithOpts :: Opt -> IO ()-convertWithOpts opts = do- let outputFile = fromMaybe "-" (optOutputFile opts)- let filters = optFilters opts- let verbosity = optVerbosity opts-- when (optDumpArgs opts) $- do UTF8.hPutStrLn stdout outputFile- mapM_ (UTF8.hPutStrLn stdout) (optInputFiles opts)- exitSuccess-- epubMetadata <- case optEpubMetadata opts of- Nothing -> return Nothing- Just fp -> Just <$> UTF8.readFile fp-- 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)) &&- optCiteMethod opts `notElem` [Natbib, Biblatex] &&- all (not . isPandocCiteproc) filters- let filters' = if needsCiteproc then JSONFilter "pandoc-citeproc" : filters- else filters-- let sources = case optInputFiles opts of- [] -> ["-"]- xs | optIgnoreArgs opts -> ["-"]- | otherwise -> xs-- datadir <- case optDataDir opts of- Nothing -> E.catch- (Just <$> getAppUserDataDirectory "pandoc")- (\e -> let _ = (e :: E.SomeException)- in return Nothing)- Just _ -> return $ optDataDir opts-- -- assign reader and writer based on options and filenames- let readerName = fromMaybe ( defaultReaderName- (if any isURI sources- then "html"- else "markdown") sources) (optReader opts)-- let nonPdfWriterName Nothing = defaultWriterName outputFile- nonPdfWriterName (Just x) = x-- let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"- (writerName, maybePdfProg) <-- if pdfOutput- then pdfWriterAndProg (optWriter opts) (optPdfEngine opts)- else return (nonPdfWriterName $ optWriter opts, Nothing)-- let format = map toLower $ baseWriterName- $ takeFileName writerName -- in case path to lua script-- -- disabling the custom writer for now- (writer, writerExts) <-- if ".lua" `isSuffixOf` format- then return (TextWriter- (\o d -> writeCustom writerName o d)- :: Writer PandocIO, mempty)- else case getWriter (map toLower writerName) of- Left e -> E.throwIO $ PandocAppError $- if format == "pdf"- then e ++ "\n" ++ pdfIsNoWriterErrorMsg- else e- Right (w, es) -> return (w :: Writer PandocIO, es)-- -- 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 standalone = optStandalone opts || not (isTextFormat format) || pdfOutput- let addStringAsVariable varname s vars = return $ (varname, s) : vars-- highlightStyle <- lookupHighlightStyle $ optHighlightStyle opts- let addSyntaxMap existingmap f = do- res <- parseSyntaxDefinition f- case res of- Left errstr -> E.throwIO $ PandocSyntaxMapError errstr- Right syn -> return $ addSyntaxDefinition syn existingmap-- syntaxMap <- foldM addSyntaxMap defaultSyntaxMap- (optSyntaxDefinitions opts)-- -- We don't want to send output to the terminal if the user- -- does 'pandoc -t docx input.txt'; though we allow them to- -- 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 <- queryTerminal stdOutput-#endif- when (not (isTextFormat format) && istty && isNothing ( optOutputFile opts)) $- E.throwIO $ PandocAppError $- "Cannot write " ++ format ++ " output to terminal.\n" ++- "Specify an output file using the -o option, or " ++- "use '-o -' to force output to stdout."-- let convertTabs = tabFilter (if optPreserveTabs opts || readerName == "t2t"- 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- setTrace (optTrace opts)- setVerbosity verbosity- x <- f- rs <- getLog- return (x, rs)- case optLogFile opts of- Nothing -> return ()- Just logfile -> B.writeFile logfile (encodeLogMessages reports)- let isWarning msg = messageVerbosity msg == WARNING- when (optFailIfWarnings opts && any isWarning reports) $- E.throwIO PandocFailOnWarningError- return res-- let eol = case optEol opts of- CRLF -> IO.CRLF- LF -> IO.LF- Native -> nativeNewline-- -- 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-- let addContentsAsVariable varname fp vars = do- s <- UTF8.toString <$> readFileStrict fp- return $ (varname, s) : vars-- runIO' $ do- setUserDataDir datadir- setInputFiles (optInputFiles opts)- setOutputFile (optOutputFile opts)-- 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.- >>=- withList (addContentsAsVariable "include-before")- (optIncludeBeforeBody opts)- >>=- withList (addContentsAsVariable "include-after")- (optIncludeAfterBody opts)- >>=- withList (addContentsAsVariable "header-includes")- (optIncludeInHeader opts)- >>=- withList (addStringAsVariable "css") (optCss opts)- >>=- maybe return (addStringAsVariable "title-prefix")- (optTitlePrefix opts)- >>=- maybe return (addStringAsVariable "epub-cover-image")- (optEpubCoverImage opts)- >>=- (\vars -> if format == "dzslides"- then do- dztempl <- UTF8.toString <$> readDataFile- ("dzslides" </> "template.html")- let dzline = "<!-- {{{{ dzslides core"- let dzcore = unlines- $ dropWhile (not . (dzline `isPrefixOf`))- $ lines dztempl- return $ ("dzslides-core", dzcore) : vars- else return vars)-- abbrevs <- (Set.fromList . filter (not . null) . lines) <$>- case optAbbreviations opts of- Nothing -> UTF8.toString <$> readDataFile "abbreviations"- Just f -> UTF8.toString <$> readFileStrict f-- templ <- 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- Just . UTF8.toString <$>- ((fst <$> fetchItem tp') `catchError`- (\e ->- case e of- PandocResourceNotFound _ ->- readDataFile ("templates" </> tp')- _ -> throwError e))-- metadata <- if format == "jats" &&- isNothing (lookup "csl" (optMetadata opts)) &&- isNothing (lookup "citation-style" (optMetadata opts))- then do- jatsCSL <- readDataFile "jats.csl"- let jatsEncoded = makeDataURI- ("application/xml", jatsCSL)- return $ ("csl", jatsEncoded) : optMetadata opts- else return $ optMetadata opts- metadataFromFile <-- case optMetadataFile opts of- Nothing -> return mempty- Just file -> readFileLazy file >>= yamlToMeta-- case lookup "lang" (optMetadata opts) of- Just l -> case parseBCP47 l of- Left _ -> return ()- Right l' -> setTranslations l'- Nothing -> setTranslations $ Lang "en" "" "US" []-- let writerOptions = def {- writerTemplate = templ- , writerVariables = variables- , writerTabStop = optTabStop opts- , writerTableOfContents = optTableOfContents opts- , writerHTMLMathMethod = optHTMLMathMethod opts- , writerIncremental = optIncremental opts- , writerCiteMethod = optCiteMethod opts- , writerNumberSections = optNumberSections opts- , writerNumberOffset = optNumberOffset opts- , writerSectionDivs = optSectionDivs opts- , writerExtensions = writerExts- , writerReferenceLinks = optReferenceLinks opts- , writerReferenceLocation = optReferenceLocation opts- , writerDpi = optDpi opts- , writerWrapText = optWrapText opts- , writerColumns = optColumns opts- , writerEmailObfuscation = optEmailObfuscation opts- , writerIdentifierPrefix = optIdentifierPrefix opts- , writerHtmlQTags = optHtmlQTags opts- , writerTopLevelDivision = optTopLevelDivision opts- , writerListings = optListings opts- , writerSlideLevel = optSlideLevel opts- , writerHighlightStyle = highlightStyle- , writerSetextHeaders = optSetextHeaders opts- , writerEpubSubdirectory = optEpubSubdirectory opts- , writerEpubMetadata = epubMetadata- , writerEpubFonts = optEpubFonts opts- , writerEpubChapterLevel = optEpubChapterLevel opts- , writerTOCDepth = optTOCDepth opts- , writerReferenceDoc = optReferenceDoc opts- , writerSyntaxMap = syntaxMap- }-- let readerOpts = def{- readerStandalone = standalone- , readerColumns = optColumns opts- , readerTabStop = optTabStop opts- , readerIndentedCodeClasses = optIndentedCodeClasses opts- , readerDefaultImageExtension =- optDefaultImageExtension opts- , readerTrackChanges = optTrackChanges opts- , readerAbbreviations = abbrevs- , readerExtensions = readerExts- , readerStripComments = optStripComments opts- }-- let transforms = (case optBaseHeaderLevel opts of- x | x > 1 -> (headerShift (x - 1) :)- | otherwise -> id) .- (if optStripEmptyParagraphs opts- then (stripEmptyParagraphs :)- else id) .- (if extensionEnabled Ext_east_asian_line_breaks- readerExts &&- not (extensionEnabled Ext_east_asian_line_breaks- writerExts &&- writerWrapText writerOptions == WrapPreserve)- then (eastAsianLineBreakFilter :)- else id) $- []-- let sourceToDoc :: [FilePath] -> PandocIO Pandoc- sourceToDoc sources' =- case reader of- TextReader r- | optFileScope opts || readerName == "json" ->- mconcat <$> mapM (readSource >=> r readerOpts) sources- | otherwise ->- readSources sources' >>= r readerOpts- ByteStringReader r ->- mconcat <$> mapM (readFile' >=> r readerOpts) sources--- when (readerName == "markdown_github" ||- writerName == "markdown_github") $- report $ Deprecated "markdown_github" "Use gfm instead."-- setResourcePath (optResourcePath opts)- mapM_ (uncurry setRequestHeader) (optRequestHeaders opts)-- doc <- sourceToDoc sources >>=- ( (if isJust (optExtractMedia opts)- then fillMediaBag- else return)- >=> return . addNonPresentMetadata metadataFromFile- >=> return . addMetadata metadata- >=> applyTransforms transforms- >=> applyFilters readerOpts filters' [format]- >=> maybe return extractMedia (optExtractMedia opts)- )-- case writer of- ByteStringWriter f -> f writerOptions doc >>= writeFnBinary outputFile- TextWriter f -> case maybePdfProg of- Just pdfProg -> do- res <- makePDF pdfProg (optPdfEngineArgs 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')-- Nothing -> do- let htmlFormat = format `elem`- ["html","html4","html5","s5","slidy",- "slideous","dzslides","revealjs"]- escape- | optAscii opts- , htmlFormat || format == "docbook4" ||- format == "docbook5" || format == "docbook" ||- format == "jats" || format == "opml" ||- format == "icml" = toEntities- | optAscii opts- , format == "ms" || format == "man" = groffEscape- | otherwise = id- addNl = if standalone- then id- else (<> T.singleton '\n')- output <- (addNl . escape) <$> f writerOptions doc- writerFn eol outputFile =<<- if optSelfContained opts && htmlFormat- -- TODO not maximally efficient; change type- -- of makeSelfContained so it works w/ Text- then T.pack <$> makeSelfContained (T.unpack output)- else return output--groffEscape :: Text -> Text-groffEscape = T.concatMap toUchar- where toUchar c- | isAscii c = T.singleton c- | otherwise = T.pack $ printf "\\[u%04X]" (ord c)--type Transform = Pandoc -> Pandoc--isTextFormat :: String -> Bool-isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub","pptx"]---- | 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- , optTableOfContents :: Bool -- ^ Include table of contents- , optBaseHeaderLevel :: Int -- ^ Base header level- , 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- , optOutputFile :: Maybe FilePath -- ^ Name of output file- , optInputFiles :: [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 String -- ^ 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- , optAbbreviations :: Maybe FilePath -- ^ Path to abbrevs file- , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc- , optEpubSubdirectory :: String -- ^ EPUB subdir in OCF container- , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata- , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed- , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters- , optEpubCoverImage :: Maybe FilePath -- ^ Cover image for epub- , optTOCDepth :: Int -- ^ Number of levels to include in TOC- , optDumpArgs :: Bool -- ^ Output command-line arguments- , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments- , optVerbosity :: Verbosity -- ^ Verbosity of diagnostic output- , optTrace :: Bool -- ^ Enable tracing- , optLogFile :: Maybe FilePath -- ^ File to write JSON log output- , optFailIfWarnings :: Bool -- ^ Fail on warnings- , 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- , optColumns :: Int -- ^ Line length in characters- , optFilters :: [Filter] -- ^ Filters to apply- , optEmailObfuscation :: ObfuscationMethod- , optIdentifierPrefix :: String- , optStripEmptyParagraphs :: Bool -- ^ Strip empty paragraphs- , optIndentedCodeClasses :: [String] -- ^ 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- , optSlideLevel :: Maybe Int -- ^ Header level that creates slides- , optSetextHeaders :: Bool -- ^ Use atx headers for markdown level 1-2- , optAscii :: Bool -- ^ Use ascii characters only in html- , optDefaultImageExtension :: String -- ^ 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- , optCss :: [FilePath] -- ^ CSS files to link to- , 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- , optEol :: LineEnding -- ^ Style of line-endings to use- , optStripComments :: Bool -- ^ Skip HTML comments- } deriving (Generic, Show)---- | Defaults for command-line options.-defaultOpts :: Opt-defaultOpts = Opt- { optTabStop = 4- , optPreserveTabs = False- , optStandalone = False- , optReader = Nothing- , optWriter = Nothing- , optTableOfContents = False- , optBaseHeaderLevel = 1- , optTemplate = Nothing- , optVariables = []- , optMetadata = []- , optMetadataFile = Nothing- , optOutputFile = Nothing- , optInputFiles = []- , optNumberSections = False- , optNumberOffset = [0,0,0,0,0,0]- , optSectionDivs = False- , optIncremental = False- , optSelfContained = False- , optHtmlQTags = False- , optHighlightStyle = Just "pygments"- , optSyntaxDefinitions = []- , optTopLevelDivision = TopLevelDefault- , optHTMLMathMethod = PlainMath- , optAbbreviations = Nothing- , optReferenceDoc = Nothing- , optEpubSubdirectory = "EPUB"- , optEpubMetadata = Nothing- , optEpubFonts = []- , optEpubChapterLevel = 1- , optEpubCoverImage = Nothing- , optTOCDepth = 3- , optDumpArgs = False- , optIgnoreArgs = False- , optVerbosity = WARNING- , optTrace = False- , optLogFile = Nothing- , optFailIfWarnings = False- , optReferenceLinks = False- , optReferenceLocation = EndOfDocument- , optDpi = 96- , optWrapText = WrapAuto- , optColumns = 72- , optFilters = []- , optEmailObfuscation = NoObfuscation- , optIdentifierPrefix = ""- , optStripEmptyParagraphs = False- , optIndentedCodeClasses = []- , optDataDir = Nothing- , optCiteMethod = Citeproc- , optListings = False- , optPdfEngine = Nothing- , optPdfEngineArgs = []- , optSlideLevel = Nothing- , optSetextHeaders = True- , optAscii = False- , optDefaultImageExtension = ""- , optExtractMedia = Nothing- , optTrackChanges = AcceptChanges- , optFileScope = False- , optTitlePrefix = Nothing- , optCss = []- , optIncludeBeforeBody = []- , optIncludeAfterBody = []- , optIncludeInHeader = []- , optResourcePath = ["."]- , optRequestHeaders = []- , optEol = Native- , optStripComments = False- }--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 = case YAML.decodeStrict (UTF8.fromString s) of- Right [YAML.Scalar (YAML.SStr t)]- -> MetaString $ T.unpack t- Right [YAML.Scalar (YAML.SBool b)]- -> MetaBool b- _ -> MetaString s---- Determine default reader based on source file extensions-defaultReaderName :: String -> [FilePath] -> String-defaultReaderName fallback [] = fallback-defaultReaderName fallback (x:xs) =- case takeExtension (map toLower x) of- ".xhtml" -> "html"- ".html" -> "html"- ".htm" -> "html"- ".md" -> "markdown"- ".markdown" -> "markdown"- ".muse" -> "muse"- ".tex" -> "latex"- ".latex" -> "latex"- ".ltx" -> "latex"- ".rst" -> "rst"- ".org" -> "org"- ".lhs" -> "markdown+lhs"- ".db" -> "docbook"- ".opml" -> "opml"- ".wiki" -> "mediawiki"- ".dokuwiki" -> "dokuwiki"- ".textile" -> "textile"- ".native" -> "native"- ".json" -> "json"- ".docx" -> "docx"- ".t2t" -> "t2t"- ".epub" -> "epub"- ".odt" -> "odt"- ".pdf" -> "pdf" -- so we get an "unknown reader" error- ".doc" -> "doc" -- so we get an "unknown reader" error- ".fb2" -> "fb2"- _ -> defaultReaderName fallback xs---- Determine default writer based on output file extension-defaultWriterName :: FilePath -> String-defaultWriterName "-" = "html" -- no output file-defaultWriterName x =- case takeExtension (map toLower x) of- "" -> "markdown" -- empty extension- ".tex" -> "latex"- ".latex" -> "latex"- ".ltx" -> "latex"- ".context" -> "context"- ".ctx" -> "context"- ".rtf" -> "rtf"- ".rst" -> "rst"- ".s5" -> "s5"- ".native" -> "native"- ".json" -> "json"- ".txt" -> "markdown"- ".text" -> "markdown"- ".md" -> "markdown"- ".muse" -> "muse"- ".markdown" -> "markdown"- ".textile" -> "textile"- ".lhs" -> "markdown+lhs"- ".texi" -> "texinfo"- ".texinfo" -> "texinfo"- ".db" -> "docbook"- ".odt" -> "odt"- ".docx" -> "docx"- ".epub" -> "epub"- ".org" -> "org"- ".asciidoc" -> "asciidoc"- ".adoc" -> "asciidoc"- ".fb2" -> "fb2"- ".opml" -> "opml"- ".icml" -> "icml"- ".tei.xml" -> "tei"- ".tei" -> "tei"- ".ms" -> "ms"- ".roff" -> "ms"- ".pptx" -> "pptx"- ['.',y] | y `elem` ['1'..'9'] -> "man"- _ -> "html"---- Transformations of a Pandoc document post-parsing:--applyTransforms :: Monad m => [Transform] -> Pandoc -> m Pandoc-applyTransforms transforms d = return $ foldr ($) d transforms--readSource :: FilePath -> PandocIO Text-readSource "-" = liftIO (UTF8.toText <$> BS.getContents)-readSource src = case parseURI src of- Just u | uriScheme u `elem` ["http:","https:"] ->- readURI src- | uriScheme u == "file:" ->- liftIO $ UTF8.toText <$>- BS.readFile (uriPathToPath $ uriPath u)- _ -> liftIO $ UTF8.toText <$>- BS.readFile src--readURI :: FilePath -> PandocIO Text-readURI src = UTF8.toText . fst <$> openURL src--readFile' :: MonadIO m => FilePath -> m B.ByteString-readFile' "-" = liftIO B.getContents-readFile' f = liftIO $ B.readFile f--writeFnBinary :: MonadIO m => FilePath -> B.ByteString -> m ()-writeFnBinary "-" = liftIO . B.putStr-writeFnBinary f = liftIO . B.writeFile (UTF8.encodePath f)--writerFn :: MonadIO m => IO.Newline -> FilePath -> Text -> m ()--- TODO this implementation isn't maximally efficient:-writerFn eol "-" = liftIO . UTF8.putStrWith eol . T.unpack-writerFn eol f = liftIO . UTF8.writeFileWith eol f . T.unpack--lookupHighlightStyle :: Maybe String -> IO (Maybe Style)-lookupHighlightStyle Nothing = return Nothing-lookupHighlightStyle (Just 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---- | A list of functions, each transforming the options data structure--- in response to a command-line option.-options :: [OptDescr (Opt -> IO Opt)]-options =- [ Option "fr" ["from","read"]- (ReqArg- (\arg opt -> return opt { optReader =- Just (map toLower arg) })- "FORMAT")- ""-- , Option "tw" ["to","write"]- (ReqArg- (\arg opt -> return opt { optWriter = Just arg })- "FORMAT")- ""-- , Option "o" ["output"]- (ReqArg- (\arg opt -> return opt { optOutputFile = Just arg })- "FILE")- "" -- "Name of output file"-- , Option "" ["data-dir"]- (ReqArg- (\arg opt -> return opt { optDataDir = Just arg })- "DIRECTORY") -- "Directory containing pandoc data files."- ""-- , Option "" ["base-header-level"]- (ReqArg- (\arg opt ->- case safeRead arg of- Just t | t > 0 && t < 6 ->- return opt{ optBaseHeaderLevel = t }- _ -> E.throwIO $ PandocOptionError- "base-header-level must be 1-5")- "NUMBER")- "" -- "Headers base level"-- , Option "" ["strip-empty-paragraphs"]- (NoArg- (\opt -> do- deprecatedOption "--stripEmptyParagraphs"- "Use +empty_paragraphs extension."- return opt{ optStripEmptyParagraphs = True }))- "" -- "Strip empty paragraphs"-- , Option "" ["indented-code-classes"]- (ReqArg- (\arg opt -> return opt { optIndentedCodeClasses = words $- map (\c -> if c == ',' then ' ' else c) arg })- "STRING")- "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"-- , Option "F" ["filter"]- (ReqArg- (\arg opt -> return opt { optFilters =- JSONFilter arg : optFilters opt })- "PROGRAM")- "" -- "External JSON filter"-- , Option "" ["lua-filter"]- (ReqArg- (\arg opt -> return opt { optFilters =- LuaFilter arg : optFilters opt })- "SCRIPTPATH")- "" -- "Lua filter"-- , Option "p" ["preserve-tabs"]- (NoArg- (\opt -> return opt { optPreserveTabs = True }))- "" -- "Preserve tabs instead of converting to spaces"-- , Option "" ["tab-stop"]- (ReqArg- (\arg opt ->- case safeRead arg of- Just t | t > 0 -> return opt { optTabStop = t }- _ -> E.throwIO $ PandocOptionError- "tab-stop must be a number greater than 0")- "NUMBER")- "" -- "Tab stop (default 4)"-- , Option "" ["track-changes"]- (ReqArg- (\arg opt -> do- action <- case arg of- "accept" -> return AcceptChanges- "reject" -> return RejectChanges- "all" -> return AllChanges- _ -> E.throwIO $ PandocOptionError- ("Unknown option for track-changes: " ++ arg)- return opt { optTrackChanges = action })- "accept|reject|all")- "" -- "Accepting or reject MS Word track-changes.""-- , Option "" ["file-scope"]- (NoArg- (\opt -> return opt { optFileScope = True }))- "" -- "Parse input files before combining"-- , Option "" ["extract-media"]- (ReqArg- (\arg opt ->- return opt { optExtractMedia = Just arg })- "PATH")- "" -- "Directory to which to extract embedded media"-- , 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 arg,- optStandalone = True })- "FILE")- "" -- "Use custom template"-- , Option "M" ["metadata"]- (ReqArg- (\arg opt -> do- let (key, val) = splitField arg- return opt{ optMetadata = (key, val) : optMetadata opt })- "KEY[:VALUE]")- ""-- , Option "" ["metadata-file"]- (ReqArg- (\arg opt -> return opt{ optMetadataFile = Just arg })- "FILE")- ""-- , Option "V" ["variable"]- (ReqArg- (\arg opt -> do- let (key, val) = splitField arg- return opt{ optVariables = (key, val) : optVariables opt })- "KEY[:VALUE]")- ""-- , Option "D" ["print-default-template"]- (ReqArg- (\arg _ -> do- templ <- runIO $ do- setUserDataDir Nothing- getDefaultTemplate arg- case templ of- Right "" -> do -- e.g. for docx, odt, json:- E.throwIO $ PandocCouldNotFindDataFileError- ("templates/default." ++ arg)- Right t -> UTF8.hPutStr stdout t- Left e -> E.throwIO e- exitSuccess)- "FORMAT")- "" -- "Print default template for FORMAT"-- , Option "" ["print-default-data-file"]- (ReqArg- (\arg _ -> do- runIOorExplode $- readDefaultDataFile arg >>= liftIO . BS.hPutStr stdout- exitSuccess)- "FILE")- "" -- "Print default data file"-- , Option "" ["print-highlight-style"]- (ReqArg- (\arg _ -> do- sty <- fromMaybe pygments <$>- lookupHighlightStyle (Just arg)- B.putStr $ encodePretty'- defConfig{confIndent = Spaces 4- ,confCompare = keyOrder- (map T.pack- ["text-color"- ,"background-color"- ,"line-number-color"- ,"line-number-background-color"- ,"bold"- ,"italic"- ,"underline"- ,"text-styles"])- ,confNumFormat = Generic- ,confTrailingNewline = True} sty- exitSuccess)- "STYLE|FILE")- "" -- "Print default template for FORMAT"-- , Option "" ["dpi"]- (ReqArg- (\arg opt ->- case safeRead arg of- Just t | t > 0 -> return opt { optDpi = t }- _ -> E.throwIO $ PandocOptionError- "dpi must be a number greater than 0")- "NUMBER")- "" -- "Dpi (default 96)"-- , Option "" ["eol"]- (ReqArg- (\arg opt ->- case toLower <$> arg of- "crlf" -> return opt { optEol = CRLF }- "lf" -> return opt { optEol = LF }- "native" -> return opt { optEol = Native }- -- mac-syntax (cr) is not supported in ghc-base.- _ -> E.throwIO $ PandocOptionError- "--eol must be crlf, lf, or native")- "crlf|lf|native")- "" -- "EOL (default OS-dependent)"-- , 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 "" ["columns"]- (ReqArg- (\arg opt ->- case safeRead arg of- Just t | t > 0 -> return opt { optColumns = t }- _ -> E.throwIO $ PandocOptionError- "columns must be a number greater than 0")- "NUMBER")- "" -- "Length of line in characters"-- , Option "" ["strip-comments"]- (NoArg- (\opt -> return opt { optStripComments = True }))- "" -- "Strip HTML comments"-- , Option "" ["toc", "table-of-contents"]- (NoArg- (\opt -> return opt { optTableOfContents = True }))- "" -- "Include table of contents"-- , Option "" ["toc-depth"]- (ReqArg- (\arg opt ->- case safeRead 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")- "NUMBER")- "" -- "Number of levels to include in TOC"-- , Option "" ["no-highlight"]- (NoArg- (\opt -> return opt { optHighlightStyle = Nothing }))- "" -- "Don't highlight source code"-- , Option "" ["highlight-style"]- (ReqArg- (\arg opt -> return opt{ optHighlightStyle = Just arg })- "STYLE|FILE")- "" -- "Style for highlighted code"-- , Option "" ["syntax-definition"]- (ReqArg- (\arg opt -> return opt{ optSyntaxDefinitions = arg :- optSyntaxDefinitions opt })- "FILE")- "" -- "Syntax definition (xml) file"-- , Option "H" ["include-in-header"]- (ReqArg- (\arg opt -> return opt{ optIncludeInHeader =- arg : optIncludeInHeader opt,- optStandalone = True })- "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 })- "FILE")- "" -- "File to include before document body"-- , Option "A" ["include-after-body"]- (ReqArg- (\arg opt -> return opt{ optIncludeAfterBody =- arg : optIncludeAfterBody opt,- optStandalone = True })- "FILE")- "" -- "File to include after document body"-- , Option "" ["resource-path"]- (ReqArg- (\arg opt -> return opt { optResourcePath =- splitSearchPath arg })- "SEARCHPATH")- "" -- "Paths to search for images and other resources"-- , Option "" ["request-header"]- (ReqArg- (\arg opt -> do- let (key, val) = splitField arg- return opt{ optRequestHeaders =- (key, val) : optRequestHeaders opt })- "NAME:VALUE")- ""-- , Option "" ["self-contained"]- (NoArg- (\opt -> return opt { optSelfContained = True,- optStandalone = True }))- "" -- "Make slide shows include all the needed js and css"-- , Option "" ["html-q-tags"]- (NoArg- (\opt ->- return opt { optHtmlQTags = True }))- "" -- "Use <q> tags for quotes in HTML"-- , Option "" ["ascii"]- (NoArg- (\opt -> return opt { optAscii = True }))- "" -- "Use ascii characters only in HTML output"-- , Option "" ["reference-links"]- (NoArg- (\opt -> return opt { optReferenceLinks = True } ))- "" -- "Use reference links in parsing HTML"-- , Option "" ["reference-location"]- (ReqArg- (\arg opt -> do- action <- case arg of- "block" -> return EndOfBlock- "section" -> return EndOfSection- "document" -> return EndOfDocument- _ -> E.throwIO $ PandocOptionError- ("Unknown option for reference-location: " ++ arg)- return opt { optReferenceLocation = action })- "block|section|document")- "" -- "Accepting or reject MS Word track-changes.""-- , Option "" ["atx-headers"]- (NoArg- (\opt -> return opt { optSetextHeaders = False } ))- "" -- "Use atx-style headers for markdown"-- , 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"))- "section|chapter|part")- "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"-- , Option "N" ["number-sections"]- (NoArg- (\opt -> return opt { optNumberSections = True }))- "" -- "Number sections in LaTeX"-- , Option "" ["number-offset"]- (ReqArg- (\arg opt ->- case safeRead ('[':arg ++ "]") of- Just ns -> return opt { optNumberOffset = ns,- optNumberSections = True }- _ -> E.throwIO $ PandocOptionError- "could not parse number-offset")- "NUMBERS")- "" -- "Starting number for sections, subsections, etc."-- , Option "" ["listings"]- (NoArg- (\opt -> return opt { optListings = True }))- "" -- "Use listings package for LaTeX code blocks"-- , Option "i" ["incremental"]- (NoArg- (\opt -> return opt { optIncremental = True }))- "" -- "Make list items display incrementally in Slidy/Slideous/S5"-- , Option "" ["slide-level"]- (ReqArg- (\arg opt ->- case safeRead arg of- Just t | t >= 1 && t <= 6 ->- return opt { optSlideLevel = Just t }- _ -> E.throwIO $ PandocOptionError- "slide level must be a number between 1 and 6")- "NUMBER")- "" -- "Force header level for slides"-- , Option "" ["section-divs"]- (NoArg- (\opt -> return opt { optSectionDivs = True }))- "" -- "Put sections in div tags in HTML"-- , Option "" ["default-image-extension"]- (ReqArg- (\arg opt -> return opt { optDefaultImageExtension = arg })- "extension")- "" -- "Default extension for extensionless images"-- , Option "" ["email-obfuscation"]- (ReqArg- (\arg opt -> do- method <- case arg of- "references" -> return ReferenceObfuscation- "javascript" -> return JavascriptObfuscation- "none" -> return NoObfuscation- _ -> E.throwIO $ PandocOptionError- ("Unknown obfuscation method: " ++ arg)- return opt { optEmailObfuscation = method })- "none|javascript|references")- "" -- "Method for obfuscating email in HTML"-- , Option "" ["id-prefix"]- (ReqArg- (\arg opt -> return opt { optIdentifierPrefix = 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 })- "STRING")- "" -- "String to prefix to HTML window title"-- , Option "c" ["css"]- (ReqArg- (\arg opt -> return opt{ optCss = arg : optCss opt })- -- add new link to end, so it is included in proper order- "URL")- "" -- "Link to CSS style sheet"-- , Option "" ["reference-doc"]- (ReqArg- (\arg opt ->- return opt { optReferenceDoc = Just arg })- "FILE")- "" -- "Path of custom reference doc"-- , Option "" ["epub-subdirectory"]- (ReqArg- (\arg opt ->- return opt { optEpubSubdirectory = arg })- "DIRNAME")- "" -- "Name of subdirectory for epub content in OCF container"-- , Option "" ["epub-cover-image"]- (ReqArg- (\arg opt ->- return opt { optVariables =- ("epub-cover-image", arg) : optVariables opt })- "FILE")- "" -- "Path of epub cover image"-- , Option "" ["epub-metadata"]- (ReqArg- (\arg opt -> return opt { optEpubMetadata = Just arg })- "FILE")- "" -- "Path of epub metadata file"-- , Option "" ["epub-embed-font"]- (ReqArg- (\arg opt ->- return opt{ optEpubFonts = arg : optEpubFonts opt })- "FILE")- "" -- "Directory of fonts to embed"-- , Option "" ["epub-chapter-level"]- (ReqArg- (\arg opt ->- case safeRead arg of- Just t | t >= 1 && t <= 6 ->- return opt { optEpubChapterLevel = t }- _ -> E.throwIO $ PandocOptionError- "chapter level must be a number between 1 and 6")- "NUMBER")- "" -- "Header level at which to split chapters in EPUB"-- , Option "" ["pdf-engine"]- (ReqArg- (\arg opt -> do- let b = takeBaseName arg- if b `elem` pdfEngines- then return opt { optPdfEngine = Just arg }- else E.throwIO $ PandocOptionError $ "pdf-engine must be one of "- ++ intercalate ", " pdfEngines)- "PROGRAM")- "" -- "Name of program to use in generating PDF"-- , Option "" ["pdf-engine-opt"]- (ReqArg- (\arg opt -> do- let oldArgs = optPdfEngineArgs opt- return opt { optPdfEngineArgs = oldArgs ++ [arg]})- "STRING")- "" -- "Flags to pass to the PDF-engine, all instances of this option are accumulated and used"-- , Option "" ["bibliography"]- (ReqArg- (\arg opt -> return opt{ optMetadata =- ("bibliography", arg) : optMetadata opt })- "FILE")- ""-- , Option "" ["csl"]- (ReqArg- (\arg opt ->- return opt{ optMetadata =- ("csl", arg) : optMetadata opt })- "FILE")- ""-- , Option "" ["citation-abbreviations"]- (ReqArg- (\arg opt ->- return opt{ optMetadata =- ("citation-abbreviations", arg): optMetadata opt })- "FILE")- ""-- , Option "" ["natbib"]- (NoArg- (\opt -> return opt { optCiteMethod = Natbib }))- "" -- "Use natbib cite commands in LaTeX output"-- , Option "" ["biblatex"]- (NoArg- (\opt -> return opt { optCiteMethod = Biblatex }))- "" -- "Use biblatex cite commands in LaTeX output"-- , Option "" ["mathml"]- (NoArg- (\opt ->- return opt { optHTMLMathMethod = MathML }))- "" -- "Use mathml for HTML math"-- , Option "" ["webtex"]- (OptArg- (\arg opt -> do- let url' = fromMaybe "https://latex.codecogs.com/png.latex?" arg- return opt { optHTMLMathMethod = WebTeX 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- return opt { optHTMLMathMethod = MathJax url'})- "URL")- "" -- "Use MathJax for HTML math"-- , Option "" ["katex"]- (OptArg- (\arg opt ->- return opt- { optHTMLMathMethod = KaTeX $- fromMaybe defaultKaTeXURL arg })- "URL")- "" -- Use KaTeX for HTML Math-- , Option "" ["gladtex"]- (NoArg- (\opt ->- return opt { optHTMLMathMethod = GladTeX }))- "" -- "Use gladtex for HTML math"-- , Option "" ["abbreviations"]- (ReqArg- (\arg opt -> return opt { optAbbreviations = Just arg })- "FILE")- "" -- "Specify file for custom abbreviations"-- , Option "" ["trace"]- (NoArg- (\opt -> return opt { optTrace = True }))- "" -- "Turn on diagnostic tracing in readers."-- , Option "" ["dump-args"]- (NoArg- (\opt -> return opt { optDumpArgs = True }))- "" -- "Print output filename and arguments to stdout."-- , Option "" ["ignore-args"]- (NoArg- (\opt -> return opt { optIgnoreArgs = True }))- "" -- "Ignore command-line arguments."-- , Option "" ["verbose"]- (NoArg- (\opt -> return opt { optVerbosity = INFO }))- "" -- "Verbose diagnostic output."-- , Option "" ["quiet"]- (NoArg- (\opt -> return opt { optVerbosity = ERROR }))- "" -- "Suppress warnings."-- , Option "" ["fail-if-warnings"]- (NoArg- (\opt -> return opt { optFailIfWarnings = True }))- "" -- "Exit with error status if there were warnings."-- , Option "" ["log"]- (ReqArg- (\arg opt -> return opt{ optLogFile = Just arg })- "FILE")- "" -- "Log messages in JSON format to this file."-- , Option "" ["bash-completion"]- (NoArg- (\_ -> do- datafiles <- getDataFileNames- tpl <- runIOorExplode $- UTF8.toString <$>- readDefaultDataFile "bash_completion.tpl"- let optnames (Option shorts longs _ _) =- map (\c -> ['-',c]) shorts ++- map ("--" ++) longs- let allopts = unwords (concatMap optnames options)- UTF8.hPutStrLn stdout $ printf tpl allopts- (unwords readersNames)- (unwords writersNames)- (unwords $ map fst highlightingStyles)- (unwords datafiles)- exitSuccess ))- "" -- "Print bash completion script"-- , Option "" ["list-input-formats"]- (NoArg- (\_ -> do- mapM_ (UTF8.hPutStrLn stdout) readersNames- exitSuccess ))- ""-- , Option "" ["list-output-formats"]- (NoArg- (\_ -> do- mapM_ (UTF8.hPutStrLn stdout) writersNames- exitSuccess ))- ""-- , 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)- mapM_ (UTF8.hPutStrLn stdout . showExt)- ([minBound..maxBound] :: [Extension])- exitSuccess )- "FORMAT")- ""-- , Option "" ["list-highlight-languages"]- (NoArg- (\_ -> do- let langs = [ T.unpack (T.toLower (sShortname s))- | s <- M.elems defaultSyntaxMap- , sShortname s `notElem`- [T.pack "Alert", T.pack "Alert_indent"]- ]- mapM_ (UTF8.hPutStrLn stdout) langs- exitSuccess ))- ""-- , Option "" ["list-highlight-styles"]- (NoArg- (\_ -> do- mapM_ (UTF8.hPutStrLn stdout . fst) highlightingStyles- exitSuccess ))- ""-- , Option "v" ["version"]- (NoArg- (\_ -> do- prg <- getProgName- defaultDatadir <- E.catch- (getAppUserDataDirectory "pandoc")- (\e -> let _ = (e :: E.SomeException)- in return "")- UTF8.hPutStrLn stdout (prg ++ " " ++ pandocVersion ++- compileInfo ++ "\nDefault user data directory: " ++- defaultDatadir ++ copyrightMessage)- exitSuccess ))- "" -- "Print version"-- , Option "h" ["help"]- (NoArg- (\_ -> do- prg <- getProgName- UTF8.hPutStr stdout (usageMessage prg options)- exitSuccess ))- "" -- "Show help"-- ]--getDataFileNames :: IO [FilePath]-getDataFileNames = do-#ifdef EMBED_DATA_FILES- let allDataFiles = map fst dataFiles-#else- allDataFiles <- filter (\x -> x /= "." && x /= "..") <$>- (getDataDir >>= getDirectoryContents)-#endif- return $ "reference.docx" : "reference.odt" : "reference.pptx" : allDataFiles---- Returns usage message-usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String-usageMessage programName = usageInfo (programName ++ " [OPTIONS] [FILES]")--copyrightMessage :: String-copyrightMessage = intercalate "\n" [- "",- "Copyright (C) 2006-2018 John MacFarlane",- "Web: http://pandoc.org",- "This is free software; see the source for copying conditions.",- "There is no warranty, not even for merchantability or fitness",- "for a particular purpose." ]--compileInfo :: String-compileInfo =- "\nCompiled with pandoc-types " ++ VERSION_pandoc_types ++ ", texmath " ++- VERSION_texmath ++ ", skylighting " ++ VERSION_skylighting--handleUnrecognizedOption :: String -> [String] -> [String]-handleUnrecognizedOption "--smart" =- (("--smart/-S has been removed. Use +smart or -smart extension instead.\n" ++- "For example: pandoc -f markdown+smart -t markdown-smart.") :)-handleUnrecognizedOption "--normalize" =- ("--normalize has been removed. Normalization is now automatic." :)-handleUnrecognizedOption "-S" = handleUnrecognizedOption "--smart"-handleUnrecognizedOption "--old-dashes" =- ("--old-dashes has been removed. Use +old_dashes extension instead." :)-handleUnrecognizedOption "--no-wrap" =- ("--no-wrap has been removed. Use --wrap=none instead." :)-handleUnrecognizedOption "--latex-engine" =- ("--latex-engine has been removed. Use --pdf-engine instead." :)-handleUnrecognizedOption "--latex-engine-opt" =- ("--latex-engine-opt has been removed. Use --pdf-engine-opt instead." :)-handleUnrecognizedOption "--chapters" =- ("--chapters has been removed. Use --top-level-division=chapter instead." :)-handleUnrecognizedOption "--reference-docx" =- ("--reference-docx has been removed. Use --reference-doc instead." :)-handleUnrecognizedOption "--reference-odt" =- ("--reference-odt has been removed. Use --reference-doc instead." :)-handleUnrecognizedOption "--parse-raw" =- ("--parse-raw/-R has been removed. Use +raw_html or +raw_tex extension.\n" :)-handleUnrecognizedOption "--epub-stylesheet" =- ("--epub-stylesheet has been removed. Use --css instead.\n" :)-handleUnrecognizedOption "-R" = handleUnrecognizedOption "--parse-raw"-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)]))--writersNames :: [String]-writersNames = sort (map fst (writers :: [(String, Writer PandocIO)]))--splitField :: String -> (String, String)-splitField s =- case break (`elem` ":=") s of- (k,_:v) -> (k,v)- (k,[]) -> (k,"true")--baseWriterName :: String -> String-baseWriterName = takeWhile (\c -> c /= '+' && c /= '-')--deprecatedOption :: String -> String -> IO ()-deprecatedOption o msg =- runIO (report $ Deprecated o msg) >>=- \r -> case r of- Right () -> return ()- Left e -> E.throwIO e---- see https://github.com/jgm/pandoc/pull/4083--- using generic deriving caused long compilation times-$(deriveJSON defaultOptions ''LineEnding)-$(deriveJSON defaultOptions ''Opt)+{-# LANGUAGE ScopedTypeVariables #-}+{-+Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.App+ Copyright : Copyright (C) 2006-2018 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley@edu>+ Stability : alpha+ Portability : portable++Does a pandoc conversion based on command-line options.+-}+module Text.Pandoc.App (+ convertWithOpts+ , Opt(..)+ , LineEnding(..)+ , Filter(..)+ , defaultOpts+ , parseOptions+ , options+ , applyFilters+ ) where+import Prelude+import qualified Control.Exception as E+import Control.Monad+import Control.Monad.Trans+import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as B+import Data.Char (toLower)+import Data.Maybe (fromMaybe, isJust, isNothing)+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.Text.Lazy.Encoding as TE+import qualified Data.Text.Encoding.Error as TE+import qualified Data.YAML as YAML+import Network.URI (URI (..), parseURI)+import System.Directory (getAppUserDataDirectory)+import System.Exit (exitSuccess)+import System.FilePath+import System.IO (nativeNewline, stdout)+import qualified System.IO as IO (Newline (..))+import Text.Pandoc+import Text.Pandoc.App.CommandLineOptions (Opt (..), LineEnding (..),+ defaultOpts, parseOptions, options)+import Text.Pandoc.App.OutputSettings (OutputSettings (..), optToOutputSettings)+import Text.Pandoc.BCP47 (Lang (..), parseBCP47)+import Text.Pandoc.Builder (setMeta, deleteMeta)+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)+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)+ let filters = optFilters opts+ let verbosity = optVerbosity opts++ when (optDumpArgs opts) $+ do UTF8.hPutStrLn stdout outputFile+ mapM_ (UTF8.hPutStrLn stdout) (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)) &&+ optCiteMethod opts `notElem` [Natbib, Biblatex] &&+ all (not . isPandocCiteproc) filters+ let filters' = if needsCiteproc then JSONFilter "pandoc-citeproc" : filters+ else filters++ let sources = case optInputFiles opts of+ [] -> ["-"]+ xs | optIgnoreArgs opts -> ["-"]+ | otherwise -> xs++ datadir <- case optDataDir opts of+ Nothing -> E.catch+ (Just <$> getAppUserDataDirectory "pandoc")+ (\e -> let _ = (e :: E.SomeException)+ in return Nothing)+ 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+ setTrace (optTrace opts)+ setVerbosity verbosity+ x <- f+ rs <- getLog+ return (x, rs)+ case optLogFile opts of+ Nothing -> return ()+ Just logfile -> B.writeFile logfile (encodeLogMessages reports)+ let isWarning msg = messageVerbosity msg == WARNING+ when (optFailIfWarnings opts && any isWarning reports) $+ E.throwIO PandocFailOnWarningError+ return res++ let eol = case optEol opts of+ CRLF -> IO.CRLF+ LF -> IO.LF+ Native -> nativeNewline++ runIO' $ do+ setUserDataDir datadir+ setInputFiles (optInputFiles opts)+ setOutputFile (optOutputFile opts)++ outputSettings <- optToOutputSettings opts+ let format = outputFormat outputSettings+ let writer = outputWriter outputSettings+ let writerName = outputWriterName outputSettings+ let writerOptions = outputWriterOptions outputSettings++ let standalone = optStandalone opts || not (isTextFormat format) || pdfOutput++ -- We don't want to send output to the terminal if the user+ -- does 'pandoc -t docx input.txt'; though we allow them to+ -- 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 " +++ "use '-o -' to force output to stdout."+++ abbrevs <- Set.fromList . filter (not . null) . lines <$>+ case optAbbreviations opts of+ Nothing -> UTF8.toString <$> readDataFile "abbreviations"+ Just f -> UTF8.toString <$> readFileStrict f++ metadata <- if format == "jats" &&+ isNothing (lookup "csl" (optMetadata opts)) &&+ isNothing (lookup "citation-style" (optMetadata opts))+ then do+ jatsCSL <- readDataFile "jats.csl"+ let jatsEncoded = makeDataURI+ ("application/xml", jatsCSL)+ return $ ("csl", jatsEncoded) : optMetadata opts+ else return $ optMetadata opts+ metadataFromFile <-+ case optMetadataFile opts of+ Nothing -> return mempty+ Just file -> readFileLazy file >>= yamlToMeta++ case lookup "lang" (optMetadata opts) of+ Just l -> case parseBCP47 l of+ Left _ -> return ()+ Right l' -> setTranslations l'+ Nothing -> setTranslations $ Lang "en" "" "US" []++ let readerOpts = def{+ readerStandalone = standalone+ , readerColumns = optColumns opts+ , readerTabStop = optTabStop opts+ , readerIndentedCodeClasses = optIndentedCodeClasses opts+ , readerDefaultImageExtension =+ optDefaultImageExtension opts+ , readerTrackChanges = optTrackChanges opts+ , readerAbbreviations = abbrevs+ , readerExtensions = readerExts+ , readerStripComments = optStripComments opts+ }++ let transforms = (case optBaseHeaderLevel opts of+ x | x > 1 -> (headerShift (x - 1) :)+ | otherwise -> id) .+ (if optStripEmptyParagraphs opts+ then (stripEmptyParagraphs :)+ else id) .+ (if extensionEnabled Ext_east_asian_line_breaks+ readerExts &&+ not (extensionEnabled Ext_east_asian_line_breaks+ (writerExtensions writerOptions) &&+ writerWrapText writerOptions == WrapPreserve)+ then (eastAsianLineBreakFilter :)+ else id) $+ []++ let sourceToDoc :: [FilePath] -> PandocIO Pandoc+ sourceToDoc sources' =+ case reader of+ TextReader r+ | optFileScope opts || readerName == "json" ->+ mconcat <$> mapM (readSource >=> r readerOpts) sources+ | otherwise ->+ readSources sources' >>= r readerOpts+ ByteStringReader r ->+ mconcat <$> mapM (readFile' >=> r readerOpts) sources+++ when (readerName == "markdown_github" ||+ writerName == "markdown_github") $+ report $ Deprecated "markdown_github" "Use gfm instead."++ setResourcePath (optResourcePath opts)+ mapM_ (uncurry setRequestHeader) (optRequestHeaders opts)++ doc <- sourceToDoc sources >>=+ ( (if isJust (optExtractMedia opts)+ then fillMediaBag+ else return)+ >=> return . addNonPresentMetadata metadataFromFile+ >=> return . addMetadata metadata+ >=> applyTransforms transforms+ >=> applyFilters readerOpts filters' [format]+ >=> maybe return extractMedia (optExtractMedia opts)+ )++ case writer of+ ByteStringWriter f -> f writerOptions doc >>= writeFnBinary outputFile+ TextWriter f -> case outputPdfProgram outputSettings of+ Just pdfProg -> do+ res <- makePDF pdfProg (optPdfEngineArgs 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')++ Nothing -> do+ let htmlFormat = format `elem`+ ["html","html4","html5","s5","slidy",+ "slideous","dzslides","revealjs"]+ addNl = if standalone+ then id+ else (<> T.singleton '\n')+ output <- addNl <$> f writerOptions doc+ writerFn eol outputFile =<<+ if optSelfContained opts && htmlFormat+ -- TODO not maximally efficient; change type+ -- of makeSelfContained so it works w/ Text+ then T.pack <$> makeSelfContained (T.unpack output)+ else return output++type Transform = Pandoc -> Pandoc++isTextFormat :: String -> 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 = case YAML.decodeStrict (UTF8.fromString s) of+ Right [YAML.Scalar (YAML.SStr t)]+ -> MetaString $ T.unpack t+ Right [YAML.Scalar (YAML.SBool b)]+ -> MetaBool b+ _ -> MetaString s++-- Determine default reader based on source file extensions.+formatFromFilePaths :: String -> [FilePath] -> String+formatFromFilePaths fallback [] = fallback+formatFromFilePaths fallback (x:xs) =+ case formatFromFilePath x of+ Just f -> f+ Nothing -> formatFromFilePaths fallback xs++-- Determine format based on file extension+formatFromFilePath :: FilePath -> Maybe String+formatFromFilePath x =+ case takeExtension (map toLower x) of+ ".adoc" -> Just "asciidoc"+ ".asciidoc" -> Just "asciidoc"+ ".context" -> Just "context"+ ".ctx" -> Just "context"+ ".db" -> Just "docbook"+ ".doc" -> Just "doc" -- so we get an "unknown reader" error+ ".docx" -> Just "docx"+ ".dokuwiki" -> Just "dokuwiki"+ ".epub" -> Just "epub"+ ".fb2" -> Just "fb2"+ ".htm" -> Just "html"+ ".html" -> Just "html"+ ".icml" -> Just "icml"+ ".json" -> Just "json"+ ".latex" -> Just "latex"+ ".lhs" -> Just "markdown+lhs"+ ".ltx" -> Just "latex"+ ".markdown" -> Just "markdown"+ ".md" -> Just "markdown"+ ".ms" -> Just "ms"+ ".muse" -> Just "muse"+ ".native" -> Just "native"+ ".odt" -> Just "odt"+ ".opml" -> Just "opml"+ ".org" -> Just "org"+ ".pdf" -> Just "pdf" -- so we get an "unknown reader" error+ ".pptx" -> Just "pptx"+ ".roff" -> Just "ms"+ ".rst" -> Just "rst"+ ".rtf" -> Just "rtf"+ ".s5" -> Just "s5"+ ".t2t" -> Just "t2t"+ ".tei" -> Just "tei"+ ".tei.xml" -> Just "tei"+ ".tex" -> Just "latex"+ ".texi" -> Just "texinfo"+ ".texinfo" -> Just "texinfo"+ ".text" -> Just "markdown"+ ".textile" -> Just "textile"+ ".txt" -> Just "markdown"+ ".wiki" -> Just "mediawiki"+ ".xhtml" -> Just "html"+ ['.',y] | y `elem` ['1'..'9'] -> Just "man"+ _ -> Nothing++-- Transformations of a Pandoc document post-parsing:++applyTransforms :: Monad m => [Transform] -> Pandoc -> m Pandoc+applyTransforms transforms d = return $ foldr ($) d transforms++readSource :: FilePath -> PandocIO Text+readSource "-" = liftIO (UTF8.toText <$> BS.getContents)+readSource src = case parseURI src of+ Just u | uriScheme u `elem` ["http:","https:"] ->+ readURI src+ | uriScheme u == "file:" ->+ liftIO $ UTF8.toText <$>+ BS.readFile (uriPathToPath $ uriPath u)+ _ -> liftIO $ UTF8.toText <$>+ BS.readFile src++readURI :: FilePath -> PandocIO Text+readURI src = UTF8.toText . fst <$> openURL src++readFile' :: MonadIO m => FilePath -> m B.ByteString+readFile' "-" = liftIO B.getContents+readFile' f = liftIO $ B.readFile f++writeFnBinary :: MonadIO m => FilePath -> B.ByteString -> m ()+writeFnBinary "-" = liftIO . B.putStr+writeFnBinary f = liftIO . B.writeFile (UTF8.encodePath f)++writerFn :: MonadIO m => IO.Newline -> FilePath -> Text -> m ()+-- TODO this implementation isn't maximally efficient:+writerFn eol "-" = liftIO . UTF8.putStrWith eol . T.unpack+writerFn eol f = liftIO . UTF8.writeFileWith eol f . T.unpack
@@ -0,0 +1,1090 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TupleSections #-}+{-+Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.App.CommandLineOptions+ Copyright : Copyright (C) 2006-2018 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley@edu>+ Stability : alpha+ Portability : portable++Does a pandoc conversion based on command-line options.+-}+module Text.Pandoc.App.CommandLineOptions (+ Opt(..)+ , LineEnding (..)+ , defaultOpts+ , parseOptions+ , options+ , engines+ ) where+import Prelude+import Control.Monad+import Control.Monad.Trans+import Data.Aeson.Encode.Pretty (encodePretty', Config(..), keyOrder,+ defConfig, Indent(..), NumberFormat(..))+import Data.Aeson.TH (deriveJSON, defaultOptions)+import Data.Char (toLower, toUpper)+import Data.List (intercalate, sort)+import Data.Maybe (fromMaybe)+import GHC.Generics+import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme,+ pygments)+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.Filter (Filter (..))+import Text.Pandoc.Highlighting (highlightingStyles)+import Text.Pandoc.Writers.Math (defaultMathJaxURL, defaultKaTeXURL)+import Text.Pandoc.Shared (ordNub, safeRead)+import Text.Printf++#ifdef EMBED_DATA_FILES+import Text.Pandoc.Data (dataFiles)+import System.Directory (getAppUserDataDirectory)+#else+import Paths_pandoc (getDataDir)+import System.Directory (getAppUserDataDirectory, getDirectoryContents)+#endif++import qualified Control.Exception as E+import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as B+import qualified Data.Map as M+import qualified Data.Text as T+import qualified Text.Pandoc.UTF8 as UTF8++-- | The type of line-endings to be used when writing plain-text.+data LineEnding = LF | CRLF | Native deriving (Show, Generic)++parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt+parseOptions options' defaults = do+ rawArgs <- map UTF8.decodeArg <$> getArgs+ prg <- getProgName++ let (actions, args, unrecognizedOpts, errors) =+ getOpt' Permute options' rawArgs++ let unknownOptionErrors =+ foldr (handleUnrecognizedOption . takeWhile (/= '=')) []+ unrecognizedOpts++ unless (null errors && null unknownOptionErrors) $+ E.throwIO $ PandocOptionError $+ 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 = args })++latexEngines :: [String]+latexEngines = ["pdflatex", "lualatex", "xelatex"]++htmlEngines :: [String]+htmlEngines = ["wkhtmltopdf", "weasyprint", "prince"]++engines :: [(String, String)]+engines = map ("html",) htmlEngines +++ map ("html5",) htmlEngines +++ map ("latex",) latexEngines +++ map ("beamer",) latexEngines +++ [ ("ms", "pdfroff")+ , ("context", "context")+ ]++pdfEngines :: [String]+pdfEngines = ordNub $ map snd engines+++-- | 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+ , optTableOfContents :: Bool -- ^ Include table of contents+ , optBaseHeaderLevel :: Int -- ^ Base header level+ , 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+ , optOutputFile :: Maybe FilePath -- ^ Name of output file+ , optInputFiles :: [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+ , optSyntaxDefinitions :: [FilePath] -- ^ xml syntax defs to load+ , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions+ , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math+ , optAbbreviations :: Maybe FilePath -- ^ Path to abbrevs file+ , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc+ , optEpubSubdirectory :: String -- ^ EPUB subdir in OCF container+ , optEpubMetadata :: Maybe FilePath -- ^ EPUB metadata+ , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed+ , optEpubChapterLevel :: Int -- ^ Header level at which to split chapters+ , optEpubCoverImage :: Maybe FilePath -- ^ Cover image for epub+ , optTOCDepth :: Int -- ^ Number of levels to include in TOC+ , optDumpArgs :: Bool -- ^ Output command-line arguments+ , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments+ , optVerbosity :: Verbosity -- ^ Verbosity of diagnostic output+ , optTrace :: Bool -- ^ Enable tracing+ , optLogFile :: Maybe FilePath -- ^ File to write JSON log output+ , optFailIfWarnings :: Bool -- ^ Fail on warnings+ , 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+ , optColumns :: Int -- ^ Line length in characters+ , optFilters :: [Filter] -- ^ Filters to apply+ , optEmailObfuscation :: ObfuscationMethod+ , optIdentifierPrefix :: String+ , optStripEmptyParagraphs :: Bool -- ^ Strip empty paragraphs+ , optIndentedCodeClasses :: [String] -- ^ 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+ , 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+ , 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+ , optCss :: [FilePath] -- ^ CSS files to link to+ , 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+ , optEol :: LineEnding -- ^ Style of line-endings to use+ , optStripComments :: Bool -- ^ Skip HTML comments+ } deriving (Generic, Show)++-- | Defaults for command-line options.+defaultOpts :: Opt+defaultOpts = Opt+ { optTabStop = 4+ , optPreserveTabs = False+ , optStandalone = False+ , optReader = Nothing+ , optWriter = Nothing+ , optTableOfContents = False+ , optBaseHeaderLevel = 1+ , optTemplate = Nothing+ , optVariables = []+ , optMetadata = []+ , optMetadataFile = Nothing+ , optOutputFile = Nothing+ , optInputFiles = []+ , optNumberSections = False+ , optNumberOffset = [0,0,0,0,0,0]+ , optSectionDivs = False+ , optIncremental = False+ , optSelfContained = False+ , optHtmlQTags = False+ , optHighlightStyle = Just pygments+ , optSyntaxDefinitions = []+ , optTopLevelDivision = TopLevelDefault+ , optHTMLMathMethod = PlainMath+ , optAbbreviations = Nothing+ , optReferenceDoc = Nothing+ , optEpubSubdirectory = "EPUB"+ , optEpubMetadata = Nothing+ , optEpubFonts = []+ , optEpubChapterLevel = 1+ , optEpubCoverImage = Nothing+ , optTOCDepth = 3+ , optDumpArgs = False+ , optIgnoreArgs = False+ , optVerbosity = WARNING+ , optTrace = False+ , optLogFile = Nothing+ , optFailIfWarnings = False+ , optReferenceLinks = False+ , optReferenceLocation = EndOfDocument+ , optDpi = 96+ , optWrapText = WrapAuto+ , optColumns = 72+ , optFilters = []+ , optEmailObfuscation = NoObfuscation+ , optIdentifierPrefix = ""+ , optStripEmptyParagraphs = False+ , optIndentedCodeClasses = []+ , optDataDir = Nothing+ , optCiteMethod = Citeproc+ , optListings = False+ , optPdfEngine = Nothing+ , optPdfEngineArgs = []+ , optSlideLevel = Nothing+ , optSetextHeaders = True+ , optAscii = False+ , optDefaultImageExtension = ""+ , optExtractMedia = Nothing+ , optTrackChanges = AcceptChanges+ , optFileScope = False+ , optTitlePrefix = Nothing+ , optCss = []+ , optIncludeBeforeBody = []+ , optIncludeAfterBody = []+ , optIncludeInHeader = []+ , optResourcePath = ["."]+ , optRequestHeaders = []+ , optEol = Native+ , optStripComments = False+ }++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++-- | A list of functions, each transforming the options data structure+-- in response to a command-line option.+options :: [OptDescr (Opt -> IO Opt)]+options =+ [ Option "fr" ["from","read"]+ (ReqArg+ (\arg opt -> return opt { optReader =+ Just (map toLower arg) })+ "FORMAT")+ ""++ , Option "tw" ["to","write"]+ (ReqArg+ (\arg opt -> return opt { optWriter = Just arg })+ "FORMAT")+ ""++ , Option "o" ["output"]+ (ReqArg+ (\arg opt -> return opt { optOutputFile = Just arg })+ "FILE")+ "" -- "Name of output file"++ , Option "" ["data-dir"]+ (ReqArg+ (\arg opt -> return opt { optDataDir = Just arg })+ "DIRECTORY") -- "Directory containing pandoc data files."+ ""++ , Option "" ["base-header-level"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 && t < 6 ->+ return opt{ optBaseHeaderLevel = t }+ _ -> E.throwIO $ PandocOptionError+ "base-header-level must be 1-5")+ "NUMBER")+ "" -- "Headers base level"++ , Option "" ["strip-empty-paragraphs"]+ (NoArg+ (\opt -> do+ deprecatedOption "--stripEmptyParagraphs"+ "Use +empty_paragraphs extension."+ return opt{ optStripEmptyParagraphs = True }))+ "" -- "Strip empty paragraphs"++ , Option "" ["indented-code-classes"]+ (ReqArg+ (\arg opt -> return opt { optIndentedCodeClasses = words $+ map (\c -> if c == ',' then ' ' else c) arg })+ "STRING")+ "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"++ , Option "F" ["filter"]+ (ReqArg+ (\arg opt -> return opt { optFilters =+ JSONFilter arg : optFilters opt })+ "PROGRAM")+ "" -- "External JSON filter"++ , Option "" ["lua-filter"]+ (ReqArg+ (\arg opt -> return opt { optFilters =+ LuaFilter arg : optFilters opt })+ "SCRIPTPATH")+ "" -- "Lua filter"++ , Option "p" ["preserve-tabs"]+ (NoArg+ (\opt -> return opt { optPreserveTabs = True }))+ "" -- "Preserve tabs instead of converting to spaces"++ , Option "" ["tab-stop"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 -> return opt { optTabStop = t }+ _ -> E.throwIO $ PandocOptionError+ "tab-stop must be a number greater than 0")+ "NUMBER")+ "" -- "Tab stop (default 4)"++ , Option "" ["track-changes"]+ (ReqArg+ (\arg opt -> do+ action <- case arg of+ "accept" -> return AcceptChanges+ "reject" -> return RejectChanges+ "all" -> return AllChanges+ _ -> E.throwIO $ PandocOptionError+ ("Unknown option for track-changes: " ++ arg)+ return opt { optTrackChanges = action })+ "accept|reject|all")+ "" -- "Accepting or reject MS Word track-changes.""++ , Option "" ["file-scope"]+ (NoArg+ (\opt -> return opt { optFileScope = True }))+ "" -- "Parse input files before combining"++ , Option "" ["extract-media"]+ (ReqArg+ (\arg opt ->+ return opt { optExtractMedia = Just arg })+ "PATH")+ "" -- "Directory to which to extract embedded media"++ , 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 arg,+ optStandalone = True })+ "FILE")+ "" -- "Use custom template"++ , Option "M" ["metadata"]+ (ReqArg+ (\arg opt -> do+ let (key, val) = splitField arg+ return opt{ optMetadata = (key, val) : optMetadata opt })+ "KEY[:VALUE]")+ ""++ , Option "" ["metadata-file"]+ (ReqArg+ (\arg opt -> return opt{ optMetadataFile = Just arg })+ "FILE")+ ""++ , Option "V" ["variable"]+ (ReqArg+ (\arg opt -> do+ let (key, val) = splitField arg+ return opt{ optVariables = (key, val) : optVariables opt })+ "KEY[:VALUE]")+ ""++ , Option "D" ["print-default-template"]+ (ReqArg+ (\arg _ -> do+ templ <- runIO $ do+ setUserDataDir Nothing+ getDefaultTemplate arg+ case templ of+ Right "" -> -- e.g. for docx, odt, json:+ E.throwIO $ PandocCouldNotFindDataFileError+ ("templates/default." ++ arg)+ Right t -> UTF8.hPutStr stdout t+ Left e -> E.throwIO e+ exitSuccess)+ "FORMAT")+ "" -- "Print default template for FORMAT"++ , Option "" ["print-default-data-file"]+ (ReqArg+ (\arg _ -> do+ runIOorExplode $+ readDefaultDataFile arg >>= liftIO . BS.hPutStr stdout+ exitSuccess)+ "FILE")+ "" -- "Print default data file"++ , Option "" ["print-highlight-style"]+ (ReqArg+ (\arg _ -> do+ sty <- fromMaybe pygments <$> lookupHighlightStyle arg+ B.putStr $ encodePretty'+ defConfig{confIndent = Spaces 4+ ,confCompare = keyOrder+ (map T.pack+ ["text-color"+ ,"background-color"+ ,"line-number-color"+ ,"line-number-background-color"+ ,"bold"+ ,"italic"+ ,"underline"+ ,"text-styles"])+ ,confNumFormat = Generic+ ,confTrailingNewline = True} sty+ exitSuccess)+ "STYLE|FILE")+ "" -- "Print default template for FORMAT"++ , Option "" ["dpi"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 -> return opt { optDpi = t }+ _ -> E.throwIO $ PandocOptionError+ "dpi must be a number greater than 0")+ "NUMBER")+ "" -- "Dpi (default 96)"++ , Option "" ["eol"]+ (ReqArg+ (\arg opt ->+ case toLower <$> arg of+ "crlf" -> return opt { optEol = CRLF }+ "lf" -> return opt { optEol = LF }+ "native" -> return opt { optEol = Native }+ -- mac-syntax (cr) is not supported in ghc-base.+ _ -> E.throwIO $ PandocOptionError+ "--eol must be crlf, lf, or native")+ "crlf|lf|native")+ "" -- "EOL (default OS-dependent)"++ , 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 "" ["columns"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t > 0 -> return opt { optColumns = t }+ _ -> E.throwIO $ PandocOptionError+ "columns must be a number greater than 0")+ "NUMBER")+ "" -- "Length of line in characters"++ , Option "" ["strip-comments"]+ (NoArg+ (\opt -> return opt { optStripComments = True }))+ "" -- "Strip HTML comments"++ , Option "" ["toc", "table-of-contents"]+ (NoArg+ (\opt -> return opt { optTableOfContents = True }))+ "" -- "Include table of contents"++ , Option "" ["toc-depth"]+ (ReqArg+ (\arg opt ->+ case safeRead 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")+ "NUMBER")+ "" -- "Number of levels to include in TOC"++ , Option "" ["no-highlight"]+ (NoArg+ (\opt -> return opt { optHighlightStyle = Nothing }))+ "" -- "Don't highlight source code"++ , Option "" ["highlight-style"]+ (ReqArg+ (\arg opt -> lookupHighlightStyle arg >>= \style ->+ return opt{ optHighlightStyle = style })+ "STYLE|FILE")+ "" -- "Style for highlighted code"++ , Option "" ["syntax-definition"]+ (ReqArg+ (\arg opt -> do+ let tr c d = map (\x -> if x == c then d else x)+ let arg' = case arg of -- see #4836+ -- HXT confuses Windows path with URI+ _:':':'\\':_ ->+ "file:///" ++ tr '\\' '/' arg+ _ -> arg+ return opt{ optSyntaxDefinitions = arg' :+ optSyntaxDefinitions opt })+ "FILE")+ "" -- "Syntax definition (xml) file"++ , Option "H" ["include-in-header"]+ (ReqArg+ (\arg opt -> return opt{ optIncludeInHeader =+ arg : optIncludeInHeader opt,+ optStandalone = True })+ "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 })+ "FILE")+ "" -- "File to include before document body"++ , Option "A" ["include-after-body"]+ (ReqArg+ (\arg opt -> return opt{ optIncludeAfterBody =+ arg : optIncludeAfterBody opt,+ optStandalone = True })+ "FILE")+ "" -- "File to include after document body"++ , Option "" ["resource-path"]+ (ReqArg+ (\arg opt -> return opt { optResourcePath =+ splitSearchPath arg })+ "SEARCHPATH")+ "" -- "Paths to search for images and other resources"++ , Option "" ["request-header"]+ (ReqArg+ (\arg opt -> do+ let (key, val) = splitField arg+ return opt{ optRequestHeaders =+ (key, val) : optRequestHeaders opt })+ "NAME:VALUE")+ ""++ , Option "" ["self-contained"]+ (NoArg+ (\opt -> return opt { optSelfContained = True,+ optStandalone = True }))+ "" -- "Make slide shows include all the needed js and css"++ , Option "" ["html-q-tags"]+ (NoArg+ (\opt ->+ return opt { optHtmlQTags = True }))+ "" -- "Use <q> tags for quotes in HTML"++ , Option "" ["ascii"]+ (NoArg+ (\opt -> return opt { optAscii = True }))+ "" -- "Prefer ASCII output"++ , Option "" ["reference-links"]+ (NoArg+ (\opt -> return opt { optReferenceLinks = True } ))+ "" -- "Use reference links in parsing HTML"++ , Option "" ["reference-location"]+ (ReqArg+ (\arg opt -> do+ action <- case arg of+ "block" -> return EndOfBlock+ "section" -> return EndOfSection+ "document" -> return EndOfDocument+ _ -> E.throwIO $ PandocOptionError+ ("Unknown option for reference-location: " ++ arg)+ return opt { optReferenceLocation = action })+ "block|section|document")+ "" -- "Accepting or reject MS Word track-changes.""++ , Option "" ["atx-headers"]+ (NoArg+ (\opt -> return opt { optSetextHeaders = False } ))+ "" -- "Use atx-style headers for markdown"++ , 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"))+ "section|chapter|part")+ "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"++ , Option "N" ["number-sections"]+ (NoArg+ (\opt -> return opt { optNumberSections = True }))+ "" -- "Number sections in LaTeX"++ , Option "" ["number-offset"]+ (ReqArg+ (\arg opt ->+ case safeRead ('[':arg ++ "]") of+ Just ns -> return opt { optNumberOffset = ns,+ optNumberSections = True }+ _ -> E.throwIO $ PandocOptionError+ "could not parse number-offset")+ "NUMBERS")+ "" -- "Starting number for sections, subsections, etc."++ , Option "" ["listings"]+ (NoArg+ (\opt -> return opt { optListings = True }))+ "" -- "Use listings package for LaTeX code blocks"++ , Option "i" ["incremental"]+ (NoArg+ (\opt -> return opt { optIncremental = True }))+ "" -- "Make list items display incrementally in Slidy/Slideous/S5"++ , Option "" ["slide-level"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t >= 1 && t <= 6 ->+ return opt { optSlideLevel = Just t }+ _ -> E.throwIO $ PandocOptionError+ "slide level must be a number between 1 and 6")+ "NUMBER")+ "" -- "Force header level for slides"++ , Option "" ["section-divs"]+ (NoArg+ (\opt -> return opt { optSectionDivs = True }))+ "" -- "Put sections in div tags in HTML"++ , Option "" ["default-image-extension"]+ (ReqArg+ (\arg opt -> return opt { optDefaultImageExtension = arg })+ "extension")+ "" -- "Default extension for extensionless images"++ , Option "" ["email-obfuscation"]+ (ReqArg+ (\arg opt -> do+ method <- case arg of+ "references" -> return ReferenceObfuscation+ "javascript" -> return JavascriptObfuscation+ "none" -> return NoObfuscation+ _ -> E.throwIO $ PandocOptionError+ ("Unknown obfuscation method: " ++ arg)+ return opt { optEmailObfuscation = method })+ "none|javascript|references")+ "" -- "Method for obfuscating email in HTML"++ , Option "" ["id-prefix"]+ (ReqArg+ (\arg opt -> return opt { optIdentifierPrefix = 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 })+ "STRING")+ "" -- "String to prefix to HTML window title"++ , Option "c" ["css"]+ (ReqArg+ (\arg opt -> return opt{ optCss = arg : optCss opt })+ -- add new link to end, so it is included in proper order+ "URL")+ "" -- "Link to CSS style sheet"++ , Option "" ["reference-doc"]+ (ReqArg+ (\arg opt ->+ return opt { optReferenceDoc = Just arg })+ "FILE")+ "" -- "Path of custom reference doc"++ , Option "" ["epub-subdirectory"]+ (ReqArg+ (\arg opt ->+ return opt { optEpubSubdirectory = arg })+ "DIRNAME")+ "" -- "Name of subdirectory for epub content in OCF container"++ , Option "" ["epub-cover-image"]+ (ReqArg+ (\arg opt ->+ return opt { optVariables =+ ("epub-cover-image", arg) : optVariables opt })+ "FILE")+ "" -- "Path of epub cover image"++ , Option "" ["epub-metadata"]+ (ReqArg+ (\arg opt -> return opt { optEpubMetadata = Just arg })+ "FILE")+ "" -- "Path of epub metadata file"++ , Option "" ["epub-embed-font"]+ (ReqArg+ (\arg opt ->+ return opt{ optEpubFonts = arg : optEpubFonts opt })+ "FILE")+ "" -- "Directory of fonts to embed"++ , Option "" ["epub-chapter-level"]+ (ReqArg+ (\arg opt ->+ case safeRead arg of+ Just t | t >= 1 && t <= 6 ->+ return opt { optEpubChapterLevel = t }+ _ -> E.throwIO $ PandocOptionError+ "chapter level must be a number between 1 and 6")+ "NUMBER")+ "" -- "Header level at which to split chapters in EPUB"++ , Option "" ["pdf-engine"]+ (ReqArg+ (\arg opt -> do+ let b = takeBaseName arg+ if b `elem` pdfEngines+ then return opt { optPdfEngine = Just arg }+ else E.throwIO $ PandocOptionError $ "pdf-engine must be one of "+ ++ intercalate ", " pdfEngines)+ "PROGRAM")+ "" -- "Name of program to use in generating PDF"++ , Option "" ["pdf-engine-opt"]+ (ReqArg+ (\arg opt -> do+ let oldArgs = optPdfEngineArgs opt+ return opt { optPdfEngineArgs = oldArgs ++ [arg]})+ "STRING")+ "" -- "Flags to pass to the PDF-engine, all instances of this option are accumulated and used"++ , Option "" ["bibliography"]+ (ReqArg+ (\arg opt -> return opt{ optMetadata =+ ("bibliography", arg) : optMetadata opt })+ "FILE")+ ""++ , Option "" ["csl"]+ (ReqArg+ (\arg opt ->+ return opt{ optMetadata =+ ("csl", arg) : optMetadata opt })+ "FILE")+ ""++ , Option "" ["citation-abbreviations"]+ (ReqArg+ (\arg opt ->+ return opt{ optMetadata =+ ("citation-abbreviations", arg): optMetadata opt })+ "FILE")+ ""++ , Option "" ["natbib"]+ (NoArg+ (\opt -> return opt { optCiteMethod = Natbib }))+ "" -- "Use natbib cite commands in LaTeX output"++ , Option "" ["biblatex"]+ (NoArg+ (\opt -> return opt { optCiteMethod = Biblatex }))+ "" -- "Use biblatex cite commands in LaTeX output"++ , Option "" ["mathml"]+ (NoArg+ (\opt ->+ return opt { optHTMLMathMethod = MathML }))+ "" -- "Use mathml for HTML math"++ , Option "" ["webtex"]+ (OptArg+ (\arg opt -> do+ let url' = fromMaybe "https://latex.codecogs.com/png.latex?" arg+ return opt { optHTMLMathMethod = WebTeX 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+ return opt { optHTMLMathMethod = MathJax url'})+ "URL")+ "" -- "Use MathJax for HTML math"++ , Option "" ["katex"]+ (OptArg+ (\arg opt ->+ return opt+ { optHTMLMathMethod = KaTeX $+ fromMaybe defaultKaTeXURL arg })+ "URL")+ "" -- Use KaTeX for HTML Math++ , Option "" ["gladtex"]+ (NoArg+ (\opt ->+ return opt { optHTMLMathMethod = GladTeX }))+ "" -- "Use gladtex for HTML math"++ , Option "" ["abbreviations"]+ (ReqArg+ (\arg opt -> return opt { optAbbreviations = Just arg })+ "FILE")+ "" -- "Specify file for custom abbreviations"++ , Option "" ["trace"]+ (NoArg+ (\opt -> return opt { optTrace = True }))+ "" -- "Turn on diagnostic tracing in readers."++ , Option "" ["dump-args"]+ (NoArg+ (\opt -> return opt { optDumpArgs = True }))+ "" -- "Print output filename and arguments to stdout."++ , Option "" ["ignore-args"]+ (NoArg+ (\opt -> return opt { optIgnoreArgs = True }))+ "" -- "Ignore command-line arguments."++ , Option "" ["verbose"]+ (NoArg+ (\opt -> return opt { optVerbosity = INFO }))+ "" -- "Verbose diagnostic output."++ , Option "" ["quiet"]+ (NoArg+ (\opt -> return opt { optVerbosity = ERROR }))+ "" -- "Suppress warnings."++ , Option "" ["fail-if-warnings"]+ (NoArg+ (\opt -> return opt { optFailIfWarnings = True }))+ "" -- "Exit with error status if there were warnings."++ , Option "" ["log"]+ (ReqArg+ (\arg opt -> return opt{ optLogFile = Just arg })+ "FILE")+ "" -- "Log messages in JSON format to this file."++ , Option "" ["bash-completion"]+ (NoArg+ (\_ -> do+ datafiles <- getDataFileNames+ tpl <- runIOorExplode $+ UTF8.toString <$>+ readDefaultDataFile "bash_completion.tpl"+ let optnames (Option shorts longs _ _) =+ map (\c -> ['-',c]) shorts +++ map ("--" ++) longs+ let allopts = unwords (concatMap optnames options)+ UTF8.hPutStrLn stdout $ printf tpl allopts+ (unwords readersNames)+ (unwords writersNames)+ (unwords $ map fst highlightingStyles)+ (unwords datafiles)+ exitSuccess ))+ "" -- "Print bash completion script"++ , Option "" ["list-input-formats"]+ (NoArg+ (\_ -> do+ mapM_ (UTF8.hPutStrLn stdout) readersNames+ exitSuccess ))+ ""++ , Option "" ["list-output-formats"]+ (NoArg+ (\_ -> do+ mapM_ (UTF8.hPutStrLn stdout) writersNames+ exitSuccess ))+ ""++ , 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)+ mapM_ (UTF8.hPutStrLn stdout . showExt)+ ([minBound..maxBound] :: [Extension])+ exitSuccess )+ "FORMAT")+ ""++ , Option "" ["list-highlight-languages"]+ (NoArg+ (\_ -> do+ let langs = [ T.unpack (T.toLower (sShortname s))+ | s <- M.elems defaultSyntaxMap+ , sShortname s `notElem`+ [T.pack "Alert", T.pack "Alert_indent"]+ ]+ mapM_ (UTF8.hPutStrLn stdout) langs+ exitSuccess ))+ ""++ , Option "" ["list-highlight-styles"]+ (NoArg+ (\_ -> do+ mapM_ (UTF8.hPutStrLn stdout . fst) highlightingStyles+ exitSuccess ))+ ""++ , Option "v" ["version"]+ (NoArg+ (\_ -> do+ prg <- getProgName+ defaultDatadir <- E.catch+ (getAppUserDataDirectory "pandoc")+ (\e -> let _ = (e :: E.SomeException)+ in return "")+ UTF8.hPutStrLn stdout (prg ++ " " ++ pandocVersion +++ compileInfo ++ "\nDefault user data directory: " +++ defaultDatadir ++ copyrightMessage)+ exitSuccess ))+ "" -- "Print version"++ , Option "h" ["help"]+ (NoArg+ (\_ -> do+ prg <- getProgName+ UTF8.hPutStr stdout (usageMessage prg options)+ exitSuccess ))+ "" -- "Show help"+ ]++getDataFileNames :: IO [FilePath]+getDataFileNames = do+#ifdef EMBED_DATA_FILES+ let allDataFiles = map fst dataFiles+#else+ allDataFiles <- filter (\x -> x /= "." && x /= "..") <$>+ (getDataDir >>= getDirectoryContents)+#endif+ return $ "reference.docx" : "reference.odt" : "reference.pptx" : allDataFiles++-- Returns usage message+usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String+usageMessage programName = usageInfo (programName ++ " [OPTIONS] [FILES]")++copyrightMessage :: String+copyrightMessage = intercalate "\n" [+ "",+ "Copyright (C) 2006-2018 John MacFarlane",+ "Web: http://pandoc.org",+ "This is free software; see the source for copying conditions.",+ "There is no warranty, not even for merchantability or fitness",+ "for a particular purpose." ]++compileInfo :: String+compileInfo =+ "\nCompiled with pandoc-types " ++ VERSION_pandoc_types ++ ", texmath " +++ VERSION_texmath ++ ", skylighting " ++ VERSION_skylighting++handleUnrecognizedOption :: String -> [String] -> [String]+handleUnrecognizedOption "--smart" =+ (("--smart/-S has been removed. Use +smart or -smart extension instead.\n" +++ "For example: pandoc -f markdown+smart -t markdown-smart.") :)+handleUnrecognizedOption "--normalize" =+ ("--normalize has been removed. Normalization is now automatic." :)+handleUnrecognizedOption "-S" = handleUnrecognizedOption "--smart"+handleUnrecognizedOption "--old-dashes" =+ ("--old-dashes has been removed. Use +old_dashes extension instead." :)+handleUnrecognizedOption "--no-wrap" =+ ("--no-wrap has been removed. Use --wrap=none instead." :)+handleUnrecognizedOption "--latex-engine" =+ ("--latex-engine has been removed. Use --pdf-engine instead." :)+handleUnrecognizedOption "--latex-engine-opt" =+ ("--latex-engine-opt has been removed. Use --pdf-engine-opt instead." :)+handleUnrecognizedOption "--chapters" =+ ("--chapters has been removed. Use --top-level-division=chapter instead." :)+handleUnrecognizedOption "--reference-docx" =+ ("--reference-docx has been removed. Use --reference-doc instead." :)+handleUnrecognizedOption "--reference-odt" =+ ("--reference-odt has been removed. Use --reference-doc instead." :)+handleUnrecognizedOption "--parse-raw" =+ ("--parse-raw/-R has been removed. Use +raw_html or +raw_tex extension.\n" :)+handleUnrecognizedOption "--epub-stylesheet" =+ ("--epub-stylesheet has been removed. Use --css instead.\n" :)+handleUnrecognizedOption "-R" = handleUnrecognizedOption "--parse-raw"+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)]))++writersNames :: [String]+writersNames = sort (map fst (writers :: [(String, Writer PandocIO)]))++splitField :: String -> (String, String)+splitField s =+ case break (`elem` ":=") s of+ (k,_:v) -> (k,v)+ (k,[]) -> (k,"true")++deprecatedOption :: String -> String -> IO ()+deprecatedOption o msg =+ runIO (report $ Deprecated o msg) >>=+ \r -> case r of+ Right () -> return ()+ Left e -> E.throwIO e++-- see https://github.com/jgm/pandoc/pull/4083+-- using generic deriving caused long compilation times+$(deriveJSON defaultOptions ''LineEnding)+$(deriveJSON defaultOptions ''Opt)
@@ -0,0 +1,317 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TupleSections #-}+{-+Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.App+ Copyright : Copyright (C) 2006-2018 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley@edu>+ Stability : alpha+ Portability : portable++Does a pandoc conversion based on command-line options.+-}+module Text.Pandoc.App.OutputSettings+ ( OutputSettings (..)+ , optToOutputSettings+ ) where+import Prelude+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.Maybe (fromMaybe)+import Skylighting (defaultSyntaxMap)+import Skylighting.Parser (addSyntaxDefinition, parseSyntaxDefinition)+import System.Exit (exitSuccess)+import System.FilePath+import System.IO (stdout)+import Text.Pandoc+import Text.Pandoc.App.CommandLineOptions (Opt (..), engines)+import Text.Pandoc.BCP47 (Lang (..), parseBCP47)+import qualified Text.Pandoc.UTF8 as UTF8++-- | Settings specifying how document output should be produced.+data OutputSettings = OutputSettings+ { outputFormat :: String+ , outputWriter :: Writer PandocIO+ , outputWriterName :: String+ , 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+ let outputFile = fromMaybe "-" (optOutputFile opts)++ when (optDumpArgs opts) . liftIO $ do+ UTF8.hPutStrLn stdout outputFile+ mapM_ (UTF8.hPutStrLn stdout) (optInputFiles opts)+ exitSuccess++ epubMetadata <- case optEpubMetadata opts of+ Nothing -> return Nothing+ Just fp -> Just <$> readUtf8File fp++ let nonPdfWriterName Nothing = defaultWriterName outputFile+ nonPdfWriterName (Just x) = x++ let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"+ (writerName, maybePdfProg) <-+ if pdfOutput+ then liftIO $ pdfWriterAndProg (optWriter opts) (optPdfEngine opts)+ else return (nonPdfWriterName $ optWriter opts, Nothing)++ let format = map toLower $ baseWriterName+ $ takeFileName writerName -- in case path to lua script++ -- disabling the custom writer for now+ (writer, writerExts) <-+ if ".lua" `isSuffixOf` format+ then return (TextWriter+ (\o d -> writeCustom 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)+++ 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+ 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++ let addContentsAsVariable varname fp vars = do+ s <- UTF8.toString <$> readFileStrict fp+ return $ (varname, s) : vars++ 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.+ >>=+ withList (addContentsAsVariable "include-before")+ (optIncludeBeforeBody opts)+ >>=+ withList (addContentsAsVariable "include-after")+ (optIncludeAfterBody opts)+ >>=+ withList (addContentsAsVariable "header-includes")+ (optIncludeInHeader opts)+ >>=+ withList (addStringAsVariable "css") (optCss opts)+ >>=+ maybe return (addStringAsVariable "title-prefix")+ (optTitlePrefix opts)+ >>=+ maybe return (addStringAsVariable "epub-cover-image")+ (optEpubCoverImage opts)+ >>=+ (\vars -> if format == "dzslides"+ then do+ dztempl <- UTF8.toString <$> readDataFile+ ("dzslides" </> "template.html")+ let dzline = "<!-- {{{{ dzslides core"+ let dzcore = unlines+ $ dropWhile (not . (dzline `isPrefixOf`))+ $ lines dztempl+ return $ ("dzslides-core", dzcore) : vars+ else return vars)++ templ <- 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+ Just . UTF8.toString <$>+ ((fst <$> fetchItem tp') `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 writerOpts = def {+ writerTemplate = templ+ , writerVariables = variables+ , writerTabStop = optTabStop opts+ , writerTableOfContents = optTableOfContents opts+ , writerHTMLMathMethod = optHTMLMathMethod opts+ , writerIncremental = optIncremental opts+ , writerCiteMethod = optCiteMethod opts+ , writerNumberSections = optNumberSections opts+ , writerNumberOffset = optNumberOffset opts+ , writerSectionDivs = optSectionDivs opts+ , writerExtensions = writerExts+ , writerReferenceLinks = optReferenceLinks opts+ , writerReferenceLocation = optReferenceLocation opts+ , writerDpi = optDpi opts+ , writerWrapText = optWrapText opts+ , writerColumns = optColumns opts+ , writerEmailObfuscation = optEmailObfuscation opts+ , writerIdentifierPrefix = optIdentifierPrefix opts+ , writerHtmlQTags = optHtmlQTags opts+ , writerTopLevelDivision = optTopLevelDivision opts+ , writerListings = optListings opts+ , writerSlideLevel = optSlideLevel opts+ , writerHighlightStyle = optHighlightStyle opts+ , writerSetextHeaders = optSetextHeaders opts+ , writerEpubSubdirectory = optEpubSubdirectory opts+ , writerEpubMetadata = epubMetadata+ , writerEpubFonts = optEpubFonts opts+ , writerEpubChapterLevel = optEpubChapterLevel opts+ , writerTOCDepth = optTOCDepth opts+ , writerReferenceDoc = optReferenceDoc opts+ , writerSyntaxMap = syntaxMap+ , writerPreferAscii = optAscii opts+ }+ return $ OutputSettings+ { outputFormat = format+ , outputWriter = writer+ , outputWriterName = writerName+ , outputWriterOptions = writerOpts+ , outputPdfProgram = maybePdfProg+ }++-- Determine default writer based on output file extension+defaultWriterName :: FilePath -> String+defaultWriterName "-" = "html" -- no output file+defaultWriterName x =+ case takeExtension (map toLower x) of+ "" -> "markdown" -- empty extension+ ".tex" -> "latex"+ ".latex" -> "latex"+ ".ltx" -> "latex"+ ".context" -> "context"+ ".ctx" -> "context"+ ".rtf" -> "rtf"+ ".rst" -> "rst"+ ".s5" -> "s5"+ ".native" -> "native"+ ".json" -> "json"+ ".txt" -> "markdown"+ ".text" -> "markdown"+ ".md" -> "markdown"+ ".muse" -> "muse"+ ".markdown" -> "markdown"+ ".textile" -> "textile"+ ".lhs" -> "markdown+lhs"+ ".texi" -> "texinfo"+ ".texinfo" -> "texinfo"+ ".db" -> "docbook"+ ".odt" -> "odt"+ ".docx" -> "docx"+ ".epub" -> "epub"+ ".org" -> "org"+ ".asciidoc" -> "asciidoc"+ ".adoc" -> "asciidoc"+ ".fb2" -> "fb2"+ ".opml" -> "opml"+ ".icml" -> "icml"+ ".tei.xml" -> "tei"+ ".tei" -> "tei"+ ".ms" -> "ms"+ ".roff" -> "ms"+ ".pptx" -> "pptx"+ ['.',y] | y `elem` ['1'..'9'] -> "man"+ _ -> "html"++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)."++pdfWriterAndProg :: Maybe String -- ^ 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+ case go mWriter mEngine of+ Right (writ, prog) -> return (writ, Just prog)+ Left err -> panErr err+ where+ go Nothing Nothing = Right ("latex", "pdflatex")+ go (Just writer) Nothing = (writer,) <$> engineForWriter writer+ go Nothing (Just engine) = (,engine) <$> writerForEngine (takeBaseName engine)+ 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++ writerForEngine eng = case [f | (f,e) <- engines, e == eng] of+ fmt : _ -> Right fmt+ [] -> Left $+ "pdf-engine " ++ eng ++ " not known"++ engineForWriter "pdf" = Left pdfIsNoWriterErrorMsg+ engineForWriter w = case [e | (f,e) <- engines, f == baseWriterName w] of+ eng : _ -> Right eng+ [] -> Left $+ "cannot produce pdf output from " ++ w++isTextFormat :: String -> Bool+isTextFormat s = s `notElem` ["odt","docx","epub2","epub3","epub","pptx"]
@@ -98,7 +98,6 @@ ) where import Prelude-import Prelude hiding (readFile) import System.Random (StdGen, next, mkStdGen) import qualified System.Random as IO (newStdGen) import Codec.Archive.Zip@@ -629,6 +628,7 @@ "_rels/.rels", "docProps/app.xml", "docProps/core.xml",+ "docProps/custom.xml", "word/document.xml", "word/fontTable.xml", "word/footnotes.xml",
@@ -1,6 +1,7 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE TemplateHaskell #-} {--Copyright (C) 2006-2017 John MacFarlane <jgm@berkeley.edu>+Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -16,11 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -}-{-# LANGUAGE TemplateHaskell #-}- {- | Module : Text.Pandoc.Filter- Copyright : Copyright (C) 2006-2017 John MacFarlane+ Copyright : Copyright (C) 2006-2018 John MacFarlane License : GNU GPL, version 2 or above Maintainer : John MacFarlane <jgm@berkeley@edu>@@ -43,20 +42,29 @@ import Text.Pandoc.Options (ReaderOptions) import qualified Text.Pandoc.Filter.JSON as JSONFilter import qualified Text.Pandoc.Filter.Lua as LuaFilter+import qualified Text.Pandoc.Filter.Path as Path +-- | Type of filter and path to filter file. data Filter = LuaFilter FilePath | JSONFilter FilePath deriving (Show) +-- | Modify the given document using a filter. applyFilters :: ReaderOptions -> [Filter] -> [String] -> Pandoc -> PandocIO Pandoc-applyFilters ropts filters args d =- foldrM ($) d $ map applyFilter filters+applyFilters ropts filters args d = do+ expandedFilters <- mapM expandFilterPath filters+ foldrM ($) d $ map applyFilter expandedFilters where applyFilter (JSONFilter f) = JSONFilter.apply ropts args f applyFilter (LuaFilter f) = LuaFilter.apply ropts args f++-- | 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 $(deriveJSON defaultOptions ''Filter)
@@ -44,7 +44,6 @@ import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Error (PandocError (PandocFilterError)) import Text.Pandoc.Definition (Pandoc)-import Text.Pandoc.Filter.Path (expandFilterPath) import Text.Pandoc.Options (ReaderOptions) import Text.Pandoc.Process (pipeProcess) import Text.Pandoc.Shared (pandocVersion)@@ -56,9 +55,7 @@ -> FilePath -> Pandoc -> PandocIO Pandoc-apply ropts args f d = do- f' <- expandFilterPath f- liftIO $ externalFilter ropts f' args d+apply ropts args f = liftIO . externalFilter ropts f args externalFilter :: MonadIO m => ReaderOptions -> FilePath -> [String] -> Pandoc -> m Pandoc
@@ -32,24 +32,34 @@ import Prelude import Control.Exception (throw)+import Control.Monad ((>=>)) import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition (Pandoc) import Text.Pandoc.Error (PandocError (PandocFilterError))-import Text.Pandoc.Filter.Path (expandFilterPath)-import Text.Pandoc.Lua (LuaException (..), runLuaFilter)+import Text.Pandoc.Lua (Global (..), LuaException (..),+ runLua, runFilterFile, setGlobals) import Text.Pandoc.Options (ReaderOptions) +-- | Run the Lua filter in @filterPath@ for a transformation to the+-- target format (first element in args). Pandoc uses Lua init files to+-- setup the Lua interpreter. apply :: ReaderOptions -> [String] -> FilePath -> Pandoc -> PandocIO Pandoc-apply ropts args f d = do- f' <- expandFilterPath f+apply ropts args fp doc = do let format = case args of (x:_) -> x- _ -> error "Format not supplied for lua filter"- res <- runLuaFilter ropts f' format d- case res of- Right x -> return x- Left (LuaException s) -> throw (PandocFilterError f s)+ _ -> error "Format not supplied for Lua filter"+ runLua >=> forceResult fp $ do+ setGlobals [ FORMAT format+ , PANDOC_READER_OPTIONS ropts+ , PANDOC_SCRIPT_FILE fp+ ]+ runFilterFile fp doc++forceResult :: FilePath -> Either LuaException Pandoc -> PandocIO Pandoc+forceResult fp eitherResult = case eitherResult of+ Right x -> return x+ Left (LuaException s) -> throw (PandocFilterError fp s)
@@ -292,7 +292,8 @@ "Extracting " ++ fp ++ "..." NoTitleElement fallback -> "This document format requires a nonempty <title> element.\n" ++- "Please specify either 'title' or 'pagetitle' in the metadata.\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 ++ "'" NoLangSpecified -> "No value for 'lang' was specified in the metadata.\n" ++
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {- Copyright © 2017–2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de> @@ -15,7 +16,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -}-{-# LANGUAGE NoImplicitPrelude #-} {- | Module : Text.Pandoc.Lua Copyright : Copyright © 2017–2018 Albert Krewinkel@@ -27,56 +27,17 @@ Running pandoc Lua filters. -} module Text.Pandoc.Lua- ( LuaException (..)- , runLuaFilter- , runPandocLua+ ( runLua+ , LuaException (..)+ -- * Lua globals+ , Global (..)+ , setGlobals+ -- * Filters+ , runFilterFile ) where -import Prelude-import Control.Monad ((>=>))-import Foreign.Lua (Lua)-import Text.Pandoc.Class (PandocIO)-import Text.Pandoc.Definition (Pandoc)-import Text.Pandoc.Lua.Filter (LuaFilter, walkMWithLuaFilter)-import Text.Pandoc.Lua.Init (LuaException (..), runPandocLua, registerScriptPath)-import Text.Pandoc.Options (ReaderOptions)--import qualified Foreign.Lua as Lua---- | Run the Lua filter in @filterPath@ for a transformation to target--- format @format@. Pandoc uses Lua init files to setup the Lua--- interpreter.-runLuaFilter :: ReaderOptions -> FilePath -> String- -> Pandoc -> PandocIO (Either LuaException Pandoc)-runLuaFilter ropts filterPath format doc =- runPandocLua (runLuaFilter' ropts filterPath format doc)--runLuaFilter' :: ReaderOptions -> FilePath -> String- -> Pandoc -> Lua Pandoc-runLuaFilter' ropts filterPath format pd = do- registerFormat- registerReaderOptions- registerScriptPath filterPath- top <- Lua.gettop- stat <- Lua.dofile filterPath- if stat /= Lua.OK- then Lua.throwTopMessage- else do- newtop <- Lua.gettop- -- Use the returned filters, or the implicitly defined global filter if- -- nothing was returned.- luaFilters <- if newtop - top >= 1- then Lua.peek Lua.stackTop- else Lua.pushglobaltable *> fmap (:[]) Lua.popValue- runAll luaFilters pd- where- registerFormat = do- Lua.push format- Lua.setglobal "FORMAT"-- registerReaderOptions = do- Lua.push ropts- Lua.setglobal "PANDOC_READER_OPTIONS"+import Text.Pandoc.Lua.Filter (runFilterFile)+import Text.Pandoc.Lua.Global (Global (..), setGlobals)+import Text.Pandoc.Lua.Init (LuaException (..), runLua)+import Text.Pandoc.Lua.StackInstances () -runAll :: [LuaFilter] -> Pandoc -> Lua Pandoc-runAll = foldr ((>=>) . walkMWithLuaFilter) return
@@ -30,6 +30,7 @@ -} module Text.Pandoc.Lua.Filter ( LuaFilterFunction , LuaFilter+ , runFilterFile , tryFilter , runFilterFunction , walkMWithLuaFilter@@ -52,7 +53,27 @@ import qualified Data.Map.Strict as Map import qualified Foreign.Lua as Lua+import qualified Text.Pandoc.Lua.Util as LuaUtil +-- | Transform document using the filter defined in the given file.+runFilterFile :: FilePath -> Pandoc -> Lua Pandoc+runFilterFile filterPath doc = do+ top <- Lua.gettop+ stat <- LuaUtil.dofileWithTraceback filterPath+ if stat /= Lua.OK+ then Lua.throwTopMessage+ else do+ newtop <- Lua.gettop+ -- Use the returned filters, or the implicitly defined global+ -- filter if nothing was returned.+ luaFilters <- if newtop - top >= 1+ then Lua.peek Lua.stackTop+ else Lua.pushglobaltable *> fmap (:[]) Lua.popValue+ runAll luaFilters doc++runAll :: [LuaFilter] -> Pandoc -> Lua Pandoc+runAll = foldr ((>=>) . walkMWithLuaFilter) return+ -- | Filter function stored in the registry newtype LuaFilterFunction = LuaFilterFunction Lua.Reference @@ -118,11 +139,9 @@ -- element is left unchanged. runFilterFunction :: Pushable a => LuaFilterFunction -> a -> Lua () runFilterFunction lf x = do- let errorPrefix = "Error while running filter function:\n"- Lua.withExceptionMessage (errorPrefix <>) $ do- pushFilterFunction lf- Lua.push x- Lua.call 1 1+ pushFilterFunction lf+ Lua.push x+ LuaUtil.callWithTraceback 1 1 walkMWithLuaFilter :: LuaFilter -> Pandoc -> Lua Pandoc walkMWithLuaFilter f =
@@ -0,0 +1,108 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-+Copyright © 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}+{- |+ Module : Text.Pandoc.Lua+ Copyright : Copyright © 2017-2018 Albert Krewinkel+ License : GNU GPL, version 2 or above++ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>+ Stability : alpha++Pandoc's Lua globals.+-}+module Text.Pandoc.Lua.Global+ ( Global (..)+ , setGlobals+ ) where++import Prelude+import Data.Data (Data)+import Data.Version (Version (versionBranch))+import Foreign.Lua (Lua, Peekable, Pushable)+import Foreign.Lua.Userdata ( ensureUserdataMetatable, pushAnyWithMetatable+ , metatableName)+import Paths_pandoc (version)+import Text.Pandoc.Class (CommonState)+import Text.Pandoc.Definition (Pandoc (Pandoc), pandocTypesVersion)+import Text.Pandoc.Lua.StackInstances ()+import Text.Pandoc.Lua.Util (addFunction)+import Text.Pandoc.Options (ReaderOptions)++import qualified Foreign.Lua as Lua++-- | Permissible global Lua variables.+data Global =+ FORMAT String+ | PANDOC_API_VERSION+ | PANDOC_DOCUMENT Pandoc+ | PANDOC_READER_OPTIONS ReaderOptions+ | PANDOC_SCRIPT_FILE FilePath+ | PANDOC_STATE CommonState+ | PANDOC_VERSION+ -- Cannot derive instance of Data because of CommonState++-- | Set all given globals.+setGlobals :: [Global] -> Lua ()+setGlobals = mapM_ setGlobal++setGlobal :: Global -> Lua ()+setGlobal global = case global of+ -- This could be simplified if Global was an instance of Data.+ FORMAT format -> do+ Lua.push format+ Lua.setglobal "FORMAT"+ PANDOC_API_VERSION -> do+ Lua.push (versionBranch pandocTypesVersion)+ Lua.setglobal "PANDOC_API_VERSION"+ PANDOC_DOCUMENT doc -> do+ Lua.push (LazyPandoc doc)+ Lua.setglobal "PANDOC_DOCUMENT"+ PANDOC_READER_OPTIONS ropts -> do+ Lua.push ropts+ Lua.setglobal "PANDOC_READER_OPTIONS"+ PANDOC_SCRIPT_FILE filePath -> do+ Lua.push filePath+ Lua.setglobal "PANDOC_SCRIPT_FILE"+ PANDOC_STATE commonState -> do+ Lua.push commonState+ Lua.setglobal "PANDOC_STATE"+ PANDOC_VERSION -> do+ Lua.push (versionBranch version)+ Lua.setglobal "PANDOC_VERSION"++-- | Readonly and lazy pandoc objects.+newtype LazyPandoc = LazyPandoc Pandoc+ deriving (Data)++instance Pushable LazyPandoc where+ push lazyDoc = pushAnyWithMetatable pushPandocMetatable lazyDoc+ where+ pushPandocMetatable = ensureUserdataMetatable (metatableName lazyDoc) $+ addFunction "__index" indexLazyPandoc++instance Peekable LazyPandoc where+ peek = Lua.peekAny++indexLazyPandoc :: LazyPandoc -> String -> Lua Lua.NumResults+indexLazyPandoc (LazyPandoc (Pandoc meta blks)) field = 1 <$+ case field of+ "blocks" -> Lua.push blks+ "meta" -> Lua.push meta+ _ -> Lua.pushnil
@@ -29,23 +29,19 @@ module Text.Pandoc.Lua.Init ( LuaException (..) , LuaPackageParams (..)- , runPandocLua- , initLuaState+ , runLua , luaPackageParams- , registerScriptPath ) where import Prelude import Control.Monad.Trans (MonadIO (..)) import Data.Data (Data, dataTypeConstrs, dataTypeOf, showConstr) import Data.IORef (newIORef, readIORef)-import Data.Version (Version (versionBranch)) import Foreign.Lua (Lua) import GHC.IO.Encoding (getForeignEncoding, setForeignEncoding, utf8)-import Paths_pandoc (version)-import Text.Pandoc.Class (PandocIO, getCommonState, getUserDataDir, getMediaBag,- setMediaBag)-import Text.Pandoc.Definition (pandocTypesVersion)+import Text.Pandoc.Class (PandocIO, getCommonState, getUserDataDir,+ getMediaBag, setMediaBag)+import Text.Pandoc.Lua.Global (Global (..), setGlobals) import Text.Pandoc.Lua.Packages (LuaPackageParams (..), installPandocPackageSearcher) import Text.Pandoc.Lua.Util (loadScriptFromDataDir)@@ -59,11 +55,15 @@ -- | Run the lua interpreter, using pandoc's default way of environment -- initialization.-runPandocLua :: Lua a -> PandocIO (Either LuaException a)-runPandocLua luaOp = do+runLua :: Lua a -> PandocIO (Either LuaException a)+runLua luaOp = do luaPkgParams <- luaPackageParams+ globals <- defaultGlobals enc <- liftIO $ getForeignEncoding <* setForeignEncoding utf8- res <- liftIO $ Lua.runEither (initLuaState luaPkgParams *> luaOp)+ res <- liftIO . Lua.runEither $ do+ setGlobals globals+ initLuaState luaPkgParams+ luaOp liftIO $ setForeignEncoding enc newMediaBag <- liftIO (readIORef (luaPkgMediaBag luaPkgParams)) setMediaBag newMediaBag@@ -71,6 +71,16 @@ Left (Lua.Exception msg) -> Left (LuaException msg) Right x -> Right x +-- | Global variables which should always be set.+defaultGlobals :: PandocIO [Global]+defaultGlobals = do+ commonState <- getCommonState+ return+ [ PANDOC_API_VERSION+ , PANDOC_STATE commonState+ , PANDOC_VERSION+ ]+ -- | Generate parameters required to setup pandoc's lua environment. luaPackageParams :: PandocIO LuaPackageParams luaPackageParams = do@@ -83,24 +93,15 @@ , luaPkgMediaBag = mbRef } --- Initialize the lua state with all required values+-- | Initialize the lua state with all required values initLuaState :: LuaPackageParams -> Lua () initLuaState luaPkgParams = do Lua.openlibs Lua.preloadTextModule "text"- Lua.push (versionBranch version)- Lua.setglobal "PANDOC_VERSION"- Lua.push (versionBranch pandocTypesVersion)- Lua.setglobal "PANDOC_API_VERSION" installPandocPackageSearcher luaPkgParams loadScriptFromDataDir (luaPkgDataDir luaPkgParams) "init.lua" putConstructorsInRegistry -registerScriptPath :: FilePath -> Lua ()-registerScriptPath fp = do- Lua.push fp- Lua.setglobal "PANDOC_SCRIPT_FILE"- putConstructorsInRegistry :: Lua () putConstructorsInRegistry = do Lua.getglobal "pandoc"@@ -111,6 +112,7 @@ constrsToReg $ Pandoc.MetaList mempty constrsToReg $ Pandoc.Citation mempty mempty mempty Pandoc.AuthorInText 0 0 putInReg "Attr" -- used for Attr type alias+ putInReg "ListAttributes" -- used for ListAttributes type alias Lua.pop 1 where constrsToReg :: Data a => a -> Lua ()
@@ -1,3 +1,8 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE LambdaCase #-}+{-# OPTIONS_GHC -fno-warn-orphans #-} {- Copyright © 2012-2018 John MacFarlane <jgm@berkeley.edu> 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>@@ -16,11 +21,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE NoImplicitPrelude #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# OPTIONS_GHC -fno-warn-orphans #-} {- | Module : Text.Pandoc.Lua.StackInstances Copyright : © 2012-2018 John MacFarlane@@ -36,15 +36,20 @@ import Prelude import Control.Applicative ((<|>))-import Control.Monad (when) import Data.Data (showConstr, toConstr) import Foreign.Lua (Lua, Peekable, Pushable, StackIndex)+import Foreign.Lua.Types.Peekable (reportValueOnFailure)+import Foreign.Lua.Userdata ( ensureUserdataMetatable, pushAnyWithMetatable+ , toAnyWithName, metatableName)+import Text.Pandoc.Class (CommonState (..)) import Text.Pandoc.Definition import Text.Pandoc.Extensions (Extensions)+import Text.Pandoc.Logging (LogMessage, showLogMessage) import Text.Pandoc.Lua.Util (defineHowTo, pushViaConstructor) import Text.Pandoc.Options (ReaderOptions (..), TrackChanges) import Text.Pandoc.Shared (Element (Blk, Sec)) +import qualified Data.Map as Map import qualified Data.Set as Set import qualified Foreign.Lua as Lua import qualified Text.Pandoc.Lua.Util as LuaUtil@@ -185,7 +190,8 @@ Header lvl attr inlns -> pushViaConstructor "Header" lvl inlns (LuaAttr attr) HorizontalRule -> pushViaConstructor "HorizontalRule" LineBlock blcks -> pushViaConstructor "LineBlock" blcks- OrderedList lstAttr list -> pushViaConstructor "OrderedList" list lstAttr+ OrderedList lstAttr list -> pushViaConstructor "OrderedList" list+ (LuaListAttributes lstAttr) Null -> pushViaConstructor "Null" Para blcks -> pushViaConstructor "Para" blcks Plain blcks -> pushViaConstructor "Plain" blcks@@ -207,7 +213,9 @@ <$> elementContent "HorizontalRule" -> return HorizontalRule "LineBlock" -> LineBlock <$> elementContent- "OrderedList" -> uncurry OrderedList <$> elementContent+ "OrderedList" -> (\(LuaListAttributes lstAttr, lst) ->+ OrderedList lstAttr lst)+ <$> elementContent "Null" -> return Null "Para" -> Para <$> elementContent "Plain" -> Plain <$> elementContent@@ -289,31 +297,46 @@ instance Peekable LuaAttr where peek idx = defineHowTo "get Attr value" (LuaAttr <$> Lua.peek idx) +-- | Wrapper for ListAttributes+newtype LuaListAttributes = LuaListAttributes ListAttributes++instance Pushable LuaListAttributes where+ push (LuaListAttributes (start, style, delimiter)) =+ pushViaConstructor "ListAttributes" start style delimiter++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 lvl num attr label contents) = do- Lua.newtable- LuaUtil.addField "level" lvl- LuaUtil.addField "numbering" num- LuaUtil.addField "attr" (LuaAttr attr)- LuaUtil.addField "label" label- LuaUtil.addField "contents" contents- pushSecMetaTable- Lua.setmetatable (-2)- where- pushSecMetaTable :: Lua ()- pushSecMetaTable = do- inexistant <- Lua.newmetatable "PandocElementSec"- when inexistant $ do- LuaUtil.addField "t" "Sec"- Lua.push "__index"- Lua.pushvalue (-2)- Lua.rawset (-3)+ 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++ -- -- Reader Options --@@ -340,9 +363,112 @@ LuaUtil.addField "extensions" extensions LuaUtil.addField "standalone" standalone LuaUtil.addField "columns" columns- LuaUtil.addField "tabStop" tabStop- LuaUtil.addField "indentedCodeClasses" indentedCodeClasses+ LuaUtil.addField "tab_stop" tabStop+ LuaUtil.addField "indented_code_classes" indentedCodeClasses LuaUtil.addField "abbreviations" abbreviations- LuaUtil.addField "defaultImageExtension" defaultImageExtension- LuaUtil.addField "trackChanges" trackChanges- LuaUtil.addField "stripComments" stripComments+ LuaUtil.addField "default_image_extension" defaultImageExtension+ LuaUtil.addField "track_changes" trackChanges+ LuaUtil.addField "strip_comments" stripComments++ -- add metatable+ let indexReaderOptions :: AnyValue -> AnyValue -> Lua Lua.NumResults+ indexReaderOptions _tbl (AnyValue key) = do+ Lua.ltype key >>= \case+ Lua.TypeString -> Lua.peek key >>= \case+ "defaultImageExtension" -> Lua.push defaultImageExtension+ "indentedCodeClasses" -> Lua.push indentedCodeClasses+ "stripComments" -> Lua.push stripComments+ "tabStop" -> Lua.push tabStop+ "trackChanges" -> Lua.push trackChanges+ _ -> Lua.pushnil+ _ -> Lua.pushnil+ return 1+ Lua.newtable+ LuaUtil.addFunction "__index" indexReaderOptions+ Lua.setmetatable (Lua.nthFromTop 2)++-- | Dummy type to allow values of arbitrary Lua type.+newtype AnyValue = AnyValue StackIndex++--+-- TODO: Much of the following should be abstracted, factored out+-- and go into HsLua.+--++instance Peekable AnyValue where+ peek = return . AnyValue++-- | Name used by Lua for the @CommonState@ type.+commonStateTypeName :: String+commonStateTypeName = "Pandoc CommonState"++instance Peekable CommonState where+ peek idx = reportValueOnFailure commonStateTypeName+ (`toAnyWithName` commonStateTypeName) idx++instance Pushable CommonState where+ push st = pushAnyWithMetatable pushCommonStateMetatable st+ where+ pushCommonStateMetatable = ensureUserdataMetatable commonStateTypeName $ do+ LuaUtil.addFunction "__index" indexCommonState+ LuaUtil.addFunction "__pairs" pairsCommonState++indexCommonState :: CommonState -> AnyValue -> Lua Lua.NumResults+indexCommonState st (AnyValue idx) = Lua.ltype idx >>= \case+ Lua.TypeString -> 1 <$ (Lua.peek idx >>= pushField)+ _ -> 1 <$ Lua.pushnil+ where+ pushField :: String -> Lua ()+ pushField name = case lookup name commonStateFields of+ Just pushValue -> pushValue st+ Nothing -> Lua.pushnil++pairsCommonState :: CommonState -> Lua Lua.NumResults+pairsCommonState st = do+ Lua.pushHaskellFunction nextFn+ Lua.pushnil+ Lua.pushnil+ return 3+ where+ nextFn :: AnyValue -> AnyValue -> Lua Lua.NumResults+ nextFn _ (AnyValue idx) =+ Lua.ltype idx >>= \case+ Lua.TypeNil -> case commonStateFields of+ [] -> 2 <$ (Lua.pushnil *> Lua.pushnil)+ (key, pushValue):_ -> 2 <$ (Lua.push key *> pushValue st)+ Lua.TypeString -> do+ key <- Lua.peek idx+ case tail $ dropWhile ((/= key) . fst) commonStateFields of+ [] -> 2 <$ (Lua.pushnil *> Lua.pushnil)+ (nextKey, pushValue):_ -> 2 <$ (Lua.push nextKey *> pushValue st)+ _ -> 2 <$ (Lua.pushnil *> Lua.pushnil)++commonStateFields :: [(String, CommonState -> Lua ())]+commonStateFields =+ [ ("input_files", Lua.push . stInputFiles)+ , ("output_file", Lua.push . Lua.Optional . stOutputFile)+ , ("log", Lua.push . stLog)+ , ("request_headers", Lua.push . Map.fromList . stRequestHeaders)+ , ("resource_path", Lua.push . stResourcePath)+ , ("source_url", Lua.push . Lua.Optional . stSourceURL)+ , ("user_data_dir", Lua.push . Lua.Optional . stUserDataDir)+ , ("trace", Lua.push . stTrace)+ , ("verbosity", Lua.push . show . stVerbosity)+ ]++-- | Name used by Lua for the @CommonState@ type.+logMessageTypeName :: String+logMessageTypeName = "Pandoc LogMessage"++instance Peekable LogMessage where+ peek idx = reportValueOnFailure logMessageTypeName+ (`toAnyWithName` logMessageTypeName) idx++instance Pushable LogMessage where+ push msg = pushAnyWithMetatable pushLogMessageMetatable msg+ where+ pushLogMessageMetatable = ensureUserdataMetatable logMessageTypeName $+ LuaUtil.addFunction "__tostring" tostringLogMessage++tostringLogMessage :: LogMessage -> Lua String+tostringLogMessage = return . showLogMessage
@@ -40,12 +40,14 @@ , loadScriptFromDataDir , defineHowTo , throwTopMessageAsError'+ , callWithTraceback+ , dofileWithTraceback ) where import Prelude import Control.Monad (unless, when)-import Foreign.Lua ( Lua, NumArgs, Peekable, Pushable, StackIndex- , ToHaskellFunction )+import Foreign.Lua ( Lua, NumArgs, NumResults, Peekable, Pushable, StackIndex+ , Status, ToHaskellFunction ) import Text.Pandoc.Class (readDataFile, runIOorExplode, setUserDataDir) import qualified Foreign.Lua as Lua@@ -134,6 +136,38 @@ Lua.pop 2 -- remove error and error string pushed by tostring' Lua.throwException (modifier (UTF8.toString msg)) -+-- | Mark the context of a Lua computation for better error reporting. defineHowTo :: String -> Lua a -> Lua a defineHowTo ctx = Lua.withExceptionMessage (("Could not " <> ctx <> ": ") <>)++-- | Like @'Lua.pcall'@, but uses a predefined error handler which adds a+-- traceback on error.+pcallWithTraceback :: NumArgs -> NumResults -> Lua Status+pcallWithTraceback nargs nresults = do+ let traceback' :: Lua NumResults+ traceback' = do+ l <- Lua.state+ msg <- Lua.tostring' (Lua.nthFromBottom 1)+ Lua.traceback l (Just (UTF8.toString msg)) 2+ return 1+ tracebackIdx <- Lua.absindex (Lua.nthFromTop (Lua.fromNumArgs nargs + 1))+ Lua.pushHaskellFunction traceback'+ Lua.insert tracebackIdx+ result <- Lua.pcall nargs nresults (Just tracebackIdx)+ Lua.remove tracebackIdx+ return result++-- | Like @'Lua.call'@, but adds a traceback to the error message (if any).+callWithTraceback :: NumArgs -> NumResults -> Lua ()+callWithTraceback nargs nresults = do+ result <- pcallWithTraceback nargs nresults+ when (result /= Lua.OK) Lua.throwTopMessage++-- | Run the given string as a Lua program, while also adding a traceback to the+-- error message if an error occurs.+dofileWithTraceback :: FilePath -> Lua Status+dofileWithTraceback fp = do+ loadRes <- Lua.loadfile fp+ case loadRes of+ Lua.OK -> pcallWithTraceback 0 Lua.multret+ _ -> return loadRes
@@ -194,6 +194,7 @@ , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified , writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown , writerSyntaxMap :: SyntaxMap+ , writerPreferAscii :: Bool -- ^ Prefer ASCII representations of characters when possible } deriving (Show, Data, Typeable, Generic) instance Default WriterOptions where@@ -228,6 +229,7 @@ , writerReferenceDoc = Nothing , writerReferenceLocation = EndOfDocument , writerSyntaxMap = defaultSyntaxMap+ , writerPreferAscii = False } instance HasSyntaxExtensions WriterOptions where
@@ -199,13 +199,14 @@ import Prelude import Control.Monad.Identity import Control.Monad.Reader-import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isHexDigit,+import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isPunctuation, isSpace, ord, toLower, toUpper) import Data.Default import Data.List (intercalate, isSuffixOf, 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 Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Asciify (toAsciiChar)@@ -397,7 +398,7 @@ -- | Parses a nonspace, nonnewline character. nonspaceChar :: Stream s m Char => ParserT s st m Char-nonspaceChar = satisfy $ flip notElem ['\t', '\n', ' ', '\r']+nonspaceChar = noneOf ['\t', '\n', ' ', '\r'] -- | Skips zero or more spaces or tabs. skipSpaces :: Stream s m Char => ParserT s st m ()@@ -458,15 +459,15 @@ return (firstChar:rest) -- | Parse contents of 'str' using 'parser' and return result.-parseFromString :: Monad m- => ParserT [Char] st m a+parseFromString :: (Monad m, Stream s m Char, IsString s)+ => ParserT s st m r -> String- -> ParserT [Char] st m a+ -> ParserT s st m r parseFromString parser str = do oldPos <- getPosition setPosition $ initialPos "chunk" oldInput <- getInput- setInput str+ setInput $ fromString str result <- parser spaces eof@@ -476,10 +477,10 @@ -- | Like 'parseFromString' but specialized for 'ParserState'. -- This resets 'stateLastStrPos', which is almost always what we want.-parseFromString' :: Monad m- => ParserT String ParserState m a+parseFromString' :: (Monad m, Stream s m Char, IsString s)+ => ParserT s ParserState m a -> String- -> ParserT String ParserState m a+ -> ParserT s ParserState m a parseFromString' parser str = do oldStrPos <- stateLastStrPos <$> getState res <- parseFromString parser str@@ -533,11 +534,11 @@ fourhundreds <- option 0 $ try $ hundred >> fivehundred >> return 400 hundreds <- ((100 *) . length) <$> many hundred nineties <- option 0 $ try $ ten >> hundred >> return 90- fifties <- option 0 $ (50 <$ fifty)+ fifties <- option 0 (50 <$ fifty) forties <- option 0 $ try $ ten >> fifty >> return 40 tens <- ((10 *) . length) <$> many ten nines <- option 0 $ try $ one >> ten >> return 9- fives <- option 0 $ (5 <$ five)+ fives <- option 0 (5 <$ five) fours <- option 0 $ try $ one >> five >> return 4 ones <- length <$> many one let total = thousands + ninehundreds + fivehundreds + fourhundreds +@@ -579,7 +580,7 @@ uriScheme = oneOfStringsCI (Set.toList schemes) -- | Parses a URI. Returns pair of original and URI-escaped version.-uri :: Monad m => ParserT [Char] st m (String, String)+uri :: Stream s m Char => ParserT s st m (String, String) uri = try $ do scheme <- uriScheme char ':'@@ -590,25 +591,24 @@ -- 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.- let isWordChar c = isAlphaNum c || c `elem` "#$%+/@\\_-&="- let wordChar = satisfy isWordChar- let percentEscaped = try $ char '%' >> skipMany1 (satisfy isHexDigit)- let entity = () <$ characterReference- let punct = skipMany1 (char ',')- <|> () <$ satisfy (\c -> not (isSpace c) && c /= '<' && c /= '>')- let uriChunk = skipMany1 wordChar- <|> percentEscaped- <|> entity- <|> try (punct >>- lookAhead (void (satisfy isWordChar) <|> percentEscaped))- str <- snd <$> withRaw (skipMany1 ( () <$- (enclosed (char '(') (char ')') uriChunk- <|> enclosed (char '{') (char '}') uriChunk- <|> enclosed (char '[') (char ']') uriChunk)- <|> uriChunk))+ str <- concat <$> many1 (uriChunkBetween '(' ')'+ <|> uriChunkBetween '{' '}'+ <|> uriChunkBetween '[' ']'+ <|> uriChunk) str' <- option str $ char '/' >> return (str ++ "/") let uri' = scheme ++ ":" ++ fromEntities str' return (uri', escapeURI uri')+ where+ wordChar = alphaNum <|> oneOf "#$%+/@\\_-&="+ percentEscaped = try $ (:) <$> char '%' <*> many1 hexDigit+ entity = try $ pure <$> characterReference+ punct = try $ many1 (char ',') <|> fmap pure (satisfy (\c -> not (isSpace c) && c /= '<' && c /= '>'))+ uriChunk = many1 wordChar+ <|> percentEscaped+ <|> entity+ <|> try (punct <* lookAhead (void wordChar <|> void percentEscaped))+ uriChunkBetween l r = try $ do chunk <- between (char l) (char r) uriChunk+ return ([l] ++ chunk ++ [r]) mathInlineWith :: Stream s m Char => String -> String -> ParserT s st m String mathInlineWith op cl = try $ do@@ -627,7 +627,7 @@ return " " ) (try $ string cl) notFollowedBy digit -- to prevent capture of $5- return $ trim $ concat words'+ return $ trimMath $ concat words' where inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String inBalancedBraces 0 "" = do@@ -931,20 +931,20 @@ -- (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 :: (Monad m, HasReaderOptions st,- Functor mf, Applicative mf, Monad mf)- => ParserT [Char] st m (mf Blocks) -- ^ Block list parser- -> Bool -- ^ Headerless table- -> ParserT [Char] st m (mf Blocks)+gridTableWith :: (Stream s m Char, HasReaderOptions st,+ Functor mf, Applicative mf, Monad mf, IsString s)+ => ParserT s st m (mf Blocks) -- ^ Block list parser+ -> Bool -- ^ Headerless table+ -> ParserT s st m (mf Blocks) gridTableWith blocks headless = tableWith (gridTableHeader headless blocks) (gridTableRow blocks) (gridTableSep '-') gridTableFooter -gridTableWith' :: (Monad m, HasReaderOptions st,- Functor mf, Applicative mf, Monad mf)- => ParserT [Char] st m (mf Blocks) -- ^ Block list parser- -> Bool -- ^ Headerless table- -> ParserT [Char] st m (TableComponents mf)+gridTableWith' :: (Stream s m Char, HasReaderOptions st,+ Functor mf, Applicative mf, Monad mf, IsString s)+ => ParserT s st m (mf Blocks) -- ^ Block list parser+ -> Bool -- ^ Headerless table+ -> ParserT s st m (TableComponents mf) gridTableWith' blocks headless = tableWith' (gridTableHeader headless blocks) (gridTableRow blocks) (gridTableSep '-') gridTableFooter@@ -980,10 +980,11 @@ gridTableSep ch = try $ gridDashedLines ch >> return '\n' -- | Parse header for a grid table.-gridTableHeader :: (Monad m, Functor mf, Applicative mf, Monad mf)+gridTableHeader :: (Stream s m Char, Functor mf, Applicative mf, Monad mf,+ IsString s) => Bool -- ^ Headerless table- -> ParserT [Char] st m (mf Blocks)- -> ParserT [Char] st m (mf [Blocks], [Alignment], [Int])+ -> ParserT s st m (mf Blocks)+ -> ParserT s st m (mf [Blocks], [Alignment], [Int]) gridTableHeader headless blocks = try $ do optional blanklines dashes <- gridDashedLines '-'@@ -1013,10 +1014,11 @@ return (gridTableSplitLine indices line) -- | Parse row of grid table.-gridTableRow :: (Monad m, Functor mf, Applicative mf, Monad mf)- => ParserT [Char] st m (mf Blocks)+gridTableRow :: (Stream s m Char, Functor mf, Applicative mf, Monad mf,+ IsString s)+ => ParserT s st m (mf Blocks) -> [Int]- -> ParserT [Char] st m (mf [Blocks])+ -> ParserT s st m (mf [Blocks]) gridTableRow blocks indices = do colLines <- many1 (gridTableRawLine indices) let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $@@ -1042,14 +1044,13 @@ --- -- | Removes the ParsecT layer from the monad transformer stack-readWithM :: Monad m- => ParserT [Char] st m a -- ^ parser- -> st -- ^ initial state- -> String -- ^ input+readWithM :: (Monad m, Stream s m Char, ToString s)+ => ParserT s st m a -- ^ parser+ -> st -- ^ initial state+ -> s -- ^ input -> m (Either PandocError a) readWithM parser state input =- mapLeft (PandocParsecError input) `liftM` runParserT parser state "source" input-+ mapLeft (PandocParsecError $ toString input) `liftM` runParserT parser state "source" input -- | Parse a string with a given parser and state readWith :: Parser [Char] st a@@ -1331,18 +1332,16 @@ singleQuoted :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char) => ParserT s st m Inlines -> ParserT s st m Inlines-singleQuoted inlineParser = try $ do- singleQuoteStart- withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=- return . B.singleQuoted . mconcat+singleQuoted inlineParser = try $ B.singleQuoted . mconcat+ <$ singleQuoteStart+ <*> withQuoteContext InSingleQuote (many1Till inlineParser singleQuoteEnd) doubleQuoted :: (HasQuoteContext st m, Stream s m Char) => ParserT s st m Inlines -> ParserT s st m Inlines-doubleQuoted inlineParser = try $ do- doubleQuoteStart- withQuoteContext InDoubleQuote $ manyTill inlineParser doubleQuoteEnd >>=- return . B.doubleQuoted . mconcat+doubleQuoted inlineParser = try $ B.doubleQuoted . mconcat+ <$ doubleQuoteStart+ <*> withQuoteContext InDoubleQuote (manyTill inlineParser doubleQuoteEnd) failIfInQuoteContext :: (HasQuoteContext st m, Stream s m t) => QuoteContext@@ -1419,7 +1418,7 @@ => ParserT s st m (Bool, String) citeKey = try $ do guard =<< notAfterString- suppress_author <- option False (char '-' *> return True)+ suppress_author <- option False (True <$ char '-') char '@' firstChar <- alphaNum <|> char '_' <|> char '*' -- @* for wildcard in nocite let regchar = satisfy (\c -> isAlphaNum c || c == '_')
@@ -432,15 +432,13 @@ 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 groff man.+-- 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 = case map realLength . lines . render Nothing $ d of- [] -> 0- os -> maximum os+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
@@ -105,6 +105,7 @@ import Text.Pandoc.Readers.TWiki import Text.Pandoc.Readers.Txt2Tags import Text.Pandoc.Readers.Vimwiki+import Text.Pandoc.Readers.Man import Text.Pandoc.Shared (mapLeft) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Parsec.Error@@ -145,6 +146,7 @@ ,("t2t" , TextReader readTxt2Tags) ,("epub" , ByteStringReader readEPUB) ,("muse" , TextReader readMuse)+ ,("man" , TextReader readMan) ,("fb2" , TextReader readFB2) ]
@@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-} {- Copyright (C) 2017 Sascha Wilde <wilde@sha-bang.de> @@ -41,7 +42,6 @@ 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@@ -56,13 +56,12 @@ -> Text -> m Pandoc readCreole opts s = do- res <- readWithM parseCreole def{ stateOptions = opts }- (T.unpack (crFilter s) ++ "\n\n")+ res <- readWithM parseCreole def{ stateOptions = opts } $ crFilter s <> "\n\n" case res of Left e -> throwError e Right d -> return d -type CRLParser = ParserT [Char] ParserState+type CRLParser = ParserT Text ParserState -- -- Utility functions
@@ -1056,8 +1056,10 @@ | Just rPr <- findChildByName ns "w" "rPr" element = RunStyle {- isBold = checkOnOff ns rPr (elemName ns "w" "b")- , isItalic = checkOnOff ns rPr (elemName ns "w" "i")+ 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") , rVertAlign =
@@ -1069,11 +1069,11 @@ getTagName _ = Nothing isInlineTag :: NamedTag (Tag a) => Tag a -> Bool-isInlineTag t = isInlineTagName || isCommentTag t- where isInlineTagName = case getTagName t of- Just x -> x- `Set.notMember` blockTags- Nothing -> False+isInlineTag t =+ isCommentTag t || case getTagName t of+ Nothing -> False+ Just x -> x `Set.notMember` blockTags ||+ T.take 1 x == "?" -- processing instr. isBlockTag :: NamedTag (Tag a) => Tag a -> Bool isBlockTag t = isBlockTagName || isTagComment t@@ -1208,8 +1208,10 @@ let isNameChar c = isAlphaNum c || c == ':' || c == '-' || c == '_' let isName s = case s of [] -> False- ('?':_) -> True -- processing instruction (c:cs) -> isLetter c && all isNameChar cs+ let isPI s = case s of+ ('?':_) -> True -- processing instruction+ _ -> False let endpos = if ln == 1 then setSourceColumn startpos@@ -1225,7 +1227,7 @@ let handleTag tagname = do -- basic sanity check, since the parser is very forgiving -- and finds tags in stuff like x<y)- guard $ isName tagname+ guard $ isName tagname || isPI tagname guard $ not $ null tagname -- <https://example.org> should NOT be a tag either. -- tagsoup will parse it as TagOpen "https:" [("example.org","")]@@ -1245,7 +1247,7 @@ else return (next, "<!--" <> s <> "-->") | otherwise -> fail "bogus comment mode, HTML5 parse error" TagOpen tagname attr -> do- guard $ all (isName . fst) attr+ guard $ isPI tagname || all (isName . fst) attr handleTag tagname TagClose tagname -> handleTag tagname
@@ -36,7 +36,7 @@ import Data.Char (isDigit, isSpace, toUpper) import Data.Default import Data.Generics-import Data.List (intersperse)+import Data.List (foldl', intersperse) import qualified Data.Map as Map import Data.Maybe (maybeToList, fromMaybe) import Data.Text (Text)@@ -278,9 +278,7 @@ $ safeRead $ '0': filter (\x -> isDigit x || x == '.') w Nothing -> 0 :: Double- let numrows = case bodyrows of- [] -> 0- xs -> maximum $ map length xs+ let numrows = foldl' max 0 $ map length bodyrows let aligns = case colspecs of [] -> replicate numrows AlignDefault cs -> map toAlignment cs
@@ -72,10 +72,13 @@ import Text.Pandoc.Readers.LaTeX.Types (ExpansionPoint (..), Macro (..), ArgSpec (..), Tok (..), TokType (..)) import Text.Pandoc.Readers.LaTeX.Parsing+import Text.Pandoc.Readers.LaTeX.Lang (polyglossiaLangToBCP47,+ babelLangToBCP47) import Text.Pandoc.Shared import qualified Text.Pandoc.Translations as Translations import Text.Pandoc.Walk import qualified Text.Pandoc.Builder as B+import qualified Data.Text.Normalize as Normalize -- for debugging: -- import Text.Pandoc.Extensions (getDefaultExtensions)@@ -589,313 +592,23 @@ keyvals :: PandocMonad m => LP m [(String, String)] keyvals = try $ symbol '[' >> manyTill keyval (symbol ']') -accent :: PandocMonad m => Char -> (Char -> String) -> LP m Inlines-accent c f = try $ do+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 $- case f x of- [z] | z == x -> Str ([z,c] ++ xs) : ys -- combining accent- zs -> Str (zs ++ xs) : ys- [Space] -> return $ str [c]- [] -> return $ str [c]+ -- 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] _ -> return ils--grave :: Char -> String-grave 'A' = "À"-grave 'E' = "È"-grave 'I' = "Ì"-grave 'O' = "Ò"-grave 'U' = "Ù"-grave 'a' = "à"-grave 'e' = "è"-grave 'i' = "ì"-grave 'o' = "ò"-grave 'u' = "ù"-grave c = [c]--acute :: Char -> String-acute 'A' = "Á"-acute 'E' = "É"-acute 'I' = "Í"-acute 'O' = "Ó"-acute 'U' = "Ú"-acute 'Y' = "Ý"-acute 'a' = "á"-acute 'e' = "é"-acute 'i' = "í"-acute 'o' = "ó"-acute 'u' = "ú"-acute 'y' = "ý"-acute 'C' = "Ć"-acute 'c' = "ć"-acute 'L' = "Ĺ"-acute 'l' = "ĺ"-acute 'N' = "Ń"-acute 'n' = "ń"-acute 'R' = "Ŕ"-acute 'r' = "ŕ"-acute 'S' = "Ś"-acute 's' = "ś"-acute 'Z' = "Ź"-acute 'z' = "ź"-acute c = [c]--circ :: Char -> String-circ 'A' = "Â"-circ 'E' = "Ê"-circ 'I' = "Î"-circ 'O' = "Ô"-circ 'U' = "Û"-circ 'a' = "â"-circ 'e' = "ê"-circ 'i' = "î"-circ 'o' = "ô"-circ 'u' = "û"-circ 'C' = "Ĉ"-circ 'c' = "ĉ"-circ 'G' = "Ĝ"-circ 'g' = "ĝ"-circ 'H' = "Ĥ"-circ 'h' = "ĥ"-circ 'J' = "Ĵ"-circ 'j' = "ĵ"-circ 'S' = "Ŝ"-circ 's' = "ŝ"-circ 'W' = "Ŵ"-circ 'w' = "ŵ"-circ 'Y' = "Ŷ"-circ 'y' = "ŷ"-circ c = [c]--tilde :: Char -> String-tilde 'A' = "Ã"-tilde 'a' = "ã"-tilde 'O' = "Õ"-tilde 'o' = "õ"-tilde 'I' = "Ĩ"-tilde 'i' = "ĩ"-tilde 'U' = "Ũ"-tilde 'u' = "ũ"-tilde 'N' = "Ñ"-tilde 'n' = "ñ"-tilde c = [c]--umlaut :: Char -> String-umlaut 'A' = "Ä"-umlaut 'E' = "Ë"-umlaut 'I' = "Ï"-umlaut 'O' = "Ö"-umlaut 'U' = "Ü"-umlaut 'a' = "ä"-umlaut 'e' = "ë"-umlaut 'i' = "ï"-umlaut 'o' = "ö"-umlaut 'u' = "ü"-umlaut c = [c]--hungarumlaut :: Char -> String-hungarumlaut 'A' = "A̋"-hungarumlaut 'E' = "E̋"-hungarumlaut 'I' = "I̋"-hungarumlaut 'O' = "Ő"-hungarumlaut 'U' = "Ű"-hungarumlaut 'Y' = "ӳ"-hungarumlaut 'a' = "a̋"-hungarumlaut 'e' = "e̋"-hungarumlaut 'i' = "i̋"-hungarumlaut 'o' = "ő"-hungarumlaut 'u' = "ű"-hungarumlaut 'y' = "ӳ"-hungarumlaut c = [c]--dot :: Char -> String-dot 'C' = "Ċ"-dot 'c' = "ċ"-dot 'E' = "Ė"-dot 'e' = "ė"-dot 'G' = "Ġ"-dot 'g' = "ġ"-dot 'I' = "İ"-dot 'Z' = "Ż"-dot 'z' = "ż"-dot c = [c]--macron :: Char -> String-macron 'A' = "Ā"-macron 'E' = "Ē"-macron 'I' = "Ī"-macron 'O' = "Ō"-macron 'U' = "Ū"-macron 'a' = "ā"-macron 'e' = "ē"-macron 'i' = "ī"-macron 'o' = "ō"-macron 'u' = "ū"-macron c = [c]--ringabove :: Char -> String-ringabove 'A' = "Å"-ringabove 'a' = "å"-ringabove 'U' = "Ů"-ringabove 'u' = "ů"-ringabove c = [c]--dotbelow :: Char -> String-dotbelow 'B' = "Ḅ"-dotbelow 'b' = "ḅ"-dotbelow 'D' = "Ḍ"-dotbelow 'd' = "ḍ"-dotbelow 'H' = "Ḥ"-dotbelow 'h' = "ḥ"-dotbelow 'K' = "Ḳ"-dotbelow 'k' = "ḳ"-dotbelow 'L' = "Ḷ"-dotbelow 'l' = "ḷ"-dotbelow 'M' = "Ṃ"-dotbelow 'm' = "ṃ"-dotbelow 'N' = "Ṇ"-dotbelow 'n' = "ṇ"-dotbelow 'R' = "Ṛ"-dotbelow 'r' = "ṛ"-dotbelow 'S' = "Ṣ"-dotbelow 's' = "ṣ"-dotbelow 'T' = "Ṭ"-dotbelow 't' = "ṭ"-dotbelow 'V' = "Ṿ"-dotbelow 'v' = "ṿ"-dotbelow 'W' = "Ẉ"-dotbelow 'w' = "ẉ"-dotbelow 'Z' = "Ẓ"-dotbelow 'z' = "ẓ"-dotbelow 'A' = "Ạ"-dotbelow 'a' = "ạ"-dotbelow 'E' = "Ẹ"-dotbelow 'e' = "ẹ"-dotbelow 'I' = "Ị"-dotbelow 'i' = "ị"-dotbelow 'O' = "Ọ"-dotbelow 'o' = "ọ"-dotbelow 'U' = "Ụ"-dotbelow 'u' = "ụ"-dotbelow 'Y' = "Ỵ"-dotbelow 'y' = "ỵ"-dotbelow c = [c]--doublegrave :: Char -> String-doublegrave 'A' = "Ȁ"-doublegrave 'a' = "ȁ"-doublegrave 'E' = "Ȅ"-doublegrave 'e' = "ȅ"-doublegrave 'I' = "Ȉ"-doublegrave 'i' = "ȉ"-doublegrave 'O' = "Ȍ"-doublegrave 'o' = "ȍ"-doublegrave 'R' = "Ȑ"-doublegrave 'r' = "ȑ"-doublegrave 'U' = "Ȕ"-doublegrave 'u' = "ȕ"-doublegrave c = [c]--hookabove :: Char -> String-hookabove 'A' = "Ả"-hookabove 'a' = "ả"-hookabove 'E' = "Ẻ"-hookabove 'e' = "ẻ"-hookabove 'I' = "Ỉ"-hookabove 'i' = "ỉ"-hookabove 'O' = "Ỏ"-hookabove 'o' = "ỏ"-hookabove 'U' = "Ủ"-hookabove 'u' = "ủ"-hookabove 'Y' = "Ỷ"-hookabove 'y' = "ỷ"-hookabove c = [c]--cedilla :: Char -> String-cedilla 'c' = "ç"-cedilla 'C' = "Ç"-cedilla 's' = "ş"-cedilla 'S' = "Ş"-cedilla 't' = "ţ"-cedilla 'T' = "Ţ"-cedilla 'e' = "ȩ"-cedilla 'E' = "Ȩ"-cedilla 'h' = "ḩ"-cedilla 'H' = "Ḩ"-cedilla 'o' = "o̧"-cedilla 'O' = "O̧"-cedilla c = [c]--hacek :: Char -> String-hacek 'A' = "Ǎ"-hacek 'a' = "ǎ"-hacek 'C' = "Č"-hacek 'c' = "č"-hacek 'D' = "Ď"-hacek 'd' = "ď"-hacek 'E' = "Ě"-hacek 'e' = "ě"-hacek 'G' = "Ǧ"-hacek 'g' = "ǧ"-hacek 'H' = "Ȟ"-hacek 'h' = "ȟ"-hacek 'I' = "Ǐ"-hacek 'i' = "ǐ"-hacek 'j' = "ǰ"-hacek 'K' = "Ǩ"-hacek 'k' = "ǩ"-hacek 'L' = "Ľ"-hacek 'l' = "ľ"-hacek 'N' = "Ň"-hacek 'n' = "ň"-hacek 'O' = "Ǒ"-hacek 'o' = "ǒ"-hacek 'R' = "Ř"-hacek 'r' = "ř"-hacek 'S' = "Š"-hacek 's' = "š"-hacek 'T' = "Ť"-hacek 't' = "ť"-hacek 'U' = "Ǔ"-hacek 'u' = "ǔ"-hacek 'Z' = "Ž"-hacek 'z' = "ž"-hacek c = [c]--ogonek :: Char -> String-ogonek 'a' = "ą"-ogonek 'e' = "ę"-ogonek 'o' = "ǫ"-ogonek 'i' = "į"-ogonek 'u' = "ų"-ogonek 'A' = "Ą"-ogonek 'E' = "Ę"-ogonek 'I' = "Į"-ogonek 'O' = "Ǫ"-ogonek 'U' = "Ų"-ogonek c = [c]--breve :: Char -> String-breve 'A' = "Ă"-breve 'a' = "ă"-breve 'E' = "Ĕ"-breve 'e' = "ĕ"-breve 'G' = "Ğ"-breve 'g' = "ğ"-breve 'I' = "Ĭ"-breve 'i' = "ĭ"-breve 'O' = "Ŏ"-breve 'o' = "ŏ"-breve 'U' = "Ŭ"-breve 'u' = "ŭ"-breve c = [c]- mathDisplay :: String -> Inlines-mathDisplay = displayMath . trim+mathDisplay = displayMath . trimMath mathInline :: String -> Inlines-mathInline = math . trim+mathInline = math . trimMath dollarsMath :: PandocMonad m => LP m Inlines dollarsMath = do@@ -1136,6 +849,12 @@ , ("align*", mathEnvWith id (Just "aligned") "align*") , ("alignat", mathEnvWith id (Just "aligned") "alignat") , ("alignat*", mathEnvWith id (Just "aligned") "alignat*")+ , ("dmath", mathEnvWith id Nothing "dmath")+ , ("dmath*", mathEnvWith id Nothing "dmath*")+ , ("dgroup", mathEnvWith id (Just "aligned") "dgroup")+ , ("dgroup*", mathEnvWith id (Just "aligned") "dgroup*")+ , ("darray", mathEnvWith id (Just "aligned") "darray")+ , ("darray*", mathEnvWith id (Just "aligned") "darray*") ] inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)@@ -1222,32 +941,32 @@ , ("copyright", lit "©") , ("textasciicircum", lit "^") , ("textasciitilde", lit "~")- , ("H", accent '\779' hungarumlaut)- , ("`", accent '`' grave)- , ("'", accent '\'' acute)- , ("^", accent '^' circ)- , ("~", accent '~' tilde)- , ("\"", accent '\776' umlaut)- , (".", accent '\775' dot)- , ("=", accent '\772' macron)- , ("|", accent '\781' (:[])) -- vertical line above- , ("b", accent '\817' (:[])) -- macron below- , ("c", accent '\807' cedilla)- , ("G", accent '\783' doublegrave)- , ("h", accent '\777' hookabove)- , ("d", accent '\803' dotbelow)- , ("f", accent '\785' (:[])) -- inverted breve- , ("r", accent '\778' ringabove)- , ("t", accent '\865' (:[])) -- double inverted breve- , ("U", accent '\782' (:[])) -- double vertical line above- , ("v", accent 'ˇ' hacek)- , ("u", accent '\774' breve)- , ("k", accent '\808' ogonek)- , ("textogonekcentered", accent '\808' ogonek)+ , ("H", accent '\779' Nothing) -- hungarumlaut+ , ("`", accent '\768' (Just '`')) -- grave+ , ("'", accent '\769' (Just '\'')) -- acute+ , ("^", accent '\770' (Just '^')) -- circ+ , ("~", accent '\771' (Just '~')) -- tilde+ , ("\"", accent '\776' Nothing) -- umlaut+ , (".", accent '\775' Nothing) -- dot+ , ("=", accent '\772' Nothing) -- macron+ , ("|", accent '\781' Nothing) -- vertical line above+ , ("b", accent '\817' Nothing) -- macron below+ , ("c", accent '\807' Nothing) -- cedilla+ , ("G", accent '\783' Nothing) -- doublegrave+ , ("h", accent '\777' Nothing) -- hookabove+ , ("d", accent '\803' Nothing) -- dotbelow+ , ("f", accent '\785' Nothing) -- inverted breve+ , ("r", accent '\778' Nothing) -- ringabove+ , ("t", accent '\865' Nothing) -- double inverted breve+ , ("U", accent '\782' Nothing) -- double vertical line above+ , ("v", accent '\780' Nothing) -- hacek+ , ("u", accent '\774' Nothing) -- breve+ , ("k", accent '\808' Nothing) -- ogonek+ , ("textogonekcentered", accent '\808' Nothing) -- ogonek , ("i", lit "ı") -- dotless i , ("j", lit "ȷ") -- dotless j- , ("newtie", accent '\785' (:[])) -- inverted breve- , ("textcircled", accent '\8413' (:[])) -- combining circle+ , ("newtie", accent '\785' Nothing) -- inverted breve+ , ("textcircled", accent '\8413' Nothing) -- combining circle , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState guard $ not inTableCell optional opt@@ -1269,6 +988,8 @@ , ("Verb", doverb) , ("url", ((unescapeURL . T.unpack . untokenize) <$> bracedUrl) >>= \url -> pure (link url "" (str url)))+ , ("nolinkurl", ((unescapeURL . T.unpack . untokenize) <$> bracedUrl) >>= \url ->+ pure (code url)) , ("href", (unescapeURL . toksToString <$> bracedUrl <* optional sp) >>= \url -> tok >>= \lab -> pure (link url "" lab))@@ -1589,13 +1310,7 @@ treatAsBlock :: Set.Set Text treatAsBlock = Set.fromList- [ "let", "def", "DeclareRobustCommand"- , "newcommand", "renewcommand"- , "newenvironment", "renewenvironment"- , "providecommand", "provideenvironment"- -- newcommand, etc. should be parsed by macroDef, but we need this- -- here so these aren't parsed as inline commands to ignore- , "special", "pdfannot", "pdfstringdef"+ [ "special", "pdfannot", "pdfstringdef" , "bibliographystyle" , "maketitle", "makeindex", "makeglossary" , "addcontentsline", "addtocontents", "addtocounter"@@ -1656,6 +1371,7 @@ <|> (space <$ whitespace) <|> (softbreak <$ endline) <|> word+ <|> macroDef <|> inlineCommand' <|> inlineEnvironment <|> inlineGroup@@ -1701,8 +1417,7 @@ preamble :: PandocMonad m => LP m Blocks preamble = mempty <$ many preambleBlock where preambleBlock = spaces1- <|> void macroDef- <|> void blockCommand+ <|> void (macroDef <|> blockCommand) <|> void braced <|> (notFollowedBy (begin_ "document") >> void anyTok) @@ -1765,9 +1480,9 @@ egroup addMeta "author" (map trimInlines auths) -macroDef :: PandocMonad m => LP m Blocks+macroDef :: (Monoid a, PandocMonad m) => LP m a macroDef =- mempty <$ ((commandDef <|> environmentDef) <* doMacros 0)+ mempty <$ (commandDef <|> environmentDef) where commandDef = do (name, macro') <- newcommand <|> letmacro <|> defmacro guardDisabled Ext_latex_macros <|>@@ -1787,21 +1502,28 @@ letmacro :: PandocMonad m => LP m (Text, Macro) letmacro = do controlSeq "let"- Tok _ (CtrlSeq name) _ <- anyControlSeq- optional $ symbol '='- spaces- contents <- bracedOrToken- return (name, Macro ExpandWhenDefined [] Nothing contents)+ (name, contents) <- withVerbatimMode $ do+ Tok _ (CtrlSeq name) _ <- anyControlSeq+ optional $ symbol '='+ spaces+ -- we first parse in verbatim mode, and then expand macros,+ -- because we don't want \let\foo\bar to turn into+ -- \let\foo hello if we have previously \def\bar{hello}+ contents <- bracedOrToken+ return (name, contents)+ contents' <- doMacros' 0 contents+ return (name, Macro ExpandWhenDefined [] Nothing contents') defmacro :: PandocMonad m => LP m (Text, Macro)-defmacro = try $ do- controlSeq "def"- Tok _ (CtrlSeq name) _ <- anyControlSeq- argspecs <- many (argspecArg <|> argspecPattern)+defmacro = try $ -- we use withVerbatimMode, because macros are to be expanded -- at point of use, not point of definition- contents <- withVerbatimMode bracedOrToken- return (name, Macro ExpandWhenUsed argspecs Nothing contents)+ withVerbatimMode $ do+ controlSeq "def"+ Tok _ (CtrlSeq name) _ <- anyControlSeq+ argspecs <- many (argspecArg <|> argspecPattern)+ contents <- bracedOrToken+ return (name, Macro ExpandWhenUsed argspecs Nothing contents) argspecArg :: PandocMonad m => LP m ArgSpec argspecArg = do@@ -1811,12 +1533,8 @@ argspecPattern :: PandocMonad m => LP m ArgSpec argspecPattern = Pattern <$> many1 (satisfyTok (\(Tok _ toktype' txt) ->- (toktype' == Symbol || toktype' == Word) &&- (txt /= "{" && txt /= "\\" && txt /= "}")))--isArgTok :: Tok -> Bool-isArgTok (Tok _ (Arg _) _) = True-isArgTok _ = False+ (toktype' == Symbol || toktype' == Word) &&+ (txt /= "{" && txt /= "\\" && txt /= "}"))) newcommand :: PandocMonad m => LP m (Text, Macro) newcommand = do@@ -1825,22 +1543,24 @@ controlSeq "renewcommand" <|> controlSeq "providecommand" <|> controlSeq "DeclareRobustCommand"- optional $ symbol '*'- Tok _ (CtrlSeq name) txt <- withVerbatimMode $ anyControlSeq <|>- (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')- spaces- numargs <- option 0 $ try bracketedNum- let argspecs = map (\i -> ArgNum i) [1..numargs]- spaces- optarg <- option Nothing $ Just <$> try bracketedToks- spaces- contents <- withVerbatimMode bracedOrToken- 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)+ withVerbatimMode $ do+ Tok _ (CtrlSeq name) txt <- do+ optional (symbol '*')+ anyControlSeq <|>+ (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')+ spaces+ numargs <- option 0 $ try bracketedNum+ let argspecs = map (\i -> ArgNum i) [1..numargs]+ spaces+ optarg <- option Nothing $ Just <$> try bracketedToks+ spaces+ contents <- bracedOrToken+ 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) newenvironment :: PandocMonad m => LP m (Text, Macro, Macro) newenvironment = do@@ -1848,24 +1568,23 @@ Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|> controlSeq "renewenvironment" <|> controlSeq "provideenvironment"- optional $ symbol '*'- spaces- name <- untokenize <$> braced- spaces- numargs <- option 0 $ try bracketedNum- let argspecs = map (\i -> ArgNum i) [1..numargs]- spaces- optarg <- option Nothing $ Just <$> try bracketedToks- spaces- startcontents <- withVerbatimMode bracedOrToken- spaces- endcontents <- withVerbatimMode 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,+ withVerbatimMode $ do+ optional $ symbol '*'+ spaces+ name <- untokenize <$> braced+ spaces+ numargs <- option 0 $ try bracketedNum+ spaces+ optarg <- option Nothing $ Just <$> try bracketedToks+ 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) bracketedNum :: PandocMonad m => LP m Int@@ -1929,7 +1648,9 @@ let names = ordNub [name', name] let rawDefiniteBlock = do guard $ isBlockCommand name- rawBlock "latex" <$> getRawCommand name (txt <> star)+ rawcontents <- getRawCommand name (txt <> star)+ (guardEnabled Ext_raw_tex >> return (rawBlock "latex" rawcontents))+ <|> ignore rawcontents -- heuristic: if it could be either block or inline, we -- treat it if block if we have a sequence of block -- commands followed by a newline. But we stop if we@@ -1941,7 +1662,10 @@ guard $ "start" `T.isPrefixOf` n let rawMaybeBlock = try $ do guard $ not $ isInlineCommand name- curr <- rawBlock "latex" <$> getRawCommand name (txt <> star)+ rawcontents <- getRawCommand name (txt <> star)+ curr <- (guardEnabled Ext_raw_tex >>+ return (rawBlock "latex" rawcontents))+ <|> ignore rawcontents rest <- many $ notFollowedBy startCommand *> blockCommand lookAhead $ blankline <|> startCommand return $ curr <> mconcat rest@@ -2042,6 +1766,8 @@ , ("input", include "input") , ("subfile", include "subfile") , ("usepackage", include "usepackage")+ -- preamble+ , ("PackageError", mempty <$ (braced >> braced >> braced)) ] @@ -2139,8 +1865,21 @@ skipopts optional blankline res <- manyTill anyTok (end_ name)- return $ stripTrailingNewlines $ toksToString res+ return $ T.unpack+ $ stripTrailingNewline+ $ untokenize+ $ res +-- Strip single final newline and any spaces following it.+-- Input is unchanged if it doesn't end with newline ++-- optional spaces.+stripTrailingNewline :: Text -> Text+stripTrailingNewline t =+ let (b, e) = T.breakOnEnd "\n" t+ in if T.all (== ' ') e+ then T.dropEnd 1 b+ else t+ fancyverbEnv :: PandocMonad m => Text -> LP m Blocks fancyverbEnv name = do options <- option [] keyvals@@ -2535,137 +2274,3 @@ setTranslations l updateState $ setMeta "lang" $ str (renderLang l) return mempty--polyglossiaLangToBCP47 :: M.Map String (String -> Lang)-polyglossiaLangToBCP47 = M.fromList- [ ("arabic", \o -> case filter (/=' ') o of- "locale=algeria" -> Lang "ar" "" "DZ" []- "locale=mashriq" -> Lang "ar" "" "SY" []- "locale=libya" -> Lang "ar" "" "LY" []- "locale=morocco" -> Lang "ar" "" "MA" []- "locale=mauritania" -> Lang "ar" "" "MR" []- "locale=tunisia" -> Lang "ar" "" "TN" []- _ -> Lang "ar" "" "" [])- , ("german", \o -> case filter (/=' ') o of- "spelling=old" -> Lang "de" "" "DE" ["1901"]- "variant=austrian,spelling=old"- -> Lang "de" "" "AT" ["1901"]- "variant=austrian" -> Lang "de" "" "AT" []- "variant=swiss,spelling=old"- -> Lang "de" "" "CH" ["1901"]- "variant=swiss" -> Lang "de" "" "CH" []- _ -> Lang "de" "" "" [])- , ("lsorbian", \_ -> Lang "dsb" "" "" [])- , ("greek", \o -> case filter (/=' ') o of- "variant=poly" -> Lang "el" "" "polyton" []- "variant=ancient" -> Lang "grc" "" "" []- _ -> Lang "el" "" "" [])- , ("english", \o -> case filter (/=' ') o of- "variant=australian" -> Lang "en" "" "AU" []- "variant=canadian" -> Lang "en" "" "CA" []- "variant=british" -> Lang "en" "" "GB" []- "variant=newzealand" -> Lang "en" "" "NZ" []- "variant=american" -> Lang "en" "" "US" []- _ -> Lang "en" "" "" [])- , ("usorbian", \_ -> Lang "hsb" "" "" [])- , ("latin", \o -> case filter (/=' ') o of- "variant=classic" -> Lang "la" "" "" ["x-classic"]- _ -> Lang "la" "" "" [])- , ("slovenian", \_ -> Lang "sl" "" "" [])- , ("serbianc", \_ -> Lang "sr" "cyrl" "" [])- , ("pinyin", \_ -> Lang "zh" "Latn" "" ["pinyin"])- , ("afrikaans", \_ -> Lang "af" "" "" [])- , ("amharic", \_ -> Lang "am" "" "" [])- , ("assamese", \_ -> Lang "as" "" "" [])- , ("asturian", \_ -> Lang "ast" "" "" [])- , ("bulgarian", \_ -> Lang "bg" "" "" [])- , ("bengali", \_ -> Lang "bn" "" "" [])- , ("tibetan", \_ -> Lang "bo" "" "" [])- , ("breton", \_ -> Lang "br" "" "" [])- , ("catalan", \_ -> Lang "ca" "" "" [])- , ("welsh", \_ -> Lang "cy" "" "" [])- , ("czech", \_ -> Lang "cs" "" "" [])- , ("coptic", \_ -> Lang "cop" "" "" [])- , ("danish", \_ -> Lang "da" "" "" [])- , ("divehi", \_ -> Lang "dv" "" "" [])- , ("esperanto", \_ -> Lang "eo" "" "" [])- , ("spanish", \_ -> Lang "es" "" "" [])- , ("estonian", \_ -> Lang "et" "" "" [])- , ("basque", \_ -> Lang "eu" "" "" [])- , ("farsi", \_ -> Lang "fa" "" "" [])- , ("finnish", \_ -> Lang "fi" "" "" [])- , ("french", \_ -> Lang "fr" "" "" [])- , ("friulan", \_ -> Lang "fur" "" "" [])- , ("irish", \_ -> Lang "ga" "" "" [])- , ("scottish", \_ -> Lang "gd" "" "" [])- , ("ethiopic", \_ -> Lang "gez" "" "" [])- , ("galician", \_ -> Lang "gl" "" "" [])- , ("hebrew", \_ -> Lang "he" "" "" [])- , ("hindi", \_ -> Lang "hi" "" "" [])- , ("croatian", \_ -> Lang "hr" "" "" [])- , ("magyar", \_ -> Lang "hu" "" "" [])- , ("armenian", \_ -> Lang "hy" "" "" [])- , ("interlingua", \_ -> Lang "ia" "" "" [])- , ("indonesian", \_ -> Lang "id" "" "" [])- , ("icelandic", \_ -> Lang "is" "" "" [])- , ("italian", \_ -> Lang "it" "" "" [])- , ("japanese", \_ -> Lang "jp" "" "" [])- , ("khmer", \_ -> Lang "km" "" "" [])- , ("kurmanji", \_ -> Lang "kmr" "" "" [])- , ("kannada", \_ -> Lang "kn" "" "" [])- , ("korean", \_ -> Lang "ko" "" "" [])- , ("lao", \_ -> Lang "lo" "" "" [])- , ("lithuanian", \_ -> Lang "lt" "" "" [])- , ("latvian", \_ -> Lang "lv" "" "" [])- , ("malayalam", \_ -> Lang "ml" "" "" [])- , ("mongolian", \_ -> Lang "mn" "" "" [])- , ("marathi", \_ -> Lang "mr" "" "" [])- , ("dutch", \_ -> Lang "nl" "" "" [])- , ("nynorsk", \_ -> Lang "nn" "" "" [])- , ("norsk", \_ -> Lang "no" "" "" [])- , ("nko", \_ -> Lang "nqo" "" "" [])- , ("occitan", \_ -> Lang "oc" "" "" [])- , ("panjabi", \_ -> Lang "pa" "" "" [])- , ("polish", \_ -> Lang "pl" "" "" [])- , ("piedmontese", \_ -> Lang "pms" "" "" [])- , ("portuguese", \_ -> Lang "pt" "" "" [])- , ("romansh", \_ -> Lang "rm" "" "" [])- , ("romanian", \_ -> Lang "ro" "" "" [])- , ("russian", \_ -> Lang "ru" "" "" [])- , ("sanskrit", \_ -> Lang "sa" "" "" [])- , ("samin", \_ -> Lang "se" "" "" [])- , ("slovak", \_ -> Lang "sk" "" "" [])- , ("albanian", \_ -> Lang "sq" "" "" [])- , ("serbian", \_ -> Lang "sr" "" "" [])- , ("swedish", \_ -> Lang "sv" "" "" [])- , ("syriac", \_ -> Lang "syr" "" "" [])- , ("tamil", \_ -> Lang "ta" "" "" [])- , ("telugu", \_ -> Lang "te" "" "" [])- , ("thai", \_ -> Lang "th" "" "" [])- , ("turkmen", \_ -> Lang "tk" "" "" [])- , ("turkish", \_ -> Lang "tr" "" "" [])- , ("ukrainian", \_ -> Lang "uk" "" "" [])- , ("urdu", \_ -> Lang "ur" "" "" [])- , ("vietnamese", \_ -> Lang "vi" "" "" [])- ]--babelLangToBCP47 :: String -> Maybe Lang-babelLangToBCP47 s =- case s of- "austrian" -> Just $ Lang "de" "" "AT" ["1901"]- "naustrian" -> Just $ Lang "de" "" "AT" []- "swissgerman" -> Just $ Lang "de" "" "CH" ["1901"]- "nswissgerman" -> Just $ Lang "de" "" "CH" []- "german" -> Just $ Lang "de" "" "DE" ["1901"]- "ngerman" -> Just $ Lang "de" "" "DE" []- "lowersorbian" -> Just $ Lang "dsb" "" "" []- "uppersorbian" -> Just $ Lang "hsb" "" "" []- "polutonikogreek" -> Just $ Lang "el" "" "" ["polyton"]- "slovene" -> Just $ Lang "sl" "" "" []- "australian" -> Just $ Lang "en" "" "AU" []- "canadian" -> Just $ Lang "en" "" "CA" []- "british" -> Just $ Lang "en" "" "GB" []- "newzealand" -> Just $ Lang "en" "" "NZ" []- "american" -> Just $ Lang "en" "" "US" []- "classiclatin" -> Just $ Lang "la" "" "" ["x-classic"]- _ -> fmap ($ "") $ M.lookup s polyglossiaLangToBCP47
@@ -0,0 +1,173 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-+Copyright (C) 2018 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.Readers.LaTeX.Lang+ Copyright : Copyright (C) 2018 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Functions for parsing polyglossia and babel language specifiers to+BCP47 'Lang'.+-}+module Text.Pandoc.Readers.LaTeX.Lang+ ( polyglossiaLangToBCP47+ , babelLangToBCP47+ )+where+import Prelude+import qualified Data.Map as M+import Text.Pandoc.BCP47 (Lang(..))++polyglossiaLangToBCP47 :: M.Map String (String -> Lang)+polyglossiaLangToBCP47 = M.fromList+ [ ("arabic", \o -> case filter (/=' ') o of+ "locale=algeria" -> Lang "ar" "" "DZ" []+ "locale=mashriq" -> Lang "ar" "" "SY" []+ "locale=libya" -> Lang "ar" "" "LY" []+ "locale=morocco" -> Lang "ar" "" "MA" []+ "locale=mauritania" -> Lang "ar" "" "MR" []+ "locale=tunisia" -> Lang "ar" "" "TN" []+ _ -> Lang "ar" "" "" [])+ , ("german", \o -> case filter (/=' ') o of+ "spelling=old" -> Lang "de" "" "DE" ["1901"]+ "variant=austrian,spelling=old"+ -> Lang "de" "" "AT" ["1901"]+ "variant=austrian" -> Lang "de" "" "AT" []+ "variant=swiss,spelling=old"+ -> Lang "de" "" "CH" ["1901"]+ "variant=swiss" -> Lang "de" "" "CH" []+ _ -> Lang "de" "" "" [])+ , ("lsorbian", \_ -> Lang "dsb" "" "" [])+ , ("greek", \o -> case filter (/=' ') o of+ "variant=poly" -> Lang "el" "" "polyton" []+ "variant=ancient" -> Lang "grc" "" "" []+ _ -> Lang "el" "" "" [])+ , ("english", \o -> case filter (/=' ') o of+ "variant=australian" -> Lang "en" "" "AU" []+ "variant=canadian" -> Lang "en" "" "CA" []+ "variant=british" -> Lang "en" "" "GB" []+ "variant=newzealand" -> Lang "en" "" "NZ" []+ "variant=american" -> Lang "en" "" "US" []+ _ -> Lang "en" "" "" [])+ , ("usorbian", \_ -> Lang "hsb" "" "" [])+ , ("latin", \o -> case filter (/=' ') o of+ "variant=classic" -> Lang "la" "" "" ["x-classic"]+ _ -> Lang "la" "" "" [])+ , ("slovenian", \_ -> Lang "sl" "" "" [])+ , ("serbianc", \_ -> Lang "sr" "cyrl" "" [])+ , ("pinyin", \_ -> Lang "zh" "Latn" "" ["pinyin"])+ , ("afrikaans", \_ -> Lang "af" "" "" [])+ , ("amharic", \_ -> Lang "am" "" "" [])+ , ("assamese", \_ -> Lang "as" "" "" [])+ , ("asturian", \_ -> Lang "ast" "" "" [])+ , ("bulgarian", \_ -> Lang "bg" "" "" [])+ , ("bengali", \_ -> Lang "bn" "" "" [])+ , ("tibetan", \_ -> Lang "bo" "" "" [])+ , ("breton", \_ -> Lang "br" "" "" [])+ , ("catalan", \_ -> Lang "ca" "" "" [])+ , ("welsh", \_ -> Lang "cy" "" "" [])+ , ("czech", \_ -> Lang "cs" "" "" [])+ , ("coptic", \_ -> Lang "cop" "" "" [])+ , ("danish", \_ -> Lang "da" "" "" [])+ , ("divehi", \_ -> Lang "dv" "" "" [])+ , ("esperanto", \_ -> Lang "eo" "" "" [])+ , ("spanish", \_ -> Lang "es" "" "" [])+ , ("estonian", \_ -> Lang "et" "" "" [])+ , ("basque", \_ -> Lang "eu" "" "" [])+ , ("farsi", \_ -> Lang "fa" "" "" [])+ , ("finnish", \_ -> Lang "fi" "" "" [])+ , ("french", \_ -> Lang "fr" "" "" [])+ , ("friulan", \_ -> Lang "fur" "" "" [])+ , ("irish", \_ -> Lang "ga" "" "" [])+ , ("scottish", \_ -> Lang "gd" "" "" [])+ , ("ethiopic", \_ -> Lang "gez" "" "" [])+ , ("galician", \_ -> Lang "gl" "" "" [])+ , ("hebrew", \_ -> Lang "he" "" "" [])+ , ("hindi", \_ -> Lang "hi" "" "" [])+ , ("croatian", \_ -> Lang "hr" "" "" [])+ , ("magyar", \_ -> Lang "hu" "" "" [])+ , ("armenian", \_ -> Lang "hy" "" "" [])+ , ("interlingua", \_ -> Lang "ia" "" "" [])+ , ("indonesian", \_ -> Lang "id" "" "" [])+ , ("icelandic", \_ -> Lang "is" "" "" [])+ , ("italian", \_ -> Lang "it" "" "" [])+ , ("japanese", \_ -> Lang "jp" "" "" [])+ , ("khmer", \_ -> Lang "km" "" "" [])+ , ("kurmanji", \_ -> Lang "kmr" "" "" [])+ , ("kannada", \_ -> Lang "kn" "" "" [])+ , ("korean", \_ -> Lang "ko" "" "" [])+ , ("lao", \_ -> Lang "lo" "" "" [])+ , ("lithuanian", \_ -> Lang "lt" "" "" [])+ , ("latvian", \_ -> Lang "lv" "" "" [])+ , ("malayalam", \_ -> Lang "ml" "" "" [])+ , ("mongolian", \_ -> Lang "mn" "" "" [])+ , ("marathi", \_ -> Lang "mr" "" "" [])+ , ("dutch", \_ -> Lang "nl" "" "" [])+ , ("nynorsk", \_ -> Lang "nn" "" "" [])+ , ("norsk", \_ -> Lang "no" "" "" [])+ , ("nko", \_ -> Lang "nqo" "" "" [])+ , ("occitan", \_ -> Lang "oc" "" "" [])+ , ("panjabi", \_ -> Lang "pa" "" "" [])+ , ("polish", \_ -> Lang "pl" "" "" [])+ , ("piedmontese", \_ -> Lang "pms" "" "" [])+ , ("portuguese", \_ -> Lang "pt" "" "" [])+ , ("romansh", \_ -> Lang "rm" "" "" [])+ , ("romanian", \_ -> Lang "ro" "" "" [])+ , ("russian", \_ -> Lang "ru" "" "" [])+ , ("sanskrit", \_ -> Lang "sa" "" "" [])+ , ("samin", \_ -> Lang "se" "" "" [])+ , ("slovak", \_ -> Lang "sk" "" "" [])+ , ("albanian", \_ -> Lang "sq" "" "" [])+ , ("serbian", \_ -> Lang "sr" "" "" [])+ , ("swedish", \_ -> Lang "sv" "" "" [])+ , ("syriac", \_ -> Lang "syr" "" "" [])+ , ("tamil", \_ -> Lang "ta" "" "" [])+ , ("telugu", \_ -> Lang "te" "" "" [])+ , ("thai", \_ -> Lang "th" "" "" [])+ , ("turkmen", \_ -> Lang "tk" "" "" [])+ , ("turkish", \_ -> Lang "tr" "" "" [])+ , ("ukrainian", \_ -> Lang "uk" "" "" [])+ , ("urdu", \_ -> Lang "ur" "" "" [])+ , ("vietnamese", \_ -> Lang "vi" "" "" [])+ ]++babelLangToBCP47 :: String -> Maybe Lang+babelLangToBCP47 s =+ case s of+ "austrian" -> Just $ Lang "de" "" "AT" ["1901"]+ "naustrian" -> Just $ Lang "de" "" "AT" []+ "swissgerman" -> Just $ Lang "de" "" "CH" ["1901"]+ "nswissgerman" -> Just $ Lang "de" "" "CH" []+ "german" -> Just $ Lang "de" "" "DE" ["1901"]+ "ngerman" -> Just $ Lang "de" "" "DE" []+ "lowersorbian" -> Just $ Lang "dsb" "" "" []+ "uppersorbian" -> Just $ Lang "hsb" "" "" []+ "polutonikogreek" -> Just $ Lang "el" "" "" ["polyton"]+ "slovene" -> Just $ Lang "sl" "" "" []+ "australian" -> Just $ Lang "en" "" "AU" []+ "canadian" -> Just $ Lang "en" "" "CA" []+ "british" -> Just $ Lang "en" "" "GB" []+ "newzealand" -> Just $ Lang "en" "" "NZ" []+ "american" -> Just $ Lang "en" "" "US" []+ "classiclatin" -> Just $ Lang "la" "" "" ["x-classic"]+ _ -> fmap ($ "") $ M.lookup s polyglossiaLangToBCP47
@@ -49,11 +49,13 @@ , toksToString , satisfyTok , doMacros+ , doMacros' , setpos , anyControlSeq , anySymbol- , isWordTok , isNewlineTok+ , isWordTok+ , isArgTok , spaces , spaces1 , tokTypeIn@@ -109,6 +111,8 @@ import Text.Pandoc.Shared import Text.Parsec.Pos +-- import Debug.Trace (traceShowId)+ newtype DottedNum = DottedNum [Int] deriving (Show) @@ -139,6 +143,7 @@ , sLabels :: M.Map String [Inline] , sHasChapters :: Bool , sToggles :: M.Map String Bool+ , sExpanded :: Bool } deriving Show @@ -160,6 +165,7 @@ , sLabels = M.empty , sHasChapters = False , sToggles = M.empty+ , sExpanded = False } instance PandocMonad m => HasQuoteContext LaTeXState m where@@ -210,10 +216,14 @@ withVerbatimMode :: PandocMonad m => LP m a -> LP m a withVerbatimMode parser = do- updateState $ \st -> st{ sVerbatimMode = True }- result <- parser- updateState $ \st -> st{ sVerbatimMode = False }- return result+ alreadyVerbatimMode <- sVerbatimMode <$> getState+ if alreadyVerbatimMode+ then parser+ else do+ updateState $ \st -> st{ sVerbatimMode = True }+ result <- parser+ updateState $ \st -> st{ sVerbatimMode = False }+ return result rawLaTeXParser :: (PandocMonad m, HasMacros s, HasReaderOptions s) => Bool -> LP m a -> LP m a -> ParserT String s m (a, String)@@ -230,7 +240,7 @@ Right toks' -> do res <- lift $ runParserT (do when retokenize $ do -- retokenize, applying macros- doMacros 0+ doMacros ts <- many (satisfyTok (const True)) setInput ts rawparser)@@ -245,8 +255,7 @@ applyMacros :: (PandocMonad m, HasMacros s, HasReaderOptions s) => String -> ParserT String s m String applyMacros s = (guardDisabled Ext_latex_macros >> return s) <|>- do let retokenize = doMacros 0 *>- (toksToString <$> many (satisfyTok (const True)))+ do let retokenize = toksToString <$> many (satisfyTok (const True)) pstate <- getState let lstate = def{ sOptions = extractReaderOptions pstate , sMacros = extractMacros pstate }@@ -254,6 +263,7 @@ case res of Left e -> fail (show e) Right s' -> return s'+ tokenize :: SourceName -> Text -> [Tok] tokenize sourcename = totoks (initialPos sourcename) @@ -367,10 +377,10 @@ toksToString = T.unpack . untokenize satisfyTok :: PandocMonad m => (Tok -> Bool) -> LP m Tok-satisfyTok f =- try $ do+satisfyTok f = do+ doMacros -- apply macros on remaining input stream res <- tokenPrim (T.unpack . untoken) updatePos matcher- doMacros 0 -- apply macros on remaining input stream+ updateState $ \st -> st{ sExpanded = False } return res where matcher t | f t = Just t | otherwise = Nothing@@ -378,83 +388,98 @@ updatePos _spos _ (Tok pos _ _ : _) = pos updatePos spos _ [] = incSourceColumn spos 1 -doMacros :: PandocMonad m => Int -> LP m ()-doMacros n = do+doMacros :: PandocMonad m => LP m ()+doMacros = do+ expanded <- sExpanded <$> getState verbatimMode <- sVerbatimMode <$> getState- unless verbatimMode $ do- inp <- getInput- case inp of- Tok spos (CtrlSeq "begin") _ : Tok _ Symbol "{" :- Tok _ Word name : Tok _ Symbol "}" : ts- -> handleMacros spos name ts- Tok spos (CtrlSeq "end") _ : Tok _ Symbol "{" :- Tok _ Word name : Tok _ Symbol "}" : ts- -> handleMacros spos ("end" <> name) ts- Tok _ (CtrlSeq "expandafter") _ : t : ts- -> do setInput ts- doMacros n- getInput >>= setInput . combineTok t- Tok spos (CtrlSeq name) _ : ts- -> handleMacros spos name ts- _ -> return ()- where combineTok (Tok spos (CtrlSeq name) x) (Tok _ Word w : ts)- | T.all isLetterOrAt w =- Tok spos (CtrlSeq (name <> w)) (x1 <> w <> x2) : ts- where (x1, x2) = T.break isSpaceOrTab x- combineTok t ts = t:ts- handleMacros spos name ts = do- macros <- sMacros <$> getState- case M.lookup name macros of- Nothing -> return ()- Just (Macro expansionPoint argspecs optarg newtoks) -> do- setInput ts- let matchTok (Tok _ toktype txt) =- satisfyTok (\(Tok _ toktype' txt') ->- toktype == toktype' &&- txt == txt')- let matchPattern toks = try $ mapM_ matchTok toks- let getargs argmap [] = return argmap- getargs argmap (Pattern toks : rest) = try $ do- matchPattern toks- getargs argmap rest- getargs argmap (ArgNum i : Pattern toks : rest) =- try $ do- x <- mconcat <$> manyTill- (braced <|> ((:[]) <$> anyTok))- (matchPattern toks)- getargs (M.insert i x argmap) rest- getargs argmap (ArgNum i : rest) = do- x <- try $ spaces >> bracedOrToken- getargs (M.insert i x argmap) rest- args <- case optarg of- Nothing -> getargs M.empty argspecs- Just o -> do- x <- option o bracketedToks- getargs (M.singleton 1 x) argspecs- -- first boolean param is true if we're tokenizing- -- an argument (in which case we don't want to- -- expand #1 etc.)- let addTok False (Tok _ (Arg i) _) acc =- case M.lookup i args of- Nothing -> mzero- Just xs -> foldr (addTok True) acc xs- -- see #4007- addTok _ (Tok _ (CtrlSeq x) txt)- acc@(Tok _ Word _ : _)- | not (T.null txt) &&- isLetter (T.last txt) =- Tok spos (CtrlSeq x) (txt <> " ") : acc- addTok _ t acc = setpos spos t : acc- ts' <- getInput- setInput $ foldr (addTok False) ts' newtoks- case expansionPoint of- ExpandWhenUsed ->- if n > 20 -- detect macro expansion loops- then throwError $ PandocMacroLoop (T.unpack name)- else doMacros (n + 1)- ExpandWhenDefined -> return ()+ unless (expanded || verbatimMode) $ do+ getInput >>= doMacros' 1 >>= setInput+ updateState $ \st -> st{ sExpanded = True } +doMacros' :: PandocMonad m => Int -> [Tok] -> LP m [Tok]+doMacros' n inp = do+ case inp of+ Tok spos (CtrlSeq "begin") _ : Tok _ Symbol "{" :+ Tok _ Word name : Tok _ Symbol "}" : ts+ -> handleMacros n spos name ts+ Tok spos (CtrlSeq "end") _ : Tok _ Symbol "{" :+ Tok _ Word name : Tok _ Symbol "}" : ts+ -> handleMacros n spos ("end" <> name) ts+ Tok _ (CtrlSeq "expandafter") _ : t : ts+ -> combineTok t <$> doMacros' n ts+ Tok spos (CtrlSeq name) _ : ts+ -> handleMacros n spos name ts+ _ -> return inp+ <|> return inp + where+ combineTok (Tok spos (CtrlSeq name) x) (Tok _ Word w : ts)+ | T.all isLetterOrAt w =+ Tok spos (CtrlSeq (name <> w)) (x1 <> w <> x2) : ts+ where (x1, x2) = T.break isSpaceOrTab x+ combineTok t ts = t:ts++ matchTok (Tok _ toktype txt) =+ satisfyTok (\(Tok _ toktype' txt') ->+ toktype == toktype' &&+ txt == txt')++ matchPattern toks = try $ mapM_ matchTok toks++ getargs argmap [] = return argmap+ getargs argmap (Pattern toks : rest) = try $ do+ matchPattern toks+ getargs argmap rest+ getargs argmap (ArgNum i : Pattern toks : rest) =+ try $ do+ x <- mconcat <$> manyTill (braced <|> ((:[]) <$> anyTok))+ (matchPattern toks)+ getargs (M.insert i x argmap) rest+ getargs argmap (ArgNum i : rest) = do+ x <- try $ spaces >> bracedOrToken+ getargs (M.insert i x argmap) rest++ addTok False args spos (Tok _ (Arg i) _) acc =+ case M.lookup i args of+ Nothing -> mzero+ Just xs -> foldr (addTok True args spos) acc xs+ -- see #4007+ addTok _ _ spos (Tok _ (CtrlSeq x) txt)+ acc@(Tok _ Word _ : _)+ | not (T.null txt)+ , isLetter (T.last txt) =+ Tok spos (CtrlSeq x) (txt <> " ") : acc+ addTok _ _ spos t acc = setpos spos t : acc++ handleMacros n' spos name ts = do+ when (n' > 20) -- detect macro expansion loops+ $ throwError $ PandocMacroLoop (T.unpack name)+ macros <- sMacros <$> getState+ case M.lookup name macros of+ Nothing -> mzero+ Just (Macro expansionPoint argspecs optarg newtoks) -> do+ let getargs' = do+ args <- case optarg of+ Nothing -> getargs M.empty argspecs+ Just o -> do+ x <- option o bracketedToks+ getargs (M.singleton 1 x) 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 " +++ T.unpack name+ Right (args, rest) -> do+ -- first boolean param is true if we're tokenizing+ -- an argument (in which case we don't want to+ -- expand #1 etc.)+ let result = foldr (addTok False args spos) rest newtoks+ case expansionPoint of+ ExpandWhenUsed -> doMacros' (n' + 1) result+ ExpandWhenDefined -> return result+ setpos :: SourcePos -> Tok -> Tok setpos spos (Tok _ tt txt) = Tok spos tt txt @@ -475,6 +500,10 @@ isWordTok :: Tok -> Bool isWordTok (Tok _ Word _) = True isWordTok _ = False++isArgTok :: Tok -> Bool+isArgTok (Tok _ (Arg _) _) = True+isArgTok _ = False spaces :: PandocMonad m => LP m () spaces = skipMany (satisfyTok (tokTypeIn [Comment, Spaces, Newline]))
@@ -0,0 +1,522 @@+{-# LANGUAGE FlexibleContexts #-}++{-+ Copyright (C) 2018 Yan Pashkovsky <yanp.bugz@gmail.com>+ and John MacFarlane++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++-}++{- |+ Module : Text.Pandoc.Readers.Man+ Copyright : Copyright (C) 2018 Yan Pashkovsky and John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : Yan Pashkovsky <yanp.bugz@gmail.com>+ Stability : WIP+ Portability : portable++Conversion of man to 'Pandoc' document.+-}+module Text.Pandoc.Readers.Man (readMan) where++import Prelude+import Data.Char (toLower)+import Data.Default (Default)+import Control.Monad (liftM, mzero, guard, void)+import Control.Monad.Trans (lift)+import Control.Monad.Except (throwError)+import Text.Pandoc.Class (PandocMonad(..), report)+import Data.Maybe (catMaybes, isJust)+import Data.List (intersperse, intercalate)+import qualified Data.Text as T+import Text.Pandoc.Builder as B+import Text.Pandoc.Error (PandocError (PandocParsecError))+import Text.Pandoc.Logging (LogMessage(..))+import Text.Pandoc.Options+import Text.Pandoc.Parsing+import Text.Pandoc.Walk (query)+import Text.Pandoc.Shared (crFilter)+import Text.Pandoc.Readers.Roff -- TODO explicit imports+import Text.Parsec hiding (tokenPrim)+import qualified Text.Parsec as Parsec+import Text.Parsec.Pos (updatePosString, initialPos)+import qualified Data.Foldable as Foldable++data ManState = ManState { readerOptions :: ReaderOptions+ , metadata :: Meta+ , tableCellsPlain :: Bool+ } deriving Show++instance Default ManState where+ def = ManState { readerOptions = def+ , metadata = nullMeta+ , tableCellsPlain = True }++type ManParser m = ParserT [RoffToken] ManState m+++-- | Read man (troff) from an input string and return a Pandoc document.+readMan :: PandocMonad m => ReaderOptions -> T.Text -> m Pandoc+readMan opts txt = do+ tokenz <- lexRoff (initialPos "input") (crFilter txt)+ let state = def {readerOptions = opts} :: ManState+ eitherdoc <- readWithMTokens parseMan state+ (Foldable.toList . unRoffTokens $ tokenz)+ either throwError return eitherdoc++readWithMTokens :: PandocMonad m+ => ParserT [RoffToken] ManState m a -- ^ parser+ -> ManState -- ^ initial state+ -> [RoffToken] -- ^ input+ -> m (Either PandocError a)+readWithMTokens parser state input =+ let leftF = PandocParsecError . intercalate "\n" $ show <$> input+ in mapLeft leftF `liftM` runParserT parser state "source" input++mapLeft :: (a -> c) -> Either a b -> Either c b+mapLeft f (Left x) = Left $ f x+mapLeft _ (Right r) = Right r+++parseMan :: PandocMonad m => ManParser m Pandoc+parseMan = do+ bs <- many parseBlock <* eof+ meta <- metadata <$> getState+ let (Pandoc _ blocks) = doc $ mconcat bs+ return $ Pandoc meta blocks++parseBlock :: PandocMonad m => ManParser m Blocks+parseBlock = choice [ parseList+ , parseDefinitionList+ , parseHeader+ , parseTable+ , parseTitle+ , parseCodeBlock+ , parseBlockQuote+ , parseNewParagraph+ , parsePara+ , skipUnkownMacro+ ]++parseTable :: PandocMonad m => ManParser m Blocks+parseTable = do+ modifyState $ \st -> st { tableCellsPlain = True }+ let isTbl (Tbl{}) = True+ isTbl _ = False+ Tbl _opts rows pos <- msatisfy isTbl+ case rows of+ ((as,_):_) -> try (do+ let as' = map (columnTypeToAlignment . columnType) as+ guard $ all isJust as'+ let alignments = catMaybes as'+ let (headerRow', bodyRows') =+ case rows of+ (h:x:bs)+ | isHrule x -> (h, bs)+ _ -> (([],[]), rows)+ headerRow <- mapM parseTableCell $ snd headerRow'+ bodyRows <- mapM (mapM parseTableCell . snd) bodyRows'+ isPlainTable <- tableCellsPlain <$> getState+ let widths = if isPlainTable+ then repeat 0.0+ else repeat ((1.0 / fromIntegral (length alignments))+ :: Double)+ return $ B.table mempty (zip alignments widths)+ headerRow bodyRows) <|> fallback pos+ [] -> fallback pos++ where++ parseTableCell ts = do+ st <- getState+ let ts' = Foldable.toList $ unRoffTokens ts+ let plaintcell = try $ do+ skipMany memptyLine+ plain . trimInlines <$> (parseInlines <* eof)+ let blockstcell = try $ do+ skipMany memptyLine+ mconcat <$> many parseBlock <* eof+ res <- if null ts'+ then return $ Right mempty+ else lift $ readWithMTokens plaintcell st ts'+ case res of+ Left _ -> do+ res' <- lift $ readWithMTokens blockstcell st ts'+ case res' of+ Left _ -> fail "Could not parse table cell"+ Right x -> do+ modifyState $ \s -> s{ tableCellsPlain = False }+ return x+ Right x -> return x++ isHrule :: TableRow -> Bool+ isHrule ([cellfmt], _) = columnType cellfmt `elem` ['_','-','=']+ isHrule (_, [RoffTokens ss]) =+ case Foldable.toList ss of+ [TextLine [RoffStr [c]]] -> c `elem` ['_','-','=']+ _ -> False+ isHrule _ = False++ fallback pos = do+ report $ SkippedContent "TABLE" pos+ return $ B.para (B.text "TABLE")++ columnTypeToAlignment :: Char -> Maybe Alignment+ columnTypeToAlignment c =+ case toLower c of+ 'a' -> Just AlignLeft+ 'c' -> Just AlignCenter+ 'l' -> Just AlignLeft+ 'n' -> Just AlignRight+ 'r' -> Just AlignRight+ _ -> Nothing+++parseNewParagraph :: PandocMonad m => ManParser m Blocks+parseNewParagraph = do+ mmacro "P" <|> mmacro "PP" <|> mmacro "LP" <|> memptyLine+ return mempty++--+-- Parser: [RoffToken] -> Pandoc+--++msatisfy :: Monad m => (RoffToken -> Bool) -> ParserT [RoffToken] st m RoffToken+msatisfy predic = tokenPrim show nextPos testTok+ where+ testTok t = if predic t then Just t else Nothing+ nextPos _pos _x (ControlLine _ _ pos':_) = pos'+ nextPos pos _x _xs = updatePosString+ (setSourceColumn+ (setSourceLine pos $ sourceLine pos + 1) 1) ""++mtoken :: PandocMonad m => ManParser m RoffToken+mtoken = msatisfy (const True)++mline :: PandocMonad m => ManParser m RoffToken+mline = msatisfy isTextLine where+ isTextLine (TextLine _) = True+ isTextLine _ = False++memptyLine :: PandocMonad m => ManParser m RoffToken+memptyLine = msatisfy isEmptyLine where+ isEmptyLine EmptyLine = True+ isEmptyLine _ = False++mmacro :: PandocMonad m => String -> ManParser m RoffToken+mmacro mk = msatisfy isControlLine where+ isControlLine (ControlLine mk' _ _) | mk == mk' = True+ | otherwise = False+ isControlLine _ = False++mmacroAny :: PandocMonad m => ManParser m RoffToken+mmacroAny = msatisfy isControlLine where+ isControlLine ControlLine{} = True+ isControlLine _ = False++--+-- RoffToken -> Block functions+--++parseTitle :: PandocMonad m => ManParser m Blocks+parseTitle = do+ (ControlLine _ args _) <- mmacro "TH"+ let adjustMeta =+ case args of+ (x:y:z:_) -> setMeta "title" (linePartsToInlines x) .+ setMeta "section" (linePartsToInlines y) .+ setMeta "date" (linePartsToInlines z)+ [x,y] -> setMeta "title" (linePartsToInlines x) .+ setMeta "section" (linePartsToInlines y)+ [x] -> setMeta "title" (linePartsToInlines x)+ [] -> id+ modifyState $ \st -> st{ metadata = adjustMeta $ metadata st }+ return mempty++linePartsToInlines :: [LinePart] -> Inlines+linePartsToInlines = go False++ where+ go :: Bool -> [LinePart] -> Inlines+ go _ [] = mempty+ go mono (MacroArg _:xs) = go mono xs -- shouldn't happen+ go mono (RoffStr s : RoffStr t : xs) = go mono (RoffStr (s <> t):xs)+ go mono (RoffStr s : xs)+ | mono = code s <> go mono xs+ | otherwise = text s <> go mono xs+ go mono (Font fs: xs) =+ if litals > 0 && litals >= lbolds && litals >= lmonos+ then emph (go mono (Font fs{ fontItalic = False } :+ map (adjustFontSpec (\s -> s{ fontItalic = False }))+ itals)) <>+ go mono italsrest+ else if lbolds > 0 && lbolds >= lmonos+ then strong (go mono (Font fs{ fontBold = False } :+ map (adjustFontSpec (\s -> s{ fontBold = False }))+ bolds)) <>+ go mono boldsrest+ else if lmonos > 0+ then go True (Font fs{ fontMonospace = False } :+ map (adjustFontSpec (\s -> s { fontMonospace = False }))+ monos) <> go mono monosrest+ else go mono xs+ where+ adjustFontSpec f (Font fspec) = Font (f fspec)+ adjustFontSpec _ x = x+ withFont f (Font fspec) = f fspec+ withFont _ _ = False+ litals = length itals+ lbolds = length bolds+ lmonos = length monos+ (itals, italsrest) =+ if fontItalic fs+ then break (withFont (not . fontItalic)) xs+ else ([], xs)+ (bolds, boldsrest) =+ if fontBold fs+ then break (withFont (not . fontBold)) xs+ else ([], xs)+ (monos, monosrest) =+ if fontMonospace fs+ then break (withFont (not . fontMonospace)) xs+ else ([], xs)++parsePara :: PandocMonad m => ManParser m Blocks+parsePara = para . trimInlines <$> parseInlines++parseInlines :: PandocMonad m => ManParser m Inlines+parseInlines = mconcat . intersperse B.space <$> many1 parseInline++parseInline :: PandocMonad m => ManParser m Inlines+parseInline = try $ do+ tok <- mtoken+ case tok of+ TextLine lparts -> return $ linePartsToInlines lparts+ ControlLine mname args pos -> handleInlineMacro mname args pos+ _ -> mzero++handleInlineMacro :: PandocMonad m+ => String -> [Arg] -> SourcePos -> ManParser m Inlines+handleInlineMacro mname args _pos = do+ case mname of+ "UR" -> parseLink args+ "MT" -> parseEmailLink args+ "B" -> parseBold args+ "I" -> parseItalic args+ "br" -> return linebreak+ "BI" -> parseAlternatingFonts [strong, emph] args+ "IB" -> parseAlternatingFonts [emph, strong] args+ "IR" -> parseAlternatingFonts [emph, id] args+ "RI" -> parseAlternatingFonts [id, emph] args+ "BR" -> parseAlternatingFonts [strong, id] args+ "RB" -> parseAlternatingFonts [id, strong] args+ "SY" -> return $ strong $ mconcat $ intersperse B.space+ $ map linePartsToInlines args+ "YS" -> return mempty+ "OP" -> case args of+ (x:ys) -> return $ B.space <> str "[" <> B.space <>+ mconcat (strong (linePartsToInlines x) :+ map ((B.space <>) . linePartsToInlines) ys)+ <> B.space <> str "]"+ [] -> return mempty+ _ -> mzero++parseBold :: PandocMonad m => [Arg] -> ManParser m Inlines+parseBold [] = do+ TextLine lparts <- mline+ return $ strong $ linePartsToInlines lparts+parseBold args = return $+ strong $ mconcat $ intersperse B.space $ map linePartsToInlines args++parseItalic :: PandocMonad m => [Arg] -> ManParser m Inlines+parseItalic [] = do+ TextLine lparts <- mline+ return $ emph $ linePartsToInlines lparts+parseItalic args = return $+ emph $ mconcat $ intersperse B.space $ map linePartsToInlines args++parseAlternatingFonts :: PandocMonad m+ => [Inlines -> Inlines]+ -> [Arg]+ -> ManParser m Inlines+parseAlternatingFonts constructors args = return $ mconcat $+ zipWith (\f arg -> f (linePartsToInlines arg)) (cycle constructors) args++lineInl :: PandocMonad m => ManParser m Inlines+lineInl = do+ (TextLine fragments) <- mline+ return $ linePartsToInlines fragments++bareIP :: PandocMonad m => ManParser m RoffToken+bareIP = msatisfy isBareIP where+ isBareIP (ControlLine "IP" [] _) = True+ isBareIP _ = False++endmacro :: PandocMonad m => String -> ManParser m ()+endmacro name = void (mmacro name)+ <|> lookAhead (void newBlockMacro)+ <|> lookAhead eof+ where+ newBlockMacro = msatisfy isNewBlockMacro+ isNewBlockMacro (ControlLine "SH" _ _) = True+ isNewBlockMacro (ControlLine "SS" _ _) = True+ isNewBlockMacro _ = False++parseCodeBlock :: PandocMonad m => ManParser m Blocks+parseCodeBlock = try $ do+ optional bareIP+ optional (mmacro "in") -- some people indent their code+ toks <- (mmacro "nf" *> manyTill codeline (endmacro "fi"))+ <|> (mmacro "EX" *> manyTill codeline (endmacro "EE"))+ optional (mmacro "in")+ return $ codeBlock (intercalate "\n" $ catMaybes toks)++ where++ codeline = do+ tok <- mtoken+ case tok of+ 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+ return Nothing+ Tbl _ _ pos -> do+ report $ SkippedContent "TABLE" pos+ return $ Just "TABLE"+ EmptyLine -> return $ Just ""+ TextLine ss+ | not (null ss)+ , all isFontToken ss -> return Nothing+ | otherwise -> return $ Just $ linePartsToString ss++ isFontToken Font{} = True+ isFontToken _ = False++ getText :: Inline -> String+ getText (Str s) = s+ getText Space = " "+ getText (Code _ s) = s+ getText SoftBreak = "\n"+ getText LineBreak = "\n"+ getText _ = ""++parseHeader :: PandocMonad m => ManParser m Blocks+parseHeader = do+ ControlLine name args _ <- mmacro "SH" <|> mmacro "SS"+ contents <- if null args+ then option mempty lineInl+ else return $ mconcat $ intersperse B.space+ $ map linePartsToInlines args+ let lvl = if name == "SH" then 1 else 2+ return $ header lvl contents++parseBlockQuote :: PandocMonad m => ManParser m Blocks+parseBlockQuote = blockQuote <$> continuation++data ListType = Ordered ListAttributes+ | Bullet++listTypeMatches :: Maybe ListType -> ListType -> Bool+listTypeMatches Nothing _ = True+listTypeMatches (Just Bullet) Bullet = True+listTypeMatches (Just (Ordered (_,x,y))) (Ordered (_,x',y'))+ = x == x' && y == y'+listTypeMatches (Just _) _ = False++listItem :: PandocMonad m => Maybe ListType -> ManParser m (ListType, Blocks)+listItem mbListType = try $ do+ (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 lt = case Parsec.runParser anyOrderedListMarker defaultParserState+ "list marker" cs' of+ Right (start, listtype, listdelim)+ | cs == cs' -> Ordered (start, listtype, listdelim)+ | otherwise -> Ordered (start, listtype, DefaultDelim)+ Left _ -> Bullet+ guard $ listTypeMatches mbListType lt+ inls <- option mempty parseInlines+ continuations <- mconcat <$> many continuation+ return (lt, para inls <> continuations)+ [] -> mzero++parseList :: PandocMonad m => ManParser m Blocks+parseList = try $ do+ (lt, x) <- listItem Nothing+ xs <- map snd <$> many (listItem (Just lt))+ return $ case lt of+ Bullet -> bulletList (x:xs)+ Ordered lattr -> orderedListWith lattr (x:xs)++continuation :: PandocMonad m => ManParser m Blocks+continuation =+ mconcat <$> (mmacro "RS" *> manyTill parseBlock (endmacro "RE"))+ <|> mconcat <$> many1 ( try (bareIP *> parsePara)+ <|> try (bareIP *> parseCodeBlock)+ )++definitionListItem :: PandocMonad m+ => ManParser m (Inlines, [Blocks])+definitionListItem = try $ do+ mmacro "TP" -- args specify indent level, can ignore+ term <- parseInline+ moreterms <- many $ try $ do+ mmacro "TQ"+ parseInline+ inls <- option mempty parseInlines+ continuations <- mconcat <$> many continuation+ return ( mconcat (intersperse B.linebreak (term:moreterms))+ , [para inls <> continuations])++parseDefinitionList :: PandocMonad m => ManParser m Blocks+parseDefinitionList = definitionList <$> many1 definitionListItem++parseLink :: PandocMonad m => [Arg] -> ManParser m Inlines+parseLink args = do+ contents <- mconcat <$> many lineInl+ ControlLine _ endargs _ <- mmacro "UE"+ let url = case args of+ [] -> ""+ (x:_) -> linePartsToString x+ return $ link url "" contents <>+ case endargs of+ [] -> mempty+ (x:_) -> linePartsToInlines x++parseEmailLink :: PandocMonad m => [Arg] -> ManParser m Inlines+parseEmailLink args = do+ contents <- mconcat <$> many lineInl+ ControlLine _ endargs _ <- mmacro "ME"+ let url = case args of+ [] -> ""+ (x:_) -> "mailto:" ++ linePartsToString x+ return $ link url "" contents <>+ case endargs of+ [] -> mempty+ (x:_) -> linePartsToInlines x++skipUnkownMacro :: PandocMonad m => ManParser m Blocks+skipUnkownMacro = do+ tok <- mmacroAny+ case tok of+ ControlLine mkind _ pos -> do+ report $ SkippedContent ('.':mkind) pos+ return mempty+ _ -> fail "the impossible happened"
@@ -1586,6 +1586,7 @@ <|> try (do lookAhead $ char '\\' notFollowedBy' (() <$ rawTeXBlock) char '\\')+ updateLastStrPos return $ return $ B.str [result] -- parses inline code, between n `s and n `s@@ -1632,7 +1633,7 @@ 3 -> three c 2 -> two c mempty 1 -> one c mempty- _ -> return (return $ B.str cs)+ _ -> updateLastStrPos >> return (return $ B.str cs) ender :: PandocMonad m => Char -> Int -> MarkdownParser m () ender c n = try $ do@@ -1716,19 +1717,24 @@ str :: PandocMonad m => MarkdownParser m (F Inlines) str = do+ canRelocateSpace <- notAfterString result <- many1 (alphaNum <|> try (char '.' <* notFollowedBy (char '.'))) updateLastStrPos (do guardEnabled Ext_smart abbrevs <- getOption readerAbbreviations if not (null result) && last result == '.' && result `Set.member` abbrevs then try (do ils <- whitespace <|> endline- lookAhead alphaNum+ -- ?? lookAhead alphaNum+ -- replace space after with nonbreaking space+ -- if softbreak, move before abbrev if possible (#4635) return $ do ils' <- ils- if ils' == B.space- then return (B.str result <> B.str "\160")- else -- linebreak or softbreak- return (ils' <> B.str result <> B.str "\160"))+ case B.toList ils' of+ [Space] ->+ return (B.str result <> B.str "\160")+ [SoftBreak] | canRelocateSpace ->+ return (ils' <> B.str result <> B.str "\160")+ _ -> return (B.str result <> ils')) <|> return (return (B.str result)) else return (return (B.str result))) <|> return (return (B.str result))
@@ -32,7 +32,6 @@ -} {- TODO:-- Page breaks (five "*") - Org tables - table.el tables - <cite> tag@@ -41,17 +40,16 @@ import Prelude import Control.Monad+import Control.Monad.Reader import Control.Monad.Except (throwError) import Data.Bifunctor-import Data.Char (isAlphaNum) import Data.Default-import Data.List (intercalate)+import Data.List (intercalate, transpose, uncons) import Data.List.Split (splitOn) import qualified Data.Map as M import qualified Data.Set as Set import Data.Maybe (fromMaybe, isNothing, maybeToList) import Data.Text (Text, unpack)-import Text.HTML.TagSoup import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad (..))@@ -59,8 +57,8 @@ import Text.Pandoc.Error (PandocError (PandocParsecError)) import Text.Pandoc.Logging import Text.Pandoc.Options-import Text.Pandoc.Parsing hiding (F, enclosed)-import Text.Pandoc.Shared (crFilter, underlineSpan, mapLeft)+import Text.Pandoc.Parsing hiding (F)+import Text.Pandoc.Shared (crFilter, underlineSpan) -- | Read Muse from an input string and return a Pandoc document. readMuse :: PandocMonad m@@ -69,9 +67,9 @@ -> m Pandoc readMuse opts s = do let input = crFilter s- res <- mapLeft (PandocParsecError $ unpack input) `liftM` runParserT parseMuse def{ museOptions = opts } "source" input+ res <- flip runReaderT def $ runParserT parseMuse def{ museOptions = opts } "source" input case res of- Left e -> throwError e+ Left e -> throwError $ PandocParsecError (unpack input) e Right d -> return d type F = Future MuseState@@ -80,11 +78,10 @@ , museOptions :: ReaderOptions , museHeaders :: M.Map Inlines String -- ^ List of headers and ids (used for implicit ref links) , museIdentifierList :: Set.Set String+ , 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)- , museInLink :: Bool -- ^ True when parsing a link description to avoid nested links- , museInPara :: Bool -- ^ True when looking for a paragraph terminator } instance Default MuseState where@@ -93,14 +90,23 @@ , museHeaders = M.empty , museIdentifierList = Set.empty , museLastStrPos = Nothing+ , museLastSpacePos = Nothing , museLogMessages = [] , museNotes = M.empty- , museInLink = False- , museInPara = False } -type MuseParser = ParserT Text MuseState+data MuseEnv =+ MuseEnv { museInLink :: Bool -- ^ True when parsing a link description to avoid nested links+ , museInPara :: Bool -- ^ True when parsing paragraph is not allowed+ } +instance Default MuseEnv where+ def = MuseEnv { museInLink = False+ , museInPara = False+ }++type MuseParser m = ParserT Text MuseState (ReaderT MuseEnv m)+ instance HasReaderOptions MuseState where extractReaderOptions = museOptions @@ -120,29 +126,21 @@ addLogMessage m s = s{ museLogMessages = m : museLogMessages s } getLogMessages = reverse . museLogMessages +updateLastSpacePos :: Monad m => MuseParser m ()+updateLastSpacePos = getPosition >>= \pos ->+ updateState $ \s -> s { museLastSpacePos = Just pos }+ -- | Parse Muse document parseMuse :: PandocMonad m => MuseParser m Pandoc parseMuse = do many directive- firstSection <- parseBlocks- rest <- many parseSection- let blocks = mconcat (firstSection : rest)+ blocks <- (:) <$> parseBlocks <*> many parseSection+ eof st <- getState- let doc = runF (do Pandoc _ bs <- B.doc <$> blocks- meta <- museMeta st- return $ Pandoc meta bs) st- reportLogMessages- return doc+ runF (Pandoc <$> museMeta st <*> fmap B.toList (mconcat blocks)) st <$ reportLogMessages -- * Utility functions -commonPrefix :: String -> String -> String-commonPrefix _ [] = []-commonPrefix [] _ = []-commonPrefix (x:xs) (y:ys)- | x == y = x : commonPrefix xs ys- | otherwise = []- -- | Trim up to one newline from the beginning of the string. lchop :: String -> String lchop ('\n':xs) = xs@@ -152,19 +150,27 @@ rchop :: String -> String rchop = reverse . lchop . reverse +unindent :: String -> String+unindent = rchop . intercalate "\n" . dropSpacePrefix . splitOn "\n" . lchop+ dropSpacePrefix :: [String] -> [String]-dropSpacePrefix lns =- map (drop maxIndent) lns- where flns = filter (not . all (== ' ')) lns- maxIndent = if null flns then maximum (map length lns) else length $ takeWhile (== ' ') $ foldl1 commonPrefix flns+dropSpacePrefix lns = drop maxIndent <$> lns+ where isSpaceChar c = c == ' ' || c == '\t'+ maxIndent = length $ takeWhile (isSpaceChar . head) $ takeWhile same $ transpose lns+ same = and . (zipWith (==) <*> drop 1) -atStart :: PandocMonad m => MuseParser m a -> MuseParser m a-atStart p = do+atStart :: PandocMonad m => MuseParser m ()+atStart = do pos <- getPosition st <- getState guard $ museLastStrPos st /= Just pos- p +noSpaceBefore :: PandocMonad m => MuseParser m ()+noSpaceBefore = do+ pos <- getPosition+ st <- getState+ guard $ museLastSpacePos st /= Just pos+ firstColumn :: PandocMonad m => MuseParser m () firstColumn = getPosition >>= \pos -> guard (sourceColumn pos == 1) @@ -174,11 +180,9 @@ eol :: Stream s m Char => ParserT s st m () eol = void newline <|> eof -someUntil :: (Stream s m t)- => ParserT s u m a- -> ParserT s u m b- -> ParserT s u m ([a], b)-someUntil p end = first <$> ((:) <$> p) <*> manyUntil p end+getIndent :: PandocMonad m+ => MuseParser m Int+getIndent = subtract 1 . sourceColumn <$ many spaceChar <*> getPosition -- ** HTML parsers @@ -196,24 +200,21 @@ closeTag tag = try $ string "</" *> string tag *> void (char '>') -- | Convert HTML attributes to Pandoc 'Attr'-htmlAttrToPandoc :: [Attribute String] -> Attr+htmlAttrToPandoc :: [(String, String)] -> Attr htmlAttrToPandoc attrs = (ident, classes, keyvals) where ident = fromMaybe "" $ lookup "id" attrs classes = maybe [] words $ lookup "class" attrs- keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]+ keyvals = [(k,v) | (k,v) <- attrs, k /= "id", k /= "class"] parseHtmlContent :: PandocMonad m => String -- ^ Tag name -> MuseParser m (Attr, F Blocks)-parseHtmlContent tag = try $ do- many spaceChar- pos <- getPosition- attr <- openTag tag- manyTill spaceChar eol- content <- parseBlocksTill $ try $ count (sourceColumn pos - 1) spaceChar *> closeTag tag- manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline- return (htmlAttrToPandoc attr, content)+parseHtmlContent tag = try $ getIndent >>= \indent -> (,)+ <$> fmap htmlAttrToPandoc (openTag tag)+ <* manyTill spaceChar eol+ <*> allowPara (parseBlocksTill (try $ indentWith indent *> closeTag tag))+ <* manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline -- ** Directive parsers @@ -246,23 +247,25 @@ -- ** Block parsers +allowPara :: MonadReader MuseEnv m => m a -> m a+allowPara p = local (\s -> s { museInPara = False }) p+ -- | Parse section contents until EOF or next header parseBlocks :: PandocMonad m => MuseParser m (F Blocks) parseBlocks = try (parseEnd <|> nextSection <|>- blockStart <|> listStart <|>+ blockStart <|> paraStart) where nextSection = mempty <$ lookAhead headingStart parseEnd = mempty <$ eof blockStart = (B.<>) <$> (blockElements <|> emacsNoteBlock)- <*> parseBlocks- listStart = do- updateState (\st -> st { museInPara = False })- uncurry (B.<>) <$> (anyListUntil parseBlocks <|> amuseNoteBlockUntil parseBlocks)+ <*> allowPara parseBlocks+ listStart =+ uncurry (B.<>) <$> allowPara (anyListUntil parseBlocks <|> amuseNoteBlockUntil parseBlocks) paraStart = do indent <- length <$> many spaceChar uncurry (B.<>) . first (p indent) <$> paraUntil parseBlocks@@ -278,46 +281,36 @@ parseBlocksTill :: PandocMonad m => MuseParser m a -> MuseParser m (F Blocks)-parseBlocksTill end =- try (parseEnd <|>- blockStart <|>- listStart <|>- paraStart)+parseBlocksTill end = continuation where parseEnd = mempty <$ end- blockStart = (B.<>) <$> blockElements <*> continuation- listStart = do- updateState (\st -> st { museInPara = False })- uncurry (B.<>) <$> anyListUntil (parseEnd <|> continuation)+ blockStart = (B.<>) <$> blockElements <*> allowPara continuation+ listStart = uncurry (B.<>) <$> allowPara (anyListUntil (parseEnd <|> continuation)) paraStart = uncurry (B.<>) <$> paraUntil (parseEnd <|> continuation)- continuation = parseBlocksTill end+ continuation = try $ parseEnd <|> listStart <|> blockStart <|> paraStart listItemContentsUntil :: PandocMonad m => Int -> MuseParser m a -> MuseParser m a -> MuseParser m (F Blocks, a)-listItemContentsUntil col pre end =- try blockStart <|>- try listStart <|>- try paraStart+listItemContentsUntil col pre end = p where+ p = try listStart <|> try blockStart <|> try paraStart parsePre = (mempty,) <$> pre parseEnd = (mempty,) <$> end paraStart = do (f, (r, e)) <- paraUntil (parsePre <|> continuation <|> parseEnd) return (f B.<> r, e) blockStart = first <$> ((B.<>) <$> blockElements)- <*> (parsePre <|> continuation <|> parseEnd)+ <*> allowPara (parsePre <|> continuation <|> parseEnd) listStart = do- updateState (\st -> st { museInPara = False })- (f, (r, e)) <- anyListUntil (parsePre <|> continuation <|> parseEnd)+ (f, (r, e)) <- allowPara $ anyListUntil (parsePre <|> continuation <|> parseEnd) return (f B.<> r, e) continuation = try $ do blank <- optionMaybe blankline skipMany blankline indentWith col- updateState (\st -> st { museInPara = museInPara st && isNothing blank })- listItemContentsUntil col pre end+ local (\s -> s { museInPara = museInPara s && isNothing blank }) p parseBlock :: PandocMonad m => MuseParser m (F Blocks) parseBlock = do@@ -327,25 +320,23 @@ where para = fst <$> paraUntil (try (eof <|> void (lookAhead blockElements))) blockElements :: PandocMonad m => MuseParser m (F Blocks)-blockElements = do- updateState (\st -> st { museInPara = False })- choice [ mempty <$ blankline- , comment- , separator- , example- , exampleTag- , literalTag- , centerTag- , rightTag- , quoteTag- , divTag- , biblioTag- , playTag- , verseTag- , lineBlock- , table- , commentTag- ]+blockElements = (mempty <$ blankline)+ <|> comment+ <|> separator+ <|> pagebreak+ <|> example+ <|> exampleTag+ <|> literalTag+ <|> centerTag+ <|> rightTag+ <|> quoteTag+ <|> divTag+ <|> biblioTag+ <|> playTag+ <|> verseTag+ <|> lineBlock+ <|> table+ <|> commentTag -- | Parse a line comment, starting with @;@ in the first column. comment :: PandocMonad m => MuseParser m (F Blocks)@@ -363,6 +354,14 @@ <* many spaceChar <* eol +-- | Parse a page break+pagebreak :: PandocMonad m => MuseParser m (F Blocks)+pagebreak = try $ pure (B.divWith ("", [], [("style", "page-break-before: always;")]) mempty)+ <$ count 6 spaceChar+ <* many spaceChar+ <* string "* * * * *"+ <* manyTill spaceChar eol+ headingStart :: PandocMonad m => MuseParser m (String, Int) headingStart = try $ (,) <$> option "" (try (parseAnchor <* manyTill spaceChar eol))@@ -396,15 +395,15 @@ example :: PandocMonad m => MuseParser m (F Blocks) example = try $ pure . B.codeBlock <$ string "{{{"- <* optional blankline- <*> manyTill anyChar (try (optional blankline *> string "}}}"))+ <* many spaceChar+ <*> (unindent <$> manyTill anyChar (string "}}}")) -- | Parse an @\<example>@ tag. exampleTag :: PandocMonad m => MuseParser m (F Blocks) exampleTag = try $ fmap pure $ B.codeBlockWith <$ many spaceChar <*> (htmlAttrToPandoc <$> openTag "example")- <*> (rchop . intercalate "\n" . dropSpacePrefix . splitOn "\n" . lchop <$> manyTill anyChar (closeTag "example"))+ <*> (unindent <$> manyTill anyChar (closeTag "example")) <* manyTill spaceChar eol -- | Parse a @\<literal>@ tag as a raw block.@@ -414,7 +413,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- <*> (rchop . intercalate "\n" . dropSpacePrefix . splitOn "\n" . lchop <$> manyTill anyChar (closeTag "literal"))+ <*> (unindent <$> manyTill anyChar (closeTag "literal")) <* manyTill spaceChar eol -- | Parse @\<center>@ tag.@@ -441,9 +440,9 @@ -- | Parse @\<biblio>@ tag, the result is the same as @\<div class="biblio">@. -- @\<biblio>@ tag is supported only in Text::Amuse mode. biblioTag :: PandocMonad m => MuseParser m (F Blocks)-biblioTag = do- guardEnabled Ext_amuse- fmap (B.divWith ("", ["biblio"], [])) . snd <$> parseHtmlContent "biblio"+biblioTag = fmap (B.divWith ("", ["biblio"], [])) . snd+ <$ guardEnabled Ext_amuse+ <*> parseHtmlContent "biblio" -- | Parse @\<play>@ tag, the result is the same as @\<div class="play">@. -- @\<play>@ tag is supported only in Text::Amuse mode.@@ -453,22 +452,17 @@ fmap (B.divWith ("", ["play"], [])) . snd <$> parseHtmlContent "play" verseLine :: PandocMonad m => MuseParser m (F Inlines)-verseLine = do- indent <- (B.str <$> many1 ('\160' <$ char ' ')) <|> pure mempty- rest <- manyTill inline' newline- return $ trimInlinesF $ mconcat (pure indent : rest)+verseLine = (<>)+ <$> fmap pure (option mempty (B.str <$> many1 ('\160' <$ char ' ')))+ <*> fmap (trimInlinesF . mconcat) (manyTill inline' eol) -- | Parse @\<verse>@ tag. verseTag :: PandocMonad m => MuseParser m (F Blocks)-verseTag = try $ do- many spaceChar- pos <- getPosition- openTag "verse"- manyTill spaceChar eol- let indent = count (sourceColumn pos - 1) spaceChar- content <- sequence <$> manyTill (indent *> verseLine) (try $ indent *> closeTag "verse")- manyTill spaceChar eol- return $ B.lineBlock <$> content+verseTag = try $ getIndent >>= \indent -> fmap B.lineBlock . sequence+ <$ openTag "verse"+ <* manyTill spaceChar eol+ <*> manyTill (indentWith indent *> verseLine) (try $ indentWith indent *> closeTag "verse")+ <* manyTill spaceChar eol -- | Parse @\<comment>@ tag. commentTag :: PandocMonad m => MuseParser m (F Blocks)@@ -482,19 +476,16 @@ paraContentsUntil :: PandocMonad m => MuseParser m a -- ^ Terminator parser -> MuseParser m (F Inlines, a)-paraContentsUntil end = do- updateState (\st -> st { museInPara = True })- (l, e) <- someUntil inline $ try (manyTill spaceChar eol *> end)- updateState (\st -> st { museInPara = False })- return (trimInlinesF $ mconcat l, e)+paraContentsUntil end = first (trimInlinesF . mconcat)+ <$> manyUntil inline (try (manyTill spaceChar eol *> local (\s -> s { museInPara = True}) end)) -- | Parse a paragraph. paraUntil :: PandocMonad m => MuseParser m a -- ^ Terminator parser -> MuseParser m (F Blocks, a) paraUntil end = do- state <- getState- guard $ not $ museInPara state+ inPara <- asks museInPara+ guard $ not inPara first (fmap B.para) <$> paraContentsUntil end noteMarker :: PandocMonad m => MuseParser m String@@ -503,6 +494,17 @@ <*> oneOf "123456789" <*> manyTill digit (char ']') +addNote :: PandocMonad m+ => String+ -> SourcePos+ -> F Blocks+ -> MuseParser m ()+addNote ref pos content = do+ oldnotes <- museNotes <$> getState+ when (M.member ref oldnotes)+ (logMessage $ DuplicateNoteReference ref pos)+ updateState $ \s -> s{ museNotes = M.insert ref (pos, content) oldnotes }+ -- Amusewiki version of note -- Parsing is similar to list item, except that note marker is used instead of list marker amuseNoteBlockUntil :: PandocMonad m@@ -510,14 +512,11 @@ -> MuseParser m (F Blocks, a) amuseNoteBlockUntil end = try $ do guardEnabled Ext_amuse- ref <- noteMarker <* spaceChar+ ref <- noteMarker pos <- getPosition- updateState (\st -> st { museInPara = False })- (content, e) <- listItemContentsUntil (sourceColumn pos - 1) (fail "x") end- oldnotes <- museNotes <$> getState- when (M.member ref oldnotes)- (logMessage $ DuplicateNoteReference ref pos)- updateState $ \s -> s{ museNotes = M.insert ref (pos, content) oldnotes }+ void spaceChar <|> lookAhead eol+ (content, e) <- allowPara $ listItemContentsUntil (sourceColumn pos) (fail "x") end+ addNote ref pos content return (mempty, e) -- Emacs version of note@@ -525,13 +524,10 @@ emacsNoteBlock :: PandocMonad m => MuseParser m (F Blocks) emacsNoteBlock = try $ do guardDisabled Ext_amuse+ ref <- noteMarker pos <- getPosition- ref <- noteMarker <* skipSpaces- content <- mconcat <$> blocksTillNote- oldnotes <- museNotes <$> getState- when (M.member ref oldnotes)- (logMessage $ DuplicateNoteReference ref pos)- updateState $ \s -> s{ museNotes = M.insert ref (pos, content) oldnotes }+ content <- fmap mconcat blocksTillNote+ addNote ref pos content return mempty where blocksTillNote =@@ -541,26 +537,13 @@ -- Verse markup -- -lineVerseLine :: PandocMonad m => MuseParser m (F Inlines)-lineVerseLine = try $ do- string "> "- indent <- many ('\160' <$ char ' ')- let indentEl = if null indent then mempty else B.str indent- rest <- manyTill inline' eol- return $ trimInlinesF $ mconcat (pure indentEl : rest)--blanklineVerseLine :: PandocMonad m => MuseParser m (F Inlines)-blanklineVerseLine = try $ mempty- <$ char '>'- <* blankline- -- | Parse a line block indicated by @\'>\'@ characters. lineBlock :: PandocMonad m => MuseParser m (F Blocks)-lineBlock = try $ do- many spaceChar- col <- sourceColumn <$> getPosition- lns <- (blanklineVerseLine <|> lineVerseLine) `sepBy1'` try (indentWith (col - 1))- return $ B.lineBlock <$> sequence lns+lineBlock = try $ getIndent >>= \indent -> fmap B.lineBlock . sequence+ <$> (blankVerseLine <|> nonblankVerseLine) `sepBy1'` try (indentWith indent)+ where+ blankVerseLine = try $ mempty <$ char '>' <* blankline+ nonblankVerseLine = try (string "> ") *> verseLine -- *** List parsers @@ -571,8 +554,7 @@ bulletListItemsUntil indent end = try $ do char '-' void spaceChar <|> lookAhead eol- updateState (\st -> st { museInPara = False })- (x, (xs, e)) <- listItemContentsUntil (indent + 2) (try (optional blankline *> indentWith indent *> bulletListItemsUntil indent end)) (([],) <$> end)+ (x, (xs, e)) <- allowPara $ listItemContentsUntil (indent + 2) (try (optional blankline *> indentWith indent *> bulletListItemsUntil indent end)) (([],) <$> end) return (x:xs, e) -- | Parse a bullet list.@@ -580,12 +562,9 @@ => MuseParser m a -> MuseParser m (F Blocks, a) bulletListUntil end = try $ do- many spaceChar- pos <- getPosition- let indent = sourceColumn pos - 1+ indent <- getIndent guard $ indent /= 0- (items, e) <- bulletListItemsUntil indent end- return (B.bulletList <$> sequence items, e)+ first (fmap B.bulletList . sequence) <$> bulletListItemsUntil indent end museOrderedListMarker :: PandocMonad m => ListNumberStyle@@ -611,8 +590,7 @@ continuation = try $ do pos <- getPosition void spaceChar <|> lookAhead eol- updateState (\st -> st { museInPara = False })- (x, (xs, e)) <- listItemContentsUntil (sourceColumn pos) (try (optional blankline *> indentWith indent *> museOrderedListMarker style *> continuation)) (([],) <$> end)+ (x, (xs, e)) <- allowPara $ listItemContentsUntil (sourceColumn pos) (try (optional blankline *> indentWith indent *> museOrderedListMarker style *> continuation)) (([],) <$> end) return (x:xs, e) -- | Parse an ordered list.@@ -620,9 +598,7 @@ => MuseParser m a -> MuseParser m (F Blocks, a) orderedListUntil end = try $ do- many spaceChar- pos <- getPosition- let indent = sourceColumn pos - 1+ indent <- getIndent guard $ indent /= 0 (style, start) <- decimal <|> lowerRoman <|> upperRoman <|> lowerAlpha <|> upperAlpha char '.'@@ -635,8 +611,7 @@ -> MuseParser m ([F Blocks], a) descriptionsUntil indent end = do void spaceChar <|> lookAhead eol- updateState (\st -> st { museInPara = False })- (x, (xs, e)) <- listItemContentsUntil indent (try (optional blankline *> indentWith indent *> manyTill spaceChar (string "::") *> descriptionsUntil indent end)) (([],) <$> end)+ (x, (xs, e)) <- allowPara $ listItemContentsUntil indent (try (optional blankline *> indentWith indent *> manyTill spaceChar (string "::") *> descriptionsUntil indent end)) (([],) <$> end) return (x:xs, e) definitionListItemsUntil :: PandocMonad m@@ -658,9 +633,7 @@ => MuseParser m a -- ^ Terminator parser -> MuseParser m (F Blocks, a) definitionListUntil end = try $ do- many spaceChar- pos <- getPosition- let indent = sourceColumn pos - 1+ indent <- getIndent guardDisabled Ext_amuse <|> guard (indent /= 0) -- Initial space is required by Amusewiki, but not Emacs Muse first (fmap B.definitionList . sequence) <$> definitionListItemsUntil indent end @@ -687,11 +660,9 @@ museToPandocTable :: MuseTable -> Blocks museToPandocTable (MuseTable caption headers body footers) =- B.table caption attrs headRow rows- where ncol = maximum (0 : map length (headers ++ body ++ footers))- attrs = replicate ncol (AlignDefault, 0.0)- headRow = if null headers then [] else head headers- rows = (if null headers then [] else tail headers) ++ body ++ footers+ B.table caption attrs headRow (rows ++ body ++ footers)+ where attrs = const (AlignDefault, 0.0) <$> transpose (headers ++ body ++ footers)+ (headRow, rows) = fromMaybe ([], []) $ uncons headers museAppendElement :: MuseTableElement -> MuseTable@@ -703,12 +674,8 @@ MuseFooterRow row -> tbl{ museTableFooters = row : museTableFooters tbl } MuseCaption inlines -> tbl{ museTableCaption = inlines } -tableCell :: PandocMonad m => MuseParser m (F Blocks)-tableCell = try $ fmap B.plain . trimInlinesF . mconcat <$> manyTill inline (lookAhead cellEnd)- where cellEnd = try $ void (many1 spaceChar *> char '|') <|> eol- tableElements :: PandocMonad m => MuseParser m (F [MuseTableElement])-tableElements = sequence <$> (tableParseElement `sepEndBy1` eol)+tableElements = sequence <$> many1 tableParseElement elementsToTable :: [MuseTableElement] -> MuseTable elementsToTable = foldr museAppendElement emptyTable@@ -727,10 +694,10 @@ tableParseRow :: PandocMonad m => Int -- ^ Number of separator characters -> MuseParser m (F [Blocks])-tableParseRow n = try $- sequence <$> (tableCell `sepBy2` fieldSep)- where p `sepBy2` sep = (:) <$> p <*> many1 (sep *> p)- fieldSep = many1 spaceChar *> count n (char '|') *> (void (many1 spaceChar) <|> void (lookAhead newline))+tableParseRow n = try $ sequence <$> tableCells+ where tableCells = (:) <$> tableCell sep <*> (tableCells <|> fmap pure (tableCell eol))+ tableCell p = try $ fmap B.plain . trimInlinesF . mconcat <$> manyTill inline' p+ sep = try $ many1 spaceChar *> count n (char '|') *> lookAhead (void (many1 spaceChar) <|> void eol) -- | Parse a table header row. tableParseHeader :: PandocMonad m => MuseParser m (F MuseTableElement)@@ -749,7 +716,7 @@ tableParseCaption = try $ fmap MuseCaption . trimInlinesF . mconcat <$ many spaceChar <* string "|+"- <*> many1Till inline (string "+|")+ <*> many1Till inline (try $ string "+|" *> eol) -- ** Inline parsers @@ -783,7 +750,7 @@ -- | Parse a soft break. endline :: PandocMonad m => MuseParser m (F Inlines)-endline = try $ pure B.softbreak <$ newline <* notFollowedBy blankline+endline = try $ pure B.softbreak <$ newline <* notFollowedBy blankline <* updateLastSpacePos parseAnchor :: PandocMonad m => MuseParser m String parseAnchor = try $ (:)@@ -801,7 +768,7 @@ -- | Parse a footnote reference. footnote :: PandocMonad m => MuseParser m (F Inlines) footnote = try $ do- inLink <- museInLink <$> getState+ inLink <- asks museInLink guard $ not inLink ref <- noteMarker return $ do@@ -814,30 +781,21 @@ return $ B.note contents' whitespace :: PandocMonad m => MuseParser m (F Inlines)-whitespace = try $ pure B.space <$ skipMany1 spaceChar+whitespace = try $ pure B.space <$ skipMany1 spaceChar <* updateLastSpacePos -- | Parse @\<br>@ tag. br :: PandocMonad m => MuseParser m (F Inlines) br = try $ pure B.linebreak <$ string "<br>" -emphasisBetween :: (PandocMonad m, Show a) => MuseParser m a -> MuseParser m (F Inlines)-emphasisBetween c = try $ enclosedInlines c c---- | Parses material enclosed between start and end parsers.-enclosed :: (Show end, Stream s m Char) => ParserT s st m t -- ^ start parser- -> ParserT s st m end -- ^ end parser- -> ParserT s st m a -- ^ content parser (to be used repeatedly)- -> ParserT s st m [a]-enclosed start end parser = try $- start *> notFollowedBy spaceChar *> many1Till parser end--enclosedInlines :: (PandocMonad m, Show a, Show b)+emphasisBetween :: (PandocMonad m, Show a) => MuseParser m a- -> MuseParser m b -> MuseParser m (F Inlines)-enclosedInlines start end = try $ trimInlinesF . mconcat- <$> enclosed (atStart start) end inline- <* notFollowedBy (satisfy isAlphaNum)+emphasisBetween p = try $ trimInlinesF . mconcat+ <$ atStart+ <* p+ <* notFollowedBy space+ <*> many1Till inline (try $ noSpaceBefore *> p)+ <* notFollowedBy alphaNum -- | Parse an inline tag, such as @\<em>@ and @\<strong>@. inlineTag :: PandocMonad m@@ -892,8 +850,7 @@ classTag :: PandocMonad m => MuseParser m (F Inlines) classTag = do classes <- maybe [] words . lookup "name" <$> openTag "class"- res <- manyTill inline $ closeTag "class"- return $ B.spanWith ("", classes, []) <$> mconcat res+ fmap (B.spanWith ("", classes, [])) . mconcat <$> manyTill inline (closeTag "class") -- | Parse "~~" as nonbreaking space. nbsp :: PandocMonad m => MuseParser m (F Inlines)@@ -901,14 +858,12 @@ -- | Parse code markup, indicated by @\'=\'@ characters. code :: PandocMonad m => MuseParser m (F Inlines)-code = try $ do- atStart $ char '='- contents <- many1Till (noneOf "\n\r" <|> (newline <* notFollowedBy newline)) $ char '='- guard $ not $ null contents- guard $ head contents `notElem` " \t\n"- guard $ last contents `notElem` " \t\n"- notFollowedBy $ satisfy isAlphaNum- return $ return $ B.code contents+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 '=')+ <* notFollowedBy alphaNum -- | Parse @\<code>@ tag. codeTag :: PandocMonad m => MuseParser m (F Inlines)@@ -933,27 +888,24 @@ str = return . B.str <$> many1 alphaNum <* updateLastStrPos symbol :: PandocMonad m => MuseParser m (F Inlines)-symbol = return . B.str <$> count 1 nonspaceChar+symbol = pure . B.str . pure <$> nonspaceChar -- | Parse a link or image. linkOrImage :: PandocMonad m => MuseParser m (F Inlines) linkOrImage = try $ do- st <- getState- guard $ not $ museInLink st- setState $ st{ museInLink = True }- res <- explicitLink <|> image <|> link- updateState (\state -> state { museInLink = False })- return res+ inLink <- asks museInLink+ guard $ not inLink+ local (\s -> s { museInLink = True }) (link "URL:" <|> image <|> link "") linkContent :: PandocMonad m => MuseParser m (F Inlines) linkContent = trimInlinesF . mconcat <$ char '[' <*> manyTill inline (char ']') --- | Parse a link starting with @URL:@-explicitLink :: PandocMonad m => MuseParser m (F Inlines)-explicitLink = try $ do- string "[[URL:"+-- | Parse a link starting with (possibly null) prefix+link :: PandocMonad m => String -> MuseParser m (F Inlines)+link prefix = try $ do+ string $ "[[" ++ prefix url <- manyTill anyChar $ char ']' content <- option (pure $ B.str url) linkContent char ']'@@ -986,11 +938,3 @@ <*> optionMaybe (many1 digit) <* many spaceChar <*> optionMaybe (oneOf "rlf")--link :: PandocMonad m => MuseParser m (F Inlines)-link = try $ do- string "[["- url <- manyTill anyChar $ char ']'- content <- optionMaybe linkContent- char ']'- return $ B.link url "" <$> fromMaybe (return $ B.str url) content
@@ -43,7 +43,7 @@ import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing -import qualified Data.Map as Map+import qualified Data.Set as Set import qualified Text.Pandoc.Builder as B --@@ -58,7 +58,7 @@ documentTree blocks inline = do initialBlocks <- blocks headlines <- sequence <$> manyTill (headline blocks inline 1) eof- title <- fmap (getTitle . unMeta) . orgStateMeta <$> getState+ title <- fmap docTitle . orgStateMeta <$> getState return $ do headlines' <- headlines initialBlocks' <- initialBlocks@@ -73,16 +73,7 @@ , headlineContents = initialBlocks' , headlineChildren = headlines' }- where- getTitle :: Map.Map String MetaValue -> [Inline]- getTitle metamap =- case Map.lookup "title" metamap of- Just (MetaInlines inlns) -> inlns- _ -> [] -newtype Tag = Tag { fromTag :: String }- deriving (Show, Eq)- -- | Create a tag containing the given string. toTag :: String -> Tag toTag = Tag@@ -160,7 +151,7 @@ headerTags :: Monad m => OrgParser m [Tag] headerTags = try $- let tag = many1 (alphaNum <|> oneOf "@%#_") <* char ':'+ let tag = orgTagWord <* char ':' in map toTag <$> (skipSpaces *> char ':' *> many1 tag <* skipSpaces) -- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks@@ -170,15 +161,17 @@ let tags = headlineTags hdln let text = headlineText hdln let level = headlineLevel hdln+ shouldNotExport <- hasDoNotExportTag tags case () of- _ | any isNoExportTag tags -> return mempty+ _ | shouldNotExport -> return mempty _ | any isArchiveTag tags -> archivedHeadlineToBlocks hdln _ | isCommentTitle text -> return mempty _ | maxLevel <= level -> headlineToHeaderWithList hdln _ | otherwise -> headlineToHeaderWithContents hdln -isNoExportTag :: Tag -> Bool-isNoExportTag = (== toTag "noexport")+hasDoNotExportTag :: Monad m => [Tag] -> OrgParser m Bool+hasDoNotExportTag tags = containsExcludedTag . orgStateExcludedTags <$> getState+ where containsExcludedTag s = any (`Set.member` s) tags isArchiveTag :: Tag -> Bool isArchiveTag = (== toTag "ARCHIVE")
@@ -289,7 +289,7 @@ berkeleyBareTag = try $ void berkeleyBareTag' berkeleyParensTag :: PandocMonad m => OrgParser m ()-berkeleyParensTag = try . void $ enclosedByPair '(' ')' berkeleyBareTag'+berkeleyParensTag = try . void $ enclosedByPair1 '(' ')' berkeleyBareTag' berkeleyBareTag' :: PandocMonad m => OrgParser m () berkeleyBareTag' = try $ void (string "cite")@@ -311,7 +311,7 @@ -- citation style, this isn't used. -- berkeleyBracketedTextualCite :: PandocMonad m => OrgParser m (F [Citation]) -- berkeleyBracketedTextualCite = try . (fmap head) $--- enclosedByPair '[' ']' berkeleyTextualCite+-- enclosedByPair1 '[' ']' berkeleyTextualCite -- | Read a link-like org-ref style citation. The citation includes pre and -- post text. However, multiple citations are not possible due to limitations@@ -461,7 +461,7 @@ return link linkTarget :: PandocMonad m => OrgParser m String-linkTarget = enclosedByPair '[' ']' (noneOf "\n\r[]")+linkTarget = enclosedByPair1 '[' ']' (noneOf "\n\r[]") possiblyEmptyLinkTarget :: PandocMonad m => OrgParser m String possiblyEmptyLinkTarget = try linkTarget <|> ("" <$ string "[]")@@ -525,9 +525,8 @@ inlineCodeBlock = try $ do string "src_" lang <- many1 orgArgWordChar- opts <- option [] $ try (enclosedByPair '[' ']' inlineBlockOption)- <|> (mempty <$ string "[]")- inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")+ opts <- option [] $ enclosedByPair '[' ']' inlineBlockOption+ inlineCode <- enclosedByPair1 '{' '}' (noneOf "\n\r") let attrClasses = [translateLang lang] let attrKeyVal = originalLang lang <> opts let codeInlineBlck = B.codeWith ("", attrClasses, attrKeyVal) inlineCode@@ -563,7 +562,14 @@ -> Char -- ^ closing char -> OrgParser m a -- ^ parser -> OrgParser m [a]-enclosedByPair s e p = char s *> many1Till p (char e)+enclosedByPair s e p = char s *> manyTill p (char e)++enclosedByPair1 :: PandocMonad m+ => Char -- ^ opening char+ -> Char -- ^ closing char+ -> OrgParser m a -- ^ parser+ -> OrgParser m [a]+enclosedByPair1 s e p = char s *> many1Till p (char e) emph :: PandocMonad m => OrgParser m (F Inlines) emph = fmap B.emph <$> emphasisBetween '/'
@@ -52,6 +52,7 @@ import Data.List (intersperse) import Data.Maybe (fromMaybe) import qualified Data.Map as M+import qualified Data.Set as Set import Network.HTTP (urlEncode) -- | Returns the current meta, respecting export options.@@ -158,6 +159,7 @@ "seq_todo" -> todoSequence >>= updateState . registerTodoSequence "typ_todo" -> todoSequence >>= updateState . registerTodoSequence "macro" -> macroDefinition >>= updateState . registerMacro+ "exclude_tags" -> excludedTagList >>= updateState . setExcludedTags "pandoc-emphasis-pre" -> emphChars >>= updateState . setEmphasisPreChar "pandoc-emphasis-post" -> emphChars >>= updateState . setEmphasisPostChar _ -> mzero@@ -189,6 +191,18 @@ rest = manyTill anyChar (eof <|> () <$ oneOf "\n\r") tillSpecifier c = manyTill (noneOf "\n\r") (try $ string ('%':c:""))++excludedTagList :: Monad m => OrgParser m [Tag]+excludedTagList = do+ skipSpaces+ map Tag <$> many (orgTagWord <* skipSpaces) <* newline++setExcludedTags :: [Tag] -> OrgParserState -> OrgParserState+setExcludedTags tagList st =+ let finalSet = if orgStateExcludedTagsChanged st+ then foldr Set.insert (orgStateExcludedTags st) tagList+ else Set.fromList tagList+ in st { orgStateExcludedTags = finalSet, orgStateExcludedTagsChanged = True } setEmphasisPreChar :: Maybe [Char] -> OrgParserState -> OrgParserState setEmphasisPreChar csMb st =
@@ -33,6 +33,7 @@ , defaultOrgParserState , OrgParserLocal (..) , OrgNoteRecord+ , Tag(..) , HasReaderOptions (..) , HasQuoteContext (..) , HasMacros (..)@@ -88,6 +89,9 @@ type OrgLinkFormatters = M.Map String (String -> String) -- | Macro expander function type MacroExpander = [String] -> String+-- | Tag+newtype Tag = Tag { fromTag :: String }+ deriving (Show, Eq, Ord) -- | The states in which a todo item can be data TodoState = Todo | Done@@ -113,6 +117,8 @@ -- specified here. , orgStateEmphasisPostChars :: [Char] -- ^ Chars allowed at after emphasis , orgStateEmphasisNewlines :: Maybe Int+ , orgStateExcludedTags :: Set.Set Tag+ , orgStateExcludedTagsChanged :: Bool , orgStateExportSettings :: ExportSettings , orgStateHeaderMap :: M.Map Inlines String , orgStateIdentifiers :: Set.Set String@@ -183,6 +189,8 @@ , orgStateEmphasisCharStack = [] , orgStateEmphasisNewlines = Nothing , orgStateExportSettings = def+ , orgStateExcludedTags = Set.singleton $ Tag "noexport"+ , orgStateExcludedTagsChanged = False , orgStateHeaderMap = M.empty , orgStateIdentifiers = Set.empty , orgStateIncludeFiles = []
@@ -46,6 +46,8 @@ , orgArgKey , orgArgWord , orgArgWordChar+ , orgTagWord+ , orgTagWordChar -- * Re-exports from Text.Pandoc.Parser , ParserContext (..) , many1Till@@ -220,3 +222,9 @@ -- | 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++orgTagWordChar :: Monad m => OrgParser m Char+orgTagWordChar = alphaNum <|> oneOf "@%#_"
@@ -665,11 +665,13 @@ optional blanklines let body' = body ++ "\n\n" name = trim $ fromMaybe "" (lookup "name" fields)- imgAttr cl = ("", classes, widthAttr ++ heightAttr)+ classes = words $ maybe "" trim (lookup "class" fields)+ keyvals = [(k, trim v) | (k, v) <- fields, k /= "name", k /= "class"]+ imgAttr cl = ("", classes ++ alignClasses, widthAttr ++ heightAttr) where- classes = words $ maybe "" trim (lookup cl fields) ++- maybe "" (\x -> "align-" ++ trim x)- (lookup "align" fields)+ alignClasses = 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 ->@@ -698,8 +700,9 @@ "line-block" -> lineBlockDirective body' "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body) "role" -> addNewRole top $ map (second trim) fields- "container" -> B.divWith (name, "container" : words top, []) <$>- parseFromString' parseBlocks body'+ "container" -> B.divWith+ (name, "container" : words top ++ classes, []) <$>+ parseFromString' parseBlocks body' "replace" -> B.para <$> -- consumed by substKey parseInlineFromString (trim top) "unicode" -> B.para <$> -- consumed by substKey@@ -717,7 +720,7 @@ (l:ls) -> B.divWith ("",["admonition-title"],[]) (B.para (B.str (toUpper l : ls))) [] -> mempty- return $ B.divWith ("",[label],[]) (lab <> bod)+ return $ B.divWith (name,label:classes,keyvals) (lab <> bod) "sidebar" -> do let subtit = maybe "" trim $ lookup "subtitle" fields tit <- B.para . B.strong <$> parseInlineFromString@@ -725,21 +728,21 @@ then "" else (": " ++ subtit)) bod <- parseFromString' parseBlocks body'- return $ B.divWith ("",["sidebar"],[]) $ tit <> bod+ return $ B.divWith (name,"sidebar":classes,keyvals) $ tit <> bod "topic" -> do tit <- B.para . B.strong <$> parseInlineFromString top bod <- parseFromString' parseBlocks body'- return $ B.divWith ("",["topic"],[]) $ tit <> bod+ return $ B.divWith (name,"topic":classes,keyvals) $ tit <> bod "default-role" -> mempty <$ updateState (\s -> s { stateRstDefaultRole = case trim top of "" -> stateRstDefaultRole def role -> role }) x | x == "code" || x == "code-block" ->- codeblock (words $ fromMaybe [] $ lookup "class" fields)+ codeblock name classes (lookup "number-lines" fields) (trim top) body "aafig" -> do- let attribs = ("", ["aafig"], map (second trimr) fields)+ 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@@ -758,8 +761,7 @@ $ B.imageWith attr src "" alt Nothing -> B.imageWith attr src "" alt "class" -> do- let attrs = ("", splitBy isSpace $ trim top,- map (second trimr) fields)+ let attrs = (name, words (trim top), map (second trimr) fields) -- directive content or the first immediately following element children <- case body of "" -> block@@ -769,7 +771,7 @@ pos <- getPosition logMessage $ SkippedContent (".. " ++ other) pos bod <- parseFromString' parseBlocks $ top ++ "\n\n" ++ body'- return $ B.divWith ("",[other],[]) bod+ return $ B.divWith (name, other:classes, keyvals) bod tableDirective :: PandocMonad m => String -> [(String, String)] -> String -> RSTParser m Blocks@@ -989,10 +991,11 @@ then "\\begin{aligned}\n" ++ s ++ "\n\\end{aligned}" else s -codeblock :: [String] -> Maybe String -> String -> String -> RSTParser m Blocks-codeblock classes numberLines lang body =+codeblock :: String -> [String] -> Maybe String -> String -> String+ -> RSTParser m Blocks+codeblock ident classes numberLines lang body = return $ B.codeBlockWith attribs $ stripTrailingNewlines body- where attribs = ("", classes', kvs)+ where attribs = (ident, classes', kvs) classes' = "sourceCode" : lang : maybe [] (const ["numberLines"]) numberLines ++ classes@@ -1266,7 +1269,9 @@ rawContent <- if headless then return "" else simpleTableSep '=' >> anyLine- dashes <- simpleDashedLines '=' <|> simpleDashedLines '-'+ dashes <- if headless+ then simpleDashedLines '='+ else simpleDashedLines '=' <|> simpleDashedLines '-' newline let lines' = map snd dashes let indices = scanl (+) 0 lines'
@@ -0,0 +1,756 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-+ Copyright (C) 2018 Yan Pashkovsky <yanp.bugz@gmail.com>+ and John MacFarlane++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++-}++{- |+ Module : Text.Pandoc.Readers.Roff+ Copyright : Copyright (C) 2018 Yan Pashkovsky and John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : Yan Pashkovsky <yanp.bugz@gmail.com>+ Stability : WIP+ Portability : portable++Tokenizer for roff formats (man, ms).+-}+module Text.Pandoc.Readers.Roff+ ( FontSpec(..)+ , defaultFontSpec+ , LinePart(..)+ , Arg+ , TableOption+ , CellFormat(..)+ , TableRow+ , RoffToken(..)+ , RoffTokens(..)+ , linePartsToString+ , lexRoff+ )+where++import Prelude+import Safe (lastDef)+import Control.Monad (void, mzero, mplus, guard)+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.Default (Default)+import qualified Data.Map as M+import Data.List (intercalate)+import qualified Data.Text as T+import Text.Pandoc.Logging (LogMessage(..))+import Text.Pandoc.Options+import Text.Pandoc.Parsing+import Text.Pandoc.Shared (safeRead, substitute)+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+import qualified Data.Text.Normalize as Normalize++-- import Debug.Trace (traceShowId)++--+-- Data Types+--+data FontSpec = FontSpec{ fontBold :: Bool+ , fontItalic :: Bool+ , fontMonospace :: Bool+ } deriving (Show, Eq, Ord)++defaultFontSpec :: FontSpec+defaultFontSpec = FontSpec False False False++data LinePart = RoffStr String+ | Font FontSpec+ | MacroArg Int+ deriving Show++type Arg = [LinePart]++type TableOption = (String, String)++data CellFormat =+ CellFormat+ { columnType :: Char+ , pipePrefix :: Bool+ , pipeSuffix :: Bool+ , columnSuffixes :: [String]+ } deriving (Show, Eq, Ord)++type TableRow = ([CellFormat], [RoffTokens])++data RoffToken = TextLine [LinePart]+ | EmptyLine+ | ControlLine String [Arg] SourcePos+ | Tbl [TableOption] [TableRow] SourcePos+ deriving Show++newtype RoffTokens = RoffTokens { unRoffTokens :: Seq.Seq RoffToken }+ deriving (Show, Semigroup, Monoid)++singleTok :: RoffToken -> RoffTokens+singleTok t = RoffTokens (Seq.singleton t)++data RoffMode = NormalMode+ | CopyMode+ deriving Show++data RoffState = RoffState { customMacros :: M.Map String RoffTokens+ , prevFont :: FontSpec+ , currentFont :: FontSpec+ , tableTabChar :: Char+ , roffMode :: RoffMode+ , lastExpression :: Maybe Bool+ , afterConditional :: Bool+ } deriving Show++instance Default RoffState where+ def = RoffState { customMacros = M.fromList+ $ map (\(n, s) ->+ (n, singleTok+ (TextLine [RoffStr s])))+ [ ("Tm", "\x2122")+ , ("lq", "\x201C")+ , ("rq", "\x201D")+ , ("R", "\x00AE") ]+ , prevFont = defaultFontSpec+ , currentFont = defaultFontSpec+ , tableTabChar = '\t'+ , roffMode = NormalMode+ , lastExpression = Nothing+ , afterConditional = False+ }++type RoffLexer m = ParserT [Char] RoffState m++--+-- Lexer: String -> RoffToken+--++eofline :: Stream s m Char => ParsecT s u m ()+eofline = void newline <|> eof++spacetab :: Stream s m Char => ParsecT s u m Char+spacetab = char ' ' <|> char '\t'++characterCodeMap :: M.Map String Char+characterCodeMap =+ M.fromList $ map (\(x,y) -> (y,x)) characterCodes++combiningAccentsMap :: M.Map String Char+combiningAccentsMap =+ M.fromList $ map (\(x,y) -> (y,x)) combiningAccents++escape :: PandocMonad m => RoffLexer m [LinePart]+escape = do+ backslash+ escapeGlyph <|> escapeNormal++escapeGlyph :: PandocMonad m => RoffLexer m [LinePart]+escapeGlyph = do+ c <- lookAhead (oneOf ['[','('])+ escapeArg >>= resolveGlyph c++resolveGlyph :: PandocMonad m => Char -> String -> RoffLexer m [LinePart]+resolveGlyph delimChar glyph = do+ let cs = substitute "_u" " u" glyph -- unicode glyphs separated by _+ (case words cs of+ [] -> mzero+ [s] -> case M.lookup s characterCodeMap `mplus` readUnicodeChar s of+ Nothing -> mzero+ Just c -> return [RoffStr [c]]+ (s:ss) -> do+ basechar <- case M.lookup s characterCodeMap `mplus`+ readUnicodeChar s of+ Nothing ->+ case 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+ addAccents (a:as) xs =+ case M.lookup a combiningAccentsMap `mplus` readUnicodeChar a of+ Just x -> addAccents as (x:xs)+ Nothing -> mzero+ addAccents ss [basechar] >>= \xs -> return [RoffStr xs])+ <|> case delimChar of+ '[' -> escUnknown ("\\[" ++ glyph ++ "]")+ '(' -> escUnknown ("\\(" ++ glyph)+ '\'' -> escUnknown ("\\C'" ++ glyph ++ "'")+ _ -> 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++escapeNormal :: PandocMonad m => RoffLexer m [LinePart]+escapeNormal = do+ c <- anyChar+ optional expandString+ case c of+ ' ' -> return [RoffStr " "]+ '"' -> mempty <$ skipMany (satisfy (/='\n')) -- line comment+ '#' -> mempty <$ manyTill anyChar newline+ '%' -> return mempty -- optional hyphenation+ '&' -> return mempty -- nonprintable zero-width+ ')' -> return mempty -- nonprintable zero-width+ '*' -> escString+ ',' -> return mempty -- to fix spacing after roman+ '-' -> return [RoffStr "-"]+ '.' -> return [RoffStr "`"]+ '/' -> return mempty -- to fix spacing before roman+ '0' -> return [RoffStr "\x2007"] -- digit-width space+ ':' -> return mempty -- zero-width break+ 'A' -> quoteArg >>= checkDefined+ 'B' -> escIgnore 'B' [quoteArg]+ 'C' -> quoteArg >>= resolveGlyph '\''+ 'D' -> escIgnore 'D' [quoteArg]+ 'E' -> do+ mode <- roffMode <$> getState+ case mode of+ CopyMode -> return mempty+ NormalMode -> return [RoffStr "\\"]+ 'H' -> escIgnore 'H' [quoteArg]+ 'L' -> escIgnore 'L' [quoteArg]+ 'M' -> escIgnore 'M' [escapeArg, count 1 (satisfy (/='\n'))]+ 'N' -> escIgnore 'N' [quoteArg]+ 'O' -> escIgnore 'O' [count 1 (oneOf ['0','1'])]+ 'R' -> escIgnore 'R' [quoteArg]+ 'S' -> escIgnore 'S' [quoteArg]+ 'V' -> escIgnore 'V' [escapeArg, count 1 alphaNum]+ 'X' -> escIgnore 'X' [quoteArg]+ 'Y' -> escIgnore 'Y' [escapeArg, count 1 (satisfy (/='\n'))]+ 'Z' -> escIgnore 'Z' [quoteArg]+ '\'' -> return [RoffStr "`"]+ '\n' -> return mempty -- line continuation+ '^' -> return [RoffStr "\x200A"] -- 1/12 em space+ '_' -> return [RoffStr "_"]+ '`' -> return [RoffStr "`"]+ 'a' -> return mempty -- "non-interpreted leader character"+ 'b' -> escIgnore 'b' [quoteArg]+ 'c' -> return mempty -- interrupt text processing+ 'd' -> escIgnore 'd' [] -- forward down 1/2em+ 'e' -> return [RoffStr "\\"]+ 'f' -> escFont+ 'g' -> escIgnore 'g' [escapeArg, count 1 (satisfy (/='\n'))]+ 'h' -> escIgnore 'h' [quoteArg]+ 'k' -> escIgnore 'k' [escapeArg, count 1 (satisfy (/='\n'))]+ 'l' -> escIgnore 'l' [quoteArg]+ 'm' -> escIgnore 'm' [escapeArg, count 1 (satisfy (/='\n'))]+ 'n' -> escIgnore 'm' [escapeArg, count 1 (satisfy (/='\n'))]+ 'o' -> escIgnore 'o' [quoteArg]+ 'p' -> escIgnore 'p' []+ 'r' -> escIgnore 'r' []+ 's' -> escIgnore 's' [escapeArg, signedNumber]+ 't' -> return [RoffStr "\t"]+ 'u' -> escIgnore 'u' []+ 'v' -> escIgnore 'v' [quoteArg]+ 'w' -> escIgnore 'w' [quoteArg]+ 'x' -> escIgnore 'x' [quoteArg]+ 'z' -> escIgnore 'z' [count 1 anyChar]+ '{' -> return mempty+ '|' -> return [RoffStr "\x2006"] --1/6 em space+ '}' -> return mempty+ '~' -> return [RoffStr "\160"] -- nonbreaking space+ '\\' -> do+ mode <- roffMode <$> getState+ case mode of+ CopyMode -> char '\\'+ NormalMode -> return '\\'+ return [RoffStr "\\"]+ _ -> return [RoffStr [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 [LinePart]+escIgnore c argparsers = do+ pos <- getPosition+ arg <- snd <$> withRaw (choice argparsers) <|> return ""+ report $ SkippedContent ('\\':c:arg) pos+ return mempty++escUnknown :: PandocMonad m => String -> RoffLexer m [LinePart]+escUnknown s = do+ pos <- getPosition+ report $ SkippedContent s pos+ return [RoffStr "\xFFFD"]++signedNumber :: PandocMonad m => RoffLexer m String+signedNumber = try $ do+ sign <- option "" ("-" <$ char '-' <|> "" <$ char '+')+ ds <- many1 digit+ return (sign ++ ds)++-- Parses: [..] or (..+escapeArg :: PandocMonad m => RoffLexer m String+escapeArg = choice+ [ char '[' *> optional expandString *>+ manyTill (noneOf ['\n',']']) (char ']')+ , char '(' *> optional expandString *>+ count 2 (satisfy (/='\n'))+ ]++expandString :: PandocMonad m => RoffLexer m ()+expandString = try $ do+ pos <- getPosition+ char '\\'+ char '*'+ cs <- escapeArg <|> count 1 anyChar+ s <- linePartsToString <$> resolveString cs pos+ getInput >>= setInput . (s ++)+ return ()++-- Parses: '..'+quoteArg :: PandocMonad m => RoffLexer m String+quoteArg = char '\'' *> manyTill (noneOf ['\n','\'']) (char '\'')++escFont :: PandocMonad m => RoffLexer m [LinePart]+escFont = do+ font <- escapeArg <|> count 1 alphaNum+ font' <- if null font || font == "P"+ then prevFont <$> getState+ else return $ foldr processFontLetter defaultFontSpec font+ modifyState $ \st -> st{ prevFont = currentFont st+ , currentFont = font' }+ return [Font font']+ where+ processFontLetter c fs+ | isLower c = processFontLetter (toUpper c) fs+ processFontLetter 'B' fs = fs{ fontBold = True }+ processFontLetter 'I' fs = fs{ fontItalic = True }+ processFontLetter 'C' fs = fs{ fontMonospace = True }+ processFontLetter _ fs = fs -- do nothing++-- separate function from lexMacro since real man files sometimes do not+-- follow the rules+lexComment :: PandocMonad m => RoffLexer m RoffTokens+lexComment = do+ try $ string ".\\\""+ many Parsec.space+ skipMany $ noneOf "\n"+ eofline+ return mempty++lexMacro :: PandocMonad m => RoffLexer m RoffTokens+lexMacro = do+ pos <- getPosition+ st <- getState+ guard $ sourceColumn pos == 1 || afterConditional st+ char '.' <|> char '\''+ skipMany spacetab+ macroName <- many (satisfy (not . isSpace))+ case macroName of+ "nop" -> return mempty+ "ie" -> lexConditional "ie"+ "if" -> lexConditional "if"+ "el" -> lexConditional "el"++ _ -> do+ args <- lexArgs+ case macroName of+ "" -> return mempty+ "\\\"" -> return mempty+ "\\#" -> return mempty+ "TS" -> lexTable pos+ "de" -> lexMacroDef args+ "de1" -> lexMacroDef args+ "ds" -> lexStringDef args+ "ds1" -> lexStringDef args+ "sp" -> return $ singleTok EmptyLine+ "so" -> lexIncludeFile args+ _ -> resolveMacro macroName args pos++lexTable :: PandocMonad m => SourcePos -> RoffLexer m RoffTokens+lexTable pos = do+ skipMany lexComment+ spaces+ opts <- try tableOptions <|> [] <$ optional (char ';')+ case lookup "tab" opts of+ Just (c:_) -> modifyState $ \st -> st{ tableTabChar = c }+ _ -> modifyState $ \st -> st{ tableTabChar = '\t' }+ spaces+ skipMany lexComment+ spaces+ rows <- lexTableRows+ morerows <- many $ try $ do+ string ".T&"+ skipMany spacetab+ newline+ lexTableRows+ string ".TE"+ skipMany spacetab+ eofline+ return $ singleTok $ Tbl opts (rows ++ concat morerows) pos++lexTableRows :: PandocMonad m => RoffLexer m [TableRow]+lexTableRows = do+ aligns <- tableFormatSpec+ spaces+ skipMany $ lexComment+ <|> try (mempty <$ (string ".sp" >> skipMany spaceChar >> newline))+ spaces+ rows <- many (notFollowedBy (try (string ".TE") <|> try (string ".T&")) >>+ tableRow)+ return $ zip aligns rows++tableCell :: PandocMonad m => RoffLexer m RoffTokens+tableCell = do+ pos <- getPosition+ (enclosedCell <|> simpleCell) >>= lexRoff pos . T.pack+ where+ enclosedCell = do+ try (string "T{")+ manyTill anyChar (try (string "T}"))+ simpleCell = do+ tabChar <- tableTabChar <$> getState+ many (notFollowedBy (char tabChar <|> newline) >> anyChar)++tableRow :: PandocMonad m => RoffLexer m [RoffTokens]+tableRow = do+ tabChar <- tableTabChar <$> getState+ c <- tableCell+ cs <- many $ try (char tabChar >> tableCell)+ skipMany spacetab+ eofline+ skipMany lexComment+ return (c:cs)++tableOptions :: PandocMonad m => RoffLexer m [TableOption]+tableOptions = many1 tableOption <* spaces <* char ';'++tableOption :: PandocMonad m => RoffLexer m TableOption+tableOption = do+ k <- many1 letter+ v <- option "" $ try $ do+ skipMany spacetab+ char '('+ manyTill anyChar (char ')')+ skipMany spacetab+ optional (char ',' >> skipMany spacetab)+ return (k,v)++tableFormatSpec :: PandocMonad m => RoffLexer m [[CellFormat]]+tableFormatSpec = do+ first <- tableFormatSpecLine+ rest <- many $ try $ (newline <|> char ',') *> tableFormatSpecLine+ let speclines = first:rest+ spaces+ char '.'+ return $ speclines ++ repeat (lastDef [] speclines) -- last line is default++tableFormatSpecLine :: PandocMonad m => RoffLexer m [CellFormat]+tableFormatSpecLine =+ many1 $ skipMany spacetab *> tableColFormat <* skipMany spacetab++tableColFormat :: PandocMonad m => RoffLexer m CellFormat+tableColFormat = do+ pipePrefix' <- option False+ $ 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) <|>+ (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 ""+ 'f' -> count 1 alphaNum <* skipMany spacetab+ 'm' -> count 1 alphaNum <* skipMany spacetab+ _ -> return ""+ return $ x : num)+ pipeSuffix' <- option False $ True <$ string "|"+ return $ CellFormat+ { columnType = c+ , pipePrefix = pipePrefix'+ , pipeSuffix = pipeSuffix'+ , columnSuffixes = suffixes }++-- 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 mname = do+ pos <- getPosition+ skipMany spacetab+ mbtest <- if mname == "el"+ then fmap not . lastExpression <$> getState+ else expression+ skipMany spacetab+ st <- getState -- save state, so we can reset it+ ifPart <- lexGroup <|> ((try (char '\\' >> newline)) >> manToken)+ <|> do modifyState $ \s -> s{ afterConditional = True }+ t <- manToken+ modifyState $ \s -> s{ afterConditional = False }+ return t+ case mbtest of+ Nothing -> do+ putState st -- reset state, so we don't record macros in skipped section+ report $ SkippedContent ('.':mname) pos+ return mempty+ Just True -> return ifPart+ Just False -> do+ putState st+ return mempty++expression :: PandocMonad m => RoffLexer m (Maybe Bool)+expression = do+ raw <- charsInBalanced '(' ')' (satisfy (/= '\n'))+ <|> many1 nonspaceChar+ returnValue $+ case raw of+ "1" -> Just True+ "n" -> Just True -- nroff mode+ "t" -> Just False -- troff mode+ _ -> Nothing+ where+ returnValue v = do+ modifyState $ \st -> st{ lastExpression = v }+ return v++lexGroup :: PandocMonad m => RoffLexer m RoffTokens+lexGroup = do+ groupstart+ mconcat <$> manyTill manToken groupend+ where+ groupstart = try $ string "\\{\\" >> newline+ groupend = try $ optional (char '.' >> many spacetab) >>+ string "\\}" >> (lexLine <|> lexEmptyLine)+ -- could be comment++lexIncludeFile :: PandocMonad m => [Arg] -> RoffLexer m RoffTokens+lexIncludeFile args = do+ pos <- getPosition+ case args of+ (f:_) -> do+ let fp = linePartsToString f+ dirs <- getResourcePath+ result <- readFileFromDirs dirs fp+ case result of+ Nothing -> report $ CouldNotLoadIncludeFile fp pos+ Just s -> getInput >>= setInput . (s ++)+ return mempty+ [] -> return mempty++resolveMacro :: PandocMonad m+ => String -> [Arg] -> SourcePos -> RoffLexer m RoffTokens+resolveMacro macroName args pos = do+ macros <- customMacros <$> getState+ case M.lookup macroName macros of+ Nothing -> return $ singleTok $ ControlLine macroName args pos+ Just ts -> do+ let fillLP (MacroArg i) zs =+ case drop (i - 1) args of+ [] -> zs+ (ys:_) -> ys ++ zs+ fillLP z zs = z : zs+ let fillMacroArg (TextLine lineparts) =+ TextLine (foldr fillLP [] lineparts)+ fillMacroArg x = x+ return $ RoffTokens . fmap fillMacroArg . unRoffTokens $ ts++lexStringDef :: PandocMonad m => [Arg] -> RoffLexer m RoffTokens+lexStringDef args = do -- string definition+ case args of+ [] -> fail "No argument to .ds"+ (x:ys) -> do+ let ts = singleTok $ TextLine (intercalate [RoffStr " " ] ys)+ let stringName = linePartsToString x+ modifyState $ \st ->+ st{ customMacros = M.insert stringName ts (customMacros st) }+ return mempty++lexMacroDef :: PandocMonad m => [Arg] -> RoffLexer m RoffTokens+lexMacroDef args = do -- macro definition+ modifyState $ \st -> st{ roffMode = CopyMode }+ (macroName, stopMacro) <-+ case args of+ (x : y : _) -> return (linePartsToString x, linePartsToString y)+ -- optional second arg+ (x:_) -> return (linePartsToString x, ".")+ [] -> fail "No argument to .de"+ let stop = try $ do+ char '.' <|> char '\''+ skipMany spacetab+ string stopMacro+ _ <- lexArgs+ return ()+ ts <- mconcat <$> manyTill manToken stop+ modifyState $ \st ->+ st{ customMacros = M.insert macroName ts (customMacros st)+ , roffMode = NormalMode }+ return mempty++lexArgs :: PandocMonad m => RoffLexer m [Arg]+lexArgs = do+ args <- many $ try oneArg+ skipMany spacetab+ eofline+ return args++ where++ oneArg :: PandocMonad m => RoffLexer m [LinePart]+ oneArg = do+ skipMany $ try $ string "\\\n" -- continuation line+ try quotedArg <|> plainArg+ -- try, because there are some erroneous files, e.g. linux/bpf.2++ plainArg :: PandocMonad m => RoffLexer m [LinePart]+ plainArg = do+ skipMany spacetab+ mconcat <$> many1 (macroArg <|> escape <|> regularText <|> unescapedQuote)+ where+ unescapedQuote = char '"' >> return [RoffStr "\""]++ quotedArg :: PandocMonad m => RoffLexer m [LinePart]+ quotedArg = do+ skipMany spacetab+ char '"'+ xs <- mconcat <$>+ many (macroArg <|> escape <|> regularText+ <|> spaceTabChar <|> escapedQuote)+ char '"'+ return xs+ where+ escapedQuote = try $ do+ char '"'+ char '"'+ return [RoffStr "\""]++checkDefined :: PandocMonad m => String -> RoffLexer m [LinePart]+checkDefined name = do+ macros <- customMacros <$> getState+ case M.lookup name macros of+ Just _ -> return [RoffStr "1"]+ Nothing -> return [RoffStr "0"]++escString :: PandocMonad m => RoffLexer m [LinePart]+escString = try $ do+ pos <- getPosition+ (do cs <- escapeArg <|> count 1 anyChar+ resolveString cs pos)+ <|> mempty <$ char 'S'++-- strings and macros share namespace+resolveString :: PandocMonad m+ => String -> SourcePos -> RoffLexer m [LinePart]+resolveString stringname pos = do+ RoffTokens ts <- resolveMacro stringname [] pos+ case Foldable.toList ts of+ [TextLine xs] -> return xs+ _ -> do+ report $ SkippedContent ("unknown string " ++ stringname) pos+ return mempty++lexLine :: PandocMonad m => RoffLexer m RoffTokens+lexLine = do+ mode <- roffMode <$> getState+ case mode of+ CopyMode -> optional $ try $ string "\\&"+ NormalMode -> return ()+ lnparts <- mconcat <$> many1 linePart+ eofline+ go lnparts+ where -- return empty line if we only have empty strings;+ -- this can happen if the line just contains \f[C], for example.+ go [] = return mempty+ go (RoffStr "" : xs) = go xs+ go xs = return $ singleTok $ TextLine xs++linePart :: PandocMonad m => RoffLexer m [LinePart]+linePart = macroArg <|> escape <|>+ regularText <|> quoteChar <|> spaceTabChar++backslash :: PandocMonad m => RoffLexer m ()+backslash = do+ char '\\'+ mode <- roffMode <$> getState+ case mode of+ -- experimentally, it seems you don't always need to double+ -- the backslash in macro defs. It's essential with \\$1,+ -- but not with \\f[I]. So we make the second one optional.+ CopyMode -> optional $ char '\\'+ NormalMode -> return ()++macroArg :: PandocMonad m => RoffLexer m [LinePart]+macroArg = try $ do+ pos <- getPosition+ backslash+ char '$'+ x <- escapeArg <|> count 1 digit+ case safeRead x of+ Just i -> return [MacroArg i]+ Nothing -> do+ report $ SkippedContent ("illegal macro argument " ++ x) pos+ return []++regularText :: PandocMonad m => RoffLexer m [LinePart]+regularText = do+ s <- many1 $ noneOf "\n\r\t \\\""+ return [RoffStr s]++quoteChar :: PandocMonad m => RoffLexer m [LinePart]+quoteChar = do+ char '"'+ return [RoffStr "\""]++spaceTabChar :: PandocMonad m => RoffLexer m [LinePart]+spaceTabChar = do+ c <- spacetab+ return [RoffStr [c]]++lexEmptyLine :: PandocMonad m => RoffLexer m RoffTokens+lexEmptyLine = newline >> return (singleTok EmptyLine)++manToken :: PandocMonad m => RoffLexer m RoffTokens+manToken = lexComment <|> lexMacro <|> lexLine <|> lexEmptyLine++linePartsToString :: [LinePart] -> String+linePartsToString = mconcat . map go+ where+ go (RoffStr s) = s+ go _ = mempty++-- | Tokenize a string as a sequence of roff tokens.+lexRoff :: PandocMonad m => SourcePos -> T.Text -> m RoffTokens+lexRoff pos txt = do+ eithertokens <- readWithM (do setPosition pos+ mconcat <$> many manToken) def (T.unpack txt)+ case eithertokens of+ Left e -> throwError e+ Right tokenz -> return tokenz
@@ -74,9 +74,6 @@ tryMsg :: String -> TWParser m a -> TWParser m a tryMsg msg p = try p <?> msg -skip :: TWParser m a -> TWParser m ()-skip parser = parser >> return ()- nested :: PandocMonad m => TWParser m a -> TWParser m a nested p = do nestlevel <- stateMaxNestingLevel <$> getState@@ -92,7 +89,7 @@ content <- manyTill anyChar (endtag <|> endofinput) return (htmlAttrToPandoc attr, trim content) where- endtag = skip $ htmlTag (~== TagClose tag)+ endtag = void $ htmlTag (~== TagClose tag) endofinput = lookAhead $ try $ skipMany blankline >> skipSpaces >> eof trim = dropWhile (=='\n') . reverse . dropWhile (=='\n') . reverse @@ -114,18 +111,15 @@ endOfContent = try $ skipMany blankline >> skipSpaces >> eof parseHtmlContent :: PandocMonad m => String -> TWParser m a -> TWParser m [a]-parseHtmlContent tag p = parseHtmlContentWithAttrs tag p >>= return . snd+parseHtmlContent tag p = snd <$> parseHtmlContentWithAttrs tag p -- -- main parser -- parseTWiki :: PandocMonad m => TWParser m Pandoc-parseTWiki = do- bs <- mconcat <$> many block- spaces- eof- return $ B.doc bs+parseTWiki =+ B.doc . mconcat <$> many block <* spaces <* eof --@@ -158,7 +152,7 @@ header :: PandocMonad m => TWParser m B.Blocks header = tryMsg "header" $ do string "---"- level <- many1 (char '+') >>= return . length+ level <- length <$> many1 (char '+') guard $ level <= 6 classes <- option [] $ string "!!" >> return ["unnumbered"] skipSpaces@@ -167,11 +161,10 @@ return $ B.headerWith attr level content verbatim :: PandocMonad m => TWParser m B.Blocks-verbatim = (htmlElement "verbatim" <|> htmlElement "pre")- >>= return . (uncurry B.codeBlockWith)+verbatim = uncurry B.codeBlockWith <$> (htmlElement "verbatim" <|> htmlElement "pre") literal :: PandocMonad m => TWParser m B.Blocks-literal = htmlElement "literal" >>= return . rawBlock+literal = rawBlock <$> htmlElement "literal" where format (_, _, kvs) = fromMaybe "html" $ lookup "format" kvs rawBlock (attrs, content) = B.rawBlock (format attrs) content@@ -183,7 +176,7 @@ definitionList :: PandocMonad m => String -> TWParser m B.Blocks definitionList prefix = tryMsg "definitionList" $ do- indent <- lookAhead $ string prefix *> (many1 $ string " ") <* string "$ "+ indent <- lookAhead $ string prefix *> many1 (string " ") <* string "$ " elements <- many $ parseDefinitionListItem (prefix ++ concat indent) return $ B.definitionList elements where@@ -193,7 +186,7 @@ string (indent ++ "$ ") >> skipSpaces term <- many1Till inline $ string ": " line <- listItemLine indent $ string "$ "- return $ (mconcat term, [line])+ return (mconcat term, [line]) bulletList :: PandocMonad m => String -> TWParser m B.Blocks bulletList prefix = tryMsg "bulletList" $@@ -227,25 +220,24 @@ listItemLine :: (PandocMonad m, Show a) => String -> TWParser m a -> TWParser m B.Blocks-listItemLine prefix marker = lineContent >>= parseContent >>= return . mconcat+listItemLine prefix marker = mconcat <$> (lineContent >>= parseContent) where lineContent = do content <- anyLine continuation <- optionMaybe listContinuation- return $ filterSpaces content ++ "\n" ++ (maybe "" (" " ++) continuation)+ return $ filterSpaces content ++ "\n" ++ maybe "" (" " ++) continuation filterSpaces = reverse . dropWhile (== ' ') . reverse listContinuation = notFollowedBy (string prefix >> marker) >> string " " >> lineContent parseContent = parseFromString' $ many1 $ nestedList <|> parseInline- parseInline = many1Till inline (lastNewline <|> newlineBeforeNestedList) >>=- return . B.plain . mconcat+ parseInline = (B.plain . mconcat) <$> many1Till inline (lastNewline <|> newlineBeforeNestedList) nestedList = list prefix lastNewline = try $ char '\n' <* eof newlineBeforeNestedList = try $ char '\n' <* lookAhead nestedList table :: PandocMonad m => TWParser m B.Blocks table = try $ do- tableHead <- optionMaybe $ many1Till tableParseHeader newline >>= return . unzip+ tableHead <- optionMaybe (unzip <$> many1Till tableParseHeader newline) rows <- many1 tableParseRow return $ buildTable mempty rows $ fromMaybe (align rows, columns rows) tableHead where@@ -258,11 +250,11 @@ tableParseHeader :: PandocMonad m => TWParser m ((Alignment, Double), B.Blocks) tableParseHeader = try $ do char '|'- leftSpaces <- many spaceChar >>= return . length+ leftSpaces <- length <$> many spaceChar char '*' content <- tableColumnContent (char '*' >> skipSpaces >> char '|') char '*'- rightSpaces <- many spaceChar >>= return . length+ rightSpaces <- length <$> many spaceChar optional tableEndOfRow return (tableAlign leftSpaces rightSpaces, content) where@@ -283,13 +275,13 @@ tableEndOfRow = lookAhead (try $ char '|' >> char '\n') >> char '|' tableColumnContent :: PandocMonad m => TWParser m a -> TWParser m B.Blocks-tableColumnContent end = manyTill content (lookAhead $ try end) >>= return . B.plain . mconcat+tableColumnContent end = (B.plain . mconcat) <$> manyTill content (lookAhead $ try end) where content = continuation <|> inline continuation = try $ char '\\' >> newline >> return mempty blockQuote :: PandocMonad m => TWParser m B.Blocks-blockQuote = parseHtmlContent "blockquote" block >>= return . B.blockQuote . mconcat+blockQuote = (B.blockQuote . mconcat) <$> parseHtmlContent "blockquote" block noautolink :: PandocMonad m => TWParser m B.Blocks noautolink = do@@ -300,15 +292,15 @@ setState $ st{ stateAllowLinks = True } return $ mconcat blocks where- parseContent = parseFromString' $ many $ block+ parseContent = parseFromString' $ many block para :: PandocMonad m => TWParser m B.Blocks-para = many1Till inline endOfParaElement >>= return . result . mconcat+para = (result . mconcat) <$> many1Till inline endOfParaElement where endOfParaElement = lookAhead $ endOfInput <|> endOfPara <|> newBlockElement endOfInput = try $ skipMany blankline >> skipSpaces >> eof endOfPara = try $ blankline >> skipMany1 blankline- newBlockElement = try $ blankline >> skip blockElements+ newBlockElement = try $ blankline >> void blockElements result content = if F.all (==Space) content then mempty else B.para $ B.trimInlines content@@ -340,7 +332,7 @@ ] <?> "inline" whitespace :: PandocMonad m => TWParser m B.Inlines-whitespace = (lb <|> regsp) >>= return+whitespace = lb <|> regsp where lb = try $ skipMany spaceChar >> linebreak >> return B.space regsp = try $ skipMany1 spaceChar >> return B.space @@ -362,13 +354,13 @@ => TWParser m a -> (TWParser m a -> TWParser m b) -> TWParser m b enclosed sep p = between sep (try $ sep <* endMarker) p where- endMarker = lookAhead $ skip endSpace <|> skip (oneOf ".,!?:)|") <|> eof+ endMarker = lookAhead $ void endSpace <|> void (oneOf ".,!?:)|") <|> eof endSpace = (spaceChar <|> newline) >> return B.space macro :: PandocMonad m => TWParser m B.Inlines macro = macroWithParameters <|> withoutParameters where- withoutParameters = enclosed (char '%') (\_ -> macroName) >>= return . emptySpan+ withoutParameters = emptySpan <$> enclosed (char '%') (const macroName) emptySpan name = buildSpan name [] mempty macroWithParameters :: PandocMonad m => TWParser m B.Inlines@@ -393,13 +385,13 @@ return (first:rest) attributes :: PandocMonad m => TWParser m (String, [(String, String)])-attributes = char '{' *> spnl *> many (attribute <* spnl) <* char '}' >>=- return . foldr (either mkContent mkKvs) ([], [])+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)- mkKvs kv (cont, rest) = (cont, (kv : rest))+ mkKvs kv (cont, rest) = (cont, kv : rest) attribute :: PandocMonad m => TWParser m (Either String (String, String)) attribute = withKey <|> withoutKey@@ -407,52 +399,50 @@ withKey = try $ do key <- macroName char '='- parseValue False >>= return . (curry Right key)- withoutKey = try $ parseValue True >>= return . Left- parseValue allowSpaces = (withQuotes <|> withoutQuotes allowSpaces) >>= return . fromEntities+ curry Right key <$> parseValue False+ withoutKey = try $ Left <$> parseValue True+ parseValue allowSpaces = fromEntities <$> (withQuotes <|> withoutQuotes allowSpaces) withQuotes = between (char '"') (char '"') (\_ -> count 1 $ noneOf ['"']) withoutQuotes allowSpaces- | allowSpaces == True = many1 $ noneOf "}"- | otherwise = many1 $ noneOf " }"+ | allowSpaces = many1 $ noneOf "}"+ | otherwise = many1 $ noneOf " }" nestedInlines :: (Show a, PandocMonad m) => TWParser m a -> TWParser m B.Inlines nestedInlines end = innerSpace <|> nestedInline where- innerSpace = try $ whitespace <* (notFollowedBy end)+ innerSpace = try $ whitespace <* notFollowedBy end nestedInline = notFollowedBy whitespace >> nested inline strong :: PandocMonad m => TWParser m B.Inlines-strong = try $ enclosed (char '*') nestedInlines >>= return . B.strong+strong = try $ B.strong <$> enclosed (char '*') nestedInlines strongHtml :: PandocMonad m => TWParser m B.Inlines-strongHtml = (parseHtmlContent "strong" inline <|> parseHtmlContent "b" inline)- >>= return . B.strong . mconcat+strongHtml = B.strong . mconcat <$> (parseHtmlContent "strong" inline <|> parseHtmlContent "b" inline) strongAndEmph :: PandocMonad m => TWParser m B.Inlines-strongAndEmph = try $ enclosed (string "__") nestedInlines >>= return . B.emph . B.strong+strongAndEmph = try $ B.emph . B.strong <$> enclosed (string "__") nestedInlines emph :: PandocMonad m => TWParser m B.Inlines-emph = try $ enclosed (char '_') nestedInlines >>= return . B.emph+emph = try $ B.emph <$> enclosed (char '_') nestedInlines emphHtml :: PandocMonad m => TWParser m B.Inlines-emphHtml = (parseHtmlContent "em" inline <|> parseHtmlContent "i" inline)- >>= return . B.emph . mconcat+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)+nestedString end = innerSpace <|> count 1 nonspaceChar where innerSpace = try $ many1 spaceChar <* notFollowedBy end boldCode :: PandocMonad m => TWParser m B.Inlines-boldCode = try $ enclosed (string "==") nestedString >>= return . B.strong . B.code . fromEntities+boldCode = try $ (B.strong . B.code . fromEntities) <$> enclosed (string "==") nestedString htmlComment :: PandocMonad m => TWParser m B.Inlines htmlComment = htmlTag isCommentTag >> return mempty code :: PandocMonad m => TWParser m B.Inlines-code = try $ enclosed (char '=') nestedString >>= return . B.code . fromEntities+code = try $ (B.code . fromEntities) <$> enclosed (char '=') nestedString codeHtml :: PandocMonad m => TWParser m B.Inlines codeHtml = do@@ -464,7 +454,7 @@ state <- getState guard $ stateAllowLinks state (text, url) <- parseLink- guard $ checkLink (head $ reverse url)+ guard $ checkLink (last url) return $ makeLink (text, url) where parseLink = notFollowedBy nop >> (uri <|> emailAddress)@@ -474,17 +464,17 @@ | otherwise = isAlphaNum c str :: PandocMonad m => TWParser m B.Inlines-str = (many1 alphaNum <|> count 1 characterReference) >>= return . B.str+str = B.str <$> (many1 alphaNum <|> count 1 characterReference) nop :: PandocMonad m => TWParser m B.Inlines-nop = try $ (skip exclamation <|> skip nopTag) >> followContent+nop = try $ (void exclamation <|> void nopTag) >> followContent where exclamation = char '!' nopTag = stringAnyCase "<nop>"- followContent = many1 nonspaceChar >>= return . B.str . fromEntities+ followContent = B.str . fromEntities <$> many1 nonspaceChar symbol :: PandocMonad m => TWParser m B.Inlines-symbol = count 1 nonspaceChar >>= return . B.str+symbol = B.str <$> count 1 nonspaceChar smart :: PandocMonad m => TWParser m B.Inlines smart = do@@ -498,17 +488,16 @@ singleQuoted :: PandocMonad m => TWParser m B.Inlines singleQuoted = try $ do singleQuoteStart- withQuoteContext InSingleQuote $- many1Till inline singleQuoteEnd >>=- (return . B.singleQuoted . B.trimInlines . mconcat)+ withQuoteContext InSingleQuote+ (B.singleQuoted . B.trimInlines . mconcat <$> many1Till inline singleQuoteEnd) doubleQuoted :: PandocMonad m => TWParser m B.Inlines doubleQuoted = try $ do doubleQuoteStart contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)- (withQuoteContext InDoubleQuote $ doubleQuoteEnd >>+ withQuoteContext InDoubleQuote (doubleQuoteEnd >> return (B.doubleQuoted $ B.trimInlines contents))- <|> (return $ (B.str "\8220") B.<> contents)+ <|> return (B.str "\8220" B.<> contents) link :: PandocMonad m => TWParser m B.Inlines link = try $ do@@ -527,5 +516,5 @@ char ']' return (url, "", content) where- linkContent = (char '[') >> many1Till anyChar (char ']') >>= parseLinkContent+ linkContent = char '[' >> many1Till anyChar (char ']') >>= parseLinkContent parseLinkContent = parseFromString' $ many1 inline
@@ -71,7 +71,7 @@ import Data.Default import Data.List (isInfixOf, isPrefixOf) import Data.Maybe-import Data.Text (Text, unpack)+import Data.Text (Text) import Text.Pandoc.Builder (Blocks, Inlines, fromList, toList, trimInlines) import qualified Text.Pandoc.Builder as B (blockQuote, bulletList, code, codeBlockWith, definitionList,@@ -85,12 +85,12 @@ import Text.Pandoc.Class (PandocMonad (..)) import Text.Pandoc.Definition (Attr, Block (BulletList, OrderedList), Inline (Space), ListNumberDelim (..),- ListNumberStyle (..), Meta, Pandoc (..),+ ListNumberStyle (..), Pandoc (..), nullMeta) import Text.Pandoc.Options (ReaderOptions)-import Text.Pandoc.Parsing (F, ParserState, ParserT, blanklines, emailAddress,+import Text.Pandoc.Parsing (ParserState, ParserT, blanklines, emailAddress, many1Till, orderedListMarker, readWithM,- registerHeader, runF, spaceChar, stateMeta',+ registerHeader, spaceChar, stateMeta, stateOptions, uri) import Text.Pandoc.Shared (crFilter, splitBy, stringify, stripFirstAndLast) import Text.Parsec.Char (alphaNum, anyChar, char, newline, noneOf, oneOf, space,@@ -101,13 +101,12 @@ readVimwiki :: PandocMonad m => ReaderOptions -> Text -> m Pandoc readVimwiki opts s = do- res <- readWithM parseVimwiki def{ stateOptions = opts }- (unpack (crFilter s))+ res <- readWithM parseVimwiki def{ stateOptions = opts } $ crFilter s case res of Left e -> throwError e Right result -> return result -type VwParser = ParserT [Char] ParserState+type VwParser = ParserT Text ParserState -- constants@@ -126,7 +125,7 @@ spaces eof st <- getState- let meta = runF (stateMeta' st) st+ let meta = stateMeta st return $ Pandoc meta (toList bs) -- block parser@@ -429,9 +428,7 @@ s <- lookAhead $ manyTill anyChar (try (char '|' >> many spaceChar >> newline)) guard $ not $ "||" `isInfixOf` ("|" ++ s ++ "|")- tr <- many tableCell- many spaceChar >> char '\n'- return tr+ many tableCell <* many spaceChar <* char '\n' tableCell :: PandocMonad m => VwParser m Blocks tableCell = try $@@ -446,18 +443,18 @@ many spaceChar >>string ('%':s) >> spaceChar contents <- trimInlines . mconcat <$> manyTill inline (lookAhead newline) --use lookAhead because of placeholder in the whitespace parser- let meta' = return $ B.setMeta s contents nullMeta :: F Meta- updateState $ \st -> st { stateMeta' = stateMeta' st <> meta' }+ let meta' = B.setMeta s contents nullMeta+ updateState $ \st -> st { stateMeta = stateMeta st <> meta' } noHtmlPh :: PandocMonad m => VwParser m () noHtmlPh = try $- () <$ (many spaceChar >> string "%nohtml" >> many spaceChar- >> lookAhead newline)+ () <$ many spaceChar <* string "%nohtml" <* many spaceChar+ <* lookAhead newline templatePh :: PandocMonad m => VwParser m () templatePh = try $- () <$ (many spaceChar >> string "%template" >>many (noneOf "\n")- >> lookAhead newline)+ () <$ many spaceChar <* string "%template" <* many (noneOf "\n")+ <* lookAhead newline -- inline parser @@ -617,10 +614,8 @@ procImgurl s = if take 6 s == "local:" then "file" ++ drop 5 s else s inlineMath :: PandocMonad m => VwParser m Inlines-inlineMath = try $ do- char '$'- contents <- many1Till (noneOf "\n") (char '$')- return $ B.math contents+inlineMath = try $+ B.math <$ char '$' <*> many1Till (noneOf "\n") (char '$') tag :: PandocMonad m => VwParser m Inlines tag = try $ do
@@ -0,0 +1,441 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE OverloadedStrings #-}+{-+Copyright (C) 2018 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.RoffChar+ Copyright : Copyright (C) 2007-2018 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Roff character escaping/unescaping.+-}++module Text.Pandoc.RoffChar (+ standardEscapes+ , characterCodes+ , combiningAccents+ ) where+import Prelude++-- | These are the escapes specifically mentioned in groff_man(7),+-- plus @ and ellipsis.+standardEscapes :: [(Char, String)]+standardEscapes =+ [ ('\160', "\\ ")+ , ('\'', "\\[aq]")+ , ('‘', "\\[oq]")+ , ('’', "\\[cq]")+ , ('"', "\\[dq]")+ , ('“', "\\[lq]")+ , ('”', "\\[rq]")+ , ('—', "\\[em]")+ , ('–', "\\[en]")+ , ('`', "\\[ga]")+ , ('^', "\\[ha]")+ , ('~', "\\[ti]")+ , ('-', "\\-") -- minus; - will be interpreted as hyphen U+2010+ , ('\\', "\\[rs]")+ , ('@', "\\[at]") -- because we use @ as a table and math delimiter+ , ('\x2026', "\\&...") -- because u2026 doesn't render on tty+ ]++characterCodes :: [(Char, String)]+characterCodes =+ [ ('Ð', "-D")+ , ('ð', "Sd")+ , ('Þ', "TP")+ , ('þ', "Tp")+ , ('ß', "ss")+ , ('ff', "ff")+ , ('fi', "fi")+ , ('fl', "fl")+ , ('ffi', "Fi")+ , ('ffl', "Fl")+ , ('Ł', "/L")+ , ('ł', "/l")+ , ('Ø', "/O")+ , ('ø', "/o")+ , ('Æ', "AE")+ , ('æ', "ae")+ , ('Œ', "OE")+ , ('œ', "oe")+ , ('IJ', "IJ")+ , ('ij', "ij")+ , ('ı', ".i")+ , ('ȷ', ".j")+ , ('Á', "'A")+ , ('Ć', "'C")+ , ('É', "'E")+ , ('Í', "'I")+ , ('Ó', "'O")+ , ('Ú', "'U")+ , ('Ý', "'Y")+ , ('á', "'a")+ , ('ć', "'c")+ , ('é', "'e")+ , ('í', "'i")+ , ('ó', "'o")+ , ('ú', "'u")+ , ('ý', "'y")+ , ('Ä', ":A")+ , ('Ë', ":E")+ , ('Ï', ":I")+ , ('Ö', ":O")+ , ('Ü', ":U")+ , ('Ÿ', ":Y")+ , ('ä', ":a")+ , ('ë', ":e")+ , ('ï', ":i")+ , ('ö', ":o")+ , ('ü', ":u")+ , ('ÿ', ":y")+ , ('Â', "^A")+ , ('Ê', "^E")+ , ('Î', "^I")+ , ('Ô', "^O")+ , ('Û', "^U")+ , ('â', "^a")+ , ('ê', "^e")+ , ('î', "^i")+ , ('ô', "^o")+ , ('û', "^u")+ , ('À', "`A")+ , ('È', "`E")+ , ('Ì', "`I")+ , ('Ò', "`O")+ , ('Ù', "`U")+ , ('à', "`a")+ , ('è', "`e")+ , ('ì', "`i")+ , ('ò', "`o")+ , ('ù', "`u")+ , ('Ã', "~A")+ , ('Ñ', "~N")+ , ('Õ', "~O")+ , ('ã', "~a")+ , ('ñ', "~n")+ , ('õ', "~o")+ , ('Š', "vS")+ , ('š', "vs")+ , ('Ž', "vZ")+ , ('ž', "vz")+ , ('Ç', ",C")+ , ('ç', ",c")+ , ('Å', "oA")+ , ('å', "oa")+ , ('˝', "a\"")+ , ('¯', "a-")+ , ('˙', "a.")+ , ('^', "a^")+ , ('´', "aa")+ , ('`', "ga")+ , ('˘', "ab")+ , ('¸', "ac")+ , ('¨', "ad")+ , ('ˇ', "ah")+ , ('˚', "ao")+ , ('~', "a~")+ , ('˛', "ho")+ , ('^', "ha")+ , ('~', "ti")+ , ('„', "Bq")+ , ('‚', "bq")+ , ('“', "lq")+ , ('”', "rq")+ , ('‘', "oq")+ , ('’', "cq")+ , ('\'', "aq")+ , ('"', "dq")+ , ('«', "Fo")+ , ('»', "Fc")+ , ('‹', "fo")+ , ('›', "fc")+ , ('¡', "r!")+ , ('¿', "r?")+ , ('—', "em")+ , ('–', "en")+ , ('‐', "hy")+ , ('[', "lB")+ , (']', "rB")+ , ('{', "lC")+ , ('}', "rC")+ , ('⟨', "la")+ , ('⟩', "ra")+ , ('⎪', "bv")+ , ('⎪', "braceex")+ , ('⎡', "bracketlefttp")+ , ('⎣', "bracketleftbt")+ , ('⎢', "bracketleftex")+ , ('⎤', "bracketrighttp")+ , ('⎦', "bracketrightbt")+ , ('⎥', "bracketrightex")+ , ('╭', "lt")+ , ('⎧', "bracelefttp")+ , ('┥', "lk")+ , ('⎨', "braceleftmid")+ , ('╰', "lb")+ , ('⎩', "braceleftbt")+ , ('⎪', "braceleftex")+ , ('╮', "rt")+ , ('⎫', "bracerighttp")+ , ('┝', "rk")+ , ('⎬', "bracerightmid")+ , ('╯', "rb")+ , ('⎭', "bracerightbt")+ , ('⎪', "bracerightex")+ , ('⎛', "parenlefttp")+ , ('⎝', "parenleftbt")+ , ('⎜', "parenleftex")+ , ('⎞', "parenrighttp")+ , ('⎠', "parenrightbt")+ , ('⎟', "parenrightex")+ , ('←', "<-")+ , ('→', "->")+ , ('↔', "<>")+ , ('↓', "da")+ , ('↑', "ua")+ , ('↕', "va")+ , ('⇐', "lA")+ , ('⇒', "rA")+ , ('⇔', "hA")+ , ('⇓', "dA")+ , ('⇑', "uA")+ , ('⇕', "vA")+ , ('⎯', "an")+ , ('|', "ba")+ , ('│', "br")+ , ('_', "ul")+ , ('‾', "rn")+ , ('_', "ru")+ , ('¦', "bb")+ , ('/', "sl")+ , ('\\', "rs")+ , ('○', "ci")+ , ('·', "bu")+ , ('‡', "dd")+ , ('†', "dg")+ , ('◊', "lz")+ , ('□', "sq")+ , ('¶', "ps")+ , ('§', "sc")+ , ('☜', "lh")+ , ('☞', "rh")+ , ('@', "at")+ , ('#', "sh")+ , ('↵', "CR")+ , ('✓', "OK")+ , ('©', "co")+ , ('®', "rg")+ , ('™', "tm")+ , ('$', "Do")+ , ('¢', "ct")+ , ('€', "eu")+ , ('€', "Eu")+ , ('¥', "Ye")+ , ('£', "Po")+ , ('¤', "Cs")+ , ('ƒ', "Fn")+ , ('°', "de")+ , ('‰', "%0")+ , ('′', "fm")+ , ('″', "sd")+ , ('µ', "mc")+ , ('ª', "Of")+ , ('º', "Om")+ , ('∧', "AN")+ , ('∨', "OR")+ , ('¬', "no")+ , ('¬', "tno")+ , ('∃', "te")+ , ('∀', "fa")+ , ('∋', "st")+ , ('∴', "3d")+ , ('∴', "tf")+ , ('|', "or")+ , ('½', "12")+ , ('¼', "14")+ , ('¾', "34")+ , ('⅛', "18")+ , ('⅜', "38")+ , ('⅝', "58")+ , ('⅞', "78")+ , ('¹', "S1")+ , ('²', "S2")+ , ('³', "S3")+ , ('+', "pl")+ , ('−', "mi")+ , ('∓', "-+")+ , ('±', "+-")+ , ('±', "t+-")+ , ('·', "pc")+ , ('⋅', "md")+ , ('×', "mu")+ , ('×', "tmu")+ , ('⊗', "c*")+ , ('⊕', "c+")+ , ('÷', "di")+ , ('÷', "tdi")+ , ('⁄', "f/")+ , ('∗', "**")+ , ('≤', "<=")+ , ('≥', ">=")+ , ('≪', "<<")+ , ('≫', ">>")+ , ('=', "eq")+ , ('≠', "!=")+ , ('≡', "==")+ , ('≢', "ne")+ , ('≅', "=~")+ , ('≃', "|=")+ , ('∼', "ap")+ , ('≈', "~~")+ , ('≈', "~=")+ , ('∝', "pt")+ , ('∅', "es")+ , ('∈', "mo")+ , ('∉', "nm")+ , ('⊂', "sb")+ , ('⊄', "nb")+ , ('⊃', "sp")+ , ('⊅', "nc")+ , ('⊆', "ib")+ , ('⊇', "ip")+ , ('∩', "ca")+ , ('∪', "cu")+ , ('∠', "/_")+ , ('⊥', "pp")+ , ('∫', "is")+ , ('∫', "integral")+ , ('∑', "sum")+ , ('∏', "product")+ , ('∐', "coproduct")+ , ('∇', "gr")+ , ('√', "sr")+ , ('√', "sqrt")+ -- , "radicalex"+ -- "sqrtex"+ , ('⌈', "lc")+ , ('⌉', "rc")+ , ('⌊', "lf")+ , ('⌋', "rf")+ , ('∞', "if")+ , ('ℵ', "Ah")+ , ('ℑ', "Im")+ , ('ℜ', "Re")+ , ('℘', "wp")+ , ('∂', "pd")+ , ('ℏ', "-h")+ , ('ℏ', "hbar")+ , ('Α', "*A")+ , ('Β', "*B")+ , ('Γ', "*G")+ , ('Δ', "*D")+ , ('Ε', "*E")+ , ('Ζ', "*Z")+ , ('Η', "*Y")+ , ('Θ', "*H")+ , ('Ι', "*I")+ , ('Κ', "*K")+ , ('Λ', "*L")+ , ('Μ', "*M")+ , ('Ν', "*N")+ , ('Ξ', "*C")+ , ('Ο', "*O")+ , ('Π', "*P")+ , ('Ρ', "*R")+ , ('Σ', "*S")+ , ('Τ', "*T")+ , ('Υ', "*U")+ , ('Φ', "*F")+ , ('Χ', "*X")+ , ('Ψ', "*Q")+ , ('Ω', "*W")+ , ('α', "*a")+ , ('β', "*b")+ , ('γ', "*g")+ , ('δ', "*d")+ , ('ε', "*e")+ , ('ζ', "*z")+ , ('η', "*y")+ , ('θ', "*h")+ , ('ι', "*i")+ , ('κ', "*k")+ , ('λ', "*l")+ , ('μ', "*m")+ , ('ν', "*n")+ , ('ξ', "*c")+ , ('ο', "*o")+ , ('π', "*p")+ , ('ρ', "*r")+ , ('ς', "ts")+ , ('σ', "*s")+ , ('τ', "*t")+ , ('υ', "*u")+ , ('ϕ', "*f")+ , ('χ', "*x")+ , ('ψ', "*q")+ , ('ω', "*w")+ , ('ϑ', "+h")+ , ('φ', "+f")+ , ('ϖ', "+p")+ , ('ϵ', "+e")+ , ('♣', "CL")+ , ('♠', "SP")+ , ('♥', "HE")+ , ('♦', "DI")+ , ('˝' , "a\"")+ , ('¯', "a-")+ , ('˙', "a.")+ , ('^', "a^")+ , ('´', "aa")+ , ('`', "ga")+ , ('˘', "ab")+ , ('¸', "ac")+ , ('¨', "ad")+ , ('ˇ', "ah")+ , ('˚', "ao")+ , ('~', "a~")+ , ('˛', "ho")+ , ('^', "ha")+ , ('~', "ti")+ ]++-- use like: \\[E a^ aa]+combiningAccents :: [(Char, String)]+combiningAccents =+ [ ('\779' , "a\"")+ , ('\772', "a-")+ , ('\775', "a.")+ , ('\770', "a^")+ , ('\769', "aa")+ , ('\768', "ga")+ , ('\774', "ab")+ , ('\807', "ac")+ , ('\776', "ad")+ , ('\780', "ah")+ , ('\778', "ao")+ , ('\771', "a~")+ , ('\808', "ho")+ , ('\770', "ha")+ , ('\771', "ti")+ ]
@@ -6,6 +6,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeSynonymInstances #-} {- Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu> @@ -43,12 +45,14 @@ substitute, ordNub, -- * Text processing+ ToString (..), backslashEscapes, escapeStringUsing, stripTrailingNewlines, trim, triml, trimr,+ trimMath, stripFirstAndLast, camelCaseToHyphenated, toRomanNumeral,@@ -79,6 +83,7 @@ makeMeta, eastAsianLineBreakFilter, underlineSpan,+ splitSentences, -- * TagSoup HTML handling renderTags', -- * File handling@@ -110,6 +115,7 @@ import Control.Monad (MonadPlus (..), msum, unless) import qualified Control.Monad.State.Strict as S import qualified Data.ByteString.Lazy as BL+import qualified Data.Bifunctor as Bifunctor import Data.Char (isAlpha, isDigit, isLetter, isLower, isSpace, isUpper, toLower) import Data.Data (Data, Typeable)@@ -190,6 +196,15 @@ -- Text processing -- +class ToString a where+ toString :: a -> String++instance ToString String where+ toString = id++instance ToString T.Text where+ toString = T.unpack+ -- | Returns an association list of backslash escapes for the -- designated characters. backslashEscapes :: [Char] -- ^ list of special characters to escape@@ -222,6 +237,15 @@ trimr :: String -> String trimr = reverse . triml . reverse +-- | Trim leading space and trailing space unless after \.+trimMath :: String -> String+trimMath = triml . reverse . stripspace . reverse+ where+ stripspace (c1:c2:cs)+ | c1 `elem` [' ','\t','\n','\r']+ , c2 /= '\\' = stripspace (c2:cs)+ stripspace cs = cs+ -- | Strip leading and trailing characters from string stripFirstAndLast :: String -> String stripFirstAndLast str =@@ -582,7 +606,32 @@ underlineSpan :: Inlines -> Inlines underlineSpan = B.spanWith ("", ["underline"], []) +-- | 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+ (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 +-- | Split a list of inlines into sentences.+splitSentences :: [Inline] -> [[Inline]]+splitSentences xs =+ let (sent, rest) = breakSentence xs+ in if null rest then [sent] else sent : splitSentences rest+ -- -- TagSoup HTML handling --@@ -611,8 +660,7 @@ -- mapLeft :: (a -> b) -> Either a c -> Either b c-mapLeft f (Left x) = Left (f x)-mapLeft _ (Right x) = Right x+mapLeft = Bifunctor.first -- | Remove intermediate "." and ".." directories from a path. --
@@ -40,14 +40,11 @@ module Text.Pandoc.Writers.AsciiDoc (writeAsciiDoc) where import Prelude import Control.Monad.State.Strict-import Data.Aeson (Result (..), Value (String), fromJSON, toJSON) import Data.Char (isPunctuation, isSpace) import Data.List (intercalate, intersperse, stripPrefix)-import qualified Data.Map as M import Data.Maybe (fromMaybe, isJust, listToMaybe) import qualified Data.Set as Set import Data.Text (Text)-import qualified Data.Text as T import Text.Pandoc.Class (PandocMonad, report) import Text.Pandoc.Definition import Text.Pandoc.ImageSize@@ -93,24 +90,25 @@ (fmap render' . blockListToAsciiDoc opts) (fmap render' . inlineListToAsciiDoc opts) meta- let addTitleLine (String t) = String $- t <> "\n" <> T.replicate (T.length t) "="- addTitleLine x = x- let metadata' = case fromJSON metadata of- Success m -> toJSON $ M.adjust addTitleLine- ("title" :: T.Text) m- _ -> metadata- body <- blockListToAsciiDoc opts blocks+ body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks) let main = render colwidth body let context = defField "body" main $ defField "toc" (writerTableOfContents opts && isJust (writerTemplate opts))- $defField "titleblock" titleblock metadata'+ $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+ -- | Escape special characters for AsciiDoc. escapeString :: String -> String escapeString = escapeStringUsing escs@@ -171,27 +169,17 @@ return $ blankline <> text "'''''" <> blankline blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do contents <- inlineListToAsciiDoc opts inlines- let len = offset contents- -- ident seem to be empty most of the time and asciidoc will generate them automatically- -- so lets make them not show up when null ids <- gets autoIds let autoId = uniqueIdent inlines ids modify $ \st -> st{ autoIds = Set.insert autoId ids }- let identifier = if null ident || (isEnabled Ext_auto_identifiers opts && ident == autoId)- then empty else "[[" <> text ident <> "]]"- let setext = writerSetextHeaders opts- return- (if setext- then- identifier $$ contents $$- (case level of- 1 -> text $ replicate len '-'- 2 -> text $ replicate len '~'- 3 -> text $ replicate len '^'- 4 -> text $ replicate len '+'- _ -> empty) <> blankline- else- identifier $$ text (replicate level '=') <> space <> contents <> blankline)+ let identifier = if null ident ||+ (isEnabled Ext_auto_identifiers opts && ident == autoId)+ then empty+ else "[[" <> text ident <> "]]"+ return $ identifier $$+ nowrap (text (replicate (level + 1) '=') <> space <> contents) <>+ blankline+ blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $ flush ( if null classes then "...." $$ text str $$ "...."
@@ -45,7 +45,7 @@ import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Options-import Text.Pandoc.Shared (isTightList, linesToPara, substitute)+import Text.Pandoc.Shared (isTightList, linesToPara, substitute, capitalize) import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Walk (query, walk, walkM) import Text.Pandoc.Writers.HTML (writeHtml5String, tagWithAttributes)@@ -253,18 +253,34 @@ inlineToNodes opts (Strikeout xs) = if isEnabled Ext_strikeout opts then (node (CUSTOM_INLINE "~~" "~~") (inlinesToNodes opts xs) :)- else ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs ++- [node (HTML_INLINE (T.pack "</s>")) []]) ++ )+ else if isEnabled Ext_raw_html opts+ then ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes opts xs +++ [node (HTML_INLINE (T.pack "</s>")) []]) ++ )+ else (inlinesToNodes opts xs ++) inlineToNodes opts (Superscript xs) =- ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs ++- [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )+ if isEnabled Ext_raw_html opts+ then ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes opts xs +++ [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )+ else case traverse toSuperscriptInline xs of+ Nothing ->+ ((node (TEXT (T.pack "^(")) [] : inlinesToNodes opts xs +++ [node (TEXT (T.pack ")")) []]) ++ )+ Just xs' -> (inlinesToNodes opts xs' ++) inlineToNodes opts (Subscript xs) =- ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs ++- [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )+ if isEnabled Ext_raw_html opts+ then ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes opts xs +++ [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )+ else case traverse toSubscriptInline xs of+ Nothing ->+ ((node (TEXT (T.pack "_(")) [] : inlinesToNodes opts xs +++ [node (TEXT (T.pack ")")) []]) ++ )+ Just xs' -> (inlinesToNodes opts xs' ++) inlineToNodes opts (SmallCaps xs) =- ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) []- : inlinesToNodes opts xs ++- [node (HTML_INLINE (T.pack "</span>")) []]) ++ )+ if isEnabled Ext_raw_html opts+ then ((node (HTML_INLINE (T.pack "<span class=\"smallcaps\">")) []+ : inlinesToNodes opts xs +++ [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) :) -- title beginning with fig: indicates implicit figure@@ -319,3 +335,19 @@ inlineToNodes opts (Cite _ ils) = (inlinesToNodes opts ils ++) inlineToNodes _ (Note _) = id -- should not occur -- we remove Note elements in preprocessing++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 LineBreak = Just LineBreak+toSubscriptInline SoftBreak = Just SoftBreak+toSubscriptInline _ = Nothing++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 LineBreak = Just LineBreak+toSuperscriptInline SoftBreak = Just SoftBreak+toSuperscriptInline _ = Nothing
@@ -1,4 +1,3 @@-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE NoImplicitPrelude #-} {- Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>@@ -44,10 +43,9 @@ import Text.Pandoc.Class (PandocIO) import Text.Pandoc.Definition import Text.Pandoc.Error-import Text.Pandoc.Lua.Init (LuaException (LuaException), runPandocLua,- registerScriptPath)-import Text.Pandoc.Lua.StackInstances ()-import Text.Pandoc.Lua.Util (addField)+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 qualified Text.Pandoc.UTF8 as UTF8@@ -109,14 +107,16 @@ -- | Convert Pandoc to custom markup. writeCustom :: FilePath -> WriterOptions -> Pandoc -> PandocIO Text writeCustom luaFile opts doc@(Pandoc meta _) = do- res <- runPandocLua $ do- registerScriptPath luaFile- stat <- Lua.dofile luaFile+ let globals = [ PANDOC_DOCUMENT doc+ , PANDOC_SCRIPT_FILE luaFile+ ]+ res <- runLua $ do+ setGlobals globals+ stat <- dofileWithTraceback luaFile -- 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- -- TODO - call hierarchicalize, so we have that info rendered <- docToCustom opts doc context <- metaToJSON opts blockListToCustom
@@ -126,9 +126,10 @@ defField "mathml" (case writerHTMLMathMethod opts of MathML -> True _ -> False) metadata- case writerTemplate opts of- Nothing -> return main- Just tpl -> renderTemplate' tpl context+ (if writerPreferAscii opts then 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
@@ -66,8 +66,7 @@ import Text.Pandoc.Shared hiding (Element) import Text.Pandoc.Walk import Text.Pandoc.Writers.Math-import Text.Pandoc.Writers.Shared (isDisplayMath, fixDisplayMath,- metaValueToInlines)+import Text.Pandoc.Writers.Shared import Text.Printf (printf) import Text.TeXMath import Text.XML.Light as XML@@ -267,8 +266,9 @@ -- parse styledoc for heading styles let styleMaps = getStyleMaps styledoc - let tocTitle = fromMaybe (stTocTitle defaultWriterState) $- metaValueToInlines <$> lookupMeta "toc-title" meta+ let tocTitle = case lookupMetaInlines "toc-title" meta of+ [] -> stTocTitle defaultWriterState+ ls -> ls let initialSt = defaultWriterState { stStyleMaps = styleMaps@@ -349,6 +349,8 @@ "application/vnd.openxmlformats-officedocument.extended-properties+xml") ,("/docProps/core.xml", "application/vnd.openxmlformats-package.core-properties+xml")+ ,("/docProps/custom.xml",+ "application/vnd.openxmlformats-officedocument.custom-properties+xml") ,("/word/styles.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml") ,("/word/document.xml",@@ -507,6 +509,19 @@ ]) (formatTime defaultTimeLocale "%FT%XZ" utctime) let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps + let customProperties :: [(String, String)]+ customProperties = [] -- FIXME+ let mkCustomProp (k, v) pid = mknode "property"+ [("fmtid","{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")+ ,("pid", show pid)+ ,("name", k)] $ mknode "vt:lpwstr" [] v+ let customPropsPath = "docProps/custom.xml"+ let customProps = mknode "Properties"+ [("xmlns","http://schemas.openxmlformats.org/officeDocument/2006/custom-properties")+ ,("xmlns:vt","http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes")+ ] $ zipWith mkCustomProp customProperties [(2 :: Int)..]+ let customPropsEntry = toEntry customPropsPath epochtime $ renderXml customProps+ let relsPath = "_rels/.rels" let rels = mknode "Relationships" [("xmlns", "http://schemas.openxmlformats.org/package/2006/relationships")] $ map (\attrs -> mknode "Relationship" attrs ())@@ -519,6 +534,9 @@ , [("Id","rId3") ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties") ,("Target","docProps/core.xml")]+ , [("Id","rId5")+ ,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties")+ ,("Target","docProps/custom.xml")] ] let relsEntry = toEntry relsPath epochtime $ renderXml rels @@ -558,7 +576,8 @@ contentTypesEntry : relsEntry : contentEntry : relEntry : footnoteRelEntry : numEntry : styleEntry : footnotesEntry : commentsEntry :- docPropsEntry : docPropsAppEntry : themeEntry :+ docPropsEntry : docPropsAppEntry : customPropsEntry :+ themeEntry : fontTableEntry : settingsEntry : webSettingsEntry : imageEntries ++ headerFooterEntries ++ miscRelEntries ++ otherMediaEntries@@ -760,24 +779,9 @@ let tit = docTitle meta let auths = docAuthors meta let dat = docDate meta- let abstract' = case lookupMeta "abstract" meta of- Just (MetaBlocks bs) -> bs- Just (MetaInlines ils) -> [Plain ils]- Just (MetaString s) -> [Plain [Str s]]- _ -> []- let subtitle' = case lookupMeta "subtitle" meta of- Just (MetaBlocks [Plain xs]) -> xs- Just (MetaBlocks [Para xs]) -> xs- Just (MetaInlines xs) -> xs- Just (MetaString s) -> [Str s]- _ -> []- let includeTOC = writerTableOfContents opts ||- case lookupMeta "toc" meta of- Just (MetaBlocks _) -> True- Just (MetaInlines _) -> True- Just (MetaString (_:_)) -> True- Just (MetaBool True) -> True- _ -> False+ let abstract' = lookupMetaBlocks "abstract" meta+ let subtitle' = lookupMetaInlines "subtitle" meta+ 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 $@@ -960,8 +964,13 @@ else withParaProp (pCustomStyle "TableCaption") $ blockToOpenXML opts (Para caption) let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()- let cellToOpenXML (al, cell) = withParaProp (alignmentFor al)- $ blocksToOpenXML opts cell+ -- Table cells require a <w:p> element, even an empty one!+ -- Not in the spec but in Word 2007, 2010. See #4953.+ let cellToOpenXML (al, cell) = do+ es <- withParaProp (alignmentFor al) $ blocksToOpenXML opts cell+ if any (\e -> qName (elName e) == "p") es+ then return es+ else return $ es ++ [mknode "w:p" [] ()] headers' <- mapM cellToOpenXML $ zip aligns headers rows' <- mapM (mapM cellToOpenXML . zip aligns) rows let borderProps = mknode "w:tcPr" []
@@ -36,6 +36,7 @@ import Prelude import Codec.Archive.Zip (Entry, addEntryToArchive, eRelativePath, emptyArchive, fromArchive, fromEntry, toEntry)+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,@@ -351,9 +352,9 @@ rights = metaValueToString <$> lookupMeta "rights" meta coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus` (metaValueToString <$> lookupMeta "cover-image" meta)- stylesheets = fromMaybe []- (metaValueToPaths <$> lookupMeta "stylesheet" meta) ++- [f | ("css",f) <- writerVariables opts]+ mCss = lookupMeta "css" meta <|> lookupMeta "stylesheet" meta+ stylesheets = fromMaybe [] (metaValueToPaths <$> mCss) +++ [f | ("css",f) <- writerVariables opts] pageDirection = case map toLower . metaValueToString <$> lookupMeta "page-progression-direction" meta of Just "ltr" -> Just LTR
@@ -75,7 +75,8 @@ import Text.Pandoc.Walk import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared-import Text.Pandoc.XML (escapeStringForXML, fromEntities)+import Text.Pandoc.XML (escapeStringForXML, fromEntities,+ toEntities, toHtml5Entities) #if MIN_VERSION_blaze_markup(0,6,3) #else import Text.Blaze.Internal (preEscapedString, preEscapedText)@@ -206,7 +207,13 @@ => WriterState -> WriterOptions -> Pandoc -> m Text writeHtmlString' st opts d = do (body, context) <- evalStateT (pandocToHtml opts d) st- case writerTemplate opts of+ (if writerPreferAscii opts+ then+ if stHtml5 st+ then toHtml5Entities+ else toEntities+ else id) <$>+ case writerTemplate opts of Nothing -> return $ renderHtml' body Just tpl -> do -- warn if empty lang@@ -221,16 +228,19 @@ lookup "sourcefile" (writerVariables opts) report $ NoTitleElement fallback return $ resetField "pagetitle" fallback context- renderTemplate' tpl $- defField "body" (renderHtml' body) context'+ renderTemplate' tpl+ (defField "body" (renderHtml' body) context') writeHtml' :: PandocMonad m => WriterState -> WriterOptions -> Pandoc -> m Html writeHtml' st opts d = case writerTemplate opts of Just _ -> preEscapedText <$> writeHtmlString' st opts d- Nothing -> do- (body, _) <- evalStateT (pandocToHtml opts d) st- return body+ Nothing+ | writerPreferAscii opts+ -> preEscapedText <$> writeHtmlString' st opts d+ | otherwise -> do+ (body, _) <- evalStateT (pandocToHtml opts d) st+ return body -- result is (title, authors, date, toc, body, new variables) pandocToHtml :: PandocMonad m@@ -273,10 +283,10 @@ KaTeX url -> do H.script ! A.src (toValue $ url ++ "katex.min.js") $ mempty- H.script !- A.src (toValue $ url ++ "contrib/auto-render.min.js") $ mempty+ nl opts H.script- "document.addEventListener(\"DOMContentLoaded\", function() {\n renderMathInElement(document.body);\n});"+ "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") @@ -1061,8 +1071,8 @@ DisplayMath -> "\\[" ++ str ++ "\\]" KaTeX _ -> return $ H.span ! A.class_ mathClass $ toHtml $ case t of- InlineMath -> "\\(" ++ str ++ "\\)"- DisplayMath -> "\\[" ++ str ++ "\\]"+ InlineMath -> str+ DisplayMath -> str PlainMath -> do x <- lift (texMathToInlines t str) >>= inlineListToHtml opts let m = H.span ! A.class_ mathClass $ x
@@ -149,7 +149,8 @@ $ defField "charStyles" (render' $ charStylesToDoc st) $ defField "parStyles" (render' $ parStylesToDoc st) $ defField "hyperlinks" (render' $ hyperlinksToDoc $ links st) metadata- case writerTemplate opts of+ (if writerPreferAscii opts then toEntities else id) <$>+ case writerTemplate opts of Nothing -> return main Just tpl -> renderTemplate' tpl context
@@ -102,7 +102,8 @@ $ defField "mathml" (case writerHTMLMathMethod opts of MathML -> True _ -> False) metadata- case writerTemplate opts of+ (if writerPreferAscii opts then toEntities else id) <$>+ case writerTemplate opts of Nothing -> return main Just tpl -> renderTemplate' tpl context
@@ -42,8 +42,9 @@ import Data.Char (isAlphaNum, isAscii, isDigit, isLetter, isPunctuation, ord, toLower) import Data.List (foldl', intercalate, intersperse, isInfixOf, nubBy,- stripPrefix, (\\))+ stripPrefix, (\\), 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)@@ -63,6 +64,7 @@ import Text.Pandoc.Writers.Shared import qualified Text.Parsec as P import Text.Printf (printf)+import qualified Data.Text.Normalize as Normalize data WriterState = WriterState { stInNote :: Bool -- true if we're in a note@@ -318,47 +320,111 @@ -- escape things as needed for LaTeX stringToLaTeX :: PandocMonad m => StringContext -> String -> LW m String-stringToLaTeX _ [] = return ""-stringToLaTeX ctx (x:xs) = do+stringToLaTeX context zs = do opts <- gets stOptions- rest <- stringToLaTeX ctx xs- let ligatures = isEnabled Ext_smart opts && ctx == TextString- let isUrl = ctx == URLString- return $+ go opts context $+ if writerPreferAscii opts+ then T.unpack $ Normalize.normalize Normalize.NFD $ T.pack zs+ else zs+ where+ go _ _ [] = return ""+ go opts ctx (x:xs) = do+ let ligatures = isEnabled Ext_smart opts && ctx == TextString+ let isUrl = ctx == URLString+ let mbAccentCmd =+ if writerPreferAscii opts && ctx == TextString+ then uncons xs >>= \(c,_) -> M.lookup c accents+ else Nothing+ let emits s =+ case mbAccentCmd of+ Just cmd -> ((cmd ++ "{" ++ s ++ "}") ++)+ <$> go opts ctx (drop 1 xs) -- drop combining accent+ Nothing -> (s++) <$> go opts ctx xs+ let emitc c =+ case mbAccentCmd of+ Just cmd -> ((cmd ++ "{" ++ [c] ++ "}") ++)+ <$> go opts ctx (drop 1 xs) -- drop combining accent+ Nothing -> (c:) <$> go opts ctx xs case x of- '{' -> "\\{" ++ rest- '}' -> "\\}" ++ rest- '`' | ctx == CodeString -> "\\textasciigrave{}" ++ rest- '$' | not isUrl -> "\\$" ++ rest- '%' -> "\\%" ++ rest- '&' -> "\\&" ++ rest- '_' | not isUrl -> "\\_" ++ rest- '#' -> "\\#" ++ rest- '-' | not isUrl -> case xs of- -- prevent adjacent hyphens from forming ligatures- ('-':_) -> "-\\/" ++ rest- _ -> '-' : rest- '~' | not isUrl -> "\\textasciitilde{}" ++ rest- '^' -> "\\^{}" ++ rest- '\\'| isUrl -> '/' : rest -- NB. / works as path sep even on Windows- | otherwise -> "\\textbackslash{}" ++ rest- '|' | not isUrl -> "\\textbar{}" ++ rest- '<' -> "\\textless{}" ++ rest- '>' -> "\\textgreater{}" ++ rest- '[' -> "{[}" ++ rest -- to avoid interpretation as- ']' -> "{]}" ++ rest -- optional arguments- '\'' | ctx == CodeString -> "\\textquotesingle{}" ++ rest- '\160' -> "~" ++ rest- '\x202F' -> "\\," ++ rest- '\x2026' -> "\\ldots{}" ++ rest- '\x2018' | ligatures -> "`" ++ rest- '\x2019' | ligatures -> "'" ++ rest- '\x201C' | ligatures -> "``" ++ rest- '\x201D' | ligatures -> "''" ++ rest- '\x2014' | ligatures -> "---" ++ rest- '\x2013' | ligatures -> "--" ++ rest- _ -> x : rest+ '{' -> emits "\\{"+ '}' -> emits "\\}"+ '`' | ctx == CodeString -> emits "\\textasciigrave{}"+ '$' | not isUrl -> emits "\\$"+ '%' -> emits "\\%"+ '&' -> emits "\\&"+ '_' | not isUrl -> emits "\\_"+ '#' -> emits "\\#"+ '-' | not isUrl -> case xs of+ -- prevent adjacent hyphens from forming ligatures+ ('-':_) -> emits "-\\/"+ _ -> emitc '-'+ '~' | not isUrl -> emits "\\textasciitilde{}"+ '^' -> emits "\\^{}"+ '\\'| isUrl -> emitc '/' -- NB. / works as path sep even on Windows+ | otherwise -> emits "\\textbackslash{}"+ '|' | not isUrl -> emits "\\textbar{}"+ '<' -> emits "\\textless{}"+ '>' -> emits "\\textgreater{}"+ '[' -> emits "{[}" -- to avoid interpretation as+ ']' -> emits "{]}" -- optional arguments+ '\'' | ctx == CodeString -> emits "\\textquotesingle{}"+ '\160' -> emits "~"+ '\x202F' -> emits "\\,"+ '\x2026' -> emits "\\ldots{}"+ '\x2018' | ligatures -> emits "`"+ '\x2019' | ligatures -> emits "'"+ '\x201C' | ligatures -> emits "``"+ '\x201D' | ligatures -> emits "''"+ '\x2014' | ligatures -> emits "---"+ '\x2013' | ligatures -> emits "--"+ _ | writerPreferAscii opts+ -> case x of+ 'ı' -> emits "\\i "+ 'ȷ' -> emits "\\j "+ 'å' -> emits "\\aa "+ 'Å' -> emits "\\AA "+ 'ß' -> emits "\\ss "+ 'ø' -> emits "\\o "+ 'Ø' -> emits "\\O "+ 'Ł' -> emits "\\L "+ 'ł' -> emits "\\l "+ 'æ' -> emits "\\ae "+ 'Æ' -> emits "\\AE "+ 'œ' -> emits "\\oe "+ 'Œ' -> emits "\\OE "+ '£' -> emits "\\pounds "+ '€' -> emits "\\euro "+ '©' -> emits "\\copyright "+ _ -> emitc x+ | otherwise -> emitc x +accents :: M.Map Char String+accents = M.fromList+ [ ('\779' , "\\H")+ , ('\768' , "\\`")+ , ('\769' , "\\'")+ , ('\770' , "\\^")+ , ('\771' , "\\~")+ , ('\776' , "\\\"")+ , ('\775' , "\\.")+ , ('\772' , "\\=")+ , ('\781' , "\\|")+ , ('\817' , "\\b")+ , ('\807' , "\\c")+ , ('\783' , "\\G")+ , ('\777' , "\\h")+ , ('\803' , "\\d")+ , ('\785' , "\\f")+ , ('\778' , "\\r")+ , ('\865' , "\\t")+ , ('\782' , "\\U")+ , ('\780' , "\\v")+ , ('\774' , "\\u")+ , ('\808' , "\\k")+ , ('\785' , "\\newtie")+ , ('\8413', "\\textcircled")+ ]+ toLabel :: PandocMonad m => String -> LW m String toLabel z = go `fmap` stringToLaTeX URLString z where go [] = ""@@ -589,7 +655,10 @@ [ (if key == "startFrom" then "firstnumber" else key) ++ "=" ++ mbBraced attr |- (key,attr) <- keyvalAttr ] +++ (key,attr) <- keyvalAttr,+ key `notElem` ["exports", "tangle", "results"]+ -- see #4889+ ] ++ (if identifier == "" then [] else [ "label=" ++ ref ])@@ -870,9 +939,11 @@ else term' def' <- liftM vsep $ mapM blockListToLaTeX defs return $ case defs of- ((Header{} : _) : _) ->+ ((Header{} : _) : _) -> "\\item" <> brackets term'' <> " ~ " $$ def'- _ ->+ ((CodeBlock{} : _) : _) -> -- see #4662+ "\\item" <> brackets term'' <> " ~ " $$ def'+ _ -> "\\item" <> brackets term'' $$ def' -- | Craft the section header, inserting the secton reference, if supplied.@@ -1097,10 +1168,10 @@ liftM text $ stringToLaTeX TextString str inlineToLaTeX (Math InlineMath str) = do setEmptyLine False- return $ "\\(" <> text str <> "\\)"+ return $ "\\(" <> text (handleMathComment str) <> "\\)" inlineToLaTeX (Math DisplayMath str) = do setEmptyLine False- return $ "\\[" <> text str <> "\\]"+ return $ "\\[" <> text (handleMathComment str) <> "\\]" inlineToLaTeX il@(RawInline f str) | f == Format "latex" || f == Format "tex" = do@@ -1201,6 +1272,16 @@ -- note: a \n before } needed when note ends with a Verbatim environment else "\\footnote" <> beamerMark <> braces noteContents +-- A comment at the end of math needs to be followed by a newline,+-- or the closing delimiter gets swallowed.+handleMathComment :: String -> String+handleMathComment s =+ let (_, ys) = break (\c -> c == '\n' || c == '%') $ reverse s+ in case ys of+ '%':'\\':_ -> s+ '%':_ -> s ++ "\n"+ _ -> s+ protectCode :: [Inline] -> [Inline] protectCode [] = [] protectCode (x@(Code ("",[],[]) _) : xs) = x : protectCode xs@@ -1298,19 +1379,27 @@ AuthorInText -> "textcite" NormalCitation -> "autocite" -citationsToBiblatex (c:cs) = do- args <- mapM convertOne (c:cs)- return $ text cmd <> foldl' (<>) empty args- where- cmd = case citationMode c of- SuppressAuthor -> "\\autocites*"- AuthorInText -> "\\textcites"- NormalCitation -> "\\autocites"- convertOne Citation { citationId = k- , citationPrefix = p- , citationSuffix = s- }- = citeArguments p s k+citationsToBiblatex (c:cs)+ | all (\cit -> null (citationPrefix cit) && null (citationSuffix cit)) (c:cs)+ = do+ let cmd = case citationMode c of+ SuppressAuthor -> "\\autocite*"+ AuthorInText -> "\\textcite"+ NormalCitation -> "\\autocite"+ return $ text cmd <>+ braces (text (intercalate "," (map citationId (c:cs))))+ | otherwise = do+ let cmd = case citationMode c of+ SuppressAuthor -> "\\autocites*"+ AuthorInText -> "\\textcites"+ NormalCitation -> "\\autocites"+ let convertOne Citation { citationId = k+ , citationPrefix = p+ , citationSuffix = s+ }+ = citeArguments p s k+ args <- mapM convertOne (c:cs)+ return $ text cmd <> foldl' (<>) empty args citationsToBiblatex _ = return empty
@@ -27,14 +27,13 @@ Stability : alpha Portability : portable -Conversion of 'Pandoc' documents to groff man page format.+Conversion of 'Pandoc' documents to roff man page format. -} module Text.Pandoc.Writers.Man ( writeMan) where import Prelude import Control.Monad.State.Strict-import Data.List (intercalate, intersperse, sort, stripPrefix)-import qualified Data.Map as Map+import Data.List (intersperse, stripPrefix) import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T@@ -48,28 +47,15 @@ import Text.Pandoc.Templates import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared+import Text.Pandoc.Writers.Roff import Text.Printf (printf) -type Notes = [[Block]]-data WriterState = WriterState { stNotes :: Notes- , stFontFeatures :: Map.Map Char Bool- , stHasTables :: Bool }--defaultWriterState :: WriterState-defaultWriterState = WriterState { stNotes = []- , stFontFeatures = Map.fromList [- ('I',False)- , ('B',False)- , ('C',False)- ]- , stHasTables = False }- -- | Convert Pandoc to Man. writeMan :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeMan opts document = evalStateT (pandocToMan opts document) defaultWriterState --- | Return groff man representation of document.+-- | Return roff man representation of document. pandocToMan :: PandocMonad m => WriterOptions -> Pandoc -> StateT WriterState m Text pandocToMan opts (Pandoc meta blocks) = do let colwidth = if writerWrapText opts == WrapAuto@@ -111,6 +97,9 @@ Nothing -> return main Just tpl -> renderTemplate' tpl context +escString :: WriterOptions -> String -> String+escString _ = escapeString AsciiOnly -- for better portability+ -- | Return man representation of notes. notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState m Doc notesToMan opts notes =@@ -126,58 +115,10 @@ let marker = cr <> text ".SS " <> brackets (text (show num)) return $ marker $$ contents --- | Association list of characters to escape.-manEscapes :: [(Char, String)]-manEscapes = [ ('\160', "\\ ")- , ('\'', "\\[aq]")- , ('’', "'")- , ('\x2014', "\\[em]")- , ('\x2013', "\\[en]")- , ('\x2026', "\\&...")- ] ++ backslashEscapes "-@\\"---- | Escape special characters for Man.-escapeString :: String -> String-escapeString = escapeStringUsing manEscapes---- | Escape a literal (code) section for Man.-escapeCode :: String -> String-escapeCode = intercalate "\n" . map escapeLine . lines where- escapeLine codeline =- case escapeStringUsing (manEscapes ++ backslashEscapes "\t ") codeline of- a@('.':_) -> "\\&" ++ a- b -> b- -- We split inline lists into sentences, and print one sentence per--- line. groff/troff treats the line-ending period differently.+-- line. roff treats the line-ending period differently. -- See http://code.google.com/p/pandoc/issues/detail?id=148. --- | 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- (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---- | Split a list of inlines into sentences.-splitSentences :: [Inline] -> [[Inline]]-splitSentences xs =- let (sent, rest) = breakSentence xs- in if null rest then [sent] else sent : splitSentences rest- -- | Convert Pandoc block element to man. blockToMan :: PandocMonad m => WriterOptions -- ^ Options@@ -204,13 +145,16 @@ let heading = case level of 1 -> ".SH " _ -> ".SS "- return $ text heading <> contents-blockToMan _ (CodeBlock _ str) = return $+ return $ nowrap $ text heading <> contents+blockToMan opts (CodeBlock _ str) = return $ text ".IP" $$ text ".nf" $$ text "\\f[C]" $$- text (escapeCode str) $$- text "\\f[]" $$+ ((case str of+ '.':_ -> text "\\&"+ _ -> mempty) <>+ text (escString opts str)) $$+ text "\\f[R]" $$ text ".fi" blockToMan opts (BlockQuote blocks) = do contents <- blockListToMan opts blocks@@ -315,7 +259,9 @@ rest' <- liftM vcat $ mapM (\item -> blockToMan opts item) xs return $ first' $$- text ".RS" $$ rest' $$ text ".RE"+ if null xs+ then empty+ else text ".RS" $$ rest' $$ text ".RE" [] -> return empty return $ text ".TP" $$ nowrap (text ".B " <> labelText) $$ contents @@ -356,11 +302,11 @@ return $ text "\\[lq]" <> contents <> text "\\[rq]" inlineToMan opts (Cite _ lst) = inlineListToMan opts lst-inlineToMan _ (Code _ str) =- withFontFeature 'C' (return (text $ escapeCode str))-inlineToMan _ (Str str@('.':_)) =- return $ afterBreak "\\&" <> text (escapeString str)-inlineToMan _ (Str str) = return $ text $ escapeString str+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 inlineToMan opts (Math InlineMath str) = lift (texMathToInlines InlineMath str) >>= inlineListToMan opts inlineToMan opts (Math DisplayMath str) = do@@ -398,21 +344,3 @@ notes <- gets stNotes let ref = show (length notes) return $ char '[' <> text ref <> char ']'--fontChange :: PandocMonad m => StateT WriterState m Doc-fontChange = do- features <- gets stFontFeatures- let filling = sort [c | (c,True) <- Map.toList features]- return $ text $ "\\f[" ++ filling ++ "]"--withFontFeature :: PandocMonad m- => Char- -> StateT WriterState m Doc- -> StateT WriterState m Doc-withFontFeature c action = do- modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }- begin <- fontChange- d <- action- modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }- end <- fontChange- return $ begin <> d <> end
@@ -38,7 +38,7 @@ import Prelude import Control.Monad.Reader import Control.Monad.State.Strict-import Data.Char (chr, isPunctuation, isSpace, ord, isAlphaNum)+import Data.Char (isPunctuation, isSpace, isAlphaNum) import Data.Default import qualified Data.HashMap.Strict as H import Data.List (find, group, intersperse, sortBy, stripPrefix, transpose)@@ -65,6 +65,7 @@ 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)@@ -279,39 +280,44 @@ -- | Escape special characters for Markdown. escapeString :: WriterOptions -> String -> String-escapeString _ [] = []-escapeString opts (c:cs) =- case c of+escapeString opts =+ (if writerPreferAscii opts+ then T.unpack . toHtml5Entities . T.pack+ else id) . go+ where+ go [] = []+ go (c:cs) =+ case c of '<' | isEnabled Ext_all_symbols_escapable opts ->- '\\' : '<' : escapeString opts cs- | otherwise -> "<" ++ escapeString opts cs+ '\\' : '<' : go cs+ | otherwise -> "<" ++ go cs '>' | isEnabled Ext_all_symbols_escapable opts ->- '\\' : '>' : escapeString opts cs- | otherwise -> ">" ++ escapeString opts cs+ '\\' : '>' : go cs+ | otherwise -> ">" ++ go cs '@' | isEnabled Ext_citations opts -> case cs of (d:_) | isAlphaNum d || d == '_'- -> '\\':'@':escapeString opts cs- _ -> '@':escapeString opts cs+ -> '\\':'@':go cs+ _ -> '@':go cs _ | c `elem` ['\\','`','*','_','[',']','#'] ->- '\\':c:escapeString opts cs- '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':escapeString opts cs- '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs+ '\\':c:go cs+ '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':go cs+ '^' | isEnabled Ext_superscript opts -> '\\':'^':go cs '~' | isEnabled Ext_subscript opts ||- isEnabled Ext_strikeout opts -> '\\':'~':escapeString opts cs- '$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':escapeString opts cs- '\'' | isEnabled Ext_smart opts -> '\\':'\'':escapeString opts cs- '"' | isEnabled Ext_smart opts -> '\\':'"':escapeString opts cs+ isEnabled Ext_strikeout opts -> '\\':'~':go cs+ '$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':go cs+ '\'' | isEnabled Ext_smart opts -> '\\':'\'':go cs+ '"' | isEnabled Ext_smart opts -> '\\':'"':go cs '-' | isEnabled Ext_smart opts -> case cs of- '-':_ -> '\\':'-':escapeString opts cs- _ -> '-':escapeString opts cs+ '-':_ -> '\\':'-':go cs+ _ -> '-':go cs '.' | isEnabled Ext_smart opts -> case cs of- '.':'.':rest -> '\\':'.':'.':'.':escapeString opts rest- _ -> '.':escapeString opts cs- _ -> c : escapeString opts cs+ '.':'.':rest -> '\\':'.':'.':'.':go rest+ _ -> '.':go cs+ _ -> c : go cs -- | Construct table of contents from list of header blocks. tableOfContents :: PandocMonad m => WriterOptions -> [Block] -> MD m Doc@@ -847,6 +853,13 @@ Plain ils : fixBlocks bs fixBlocks (Plain ils : bs) = Para ils : fixBlocks bs+ fixBlocks (r@(RawBlock f raw) : b : bs)+ | not (null raw)+ , last raw /= '\n' =+ case b of+ Plain{} -> r : fixBlocks (b:bs)+ RawBlock{} -> r : fixBlocks (b:bs)+ _ -> RawBlock f (raw ++ "\n") : fixBlocks (b:bs) -- #4629 fixBlocks (x : xs) = x : fixBlocks xs fixBlocks [] = [] isListBlock (BulletList _) = True@@ -1062,12 +1075,18 @@ contents <- inlineListToMarkdown opts lst return $ if isEnabled Ext_smart opts then "'" <> contents <> "'"- else "‘" <> contents <> "’"+ else+ if writerPreferAscii opts+ then "‘" <> contents <> "’"+ else "‘" <> contents <> "’" inlineToMarkdown opts (Quoted DoubleQuote lst) = do contents <- inlineListToMarkdown opts lst return $ if isEnabled Ext_smart opts then "\"" <> contents <> "\""- else "“" <> contents <> "”"+ else+ if writerPreferAscii opts+ then "“" <> contents <> "”"+ else "“" <> contents <> "”" inlineToMarkdown opts (Code attr str) = do let tickGroups = filter (\s -> '`' `elem` s) $ group str let longest = if null tickGroups@@ -1248,33 +1267,6 @@ where go (Emph xs) = Span nullAttr xs go x = x--toSuperscript :: Char -> Maybe Char-toSuperscript '1' = Just '\x00B9'-toSuperscript '2' = Just '\x00B2'-toSuperscript '3' = Just '\x00B3'-toSuperscript '+' = Just '\x207A'-toSuperscript '-' = Just '\x207B'-toSuperscript '=' = Just '\x207C'-toSuperscript '(' = Just '\x207D'-toSuperscript ')' = Just '\x207E'-toSuperscript c- | c >= '0' && c <= '9' =- Just $ chr (0x2070 + (ord c - 48))- | isSpace c = Just c- | otherwise = Nothing--toSubscript :: Char -> Maybe Char-toSubscript '+' = Just '\x208A'-toSubscript '-' = Just '\x208B'-toSubscript '=' = Just '\x208C'-toSubscript '(' = Just '\x208D'-toSubscript ')' = Just '\x208E'-toSubscript c- | c >= '0' && c <= '9' =- Just $ chr (0x2080 + (ord c - 48))- | isSpace c = Just c- | otherwise = Nothing lineBreakToSpace :: Inline -> Inline lineBreakToSpace LineBreak = Space
@@ -55,4 +55,4 @@ defaultMathJaxURL = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/" defaultKaTeXURL :: String-defaultKaTeXURL = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.3/"+defaultKaTeXURL = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/"
@@ -26,7 +26,7 @@ Stability : alpha Portability : portable -Conversion of 'Pandoc' documents to groff ms format.+Conversion of 'Pandoc' documents to roff ms format. TODO: @@ -60,42 +60,16 @@ import Text.Pandoc.Templates import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared+import Text.Pandoc.Writers.Roff import Text.Printf (printf) import Text.TeXMath (writeEqn) -data WriterState = WriterState { stHasInlineMath :: Bool- , stFirstPara :: Bool- , stNotes :: [Note]- , stSmallCaps :: Bool- , stHighlighting :: Bool- , stInHeader :: Bool- , stFontFeatures :: Map.Map Char Bool- }--defaultWriterState :: WriterState-defaultWriterState = WriterState{ stHasInlineMath = False- , stFirstPara = True- , stNotes = []- , stSmallCaps = False- , stHighlighting = False- , stInHeader = False- , stFontFeatures = Map.fromList [- ('I',False)- , ('B',False)- , ('C',False)- ]- }--type Note = [Block]--type MS = StateT WriterState- -- | Convert Pandoc to Ms. writeMs :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeMs opts document = evalStateT (pandocToMs opts document) defaultWriterState --- | Return groff ms representation of document.+-- | Return roff ms representation of document. pandocToMs :: PandocMonad m => WriterOptions -> Pandoc -> MS m Text pandocToMs opts (Pandoc meta blocks) = do let colwidth = if writerWrapText opts == WrapAuto@@ -110,8 +84,8 @@ body <- blockListToMs opts blocks let main = render' body hasInlineMath <- gets stHasInlineMath- let titleMeta = (escapeString . stringify) $ docTitle meta- let authorsMeta = map (escapeString . stringify) $ docAuthors meta+ let titleMeta = (escapeStr opts . stringify) $ docTitle meta+ let authorsMeta = map (escapeStr opts . stringify) $ docAuthors meta hasHighlighting <- gets stHighlighting let highlightingMacros = if hasHighlighting then case writerHighlightStyle opts of@@ -131,89 +105,27 @@ Nothing -> return main Just tpl -> renderTemplate' tpl context --- | Association list of characters to escape.-msEscapes :: Map.Map Char String-msEscapes = Map.fromList- [ ('\160', "\\~")- , ('\'', "\\[aq]")- , ('`', "\\`")- , ('"', "\\[dq]")- , ('\x2014', "\\[em]")- , ('\x2013', "\\[en]")- , ('\x2026', "\\&...")- , ('~', "\\[ti]")- , ('^', "\\[ha]")- , ('@', "\\@")- , ('\\', "\\\\")- ]--escapeChar :: Char -> String-escapeChar c = fromMaybe [c] (Map.lookup c msEscapes)---- | Escape | character, used to mark inline math, inside math.-escapeBar :: String -> String-escapeBar = concatMap go- where go '|' = "\\[u007C]"- go c = [c]---- | Escape special characters for Ms.-escapeString :: String -> String-escapeString = concatMap escapeChar+escapeStr :: WriterOptions -> String -> String+escapeStr opts =+ escapeString (if writerPreferAscii opts then AsciiOnly else AllowUTF8) escapeUri :: String -> String escapeUri = escapeURIString (\c -> c /= '@' && isAllowedInURI c) -toSmallCaps :: String -> String-toSmallCaps [] = []-toSmallCaps (c:cs)+toSmallCaps :: WriterOptions -> String -> String+toSmallCaps _ [] = []+toSmallCaps opts (c:cs) | isLower c = let (lowers,rest) = span isLower (c:cs)- in "\\s-2" ++ escapeString (map toUpper lowers) ++- "\\s0" ++ toSmallCaps rest+ in "\\s-2" ++ escapeStr opts (map toUpper lowers) +++ "\\s0" ++ toSmallCaps opts rest | isUpper c = let (uppers,rest) = span isUpper (c:cs)- in escapeString uppers ++ toSmallCaps rest- | otherwise = escapeChar c ++ toSmallCaps cs---- | Escape a literal (code) section for Ms.-escapeCode :: String -> String-escapeCode = intercalate "\n" . map escapeLine . lines- where escapeCodeChar ' ' = "\\ "- escapeCodeChar '\t' = "\\\t"- escapeCodeChar c = escapeChar c- escapeLine codeline =- case concatMap escapeCodeChar codeline of- a@('.':_) -> "\\&" ++ a- b -> b+ in escapeStr opts uppers ++ toSmallCaps opts rest+ | otherwise = escapeStr opts [c] ++ toSmallCaps opts cs -- We split inline lists into sentences, and print one sentence per--- line. groff/troff treats the line-ending period differently.+-- line. roff treats the line-ending period differently. -- See http://code.google.com/p/pandoc/issues/detail?id=148. --- | 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- (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---- | Split a list of inlines into sentences.-splitSentences :: [Inline] -> [[Inline]]-splitSentences xs =- let (sent, rest) = breakSentence xs- in if null rest then [sent] else sent : splitSentences rest- blockToMs :: PandocMonad m => WriterOptions -- ^ Options -> Block -- ^ Block element@@ -245,7 +157,7 @@ _ -> empty capt <- inlineListToMs' opts alt return $ nowrap (text ".PSPIC -C " <>- doubleQuotes (text (escapeString src)) <>+ doubleQuotes (text (escapeStr opts src)) <> sizeAttrs) $$ text ".ce 1000" $$ capt $$@@ -283,7 +195,7 @@ (if null secnum then "" else " ") ++- escapeString (stringify inlines))+ escapeStr opts (stringify inlines)) let backlink = nowrap (text ".pdfhref L -D " <> doubleQuotes (text (toAscii ident)) <> space <> text "\\") <> cr <> text " -- "@@ -460,7 +372,7 @@ inlineToMs opts (Strikeout lst) = do contents <- inlineListToMs opts lst -- we use grey color instead of strikeout, which seems quite- -- hard to do in groff for arbitrary bits of text+ -- hard to do in roff for arbitrary bits of text return $ text "\\m[strikecolor]" <> contents <> text "\\m[]" inlineToMs opts (Superscript lst) = do contents <- inlineListToMs opts lst@@ -485,20 +397,20 @@ inlineToMs opts (Code attr str) = do hlCode <- highlightCode opts attr str withFontFeature 'C' (return hlCode)-inlineToMs _ (Str str) = do+inlineToMs opts (Str str) = do let shim = case str of '.':_ -> afterBreak "\\&" _ -> empty smallcaps <- gets stSmallCaps if smallcaps- then return $ shim <> text (toSmallCaps str)- else return $ shim <> text (escapeString str)+ then return $ shim <> text (toSmallCaps opts str)+ else return $ shim <> text (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 (escapeBar r) <> text "@"+ Right r -> return $ text "@" <> text r <> text "@" inlineToMs opts (Math DisplayMath str) = do res <- convertMath writeEqn InlineMath str case res of@@ -506,7 +418,7 @@ contents <- inlineToMs opts il return $ cr <> text ".RS" $$ contents $$ text ".RE" Right r -> return $- cr <> text ".EQ" $$ text (escapeBar r) $$ text ".EN"+ cr <> text ".EQ" $$ text r $$ text ".EN" inlineToMs _ il@(RawInline f str) | f == Format "ms" = return $ text str | otherwise = do@@ -534,9 +446,10 @@ doubleQuotes (text (escapeUri src)) <> text " -A " <> doubleQuotes (text "\\c") <> space <> text "\\") <> cr <> text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"-inlineToMs _ (Image _ alternate (_, _)) =+inlineToMs opts (Image _ alternate (_, _)) = return $ char '[' <> text "IMAGE: " <>- text (escapeString (stringify alternate)) <> char ']'+ text (escapeStr opts (stringify alternate))+ <> char ']' inlineToMs _ (Note contents) = do modify $ \st -> st{ stNotes = contents : stNotes st } return $ text "\\**"@@ -560,28 +473,6 @@ contents <- blockListToMs opts bs' return $ cr <> text ".FS" $$ contents $$ text ".FE" <> cr -fontChange :: PandocMonad m => MS m Doc-fontChange = do- features <- gets stFontFeatures- inHeader <- gets stInHeader- let filling = ['C' | fromMaybe False $ Map.lookup 'C' features] ++- ['B' | inHeader ||- fromMaybe False (Map.lookup 'B' features)] ++- ['I' | fromMaybe False $ Map.lookup 'I' features]- return $- if null filling- then text "\\f[R]"- else text $ "\\f[" ++ filling ++ "]"--withFontFeature :: PandocMonad m => Char -> MS m Doc -> MS m Doc-withFontFeature c action = do- modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }- begin <- fontChange- d <- action- modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }- end <- fontChange- return $ begin <> d <> end- setFirstPara :: PandocMonad m => MS m () setFirstPara = modify $ \st -> st{ stFirstPara = True } @@ -638,20 +529,20 @@ -- lnColor = lineNumberColor sty -- lnBkgColor = lineNumberBackgroundColor sty -msFormatter :: FormatOptions -> [SourceLine] -> Doc-msFormatter _fmtopts =+msFormatter :: WriterOptions -> FormatOptions -> [SourceLine] -> Doc+msFormatter opts _fmtopts = vcat . map fmtLine where fmtLine = hcat . map fmtToken fmtToken (toktype, tok) = text "\\*" <> brackets (text (show toktype) <> text " \""- <> text (escapeCode (T.unpack tok)) <> text "\"")+ <> text (escapeStr opts (T.unpack tok)) <> text "\"") highlightCode :: PandocMonad m => WriterOptions -> Attr -> String -> MS m Doc highlightCode opts attr str =- case highlight (writerSyntaxMap opts) msFormatter attr str of+ case highlight (writerSyntaxMap opts) (msFormatter opts) attr str of Left msg -> do unless (null msg) $ report $ CouldNotHighlight msg- return $ text (escapeCode str)+ return $ text (escapeStr opts str) Right h -> do modify (\st -> st{ stHighlighting = True }) return h
@@ -46,10 +46,11 @@ import Prelude import Control.Monad.Reader import Control.Monad.State.Strict-import Data.Char (isSpace, isAlphaNum, isDigit, isAsciiUpper, isAsciiLower)+import Data.Char (isAlphaNum, isAsciiLower, isAsciiUpper, isDigit, isSpace) import Data.Default+import Data.List (intersperse, isInfixOf, transpose)+import qualified Data.Set as Set import Data.Text (Text)-import Data.List (intersperse, transpose, isInfixOf) import System.FilePath (takeExtension) import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition@@ -60,28 +61,27 @@ import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared-import qualified Data.Set as Set type Notes = [[Block]] type Muse m = ReaderT WriterEnv (StateT WriterState m) data WriterEnv =- WriterEnv { envOptions :: WriterOptions- , envTopLevel :: Bool- , envInsideBlock :: Bool- , envInlineStart :: Bool -- ^ True if there is only whitespace since last newline+ WriterEnv { envOptions :: WriterOptions+ , envTopLevel :: Bool+ , envInsideBlock :: Bool+ , envInlineStart :: Bool -- ^ True if there is only whitespace since last newline , envInsideLinkDescription :: Bool -- ^ Escape ] if True- , envAfterSpace :: Bool -- ^ There is whitespace (not just newline) before- , envOneLine :: Bool -- ^ True if newlines are not allowed- , envInsideAsterisks :: Bool -- ^ True if outer element is emphasis with asterisks- , envNearAsterisks :: Bool -- ^ Rendering inline near asterisks+ , envAfterSpace :: Bool -- ^ There is whitespace (not just newline) before+ , envOneLine :: Bool -- ^ True if newlines are not allowed+ , envInsideAsterisks :: Bool -- ^ True if outer element is emphasis with asterisks+ , envNearAsterisks :: Bool -- ^ Rendering inline near asterisks } data WriterState =- WriterState { stNotes :: Notes- , stIds :: Set.Set String- , stUseTags :: Bool -- ^ Use tags for emphasis, for example because previous character is a letter+ WriterState { stNotes :: Notes+ , stIds :: Set.Set String+ , stUseTags :: Bool -- ^ Use tags for emphasis, for example because previous character is a letter } instance Default WriterState@@ -158,11 +158,37 @@ style1' = normalizeStyle style1 style2' = normalizeStyle style2 normalizeStyle DefaultStyle = Decimal- normalizeStyle s = s+ normalizeStyle s = s flatBlockListToMuse bs@(DefinitionList _ : DefinitionList _ : _) = catWithBlankLines bs 2 flatBlockListToMuse bs@(_ : _) = catWithBlankLines bs 0 flatBlockListToMuse [] = return mempty +simpleTable :: PandocMonad m+ => [Inline]+ -> [TableCell]+ -> [[TableCell]]+ -> Muse m Doc+simpleTable caption headers rows = do+ caption' <- inlineListToMuse caption+ headers' <- mapM blockListToMuse headers+ rows' <- mapM (mapM blockListToMuse) rows+ let noHeaders = all null headers+ let numChars = maximum . map offset+ let widthsInChars =+ map numChars $ transpose (headers' : rows')+ let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks+ where h = maximum (1 : map height blocks)+ sep' = lblock (length sep) $ vcat (replicate h (text sep))+ let makeRow sep = (" " <>) . hpipeBlocks sep . zipWith lblock widthsInChars+ let head' = makeRow " || " headers'+ let rowSeparator = if noHeaders then " | " else " | "+ rows'' <- mapM (\row -> makeRow rowSeparator <$> mapM blockListToMuse row) rows+ let body = vcat rows''+ return $ (if noHeaders then empty else head')+ $$ body+ $$ (if null caption then empty else " |+ " <> caption' <> " +|")+ $$ blankline+ -- | Convert list of Pandoc block elements to Muse. blockListToMuse :: PandocMonad m => [Block] -- ^ List of block elements@@ -201,40 +227,38 @@ contents <- zipWithM orderedListItemToMuse markers items -- ensure that sublists have preceding blank line topLevel <- asks envTopLevel- return $ cr $$ (if topLevel then nest 1 else id) (vcat contents) $$ blankline+ return $ (if topLevel then nest 1 else id) (vcat contents) $$ blankline where orderedListItemToMuse :: PandocMonad m => String -- ^ marker for list item -> [Block] -- ^ list item (list of blocks) -> Muse m Doc- orderedListItemToMuse marker item = do- contents <- blockListToMuse item- return $ hang (length marker + 1) (text marker <> space) contents+ orderedListItemToMuse marker item = hang (length marker + 1) (text marker <> space)+ <$> blockListToMuse item blockToMuse (BulletList items) = do contents <- mapM bulletListItemToMuse items -- ensure that sublists have preceding blank line topLevel <- asks envTopLevel- return $ cr $$ (if topLevel then nest 1 else id) (vcat contents) $$ blankline+ return $ (if topLevel then nest 1 else id) (vcat contents) $$ blankline where bulletListItemToMuse :: PandocMonad m => [Block] -> Muse m Doc bulletListItemToMuse item = do modify $ \st -> st { stUseTags = False }- contents <- blockListToMuse item- return $ hang 2 "- " contents+ hang 2 "- " <$> blockListToMuse item blockToMuse (DefinitionList items) = do contents <- mapM definitionListItemToMuse items -- ensure that sublists have preceding blank line topLevel <- asks envTopLevel- return $ cr $$ (if topLevel then nest 1 else id) (vcat contents) $$ blankline+ return $ (if topLevel then nest 1 else id) (vcat contents) $$ blankline where definitionListItemToMuse :: PandocMonad m => ([Inline], [[Block]]) -> Muse m Doc definitionListItemToMuse (label, defs) = do modify $ \st -> st { stUseTags = False } label' <- local (\env -> env { envOneLine = True, envAfterSpace = True }) $ inlineListToMuse' label- contents <- vcat <$> mapM descriptionToMuse defs- let ind = offset label'- return $ hang ind (nowrap label') contents+ let ind = offset' label' -- using Text.Pandoc.Pretty.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)) descriptionToMuse :: PandocMonad m => [Block] -> Muse m Doc@@ -250,34 +274,19 @@ let attr' = if 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+ let header' = if topLevel then text (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-blockToMuse (Table caption _ _ headers rows) = do- caption' <- inlineListToMuse caption- headers' <- mapM blockListToMuse headers- rows' <- mapM (mapM blockListToMuse) rows- let noHeaders = all null headers-- let numChars = maximum . map offset- -- FIXME: width is not being used.- let widthsInChars =- map numChars $ transpose (headers' : rows')- -- FIXME: Muse doesn't allow blocks with height more than 1.- let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks- where h = maximum (1 : map height blocks)- sep' = lblock (length sep) $ vcat (replicate h (text sep))- let makeRow sep = (" " <>) . hpipeBlocks sep . zipWith lblock widthsInChars- let head' = makeRow " || " headers'- let rowSeparator = if noHeaders then " | " else " | "- rows'' <- mapM (\row -> do cols <- mapM blockListToMuse row- return $ makeRow rowSeparator cols) rows- let body = vcat rows''- return $ (if noHeaders then empty else head')- $$ body- $$ (if null caption then empty else " |+ " <> caption' <> " +|")- $$ blankline+blockToMuse (Table caption aligns widths headers rows) =+ if all (== 0.0) widths+ then simpleTable caption headers rows+ else do+ opts <- asks envOptions+ gridTable opts blocksToDoc True (map (const AlignDefault) aligns) widths headers rows+ where+ blocksToDoc opts blocks =+ local (\env -> env { envOptions = opts }) $ blockListToMuse blocks blockToMuse (Div _ bs) = flatBlockListToMuse bs blockToMuse Null = return empty @@ -294,10 +303,10 @@ -> Muse m Doc noteToMuse num note = hang (length marker) (text marker) <$>- (local (\env -> env { envInsideBlock = True- , envInlineStart = True- , envAfterSpace = True- }) $ blockListToMuse note)+ local (\env -> env { envInsideBlock = True+ , envInlineStart = True+ , envAfterSpace = True+ }) (blockListToMuse note) where marker = "[" ++ show num ++ "] " @@ -311,34 +320,34 @@ -- | Replace newlines with spaces replaceNewlines :: String -> String replaceNewlines ('\n':xs) = ' ':replaceNewlines xs-replaceNewlines (x:xs) = x:replaceNewlines xs-replaceNewlines [] = []+replaceNewlines (x:xs) = x:replaceNewlines xs+replaceNewlines [] = [] startsWithMarker :: (Char -> Bool) -> String -> Bool startsWithMarker f (' ':xs) = startsWithMarker f xs startsWithMarker f (x:xs) = f x && (startsWithMarker f xs || startsWithDot xs) where- startsWithDot ['.'] = True+ startsWithDot ['.'] = True startsWithDot ('.':c:_) = isSpace c- startsWithDot _ = False+ startsWithDot _ = False startsWithMarker _ [] = False -- | Escape special characters for Muse if needed. containsFootnotes :: String -> Bool containsFootnotes = p where p ('[':xs) = q xs || p xs- p (_:xs) = p xs- p "" = False+ p (_:xs) = p xs+ p "" = False q (x:xs) | x `elem` ("123456789"::String) = r xs || p xs | otherwise = p xs q [] = False r ('0':xs) = r xs || p xs- r xs = s xs || q xs || p xs+ r xs = s xs || q xs || p xs s (']':_) = True- s (_:xs) = p xs- s [] = False+ s (_:xs) = p xs+ s [] = False -- | Return True if string should be escaped with <verbatim> tags shouldEscapeString :: PandocMonad m@@ -378,14 +387,14 @@ replaceSmallCaps :: Inline -> Inline replaceSmallCaps (SmallCaps lst) = Emph lst-replaceSmallCaps x = x+replaceSmallCaps x = x removeKeyValues :: Inline -> Inline 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-removeKeyValues x = x+removeKeyValues x = x normalizeInlineList :: [Inline] -> [Inline] normalizeInlineList (Str "" : xs)@@ -415,35 +424,35 @@ normalizeInlineList [] = [] fixNotes :: [Inline] -> [Inline]-fixNotes [] = []-fixNotes (Space : n@Note{} : rest) = Str " " : n : fixNotes rest+fixNotes [] = []+fixNotes (Space : n@Note{} : rest) = Str " " : n : fixNotes rest fixNotes (SoftBreak : n@Note{} : rest) = Str " " : n : fixNotes rest-fixNotes (x:xs) = x : fixNotes xs+fixNotes (x:xs) = x : fixNotes xs startsWithSpace :: [Inline] -> Bool-startsWithSpace (Space:_) = True+startsWithSpace (Space:_) = True startsWithSpace (SoftBreak:_) = True-startsWithSpace (Str s:_) = stringStartsWithSpace s-startsWithSpace _ = False+startsWithSpace (Str s:_) = stringStartsWithSpace s+startsWithSpace _ = False endsWithSpace :: [Inline] -> Bool-endsWithSpace [Space] = True+endsWithSpace [Space] = True endsWithSpace [SoftBreak] = True-endsWithSpace [Str s] = stringStartsWithSpace $ reverse s-endsWithSpace (_:xs) = endsWithSpace xs-endsWithSpace [] = False+endsWithSpace [Str s] = stringStartsWithSpace $ reverse s+endsWithSpace (_:xs) = endsWithSpace xs+endsWithSpace [] = False urlEscapeBrackets :: String -> String urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs-urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs-urlEscapeBrackets [] = []+urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs+urlEscapeBrackets [] = [] isHorizontalRule :: String -> Bool isHorizontalRule s = length s >= 4 && all (== '-') s stringStartsWithSpace :: String -> Bool stringStartsWithSpace (x:_) = isSpace x-stringStartsWithSpace "" = False+stringStartsWithSpace "" = False fixOrEscape :: Bool -> Inline -> Bool fixOrEscape sp (Str "-") = sp@@ -518,6 +527,14 @@ , envAfterSpace = afterSpace || not topLevel }) $ inlineListToMuse lst +emphasis :: PandocMonad m => String -> String -> [Inline] -> Muse m Doc+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 /= '>'+ -- | Convert Pandoc inline element to Muse. inlineToMuse :: PandocMonad m => Inline@@ -531,53 +548,30 @@ useTags <- gets stUseTags let lst' = normalizeInlineList lst if useTags- then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = False }- return $ "<em>**" <> contents <> "**</em>"+ then emphasis "<em>**" "**</em>" lst' else if null lst' || startsWithSpace lst' || endsWithSpace lst'- then do- contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = True }- return $ "*<strong>" <> contents <> "</strong>*"- else do- contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = True }- return $ "***" <> contents <> "***"+ then emphasis "*<strong>" "</strong>*" lst'+ else emphasis "***" "***" lst' inlineToMuse (Emph lst) = do useTags <- gets stUseTags let lst' = normalizeInlineList lst if useTags || null lst' || startsWithSpace lst' || endsWithSpace lst'- then do contents <- inlineListToMuse lst'- return $ "<em>" <> contents <> "</em>"- else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = True }- return $ "*" <> contents <> "*"+ then emphasis "<em>" "</em>" lst'+ else emphasis "*" "*" lst' inlineToMuse (Strong [Emph lst]) = do useTags <- gets stUseTags let lst' = normalizeInlineList lst if useTags- then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = False }- return $ "<strong>*" <> contents <> "*</strong>"+ then emphasis "<strong>*" "*</strong>" lst' else if null lst' || startsWithSpace lst' || endsWithSpace lst'- then do- contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = True }- return $ "**<em>" <> contents <> "</em>**"- else do- contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = True }- return $ "***" <> contents <> "***"+ then emphasis "**<em>" "</em>**" lst'+ else emphasis "***" "***" lst' inlineToMuse (Strong lst) = do useTags <- gets stUseTags let lst' = normalizeInlineList lst if useTags || null lst' || startsWithSpace lst' || endsWithSpace lst'- then do contents <- inlineListToMuse lst'- modify $ \st -> st { stUseTags = False }- return $ "<strong>" <> contents <> "</strong>"- else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'- modify $ \st -> st { stUseTags = True }- return $ "**" <> contents <> "**"+ then emphasis "<strong>" "</strong>" lst'+ else emphasis "**" "**" lst' inlineToMuse (Strikeout lst) = do contents <- inlineListToMuse lst modify $ \st -> st { stUseTags = False }
@@ -36,8 +36,9 @@ import Control.Monad.State.Strict import qualified Data.ByteString.Lazy as B import Data.Generics (everywhere', mkT)-import Data.List (isPrefixOf)+import Data.List (isPrefixOf, intercalate) import Data.Maybe (fromMaybe)+import qualified Data.Map as Map import qualified Data.Text.Lazy as TL import System.FilePath (takeDirectory, takeExtension, (<.>)) import Text.Pandoc.BCP47 (Lang (..), getLang, renderLang)@@ -49,7 +50,8 @@ import Text.Pandoc.MIME (extensionFromMimeType, getMimeType) import Text.Pandoc.Options (WrapOption (..), WriterOptions (..)) import Text.Pandoc.Pretty-import Text.Pandoc.Shared (stringify)+import Text.Pandoc.Shared (stringify, normalizeDate)+import Text.Pandoc.Writers.Shared (lookupMetaString) import Text.Pandoc.UTF8 (fromStringLazy, fromTextLazy, toStringLazy) import Text.Pandoc.Walk import Text.Pandoc.Writers.OpenDocument (writeOpenDocument)@@ -81,6 +83,7 @@ -> O m B.ByteString pandocToODT opts doc@(Pandoc meta _) = do let title = docTitle meta+ let authors = docAuthors meta lang <- toLang (getLang opts meta) refArchive <- case writerReferenceDoc opts of@@ -123,6 +126,15 @@ ) ) let archive' = addEntryToArchive manifestEntry archive+ let userDefinedMetaFields = [k | k <- Map.keys (unMeta meta)+ , k `notElem` ["title", "lang", "author", "date"]]+ let escapedText = text . escapeStringForXML+ let userDefinedMeta =+ map (\k -> inTags False "meta:user-defined"+ [ ("meta_name", escapeStringForXML k)+ ,("meta-value-type", "string")+ ] (escapedText $ lookupMetaString k meta)) userDefinedMetaFields+ let metaTag metafield = inTagsSimple metafield . escapedText let metaEntry = toEntry "meta.xml" epochtime $ fromStringLazy $ render Nothing $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"@@ -134,14 +146,21 @@ ,("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0") ,("xmlns:ooo","http://openoffice.org/2004/office") ,("xmlns:grddl","http://www.w3.org/2003/g/data-view#")- ,("office:version","1.2")] ( inTagsSimple "office:meta" $- ( inTagsSimple "dc:title"- (text $ escapeStringForXML (stringify title))+ ,("office:version","1.2")] ( inTags True "office:meta" [] $+ ( metaTag "dc:title" (stringify title) $$ case lang of- Just l -> inTagsSimple "dc:language"- (text (escapeStringForXML (renderLang l)))+ Just l -> metaTag "dc:language" (renderLang l) Nothing -> empty+ $$+ metaTag "dc:creator"+ (intercalate "; " (map stringify authors))+ $$+ maybe mempty+ (metaTag "dc:date")+ (normalizeDate (lookupMetaString "date" meta))+ $$+ vcat userDefinedMeta ) ) )
@@ -62,7 +62,8 @@ meta' main <- (render colwidth . vcat) <$> mapM (elementToOPML opts) elements let context = defField "body" main metadata- case writerTemplate opts of+ (if writerPreferAscii opts then toEntities else id) <$>+ case writerTemplate opts of Nothing -> return main Just tpl -> renderTemplate' tpl context
@@ -39,17 +39,20 @@ import Data.Char (chr) import Data.List (sortBy) 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 Text.Pandoc.BCP47 (Lang (..), parseBCP47)-import Text.Pandoc.Class (PandocMonad, report)+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 qualified Text.Pandoc.Translations as Term (Term(Figure, Table)) import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared import Text.Pandoc.XML@@ -67,32 +70,36 @@ 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)- , stTextStyleAttr :: Set.Set TextStyle- , stIndentPara :: Int- , stInDefinition :: Bool- , stTight :: Bool- , stFirstPara :: Bool- , stImageId :: Int+ WriterState { stNotes :: [Doc]+ , stTableStyles :: [Doc]+ , stParaStyles :: [Doc]+ , stListStyles :: [(Int, [Doc])]+ , stTextStyles :: Map.Map (Set.Set TextStyle) (String, Doc)+ , stTextStyleAttr :: Set.Set TextStyle+ , stIndentPara :: Int+ , stInDefinition :: Bool+ , stTight :: Bool+ , stFirstPara :: Bool+ , stImageId :: Int+ , stTableCaptionId :: Int+ , stImageCaptionId :: Int } defaultWriterState :: WriterState defaultWriterState =- WriterState { stNotes = []- , stTableStyles = []- , stParaStyles = []- , stListStyles = []- , stTextStyles = Map.empty- , stTextStyleAttr = Set.empty- , stIndentPara = 0- , stInDefinition = False- , stTight = False- , stFirstPara = False- , stImageId = 1+ WriterState { stNotes = []+ , stTableStyles = []+ , stParaStyles = []+ , stListStyles = []+ , stTextStyles = Map.empty+ , stTextStyleAttr = Set.empty+ , stIndentPara = 0+ , stInDefinition = False+ , stTight = False+ , stFirstPara = False+ , stImageId = 1+ , stTableCaptionId = 1+ , stImageCaptionId = 1 } when :: Bool -> Doc -> Doc@@ -223,6 +230,11 @@ -- | Convert Pandoc document to string in OpenDocument format. writeOpenDocument :: PandocMonad m => WriterOptions -> Pandoc -> m Text writeOpenDocument opts (Pandoc meta blocks) = do+ let defLang = Lang "en" "US" "" []+ lang <- case lookupMetaString "lang" meta of+ "" -> pure defLang+ s -> fromMaybe defLang <$> toLang (Just s)+ setTranslations lang let colwidth = if writerWrapText opts == WrapAuto then Just $ writerColumns opts else Nothing@@ -400,7 +412,7 @@ mapM_ addParaStyle . newPara $ paraHStyles ++ paraStyles captionDoc <- if null c then return empty- else withParagraphStyle o "Table" [Para c]+ else inlinesToOpenDocument o c >>= numberedTableCaption th <- if all null h then return empty else colHeadsToOpenDocument o (map fst paraHStyles) h@@ -412,9 +424,35 @@ withParagraphStyle o "Figure" [Para [Image attr caption (source,title)]] | otherwise = do imageDoc <- withParagraphStyle o "FigureWithCaption" [Para [Image attr caption (source,title)]]- captionDoc <- withParagraphStyle o "FigureCaption" [Para caption]+ captionDoc <- inlinesToOpenDocument o caption >>= numberedFigureCaption return $ imageDoc $$ captionDoc ++numberedTableCaption :: PandocMonad m => Doc -> OD m Doc+numberedTableCaption caption = do+ id' <- gets stTableCaptionId+ modify (\st -> st{ stTableCaptionId = id' + 1 })+ capterm <- translateTerm Term.Table+ return $ numberedCaption "Table" capterm "Table" id' caption++numberedFigureCaption :: PandocMonad m => Doc -> OD m Doc+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 style term name num caption =+ let t = text term+ r = num - 1+ s = inTags False "text:sequence" [ ("text:ref-name", "ref" ++ name ++ show r),+ ("text:name", name),+ ("text:formula", "ooow:" ++ name ++ "+1"),+ ("style:num-format", "1") ] $ text $ show num+ c = text ": "+ in inParagraphTagsWithStyle style $ hcat [ t, text " ", s, c, caption ]+ colHeadsToOpenDocument :: PandocMonad m => WriterOptions -> [String] -> [[Block]] -> OD m Doc@@ -563,10 +601,18 @@ listLevelStyle :: Int -> Doc listLevelStyle i =- let indent = show (0.4 * fromIntegral (i - 1) :: Double) in- selfClosingTag "style:list-level-properties"- [ ("text:space-before" , indent ++ "in")- , ("text:min-label-width", "0.4in")]+ let indent = show (0.5 * fromIntegral i :: Double) in+ inTags True "style:list-level-properties"+ [ ("text:list-level-position-and-space-mode",+ "label-alignment")+ , ("fo:text-align", "right")+ ] $+ selfClosingTag "style:list-level-label-alignment"+ [ ("text:label-followed-by", "listtab")+ , ("text:list-tab-stop-position", indent ++ "in")+ , ("fo:text-indent", "-0.1in")+ , ("fo:margin-left", indent ++ "in")+ ] tableStyle :: Int -> [(Char,Double)] -> Doc tableStyle num wcs =
@@ -728,9 +728,9 @@ else return [picShape] -paraElemToElement :: PandocMonad m => ParaElem -> P m Element-paraElemToElement Break = return $ mknode "a:br" [] ()-paraElemToElement (Run rpr s) = do+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@@ -787,16 +787,18 @@ then [mknode "a:latin" [("typeface", "Courier")] ()] else [] let propContents = linkProps ++ colorContents ++ codeContents- return $ mknode "a:r" [] [ mknode "a:rPr" attrs $ propContents- , mknode "a:t" [] s- ]-paraElemToElement (MathElem mathType texStr) = do+ return [mknode "a:r" [] [ mknode "a:rPr" attrs $ propContents+ , mknode "a:t" [] s+ ]]+paraElemToElements (MathElem mathType texStr) = do res <- convertMath writeOMML mathType (unTeXString texStr) case res of- Right r -> return $ mknode "a14:m" [] $ addMathInfo r- Left (Str s) -> paraElemToElement (Run def s)+ Right r -> return [mknode "a14:m" [] $ addMathInfo r]+ Left (Str s) -> paraElemToElements (Run def s) Left _ -> throwError $ PandocShouldNeverHappenError "non-string math fallback"+paraElemToElements (RawOOXMLParaElem str) = return [ x | Elem x <- parseXML str ] + -- This is a bit of a kludge -- really requires adding an option to -- TeXMath, but since that's a different package, we'll do this one -- step at a time.@@ -852,7 +854,7 @@ [mknode "a:buAutoNum" [("type", autoNumberingToType attrs')] ()] Nothing -> [mknode "a:buNone" [] ()] )- paras <- mapM paraElemToElement (paraElems par)+ paras <- concat <$> mapM paraElemToElements (paraElems par) return $ mknode "a:p" [] $ [mknode "a:pPr" attrs props] ++ paras shapeToElement :: PandocMonad m => Element -> Shape -> P m Element@@ -882,6 +884,7 @@ Nothing -> shapeToElements layout $ TextBox [Paragraph def alt] shapeToElements layout (GraphicFrame tbls cptn) = graphicFrameToElements layout tbls cptn+shapeToElements _ (RawOOXMLShape str) = return [ x | Elem x <- parseXML str ] shapeToElements layout shp = do element <- shapeToElement layout shp return [element]
@@ -72,7 +72,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.Writers.Shared (metaValueToInlines)+import Text.Pandoc.Writers.Shared (lookupMetaInlines) import qualified Data.Map as M import qualified Data.Set as S import Data.Maybe (maybeToList, fromMaybe)@@ -216,6 +216,7 @@ data Shape = Pic PicProps FilePath [ParaElem] | GraphicFrame [Graphic] [ParaElem] | TextBox [Paragraph]+ | RawOOXMLShape String deriving (Show, Eq) type Cell = [Paragraph]@@ -266,6 +267,7 @@ -- `convertmath` from T.P.Writers.Math. Will perhaps -- revisit in the future. | MathElem MathType TeXString+ | RawOOXMLParaElem String deriving (Show, Eq) data Strikethrough = NoStrike | SingleStrike | DoubleStrike@@ -382,7 +384,11 @@ where (open, close) = case quoteType of SingleQuote -> ("\x2018", "\x2019") DoubleQuote -> ("\x201C", "\x201D")-inlineToParElems (RawInline _ _) = return []+inlineToParElems il@(RawInline fmt s) =+ case fmt of+ Format "openxml" -> return [RawOOXMLParaElem s]+ _ -> do addLogMessage $ InlineNotRendered il+ return [] inlineToParElems (Cite _ ils) = inlinesToParElems ils -- Note: we shouldn't reach this, because images should be handled at -- the shape level, but should that change in the future, we render@@ -446,7 +452,8 @@ , envRunProps = (envRunProps r){rPropForceSize = Just blockQuoteSize}})$ concatMapM blockToParagraphs blks -- TODO: work out the format-blockToParagraphs (RawBlock _ _) = return []+blockToParagraphs blk@(RawBlock _ _) = do addLogMessage $ BlockNotRendered blk+ return [] blockToParagraphs (Header _ (ident, _, _) ils) = do -- Note that this function only deals with content blocks, so it -- will only touch headers that are above the current slide level --@@ -547,6 +554,8 @@ } return $ GraphicFrame [Tbl tblPr hdrCells' rows'] caption'+-- If the format isn't openxml, we fall through to blockToPargraphs+blockToShape (RawBlock (Format "openxml") str) = return $ RawOOXMLShape str blockToShape blk = do paras <- blockToParagraphs blk let paras' = map (\par -> par{paraElems = combineParaElems $ paraElems par}) paras return $ TextBox paras'@@ -731,9 +740,9 @@ anchorSet <- M.keysSet <$> gets stAnchorMap if M.null noteIds then return []- else let title = case lookupMeta "notes-title" meta of- Just val -> metaValueToInlines val- Nothing -> [Str "Notes"]+ else let title = case lookupMetaInlines "notes-title" meta of+ [] -> [Str "Notes"]+ ls -> ls ident = Shared.uniqueIdent title anchorSet hdr = Header slideLevel (ident, [], []) title blks = concatMap (\(n, bs) -> makeNoteEntry n bs) $@@ -744,13 +753,7 @@ getMetaSlide = do meta <- asks envMetadata title <- inlinesToParElems $ docTitle meta- subtitle <- inlinesToParElems $- case lookupMeta "subtitle" meta of- Just (MetaString s) -> [Str s]- Just (MetaInlines ils) -> ils- Just (MetaBlocks [Plain ils]) -> ils- Just (MetaBlocks [Para ils]) -> ils- _ -> []+ subtitle <- inlinesToParElems $ lookupMetaInlines "subtitle" meta authors <- mapM inlinesToParElems $ docAuthors meta date <- inlinesToParElems $ docDate meta if null title && null subtitle && null authors && null date@@ -785,9 +788,9 @@ contents <- BulletList <$> mapM elementToListItem (Shared.hierarchicalize blks) meta <- asks envMetadata slideLevel <- asks envSlideLevel- let tocTitle = case lookupMeta "toc-title" meta of- Just val -> metaValueToInlines val- Nothing -> [Str "Table of Contents"]+ let tocTitle = case lookupMetaInlines "toc-title" meta of+ [] -> [Str "Table of Contents"]+ ls -> ls hdr = Header slideLevel nullAttr tocTitle blocksToSlide [hdr, contents] @@ -815,6 +818,7 @@ applyToShape f (Pic pPr fp pes) = Pic pPr fp <$> mapM f pes applyToShape f (GraphicFrame gfx pes) = GraphicFrame gfx <$> mapM f pes applyToShape f (TextBox paras) = TextBox <$> mapM (applyToParagraph f) paras+applyToShape _ (RawOOXMLShape str) = return $ RawOOXMLShape str applyToLayout :: Monad m => (ParaElem -> m ParaElem) -> Layout -> m Layout applyToLayout f (MetadataSlide title subtitle authors date) = do
@@ -35,7 +35,7 @@ import Prelude import Control.Monad.State.Strict import Data.Char (isSpace, toLower)-import Data.List (isPrefixOf, stripPrefix)+import Data.List (isPrefixOf, stripPrefix, transpose) import Data.Maybe (fromMaybe) import Data.Text (Text, stripEnd) import qualified Text.Pandoc.Builder as B@@ -82,10 +82,7 @@ else Nothing let render' :: Doc -> Text render' = render colwidth- let subtit = case lookupMeta "subtitle" meta of- Just (MetaBlocks [Plain xs]) -> xs- Just (MetaInlines xs) -> xs- _ -> []+ let subtit = lookupMetaInlines "subtitle" meta title <- titleToRST (docTitle meta) subtit metadata <- metaToJSON opts (fmap render' . blockListToRST)@@ -307,9 +304,12 @@ modify $ \st -> st{ stOptions = oldOpts } return result opts <- gets stOptions- tbl <- gridTable opts blocksToDoc (all null headers)- (map (const AlignDefault) aligns) widths- headers rows+ let isSimple = all (== 0) widths+ tbl <- if isSimple+ then simpleTable opts blocksToDoc headers rows+ 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 $$@@ -696,3 +696,30 @@ Just dim -> cols dim Nothing -> empty return $ cr <> name $$ showDim Width $$ showDim Height++simpleTable :: PandocMonad m+ => WriterOptions+ -> (WriterOptions -> [Block] -> m Doc)+ -> [[Block]]+ -> [[[Block]]]+ -> m Doc+simpleTable opts blocksToDoc headers rows = do+ -- can't have empty cells in first column:+ let fixEmpties (d:ds) = if isEmpty d+ then text "\\ " : ds+ else d : ds+ fixEmpties [] = []+ headerDocs <- if all null headers+ then return []+ else fixEmpties <$> mapM (blocksToDoc opts) headers+ rowDocs <- mapM (fmap fixEmpties . mapM (blocksToDoc opts)) rows+ let numChars [] = 0+ numChars xs = maximum . map offset $ xs+ let colWidths = map numChars $ transpose (headerDocs : rowDocs)+ let toRow = hsep . zipWith lblock colWidths+ let hline = hsep (map (\n -> text (replicate n '=')) colWidths)+ let hdr = if all null headers+ then mempty+ else hline $$ toRow headerDocs+ let bdy = vcat $ map toRow rowDocs+ return $ hdr $$ hline $$ bdy $$ hline
@@ -0,0 +1,138 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-+Copyright (C) 2007-2018 John MacFarlane <jgm@berkeley.edu>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.Writers.Roff+ Copyright : Copyright (C) 2007-2018 John MacFarlane+ License : GNU GPL, version 2 or above++ Maintainer : John MacFarlane <jgm@berkeley.edu>+ Stability : alpha+ Portability : portable++Common functions for roff writers (man, ms).+-}++module Text.Pandoc.Writers.Roff (+ WriterState(..)+ , defaultWriterState+ , MS+ , Note+ , EscapeMode(..)+ , escapeString+ , withFontFeature+ ) where+import Prelude+import Data.Char (ord, isAscii)+import Control.Monad.State.Strict+import qualified Data.Map as Map+import Data.Maybe (fromMaybe, isJust, catMaybes)+import Text.Pandoc.Class (PandocMonad)+import Text.Pandoc.Definition+import Text.Pandoc.Pretty+import Text.Printf (printf)+import Text.Pandoc.RoffChar (standardEscapes,+ characterCodes, combiningAccents)++data WriterState = WriterState { stHasInlineMath :: Bool+ , stFirstPara :: Bool+ , stNotes :: [Note]+ , stSmallCaps :: Bool+ , stHighlighting :: Bool+ , stInHeader :: Bool+ , stFontFeatures :: Map.Map Char Bool+ , stHasTables :: Bool+ }++defaultWriterState :: WriterState+defaultWriterState = WriterState{ stHasInlineMath = False+ , stFirstPara = True+ , stNotes = []+ , stSmallCaps = False+ , stHighlighting = False+ , stInHeader = False+ , stFontFeatures = Map.fromList [+ ('I',False)+ , ('B',False)+ , ('C',False)+ ]+ , stHasTables = False+ }++type Note = [Block]++type MS = StateT WriterState++data EscapeMode = AllowUTF8 -- ^ use preferred man escapes+ | AsciiOnly -- ^ escape everything+ deriving Show++combiningAccentsMap :: Map.Map Char String+combiningAccentsMap = Map.fromList combiningAccents++essentialEscapes :: Map.Map Char String+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++characterCodeMap :: Map.Map Char String+characterCodeMap = Map.fromList characterCodes++fontChange :: PandocMonad m => MS m Doc+fontChange = do+ features <- gets stFontFeatures+ inHeader <- gets stInHeader+ let filling = ['C' | fromMaybe False $ Map.lookup 'C' features] +++ ['B' | inHeader ||+ fromMaybe False (Map.lookup 'B' features)] +++ ['I' | fromMaybe False $ Map.lookup 'I' features]+ return $+ if null filling+ then text "\\f[R]"+ else text $ "\\f[" ++ filling ++ "]"++withFontFeature :: PandocMonad m => Char -> MS m Doc -> MS m Doc+withFontFeature c action = do+ modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }+ begin <- fontChange+ d <- action+ modify $ \st -> st{ stFontFeatures = Map.adjust not c $ stFontFeatures st }+ end <- fontChange+ return $ begin <> d <> end
@@ -42,14 +42,20 @@ , fixDisplayMath , unsmartify , gridTable- , metaValueToInlines+ , lookupMetaBool+ , lookupMetaBlocks+ , lookupMetaInlines+ , lookupMetaString , stripLeadingTrailingSpace+ , toSubscript+ , toSuperscript ) where import Prelude import Control.Monad (zipWithM) import Data.Aeson (FromJSON (..), Result (..), ToJSON (..), Value (Object), encode, fromJSON)+import Data.Char (chr, ord, isSpace) import qualified Data.HashMap.Strict as H import Data.List (groupBy, intersperse, transpose) import qualified Data.Map as M@@ -60,7 +66,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Pretty-import Text.Pandoc.Walk (query)+import Text.Pandoc.Shared (stringify) import Text.Pandoc.UTF8 (toStringLazy) import Text.Pandoc.XML (escapeStringForXML) @@ -334,9 +340,75 @@ body $$ border '-' (repeat AlignDefault) widthsInChars -metaValueToInlines :: MetaValue -> [Inline]-metaValueToInlines (MetaString s) = [Str s]-metaValueToInlines (MetaInlines ils) = ils-metaValueToInlines (MetaBlocks bs) = query return bs-metaValueToInlines (MetaBool b) = [Str $ show b]-metaValueToInlines _ = []+++-- | Retrieve the metadata value for a given @key@+-- and convert to Bool.+lookupMetaBool :: String -> Meta -> Bool+lookupMetaBool key meta =+ case lookupMeta key meta of+ Just (MetaBlocks _) -> True+ Just (MetaInlines _) -> True+ Just (MetaString (_:_)) -> True+ Just (MetaBool True) -> True+ _ -> False++-- | Retrieve the metadata value for a given @key@+-- and extract blocks.+lookupMetaBlocks :: String -> Meta -> [Block]+lookupMetaBlocks key meta =+ case lookupMeta key meta of+ Just (MetaBlocks bs) -> bs+ Just (MetaInlines ils) -> [Plain ils]+ Just (MetaString s) -> [Plain [Str s]]+ _ -> []++-- | Retrieve the metadata value for a given @key@+-- and extract inlines.+lookupMetaInlines :: String -> Meta -> [Inline]+lookupMetaInlines key meta =+ case lookupMeta key meta of+ Just (MetaString s) -> [Str s]+ Just (MetaInlines ils) -> ils+ Just (MetaBlocks [Plain ils]) -> ils+ Just (MetaBlocks [Para ils]) -> ils+ _ -> []++-- | Retrieve the metadata value for a given @key@+-- and convert to String.+lookupMetaString :: String -> Meta -> String+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+ _ -> ""+++toSuperscript :: Char -> Maybe Char+toSuperscript '1' = Just '\x00B9'+toSuperscript '2' = Just '\x00B2'+toSuperscript '3' = Just '\x00B3'+toSuperscript '+' = Just '\x207A'+toSuperscript '-' = Just '\x207B'+toSuperscript '=' = Just '\x207C'+toSuperscript '(' = Just '\x207D'+toSuperscript ')' = Just '\x207E'+toSuperscript c+ | c >= '0' && c <= '9' =+ Just $ chr (0x2070 + (ord c - 48))+ | isSpace c = Just c+ | otherwise = Nothing++toSubscript :: Char -> Maybe Char+toSubscript '+' = Just '\x208A'+toSubscript '-' = Just '\x208B'+toSubscript '=' = Just '\x208C'+toSubscript '(' = Just '\x208D'+toSubscript ')' = Just '\x208E'+toSubscript c+ | c >= '0' && c <= '9' =+ Just $ chr (0x2080 + (ord c - 48))+ | isSpace c = Just c+ | otherwise = Nothing
@@ -52,14 +52,13 @@ import Text.Pandoc.Writers.Shared (defField, metaToJSON) data WriterState = WriterState {- stItemNum :: Int, stIndent :: String, -- Indent after the marker at the beginning of list items stInTable :: Bool, -- Inside a table stInLink :: Bool -- Inside a link description } instance Default WriterState where- def = WriterState { stItemNum = 1, stIndent = "", stInTable = False, stInLink = False }+ def = WriterState { stIndent = "", stInTable = False, stInLink = False } type ZW = StateT WriterState @@ -183,17 +182,13 @@ unlines (map renderRow rows') blockToZimWiki opts (BulletList items) = do- indent <- gets stIndent- modify $ \s -> s { stIndent = stIndent s ++ "\t" } contents <- mapM (listItemToZimWiki opts) items- modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) }+ indent <- gets stIndent return $ vcat contents ++ if null indent then "\n" else "" blockToZimWiki opts (OrderedList _ items) = do+ contents <- zipWithM (orderedListItemToZimWiki opts) [1..] items indent <- gets stIndent- modify $ \s -> s { stIndent = stIndent s ++ "\t", stItemNum = 1 }- contents <- mapM (orderedListItemToZimWiki opts) items- modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) } return $ vcat contents ++ if null indent then "\n" else "" blockToZimWiki opts (DefinitionList items) = do@@ -214,25 +209,24 @@ indentFromHTML :: PandocMonad m => WriterOptions -> String -> ZW m String indentFromHTML _ str = do indent <- gets stIndent- itemnum <- gets stItemNum- if "<li>" `isInfixOf` str then return $ indent ++ show itemnum ++ "."- else if "</li>" `isInfixOf` str then return "\n"- else if "<li value=" `isInfixOf` str then do- -- poor man's cut- let val = drop 10 $ reverse $ drop 1 $ reverse str- --let val = take ((length valls) - 2) valls- modify $ \s -> s { stItemNum = read val }- return ""- else if "<ol>" `isInfixOf` str then do- let olcount=countSubStrs "<ol>" str- modify $ \s -> s { stIndent = stIndent s ++ replicate olcount '\t', stItemNum = 1 }- return ""- else if "</ol>" `isInfixOf` str then do- let olcount=countSubStrs "/<ol>" str- modify $ \s -> s{ stIndent = drop olcount (stIndent s) }- return ""- else- return ""+ if "<li>" `isInfixOf` str+ then return indent+ else if "</li>" `isInfixOf` str+ then return "\n"+ else if "<li value=" `isInfixOf` str+ then return ""+ else if "<ol>" `isInfixOf` str+ then do+ let olcount=countSubStrs "<ol>" str+ modify $ \s -> s { stIndent = stIndent s +++ replicate olcount '\t' }+ return ""+ else if "</ol>" `isInfixOf` str+ then do+ let olcount=countSubStrs "/<ol>" str+ modify $ \s -> s{ stIndent = drop olcount (stIndent s) }+ return ""+ else return "" countSubStrs :: String -> String -> Int countSubStrs sub str = length $ breakOnAll (pack sub) (pack str)@@ -246,18 +240,20 @@ -- | Convert bullet list item (list of blocks) to ZimWiki. listItemToZimWiki :: PandocMonad m => WriterOptions -> [Block] -> ZW m String listItemToZimWiki opts items = do- contents <- blockListToZimWiki opts items indent <- gets stIndent+ modify $ \s -> s { stIndent = indent ++ "\t" }+ contents <- blockListToZimWiki opts items+ modify $ \s -> s{ stIndent = indent } return $ indent ++ "* " ++ contents -- | Convert ordered list item (list of blocks) to ZimWiki. orderedListItemToZimWiki :: PandocMonad m- => WriterOptions -> [Block] -> ZW m String-orderedListItemToZimWiki opts items = do- contents <- blockListToZimWiki opts items+ => WriterOptions -> Int -> [Block] -> ZW m String+orderedListItemToZimWiki opts itemnum items = do indent <- gets stIndent- itemnum <- gets stItemNum- --modify $ \s -> s { stItemNum = itemnum + 1 } -- this is not strictly necessary for zim as zim does its own renumbering+ modify $ \s -> s { stIndent = indent ++ "\t" }+ contents <- blockListToZimWiki opts items+ modify $ \s -> s{ stIndent = indent } return $ indent ++ show itemnum ++ ". " ++ contents -- Auxiliary functions for tables:@@ -343,8 +339,8 @@ -- | f == Format "html" = return $ "<html>" ++ str ++ "</html>" inlineToZimWiki opts il@(RawInline f str) | f == Format "zimwiki" = return str- | f == Format "html" = indentFromHTML opts str- | otherwise = do+ | f == Format "html" = indentFromHTML opts str+ | otherwise = do report $ InlineNotRendered il return ""
@@ -35,6 +35,7 @@ inTagsSimple, inTagsIndented, toEntities,+ toHtml5Entities, fromEntities ) where import Prelude@@ -43,6 +44,8 @@ import qualified Data.Text as T import Text.HTML.TagSoup.Entity (lookupEntity) import Text.Pandoc.Pretty+import qualified Data.Map as M+import Text.HTML.TagSoup.Entity (htmlEntities) -- | Escape one character as needed for XML. escapeCharForXML :: Char -> String@@ -99,6 +102,21 @@ toEntities = T.concatMap go where go c | isAscii c = T.singleton c | otherwise = T.pack ("&#" ++ show (ord c) ++ ";")++-- | Escape all non-ascii characters using HTML5 entities, falling+-- back to numerical entities.+toHtml5Entities :: Text -> Text+toHtml5Entities = T.concatMap go+ where go c | isAscii c = T.singleton c+ | otherwise =+ case M.lookup c html5EntityMap of+ Just t -> T.singleton '&' <> t <> T.singleton ';'+ Nothing -> T.pack ("&#" ++ show (ord c) ++ ";")++html5EntityMap :: M.Map Char Text+html5EntityMap = M.fromList [(c, T.takeWhile (/=';') (T.pack ent))+ | (ent@(_:_), [c]) <- htmlEntities+ , last ent == ';'] -- Unescapes XML entities fromEntities :: String -> String
@@ -19,13 +19,16 @@ - foundation extra-dep: true extra-deps:-- pandoc-citeproc-0.14.4-- haddock-library-1.6.0+- pandoc-citeproc-0.14.8+- haddock-library-1.7.0 - HsYAML-0.1.1.1-- texmath-0.11.1+- texmath-0.11.1.2 - yaml-0.9.0-- hslua-1.0.0+- cmark-gfm-0.1.6+- hslua-1.0.1 - hslua-module-text-0.2.0+- skylighting-0.7.4+- skylighting-core-0.7.4 ghc-options: "$locals": -fhide-source-paths -XNoImplicitPrelude-resolver: lts-12.6+resolver: lts-12.12
@@ -7,7 +7,7 @@ import Data.Version (Version (versionBranch)) import System.FilePath ((</>)) import Test.Tasty (TestTree, localOption)-import Test.Tasty.HUnit (Assertion, assertEqual, assertFailure, testCase)+import Test.Tasty.HUnit (Assertion, assertEqual, testCase) import Test.Tasty.QuickCheck (QuickCheckTests (..), ioProperty, testProperty) import Text.Pandoc.Arbitrary () import Text.Pandoc.Builder (bulletList, divWith, doc, doubleQuoted, emph,@@ -17,7 +17,8 @@ import Text.Pandoc.Class (runIOorExplode, setUserDataDir) import Text.Pandoc.Definition (Block (BlockQuote, Div, Para), Inline (Emph, Str), Attr, Meta, Pandoc, pandocTypesVersion)-import Text.Pandoc.Lua (runLuaFilter, runPandocLua)+import Text.Pandoc.Filter (Filter (LuaFilter), applyFilters)+import Text.Pandoc.Lua (runLua) import Text.Pandoc.Options (def) import Text.Pandoc.Shared (pandocVersion) @@ -127,7 +128,7 @@ (doc $ para "ignored") (doc $ para (str $ "lua" </> "script-name.lua")) - , testCase "Pandoc version is set" . runPandocLua' $ do+ , testCase "Pandoc version is set" . runLua' $ do Lua.getglobal' "table.concat" Lua.getglobal "PANDOC_VERSION" Lua.push ("." :: String) -- separator@@ -135,13 +136,13 @@ Lua.liftIO . assertEqual "pandoc version is wrong" pandocVersion =<< Lua.peek Lua.stackTop - , testCase "Pandoc types version is set" . runPandocLua' $ do+ , testCase "Pandoc types version is set" . runLua' $ do let versionNums = versionBranch pandocTypesVersion Lua.getglobal "PANDOC_API_VERSION" Lua.liftIO . assertEqual "pandoc-types version is wrong" versionNums =<< Lua.peek Lua.stackTop - , testCase "Allow singleton inline in constructors" . runPandocLua' $ do+ , testCase "Allow singleton inline in constructors" . runLua' $ do Lua.liftIO . assertEqual "Not the exptected Emph" (Emph [Str "test"]) =<< Lua.callFunc "pandoc.Emph" (Str "test") Lua.liftIO . assertEqual "Unexpected element" (Para [Str "test"])@@ -155,14 +156,14 @@ Lua.peek Lua.stackTop ) - , testCase "Elements with Attr have `attr` accessor" . runPandocLua' $ do+ , testCase "Elements with Attr have `attr` accessor" . runLua' $ do Lua.push (Div ("hi", ["moin"], []) [Para [Str "ignored"]]) Lua.getfield Lua.stackTop "attr" Lua.liftIO . assertEqual "no accessor" (("hi", ["moin"], []) :: Attr) =<< Lua.peek Lua.stackTop - , testCase "informative error messages" . runPandocLua' $ do+ , testCase "informative error messages" . runLua' $ do Lua.pushboolean True err <- Lua.peekEither Lua.stackTop case (err :: Either String Pandoc) of@@ -174,19 +175,17 @@ ] assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion-assertFilterConversion msg filterPath docIn docExpected = do- docEither <- runIOorExplode $ do+assertFilterConversion msg filterPath docIn expectedDoc = do+ actualDoc <- runIOorExplode $ do setUserDataDir (Just "../data")- runLuaFilter def ("lua" </> filterPath) [] docIn- case docEither of- Left exception -> assertFailure (show exception)- Right docRes -> assertEqual msg docExpected docRes+ applyFilters def [LuaFilter ("lua" </> filterPath)] ["HTML"] docIn+ assertEqual msg expectedDoc actualDoc 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 = runPandocLua' $ do+ roundtripped = runLua' $ do oldSize <- Lua.gettop Lua.push x size <- Lua.gettop@@ -197,10 +196,10 @@ Left e -> error (show e) Right y -> return y -runPandocLua' :: Lua.Lua a -> IO a-runPandocLua' op = runIOorExplode $ do+runLua' :: Lua.Lua a -> IO a+runLua' op = runIOorExplode $ do setUserDataDir (Just "../data")- res <- runPandocLua op+ res <- runLua op case res of Left e -> error (show e) Right x -> return x
@@ -171,6 +171,10 @@ , test "tables" ["-f", "native", "-t", "../data/sample.lua"] "tables.native" "tables.custom" ]+ , testGroup "man"+ [ test "reader" ["-r", "man", "-w", "native", "-s"]+ "man-reader.man" "man-reader.native"+ ] ] -- makes sure file is fully closed after reading
@@ -7,6 +7,7 @@ import qualified Data.Text as T import Test.Tasty import Test.Tasty.QuickCheck+import Test.Tasty.Options (IsOption(defaultValue)) import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary ()@@ -77,5 +78,9 @@ , 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")) ]- , testProperty "Round trip" (withMaxSuccess 25 roundTrip)+ , askOption $ \(QuickCheckTests numtests) ->+ testProperty "Round trip" $+ withMaxSuccess (if QuickCheckTests numtests == defaultValue+ then 25+ else numtests) roundTrip ]
@@ -0,0 +1,121 @@+{-# LANGUAGE OverloadedStrings #-}+module Tests.Readers.Man (tests) where++import Prelude+import Data.Text (Text)+import Test.Tasty+import Tests.Helpers+import Text.Pandoc+import Text.Pandoc.Arbitrary ()+import Text.Pandoc.Builder+import Text.Pandoc.Readers.Man++man :: Text -> Pandoc+man = purely $ readMan def++infix 4 =:+(=:) :: ToString c+ => String -> (Text, c) -> TestTree+(=:) = test man++tests :: [TestTree]+tests = [+ -- .SH "HEllo bbb" "aaa"" as"+ testGroup "Macros" [+ "Bold" =:+ ".B foo"+ =?> para (strong "foo")+ , "Italic" =:+ ".I bar\n"+ =?> para (emph "bar")+ , "BoldItalic" =:+ ".BI foo bar"+ =?> para (strong (str "foo") <> emph (str "bar"))+ , "H1" =:+ ".SH The header\n"+ =?> header 1 (text "The header")+ , "H2" =:+ ".SS \"The header 2\""+ =?> header 2 (text "The header 2")+ , "Macro args" =:+ ".B \"single arg with \"\"Q\"\"\""+ =?> (para $ strong $ text "single arg with \"Q\"")+ , "Argument from next line" =:+ ".B\nsingle arg with \"Q\""+ =?> (para $ strong $ text "single arg with \"Q\"")+ , "comment" =:+ ".\\\"bla\naaa"+ =?> (para $ str "aaa")+ , "link" =:+ ".BR aa (1)"+ =?> para (strong (str "aa") <> str "(1)")+ ],+ testGroup "Escapes" [+ "fonts" =:+ "aa\\fIbb\\fRcc"+ =?> (para $ str "aa" <> (emph $ str "bb") <> str "cc")+ , "nested fonts" =:+ "\\f[BI]hi\\f[I] there\\f[R]"+ =?> para (emph (strong (text "hi") <> text " there"))+ , "nested fonts 2" =:+ "\\f[R]hi \\f[I]there \\f[BI]bold\\f[R] ok"+ =?> para (text "hi " <> emph (text "there " <> strong (text "bold")) <>+ text " ok")+ , "skip" =:+ "a\\%\\{\\}\\\n\\:b\\0"+ =?> (para $ str "ab\8199")+ , "replace" =:+ "\\-\\ \\\\\\[lq]\\[rq]\\[em]\\[en]\\*(lq\\*(rq"+ =?> (para $ text "- \\“”—–“”")+ , "replace2" =:+ "\\t\\e\\`\\^\\|\\'" =?> (para $ text "\\`\8202\8198`")+ , "comment with \\\"" =:+ "Foo \\\" bar\n" =?> (para $ text "Foo")+ , "comment with \\#" =:+ "Foo\\#\nbar\n" =?> (para $ text "Foobar")+ , "two letter escapes" =:+ "\\(oA\\(~O" =?> (para $ text "ÅÕ")+ , "bracketed escapes" =:+ "\\[oA]\\[~O]\\[Do]\\[Ye]\\[product]\\[ul]" =?> (para $ text "ÅÕ$¥∏_")+ , "unicode escapes" =:+ "\\[u2020]" =?> (para $ text "†")+ , "unicode escapes (combined)" =:+ "\\[u0075_u0301]" =?> (para $ text "\250")+ , "unknown escape (#5034)" =:+ "\\9" =?> (para $ text "9")+ ],+ testGroup "Lists" [+ "bullet" =:+ ".IP \"\\[bu]\"\nfirst\n.IP \"\\[bu]\"\nsecond"+ =?> bulletList [para $ str "first", para $ str "second"]+ , "ordered" =:+ ".IP 2 a\nfirst\n.IP 3 a\nsecond"+ =?> orderedListWith (2,Decimal,DefaultDelim) [para $ str "first", para $ str "second"]+ , "upper" =:+ ".IP A) a\nfirst\n.IP B) a\nsecond"+ =?> orderedListWith (1,UpperAlpha,OneParen) [para $ str "first", para $ str "second"]+ , "nested" =:+ ".IP \"\\[bu]\"\nfirst\n.RS\n.IP \"\\[bu]\"\n1a\n.IP \"\\[bu]\"\n1b\n.RE"+ =?> bulletList [(para $ str "first") <> (bulletList [para $ str "1a", para $ str "1b"])]+ , "change in list style" =:+ ".IP \\[bu]\nfirst\n.IP 1\nsecond"+ =?> bulletList [para (str "first")] <>+ orderedListWith (1,Decimal,DefaultDelim) [para (str "second")]+ ],+ testGroup "CodeBlocks" [+ "cb1"=:+ ".nf\naa\n\tbb\n.fi"+ =?> codeBlock "aa\n\tbb"+ ],+ testGroup "Tables" [+ "t1" =:+ ".TS\nallbox;\nl l l.\na\tb\tc\nd\te\tf\n.TE"+ =?> table mempty (replicate 3 (AlignLeft, 0.0)) [] [+ map (plain . str ) ["a", "b", "c"],+ map (plain . str ) ["d", "e", "f"]+ ],+ "longcell" =:+ ".TS\n;\nr.\nT{\na\nb\nc d\nT}\nf\n.TE"+ =?> table mempty [(AlignRight, 0.0)] [] [[plain $ text "a b c d"], [plain $ str "f"]]+ ]+ ]
@@ -4,16 +4,18 @@ import Prelude import Data.List (intersperse)+import Data.Monoid (Any (..)) import Data.Text (Text) import qualified Data.Text as T import Test.Tasty import Test.Tasty.QuickCheck+import Test.Tasty.Options (IsOption(defaultValue)) import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary () import Text.Pandoc.Builder import Text.Pandoc.Shared (underlineSpan)-import Text.Pandoc.Walk (walk)+import Text.Pandoc.Walk amuse :: Text -> Pandoc amuse = purely $ readMuse def { readerExtensions = extensionsFromList [Ext_amuse]}@@ -32,7 +34,20 @@ -- Tables don't round-trip yet -- makeRoundTrip :: Block -> Block-makeRoundTrip Table{} = Para [Str "table was here"]+makeRoundTrip t@(Table _caption aligns widths headers rows) =+ if isSimple && numcols > 1+ then t+ else Para [Str "table was here"]+ where numcols = maximum (length aligns : length widths : map length (headers:rows))+ hasSimpleCells = all isSimpleCell (concat (headers:rows))+ isLineBreak LineBreak = Any True+ isLineBreak _ = Any False+ hasLineBreak = getAny . query isLineBreak+ isSimple = hasSimpleCells && all (== 0) widths+ isSimpleCell [Plain ils] = not (hasLineBreak ils)+ isSimpleCell [Para ils ] = not (hasLineBreak ils)+ isSimpleCell [] = True+ isSimpleCell _ = False makeRoundTrip (OrderedList (start, LowerAlpha, _) items) = OrderedList (start, Decimal, Period) items makeRoundTrip (OrderedList (start, UpperAlpha, _) items) = OrderedList (start, Decimal, Period) items makeRoundTrip x = x@@ -62,13 +77,12 @@ "*Foo bar*" =?> para (emph . spcSep $ ["Foo", "bar"]) - -- Emacs Muse allows this , "Newline in the beginning of emphasis" =: "*\nFoo bar*" =?>- para (emph ("Foo" <> space <> "bar"))+ para (text "*\nFoo bar*") , "Newline in the end of emphasis" =: "*Foo bar\n*" =?>- para (emph ("Foo" <> space <> "bar"))+ para (text "*Foo bar\n*") , "Comma after closing *" =: "Foo *bar*, baz" =?>@@ -100,6 +114,14 @@ "***strength***" =?> para (strong . emph $ "strength") + , "Strong inside emphasis" =:+ "*foo **bar** baz*" =?>+ para (emph (text "foo " <> strong (text "bar") <> text " baz"))++ , "Emphasis inside strong" =:+ "**foo *bar* baz**" =?>+ para (strong (text "foo " <> emph (text "bar") <> text " baz"))+ , test emacsMuse "Underline" ("_Underline_" =?> para (underlineSpan "Underline")) @@ -156,6 +178,8 @@ , "One character code" =: "=c=" =?> para (code "c") + , "Code with equal sign" =: "=foo = bar=" =?> para (code "foo = bar")+ , "Three = characters is not a code" =: "===" =?> para "===" , "Multiline code markup" =:@@ -260,7 +284,11 @@ ] , testGroup "Blocks"- [ testProperty "Round trip" (withMaxSuccess 25 roundTrip)+ [ askOption $ \(QuickCheckTests numtests) ->+ testProperty "Round trip" $+ withMaxSuccess (if QuickCheckTests numtests == defaultValue+ then 25+ else numtests) roundTrip , "Block elements end paragraphs" =: T.unlines [ "First paragraph" , "----"@@ -272,6 +300,14 @@ , "5 dashes is a horizontal rule" =: "-----" =?> horizontalRule , "4 dashes with spaces is a horizontal rule" =: "---- " =?> horizontalRule ]+ , testGroup "Page breaks"+ [ "Page break" =:+ " * * * * *" =?>+ divWith ("", [], [("style", "page-break-before: always;")]) mempty+ , "Page break with trailing space" =:+ " * * * * * " =?>+ divWith ("", [], [("style", "page-break-before: always;")]) mempty+ ] , testGroup "Paragraphs" [ "Simple paragraph" =: T.unlines [ "First line"@@ -452,6 +488,20 @@ , "}}}" ] =?> codeBlock "Example line\n"+ , "Indented braces" =:+ T.unlines [ " - {{{"+ , " Example line"+ , " }}}"+ ] =?>+ bulletList [ codeBlock "Example line" ]+ , "Tabs" =:+ T.unlines [ "{{{"+ , "\t foo"+ , "\t\t"+ , "\t bar"+ , "}}}"+ ] =?>+ codeBlock " foo\n\t\n bar" -- Amusewiki requires braces to be on separate line, -- this is an extension. , "One line" =:@@ -629,6 +679,13 @@ T.unlines [ "* Foo" , "bar" ] =?> header 1 "Foo\nbar"+ , "Empty header" =:+ T.unlines [ "Foo"+ , ""+ , "* "+ , ""+ , "bar"+ ] =?> para (text "Foo") <> header 1 "" <> para (text "bar") , test (purely $ readMuse def { readerExtensions = extensionsFromList [Ext_amuse, Ext_auto_identifiers]}) "Auto identifiers" (T.unlines [ "* foo"@@ -769,6 +826,23 @@ , "baz" ] =?> para (str "Foo" <> note (lineBlock ["bar"])) <> para (str "baz")++ , "Footnote starting with empty line" =:+ T.unlines [ "Foo[1]"+ , ""+ , "[1]" -- No space character after note marker+ , ""+ , " Bar"+ ] =?>+ para (str "Foo" <> note (para $ text "Bar"))+ , "Indentation in footnote starting with empty line" =:+ T.unlines [ "Foo[1]"+ , ""+ , "[1]" -- No space character after note marker+ , ""+ , " Bar"+ ] =?>+ para (str "Foo" <> note mempty) <> blockQuote (para $ text "Bar") , test emacsMuse "Emacs multiparagraph footnotes" (T.unlines [ "First footnote reference[1] and second footnote reference[2]."@@ -857,6 +931,14 @@ [plain "Foo", plain "bar", plain "baz"] [[plain "First", plain "row", plain "here"], [plain "Second", plain "row", plain "there"]]+ , "Table caption with +" =:+ T.unlines+ [ "Foo | bar"+ , "|+ Table + caption +|"+ ] =?>+ table (text "Table + caption") (replicate 2 (AlignDefault, 0.0))+ []+ [[plain "Foo", plain "bar"]] , "Caption without table" =: "|+ Foo bar baz +|" =?> table (text "Foo bar baz") [] [] []@@ -883,6 +965,17 @@ [[plain "", plain "Foo"], [plain "", plain ""], [plain "bar", plain ""]]+ , "Empty cell in the middle" =:+ T.unlines+ [ " 1 | 2 | 3"+ , " 4 | | 6"+ , " 7 | 8 | 9"+ ] =?>+ table mempty [(AlignDefault, 0.0), (AlignDefault, 0.0), (AlignDefault, 0.0)]+ []+ [[plain "1", plain "2", plain "3"],+ [plain "4", mempty, plain "6"],+ [plain "7", plain "8", plain "9"]] ] , testGroup "Lists" [ "Bullet list" =:@@ -1249,6 +1342,18 @@ ] ]) ]+ , "Definition list with table" =:+ " foo :: bar | baz" =?>+ definitionList [ ("foo", [ table mempty [(AlignDefault, 0.0), (AlignDefault, 0.0)]+ []+ [[plain "bar", plain "baz"]]+ ])]+ , "Definition list with table inside bullet list" =:+ " - foo :: bar | baz" =?>+ bulletList [definitionList [ ("foo", [ table mempty [(AlignDefault, 0.0), (AlignDefault, 0.0)]+ []+ [[plain "bar", plain "baz"]]+ ])]] , test emacsMuse "Multi-line definition lists from Emacs Muse manual" (T.unlines [ "Term1 ::"
@@ -247,6 +247,7 @@ , " first inner definition :: first inner description" , " second inner definition :: second inner description" ]+ , "list item starting with list" =: bulletList [ bulletList [ plain $ text "foo"] ] =?> " - - foo" ] -- Check that list is intended with one space even inside a quote , "List inside block quote" =: blockQuote (orderedList [ plain $ text "first"@@ -400,6 +401,9 @@ , "strong after emphasis" =: emph (text "foo") <> strong (text "bar") =?> "*foo*<strong>bar</strong>" , "strong emphasis after emphasis" =: emph (text "foo") <> strong (emph (text "bar")) =?> "*foo*<strong>*bar*</strong>" , "strong in the end of emphasis" =: emph (text "foo" <> strong (text "bar")) =?> "*foo<strong>bar</strong>*"+ , "switch to lightweight markup after <em> tag" =:+ strong (str "foo") <> emph (str "bar") <> strong (str "baz") =?>+ "**foo**<em>bar</em>**baz**" , "strikeout" =: strikeout (text "foo") =?> "<del>foo</del>" , "space at the beginning of emphasis" =: emph (text " foo") =?> "<em> foo</em>" , "space at the end of emphasis" =: emph (text "foo ") =?> "<em>foo </em>"
@@ -95,5 +95,8 @@ def "pptx/remove_empty_slides.native" "pptx/remove_empty_slides.pptx"-+ , pptxTests "raw ooxml"+ def+ "pptx/raw_ooxml.native"+ "pptx/raw_ooxml.pptx" ]
@@ -0,0 +1,13 @@+```+% pandoc -f markdown -t native+<?php echo "1" ; ?>+^D+[RawBlock (Format "html") "<?php echo \"1\" ; ?>"]+```++```+% pandoc -f markdown -t native+a<?php echo "1" ; ?>+^D+[Para [Str "a",RawInline (Format "html") "<?php echo \"1\" ; ?>"]]+```
@@ -25,7 +25,7 @@ <td style="text-align: left;">thank you</td> </tr> <tr class="odd">-<td style="text-align: right;"><p><em>blah</em></p></td>+<td style="text-align: right;"><em>blah</em></td> <td style="text-align: left;"><em>blah</em></td> <td style="text-align: left;"><em>blah</em></td> </tr>
@@ -7,9 +7,10 @@ normal `code` normal. ^D .PP-normal \f[I]italic \f[BI]bold in the middle\f[I] only italic\f[] normal.+normal \f[I]italic \f[BI]bold in the middle\f[I] only italic\f[R]+normal. .PP-normal \f[B]bold \f[BC]code\f[B] more bold\f[] normal.+normal \f[B]bold \f[CB]code\f[B] more bold\f[R] normal. .PP-normal \f[C]code\f[] normal.+normal \f[C]code\f[R] normal. ```
@@ -15,11 +15,9 @@ \caption{Subfigure with Subfloat} \end{figure} ^D- <figure> <img src="img1.jpg" alt="Caption 1" /><figcaption>Caption 1</figcaption> </figure>- <figure> <img src="img2.jpg" alt="Caption 2" /><figcaption>Caption 2</figcaption> </figure>
@@ -1,5 +1,5 @@ ```-pandoc -f latex -t native+pandoc -f latex+raw_tex -t native \def\filename@area{foo:bar:baz} \makeatletter \graphicspath\expandafter{\expandafter{\filename@area}}%@@ -10,7 +10,7 @@ ``` ```-pandoc -f latex -t native+pandoc -f latex+raw_tex -t native \makeatletter \newcommand\urlfootnote@[1]{\footnote{\url@{#1}}} \DeclareRobustCommand{\urlfootnote}{\hyper@normalise\urlfootnote@}@@ -21,7 +21,7 @@ ``` ```-pandoc -f latex -t native+pandoc -f latex+raw_tex -t native \def\foo{bar} \expandafter\bam\foo ^D
@@ -0,0 +1,40 @@+```+% pandoc -f org -t native+#+EXCLUDE_TAGS:apple cat bye dog % ++* This should not appear :apple:+* NOEXPORT should appear if not specified in EXCLUDE_TAGS :noexport:+* This should not appear :cat:hi:laptop:+** Children of headers with excluded tags should not appear :xylophone:+* This should not appear :%:+^D+[Header 1 ("noexport-should-appear-if-not-specified-in-excludetags",[],[]) [Str "NOEXPORT",Space,Str "should",Space,Str "appear",Space,Str "if",Space,Str "not",Space,Str "specified",Space,Str "in",Space,Str "EXCLUDE",Subscript [Str "TAGS"],Space,Span ("",["tag"],[("tag-name","noexport")]) [SmallCaps [Str "noexport"]]]]+```++```+% pandoc -f org -t native+#+EXCLUDE_TAGS:elephant+* This should not appear :elephant:+* This should appear :fawn:+^D+[Header 1 ("this-should-appear",[],[]) [Str "This",Space,Str "should",Space,Str "appear",Space,Span ("",["tag"],[("tag-name","fawn")]) [SmallCaps [Str "fawn"]]]]+```++```+% pandoc -f org -t native+#+EXCLUDE_TAGS: giraffe+#+EXCLUDE_TAGS: hippo+* This should not appear :giraffe:+* This should not appear :hippo:+* This should appear :noexport:+^D+[Header 1 ("this-should-appear",[],[]) [Str "This",Space,Str "should",Space,Str "appear",Space,Span ("",["tag"],[("tag-name","noexport")]) [SmallCaps [Str "noexport"]]]]+```++```+% pandoc -f org -t native+#+EXCLUDE_TAGS:+* NOEXPORT should appear if not specified in EXCLUDE_TAGS :noexport:+^D+[Header 1 ("noexport-should-appear-if-not-specified-in-excludetags",[],[]) [Str "NOEXPORT",Space,Str "should",Space,Str "appear",Space,Str "if",Space,Str "not",Space,Str "specified",Space,Str "in",Space,Str "EXCLUDE",Subscript [Str "TAGS"],Space,Span ("",["tag"],[("tag-name","noexport")]) [SmallCaps [Str "noexport"]]]]+```
@@ -0,0 +1,10 @@+```+pandoc -f latex -t native+\documentclass{article}+\usepackage{hyperref}+\begin{document}+The file id is \nolinkurl{ESP_123_5235}.+\end{document}+^D+[Para [Str "The",Space,Str "file",Space,Str "id",Space,Str "is",Space,Code ("",[],[]) "ESP_123_5235",Str "."]]+```
@@ -0,0 +1,10 @@+```+% pandoc -f rst -t native+-++=====+^D+[BulletList+ [[]]+,HorizontalRule]+```
@@ -1,7 +1,7 @@ # Raw TeX blocks in CommonMark with and without raw_tex ```-% pandoc -f latex -t commonmark-raw_tex+% pandoc -f latex+raw_tex -t commonmark-raw_tex \someunknowncommand Hello.@@ -10,12 +10,27 @@ ``` ```-% pandoc -f latex -t commonmark+raw_tex+% pandoc -f latex+raw_tex -t commonmark+raw_tex \someunknowncommand Hello. ^D \someunknowncommand +Hello.+```++```+% pandoc -f latex -t native+\maketitle+^D+[]+```++```+% pandoc -f latex -t rst+\maketitle+Hello.+^D Hello. ```
@@ -0,0 +1,156 @@+# Rendering small caps, superscripts and subscripts with and without `raw_html`++## Small caps++```+% pandoc --wrap=none -f latex -t commonmark-raw_html+This has \textsc{small caps} in it.+^D+This has SMALL CAPS in it.+```++```+% pandoc --wrap=none -f latex -t commonmark+raw_html+This has \textsc{small caps} in it.+^D+This has <span class="smallcaps">small caps</span> in it.+```+```++```+% pandoc --wrap=none -f latex -t markdown_strict+raw_html+This has \textsc{small caps} in it.+^D+This has <span class="smallcaps">small caps</span> in it.+```++## Strikeout++```+% pandoc --wrap=none -f html -t commonmark-raw_html-strikeout+This has <s>strikeout</s> in it.+^D+This has strikeout in it.++```+% pandoc --wrap=none -f html -t commonmark+raw_html-strikeout+This has <s>strikeout</s> in it.+^D+This has <s>strikeout</s> in it.+```++```+% pandoc --wrap=none -f html -t commonmark-raw_html+strikeout+This has <s>strikeout</s> in it.+^D+This has ~~strikeout~~ in it.+```++```+% pandoc --wrap=none -f html -t commonmark+raw_html+strikeout+This has <s>strikeout</s> in it.+^D+This has ~~strikeout~~ in it.+```++```+% pandoc --wrap=none -f html -t markdown_strict-raw_html-strikeout+This has <s>strikeout</s> in it.+^D+This has strikeout in it.+```++```+% pandoc --wrap=none -f html -t markdown_strict+raw_html-strikeout+This has <s>strikeout</s> in it.+^D+This has <s>strikeout</s> in it.+```++```+% pandoc --wrap=none -f html -t markdown_strict-raw_html+strikeout+This has <s>strikeout</s> in it.+^D+This has ~~strikeout~~ in it.+```++```+% pandoc --wrap=none -f html -t markdown_strict+raw_html+strikeout+This has <s>strikeout</s> in it.+^D+This has ~~strikeout~~ in it.+```++## Superscript++```+% pandoc --wrap=none -f html -t commonmark-raw_html+This has <sup>superscript</sup> in it and <sup>2 3</sup> again. With emphasis: <sup><em>2</em> 3</sup>. With letters: <sup>foo</sup>. With a span: <sup><span class=foo>2</span></sup>.+^D+This has ^(superscript) in it and ² ³ again. With emphasis: ^(*2* 3). With letters: ^(foo). With a span: ².+```++```+% pandoc --wrap=none -f html -t commonmark+raw_html+This has <sup>superscript</sup> in it and <sup>2</sup> again.+^D+This has <sup>superscript</sup> in it and <sup>2</sup> again.+```++```+% pandoc --wrap=none -f html -t markdown_strict-raw_html-superscript+This has <sup>superscript</sup> in it and <sup>2</sup> again.+^D+This has ^(superscript) in it and ² again.+```++```+% pandoc --wrap=none -f html -t markdown_strict+raw_html-superscript+This has <sup>superscript</sup> in it and <sup>2</sup> again.+^D+This has <sup>superscript</sup> in it and <sup>2</sup> again.+```++```+% pandoc --wrap=none -f html -t markdown_strict+raw_html+superscript+This has <sup>superscript</sup> in it and <sup>2</sup> again.+^D+This has ^superscript^ in it and ^2^ again.+```++## Subscript++```+% pandoc --wrap=none -f html -t commonmark-raw_html+This has <sub>subscript</sub> in it and <sub>2 3</sub> again. With emphasis: <sub><em>2</em> 3</sub>. With letters: <sub>foo</sub>. With a span: <sub><span class=foo>2</span></sub>.+^D+This has \_(subscript) in it and ₂ ₃ again. With emphasis: \_(*2* 3). With letters: \_(foo). With a span: ₂.+```++```+% pandoc --wrap=none -f html -t commonmark+raw_html+This has <sub>subscript</sub> in it and <sub>2</sub> again.+^D+This has <sub>subscript</sub> in it and <sub>2</sub> again.+```++```+% pandoc --wrap=none -f html -t markdown_strict-raw_html-subscript+This has <sub>subscript</sub> in it and <sub>2</sub> again.+^D+This has _(subscript) in it and ₂ again.+```++```+% pandoc --wrap=none -f html -t markdown_strict+raw_html-subscript+This has <sub>subscript</sub> in it and <sub>2</sub> again.+^D+This has <sub>subscript</sub> in it and <sub>2</sub> again.+```++```+% pandoc --wrap=none -f html -t markdown_strict+raw_html+subscript+This has <sub>subscript</sub> in it and <sub>2</sub> again.+^D+This has ~subscript~ in it and ~2~ again.+```
@@ -3,5 +3,5 @@ A ‘simple’ example ^D .LP-A ‘simple’ example+A \[oq]simple\[cq] example ```
@@ -0,0 +1,30 @@+```+% pandoc -f latex -t native+\begin{Verbatim}[key1=value1]+code1++\end{Verbatim}+++\begin{lstlisting}[key2=value2]+code2+ +\end{lstlisting}++\begin{verbatim}+code3+\end{verbatim}++\begin{verbatim}+code4+ \end{verbatim}++\begin{verbatim}+code5\end{verbatim}+^D+[CodeBlock ("",[],[("key1","value1")]) "code1\n"+,CodeBlock ("",[],[("key2","value2")]) "code2\n "+,CodeBlock ("",[],[]) "code3"+,CodeBlock ("",[],[]) "code4"+,CodeBlock ("",[],[]) "code5"]+```
@@ -0,0 +1,31 @@+```+% pandoc -f markdown -t native+(cf.+foo)+^D+[Para [Str "(cf.",SoftBreak,Str "foo)"]]+```++```+% pandoc -f markdown -t native+a (cf.+foo)+^D+[Para [Str "a",Space,Str "(cf.",SoftBreak,Str "foo)"]]+```++```+% pandoc -f markdown -t native+cf.+foo+^D+[Para [Str "cf.\160foo"]]+```++```+% pandoc -f markdown -t native+a cf.+foo+^D+[Para [Str "a",SoftBreak,Str "cf.\160foo"]]+```
@@ -0,0 +1,16 @@+```+% pandoc -f rst -t native+.. toctree::+ :name: tree1+ :class: foo bar+ :caption: Indice dei contenuti+ :numbered:+ :maxdepth: 3++ premessa.rst+ acquisizione-software.rst+ riuso-software.rst+^D+[Div ("tree1",["toctree","foo","bar"],[("caption","Indice dei contenuti"),("numbered",""),("maxdepth","3")])+ [Para [Str "premessa.rst",SoftBreak,Str "acquisizione-software.rst",SoftBreak,Str "riuso-software.rst"]]]+ ```
@@ -0,0 +1,7 @@+```+% pandoc -t latex+$x=y%comment$+^D+\(x=y%comment+\)+```
@@ -0,0 +1,22 @@+```+% pandoc -t latex --biblatex+[@a1;@a2;@a3]+^D+\autocite{a1,a2,a3}+```++```+% pandoc -t latex --biblatex+@a1 [@a2;@a3]+^D+\textcite{a1,a2,a3}+```++```+% pandoc -t latex --biblatex+[@a1, blah; @a2; see @a3]+^D+\autocites[blah]{a1}{a2}[see][]{a3}+```++
@@ -0,0 +1,21 @@+```+% pandoc -f latex -t latex+\(\left\{ \begin{matrix}+y\,\,\,\, \geqq \,\,\, f\,(\, x\,)\,\, \\+y\,\,\, \leqq \,\,\, g\,(\, x\,)\, \\+\end{matrix} \right.\ \)+^D+\(\left\{ \begin{matrix}+y\,\,\,\, \geqq \,\,\, f\,(\, x\,)\,\, \\+y\,\,\, \leqq \,\,\, g\,(\, x\,)\, \\+\end{matrix} \right.\ \)+```++```+% pandoc -f markdown -t latex+$x\ $+^D+\(x\ \)+```++
@@ -0,0 +1,27 @@+```+% pandoc -f man -t plain+.ds foo bar+.ds bar baz+\*[\*[foo]]+^D+baz+```++```+% pandoc -f man -t plain+.ds foo [bar]+.ds bar baz+\*\*[foo]+^D+baz+```++```+% pandoc -f man -t html+.ds B-Font B+.ds I-Font I+.ds R-Font R+\f\*[B-Font]certtool\fP+^D+<p><strong>certtool</strong></p>+```
@@ -0,0 +1,53 @@+```+pandoc -t html --ascii+äéıå+^D+<p>äéıå</p>+```++```+pandoc -t latex --ascii+äéıå+^D+\"{a}\'{e}\i \r{a}+```++```+pandoc -t man --ascii+äéıå+^D+.PP+\[:a]\['e]\[.i]\[oa]+```++```+pandoc -t ms --ascii+äéıå+^D+.LP+\[:a]\['e]\[.i]\[oa]+```++```+pandoc -t docbook --ascii+äéıå+^D+<para>+ äéıå+</para>+```++```+pandoc -t jats --ascii+äéıå+^D+<p>äéıå</p>+```++```+pandoc -t markdown-smart --ascii+"äéıå"+^D+“äéıå”+```+
@@ -5,6 +5,5 @@ \h{a} \h{b} ^D-[Para [Emph [Str "no"]]-,Para [Str "\225",SoftBreak,Str "b"]]+[Para [Emph [Str "no"],SoftBreak,Str "\225",SoftBreak,Str "b"]] ```
@@ -0,0 +1,11 @@+function report (what, value)+ print(string.format('%16s: %s', what, value))+end+report('# input files', #PANDOC_STATE.input_files)+report('output file', PANDOC_STATE.output_file)+report('# request header', #PANDOC_STATE.request_headers)+report('resource path', table.concat(PANDOC_STATE.resource_path, ', '))+report('source URL', PANDOC_STATE.source_url)+report('user data dir', PANDOC_STATE.user_data_dir and 'defined' or 'unset')+report('trace', PANDOC_STATE.trace)+report('verbosity', PANDOC_STATE.verbosity)
@@ -0,0 +1,14 @@+```+% pandoc --lua-filter=command/lua-pandoc-state.lua+Hello+^D+ # input files: 0+ output file: nil+# request header: 0+ resource path: .+ source URL: nil+ user data dir: defined+ trace: false+ verbosity: WARNING+<p>Hello</p>+```
@@ -4,6 +4,7 @@ $\my+\my$ ^D \newcommand{\my}{\phi}+ $\phi+\phi$ ``` @@ -13,6 +14,7 @@ $\my+\my$ ^D \newcommand{\my}{\phi}+ $\my+\my$ ``` @@ -75,6 +77,7 @@ \end{equation} ^D \newcommand{\my}{\phi}+ \begin{equation} \phi+\phi \end{equation}@@ -88,6 +91,7 @@ \end{equation} ^D \newcommand{\my}{\phi}+ \begin{equation} \my+\my \end{equation}@@ -101,3 +105,21 @@ \newcommand{\my}{\emph{a}} \emph{a} ```++<https://tex.stackexchange.com/questions/258/what-is-the-difference-between-let-and-def>++```+% pandoc -f latex -t plain+\def\bar{hello}+\let\fooi\bar+\def\fooii{\bar}+\fooi +\fooii++\def\bar{goodbye}+\fooi +\fooii+^D+hello+hello++hello+goodbye+```+
binary file changed (9778 → 10147 bytes)
binary file changed (9638 → 10007 bytes)
binary file changed (9960 → 10328 bytes)
binary file changed (9724 → 10092 bytes)
binary file changed (12118 → 12486 bytes)
binary file changed (9617 → 9986 bytes)
binary file changed (9765 → 10134 bytes)
binary file changed (26452 → 26810 bytes)
binary file changed (9560 → 9929 bytes)
binary file changed (9747 → 10115 bytes)
binary file changed (26506 → 26865 bytes)
binary file changed (9781 → 10150 bytes)
binary file changed (9960 → 10329 bytes)
binary file changed (10031 → 10400 bytes)
binary file changed (9830 → 10199 bytes)
binary file changed (9830 → 10199 bytes)
binary file changed (9882 → 10251 bytes)
binary file changed (9731 → 10100 bytes)
binary file changed (9581 → 9950 bytes)
binary file changed (9948 → 10317 bytes)
binary file changed (9963 → 10332 bytes)
binary file changed (9604 → 9973 bytes)
binary file changed (9587 → 9956 bytes)
binary file changed (9621 → 9990 bytes)
binary file changed (9545 → 9914 bytes)
binary file changed (9593 → 9962 bytes)
@@ -29,7 +29,7 @@ pre.numberSource a.sourceLine { position: relative; left: -4em; } pre.numberSource a.sourceLine::before- { content: attr(data-line-number);+ { content: attr(title); position: relative; left: -1em; text-align: right; vertical-align: baseline; border: none; pointer-events: all; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none;@@ -82,9 +82,9 @@ <h1 id="lhs-test">lhs test</h1> <p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>-<div class="sourceCode" id="cb1"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d</a>-<a class="sourceLine" id="cb1-2" data-line-number="2">unsplit <span class="fu">=</span> arr <span class="fu">.</span> uncurry</a>-<a class="sourceLine" id="cb1-3" data-line-number="3"> <span class="co">-- arr (\op (x,y) -> x `op` y)</span></a></code></pre></div>+<div class="sourceCode" id="cb1"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d</a>+<a class="sourceLine" id="cb1-2" title="2">unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span></a>+<a class="sourceLine" id="cb1-3" title="3"> <span class="co">-- arr (\op (x,y) -> x `op` y)</span></a></code></pre></div> <p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
@@ -29,7 +29,7 @@ pre.numberSource a.sourceLine { position: relative; left: -4em; } pre.numberSource a.sourceLine::before- { content: attr(data-line-number);+ { content: attr(title); position: relative; left: -1em; text-align: right; vertical-align: baseline; border: none; pointer-events: all; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none;@@ -82,9 +82,9 @@ <h1 id="lhs-test">lhs test</h1> <p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>-<div class="sourceCode" id="cb1"><pre class="sourceCode literate literatehaskell"><code class="sourceCode literatehaskell"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="ot">> unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d</a>-<a class="sourceLine" id="cb1-2" data-line-number="2"><span class="ot">></span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> uncurry</a>-<a class="sourceLine" id="cb1-3" data-line-number="3"><span class="ot">></span> <span class="co">-- arr (\op (x,y) -> x `op` y)</span></a></code></pre></div>+<div class="sourceCode" id="cb1"><pre class="sourceCode literate literatehaskell"><code class="sourceCode literatehaskell"><a class="sourceLine" id="cb1-1" title="1"><span class="ot">> unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d</a>+<a class="sourceLine" id="cb1-2" title="2"><span class="ot">></span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span></a>+<a class="sourceLine" id="cb1-3" title="3"><span class="ot">></span> <span class="co">-- arr (\op (x,y) -> x `op` y)</span></a></code></pre></div> <p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
@@ -103,7 +103,7 @@ \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}-\NormalTok{unsplit }\FunctionTok{=}\NormalTok{ arr }\FunctionTok{.}\NormalTok{ uncurry}+\NormalTok{unsplit }\FunctionTok{=}\NormalTok{ arr }\FunctionTok{.} \FunctionTok{uncurry} \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y)} \end{Highlighting} \end{Shaded}
@@ -0,0 +1,391 @@+.TH "Pandoc Man tests" "" "Oct 17, 2018" "" ""+.PP+This is a set of tests for pandoc.+.PP+ * * * * *+.SH Headers+.SH Level 1+.SS Level 2++ * * * * *+.SH Paragraphs+.PP+Here's a regular paragraph.+.PP+Another paragraph+In Markdown 1.0.0 and earlier.+Version 8.+This line turns into a list item.+Because a hard\-wrapped line in the middle of a paragraph looked like a list+item.+.PP+There should be a hard line break+.PD 0+.P+.PD+here.+.PP+ * * * * *+.SH Block Quotes+Code in a block quote:+.RS+.nf+\f[C]+sub\ status\ {+\ \ \ \ print\ "working";+}+\f[]+.fi+.RE+.PP+A list:+.IP "1." 3+item one+.IP "2." 3+item two+.PP+.SH Code Blocks+.PP+Code:+.IP+.nf+\f[C]+\-\-\-\- (should be four hyphens)++sub status {+ print "working";+}++\f[]+.fi+.PP+And:+.IP+.nf+\f[C]+\tthis code line is indented by one tab+\f[]+.fi+.PP+ * * * * *+.SH Lists+.SS Unordered+.PP+Asterisks:+.IP \[bu] 2+asterisk 1+.IP \[bu] 2+asterisk 2+.IP \[bu] 2+asterisk 3+.PP+.SS Ordered+.IP "1." 3+First+.IP "2." 3+Second+.IP "3." 3+Third+.PP+.SS Nested+.IP \[bu] 2+Tab+.RS 2+.IP \[bu] 2+Tab+.RS 2+.IP \[bu] 2+Tab+.RE+.RE+.PP+Here's another:+.IP "1." 3+First+.IP "2." 3+Second:+.RS 4+.IP \[bu] 2+Fee+.IP \[bu] 2+Fie+.IP \[bu] 2+Foe+.RE+.IP "3." 3+Third+.PP+Same thing:+.IP "1." 3+First+.IP "2." 3+Second:+.RS 4+.IP \[bu] 2+Fee+.IP \[bu] 2+Fie+.IP \[bu] 2+Foe+.RE+.IP "3." 3+Third+.SS different styles:+.IP "A." 3+Upper Alpha+.RS 4+.IP "I." 3+Upper Roman.+.RS 4+.IP "(6)" 4+Decimal start with 6+.RS 4+.IP "c)" 3+Lower alpha with paren+.RE+.RE+.RE+.SS Ordered+Definition lists+.TP+.B term1+definition 1+.RS+.PP+continued+.RE+.TP+.B term2+definition 2+ * * * * *+.SH Special Characters+AT&T has an ampersand in their name.+.PP+4 < 5.+.PP+6 > 5.+.PP+Backslash: \\+.PP+Backtick: `+.PP+Asterisk: *+.PP+Underscore: _+.PP+Left brace: {+.PP+Right brace: }+.PP+Left bracket: [+.PP+Right bracket: ]+.PP+Left paren: (+.PP+Right paren: )+.PP+Greater\-than: >+.PP+Hash: #+.PP+Period: .+.PP+Bang: !+.PP+Plus: ++.PP+Minus: \-+.PP+.SH Links+.PP+.UR http://\:example.com+some random+site+.UE .+.PP+.MT me@example.com+my email address+.ME .+.SH Macros+.de au+.B+Me Myself+..+.de auth !!+.I+The author is \\$1.+.!!+.au+and I.+.auth "John Jones"+.ds me The \f[B]Author\f[R]+It's \*(me.+.SH Tables+.TS+tab(@);+r l c l.+T{+Right+T}@T{+Left+T}@T{+Center+T}@T{+Default+T}+_+T{+12+T}@T{+12+T}@T{+12+T}@T{+12+T}+T{+123+T}@T{+123+T}@T{+123+T}@T{+123+T}+T{+1+T}@T{+1+T}@T{+1+T}@T{+1+T}+.TE+.TS+allbox tab(;);+rlcl.+T{+Right+T};T{+Left+T};T{+Center+T};T{+Left+\f[I]more\f[R]+T}+_+T{+12+T};T{+12+T};T{+12+T};T{+12+T}+T{+123+T};T{+123+T};T{+123+T};T{+123+T}+T{+1+T};T{+1+T};T{+1+T};T{+1+T}+.TE+.TS+tab(@);+cw(10.5n) lw(9.6n) rw(11.4n) lw(24.5n).+T{+Centered Header+T}@T{+Left Aligned+T}@T{+Right Aligned+T}@T{+Default aligned+T}+_+T{+First+T}@T{+row+T}@T{+12.0+T}@T{+Example of a row that spans multiple lines.+T}+T{+Second+T}@T{+row+T}@T{+5.0+T}@T{+Here\[cq]s another one.+Note the blank line between rows.+T}+.TE+.PP+Table without column headers:+.PP+.TS+tab(@);+r l c r.+T{+12+T}@T{+12+T}@T{+12+T}@T{+12+T}+T{+123+T}@T{+123+T}@T{+123+T}@T{+123+T}+T{+1+T}@T{+1+T}@T{+1+T}@T{+1+T}+.TE+.TS+tab(@);+rl.+a@b+T{+.PP+one+.PP+two+T}@T{+.nf+some+ code+.fi+T}+.TE+
@@ -0,0 +1,180 @@+Pandoc (Meta {unMeta = fromList [("date",MetaInlines [Str "Oct",Space,Str "17,",Space,Str "2018"]),("section",MetaInlines []),("title",MetaInlines [Str "Pandoc",Space,Str "Man",Space,Str "tests"])]})+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc."]+,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]+,Header 1 ("",[],[]) [Str "Headers"]+,Header 1 ("",[],[]) [Str "Level",Space,Str "1"]+,Header 2 ("",[],[]) [Str "Level",Space,Str "2"]+,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]+,Header 1 ("",[],[]) [Str "Paragraphs"]+,Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]+,Para [Str "Another",Space,Str "paragraph",Space,Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break"]+,Para [Str "here."]+,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]+,Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]+,BlockQuote+ [CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"]+,Para [Str "A",Space,Str "list:"]+,OrderedList (1,Decimal,Period)+ [[Para [Str "item",Space,Str "one"]]+ ,[Para [Str "item",Space,Str "two"]]]+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]+,Para [Str "Code:"]+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n"+,Para [Str "And:"]+,CodeBlock ("",[],[]) "\tthis code line is indented by one tab"+,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]+,Header 1 ("",[],[]) [Str "Lists"]+,Header 2 ("",[],[]) [Str "Unordered"]+,Para [Str "Asterisks:"]+,BulletList+ [[Para [Str "asterisk",Space,Str "1"]]+ ,[Para [Str "asterisk",Space,Str "2"]]+ ,[Para [Str "asterisk",Space,Str "3"]]]+,Header 2 ("",[],[]) [Str "Ordered"]+,OrderedList (1,Decimal,Period)+ [[Para [Str "First"]]+ ,[Para [Str "Second"]]+ ,[Para [Str "Third"]]]+,Header 2 ("",[],[]) [Str "Nested"]+,BulletList+ [[Para [Str "Tab"]+ ,BulletList+ [[Para [Str "Tab"]+ ,BulletList+ [[Para [Str "Tab"]]]]]]]+,Para [Str "Here's",Space,Str "another:"]+,OrderedList (1,Decimal,Period)+ [[Para [Str "First"]]+ ,[Para [Str "Second:"]+ ,BulletList+ [[Para [Str "Fee"]]+ ,[Para [Str "Fie"]]+ ,[Para [Str "Foe"]]]]+ ,[Para [Str "Third"]]]+,Para [Str "Same",Space,Str "thing:"]+,OrderedList (1,Decimal,Period)+ [[Para [Str "First"]]+ ,[Para [Str "Second:"]+ ,BulletList+ [[Para [Str "Fee"]]+ ,[Para [Str "Fie"]]+ ,[Para [Str "Foe"]]]]+ ,[Para [Str "Third"]]]+,Header 2 ("",[],[]) [Str "different",Space,Str "styles:"]+,OrderedList (1,UpperAlpha,Period)+ [[Para [Str "Upper",Space,Str "Alpha"]+ ,OrderedList (1,UpperRoman,Period)+ [[Para [Str "Upper",Space,Str "Roman."]+ ,OrderedList (6,Decimal,TwoParens)+ [[Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]+ ,OrderedList (3,LowerAlpha,OneParen)+ [[Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]+,Header 2 ("",[],[]) [Str "Ordered"]+,Para [Str "Definition",Space,Str "lists"]+,DefinitionList+ [([Strong [Str "term1"]],+ [[Para [Str "definition",Space,Str "1"]+ ,Para [Str "continued"]]])+ ,([Strong [Str "term2"]],+ [[Para [Str "definition",Space,Str "2",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]]])]+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]+,Para [Str "4",Space,Str "<",Space,Str "5."]+,Para [Str "6",Space,Str ">",Space,Str "5."]+,Para [Str "Backslash:",Space,Str "\\"]+,Para [Str "Backtick:",Space,Str "`"]+,Para [Str "Asterisk:",Space,Str "*"]+,Para [Str "Underscore:",Space,Str "_"]+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]+,Para [Str "Left",Space,Str "paren:",Space,Str "("]+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]+,Para [Str "Greater-than:",Space,Str ">"]+,Para [Str "Hash:",Space,Str "#"]+,Para [Str "Period:",Space,Str "."]+,Para [Str "Bang:",Space,Str "!"]+,Para [Str "Plus:",Space,Str "+"]+,Para [Str "Minus:",Space,Str "-"]+,Header 1 ("",[],[]) [Str "Links"]+,Para [Link ("",[],[]) [Str "some",Space,Str "randomsite"] ("http://example.com",""),Str "."]+,Para [Link ("",[],[]) [Str "my",Space,Str "email",Space,Str "address"] ("mailto:me@example.com",""),Str "."]+,Header 1 ("",[],[]) [Str "Macros"]+,Para [Strong [Str "Me",Space,Str "Myself"],Space,Str "and",Space,Str "I.",Space,Emph [Str "The",Space,Str "author",Space,Str "is",Space,Str "John",Space,Str "Jones."],Space,Str "It's",Space,Str "The",Space,Strong [Str "Author"],Str "."]+,Header 1 ("",[],[]) [Str "Tables"]+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignLeft] [0.0,0.0,0.0,0.0]+ [[Plain [Str "Right"]]+ ,[Plain [Str "Left"]]+ ,[Plain [Str "Center"]]+ ,[Plain [Str "Default"]]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignLeft] [0.0,0.0,0.0,0.0]+ [[Plain [Str "Right"]]+ ,[Plain [Str "Left"]]+ ,[Plain [Str "Center"]]+ ,[Plain [Str "Left",Space,Emph [Str "more"]]]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.0,0.0,0.0,0.0]+ [[Plain [Str "Centered",Space,Str "Header"]]+ ,[Plain [Str "Left",Space,Str "Aligned"]]+ ,[Plain [Str "Right",Space,Str "Aligned"]]+ ,[Plain [Str "Default",Space,Str "aligned"]]]+ [[[Plain [Str "First"]]+ ,[Plain [Str "row"]]+ ,[Plain [Str "12.0"]]+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]]+ ,[[Plain [Str "Second"]]+ ,[Plain [Str "row"]]+ ,[Plain [Str "5.0"]]+ ,[Plain [Str "Here\8217s",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]+,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers:"]+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0]+ [[]+ ,[]+ ,[]+ ,[]]+ [[[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]+ ,[Plain [Str "12"]]]+ ,[[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]+ ,[Plain [Str "123"]]]+ ,[[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]+ ,[Plain [Str "1"]]]]+,Table [] [AlignRight,AlignLeft] [0.5,0.5]+ [[]+ ,[]]+ [[[Plain [Str "a"]]+ ,[Plain [Str "b"]]]+ ,[[Para [Str "one"]+ ,Para [Str "two"]]+ ,[CodeBlock ("",[],[]) "some\n code"]]]]
@@ -13,5 +13,5 @@ ,[Para [Str "Citation",Space,Str "with",Space,Str "a",Space,Str "suffix",Space,Str "and",Space,Str "locator",Space,Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [Space,Str "pp.\160\&33,",Space,Str "35-37,",Space,Str "and",Space,Str "nowhere",Space,Str "else"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@item1",Space,Str "pp.",Space,Str "33,",Space,Str "35-37,",Space,Str "and",Space,Str "nowhere",Space,Str "else]"],Str "."]] ,[Para [Str "Citation",Space,Str "with",Space,Str "suffix",Space,Str "only",Space,Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [Space,Str "and",Space,Str "nowhere",Space,Str "else"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@item1",Space,Str "and",Space,Str "nowhere",Space,Str "else]"],Str "."]] ,[Para [Str "Now",Space,Str "some",Space,Str "modifiers.",Note [Para [Str "Like",Space,Str "a",Space,Str "citation",Space,Str "without",Space,Str "author:",Space,Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [], citationMode = SuppressAuthor, citationNoteNum = 0, citationHash = 0}] [Str "[-@item1]"],Str ",",Space,Str "and",Space,Str "now",Space,Str "Doe",Space,Str "with",Space,Str "a",Space,Str "locator",Space,Cite [Citation {citationId = "item2", citationPrefix = [], citationSuffix = [Space,Str "p.\160\&44"], citationMode = SuppressAuthor, citationNoteNum = 0, citationHash = 0}] [Str "[-@item2",Space,Str "p.",Space,Str "44]"],Str "."]]]]- ,[Para [Str "With",Space,Str "some",Space,Str "markup",Space,Cite [Citation {citationId = "item1", citationPrefix = [Emph [Str "see"]], citationSuffix = [Space,Str "p.",Space,Strong [Str "32"]], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[*see*",Space,Str "@item1",Space,Str "p.",Space,Str "**32**]"],Str "."]]]+ ,[Para [Str "With",Space,Str "some",Space,Str "markup",Space,Cite [Citation {citationId = "item1", citationPrefix = [Emph [Str "see"]], citationSuffix = [Space,Str "p.\160",Strong [Str "32"]], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[*see*",Space,Str "@item1",Space,Str "p.",Space,Str "**32**]"],Str "."]]] ,Header 1 ("references",[],[]) [Str "References"]]
@@ -0,0 +1,3 @@+[Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "text,",Space,Str "written",Space,Str "as",Space,Str "a",Space,Str "raw",Space,Str "inline:",Space,RawInline (Format "openxml") "<a:r><a:rPr /><a:t>Here are examples of </a:t></a:r><a:r><a:rPr i=\"1\" /><a:t>italics</a:t></a:r><a:r><a:rPr /><a:t>, </a:t></a:r><a:r><a:rPr b=\"1\" /><a:t>bold</a:t></a:r>"]+,HorizontalRule+,RawBlock (Format "openxml") " <p:sp>\n <p:nvSpPr>\n <p:cNvPr id=\"3\" name=\"Content Placeholder 2\"/>\n <p:cNvSpPr>\n <a:spLocks noGrp=\"1\"/>\n </p:cNvSpPr>\n <p:nvPr>\n <p:ph idx=\"1\"/>\n </p:nvPr>\n </p:nvSpPr>\n <p:spPr/>\n <p:txBody>\n <a:bodyPr/>\n <a:lstStyle/>\n <a:p>\n <a:pPr lvl=\"1\"/>\n <a:r>\n <a:rPr/>\n <a:t>Bulleted bulleted lists.</a:t>\n </a:r>\n </a:p>\n <a:p>\n <a:pPr lvl=\"1\"/>\n <a:r>\n <a:rPr/>\n <a:t>And go to arbitrary depth.</a:t>\n </a:r>\n </a:p>\n <a:p>\n <a:pPr lvl=\"2\"/>\n <a:r>\n <a:rPr/>\n <a:t>Like this</a:t>\n </a:r>\n </a:p>\n <a:p>\n <a:pPr lvl=\"3\"/>\n <a:r>\n <a:rPr/>\n <a:t>Or this</a:t>\n </a:r>\n </a:p>\n <a:p>\n <a:pPr lvl=\"2\"/>\n <a:r>\n <a:rPr/>\n <a:t>Back to here.</a:t>\n </a:r>\n </a:p>\n </p:txBody>\n </p:sp>"]
binary file changed (absent → 26656 bytes)
binary file changed (absent → 393982 bytes)
@@ -1,5 +1,5 @@ [Para [Str "Simple",Space,Str "table",Space,Str "with",Space,Str "caption:"]-,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,8.75e-2,0.1125,0.125]+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]] ,[Plain [Str "Left"]] ,[Plain [Str "Center"]]@@ -17,7 +17,7 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]]]] ,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]-,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,8.75e-2,0.1125,0.125]+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]] ,[Plain [Str "Left"]] ,[Plain [Str "Center"]]@@ -35,7 +35,7 @@ ,[Plain [Str "1"]] ,[Plain [Str "1"]]]] ,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"]-,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.1,8.75e-2,0.1125,0.125]+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0] [[Plain [Str "Right"]] ,[Plain [Str "Left"]] ,[Plain [Str "Center"]]@@ -81,7 +81,7 @@ ,[Plain [Str "5.0"]] ,[Plain [Str "Here\8217s",Space,Str "another",Space,Str "one.",Space,Str "Note",SoftBreak,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",SoftBreak,Str "rows."]]]] ,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers:"]-,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [7.5e-2,7.5e-2,7.5e-2,7.5e-2]+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0] [[] ,[] ,[]
@@ -135,7 +135,7 @@ .PP Multiline table with caption: .PP-Here's the caption. It may span multiple lines.+Here\[cq]s the caption. It may span multiple lines. .TS tab(@); cw(10.5n) lw(9.6n) rw(11.4n) lw(24.5n).@@ -165,7 +165,7 @@ T}@T{ 5.0 T}@T{-Here's another one.+Here\[cq]s another one. Note the blank line between rows. T} .TE@@ -201,7 +201,7 @@ T}@T{ 5.0 T}@T{-Here's another one.+Here\[cq]s another one. Note the blank line between rows. T} .TE@@ -261,7 +261,7 @@ T}@T{ 5.0 T}@T{-Here's another one.+Here\[cq]s another one. Note the blank line between rows. T} .TE
@@ -135,7 +135,7 @@ .LP Multiline table with caption: .PP-Here’s the caption. It may span multiple lines.+Here\[cq]s the caption. It may span multiple lines. .TS delim(@@) tab( ); cw(10.5n) lw(9.6n) rw(11.4n) lw(24.5n).@@ -165,7 +165,7 @@ T} T{ 5.0 T} T{-Here’s another one.+Here\[cq]s another one. Note the blank line between rows. T} .TE@@ -201,7 +201,7 @@ T} T{ 5.0 T} T{-Here’s another one.+Here\[cq]s another one. Note the blank line between rows. T} .TE@@ -261,7 +261,7 @@ T} T{ 5.0 T} T{-Here’s another one.+Here\[cq]s another one. Note the blank line between rows. T} .TE
@@ -23,17 +23,24 @@ Multiline table with caption: - Centered Header || Left Aligned || Right Aligned || Default aligned- First | row | 12.0 | Example of a row that spans multiple lines.- Second | row | 5.0 | Here’s another one. Note the blank line between rows.- |+ Here’s the caption. It may span multiple lines. +|-++----------+---------+-----------+--------------------------++| 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. |++----------+---------+-----------+--------------------------+ 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.-++----------+---------+-----------+--------------------------++| First | row | 12.0 | Example of a row that |+| | | | spans multiple lines. |++----------+---------+-----------+--------------------------++| Second | row | 5.0 | Here’s another one. Note |+| | | | the blank line between |+| | | | rows. |++----------+---------+-----------+--------------------------+ Table without column headers: 12 | 12 | 12 | 12@@ -42,5 +49,11 @@ 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.++----------+---------+-----------+--------------------------++| 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. |++----------+---------+-----------+--------------------------+
@@ -63,7 +63,8 @@ </table:table-cell> </table:table-row> </table:table>-<text:p text:style-name="Table">Demonstration of simple table syntax.</text:p>+<text:p text:style-name="Table">Table <text:sequence text:ref-name="refTable0" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">1</text:sequence>: 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">@@ -196,7 +197,8 @@ </table:table-cell> </table:table-row> </table:table>-<text:p text:style-name="Table">Demonstration of simple table syntax.</text:p>+<text:p text:style-name="Table">Table <text:sequence text:ref-name="refTable1" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">2</text:sequence>: Demonstration+of simple table syntax.</text:p> <text:p text:style-name="First_20_paragraph">Multiline table with caption:</text:p> <table:table table:name="Table4" table:style-name="Table4">@@ -251,8 +253,8 @@ </table:table-cell> </table:table-row> </table:table>-<text:p text:style-name="Table">Here’s the caption. It may span multiple-lines.</text:p>+<text:p text:style-name="Table">Table <text:sequence text:ref-name="refTable2" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">3</text:sequence>: 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">
@@ -2,41 +2,35 @@ .. table:: Demonstration of simple table syntax. - +-------+------+--------+---------+- | Right | Left | Center | Default |- +=======+======+========+=========+- | 12 | 12 | 12 | 12 |- +-------+------+--------+---------+- | 123 | 123 | 123 | 123 |- +-------+------+--------+---------+- | 1 | 1 | 1 | 1 |- +-------+------+--------+---------++ ===== ==== ====== =======+ Right Left Center Default+ ===== ==== ====== =======+ 12 12 12 12+ 123 123 123 123+ 1 1 1 1+ ===== ==== ====== ======= Simple table without caption: -+-------+------+--------+---------+-| Right | Left | Center | Default |-+=======+======+========+=========+-| 12 | 12 | 12 | 12 |-+-------+------+--------+---------+-| 123 | 123 | 123 | 123 |-+-------+------+--------+---------+-| 1 | 1 | 1 | 1 |-+-------+------+--------+---------++===== ==== ====== =======+Right Left Center Default+===== ==== ====== =======+12 12 12 12+123 123 123 123+1 1 1 1+===== ==== ====== ======= Simple table indented two spaces: .. table:: Demonstration of simple table syntax. - +-------+------+--------+---------+- | Right | Left | Center | Default |- +=======+======+========+=========+- | 12 | 12 | 12 | 12 |- +-------+------+--------+---------+- | 123 | 123 | 123 | 123 |- +-------+------+--------+---------+- | 1 | 1 | 1 | 1 |- +-------+------+--------+---------++ ===== ==== ====== =======+ Right Left Center Default+ ===== ==== ====== =======+ 12 12 12 12+ 123 123 123 123+ 1 1 1 1+ ===== ==== ====== ======= Multiline table with caption: @@ -70,13 +64,11 @@ Table without column headers: -+-----+-----+-----+-----+-| 12 | 12 | 12 | 12 |-+-----+-----+-----+-----+-| 123 | 123 | 123 | 123 |-+-----+-----+-----+-----+-| 1 | 1 | 1 | 1 |-+-----+-----+-----+-----++=== === === ===+12 12 12 12+123 123 123 123+1 1 1 1+=== === === === Multiline table without column headers:
@@ -22,6 +22,7 @@ import qualified Tests.Readers.Org import qualified Tests.Readers.RST import qualified Tests.Readers.Txt2Tags+import qualified Tests.Readers.Man import qualified Tests.Shared import qualified Tests.Writers.AsciiDoc import qualified Tests.Writers.ConTeXt@@ -76,6 +77,7 @@ , testGroup "EPUB" Tests.Readers.EPUB.tests , testGroup "Muse" Tests.Readers.Muse.tests , testGroup "Creole" Tests.Readers.Creole.tests+ , testGroup "Man" Tests.Readers.Man.tests , testGroup "FB2" Tests.Readers.FB2.tests ] , testGroup "Lua filters" Tests.Lua.tests
@@ -49,6 +49,8 @@ ,CodeBlock ("",[],[]) " Tyger! Tyger! burning bright\n In the forests of the night,\n What immortal hand or eye\n Could frame thy fearful symmetry?\n In what distant deeps or skies\n Burnt the fire of thine eyes?\n On what wings dare he aspire?\n What the hand dare sieze the fire?" ,Header 3 ("preformatted text with attributes",[],[]) [Str "preformatted",Space,Str "text",Space,Str "with",Space,Str "attributes"] ,CodeBlock ("",[],[("class","python"),("style","color:blue")]) " for i in range(1, 5):\n print(i)"+,Header 3 ("empty preformatted text",[],[]) [Str "empty",Space,Str "preformatted",Space,Str "text"]+,CodeBlock ("",[],[]) "" ,Header 2 ("block quotes",[],[]) [Str "block",Space,Str "quotes"] ,BlockQuote [Plain [Str "(indentation",Space,Str "4",Space,Str "spaces)",Space,Str "This",Space,Str "would",Space,Str "be",Space,Str "a",Space,Str "blockquote",Space,Str "in",Space,Str "Vimwiki.",Space,Str "It",Space,Str "is",Space,Str "not",Space,Span ("highlighted",[],[]) [],Strong [Str "highlighted"],Space,Str "in",Space,Str "Vim",Space,Str "but",SoftBreak,Str "(indentation",Space,Str "1",Space,Str "space",Space,Str "followed",Space,Str "by",Space,Str "1",Space,Str "tab",Space,Str "of",Space,Str "width",Space,Str "4)",Space,Str "could",Space,Str "be",Space,Str "styled",Space,Str "by",Space,Str "CSS",Space,Str "in",Space,Str "HTML.",Space,Str "Blockquotes",Space,Str "are",Space,Str "usually",Space,Str "used",Space,Str "to",Space,Str "quote",Space,Str "a",SoftBreak,Str "(indentation",Space,Str "1",Space,Str "tab",Space,Str "of",Space,Str "width",Space,Str "4)",Space,Str "long",Space,Str "piece",Space,Str "of",Space,Str "text",Space,Str "from",Space,Str "another",Space,Str "source.",Space,Strikeout [Str "blah",Space,Str "blah"],Space,Span ("-blockquote",[],[]) [Str ""],Span ("blockquote",["tag"],[]) [Str "blockquote"]]]
@@ -116,7 +116,12 @@ for i in range(1, 5): print(i) }}}- ++=== empty preformatted text ===++{{{+}}}+ == block quotes == (indentation 4 spaces) This would be a blockquote in Vimwiki. It is not *highlighted* in Vim but
@@ -1,5 +1,4 @@-Pandoc Test Suite-=================+= Pandoc Test Suite John MacFarlane; Anonymous July 17, 2006 @@ -8,40 +7,31 @@ ''''' -Headers--------+== Headers -Level 2 with an link:/url[embedded link]-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+=== Level 2 with an link:/url[embedded link] -Level 3 with _emphasis_-^^^^^^^^^^^^^^^^^^^^^^^+==== Level 3 with _emphasis_ -Level 4-++++++++===== Level 4 -Level 5+====== Level 5 -Level 1--------+== Level 1 -Level 2 with _emphasis_-~~~~~~~~~~~~~~~~~~~~~~~+=== Level 2 with _emphasis_ -Level 3-^^^^^^^+==== Level 3 with no blank line -Level 2-~~~~~~~+=== Level 2 with no blank line ''''' -Paragraphs-----------+== Paragraphs Here’s a regular paragraph. @@ -56,8 +46,7 @@ ''''' -Block Quotes-------------+== Block Quotes E-mail style: @@ -99,8 +88,7 @@ ''''' -Code Blocks------------+== Code Blocks Code: @@ -124,11 +112,9 @@ ''''' -Lists------+== Lists -Unordered-~~~~~~~~~+=== Unordered Asterisks tight: @@ -166,8 +152,7 @@ * Minus 2 * Minus 3 -Ordered-~~~~~~~+=== Ordered Tight: @@ -201,8 +186,7 @@ 2. Item 2. 3. Item 3. -Nested-~~~~~~+=== Nested * Tab ** Tab@@ -226,16 +210,14 @@ * Foe 3. Third -Tabs and spaces-~~~~~~~~~~~~~~~+=== Tabs and spaces * this is a list item indented with tabs * this is a list item indented with spaces ** this is an example list item indented with tabs ** this is an example list item indented with spaces -Fancy list markers-~~~~~~~~~~~~~~~~~~+=== Fancy list markers 1. begins with 2 2. and now 3@@ -267,8 +249,7 @@ ''''' -Definition Lists-----------------+== Definition Lists Tight using spaces: @@ -348,8 +329,7 @@ 1. sublist 2. sublist -HTML Blocks------------+== HTML Blocks Simple block on one line: @@ -411,8 +391,7 @@ ''''' -Inline Markup--------------+== Inline Markup This is _emphasized_, and so _is this_. @@ -441,8 +420,7 @@ ''''' -Smart quotes, ellipses, dashes-------------------------------+== Smart quotes, ellipses, dashes ``Hello,'' said the spider. ```Shelob' is my name.'' @@ -463,8 +441,7 @@ ''''' -LaTeX------+== LaTeX * * latexmath:[$2+2=4$]@@ -489,8 +466,7 @@ ''''' -Special Characters-------------------+== Special Characters Here is some unicode: @@ -544,11 +520,9 @@ ''''' -Links------+== Links -Explicit-~~~~~~~~+=== Explicit Just a link:/url/[URL]. @@ -568,8 +542,7 @@ link:[Empty]. -Reference-~~~~~~~~~+=== Reference Foo link:/url/[bar]. @@ -593,8 +566,7 @@ Foo link:/url/[biz]. -With ampersands-~~~~~~~~~~~~~~~+=== With ampersands Here’s a http://example.com/?foo=1&bar=2[link with an ampersand in the URL]. @@ -604,8 +576,7 @@ Here’s an link:/script?foo=1&bar=2[inline link in pointy braces]. -Autolinks-~~~~~~~~~+=== Autolinks With an ampersand: http://example.com/?foo=1&bar=2 @@ -627,8 +598,7 @@ ''''' -Images-------+== Images From ``Voyage dans la Lune'' by Georges Melies (1902): @@ -638,8 +608,7 @@ ''''' -Footnotes----------+== Footnotes Here is a footnote reference,footnote:[Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the
@@ -2,16 +2,16 @@ .hy .PP This is a set of tests for pandoc.-Most of them are adapted from John Gruber's markdown test suite.+Most of them are adapted from John Gruber\[cq]s markdown test suite. .PP * * * * * .SH Headers .SS Level 2 with an embedded link (/url)-.SS Level 3 with \f[I]emphasis\f[]+.SS Level 3 with \f[I]emphasis\f[R] .SS Level 4 .SS Level 5 .SH Level 1-.SS Level 2 with \f[I]emphasis\f[]+.SS Level 2 with \f[I]emphasis\f[R] .SS Level 3 .PP with no blank line@@ -22,7 +22,7 @@ * * * * * .SH Paragraphs .PP-Here's a regular paragraph.+Here\[cq]s a regular paragraph. .PP In Markdown 1.0.0 and earlier. Version 8.@@ -30,7 +30,7 @@ Because a hard\-wrapped line in the middle of a paragraph looked like a list item. .PP-Here's one with a bullet.+Here\[cq]s one with a bullet. * criminey. .PP There should be a hard line break@@ -54,10 +54,10 @@ .IP .nf \f[C]-sub\ status\ {-\ \ \ \ print\ "working";+sub status {+ print \[dq]working\[dq]; }-\f[]+\f[R] .fi .PP A list:@@ -88,24 +88,24 @@ .IP .nf \f[C]-\-\-\-\-\ (should\ be\ four\ hyphens)+\-\-\-\- (should be four hyphens) -sub\ status\ {-\ \ \ \ print\ "working";+sub status {+ print \[dq]working\[dq]; } -this\ code\ block\ is\ indented\ by\ one\ tab-\f[]+this code block is indented by one tab+\f[R] .fi .PP And: .IP .nf \f[C]-\ \ \ \ this\ code\ block\ is\ indented\ by\ two\ tabs+ this code block is indented by two tabs -These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{-\f[]+These should not be escaped: \[rs]$ \[rs]\[rs] \[rs]> \[rs][ \[rs]{+\f[R] .fi .PP * * * * *@@ -200,7 +200,7 @@ .PP Item 1. graf two.-The quick brown fox jumped over the lazy dog's back.+The quick brown fox jumped over the lazy dog\[cq]s back. .RE .IP "2." 3 Item 2.@@ -218,7 +218,7 @@ .RE .RE .PP-Here's another:+Here\[cq]s another: .IP "1." 3 First .IP "2." 3@@ -320,70 +320,52 @@ .TP .B apple red fruit-.RS-.RE .TP .B orange orange fruit-.RS-.RE .TP .B banana yellow fruit-.RS-.RE .PP Tight using tabs: .TP .B apple red fruit-.RS-.RE .TP .B orange orange fruit-.RS-.RE .TP .B banana yellow fruit-.RS-.RE .PP Loose: .TP .B apple red fruit-.RS-.RE .TP .B orange orange fruit-.RS-.RE .TP .B banana yellow fruit-.RS-.RE .PP Multiple blocks with italics: .TP-.B \f[I]apple\f[]+.B \f[I]apple\f[R] red fruit .RS .PP contains seeds, crisp, pleasant to taste .RE .TP-.B \f[I]orange\f[]+.B \f[I]orange\f[R] orange fruit .RS .IP .nf \f[C]-{\ orange\ code\ block\ }-\f[]+{ orange code block }+\f[R] .fi .RS .PP@@ -395,47 +377,27 @@ .TP .B apple red fruit-.RS-.RE computer-.RS-.RE .TP .B orange orange fruit-.RS-.RE bank-.RS-.RE .PP Multiple definitions, loose: .TP .B apple red fruit-.RS-.RE computer-.RS-.RE .TP .B orange orange fruit-.RS-.RE bank-.RS-.RE .PP Blank line after term, indented marker, alternate markers: .TP .B apple red fruit-.RS-.RE computer-.RS-.RE .TP .B orange orange fruit@@ -456,10 +418,10 @@ bar .PP Interpreted markdown in a table:-This is \f[I]emphasized\f[]-And this is \f[B]strong\f[]+This is \f[I]emphasized\f[R]+And this is \f[B]strong\f[R] .PP-Here's a simple block:+Here\[cq]s a simple block: .PP foo .PP@@ -468,9 +430,9 @@ .nf \f[C] <div>-\ \ \ \ foo+ foo </div>-\f[]+\f[R] .fi .PP As should this:@@ -478,7 +440,7 @@ .nf \f[C] <div>foo</div>-\f[]+\f[R] .fi .PP Now, nested:@@ -492,8 +454,8 @@ .IP .nf \f[C]-<!\-\-\ Comment\ \-\->-\f[]+<!\-\- Comment \-\->+\f[R] .fi .PP Just plain comment, with trailing spaces on the line:@@ -502,40 +464,40 @@ .IP .nf \f[C]-<hr\ />-\f[]+<hr />+\f[R] .fi .PP-Hr's:+Hr\[cq]s: .PP * * * * * .SH Inline Markup .PP-This is \f[I]emphasized\f[], and so \f[I]is this\f[].+This is \f[I]emphasized\f[R], and so \f[I]is this\f[R]. .PP-This is \f[B]strong\f[], and so \f[B]is this\f[].+This is \f[B]strong\f[R], and so \f[B]is this\f[R]. .PP-An \f[I]emphasized link (/url)\f[].+An \f[I]emphasized link (/url)\f[R]. .PP-\f[B]\f[BI]This is strong and em.\f[B]\f[]+\f[B]\f[BI]This is strong and em.\f[B]\f[R] .PP-So is \f[B]\f[BI]this\f[B]\f[] word.+So is \f[B]\f[BI]this\f[B]\f[R] word. .PP-\f[B]\f[BI]This is strong and em.\f[B]\f[]+\f[B]\f[BI]This is strong and em.\f[B]\f[R] .PP-So is \f[B]\f[BI]this\f[B]\f[] word.+So is \f[B]\f[BI]this\f[B]\f[R] word. .PP-This is code: \f[C]>\f[], \f[C]$\f[], \f[C]\\\f[], \f[C]\\$\f[],-\f[C]<html>\f[].+This is code: \f[C]>\f[R], \f[C]$\f[R], \f[C]\[rs]\f[R], \f[C]\[rs]$\f[R],+\f[C]<html>\f[R]. .PP-[STRIKEOUT:This is \f[I]strikeout\f[].]+[STRIKEOUT:This is \f[I]strikeout\f[R].] .PP-Superscripts: a^bc^d a^\f[I]hello\f[]^ a^hello\ there^.+Superscripts: a^bc^d a^\f[I]hello\f[R]^ a^hello\ there^. .PP Subscripts: H~2~O, H~23~O, H~many\ of\ them~O. .PP These should not be superscripts or subscripts, because of the unescaped-spaces: a^b c^d, a~b c~d.+spaces: a\[ha]b c\[ha]d, a\[ti]b c\[ti]d. .PP * * * * * .SH Smart quotes, ellipses, dashes@@ -548,9 +510,9 @@ `Oak,' `elm,' and `beech' are names of trees. So is `pine.' .PP-`He said, \[lq]I want to go.\[rq]' Were you alive in the 70's?+`He said, \[lq]I want to go.\[rq]' Were you alive in the 70\[cq]s? .PP-Here is some quoted `\f[C]code\f[]' and a \[lq]quoted+Here is some quoted `\f[C]code\f[R]' and a \[lq]quoted link (http://example.com/?foo=1&bar=2)\[rq]. .PP Some dashes: one\[em]two \[em] three\[em]four \[em] five.@@ -563,52 +525,52 @@ .SH LaTeX .IP \[bu] 2 .IP \[bu] 2-2 + 2 = 4+2\[u2005]+\[u2005]2\[u2004]=\[u2004]4 .IP \[bu] 2-\f[I]x\f[] ∈ \f[I]y\f[]+\f[I]x\f[R]\[u2004]\[mo]\[u2004]\f[I]y\f[R] .IP \[bu] 2-\f[I]α\f[] ∧ \f[I]ω\f[]+\f[I]\[*a]\f[R]\[u2005]\[AN]\[u2005]\f[I]\[*w]\f[R] .IP \[bu] 2 223 .IP \[bu] 2-\f[I]p\f[]\-Tree+\f[I]p\f[R]\-Tree .IP \[bu] 2-Here's some display math:+Here\[cq]s some display math: .RS-$$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)\-f(x)}{h}$$+$$\[rs]frac{d}{dx}f(x)=\[rs]lim_{h\[rs]to 0}\[rs]frac{f(x+h)\-f(x)}{h}$$ .RE .IP \[bu] 2-Here's one that has a line break in it:-\f[I]α\f[] + \f[I]ω\f[] × \f[I]x\f[]^2^.+Here\[cq]s one that has a line break in it:+\f[I]\[*a]\f[R]\[u2005]+\[u2005]\f[I]\[*w]\f[R]\[u2005]\[tmu]\[u2005]\f[I]x\f[R]^2^. .PP-These shouldn't be math:+These shouldn\[cq]t be math: .IP \[bu] 2-To get the famous equation, write \f[C]$e\ =\ mc^2$\f[].+To get the famous equation, write \f[C]$e = mc\[ha]2$\f[R]. .IP \[bu] 2-$22,000 is a \f[I]lot\f[] of money.+$22,000 is a \f[I]lot\f[R] of money. So is $34,000. (It worked if \[lq]lot\[rq] is emphasized.) .IP \[bu] 2 Shoes ($20) and socks ($5). .IP \[bu] 2-Escaped \f[C]$\f[]: $73 \f[I]this should be emphasized\f[] 23$.+Escaped \f[C]$\f[R]: $73 \f[I]this should be emphasized\f[R] 23$. .PP-Here's a LaTeX table:+Here\[cq]s a LaTeX table: .PP * * * * * .SH Special Characters .PP Here is some unicode: .IP \[bu] 2-I hat: Î+I hat: \[^I] .IP \[bu] 2-o umlaut: ö+o umlaut: \[:o] .IP \[bu] 2-section: §+section: \[sc] .IP \[bu] 2-set membership: ∈+set membership: \[mo] .IP \[bu] 2-copyright: ©+copyright: \[co] .PP AT&T has an ampersand in their name. .PP@@ -620,9 +582,9 @@ .PP 6 > 5. .PP-Backslash: \\+Backslash: \[rs] .PP-Backtick: `+Backtick: \[ga] .PP Asterisk: * .PP@@ -691,8 +653,8 @@ .IP .nf \f[C]-[not]:\ /url-\f[]+[not]: /url+\f[R] .fi .PP Foo bar (/url/).@@ -700,13 +662,14 @@ Foo biz (/url/). .SS With ampersands .PP-Here's a link with an ampersand in the URL (http://example.com/?foo=1&bar=2).+Here\[cq]s a link with an ampersand in the+URL (http://example.com/?foo=1&bar=2). .PP-Here's a link with an amersand in the link text: AT&T (http://att.com/).+Here\[cq]s a link with an amersand in the link text: AT&T (http://att.com/). .PP-Here's an inline link (/script?foo=1&bar=2).+Here\[cq]s an inline link (/script?foo=1&bar=2). .PP-Here's an inline link in pointy braces (/script?foo=1&bar=2).+Here\[cq]s an inline link in pointy braces (/script?foo=1&bar=2). .SS Autolinks .PP With an ampersand: <http://example.com/?foo=1&bar=2>@@ -723,12 +686,12 @@ Blockquoted: <http://example.com/> .RE .PP-Auto\-links should not occur here: \f[C]<http://example.com/>\f[]+Auto\-links should not occur here: \f[C]<http://example.com/>\f[R] .IP .nf \f[C]-or\ here:\ <http://example.com/>-\f[]+or here: <http://example.com/>+\f[R] .fi .PP * * * * *@@ -743,9 +706,9 @@ * * * * * .SH Footnotes .PP-Here is a footnote reference,[1] and another.[2] This should \f[I]not\f[] be a-footnote reference, because it contains a space.[^my note] Here is an inline-note.[3]+Here is a footnote reference,[1] and another.[2] This should \f[I]not\f[R] be+a footnote reference, because it contains a space.[\[ha]my note] Here is an+inline note.[3] .RS .PP Notes can go in quotes.[4]@@ -762,7 +725,7 @@ It need not be placed at the end of the document. .SS [2] .PP-Here's the long note.+Here\[cq]s the long note. This one contains multiple blocks. .PP Subsequent blocks are indented to show that they belong to the footnote (as@@ -770,16 +733,16 @@ .IP .nf \f[C]-\ \ {\ <code>\ }-\f[]+ { <code> }+\f[R] .fi .PP If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. .SS [3] .PP-This is \f[I]easier\f[] to type.-Inline notes may contain links (http://google.com) and \f[C]]\f[] verbatim+This is \f[I]easier\f[R] to type.+Inline notes may contain links (http://google.com) and \f[C]]\f[R] verbatim characters, as well as [bracketed text]. .SS [4] .PP
@@ -409,6 +409,7 @@ </tr> </table> <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>+ Here's a simple block: <div>@@ -446,6 +447,7 @@ This should just be an HTML comment: <!-- Comment -->+ Multiline: <!--@@ -455,6 +457,7 @@ <!-- This is another comment. -->+ Code block: <!-- Comment -->@@ -462,6 +465,7 @@ Just plain comment, with trailing spaces on the line: <!-- foo -->+ Code: <hr />
@@ -75,7 +75,7 @@ .1C .LP This is a set of tests for pandoc.-Most of them are adapted from John Gruber’s markdown test suite.+Most of them are adapted from John Gruber\[cq]s markdown test suite. .HLINE .SH 1 Headers@@ -126,15 +126,15 @@ .pdfhref O 1 "Paragraphs" .pdfhref M "paragraphs" .LP-Here’s a regular paragraph.+Here\[cq]s a regular paragraph. .PP 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+Because a hard\-wrapped line in the middle of a paragraph looked like a list item. .PP-Here’s one with a bullet.+Here\[cq]s one with a bullet. * criminey. .PP There should be a hard line break@@ -146,7 +146,7 @@ .pdfhref O 1 "Block Quotes" .pdfhref M "block-quotes" .LP-E-mail style:+E\-mail style: .RS .LP This is a block quote.@@ -158,8 +158,8 @@ .IP .nf \f[C]-sub\ status\ {-\ \ \ \ print\ \[dq]working\[dq];+sub status {+ print \[dq]working\[dq]; } \f[] .fi@@ -194,13 +194,13 @@ .IP .nf \f[C]-----\ (should\ be\ four\ hyphens)+\-\-\-\- (should be four hyphens) -sub\ status\ {-\ \ \ \ print\ \[dq]working\[dq];+sub status {+ print \[dq]working\[dq]; } -this\ code\ block\ is\ indented\ by\ one\ tab+this code block is indented by one tab \f[] .fi .LP@@ -208,9 +208,9 @@ .IP .nf \f[C]-\ \ \ \ this\ code\ block\ is\ indented\ by\ two\ tabs+ this code block is indented by two tabs -These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{+These should not be escaped: \[rs]$ \[rs]\[rs] \[rs]> \[rs][ \[rs]{ \f[] .fi .HLINE@@ -314,7 +314,7 @@ .PP Item 1. graf two.-The quick brown fox jumped over the lazy dog’s back.+The quick brown fox jumped over the lazy dog\[cq]s back. .RE .IP " 2." 4 Item 2.@@ -335,7 +335,7 @@ .RE .RE .LP-Here’s another:+Here\[cq]s another: .IP " 1." 4 First .IP " 2." 4@@ -431,7 +431,7 @@ .LP Should not be a list item: .PP-M.A.\~2007+M.A.\ 2007 .PP B. Williams@@ -496,7 +496,7 @@ .IP .nf \f[C]-{\ orange\ code\ block\ }+{ orange code block } \f[] .fi .RS@@ -570,7 +570,7 @@ This is \f[I]emphasized\f[R] And this is \f[B]strong\f[R] .PP-Here’s a simple block:+Here\[cq]s a simple block: .LP foo .LP@@ -579,7 +579,7 @@ .nf \f[C] <div>-\ \ \ \ foo+ foo </div> \f[] .fi@@ -603,7 +603,7 @@ .IP .nf \f[C]-<!--\ Comment\ -->+<!\-\- Comment \-\-> \f[] .fi .LP@@ -613,11 +613,11 @@ .IP .nf \f[C]-<hr\ />+<hr /> \f[] .fi .LP-Hr’s:+Hr\[cq]s: .HLINE .SH 1 Inline Markup@@ -641,14 +641,14 @@ .PP So is \f[B]\f[BI]this\f[B]\f[R] word. .PP-This is code: \f[C]>\f[R], \f[C]$\f[R], \f[C]\\\f[R], \f[C]\\$\f[R],+This is code: \f[C]>\f[R], \f[C]$\f[R], \f[C]\[rs]\f[R], \f[C]\[rs]$\f[R], \f[C]<html>\f[R]. .PP \m[strikecolor]This is \f[I]strikeout\f[R].\m[] .PP-Superscripts: a\*{bc\*}d a\*{\f[I]hello\f[R]\*} a\*{hello\~there\*}.+Superscripts: a\*{bc\*}d a\*{\f[I]hello\f[R]\*} a\*{hello\ there\*}. .PP-Subscripts: H\*<2\*>O, H\*<23\*>O, H\*<many\~of\~them\*>O.+Subscripts: H\*<2\*>O, H\*<23\*>O, H\*<many\ of\ them\*>O. .PP These should not be superscripts or subscripts, because of the unescaped spaces: a\[ha]b c\[ha]d, a\[ti]b c\[ti]d.@@ -666,7 +666,7 @@ `Oak,' `elm,' and `beech' are names of trees. So is `pine.' .PP-`He said, \[lq]I want to go.\[rq]' Were you alive in the 70’s?+`He said, \[lq]I want to go.\[rq]' Were you alive in the 70\[cq]s? .PP Here is some quoted `\f[C]code\f[R]' and a \[lq]\c .pdfhref W -D "http://example.com/?foo=1&bar=2" -A "\c" \@@ -693,18 +693,18 @@ .IP \[bu] 3 @223@ .IP \[bu] 3-@p@-Tree+@p@\-Tree .IP \[bu] 3-Here’s some display math:+Here\[cq]s some display math: .EQ d over {d x} f ( x ) = lim sub {h -> 0} {f ( x + h ) \[u2212] f ( x )} over h .EN .IP \[bu] 3-Here’s one that has a line break in it: @alpha + omega times x sup 2@.+Here\[cq]s one that has a line break in it: @alpha + omega times x sup 2@. .LP-These shouldn’t be math:+These shouldn\[cq]t be math: .IP \[bu] 3-To get the famous equation, write \f[C]$e\ =\ mc\[ha]2$\f[R].+To get the famous equation, write \f[C]$e = mc\[ha]2$\f[R]. .IP \[bu] 3 $22,000 is a \f[I]lot\f[R] of money. So is $34,000.@@ -714,7 +714,7 @@ .IP \[bu] 3 Escaped \f[C]$\f[R]: $73 \f[I]this should be emphasized\f[R] 23$. .LP-Here’s a LaTeX table:+Here\[cq]s a LaTeX table: .HLINE .SH 1 Special Characters@@ -743,9 +743,9 @@ .PP 6 > 5. .PP-Backslash: \\+Backslash: \[rs] .PP-Backtick: \`+Backtick: \[ga] .PP Asterisk: * .PP@@ -763,7 +763,7 @@ .PP Right paren: ) .PP-Greater-than: >+Greater\-than: > .PP Hash: # .PP@@ -773,7 +773,7 @@ .PP Plus: + .PP-Minus: -+Minus: \- .HLINE .SH 1 Links@@ -867,7 +867,7 @@ .IP .nf \f[C]-[not]:\ /url+[not]: /url \f[] .fi .LP@@ -885,22 +885,22 @@ .pdfhref O 2 "With ampersands" .pdfhref M "with-ampersands" .LP-Here’s a \c+Here\[cq]s a \c .pdfhref W -D "http://example.com/?foo=1&bar=2" -A "\c" \ -- "link with an ampersand in the URL" \&. .PP-Here’s a link with an amersand in the link text: \c+Here\[cq]s a link with an amersand in the link text: \c .pdfhref W -D "http://att.com/" -A "\c" \ -- "AT&T" \&. .PP-Here’s an \c+Here\[cq]s an \c .pdfhref W -D "/script?foo=1&bar=2" -A "\c" \ -- "inline link" \&. .PP-Here’s an \c+Here\[cq]s an \c .pdfhref W -D "/script?foo=1&bar=2" -A "\c" \ -- "inline link in pointy braces" \&.@@ -923,9 +923,9 @@ .IP \[bu] 3 It should. .LP-An e-mail address: \c+An e\-mail address: \c .pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \- -- "nobody\@nowhere.net"+ -- "nobody\[at]nowhere.net" \& .RS .LP@@ -935,11 +935,11 @@ \& .RE .LP-Auto-links should not occur here: \f[C]<http://example.com/>\f[R]+Auto\-links should not occur here: \f[C]<http://example.com/>\f[R] .IP .nf \f[C]-or\ here:\ <http://example.com/>+or here: <http://example.com/> \f[] .fi .HLINE@@ -967,7 +967,7 @@ .FE and another.\** .FS-Here’s the long note.+Here\[cq]s the long note. This one contains multiple blocks. .PP Subsequent blocks are indented to show that they belong to the footnote (as@@ -975,7 +975,7 @@ .IP .nf \f[C]-\ \ {\ <code>\ }+ { <code> } \f[] .fi .LP
@@ -6,629 +6,1007 @@ <office:automatic-styles> <text:list-style style:name="L1"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L2"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L3"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L4"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L5"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L6"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L7"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L8"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L9"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L10"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L11"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L12"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L13"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L14"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L15"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L16"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L17"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L18"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L19"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L20"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L21"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L22"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="2" style:num-prefix="(" style:num-suffix=")">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-format="i" text:start-value="4" style:num-suffix=".">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-format="A" text:start-value="1" style:num-prefix="(" style:num-suffix=")">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L23"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="A" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-format="I" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="6" style:num-prefix="(" style:num-suffix=")">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="4" text:style-name="Numbering_20_Symbols" style:num-format="a" text:start-value="3" style:num-suffix=")">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L24"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L25"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </text:list-style> <text:list-style style:name="L26"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L27"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L28"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L29"> <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="0.4in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.0in" fo:text-indent="-0.1in" fo:margin-left="1.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="0.8in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.5in" fo:text-indent="-0.1in" fo:margin-left="1.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="1.2000000000000002in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.0in" fo:text-indent="-0.1in" fo:margin-left="2.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="1.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.5in" fo:text-indent="-0.1in" fo:margin-left="2.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="2.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.0in" fo:text-indent="-0.1in" fo:margin-left="3.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="2.4000000000000004in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5in" fo:text-indent="-0.1in" fo:margin-left="3.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">- <style:list-level-properties text:space-before="2.8000000000000003in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.0in" fo:text-indent="-0.1in" fo:margin-left="4.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">- <style:list-level-properties text:space-before="3.2in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5in" fo:text-indent="-0.1in" fo:margin-left="4.5in" />+ </style:list-level-properties> </text:list-level-style-bullet> <text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">- <style:list-level-properties text:space-before="3.6in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.0in" fo:text-indent="-0.1in" fo:margin-left="5.0in" />+ </style:list-level-properties> </text:list-level-style-bullet> </text:list-style> <text:list-style style:name="L30"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">- <style:list-level-properties text:space-before="0.0in" text:min-label-width="0.4in" />+ <style:list-level-properties text:list-level-position-and-space-mode="label-alignment" fo:text-align="right">+ <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.5in" fo:text-indent="-0.1in" fo:margin-left="0.5in" />+ </style:list-level-properties> </text:list-level-style-number> </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>@@ -1502,7 +1880,7 @@ <text:p text:style-name="First_20_paragraph">From “Voyage dans la Lune” by Georges Melies (1902):</text:p> <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">lalune</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>: lalune</text:p> <text:p text:style-name="Text_20_body">Here is a movie <draw:frame draw:name="img2"><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame> icon.</text:p>
@@ -61,8 +61,8 @@ > > A list: > -> 1. item one-> 1. item two+> 1. item one+> 2. item two > > Nested block quotes: > @@ -108,126 +108,126 @@ Asterisks tight: - * asterisk 1- * asterisk 2- * asterisk 3+* asterisk 1+* asterisk 2+* asterisk 3 Asterisks loose: - * asterisk 1- * asterisk 2- * asterisk 3+* asterisk 1+* asterisk 2+* asterisk 3 Pluses tight: - * Plus 1- * Plus 2- * Plus 3+* Plus 1+* Plus 2+* Plus 3 Pluses loose: - * Plus 1- * Plus 2- * Plus 3+* Plus 1+* Plus 2+* Plus 3 Minuses tight: - * Minus 1- * Minus 2- * Minus 3+* Minus 1+* Minus 2+* Minus 3 Minuses loose: - * Minus 1- * Minus 2- * Minus 3+* Minus 1+* Minus 2+* Minus 3 ===== Ordered ===== Tight: - 1. First- 1. Second- 1. Third+1. First+2. Second+3. Third and: - 1. One- 1. Two- 1. Three+1. One+2. Two+3. Three Loose using tabs: - 1. First- 1. Second- 1. Third+1. First+2. Second+3. Third and using spaces: - 1. One- 1. Two- 1. Three+1. One+2. Two+3. Three Multiple paragraphs: - 1. Item 1, graf one.+1. Item 1, graf one. Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.- 1. Item 2.- 1. Item 3.+2. Item 2.+3. Item 3. ===== Nested ===== +* Tab * Tab * Tab- * Tab Here’s another: - 1. First- 1. Second:- * Fee- * Fie- * Foe- 1. Third+1. First+2. Second:+ * Fee+ * Fie+ * Foe+3. Third Same thing but with paragraphs: - 1. First- 1. Second:- * Fee- * Fie- * Foe- 1. Third+1. First+2. Second:+ * Fee+ * Fie+ * Foe+3. Third ===== Tabs and spaces ===== - * this is a list item indented with tabs- * this is a list item indented with spaces- * this is an example list item indented with tabs- * this is an example list item indented with spaces+* this is a list item indented with tabs+* this is a list item indented with spaces+ * this is an example list item indented with tabs+ * this is an example list item indented with spaces ===== Fancy list markers ===== - 1. begins with 2- 1. and now 3+1. begins with 2+2. and now 3 with a continuation- 1. sublist with roman numerals, starting with 4- 1. more items- 1. a subsublist- 1. a subsublist+ 1. sublist with roman numerals, starting with 4+ 2. more items+ 1. a subsublist+ 2. a subsublist Nesting: - 1. Upper Alpha- 1. Upper Roman.- 1. Decimal start with 6- 1. Lower alpha with paren+1. Upper Alpha+ 1. Upper Roman.+ 1. Decimal start with 6+ 1. Lower alpha with paren Autonumbering: - 1. Autonumber.- 1. More.- 1. Nested.+1. Autonumber.+2. More.+ 1. Nested. Should not be a list item: @@ -291,8 +291,8 @@ * **orange** orange fruit - 1. sublist- 1. sublist+1. sublist+2. sublist ====== HTML Blocks ====== @@ -435,21 +435,21 @@ ====== LaTeX ====== - * - * $2+2=4$- * $x \in y$- * $\alpha \wedge \omega$- * $223$- * $p$-Tree- * Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$- * Here’s one that has a line break in it: $\alpha + \omega \times x^2$.+* +* $2+2=4$+* $x \in y$+* $\alpha \wedge \omega$+* $223$+* $p$-Tree+* Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$+* Here’s one that has a line break in it: $\alpha + \omega \times x^2$. These shouldn’t be math: - * To get the famous equation, write ''$e = mc^2$''.- * $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.)- * Shoes ($20) and socks ($5).- * Escaped ''$'': $73 //this should be emphasized// 23$.+* 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: @@ -461,11 +461,11 @@ Here is some unicode: - * I hat: Î- * o umlaut: ö- * section: §- * set membership: ∈- * copyright: ©+* I hat: Î+* o umlaut: ö+* section: §+* set membership: ∈+* copyright: © AT&T has an ampersand in their name. @@ -572,9 +572,9 @@ With an ampersand: http://example.com/?foo=1&bar=2 - * In a list?- * http://example.com/- * It should.+* In a list?+* http://example.com/+* It should. An e-mail address: <nobody@nowhere.net> @@ -614,6 +614,6 @@ > Notes can go in quotes. **{Note:** In quote.**}** - 1. And in list items. **{Note:** In list.**}**+1. And in list items. **{Note:** In list.**}** This paragraph should not be part of the note, as it is not indented.